@wrongstack/acp 0.274.0 → 0.275.0
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.
- package/README.md +376 -0
- package/dist/acp-subagent-runner-BAlo23L-.d.ts +644 -0
- package/dist/acp-v1-BxskPsdo.d.ts +520 -0
- package/dist/agent.d.ts +34 -61
- package/dist/agent.js +796 -32
- package/dist/agent.js.map +1 -1
- package/dist/client.d.ts +3 -2
- package/dist/client.js +779 -112
- package/dist/client.js.map +1 -1
- package/dist/index-DEEYyEpu.d.ts +54 -0
- package/dist/index.d.ts +186 -227
- package/dist/index.js +1881 -286
- package/dist/index.js.map +1 -1
- package/dist/sdk.d.ts +12 -0
- package/dist/sdk.js +3350 -0
- package/dist/sdk.js.map +1 -0
- package/dist/server-agent-turn-C3U0lhA-.d.ts +163 -0
- package/dist/terminal-server-P9KpMZTT.d.ts +99 -0
- package/dist/{tools-registry-BCf8evEG.d.ts → tools-registry-D2xdbzN7.d.ts} +1 -1
- package/dist/wrongstack-acp-agent-nzrqmJnc.d.ts +341 -0
- package/dist/wrongstack-acp-agent.d.ts +2 -2
- package/dist/wrongstack-acp-agent.js +426 -26
- package/dist/wrongstack-acp-agent.js.map +1 -1
- package/package.json +7 -2
- package/dist/index-BvPqJHhm.d.ts +0 -119
- package/dist/stdio-transport-CsFr8JzC.d.ts +0 -205
- package/dist/wrongstack-acp-agent-Dv-A0bEm.d.ts +0 -310
package/dist/index-BvPqJHhm.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { j as ACPMessage, v as ACPToolCallResponse } from './stdio-transport-CsFr8JzC.js';
|
|
2
|
-
import { SubagentRunner } from '@wrongstack/core';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* ToolTranslator — bidirectional translation between WrongStack tools and
|
|
6
|
-
* ACP tool representations.
|
|
7
|
-
*
|
|
8
|
-
* Used by DIR-1 (WrongStack as ACP client) to:
|
|
9
|
-
* - Map WrongStack TaskSpec → ACP task payload
|
|
10
|
-
* - Map ACP tool responses → TaskResult
|
|
11
|
-
*
|
|
12
|
-
* Used by DIR-2 (WrongStack as ACP server) to:
|
|
13
|
-
* - Convert the WrongStack Tool.inputSchema → ACPToolDefinition.inputSchema
|
|
14
|
-
* - (handled by tools-registry.ts — same logic lives there)
|
|
15
|
-
*
|
|
16
|
-
* For DIR-1 async tool calls: ACP agents send progress notifications while
|
|
17
|
-
* a tool is running, then send a final result. The translator handles this
|
|
18
|
-
* by polling for the final [result] notification on the transport.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
interface ToolTranslatorOptions {
|
|
22
|
-
/**
|
|
23
|
-
* If true (default), wrap tool calls in an async poll loop that waits
|
|
24
|
-
* for progress notifications until a final result arrives.
|
|
25
|
-
*/
|
|
26
|
-
asyncTools?: boolean | undefined;
|
|
27
|
-
pollIntervalMs?: number | undefined;
|
|
28
|
-
totalTimeoutMs?: number | undefined;
|
|
29
|
-
}
|
|
30
|
-
/** ToolTranslator for DIR-1 — wraps ACP client transport, adds task semantics */
|
|
31
|
-
declare class ToolTranslator {
|
|
32
|
-
private readonly opts;
|
|
33
|
-
private readonly pending;
|
|
34
|
-
constructor(opts?: ToolTranslatorOptions);
|
|
35
|
-
/**
|
|
36
|
-
* Start listening to a transport for tool responses and cancellations.
|
|
37
|
-
* Call this once after constructing the translator and before sending tasks.
|
|
38
|
-
*/
|
|
39
|
-
attachToTransport(transport: {
|
|
40
|
-
onMessage: (h: (msg: ACPMessage) => void) => () => void;
|
|
41
|
-
send: (msg: ACPMessage) => Promise<void>;
|
|
42
|
-
}): void;
|
|
43
|
-
/**
|
|
44
|
-
* Send a tool call over the transport and wait for a response.
|
|
45
|
-
* If asyncTools is true, polls for progress and resolves when the final
|
|
46
|
-
* response arrives.
|
|
47
|
-
*/
|
|
48
|
-
callTool(transport: {
|
|
49
|
-
send: (msg: ACPMessage) => Promise<void>;
|
|
50
|
-
}, name: string, args: Record<string, unknown>, callId?: string | number): Promise<ACPToolCallResponse>;
|
|
51
|
-
cancelAll(): void;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* ACPSubagentRunner — `SubagentRunner` implementation for DIR-1.
|
|
56
|
-
*
|
|
57
|
-
* Wraps an external ACP-supporting agent (Claude Code, Gemini CLI, Codex
|
|
58
|
-
* CLI, Cline, Goose, OpenHands, etc.) as a WrongStack subagent. The
|
|
59
|
-
* external agent runs its own agent loop; we send it a task via the ACP
|
|
60
|
-
* v1 protocol and return the result.
|
|
61
|
-
*
|
|
62
|
-
* v1 spec: https://agentclientprotocol.com/protocol/v1/overview
|
|
63
|
-
*
|
|
64
|
-
* Connected to the Director / MultiAgentCoordinator via the
|
|
65
|
-
* `SubagentRunner` interface (same shape as `AgentSubagentRunner`).
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
interface ACPSubagentRunnerOptions {
|
|
69
|
-
/** How to spawn the external agent. */
|
|
70
|
-
command: string;
|
|
71
|
-
args?: string[] | undefined;
|
|
72
|
-
env?: Record<string, string> | undefined;
|
|
73
|
-
cwd?: string | undefined;
|
|
74
|
-
/** Subagent role label — surfaced in errors and used for logging. */
|
|
75
|
-
role?: string | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Hard wall-clock cap for one prompt turn. Defaults to 5 minutes.
|
|
78
|
-
* Overrides `SubagentRunContext.budget.limits.timeoutMs` if both are set.
|
|
79
|
-
*/
|
|
80
|
-
timeoutMs?: number | undefined;
|
|
81
|
-
/**
|
|
82
|
-
* Filesystem sandbox root. Defaults to `options.cwd` (when set) or
|
|
83
|
-
* the process's current working directory. All `fs/read_text_file` /
|
|
84
|
-
* `fs/write_text_file` calls are bounded to this root.
|
|
85
|
-
*/
|
|
86
|
-
projectRoot?: string | undefined;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Static catalog of agent ids → spawn options.
|
|
90
|
-
*
|
|
91
|
-
* The CLI and the host's `buildACPRunner` look up entries by id. The
|
|
92
|
-
* canonical, multi-source catalog is `packages/acp/src/registry/agents.catalog.ts`
|
|
93
|
-
* (the 12-entry static catalog introduced in commit 4ad287b4). This
|
|
94
|
-
* map stays for backward compatibility with existing call sites that
|
|
95
|
-
* import it directly; new code should prefer the registry.
|
|
96
|
-
*/
|
|
97
|
-
declare const ACP_AGENT_COMMANDS: Record<string, ACPSubagentRunnerOptions>;
|
|
98
|
-
/**
|
|
99
|
-
* Build a one-shot `SubagentRunner` for a single agent invocation. Each
|
|
100
|
-
* call to the returned function spawns a fresh child process, runs one
|
|
101
|
-
* prompt turn, and tears everything down. The cost is ~1 second of
|
|
102
|
-
* process-startup per call; for long-lived sessions (multi-turn
|
|
103
|
-
* conversations), use `makeACPSubagentRunnerWithStop` and call `stop()`
|
|
104
|
-
* explicitly.
|
|
105
|
-
*/
|
|
106
|
-
declare function makeACPSubagentRunner(options: ACPSubagentRunnerOptions): Promise<SubagentRunner>;
|
|
107
|
-
/**
|
|
108
|
-
* Build a long-lived `SubagentRunner` plus an explicit `stop()` for
|
|
109
|
-
* teardown. The caller is responsible for calling `stop()` when done
|
|
110
|
-
* (or when the host's signal fires). Useful for the `wstack acp spawn`
|
|
111
|
-
* CLI command, which holds the child open for the duration of a user
|
|
112
|
-
* task and tears down on SIGINT.
|
|
113
|
-
*/
|
|
114
|
-
declare function makeACPSubagentRunnerWithStop(options: ACPSubagentRunnerOptions): Promise<{
|
|
115
|
-
runner: SubagentRunner;
|
|
116
|
-
stop: () => void;
|
|
117
|
-
}>;
|
|
118
|
-
|
|
119
|
-
export { type ACPSubagentRunnerOptions as A, ToolTranslator as T, ACP_AGENT_COMMANDS as a, type ToolTranslatorOptions as b, makeACPSubagentRunnerWithStop as c, makeACPSubagentRunner as m };
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ACP message types — transport-agnostic JSON-RPC 2.0 envelope.
|
|
5
|
-
* Reuses MCP types where possible; custom types for agentic UX (diffs, plans).
|
|
6
|
-
*/
|
|
7
|
-
interface ACPMessage {
|
|
8
|
-
method: string;
|
|
9
|
-
id?: string | number | undefined;
|
|
10
|
-
params?: unknown | undefined;
|
|
11
|
-
result?: unknown | undefined;
|
|
12
|
-
error?: ACPError | undefined;
|
|
13
|
-
}
|
|
14
|
-
interface ACPError {
|
|
15
|
-
code: number;
|
|
16
|
-
message: string;
|
|
17
|
-
data?: unknown | undefined;
|
|
18
|
-
}
|
|
19
|
-
type ACPRequest = RequiredPick<ACPMessage, 'id' | 'params' | 'method'>;
|
|
20
|
-
type ACPResponse = RequiredPick<ACPMessage, 'id' | 'result' | 'method'>;
|
|
21
|
-
type ACPNotification = Omit<ACPMessage, 'id'> & {
|
|
22
|
-
method: string;
|
|
23
|
-
};
|
|
24
|
-
interface ACPInitializeParams {
|
|
25
|
-
capabilities?: string[] | undefined;
|
|
26
|
-
protocolVersion?: string | undefined;
|
|
27
|
-
sessionId?: string | undefined;
|
|
28
|
-
authToken?: string | undefined;
|
|
29
|
-
sessionPath?: string | undefined;
|
|
30
|
-
workspaceRoots?: string[] | undefined;
|
|
31
|
-
mcpServers?: unknown[] | undefined;
|
|
32
|
-
[key: string]: unknown;
|
|
33
|
-
}
|
|
34
|
-
interface ACPCapabilities {
|
|
35
|
-
capabilities: string[];
|
|
36
|
-
agentName: string;
|
|
37
|
-
agentVersion: string;
|
|
38
|
-
tools?: ACPToolList | undefined;
|
|
39
|
-
protocolVersion: string;
|
|
40
|
-
}
|
|
41
|
-
interface ACPToolList {
|
|
42
|
-
tools: ACPToolDefinition[];
|
|
43
|
-
}
|
|
44
|
-
interface ACPToolDefinition {
|
|
45
|
-
name: string;
|
|
46
|
-
description?: string | undefined;
|
|
47
|
-
inputSchema: ACPInputSchema;
|
|
48
|
-
annotations?: {
|
|
49
|
-
title?: string | undefined;
|
|
50
|
-
description?: string | undefined;
|
|
51
|
-
priority?: 'high' | 'medium' | 'low' | undefined;
|
|
52
|
-
alwaysAccept?: boolean | undefined;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
type ACPInputSchema = {
|
|
56
|
-
type?: string | undefined;
|
|
57
|
-
properties?: Record<string, ACPInputSchema>;
|
|
58
|
-
required?: string[] | undefined;
|
|
59
|
-
items?: ACPInputSchema | undefined;
|
|
60
|
-
enum?: unknown[] | undefined;
|
|
61
|
-
description?: string | undefined;
|
|
62
|
-
default?: unknown | undefined;
|
|
63
|
-
minimum?: number | undefined;
|
|
64
|
-
maximum?: number | undefined;
|
|
65
|
-
[key: string]: unknown;
|
|
66
|
-
};
|
|
67
|
-
type ContentBlock = ACPTextContent | ACPResourceContent | ACPImageContent | ACPProgressContent;
|
|
68
|
-
interface ACPTextContent {
|
|
69
|
-
type: 'text';
|
|
70
|
-
text: string;
|
|
71
|
-
}
|
|
72
|
-
interface ACPResourceContent {
|
|
73
|
-
type: 'resource';
|
|
74
|
-
resource: {
|
|
75
|
-
type: string;
|
|
76
|
-
uri: string;
|
|
77
|
-
data?: string | undefined;
|
|
78
|
-
mimeType?: string | undefined;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
interface ACPImageContent {
|
|
82
|
-
type: 'image';
|
|
83
|
-
data: string;
|
|
84
|
-
mimeType?: string | undefined;
|
|
85
|
-
}
|
|
86
|
-
interface ACPProgressContent {
|
|
87
|
-
type: 'progress';
|
|
88
|
-
id: string;
|
|
89
|
-
label?: string | undefined;
|
|
90
|
-
message?: string | undefined;
|
|
91
|
-
messages?: string[] | undefined;
|
|
92
|
-
}
|
|
93
|
-
interface ACPToolCallRequest {
|
|
94
|
-
method: 'tools/call';
|
|
95
|
-
id: string | number;
|
|
96
|
-
params: {
|
|
97
|
-
name: string;
|
|
98
|
-
arguments: Record<string, unknown>;
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
interface ACPToolResult {
|
|
102
|
-
content: ContentBlock[];
|
|
103
|
-
isError?: boolean | undefined;
|
|
104
|
-
}
|
|
105
|
-
type ACPToolCallResponse = {
|
|
106
|
-
method: 'tools/call';
|
|
107
|
-
id: string | number;
|
|
108
|
-
result: ACPToolResult;
|
|
109
|
-
};
|
|
110
|
-
interface ACPSessionInfo {
|
|
111
|
-
sessionId: string;
|
|
112
|
-
path: string;
|
|
113
|
-
title?: string | undefined;
|
|
114
|
-
modelId?: string | undefined;
|
|
115
|
-
createdAt: string;
|
|
116
|
-
lastActiveAt: string;
|
|
117
|
-
}
|
|
118
|
-
interface ACPPlanStep {
|
|
119
|
-
id: string;
|
|
120
|
-
description: string;
|
|
121
|
-
status?: 'pending' | 'running' | 'completed' | 'skipped' | undefined;
|
|
122
|
-
}
|
|
123
|
-
interface ACPPlanContent {
|
|
124
|
-
type: 'plan';
|
|
125
|
-
plan: {
|
|
126
|
-
steps: ACPPlanStep[];
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
type ACPSessionMode = 'agent' | 'chat' | 'edit' | 'preview';
|
|
130
|
-
interface ACPCancelParams {
|
|
131
|
-
reason?: string | undefined;
|
|
132
|
-
}
|
|
133
|
-
type RequiredPick<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;
|
|
134
|
-
|
|
135
|
-
interface AgentServerTransport {
|
|
136
|
-
send(msg: ACPMessage): Promise<void>;
|
|
137
|
-
sendRaw(chunk: string): void;
|
|
138
|
-
read(): Promise<ACPMessage | null>;
|
|
139
|
-
close(): void;
|
|
140
|
-
onMessage(handler: (msg: ACPMessage) => void): () => void;
|
|
141
|
-
}
|
|
142
|
-
declare class StdioTransport implements AgentServerTransport {
|
|
143
|
-
private readonly stdin;
|
|
144
|
-
private readonly stdout;
|
|
145
|
-
private readonly stderr;
|
|
146
|
-
private buffer;
|
|
147
|
-
private readonly handlers;
|
|
148
|
-
private closed;
|
|
149
|
-
private resolveRead;
|
|
150
|
-
private messageQueue;
|
|
151
|
-
constructor();
|
|
152
|
-
sendStartupMarker(): void;
|
|
153
|
-
send(msg: ACPMessage): Promise<void>;
|
|
154
|
-
sendRaw(chunk: string): void;
|
|
155
|
-
read(): Promise<ACPMessage | null>;
|
|
156
|
-
onMessage(handler: (msg: ACPMessage) => void): () => void;
|
|
157
|
-
close(): void;
|
|
158
|
-
private onData;
|
|
159
|
-
private dispatch;
|
|
160
|
-
private handleClose;
|
|
161
|
-
private failAll;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
interface ClientTransportOptions {
|
|
165
|
-
command: string;
|
|
166
|
-
args?: string[] | undefined;
|
|
167
|
-
env?: Record<string, string>;
|
|
168
|
-
cwd?: string | undefined;
|
|
169
|
-
handshakeTimeoutMs?: number | undefined;
|
|
170
|
-
/**
|
|
171
|
-
* Set to true when the child is an external ACP agent (Claude Code,
|
|
172
|
-
* Gemini CLI, Codex CLI, …) that does NOT emit a `[wstack-acp]\n`
|
|
173
|
-
* marker on startup. The v1 client (`ACPSession`) sets this; the
|
|
174
|
-
* server-side transport (the default) keeps the marker check.
|
|
175
|
-
*/
|
|
176
|
-
skipHandshakeMarker?: boolean | undefined;
|
|
177
|
-
}
|
|
178
|
-
interface ACPChildProcess extends EventEmitter {
|
|
179
|
-
stdout: NodeJS.ReadableStream;
|
|
180
|
-
stdin: NodeJS.WritableStream;
|
|
181
|
-
stderr: NodeJS.ReadableStream;
|
|
182
|
-
pid: number | undefined;
|
|
183
|
-
kill(): void;
|
|
184
|
-
}
|
|
185
|
-
declare class ClientTransport {
|
|
186
|
-
private child;
|
|
187
|
-
private buffer;
|
|
188
|
-
private readonly handlers;
|
|
189
|
-
private closed;
|
|
190
|
-
private resolveRead;
|
|
191
|
-
private messageQueue;
|
|
192
|
-
private readonly opts;
|
|
193
|
-
constructor(options: ClientTransportOptions);
|
|
194
|
-
start(): Promise<void>;
|
|
195
|
-
send(msg: ACPMessage): Promise<void>;
|
|
196
|
-
read(): Promise<ACPMessage | null>;
|
|
197
|
-
onMessage(handler: (msg: ACPMessage) => void): () => void;
|
|
198
|
-
stop(): void;
|
|
199
|
-
private onChildData;
|
|
200
|
-
private onChildError;
|
|
201
|
-
private onChildClose;
|
|
202
|
-
private dispatch;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export { type AgentServerTransport as A, ClientTransport as C, StdioTransport as S, type ACPToolList as a, type ACPToolResult as b, type ACPCancelParams as c, type ACPCapabilities as d, type ACPChildProcess as e, type ACPError as f, type ACPImageContent as g, type ACPInitializeParams as h, type ACPInputSchema as i, type ACPMessage as j, type ACPNotification as k, type ACPPlanContent as l, type ACPPlanStep as m, type ACPProgressContent as n, type ACPRequest as o, type ACPResourceContent as p, type ACPResponse as q, type ACPSessionInfo as r, type ACPSessionMode as s, type ACPTextContent as t, type ACPToolCallRequest as u, type ACPToolCallResponse as v, type ACPToolDefinition as w, type ClientTransportOptions as x, type ContentBlock as y };
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { A as AgentServerTransport } from './stdio-transport-CsFr8JzC.js';
|
|
2
|
-
|
|
3
|
-
type ToolCallId = string & {
|
|
4
|
-
readonly __acpToolCallId: unique symbol;
|
|
5
|
-
};
|
|
6
|
-
type TerminalId = string & {
|
|
7
|
-
readonly __acpTerminalId: unique symbol;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Annotations attached to a content block. Optional, agent-supplied hint
|
|
11
|
-
* about audience/priority. Spec leaves shape open; we mirror the fields
|
|
12
|
-
* the spec shows in its examples.
|
|
13
|
-
*/
|
|
14
|
-
interface ContentAnnotations {
|
|
15
|
-
audience?: ('user' | 'assistant')[] | undefined;
|
|
16
|
-
priority?: number | undefined;
|
|
17
|
-
[key: string]: unknown;
|
|
18
|
-
}
|
|
19
|
-
interface TextContent {
|
|
20
|
-
type: 'text';
|
|
21
|
-
text: string;
|
|
22
|
-
annotations?: ContentAnnotations | undefined;
|
|
23
|
-
}
|
|
24
|
-
interface ImageContent {
|
|
25
|
-
type: 'image';
|
|
26
|
-
mimeType: string;
|
|
27
|
-
/** Base64-encoded image data. */
|
|
28
|
-
data: string;
|
|
29
|
-
uri?: string | undefined;
|
|
30
|
-
annotations?: ContentAnnotations | undefined;
|
|
31
|
-
}
|
|
32
|
-
interface AudioContent {
|
|
33
|
-
type: 'audio';
|
|
34
|
-
mimeType: string;
|
|
35
|
-
/** Base64-encoded audio data. */
|
|
36
|
-
data: string;
|
|
37
|
-
annotations?: ContentAnnotations | undefined;
|
|
38
|
-
}
|
|
39
|
-
interface TextResourceContents {
|
|
40
|
-
uri: string;
|
|
41
|
-
mimeType?: string | undefined;
|
|
42
|
-
text: string;
|
|
43
|
-
}
|
|
44
|
-
interface BlobResourceContents {
|
|
45
|
-
uri: string;
|
|
46
|
-
mimeType?: string | undefined;
|
|
47
|
-
/** Base64-encoded binary. */
|
|
48
|
-
blob: string;
|
|
49
|
-
}
|
|
50
|
-
type EmbeddedResourceContents = TextResourceContents | BlobResourceContents;
|
|
51
|
-
interface EmbeddedResourceContent {
|
|
52
|
-
type: 'resource';
|
|
53
|
-
resource: EmbeddedResourceContents;
|
|
54
|
-
annotations?: ContentAnnotations | undefined;
|
|
55
|
-
}
|
|
56
|
-
interface ResourceLinkContent {
|
|
57
|
-
type: 'resource_link';
|
|
58
|
-
uri: string;
|
|
59
|
-
name: string;
|
|
60
|
-
mimeType?: string | undefined;
|
|
61
|
-
title?: string | undefined;
|
|
62
|
-
description?: string | undefined;
|
|
63
|
-
size?: number | undefined;
|
|
64
|
-
annotations?: ContentAnnotations | undefined;
|
|
65
|
-
}
|
|
66
|
-
type ContentBlock = TextContent | ImageContent | AudioContent | EmbeddedResourceContent | ResourceLinkContent;
|
|
67
|
-
type ToolKind = 'read' | 'edit' | 'delete' | 'move' | 'search' | 'execute' | 'think' | 'fetch' | 'switch_mode' | 'other';
|
|
68
|
-
type ToolCallStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
|
|
69
|
-
/** A single concrete content payload attached to a tool call. */
|
|
70
|
-
type ToolCallContent = {
|
|
71
|
-
type: 'content';
|
|
72
|
-
content: ContentBlock;
|
|
73
|
-
} | {
|
|
74
|
-
type: 'diff';
|
|
75
|
-
path: string;
|
|
76
|
-
oldText: string | null;
|
|
77
|
-
newText: string;
|
|
78
|
-
} | {
|
|
79
|
-
type: 'terminal';
|
|
80
|
-
terminalId: TerminalId;
|
|
81
|
-
};
|
|
82
|
-
interface ToolCallLocation {
|
|
83
|
-
path: string;
|
|
84
|
-
/** 1-based per the spec's argument requirements. */
|
|
85
|
-
line?: number | undefined;
|
|
86
|
-
}
|
|
87
|
-
type PlanEntryPriority = 'high' | 'medium' | 'low';
|
|
88
|
-
type PlanEntryStatus = 'pending' | 'in_progress' | 'completed';
|
|
89
|
-
interface PlanEntry {
|
|
90
|
-
/** Required by the spec for the array shape, but per-entry id is optional. */
|
|
91
|
-
content: string;
|
|
92
|
-
priority: PlanEntryPriority;
|
|
93
|
-
status: PlanEntryStatus;
|
|
94
|
-
}
|
|
95
|
-
interface UsageCost {
|
|
96
|
-
amount: number;
|
|
97
|
-
/** ISO 4217 currency code, e.g. "USD". */
|
|
98
|
-
currency: string;
|
|
99
|
-
}
|
|
100
|
-
type PermissionOptionKind = 'allow_once' | 'allow_always' | 'reject_once' | 'reject_always';
|
|
101
|
-
interface PermissionOption {
|
|
102
|
-
optionId: string;
|
|
103
|
-
name: string;
|
|
104
|
-
kind: PermissionOptionKind;
|
|
105
|
-
}
|
|
106
|
-
type RequestPermissionOutcome = {
|
|
107
|
-
outcome: 'cancelled';
|
|
108
|
-
} | {
|
|
109
|
-
outcome: 'selected';
|
|
110
|
-
optionId: string;
|
|
111
|
-
};
|
|
112
|
-
type StopReason = 'end_turn' | 'max_tokens' | 'max_turn_requests' | 'refusal' | 'cancelled' | string;
|
|
113
|
-
/** Subsequent updates to a previously-emitted tool call. */
|
|
114
|
-
interface ToolCallUpdateNotification {
|
|
115
|
-
sessionUpdate: 'tool_call_update';
|
|
116
|
-
toolCallId: ToolCallId;
|
|
117
|
-
status?: ToolCallStatus | undefined;
|
|
118
|
-
content?: ToolCallContent[] | undefined;
|
|
119
|
-
title?: string | undefined;
|
|
120
|
-
kind?: ToolKind | undefined;
|
|
121
|
-
locations?: ToolCallLocation[] | undefined;
|
|
122
|
-
rawInput?: Record<string, unknown> | undefined;
|
|
123
|
-
rawOutput?: Record<string, unknown> | undefined;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* ACP v1 server-side protocol handler.
|
|
128
|
-
*
|
|
129
|
-
* Receives JSON-RPC requests from an external ACP client (Zed, JetBrains
|
|
130
|
-
* Junie, VS Code ACP extension, etc.) over stdio and answers them per the
|
|
131
|
-
* v1 spec. See https://agentclientprotocol.com/protocol/v1/overview.
|
|
132
|
-
*
|
|
133
|
-
* Supported methods
|
|
134
|
-
* ─────────────────
|
|
135
|
-
* - initialize — handshake
|
|
136
|
-
* - authenticate — optional, no-op when auth isn't required
|
|
137
|
-
* - session/new — create a session
|
|
138
|
-
* - session/load — restore a session by id
|
|
139
|
-
* - session/prompt — run one turn, stream session/update
|
|
140
|
-
* notifications, return stopReason
|
|
141
|
-
* - session/cancel — notification (no response); cancels the
|
|
142
|
-
* in-flight turn on the target session
|
|
143
|
-
* - session/set_mode — change the active mode for a session
|
|
144
|
-
* - session/set_config_option — change a config option value
|
|
145
|
-
* - session/list — list known sessions
|
|
146
|
-
*
|
|
147
|
-
* Method execution
|
|
148
|
-
* ────────────────
|
|
149
|
-
* The handler is transport-agnostic; it sends responses via the
|
|
150
|
-
* `AgentServerTransport` injected at construction. The actual
|
|
151
|
-
* agent-loop work for a `session/prompt` turn is delegated to the
|
|
152
|
-
* caller-provided `runTurn` callback, which receives the prompt
|
|
153
|
-
* blocks and the per-turn AbortSignal and resolves with the final
|
|
154
|
-
* stopReason. Updates are streamed via the `emit` callback passed
|
|
155
|
-
* to `runTurn`; the handler wraps each as a `session/update`
|
|
156
|
-
* notification.
|
|
157
|
-
*
|
|
158
|
-
* This separation keeps the handler unit-testable: tests can supply
|
|
159
|
-
* a fake `runTurn` that yields a canned sequence of updates, and
|
|
160
|
-
* assert on the JSON-RPC traffic the handler produces. A real
|
|
161
|
-
* production caller wires `runTurn` to a core `Agent` instance.
|
|
162
|
-
*
|
|
163
|
-
* Concurrency
|
|
164
|
-
* ───────────
|
|
165
|
-
* Each session is single-threaded (one active turn at a time). The
|
|
166
|
-
* handler keeps a per-session AbortController so a `session/cancel`
|
|
167
|
-
* notification can stop the running turn mid-stream without tearing
|
|
168
|
-
* down the session. Multiple sessions can be active concurrently.
|
|
169
|
-
*/
|
|
170
|
-
|
|
171
|
-
interface RunTurnInput {
|
|
172
|
-
sessionId: string;
|
|
173
|
-
/** Content blocks the client sent. */
|
|
174
|
-
prompt: readonly ContentBlock[];
|
|
175
|
-
/** Cancelled when the client sends `session/cancel` for this session. */
|
|
176
|
-
signal: AbortSignal;
|
|
177
|
-
}
|
|
178
|
-
interface RunTurnResult {
|
|
179
|
-
stopReason: StopReason;
|
|
180
|
-
/** Optional summary text the agent produced. */
|
|
181
|
-
text?: string;
|
|
182
|
-
plan?: PlanEntry[];
|
|
183
|
-
usage?: {
|
|
184
|
-
used: number;
|
|
185
|
-
size: number;
|
|
186
|
-
cost?: UsageCost | undefined;
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* The agent's per-turn work. Streams `SessionUpdate` notifications to
|
|
191
|
-
* `emit` and resolves with the final stopReason. Errors thrown from
|
|
192
|
-
* this iterable are converted to a `prompt_failed` JSON-RPC error.
|
|
193
|
-
*/
|
|
194
|
-
type RunTurn = (input: RunTurnInput, emit: (update: unknown) => void) => Promise<RunTurnResult>;
|
|
195
|
-
interface SessionState {
|
|
196
|
-
id: string;
|
|
197
|
-
cwd: string;
|
|
198
|
-
/** Per-turn abort signal — aborted when the session is cancelled or closed. */
|
|
199
|
-
abort: AbortController;
|
|
200
|
-
/** Active mode, advertised to the client in current_mode_update. */
|
|
201
|
-
modeId: string;
|
|
202
|
-
/** Created at, for session/list ordering. */
|
|
203
|
-
createdAt: string;
|
|
204
|
-
/** Last activity timestamp, for session/info_update. */
|
|
205
|
-
updatedAt: string;
|
|
206
|
-
/** Optional human title. */
|
|
207
|
-
title?: string;
|
|
208
|
-
}
|
|
209
|
-
/** MCP-style session mode advertised in current_mode_update. */
|
|
210
|
-
interface SessionMode {
|
|
211
|
-
id: string;
|
|
212
|
-
name: string;
|
|
213
|
-
description?: string | undefined;
|
|
214
|
-
}
|
|
215
|
-
interface SessionConfigOption {
|
|
216
|
-
id: string;
|
|
217
|
-
name: string;
|
|
218
|
-
type: 'select' | string;
|
|
219
|
-
currentValue: string;
|
|
220
|
-
options: {
|
|
221
|
-
value: string;
|
|
222
|
-
name: string;
|
|
223
|
-
description?: string | undefined;
|
|
224
|
-
}[];
|
|
225
|
-
}
|
|
226
|
-
interface ProtocolHandlerOptions {
|
|
227
|
-
transport: AgentServerTransport;
|
|
228
|
-
/** Where the server is running; used for new sessions' default cwd. */
|
|
229
|
-
defaultCwd: string;
|
|
230
|
-
/** Agent's per-turn implementation. */
|
|
231
|
-
runTurn: RunTurn;
|
|
232
|
-
/**
|
|
233
|
-
* Optional callbacks for the lifecycle events the server should
|
|
234
|
-
* surface to the client. All default to no-ops.
|
|
235
|
-
*/
|
|
236
|
-
onSessionNew?: ((state: SessionState) => void) | undefined;
|
|
237
|
-
/** Static list of available modes (advertised to clients). */
|
|
238
|
-
modes?: readonly SessionMode[] | undefined;
|
|
239
|
-
/** Static list of config options. */
|
|
240
|
-
configOptions?: readonly SessionConfigOption[] | undefined;
|
|
241
|
-
/** Agent name advertised in initialize. */
|
|
242
|
-
agentName?: string | undefined;
|
|
243
|
-
}
|
|
244
|
-
declare class ACPProtocolHandler {
|
|
245
|
-
private readonly transport;
|
|
246
|
-
private readonly defaultCwd;
|
|
247
|
-
private readonly runTurn;
|
|
248
|
-
private readonly onSessionNew;
|
|
249
|
-
private readonly modes;
|
|
250
|
-
private readonly configOptions;
|
|
251
|
-
private readonly agentName;
|
|
252
|
-
private initialized;
|
|
253
|
-
private readonly sessions;
|
|
254
|
-
private nextId;
|
|
255
|
-
constructor(opts: ProtocolHandlerOptions);
|
|
256
|
-
/**
|
|
257
|
-
* Process one inbound message. Returns true if this was a terminal
|
|
258
|
-
* message (rare; reserved for future use by the server's own
|
|
259
|
-
* shutdown signal).
|
|
260
|
-
*/
|
|
261
|
-
handleMessage(msg: unknown): Promise<boolean>;
|
|
262
|
-
/** Abort all active turns and drop session state. */
|
|
263
|
-
close(): void;
|
|
264
|
-
private handleRequest;
|
|
265
|
-
private handleInitialize;
|
|
266
|
-
private handleAuthenticate;
|
|
267
|
-
private handleSessionNew;
|
|
268
|
-
private handleSessionLoad;
|
|
269
|
-
private handleSessionPrompt;
|
|
270
|
-
private handleSetMode;
|
|
271
|
-
private handleSetConfigOption;
|
|
272
|
-
private handleSessionList;
|
|
273
|
-
private handleNotification;
|
|
274
|
-
private sendNotification;
|
|
275
|
-
private sendError;
|
|
276
|
-
private allocId;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
interface WrongStackACPServerOptions {
|
|
280
|
-
/**
|
|
281
|
-
* Per-turn implementation. If omitted, the server runs a no-op turn
|
|
282
|
-
* that just resolves with `end_turn`. The real production usage
|
|
283
|
-
* passes the result of `makeACPServerAgentTurn({ agentFor: ... })`
|
|
284
|
-
* from `./server-agent-turn.js` so each session gets a real
|
|
285
|
-
* `Agent` instance.
|
|
286
|
-
*/
|
|
287
|
-
runTurn?: RunTurn | undefined;
|
|
288
|
-
/** Default cwd for new sessions. Defaults to the current process cwd. */
|
|
289
|
-
defaultCwd?: string | undefined;
|
|
290
|
-
/** Agent name advertised in initialize. */
|
|
291
|
-
agentName?: string | undefined;
|
|
292
|
-
}
|
|
293
|
-
declare class WrongStackACPServer {
|
|
294
|
-
private readonly transport;
|
|
295
|
-
private readonly handler;
|
|
296
|
-
private running;
|
|
297
|
-
constructor(opts?: WrongStackACPServerOptions);
|
|
298
|
-
/**
|
|
299
|
-
* Start the server. Blocks until the client disconnects.
|
|
300
|
-
*
|
|
301
|
-
* 1. Print the legacy `[wstack-acp]\n` marker so the client knows the
|
|
302
|
-
* process is the ACP server (the old `StdioTransport` handshake).
|
|
303
|
-
* 2. Loop: read messages, dispatch to the handler, until EOF / error.
|
|
304
|
-
*/
|
|
305
|
-
start(): Promise<void>;
|
|
306
|
-
/** Stop the server. */
|
|
307
|
-
stop(): void;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
export { ACPProtocolHandler as A, type PermissionOption as P, type RunTurn as R, type StopReason as S, type ToolCallUpdateNotification as T, type UsageCost as U, WrongStackACPServer as W, type WrongStackACPServerOptions as a, type RequestPermissionOutcome as b, type PlanEntry as c };
|