@poe-platform/safe-js 0.1.656 → 0.1.658

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ import { type dashboard } from "../toolcraft-design/index.js";
2
+ import type { RunQueue } from "./run-queue.js";
3
+ /** One view for an entire harness sequence, including work added while it runs. */
4
+ export declare function createHarnessDashboard(options: {
5
+ title: string;
6
+ agent: string;
7
+ model?: string;
8
+ cwd: string;
9
+ queue: RunQueue;
10
+ validatePlan?: (path: string) => Promise<string>;
11
+ }): {
12
+ dashboard: dashboard.Dashboard;
13
+ start(): void;
14
+ updateRun(update: Partial<dashboard.DashboardRunState>): void;
15
+ addUsage(usage: {
16
+ inputTokens: number;
17
+ outputTokens: number;
18
+ }): void;
19
+ dispose(): void;
20
+ };
21
+ export type HarnessDashboard = ReturnType<typeof createHarnessDashboard>;
@@ -8,11 +8,15 @@ export { runWorkflowHook, type HookContext, type RunAgentFn, type RunAgentHooks,
8
8
  export { runWorkflowStage, type StageContext, type WorkflowStage } from "./stage.js";
9
9
  export { runDocumentWorkflow, type DocumentWorkflowOptions, type IterationResult, type WorkflowFileStat, type WorkflowFileSystem } from "./runner.js";
10
10
  export { runDocumentWorkflowSequence, type DocumentWorkflowSequenceOptions } from "./sequence.js";
11
+ export { createRunQueue, type RunQueue, type RunQueueItem, type RunQueueItemStatus, type RunQueueOutcome, type RunQueueSnapshot } from "./run-queue.js";
11
12
  export { ensureSafeRunLogDir, makeRunLogFileName, resolveRunLogDir, slugifyPlanPath, type RunLogFileSystem, type ResolveRunLogDirOptions } from "./run-logs.js";
12
13
  export { streamLogFile, waitForExit, wrapForLogTee, type LogStreamEnv, type LogStreamFs } from "./log-stream.js";
13
14
  export { createPoeCommandSession, runPoeCommand, type PoeCommandSession } from "./run-poe-command.js";
14
15
  export { createBinaryExistsDetectors, type BinaryExistsDetector, type BinaryExistsDetectorResult } from "./binary-exists.js";
15
16
  export { applyRuntimeOverrides, resolvePoeCommandExecution, UnsupportedRuntimeCapabilityError, type RuntimeOverrideOptions } from "./poe-command-execution.js";
16
17
  export { skillPlanConfigSection } from "./skill-config.js";
18
+ export { createHarnessDashboard, type HarnessDashboard } from "./harness-dashboard.js";
19
+ export { mapSourcePathIntoWorktree } from "./worktree-path.js";
20
+ export { formatRunQueueSummary } from "./run-queue-summary.js";
17
21
  export * from "./execution-env.js";
18
22
  export * from "./workspace-transfer.js";
@@ -31,5 +31,5 @@ export interface OpenPlanListOptions {
31
31
  }
32
32
  export declare function parsePlanReadiness(value: unknown): PlanReadiness;
33
33
  export declare function discoverPlans(options: DiscoverPlansOptions): Promise<PlanRef[]>;
34
- export declare const archivePlan: (options: ArchivePlanOptions) => Promise<void>;
34
+ export declare const archivePlan: (options: ArchivePlanOptions) => Promise<string>;
35
35
  export declare function openPlanList(options: OpenPlanListOptions): Promise<TaskList>;
@@ -0,0 +1,2 @@
1
+ import type { RunQueueSnapshot } from "./run-queue.js";
2
+ export declare function formatRunQueueSummary(snapshot: RunQueueSnapshot): string;
@@ -0,0 +1,38 @@
1
+ export type RunQueueOutcome = "completed" | "failed" | "cancelled" | "paused";
2
+ export type RunQueueItemStatus = "pending" | "running" | RunQueueOutcome;
3
+ export type RunQueueItem = Readonly<{
4
+ id: string;
5
+ status: RunQueueItemStatus;
6
+ } & ({
7
+ kind: "plan";
8
+ path: string;
9
+ } | {
10
+ kind: "message";
11
+ text: string;
12
+ afterPlanId: string;
13
+ })>;
14
+ export type RunQueueSnapshot = Readonly<{
15
+ status: "idle" | "running" | RunQueueOutcome;
16
+ items: readonly RunQueueItem[];
17
+ activePlanId?: string;
18
+ activeItemId?: string;
19
+ }>;
20
+ export type RunQueue = ReturnType<typeof createRunQueue>;
21
+ /** A live, ordered sequence shared by harness runtimes and their interactive views. */
22
+ export declare function createRunQueue(options: {
23
+ plans: readonly string[];
24
+ afterEachPlan?: readonly string[];
25
+ cwd?: string;
26
+ }): {
27
+ getSnapshot: () => RunQueueSnapshot;
28
+ enqueuePlan: (planPath: string) => string;
29
+ enqueueValidatedPlan: (planPath: string, validate: (path: string) => Promise<string>) => Promise<string>;
30
+ enqueueMessage: (text: string, afterPlanId?: string) => string;
31
+ onChange(listener: (snapshot: RunQueueSnapshot) => void): () => void;
32
+ run: (runtime: {
33
+ signal?: AbortSignal;
34
+ /** Stop between items, preserving already completed and still pending work. */
35
+ shouldPause?: () => boolean;
36
+ execute(item: RunQueueItem): Promise<RunQueueOutcome>;
37
+ }) => Promise<RunQueueSnapshot>;
38
+ };
@@ -0,0 +1,2 @@
1
+ /** Keep repository-absolute paths inside the selected execution worktree. */
2
+ export declare function mapSourcePathIntoWorktree(sourceCwd: string, sourcePath: string, worktreeCwd: string): string;
@@ -6,6 +6,7 @@ export interface SessionToolCall {
6
6
  title?: string;
7
7
  input?: unknown;
8
8
  path?: string;
9
+ status?: "completed" | "failed" | "cancelled";
9
10
  }
10
11
  export interface SessionResult {
11
12
  output: string;
@@ -16,6 +16,7 @@
16
16
  * TODO: Consider full ACP alignment (JSON-RPC, official discriminators, `execute` tool kind) if we need
17
17
  * interop with Zed/JetBrains/other ACP clients.
18
18
  */
19
+ import type { Plan } from "../../poe-acp-client/index.js";
19
20
  export type ToolKind = "read" | "edit" | "delete" | "move" | "search" | "execute" | "think" | "fetch" | "switch_mode" | "other";
20
21
  /** ACP-compatible type - @see https://agentclientprotocol.com/ - no package dependency, structural compatibility only */
21
22
  export type ToolCallStatus = "pending" | "in_progress" | "completed" | "failed" | "cancelled";
@@ -118,6 +119,7 @@ export interface ToolStartEvent {
118
119
  kind: string;
119
120
  title: string;
120
121
  id?: string;
122
+ input?: unknown;
121
123
  _meta?: Record<string, unknown>;
122
124
  }
123
125
  /**
@@ -131,6 +133,7 @@ export interface ToolCompleteEvent {
131
133
  kind: string;
132
134
  path: string;
133
135
  id?: string;
136
+ status?: "completed" | "failed" | "cancelled";
134
137
  _meta?: Record<string, unknown>;
135
138
  }
136
139
  export interface ReasoningEvent {
@@ -138,6 +141,13 @@ export interface ReasoningEvent {
138
141
  text: string;
139
142
  _meta?: Record<string, unknown>;
140
143
  }
144
+ /** An agent's own checklist, separate from harness tasks and queued plan files. */
145
+ export interface PlanEvent {
146
+ event: "plan";
147
+ id?: string;
148
+ entries: Plan["entries"];
149
+ _meta?: Record<string, unknown>;
150
+ }
141
151
  export interface UsageEvent {
142
152
  event: "usage";
143
153
  inputTokens: number;
@@ -173,7 +183,7 @@ export interface SpawnResultEvent {
173
183
  protocolVersion?: number;
174
184
  _meta?: Record<string, unknown>;
175
185
  }
176
- export type KnownAcpEvent = SessionStartEvent | AgentMessageEvent | ToolStartEvent | ToolCompleteEvent | ReasoningEvent | UsageEvent | ErrorEvent | PermissionRejectedEvent | SpawnResultEvent;
186
+ export type KnownAcpEvent = SessionStartEvent | AgentMessageEvent | ToolStartEvent | ToolCompleteEvent | ReasoningEvent | PlanEvent | UsageEvent | ErrorEvent | PermissionRejectedEvent | SpawnResultEvent;
177
187
  export type UnknownAcpEvent = {
178
188
  event: string;
179
189
  } & Record<string, unknown>;
@@ -0,0 +1,144 @@
1
+ import { AcpTransport, type AcpTransportClosedEvent, type AcpTransportOptions } from "./acp-transport.js";
2
+ import type { JsonRpcRequestOptions } from "./jsonrpc-message-layer.js";
3
+ import { type AgentCapabilities, type AuthenticateResponse, type AuthMethod, type ClientCapabilities, type ContentBlock, type EnvVariable, type Implementation, type InitializeResponse, type LoadSessionResponse, type McpServer, type NewSessionResponse, type PermissionOption, type PromptResponse, type RequestId, type SessionConfigId, type SessionConfigOption, type SessionConfigValueId, type RequestPermissionOutcome, type ProtocolVersion, type SessionModeId, type SessionId, type SetSessionModeResponse, type SessionUpdateNotification, type ToolCallUpdate, type TerminalOutputResponse, type WaitForTerminalExitResponse } from "./types.js";
4
+ export type AcpClientState = "uninitialized" | "initialized" | "ready";
5
+ type ExtensionMethod = `_${string}`;
6
+ export interface PromptTurn extends AsyncIterable<SessionUpdateNotification> {
7
+ response: Promise<PromptResponse>;
8
+ }
9
+ export interface AcpClientFsHandler {
10
+ readTextFile?: (args: {
11
+ sessionId: SessionId;
12
+ path: string;
13
+ line?: number | null;
14
+ limit?: number | null;
15
+ }) => string | Promise<string>;
16
+ writeTextFile?: (args: {
17
+ sessionId: SessionId;
18
+ path: string;
19
+ content: string;
20
+ }) => void | Promise<void>;
21
+ }
22
+ export interface AcpClientTerminalHandler {
23
+ create: (args: {
24
+ sessionId: SessionId;
25
+ command: string;
26
+ args?: string[];
27
+ cwd?: string | null;
28
+ env?: EnvVariable[];
29
+ outputByteLimit?: number | null;
30
+ }) => string | Promise<string>;
31
+ output: (args: {
32
+ sessionId: SessionId;
33
+ terminalId: string;
34
+ }) => TerminalOutputResponse | Promise<TerminalOutputResponse>;
35
+ waitForExit: (args: {
36
+ sessionId: SessionId;
37
+ terminalId: string;
38
+ }) => WaitForTerminalExitResponse | Promise<WaitForTerminalExitResponse>;
39
+ kill: (args: {
40
+ sessionId: SessionId;
41
+ terminalId: string;
42
+ }) => void | Promise<void>;
43
+ release: (args: {
44
+ sessionId: SessionId;
45
+ terminalId: string;
46
+ }) => void | Promise<void>;
47
+ }
48
+ type AcpClientPermissionHandler = (args: {
49
+ toolCall: ToolCallUpdate;
50
+ options: PermissionOption[];
51
+ }) => RequestPermissionOutcome | Promise<RequestPermissionOutcome>;
52
+ export interface AcpClientHandlers {
53
+ permission?: AcpClientPermissionHandler;
54
+ fs?: AcpClientFsHandler;
55
+ terminal?: AcpClientTerminalHandler;
56
+ }
57
+ type AcpClientTransport = Pick<AcpTransport, "sendRequest" | "sendNotification" | "onRequest" | "onNotification"> & Partial<Pick<AcpTransport, "dispose" | "closed">>;
58
+ interface AcpClientSharedOptions {
59
+ protocolVersion?: ProtocolVersion;
60
+ clientCapabilities?: ClientCapabilities;
61
+ clientInfo?: Implementation | null;
62
+ handlers?: AcpClientHandlers;
63
+ permissionHandler?: AcpClientPermissionHandler;
64
+ fsHandler?: AcpClientFsHandler;
65
+ terminalHandler?: AcpClientTerminalHandler;
66
+ skipAuth?: boolean;
67
+ /**
68
+ * Automatically approve all permission requests (selects the first
69
+ * "allow_always" or "allow_once" option). Ignored when a custom
70
+ * `permissionHandler` is provided.
71
+ */
72
+ autoApprove?: boolean;
73
+ }
74
+ export interface AcpClientProcessOptions extends AcpClientSharedOptions {
75
+ command: string;
76
+ args?: readonly string[];
77
+ cwd?: string;
78
+ env?: NodeJS.ProcessEnv;
79
+ firstRequestId?: number;
80
+ spawn?: AcpTransportOptions["spawn"];
81
+ }
82
+ export interface AcpClientInjectedTransportOptions extends AcpClientSharedOptions {
83
+ transport: AcpClientTransport;
84
+ }
85
+ export type AcpClientOptions = AcpClientProcessOptions | AcpClientInjectedTransportOptions;
86
+ export declare class AcpClient {
87
+ private readonly transport;
88
+ private readonly clientProtocolVersion;
89
+ private clientCapabilities?;
90
+ private readonly clientInfo?;
91
+ private readonly skipAuth;
92
+ private readonly permissionHandler?;
93
+ private readonly fsHandler?;
94
+ private readonly terminalHandler?;
95
+ private readonly activePromptUpdates;
96
+ private readonly trackedTerminalIds;
97
+ private hasRegisteredFsReadHandler;
98
+ private hasRegisteredFsWriteHandler;
99
+ private hasRegisteredTerminalHandlers;
100
+ private disposed;
101
+ private transportDisposed;
102
+ private initializing;
103
+ private authenticating;
104
+ private lifecycleState;
105
+ private negotiatedVersion;
106
+ private availableAuthMethods;
107
+ private negotiatedAgentCapabilities;
108
+ private negotiatedAgentInfo;
109
+ constructor(options: AcpClientOptions);
110
+ get state(): AcpClientState;
111
+ get negotiatedProtocolVersion(): ProtocolVersion | null;
112
+ get authMethods(): AuthMethod[];
113
+ get agentCapabilities(): AgentCapabilities | undefined;
114
+ get agentInfo(): Implementation | null | undefined;
115
+ get closed(): Promise<AcpTransportClosedEvent> | undefined;
116
+ initialize(clientCapabilities?: ClientCapabilities): Promise<InitializeResponse>;
117
+ authenticate(methodId: string): Promise<AuthenticateResponse>;
118
+ newSession(cwd: string, mcpServers: McpServer[]): Promise<NewSessionResponse>;
119
+ loadSession(sessionId: SessionId, cwd: string, mcpServers: McpServer[]): Promise<LoadSessionResponse>;
120
+ cancelSession(sessionId: SessionId): Promise<void>;
121
+ setMode(sessionId: SessionId, modeId: SessionModeId): Promise<SetSessionModeResponse>;
122
+ setConfigOption(sessionId: SessionId, configId: SessionConfigId, value: SessionConfigValueId): Promise<SessionConfigOption[]>;
123
+ prompt(sessionId: SessionId, content: ContentBlock[]): PromptTurn;
124
+ sendExtRequest<TResult = unknown>(method: ExtensionMethod, params?: unknown, options?: JsonRpcRequestOptions): Promise<TResult>;
125
+ sendExtNotification(method: ExtensionMethod, params?: unknown): Promise<void>;
126
+ onExtRequest<TMethod extends ExtensionMethod>(method: TMethod, handler: (params: unknown, context: {
127
+ id: RequestId;
128
+ method: TMethod;
129
+ }) => unknown | Promise<unknown>): void;
130
+ onExtNotification<TMethod extends ExtensionMethod>(method: TMethod, handler: (params: unknown, context: {
131
+ method: TMethod;
132
+ }) => void | Promise<void>): void;
133
+ dispose(): Promise<void>;
134
+ assertReady(operation: string): void;
135
+ private assertNotDisposed;
136
+ private registerCapabilityHandlers;
137
+ private assertMcpServerCapabilitySupport;
138
+ private handleSessionUpdateNotification;
139
+ private trackTerminal;
140
+ private assertKnownTerminal;
141
+ private untrackTerminal;
142
+ private assertPromptContentCapabilitySupport;
143
+ }
144
+ export {};
@@ -0,0 +1,93 @@
1
+ import { type ChildProcessWithoutNullStreams, type SpawnOptionsWithoutStdio } from "node:child_process";
2
+ import { type JsonRpcNotificationHandler, type JsonRpcRequestHandler, type JsonRpcRequestOptions } from "./jsonrpc-message-layer.js";
3
+ import type { AuthenticateRequest, AuthenticateResponse, CancelNotification, CreateTerminalRequest, CreateTerminalResponse, InitializeRequest, InitializeResponse, KillTerminalCommandRequest, KillTerminalCommandResponse, LoadSessionRequest, LoadSessionResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, ReleaseTerminalRequest, ReleaseTerminalResponse, RequestId, RequestPermissionRequest, RequestPermissionResponse, SessionNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, TerminalOutputRequest, TerminalOutputResponse, WaitForTerminalExitRequest, WaitForTerminalExitResponse, WriteTextFileRequest, WriteTextFileResponse } from "./types.js";
4
+ interface AcpRequestShape<TParams, TResult> {
5
+ params: TParams;
6
+ result: TResult;
7
+ }
8
+ export interface AcpAgentRequestMap {
9
+ initialize: AcpRequestShape<InitializeRequest, InitializeResponse>;
10
+ authenticate: AcpRequestShape<AuthenticateRequest, AuthenticateResponse>;
11
+ "session/new": AcpRequestShape<NewSessionRequest, NewSessionResponse>;
12
+ "session/load": AcpRequestShape<LoadSessionRequest, LoadSessionResponse>;
13
+ "session/prompt": AcpRequestShape<PromptRequest, PromptResponse>;
14
+ "session/set_mode": AcpRequestShape<SetSessionModeRequest, SetSessionModeResponse>;
15
+ "session/set_config_option": AcpRequestShape<SetSessionConfigOptionRequest, SetSessionConfigOptionResponse>;
16
+ }
17
+ export interface AcpAgentNotificationMap {
18
+ "session/cancel": CancelNotification;
19
+ }
20
+ export interface AcpClientRequestMap {
21
+ "session/request_permission": AcpRequestShape<RequestPermissionRequest, RequestPermissionResponse>;
22
+ "fs/read_text_file": AcpRequestShape<ReadTextFileRequest, ReadTextFileResponse>;
23
+ "fs/write_text_file": AcpRequestShape<WriteTextFileRequest, WriteTextFileResponse>;
24
+ "terminal/create": AcpRequestShape<CreateTerminalRequest, CreateTerminalResponse>;
25
+ "terminal/output": AcpRequestShape<TerminalOutputRequest, TerminalOutputResponse>;
26
+ "terminal/wait_for_exit": AcpRequestShape<WaitForTerminalExitRequest, WaitForTerminalExitResponse>;
27
+ "terminal/kill": AcpRequestShape<KillTerminalCommandRequest, KillTerminalCommandResponse>;
28
+ "terminal/release": AcpRequestShape<ReleaseTerminalRequest, ReleaseTerminalResponse>;
29
+ }
30
+ export interface AcpClientNotificationMap {
31
+ "session/update": SessionNotification;
32
+ }
33
+ type ExtensionMethod = `_${string}`;
34
+ type SpawnFunction = (command: string, args?: ReadonlyArray<string>, options?: SpawnOptionsWithoutStdio) => ChildProcessWithoutNullStreams;
35
+ export interface AcpTransportOptions {
36
+ command: string;
37
+ args?: readonly string[];
38
+ cwd?: string;
39
+ env?: NodeJS.ProcessEnv;
40
+ firstRequestId?: number;
41
+ spawn?: SpawnFunction;
42
+ }
43
+ export interface AcpTransportClosedEvent {
44
+ code: number | null;
45
+ signal: NodeJS.Signals | null;
46
+ reason: Error;
47
+ stderr: string;
48
+ }
49
+ export declare class AcpTransport {
50
+ readonly closed: Promise<AcpTransportClosedEvent>;
51
+ private readonly command;
52
+ private readonly child;
53
+ private readonly layer;
54
+ private stderrOutput;
55
+ private static readonly STDERR_MAX_LENGTH;
56
+ private resolveClosed;
57
+ private closeEvent;
58
+ private closeReason;
59
+ private disposeStarted;
60
+ private disposeEscalationTimer;
61
+ private disposeForcedCloseTimer;
62
+ constructor(options: AcpTransportOptions);
63
+ sendRequest<TMethod extends keyof AcpAgentRequestMap>(method: TMethod, params: AcpAgentRequestMap[TMethod]["params"], options?: JsonRpcRequestOptions): Promise<AcpAgentRequestMap[TMethod]["result"]>;
64
+ sendRequest<TResult = unknown>(method: string, params?: unknown, options?: JsonRpcRequestOptions): Promise<TResult>;
65
+ sendExtRequest<TResult = unknown>(method: ExtensionMethod, params?: unknown, options?: JsonRpcRequestOptions): Promise<TResult>;
66
+ sendNotification<TMethod extends keyof AcpAgentNotificationMap>(method: TMethod, params: AcpAgentNotificationMap[TMethod]): void;
67
+ sendNotification(method: string, params?: unknown): void;
68
+ sendExtNotification(method: ExtensionMethod, params?: unknown): void;
69
+ sendExtNotification(method: string, params?: unknown): void;
70
+ onRequest<TMethod extends keyof AcpClientRequestMap>(method: TMethod, handler: (params: AcpClientRequestMap[TMethod]["params"], context: {
71
+ id: RequestId;
72
+ method: TMethod;
73
+ }) => AcpClientRequestMap[TMethod]["result"] | Promise<AcpClientRequestMap[TMethod]["result"]>): void;
74
+ onRequest(method: string, handler: JsonRpcRequestHandler): void;
75
+ onExtRequest<TMethod extends ExtensionMethod>(method: TMethod, handler: (params: unknown, context: {
76
+ id: RequestId;
77
+ method: TMethod;
78
+ }) => unknown | Promise<unknown>): void;
79
+ onExtRequest(method: string, handler: JsonRpcRequestHandler): void;
80
+ onNotification<TMethod extends keyof AcpClientNotificationMap>(method: TMethod, handler: (params: AcpClientNotificationMap[TMethod], context: {
81
+ method: TMethod;
82
+ }) => void | Promise<void>): void;
83
+ onNotification(method: string, handler: JsonRpcNotificationHandler): void;
84
+ onExtNotification<TMethod extends ExtensionMethod>(method: TMethod, handler: (params: unknown, context: {
85
+ method: TMethod;
86
+ }) => void | Promise<void>): void;
87
+ onExtNotification(method: string, handler: JsonRpcNotificationHandler): void;
88
+ getStderrOutput(): string;
89
+ pendingRequestCount(): number;
90
+ dispose(reason?: Error): void;
91
+ private close;
92
+ }
93
+ export {};
@@ -0,0 +1,13 @@
1
+ export { AcpClient } from "./acp-client.js";
2
+ export { AcpTransport } from "./acp-transport.js";
3
+ export { ACP_ERROR_CODE_AUTH_REQUIRED, ACP_ERROR_CODE_INTERNAL, ACP_ERROR_CODE_INVALID_PARAMS, ACP_ERROR_CODE_INVALID_REQUEST, ACP_ERROR_CODE_METHOD_NOT_FOUND, ACP_ERROR_CODE_PARSE, ACP_ERROR_CODE_RESOURCE_NOT_FOUND, AcpError, isAcpError, isAcpErrorCode, } from "./types.js";
4
+ export { createJsonRpcErrorResponse, JsonRpcMessageLayer, parseJsonRpcMessage, serializeJsonRpcMessage, } from "./jsonrpc-message-layer.js";
5
+ export { formatSessionUpdate, parseSessionUpdate } from "./jsonrpc.js";
6
+ export { formatRunReportSummary, generateRunReportFromSessionUpdateStream, saveRunReport, } from "./run-report.js";
7
+ export { extractMessagesFromSessionUpdateStream, extractToolCallSummariesFromSessionUpdateStream, extractUsageFromSessionUpdateStream, mapLegacyEventToSessionUpdates, } from "./stream-helpers.js";
8
+ export type { AcpClientFsHandler, AcpClientHandlers, AcpClientInjectedTransportOptions, AcpClientOptions, AcpClientProcessOptions, AcpClientState, AcpClientTerminalHandler, PromptTurn, } from "./acp-client.js";
9
+ export type { AcpAgentNotificationMap, AcpAgentRequestMap, AcpClientNotificationMap, AcpClientRequestMap, AcpTransportClosedEvent, AcpTransportOptions, } from "./acp-transport.js";
10
+ export type { JsonRpcErrorObject, JsonRpcErrorResponseMessage, JsonRpcMessageLayerOptions, JsonRpcNotificationHandler, JsonRpcNotificationMessage, JsonRpcOutgoingMessage, JsonRpcRequestHandler, JsonRpcRequestMessage, JsonRpcRequestOptions, JsonRpcResponseMessage, JsonRpcSuccessResponseMessage, ParsedJsonRpcMessage, } from "./jsonrpc-message-layer.js";
11
+ export type { GenerateRunReportOptions, RunExitStatus, RunReport, RunReportError, RunReportFileSystem, RunReportUsage, SaveRunReportOptions, SavedRunReportPaths, } from "./run-report.js";
12
+ export type { LegacyInternalEvent, ToolCallSummary } from "./stream-helpers.js";
13
+ export type * from "./types.js";
@@ -0,0 +1,85 @@
1
+ import type { Readable, Writable } from "node:stream";
2
+ import { AcpError, type RequestId } from "./types.js";
3
+ export interface JsonRpcRequestMessage {
4
+ jsonrpc: "2.0";
5
+ id: RequestId;
6
+ method: string;
7
+ params?: unknown;
8
+ }
9
+ export interface JsonRpcNotificationMessage {
10
+ jsonrpc: "2.0";
11
+ method: string;
12
+ params?: unknown;
13
+ }
14
+ export interface JsonRpcErrorObject {
15
+ code: number;
16
+ message: string;
17
+ data?: unknown;
18
+ }
19
+ export interface JsonRpcSuccessResponseMessage {
20
+ jsonrpc: "2.0";
21
+ id: RequestId;
22
+ result: unknown;
23
+ }
24
+ export interface JsonRpcErrorResponseMessage {
25
+ jsonrpc: "2.0";
26
+ id: RequestId;
27
+ error: JsonRpcErrorObject;
28
+ }
29
+ export type JsonRpcResponseMessage = JsonRpcSuccessResponseMessage | JsonRpcErrorResponseMessage;
30
+ export type JsonRpcOutgoingMessage = JsonRpcRequestMessage | JsonRpcNotificationMessage | JsonRpcResponseMessage;
31
+ export type ParsedJsonRpcMessage = {
32
+ type: "request";
33
+ message: JsonRpcRequestMessage;
34
+ } | {
35
+ type: "notification";
36
+ message: JsonRpcNotificationMessage;
37
+ } | {
38
+ type: "response";
39
+ message: JsonRpcResponseMessage;
40
+ } | {
41
+ type: "invalid";
42
+ id: RequestId;
43
+ error: AcpError;
44
+ };
45
+ export interface JsonRpcRequestOptions {
46
+ id?: RequestId;
47
+ }
48
+ export interface JsonRpcMessageLayerOptions {
49
+ input: Readable;
50
+ output: Writable;
51
+ firstRequestId?: number;
52
+ }
53
+ export type JsonRpcRequestHandler = (params: unknown, context: {
54
+ id: RequestId;
55
+ method: string;
56
+ }) => Promise<unknown> | unknown;
57
+ export type JsonRpcNotificationHandler = (params: unknown, context: {
58
+ method: string;
59
+ }) => Promise<void> | void;
60
+ export declare function createJsonRpcErrorResponse(id: RequestId, error: AcpError): JsonRpcErrorResponseMessage;
61
+ export declare function serializeJsonRpcMessage(message: JsonRpcOutgoingMessage): string;
62
+ export declare function parseJsonRpcMessage(line: string): ParsedJsonRpcMessage;
63
+ export declare class JsonRpcMessageLayer {
64
+ private readonly input;
65
+ private readonly output;
66
+ private readonly requestHandlers;
67
+ private readonly notificationHandlers;
68
+ private readonly pending;
69
+ private nextRequestId;
70
+ private disposed;
71
+ constructor(options: JsonRpcMessageLayerOptions);
72
+ onRequest(method: string, handler: JsonRpcRequestHandler): void;
73
+ onNotification(method: string, handler: JsonRpcNotificationHandler): void;
74
+ pendingRequestCount(): number;
75
+ sendNotification(method: string, params?: unknown): void;
76
+ sendRequest(method: string, params?: unknown, options?: JsonRpcRequestOptions): Promise<unknown>;
77
+ dispose(reason?: Error): void;
78
+ private consumeInput;
79
+ private handleIncomingLine;
80
+ private handleResponse;
81
+ private handleRequest;
82
+ private handleNotification;
83
+ private sendMessage;
84
+ private rejectAllPending;
85
+ }
@@ -0,0 +1,5 @@
1
+ import type { AcpMeta, Plan, SessionNotification, SessionUpdate, SessionUpdateNotification } from "./types.js";
2
+ export declare function isPlan(value: unknown): value is Plan;
3
+ export declare function isSessionNotification(value: unknown): value is SessionNotification;
4
+ export declare function formatSessionUpdate(sessionId: string, update: SessionUpdate, meta?: AcpMeta): string;
5
+ export declare function parseSessionUpdate(notificationLine: string): SessionUpdateNotification | null;
@@ -0,0 +1,60 @@
1
+ import { type ToolCallSummary } from "./stream-helpers.js";
2
+ import type { Cost, SessionUpdate, SessionUpdateNotification } from "./types.js";
3
+ type SessionUpdateStreamItem = SessionUpdateNotification | SessionUpdate;
4
+ export type RunExitStatus = "success" | "failed";
5
+ export interface RunReportUsage {
6
+ used: number;
7
+ size: number;
8
+ updates: number;
9
+ cost?: Cost | null;
10
+ }
11
+ export interface RunReportError {
12
+ message: string;
13
+ toolCallId?: string;
14
+ }
15
+ export interface RunReport {
16
+ runId: string;
17
+ startTime: string;
18
+ endTime: string;
19
+ exitStatus: RunExitStatus;
20
+ toolCalls: ToolCallSummary[];
21
+ usage: RunReportUsage;
22
+ errors: RunReportError[];
23
+ }
24
+ export interface GenerateRunReportOptions {
25
+ runId?: string;
26
+ startTime?: string | Date;
27
+ endTime?: string | Date;
28
+ exitStatus?: RunExitStatus;
29
+ errors?: string[];
30
+ now?: () => Date;
31
+ }
32
+ export type RunReportFileSystem = {
33
+ mkdir(path: string, options?: {
34
+ recursive?: boolean;
35
+ }): Promise<unknown>;
36
+ writeFile(path: string, data: string, options?: {
37
+ encoding?: BufferEncoding;
38
+ flag?: string;
39
+ }): Promise<void>;
40
+ rm(path: string, options?: {
41
+ force?: boolean;
42
+ }): Promise<void>;
43
+ rename?(oldPath: string, newPath: string): Promise<void>;
44
+ realpath?(path: string): Promise<string>;
45
+ };
46
+ export interface SaveRunReportOptions {
47
+ fs?: RunReportFileSystem;
48
+ homeDir?: string;
49
+ includeRawContent?: boolean;
50
+ now?: () => Date;
51
+ }
52
+ export interface SavedRunReportPaths {
53
+ reportsDir: string;
54
+ jsonPath: string;
55
+ summaryPath: string;
56
+ }
57
+ export declare function generateRunReportFromSessionUpdateStream(stream: AsyncIterable<SessionUpdateStreamItem> | Iterable<SessionUpdateStreamItem>, options?: GenerateRunReportOptions): Promise<RunReport>;
58
+ export declare function formatRunReportSummary(report: RunReport): string;
59
+ export declare function saveRunReport(report: RunReport, options?: SaveRunReportOptions): Promise<SavedRunReportPaths>;
60
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { AgentMessageChunk, AgentThoughtChunk, SessionUpdate, SessionUpdateNotification, ToolCallStatus, ToolKind, UsageUpdate, UserMessageChunk } from "./types.js";
2
+ type SessionUpdateStreamItem = SessionUpdateNotification | SessionUpdate;
3
+ type MessageUpdate = UserMessageChunk | AgentMessageChunk | AgentThoughtChunk;
4
+ export interface ToolCallSummary {
5
+ toolCallId: string;
6
+ title: string;
7
+ kind?: ToolKind;
8
+ status?: ToolCallStatus;
9
+ rawInput?: unknown;
10
+ rawOutput?: unknown;
11
+ }
12
+ export type LegacyInternalEvent = {
13
+ event: string;
14
+ } & Record<string, unknown>;
15
+ export declare function extractMessagesFromSessionUpdateStream(stream: AsyncIterable<SessionUpdateStreamItem> | Iterable<SessionUpdateStreamItem>): Promise<MessageUpdate[]>;
16
+ export declare function extractUsageFromSessionUpdateStream(stream: AsyncIterable<SessionUpdateStreamItem> | Iterable<SessionUpdateStreamItem>): Promise<UsageUpdate[]>;
17
+ export declare function extractToolCallSummariesFromSessionUpdateStream(stream: AsyncIterable<SessionUpdateStreamItem> | Iterable<SessionUpdateStreamItem>): Promise<ToolCallSummary[]>;
18
+ export declare function mapLegacyEventToSessionUpdates(event: LegacyInternalEvent): SessionUpdate[];
19
+ export {};
@@ -0,0 +1,443 @@
1
+ export type AcpMeta = Record<string, unknown> | null;
2
+ export interface AcpExtensible {
3
+ _meta?: AcpMeta;
4
+ }
5
+ export type Role = "assistant" | "user";
6
+ export interface Annotations extends AcpExtensible {
7
+ audience?: Role[] | null;
8
+ lastModified?: string | null;
9
+ priority?: number | null;
10
+ }
11
+ export interface TextContent extends AcpExtensible {
12
+ type: "text";
13
+ text: string;
14
+ annotations?: Annotations | null;
15
+ }
16
+ export interface ImageContent extends AcpExtensible {
17
+ type: "image";
18
+ data: string;
19
+ mimeType: string;
20
+ uri?: string | null;
21
+ annotations?: Annotations | null;
22
+ }
23
+ export interface AudioContent extends AcpExtensible {
24
+ type: "audio";
25
+ data: string;
26
+ mimeType: string;
27
+ annotations?: Annotations | null;
28
+ }
29
+ export interface ResourceLink extends AcpExtensible {
30
+ type: "resource_link";
31
+ name: string;
32
+ uri: string;
33
+ description?: string | null;
34
+ mimeType?: string | null;
35
+ size?: number | null;
36
+ title?: string | null;
37
+ annotations?: Annotations | null;
38
+ }
39
+ export interface TextResourceContents extends AcpExtensible {
40
+ text: string;
41
+ uri: string;
42
+ mimeType?: string | null;
43
+ }
44
+ export interface BlobResourceContents extends AcpExtensible {
45
+ blob: string;
46
+ uri: string;
47
+ mimeType?: string | null;
48
+ }
49
+ export type EmbeddedResourceResource = TextResourceContents | BlobResourceContents;
50
+ export interface EmbeddedResource extends AcpExtensible {
51
+ type: "resource";
52
+ resource: EmbeddedResourceResource;
53
+ annotations?: Annotations | null;
54
+ }
55
+ export type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource;
56
+ export interface ContentChunk extends AcpExtensible {
57
+ content: ContentBlock;
58
+ }
59
+ export interface UserMessageChunk extends ContentChunk {
60
+ sessionUpdate: "user_message_chunk";
61
+ }
62
+ export interface AgentMessageChunk extends ContentChunk {
63
+ sessionUpdate: "agent_message_chunk";
64
+ }
65
+ export interface AgentThoughtChunk extends ContentChunk {
66
+ sessionUpdate: "agent_thought_chunk";
67
+ }
68
+ export type ToolKind = "read" | "write" | "execute" | "other";
69
+ export type ToolCallStatus = "pending" | "in_progress" | "completed" | "failed" | "cancelled";
70
+ export interface Diff extends AcpExtensible {
71
+ path: string;
72
+ newText: string;
73
+ oldText?: string | null;
74
+ }
75
+ export interface Terminal extends AcpExtensible {
76
+ terminalId: string;
77
+ }
78
+ export interface ToolCallTextContent extends TextContent {
79
+ type: "text";
80
+ }
81
+ export interface ToolCallDiffContent extends Diff {
82
+ type: "diff";
83
+ }
84
+ export interface ToolCallImageContent extends ImageContent {
85
+ type: "image";
86
+ }
87
+ export interface ToolCallResourceLinkContent extends ResourceLink {
88
+ type: "resource_link";
89
+ }
90
+ export interface ToolCallResourceContent extends EmbeddedResource {
91
+ type: "resource";
92
+ }
93
+ export interface ToolCallTerminalContent extends Terminal {
94
+ type: "terminal";
95
+ }
96
+ export type ToolCallContent = ToolCallTextContent | ToolCallDiffContent | ToolCallImageContent | ToolCallResourceLinkContent | ToolCallResourceContent | ToolCallTerminalContent;
97
+ export interface ToolCallLocation extends AcpExtensible {
98
+ path: string;
99
+ lineNumber?: number | null;
100
+ }
101
+ export interface ToolCall extends AcpExtensible {
102
+ sessionUpdate: "tool_call";
103
+ toolCallId: string;
104
+ title: string;
105
+ content?: ToolCallContent[];
106
+ kind?: ToolKind;
107
+ locations?: ToolCallLocation[];
108
+ rawInput?: unknown;
109
+ rawOutput?: unknown;
110
+ status?: ToolCallStatus;
111
+ }
112
+ export interface ToolCallUpdate extends AcpExtensible {
113
+ sessionUpdate: "tool_call_update";
114
+ toolCallId: string;
115
+ content?: ToolCallContent[] | null;
116
+ kind?: ToolKind | null;
117
+ locations?: ToolCallLocation[] | null;
118
+ rawInput?: unknown;
119
+ rawOutput?: unknown;
120
+ status?: ToolCallStatus | null;
121
+ title?: string | null;
122
+ }
123
+ export type PlanEntryPriority = "high" | "medium" | "low";
124
+ export type PlanEntryStatus = "pending" | "in_progress" | "completed";
125
+ export interface PlanEntry extends AcpExtensible {
126
+ content: string;
127
+ priority: PlanEntryPriority;
128
+ status: PlanEntryStatus;
129
+ }
130
+ export interface Plan extends AcpExtensible {
131
+ sessionUpdate: "plan";
132
+ entries: PlanEntry[];
133
+ }
134
+ export interface UnstructuredCommandInput extends AcpExtensible {
135
+ hint: string;
136
+ }
137
+ export type AvailableCommandInput = UnstructuredCommandInput;
138
+ export interface AvailableCommand extends AcpExtensible {
139
+ name: string;
140
+ description: string;
141
+ input?: AvailableCommandInput | null;
142
+ }
143
+ export interface AvailableCommandsUpdate extends AcpExtensible {
144
+ sessionUpdate: "available_commands_update";
145
+ availableCommands: AvailableCommand[];
146
+ }
147
+ export type SessionModeId = string;
148
+ export interface CurrentModeUpdate extends AcpExtensible {
149
+ sessionUpdate: "current_mode_update";
150
+ currentModeId: SessionModeId;
151
+ }
152
+ export type SessionConfigId = string;
153
+ export type SessionConfigGroupId = string;
154
+ export type SessionConfigValueId = string;
155
+ export type SessionConfigOptionCategory = "mode" | "model" | "thought_level" | string;
156
+ export interface SessionConfigSelectOption extends AcpExtensible {
157
+ value: SessionConfigValueId;
158
+ name: string;
159
+ description?: string | null;
160
+ }
161
+ export interface SessionConfigSelectGroup extends AcpExtensible {
162
+ group: SessionConfigGroupId;
163
+ name: string;
164
+ options: SessionConfigSelectOption[];
165
+ }
166
+ export type SessionConfigSelectOptions = SessionConfigSelectOption[] | SessionConfigSelectGroup[];
167
+ export interface SessionConfigSelect {
168
+ currentValue: SessionConfigValueId;
169
+ options: SessionConfigSelectOptions;
170
+ }
171
+ export interface SessionConfigOption extends AcpExtensible, SessionConfigSelect {
172
+ type: "select";
173
+ id: SessionConfigId;
174
+ name: string;
175
+ category?: SessionConfigOptionCategory | null;
176
+ description?: string | null;
177
+ }
178
+ export interface ConfigOptionUpdate extends AcpExtensible {
179
+ sessionUpdate: "config_option_update";
180
+ configOptions: SessionConfigOption[];
181
+ }
182
+ export interface SessionInfoUpdate extends AcpExtensible {
183
+ sessionUpdate: "session_info_update";
184
+ title?: string | null;
185
+ updatedAt?: string | null;
186
+ }
187
+ export interface Cost {
188
+ amount: number;
189
+ currency: string;
190
+ }
191
+ export interface UsageUpdate extends AcpExtensible {
192
+ sessionUpdate: "usage_update";
193
+ used: number;
194
+ size: number;
195
+ cost?: Cost | null;
196
+ }
197
+ export type StableSessionUpdate = UserMessageChunk | AgentMessageChunk | AgentThoughtChunk | ToolCall | ToolCallUpdate | Plan | AvailableCommandsUpdate | CurrentModeUpdate | ConfigOptionUpdate;
198
+ export type UnstableSessionUpdate = SessionInfoUpdate | UsageUpdate;
199
+ export type SessionUpdate = StableSessionUpdate | UnstableSessionUpdate;
200
+ export type SessionUpdateKind = SessionUpdate["sessionUpdate"];
201
+ export type SessionId = string;
202
+ export interface SessionNotification extends AcpExtensible {
203
+ sessionId: SessionId;
204
+ update: SessionUpdate;
205
+ }
206
+ export interface SessionUpdateNotification {
207
+ jsonrpc: "2.0";
208
+ method: "session/update";
209
+ params: SessionNotification;
210
+ }
211
+ export type ProtocolVersion = number;
212
+ export type RequestId = null | number | string;
213
+ export type StopReason = "completed" | "end_turn" | "cancelled" | "max_tokens";
214
+ export interface Implementation extends AcpExtensible {
215
+ name: string;
216
+ version: string;
217
+ title?: string | null;
218
+ }
219
+ export interface AuthMethod extends AcpExtensible {
220
+ id: string;
221
+ name: string;
222
+ description?: string | null;
223
+ }
224
+ export interface FileSystemCapability extends AcpExtensible {
225
+ readTextFile?: boolean;
226
+ writeTextFile?: boolean;
227
+ }
228
+ export interface ClientCapabilities extends AcpExtensible {
229
+ fs?: FileSystemCapability;
230
+ terminal?: boolean;
231
+ }
232
+ export interface McpCapabilities extends AcpExtensible {
233
+ http?: boolean;
234
+ sse?: boolean;
235
+ }
236
+ export interface PromptCapabilities extends AcpExtensible {
237
+ image?: boolean;
238
+ audio?: boolean;
239
+ embeddedContext?: boolean;
240
+ }
241
+ export type SessionCapabilities = AcpExtensible;
242
+ export interface AgentCapabilities extends AcpExtensible {
243
+ loadSession?: boolean;
244
+ mcpCapabilities?: McpCapabilities;
245
+ promptCapabilities?: PromptCapabilities;
246
+ sessionCapabilities?: SessionCapabilities;
247
+ }
248
+ export interface SessionMode extends AcpExtensible {
249
+ id: SessionModeId;
250
+ name: string;
251
+ description?: string | null;
252
+ }
253
+ export interface SessionModeState extends AcpExtensible {
254
+ availableModes: SessionMode[];
255
+ currentModeId: SessionModeId;
256
+ }
257
+ export interface HttpHeader extends AcpExtensible {
258
+ name: string;
259
+ value: string;
260
+ }
261
+ export interface EnvVariable extends AcpExtensible {
262
+ name: string;
263
+ value: string;
264
+ }
265
+ export interface McpServerStdio extends AcpExtensible {
266
+ name: string;
267
+ command: string;
268
+ args: string[];
269
+ env: EnvVariable[];
270
+ }
271
+ export interface McpServerHttp extends AcpExtensible {
272
+ type: "http";
273
+ name: string;
274
+ url: string;
275
+ headers: HttpHeader[];
276
+ }
277
+ export interface McpServerSse extends AcpExtensible {
278
+ type: "sse";
279
+ name: string;
280
+ url: string;
281
+ headers: HttpHeader[];
282
+ }
283
+ export type McpServer = McpServerStdio | McpServerHttp | McpServerSse;
284
+ export type PermissionOptionId = string;
285
+ export type PermissionOptionKind = "allow_once" | "allow_always" | "reject_once" | "reject_always";
286
+ export interface PermissionOption extends AcpExtensible {
287
+ optionId: PermissionOptionId;
288
+ kind: PermissionOptionKind;
289
+ name: string;
290
+ }
291
+ export interface RequestPermissionCancelledOutcome extends AcpExtensible {
292
+ outcome: "cancelled";
293
+ }
294
+ export interface RequestPermissionSelectedOutcome extends AcpExtensible {
295
+ outcome: "selected";
296
+ optionId: PermissionOptionId;
297
+ }
298
+ export type RequestPermissionOutcome = RequestPermissionCancelledOutcome | RequestPermissionSelectedOutcome;
299
+ export interface TerminalExitStatus extends AcpExtensible {
300
+ exitCode?: number | null;
301
+ signal?: string | null;
302
+ }
303
+ export declare const ACP_ERROR_CODE_PARSE = -32700;
304
+ export declare const ACP_ERROR_CODE_INVALID_REQUEST = -32600;
305
+ export declare const ACP_ERROR_CODE_METHOD_NOT_FOUND = -32601;
306
+ export declare const ACP_ERROR_CODE_INVALID_PARAMS = -32602;
307
+ export declare const ACP_ERROR_CODE_INTERNAL = -32603;
308
+ export declare const ACP_ERROR_CODE_AUTH_REQUIRED = -32000;
309
+ export declare const ACP_ERROR_CODE_RESOURCE_NOT_FOUND = -32002;
310
+ export type StandardAcpErrorCode = typeof ACP_ERROR_CODE_PARSE | typeof ACP_ERROR_CODE_INVALID_REQUEST | typeof ACP_ERROR_CODE_METHOD_NOT_FOUND | typeof ACP_ERROR_CODE_INVALID_PARAMS | typeof ACP_ERROR_CODE_INTERNAL | typeof ACP_ERROR_CODE_AUTH_REQUIRED | typeof ACP_ERROR_CODE_RESOURCE_NOT_FOUND;
311
+ export type AcpErrorCode = StandardAcpErrorCode | number;
312
+ export declare function isAcpErrorCode(value: unknown): value is AcpErrorCode;
313
+ export declare class AcpError extends Error {
314
+ readonly code: AcpErrorCode;
315
+ readonly data?: unknown;
316
+ constructor(code: AcpErrorCode, message: string, data?: unknown);
317
+ }
318
+ export declare function isAcpError(value: unknown): value is AcpError;
319
+ export interface InitializeRequest extends AcpExtensible {
320
+ protocolVersion: ProtocolVersion;
321
+ clientCapabilities?: ClientCapabilities;
322
+ clientInfo?: Implementation | null;
323
+ }
324
+ export interface InitializeResponse extends AcpExtensible {
325
+ protocolVersion: ProtocolVersion;
326
+ agentCapabilities?: AgentCapabilities;
327
+ agentInfo?: Implementation | null;
328
+ authMethods?: AuthMethod[];
329
+ }
330
+ export interface AuthenticateRequest extends AcpExtensible {
331
+ methodId: string;
332
+ }
333
+ export type AuthenticateResponse = AcpExtensible;
334
+ export interface NewSessionRequest extends AcpExtensible {
335
+ cwd: string;
336
+ mcpServers: McpServer[];
337
+ }
338
+ export interface NewSessionResponse extends AcpExtensible {
339
+ sessionId: SessionId;
340
+ configOptions?: SessionConfigOption[] | null;
341
+ modes?: SessionModeState | null;
342
+ }
343
+ export interface LoadSessionRequest extends AcpExtensible {
344
+ sessionId: SessionId;
345
+ cwd: string;
346
+ mcpServers: McpServer[];
347
+ }
348
+ export interface LoadSessionResponse extends AcpExtensible {
349
+ configOptions?: SessionConfigOption[] | null;
350
+ modes?: SessionModeState | null;
351
+ }
352
+ export interface PromptRequest extends AcpExtensible {
353
+ sessionId: SessionId;
354
+ prompt: ContentBlock[];
355
+ }
356
+ export interface PromptResponse extends AcpExtensible {
357
+ stopReason: StopReason;
358
+ }
359
+ export interface SetSessionModeRequest extends AcpExtensible {
360
+ sessionId: SessionId;
361
+ modeId: SessionModeId;
362
+ }
363
+ export type SetSessionModeResponse = AcpExtensible;
364
+ export interface SetSessionConfigOptionRequest extends AcpExtensible {
365
+ sessionId: SessionId;
366
+ configId: SessionConfigId;
367
+ value: SessionConfigValueId;
368
+ }
369
+ export interface SetSessionConfigOptionResponse extends AcpExtensible {
370
+ configOptions: SessionConfigOption[];
371
+ }
372
+ export interface CancelNotification extends AcpExtensible {
373
+ sessionId: SessionId;
374
+ }
375
+ export interface RequestPermissionRequest extends AcpExtensible {
376
+ sessionId: SessionId;
377
+ toolCall: ToolCallUpdate;
378
+ options: PermissionOption[];
379
+ }
380
+ export interface RequestPermissionResponse extends AcpExtensible {
381
+ outcome: RequestPermissionOutcome;
382
+ }
383
+ export interface ReadTextFileRequest extends AcpExtensible {
384
+ sessionId: SessionId;
385
+ path: string;
386
+ line?: number | null;
387
+ limit?: number | null;
388
+ }
389
+ export interface ReadTextFileResponse extends AcpExtensible {
390
+ content: string;
391
+ }
392
+ export interface WriteTextFileRequest extends AcpExtensible {
393
+ sessionId: SessionId;
394
+ path: string;
395
+ content: string;
396
+ }
397
+ export type WriteTextFileResponse = AcpExtensible;
398
+ export interface CreateTerminalRequest extends AcpExtensible {
399
+ sessionId: SessionId;
400
+ command: string;
401
+ args?: string[];
402
+ cwd?: string | null;
403
+ env?: EnvVariable[];
404
+ outputByteLimit?: number | null;
405
+ }
406
+ export interface CreateTerminalResponse extends AcpExtensible {
407
+ terminalId: string;
408
+ }
409
+ export interface TerminalOutputRequest extends AcpExtensible {
410
+ sessionId: SessionId;
411
+ terminalId: string;
412
+ }
413
+ export interface TerminalOutputResponse extends AcpExtensible {
414
+ output: string;
415
+ truncated: boolean;
416
+ exitStatus?: TerminalExitStatus | null;
417
+ }
418
+ export interface WaitForTerminalExitRequest extends AcpExtensible {
419
+ sessionId: SessionId;
420
+ terminalId: string;
421
+ }
422
+ export interface WaitForTerminalExitResponse extends AcpExtensible {
423
+ exitCode?: number | null;
424
+ signal?: string | null;
425
+ }
426
+ export interface KillTerminalCommandRequest extends AcpExtensible {
427
+ sessionId: SessionId;
428
+ terminalId: string;
429
+ }
430
+ export type KillTerminalCommandResponse = AcpExtensible;
431
+ export interface ReleaseTerminalRequest extends AcpExtensible {
432
+ sessionId: SessionId;
433
+ terminalId: string;
434
+ }
435
+ export type ReleaseTerminalResponse = AcpExtensible;
436
+ export interface ExtMethodRequest extends AcpExtensible {
437
+ method: `_${string}`;
438
+ params?: unknown;
439
+ }
440
+ export interface ExtNotification extends AcpExtensible {
441
+ method: `_${string}`;
442
+ params?: unknown;
443
+ }
@@ -2,3 +2,5 @@ export { renderAgentMessage, renderToolStart, renderToolComplete, renderReasonin
2
2
  export type { AcpOutputState } from "./components.js";
3
3
  export { getAcpWriter, withAcpWriter } from "./writer.js";
4
4
  export type { AcpLineWriter } from "./writer.js";
5
+ export { formatAgentPlan, renderAgentPlan } from "./plan.js";
6
+ export type { AgentPlanEntry } from "./plan.js";
@@ -0,0 +1,10 @@
1
+ export type AgentPlanEntry = {
2
+ content: string;
3
+ status: "pending" | "in_progress" | "completed";
4
+ };
5
+ /** A compact preview of an agent's checklist; the complete list stays in details. */
6
+ export declare function formatAgentPlan(entries: readonly AgentPlanEntry[]): {
7
+ text: string;
8
+ detail?: string;
9
+ };
10
+ export declare function renderAgentPlan(entries: readonly AgentPlanEntry[]): void;
@@ -0,0 +1,24 @@
1
+ import type { KeypressEvent } from "./terminal.js";
2
+ export type DashboardSubmission = {
3
+ kind: "message" | "plan";
4
+ text: string;
5
+ afterPlanId?: string;
6
+ };
7
+ export type ComposerState = {
8
+ kind: DashboardSubmission["kind"];
9
+ text: string;
10
+ /** UTF-16 offset at a grapheme boundary. */
11
+ cursor: number;
12
+ focused: boolean;
13
+ afterPlanId?: string;
14
+ error?: string;
15
+ /** Preserve the intended display column across shorter rows during vertical movement. */
16
+ preferredColumn?: number;
17
+ preferredWidth?: number;
18
+ };
19
+ export declare function createComposerState(kind: DashboardSubmission["kind"], afterPlanId?: string): ComposerState;
20
+ export declare function editComposer(state: ComposerState, event: KeypressEvent, width?: number): {
21
+ state: ComposerState;
22
+ handled: boolean;
23
+ submit?: DashboardSubmission;
24
+ };
@@ -1,5 +1,6 @@
1
1
  import { type RenderPerformanceSnapshot } from "../render-performance.js";
2
2
  import type { FooterHint } from "./components/footer.js";
3
+ import { type DashboardSubmission } from "./composer.js";
3
4
  import type { Command, DashboardStats, OutputItem } from "./types.js";
4
5
  export type DashboardOptions = {
5
6
  title?: string;
@@ -9,6 +10,9 @@ export type DashboardOptions = {
9
10
  hints?: FooterHint[];
10
11
  stdin?: NodeJS.ReadStream;
11
12
  stdout?: NodeJS.WriteStream;
13
+ appearance?: "panels" | "conversation";
14
+ /** Resolves once the runtime accepts the input; rejection keeps the draft editable. */
15
+ onSubmit?: (submission: DashboardSubmission) => void | Promise<void>;
12
16
  /** Observe bounded performance snapshots without forcing idle repaints. */
13
17
  onPerformance?: (stats: RenderPerformanceSnapshot) => void;
14
18
  };
@@ -3,8 +3,9 @@ export { createDashboardLineBuffer, createStreamingDashboardLineBuffer } from ".
3
3
  export { limitOutputPreview, createOutputPreviewBuffer } from "./output-preview.js";
4
4
  export { shouldUseInteractiveDashboard } from "./should-use-dashboard.js";
5
5
  export type { Dashboard, DashboardOptions } from "./dashboard.js";
6
+ export type { DashboardSubmission } from "./composer.js";
6
7
  export { renderDashboardSnapshot } from "./snapshot.js";
7
8
  export type { SnapshotOptions } from "./snapshot.js";
8
- export type { OutputItem, OutputItemKind, DashboardStats, Command, DashboardState } from "./types.js";
9
+ export type { OutputItem, OutputItemKind, DashboardStats, DashboardTask, DashboardRunState, DashboardQueueItem, DashboardWorkStatus, Command, DashboardState } from "./types.js";
9
10
  export { defaultHints } from "./components/footer.js";
10
11
  export type { FooterHint } from "./components/footer.js";
@@ -5,6 +5,41 @@ export type OutputItem = {
5
5
  kind: OutputItemKind;
6
6
  text: string;
7
7
  ts: number;
8
+ role?: "agent" | "reasoning" | "action" | "user" | "plan";
9
+ detail?: string;
10
+ };
11
+ export type DashboardWorkStatus = "pending" | "running" | "completed" | "failed" | "cancelled" | "paused";
12
+ export type DashboardQueueItem = Readonly<{
13
+ id: string;
14
+ status: DashboardWorkStatus;
15
+ } & ({
16
+ kind: "plan";
17
+ path: string;
18
+ } | {
19
+ kind: "message";
20
+ text: string;
21
+ afterPlanId: string;
22
+ })>;
23
+ export type DashboardTask = {
24
+ id: string;
25
+ title: string;
26
+ status: DashboardWorkStatus;
27
+ steps?: Array<{
28
+ name: string;
29
+ status: DashboardWorkStatus;
30
+ }>;
31
+ };
32
+ export type DashboardRunState = {
33
+ agent?: string;
34
+ model?: string;
35
+ cwd?: string;
36
+ phase?: string;
37
+ activity?: string;
38
+ activePlanId?: string;
39
+ activeTaskId?: string;
40
+ activeStep?: string;
41
+ queue?: readonly DashboardQueueItem[];
42
+ tasks?: readonly DashboardTask[];
8
43
  };
9
44
  export type DashboardStats = {
10
45
  status: "idle" | "running" | "paused" | "done" | "error";
@@ -21,6 +56,8 @@ export type DashboardStats = {
21
56
  agent: string;
22
57
  model?: string;
23
58
  };
59
+ usageAvailable?: boolean;
60
+ run?: DashboardRunState;
24
61
  };
25
62
  export type Command = "quit" | "forceQuit" | "edit" | "pause" | "retry" | "view-log" | "scroll-up" | "scroll-down" | "page-up" | "page-down" | "follow" | "render-stats";
26
63
  export type DashboardState = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-js",
3
- "version": "0.1.656",
3
+ "version": "0.1.658",
4
4
  "description": "Budgeted JavaScript interpreter with explicit host capabilities and resumable execution",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -68,7 +68,7 @@
68
68
  "access": "public"
69
69
  },
70
70
  "dependencies": {
71
- "@poe-platform/safe-fs": "0.1.656",
71
+ "@poe-platform/safe-fs": "0.1.658",
72
72
  "temporal-polyfill": "1.0.4",
73
73
  "@petamoriken/float16": "^3.9.3",
74
74
  "@formatjs/intl-localematcher": "0.8.13",