Make local plugins manageable and debuggable (#3446)
* feat(plugins): expose Paseo API to local plugins Plugin surfaces borrow the selected host connection while subprocess handlers receive an exclusively owned IPC session, so plugins can use normal workspace and agent operations without inventing another transport. * feat(plugins): reload global enablement safely Treat the global plugin switch as a live daemon setting and teach plugin automation to inspect it before acting. Enabling remains permission-gated because plugin backend code can access the daemon machine and client contributions execute inside the app. * feat(plugins): expose plugin logs Capture plugin stdout and stderr separately from IPC so authors can debug initialization, RPC, cleanup, and crash behavior from the app or CLI. Keep a bounded tail across lifecycle recovery while preserving structured output in the daemon log. * fix(build): order plugin dependency builds * test(plugins): align startup and CLI expectations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { afterEach, expect, test, vi } from "vitest";
|
||||
import { createPaseoClient } from "./index.js";
|
||||
import { createPaseoApi, createPaseoClient } from "./index.js";
|
||||
import { DaemonClient } from "./daemon-client.js";
|
||||
import type { PaseoAgent, PaseoClient, PaseoWorkspace } from "./index.js";
|
||||
|
||||
type FakeWebSocketHandler = (...args: unknown[]) => void;
|
||||
@@ -214,6 +215,20 @@ test("createPaseoClient exposes workspace list through the daemon client", async
|
||||
await client.close();
|
||||
});
|
||||
|
||||
test("createPaseoApi borrows daemon capabilities without exposing connection ownership", () => {
|
||||
const daemonClient = new DaemonClient({
|
||||
url: "ws://daemon.test",
|
||||
clientId: "borrowed-api",
|
||||
reconnect: { enabled: false },
|
||||
});
|
||||
|
||||
const paseo = createPaseoApi(daemonClient);
|
||||
|
||||
expect(Object.keys(paseo).sort()).toEqual(["agents", "config", "providers", "workspaces"]);
|
||||
expect("connect" in paseo).toBe(false);
|
||||
expect("close" in paseo).toBe(false);
|
||||
});
|
||||
|
||||
test("agent actions list the daemon directory without exposing the low-level client", async () => {
|
||||
const { client, ws } = await connectClient();
|
||||
const listedAgent = createAgent({ title: "Planner" });
|
||||
@@ -375,18 +390,28 @@ test("workspace handles keep identity and refresh snapshots through existing dri
|
||||
await client.close();
|
||||
});
|
||||
|
||||
test("workspace create is fresh and workspace-scoped agent create owns placement", async () => {
|
||||
test("plugin-shaped PR workspace create and agent create use the existing daemon RPCs", async () => {
|
||||
const { client, ws } = await connectClient();
|
||||
const createdWorkspace = createWorkspace({ id: "workspace_fresh", name: "Issue 42" });
|
||||
|
||||
const workspacePromise = client.workspaces.create({
|
||||
source: { kind: "directory", path: "/repo/sdk", projectId: "project_sdk" },
|
||||
source: {
|
||||
kind: "worktree",
|
||||
cwd: "/repo/sdk",
|
||||
action: "checkout",
|
||||
checkoutSource: { kind: "change_request", forge: "github", number: 42 },
|
||||
},
|
||||
title: "Issue 42",
|
||||
});
|
||||
const workspaceRequest = parseSentSessionMessage(ws.sent.at(-1));
|
||||
expect(workspaceRequest).toMatchObject({
|
||||
type: "workspace.create.request",
|
||||
source: { kind: "directory", path: "/repo/sdk", projectId: "project_sdk" },
|
||||
source: {
|
||||
kind: "worktree",
|
||||
cwd: "/repo/sdk",
|
||||
action: "checkout",
|
||||
checkoutSource: { kind: "change_request", forge: "github", number: 42 },
|
||||
},
|
||||
title: "Issue 42",
|
||||
});
|
||||
ws.message(
|
||||
|
||||
Reference in New Issue
Block a user