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:
@@ -2,17 +2,20 @@ import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
|
||||
import type { CommandError } from "../../output/index.js";
|
||||
import { connectToDaemon } from "../../utils/client.js";
|
||||
|
||||
export async function withPluginManagementClient<T>(
|
||||
type PluginFeature = "pluginManagement" | "pluginLogs";
|
||||
|
||||
async function withPluginClient<T>(
|
||||
host: string | undefined,
|
||||
feature: PluginFeature,
|
||||
updateMessage: string,
|
||||
run: (client: DaemonClient) => Promise<T>,
|
||||
): Promise<T> {
|
||||
const client = await connectToDaemon({ host });
|
||||
// COMPAT(pluginManagement): added in v0.3.1, remove gate after 2027-08-14.
|
||||
if (client.getLastServerInfoMessage()?.features?.pluginManagement !== true) {
|
||||
if (client.getLastServerInfoMessage()?.features?.[feature] !== true) {
|
||||
await client.close().catch(() => undefined);
|
||||
throw {
|
||||
code: "DAEMON_UPDATE_REQUIRED",
|
||||
message: "Update the host to use plugin management.",
|
||||
message: updateMessage,
|
||||
} satisfies CommandError;
|
||||
}
|
||||
try {
|
||||
@@ -21,3 +24,24 @@ export async function withPluginManagementClient<T>(
|
||||
await client.close().catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
export async function withPluginManagementClient<T>(
|
||||
host: string | undefined,
|
||||
run: (client: DaemonClient) => Promise<T>,
|
||||
): Promise<T> {
|
||||
// COMPAT(pluginManagement): added in v0.3.1, remove gate after 2027-08-14.
|
||||
return withPluginClient(
|
||||
host,
|
||||
"pluginManagement",
|
||||
"Update the host to use plugin management.",
|
||||
run,
|
||||
);
|
||||
}
|
||||
|
||||
export async function withPluginLogsClient<T>(
|
||||
host: string | undefined,
|
||||
run: (client: DaemonClient) => Promise<T>,
|
||||
): Promise<T> {
|
||||
// COMPAT(pluginLogs): added in v0.4.0, remove gate after 2027-08-16.
|
||||
return withPluginClient(host, "pluginLogs", "Update the host to view plugin logs.", run);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user