mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-27 19:52:49 +00:00
98 lines
2.9 KiB
TypeScript
98 lines
2.9 KiB
TypeScript
import type { AgentToolDefinition } from "./agent-tools.js";
|
|
import type {
|
|
AgentPermissionRequest,
|
|
AgentPermissionResponse,
|
|
AgentTimelineItem,
|
|
AgentSessionConfig,
|
|
} from "@getpaseo/protocol/agent-types";
|
|
import type { PaseoApi } from "@getpaseo/client";
|
|
import type { WorkspaceCreateRequest } from "@getpaseo/protocol/messages";
|
|
|
|
export interface PluginHookContext {
|
|
paseo: PaseoApi;
|
|
signal: AbortSignal;
|
|
}
|
|
|
|
export interface PluginHookWorkspace {
|
|
id: string;
|
|
projectId: string;
|
|
cwd: string;
|
|
name: string | null;
|
|
archivedAt: string | null;
|
|
}
|
|
|
|
export interface PluginHookAgent {
|
|
id: string;
|
|
workspaceId: string | null;
|
|
parentAgentId: string | null;
|
|
provider: string;
|
|
cwd: string;
|
|
title: string | null;
|
|
}
|
|
|
|
export interface PluginSessionOpenRequest {
|
|
agentId: string;
|
|
workspaceId: string | null;
|
|
provider: string;
|
|
cwd: string;
|
|
reason: "create" | "resume" | "refresh" | "import";
|
|
purpose: "interactive" | "history";
|
|
readonly title: string | null;
|
|
readonly labels: Readonly<Record<string, string>>;
|
|
tools: AgentToolDefinition[];
|
|
env: Record<string, string>;
|
|
}
|
|
|
|
export type PluginTurnOutcome =
|
|
| { kind: "completed" }
|
|
| { kind: "failed"; error: { message: string; code?: string } }
|
|
| { kind: "canceled"; reason: string };
|
|
|
|
export interface PluginLifecycleEvents {
|
|
"agent.turn_started": { agent: PluginHookAgent; turnId: string | null };
|
|
"agent.turn_ended": {
|
|
agent: PluginHookAgent;
|
|
turnId: string | null;
|
|
outcome: PluginTurnOutcome;
|
|
/**
|
|
* @deprecated Always empty. Fetch history on demand with
|
|
* context.paseo.agents.ref(agent.id).timeline.refetch({ direction: "tail", limit: 20 }).
|
|
*/
|
|
timeline: readonly AgentTimelineItem[];
|
|
};
|
|
"agent.permission_requested": { agent: PluginHookAgent; request: AgentPermissionRequest };
|
|
"agent.permission_resolved": {
|
|
agent: PluginHookAgent;
|
|
requestId: string;
|
|
resolution: AgentPermissionResponse;
|
|
};
|
|
"agent.archived": { agent: PluginHookAgent; archivedAt: string };
|
|
"agent.created": { agent: PluginHookAgent };
|
|
"agent.closed": { agent: PluginHookAgent };
|
|
"workspace.created": { workspace: PluginHookWorkspace };
|
|
"workspace.archived": { workspace: PluginHookWorkspace };
|
|
}
|
|
|
|
export interface PluginBeforeRequests {
|
|
"agent.create": { config: AgentSessionConfig; env?: Record<string, string> };
|
|
"agent.session_open": PluginSessionOpenRequest;
|
|
"workspace.create": Omit<WorkspaceCreateRequest, "type" | "requestId">;
|
|
}
|
|
|
|
export interface PluginLifecycleRegistration {
|
|
on<Name extends keyof PluginLifecycleEvents>(
|
|
name: Name,
|
|
handler: (
|
|
event: PluginLifecycleEvents[Name],
|
|
context: PluginHookContext,
|
|
) => void | Promise<void>,
|
|
): () => void;
|
|
before<Name extends keyof PluginBeforeRequests>(
|
|
name: Name,
|
|
handler: (
|
|
input: { request: PluginBeforeRequests[Name] },
|
|
context: PluginHookContext,
|
|
) => PluginBeforeRequests[Name] | void | Promise<PluginBeforeRequests[Name] | void>,
|
|
): () => void;
|
|
}
|