* feat(plugins): add local plugin surfaces and RPCs Keep plugin execution scoped to its daemon while allowing one local TypeScript entry point to contribute validated RPCs and native client surfaces. Paseo owns host selection, navigation chrome, and per-installation query caches. * feat(plugins): add Linear attachment source * fix(nix): refresh npm dependency hash * test(server): exclude internal sessions from Hub counts * test(server): distinguish Hub execution sessions * feat(plugins): make local plugins explicitly opt-in Keep plugin loading dormant until configuration enables it, and collect unsupported examples under one directory. * refactor(plugins): establish host boundaries * fix(nix): refresh plugin dependency hash * fix(plugins): complete packaging and startup rollback * feat(plugins): add managed local lifecycle Make trusted local plugins recoverable and authorable through daemon-owned lifecycle operations, host settings, and a capability-gated CLI. Reloads fully stop the previous plugin before starting new code, while generated projects provide strict TSX checking without changing runtime dependency ownership. * fix(nix): refresh plugin dependency hash
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import type { ZodType, input as ZodInput, output as ZodOutput } from "zod";
|
|
|
|
export interface PluginRpcContract<
|
|
InputSchema extends ZodType = ZodType,
|
|
OutputSchema extends ZodType = ZodType,
|
|
> {
|
|
name: string;
|
|
input: InputSchema;
|
|
output: OutputSchema;
|
|
}
|
|
|
|
interface RpcDefinition<InputSchema extends ZodType, OutputSchema extends ZodType> {
|
|
name: string;
|
|
input: InputSchema;
|
|
output: OutputSchema;
|
|
}
|
|
|
|
const RPC_NAME = /^[a-z][a-z0-9._-]*$/;
|
|
|
|
export function defineRpc<InputSchema extends ZodType, OutputSchema extends ZodType>(
|
|
definition: RpcDefinition<InputSchema, OutputSchema>,
|
|
): PluginRpcContract<InputSchema, OutputSchema> {
|
|
const name = definition.name.trim();
|
|
if (!RPC_NAME.test(name)) throw new Error(`Invalid plugin RPC method: ${definition.name}`);
|
|
return { ...definition, name };
|
|
}
|
|
|
|
export async function callPluginRpc<InputSchema extends ZodType, OutputSchema extends ZodType>(
|
|
contract: PluginRpcContract<InputSchema, OutputSchema>,
|
|
invoke: (method: string, input: unknown) => Promise<unknown>,
|
|
input: ZodInput<InputSchema>,
|
|
): Promise<ZodOutput<OutputSchema>> {
|
|
const parsedInput = await contract.input.parseAsync(input);
|
|
const output = await invoke(contract.name, parsedInput);
|
|
return contract.output.parseAsync(output);
|
|
}
|