@wrongstack/acp 0.292.1 → 0.295.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 +22 -2
- package/dist/agent/protocol-contract.d.ts +210 -0
- package/dist/agent/protocol-contract.d.ts.map +1 -0
- package/dist/agent/protocol-handler.d.ts +6 -189
- package/dist/agent/protocol-handler.d.ts.map +1 -1
- package/dist/agent/server-agent-turn.d.ts +7 -1
- package/dist/agent/server-agent-turn.d.ts.map +1 -1
- package/dist/agent/stdio-transport.d.ts +12 -1
- package/dist/agent/stdio-transport.d.ts.map +1 -1
- package/dist/agent/tools-registry.d.ts +1 -1
- package/dist/agent/tools-registry.d.ts.map +1 -1
- package/dist/agent/wrongstack-acp-agent.d.ts +2 -0
- package/dist/agent/wrongstack-acp-agent.d.ts.map +1 -1
- package/dist/agent.js +172 -22
- package/dist/agent.js.map +4 -4
- package/dist/client/acp-session.d.ts +19 -6
- package/dist/client/acp-session.d.ts.map +1 -1
- package/dist/client/index.d.ts +11 -9
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/permission.d.ts +7 -3
- package/dist/client/permission.d.ts.map +1 -1
- package/dist/client/terminal-server.d.ts +5 -0
- package/dist/client/terminal-server.d.ts.map +1 -1
- package/dist/client/tool-translator.d.ts +1 -1
- package/dist/client/tool-translator.d.ts.map +1 -1
- package/dist/client/trust-boundary-permission.d.ts +16 -0
- package/dist/client/trust-boundary-permission.d.ts.map +1 -0
- package/dist/client/websocket-transport.d.ts +6 -0
- package/dist/client/websocket-transport.d.ts.map +1 -1
- package/dist/client.js +440 -225
- package/dist/client.js.map +4 -4
- package/dist/index.d.ts +29 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2433 -2121
- package/dist/index.js.map +4 -4
- package/dist/integration/acp-subagent-runner.d.ts +3 -3
- package/dist/integration/acp-subagent-runner.d.ts.map +1 -1
- package/dist/integration/ensemble-runner.d.ts.map +1 -1
- package/dist/legacy.d.ts +8 -0
- package/dist/legacy.d.ts.map +1 -0
- package/dist/legacy.js +6 -0
- package/dist/legacy.js.map +7 -0
- package/dist/sdk.d.ts +10 -8
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +22 -0
- package/dist/sdk.js.map +3 -3
- package/dist/v1.d.ts +3 -0
- package/dist/v1.d.ts.map +1 -0
- package/dist/v1.js +12 -0
- package/dist/v1.js.map +7 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/wrongstack-acp-agent.js +107 -16
- package/dist/wrongstack-acp-agent.js.map +4 -4
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -9,6 +9,20 @@ WebSocket support plus an HTTP server transport. Some optional protocol surfaces
|
|
|
9
9
|
are intentionally unavailable; see [COMPLIANCE.md](COMPLIANCE.md) for the tested
|
|
10
10
|
surface and current limitations.
|
|
11
11
|
|
|
12
|
+
## Public entry points
|
|
13
|
+
|
|
14
|
+
| Import | Authority |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `@wrongstack/acp` | WrongStack's v1 client/server implementation, integrations, and stable v1 contracts |
|
|
17
|
+
| `@wrongstack/acp/client` | Client-only implementation surface |
|
|
18
|
+
| `@wrongstack/acp/agent` | Server/agent-only implementation surface |
|
|
19
|
+
| `@wrongstack/acp/v1` | WrongStack-owned stable v1 protocol contracts only |
|
|
20
|
+
| `@wrongstack/acp/sdk` | Official `@agentclientprotocol/sdk` APIs and experimental transport helpers |
|
|
21
|
+
| `@wrongstack/acp/legacy` | Deprecated pre-v1 draft envelope types; compatibility only |
|
|
22
|
+
|
|
23
|
+
New code must not import legacy draft contracts from the package root. Use `/v1`
|
|
24
|
+
for protocol types and `/sdk` only when intentionally adopting the upstream SDK.
|
|
25
|
+
|
|
12
26
|
## Compliance
|
|
13
27
|
|
|
14
28
|
The package test suite includes client/server protocol tests and an in-process
|
|
@@ -65,11 +79,17 @@ await server.start();
|
|
|
65
79
|
### Using the Official SDK (for advanced use cases)
|
|
66
80
|
|
|
67
81
|
```typescript
|
|
68
|
-
import {
|
|
82
|
+
import {
|
|
83
|
+
AcpServer,
|
|
84
|
+
AgentApp,
|
|
85
|
+
createHttpStream,
|
|
86
|
+
createWebSocketStream,
|
|
87
|
+
} from '@wrongstack/acp/sdk';
|
|
69
88
|
```
|
|
70
89
|
|
|
71
90
|
The `/sdk` entry point re-exports the official SDK's public high-level APIs, method
|
|
72
|
-
constants, and experimental Node/WebSocket helpers
|
|
91
|
+
constants, and experimental HTTP/Node/WebSocket helpers. WrongStack's `ACPSession`
|
|
92
|
+
is intentionally available from the package root or `/client`, not from `/sdk`.
|
|
73
93
|
|
|
74
94
|
## Architecture
|
|
75
95
|
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public contracts and wire-boundary helpers for the ACP v1 protocol handler.
|
|
3
|
+
* Keeping these declarations separate leaves the handler focused on request dispatch.
|
|
4
|
+
*/
|
|
5
|
+
import type { ACPMessage } from '../types/acp-messages.js';
|
|
6
|
+
import { ACP_PROTOCOL_VERSION, type ContentBlock, type PermissionOption, type PlanEntry, type RequestPermissionOutcome, type StopReason, type ToolKind, type UsageCost } from '../types/acp-v1.js';
|
|
7
|
+
import type { AgentServerTransport } from './stdio-transport.js';
|
|
8
|
+
export { ACP_PROTOCOL_VERSION };
|
|
9
|
+
export type { ACPMessage, ContentBlock, RequestPermissionOutcome };
|
|
10
|
+
type WireMessage = {
|
|
11
|
+
jsonrpc?: '2.0';
|
|
12
|
+
id?: string | number;
|
|
13
|
+
method?: string;
|
|
14
|
+
params?: unknown;
|
|
15
|
+
result?: unknown;
|
|
16
|
+
error?: unknown;
|
|
17
|
+
};
|
|
18
|
+
export declare function toWire(msg: WireMessage): ACPMessage;
|
|
19
|
+
export declare const WRONGSTACK_VERSION: string;
|
|
20
|
+
/** What kinds of content the agent accepts in a prompt. */
|
|
21
|
+
export interface PromptCapabilities {
|
|
22
|
+
image: boolean;
|
|
23
|
+
audio: boolean;
|
|
24
|
+
embeddedContext: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface AgentCapabilities {
|
|
27
|
+
loadSession: boolean;
|
|
28
|
+
promptCapabilities: PromptCapabilities;
|
|
29
|
+
}
|
|
30
|
+
export interface RunTurnInput {
|
|
31
|
+
sessionId: string;
|
|
32
|
+
/** Content blocks the client sent. */
|
|
33
|
+
prompt: readonly ContentBlock[];
|
|
34
|
+
/** Cancelled when the client sends `session/cancel` for this session. */
|
|
35
|
+
signal: AbortSignal;
|
|
36
|
+
}
|
|
37
|
+
export interface RunTurnResult {
|
|
38
|
+
stopReason: StopReason;
|
|
39
|
+
/** Optional summary text the agent produced. */
|
|
40
|
+
text?: string;
|
|
41
|
+
plan?: PlanEntry[];
|
|
42
|
+
usage?: {
|
|
43
|
+
used: number;
|
|
44
|
+
size: number;
|
|
45
|
+
cost?: UsageCost | undefined;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A tool-call permission request the agent surfaces to the client.
|
|
50
|
+
*/
|
|
51
|
+
export interface RunTurnPermissionRequest {
|
|
52
|
+
toolCall: {
|
|
53
|
+
toolCallId: string;
|
|
54
|
+
title: string;
|
|
55
|
+
kind?: ToolKind | undefined;
|
|
56
|
+
};
|
|
57
|
+
options: PermissionOption[];
|
|
58
|
+
}
|
|
59
|
+
/** Client filesystem/terminal capabilities advertised at initialize. */
|
|
60
|
+
export interface ClientCapabilities {
|
|
61
|
+
fs?: {
|
|
62
|
+
readTextFile?: boolean | undefined;
|
|
63
|
+
writeTextFile?: boolean | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
terminal?: boolean | undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Client-callback API handed to `runTurn`. Lets the agent's tools call back
|
|
69
|
+
* into the connected ACP client — ask for permission, and (when the client
|
|
70
|
+
* advertises the capability) use the client's filesystem and terminal so the
|
|
71
|
+
* editor's view (including unsaved buffers) is the source of truth.
|
|
72
|
+
*/
|
|
73
|
+
export interface RunTurnApi {
|
|
74
|
+
/**
|
|
75
|
+
* Ask the connected ACP client to approve/reject a tool call via the
|
|
76
|
+
* `session/request_permission` method. Resolves with the client's
|
|
77
|
+
* outcome. Rejects if no client channel is available or the request
|
|
78
|
+
* times out — the caller decides the fallback.
|
|
79
|
+
*/
|
|
80
|
+
requestPermission(req: RunTurnPermissionRequest): Promise<RequestPermissionOutcome>;
|
|
81
|
+
/** Capabilities the client advertised at initialize — gate tool wiring on these. */
|
|
82
|
+
clientCapabilities: ClientCapabilities;
|
|
83
|
+
/** Read a text file from the client's filesystem (`fs/read_text_file`). */
|
|
84
|
+
readTextFile(params: {
|
|
85
|
+
path: string;
|
|
86
|
+
line?: number;
|
|
87
|
+
limit?: number;
|
|
88
|
+
}): Promise<string>;
|
|
89
|
+
/** Write a text file in the client's filesystem (`fs/write_text_file`). */
|
|
90
|
+
writeTextFile(params: {
|
|
91
|
+
path: string;
|
|
92
|
+
content: string;
|
|
93
|
+
}): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Run a command in the client's terminal (`terminal/create` →
|
|
96
|
+
* `wait_for_exit` → `output` → `release`) and resolve with the combined
|
|
97
|
+
* output and exit code.
|
|
98
|
+
*/
|
|
99
|
+
runTerminal(params: {
|
|
100
|
+
command: string;
|
|
101
|
+
args?: string[] | undefined;
|
|
102
|
+
cwd?: string | undefined;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
output: string;
|
|
105
|
+
exitCode: number | null;
|
|
106
|
+
}>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The agent's per-turn work. Streams `SessionUpdate` notifications to
|
|
110
|
+
* `emit` and resolves with the final stopReason. Errors thrown from
|
|
111
|
+
* this iterable are converted to a `prompt_failed` JSON-RPC error.
|
|
112
|
+
*
|
|
113
|
+
* `api` is an optional client-callback surface (permission requests).
|
|
114
|
+
* Older runTurn implementations that ignore it keep working unchanged.
|
|
115
|
+
*/
|
|
116
|
+
export type RunTurn = (input: RunTurnInput, emit: (update: unknown) => void, api?: RunTurnApi) => Promise<RunTurnResult>;
|
|
117
|
+
export interface SessionState {
|
|
118
|
+
id: string;
|
|
119
|
+
cwd: string;
|
|
120
|
+
/** Per-turn abort signal — aborted when the session is cancelled or closed. */
|
|
121
|
+
abort: AbortController;
|
|
122
|
+
/** Active mode, advertised to the client in current_mode_update. */
|
|
123
|
+
modeId: string;
|
|
124
|
+
/** Created at, for session/list ordering. */
|
|
125
|
+
createdAt: string;
|
|
126
|
+
/** Last activity timestamp, for session/info_update. */
|
|
127
|
+
updatedAt: string;
|
|
128
|
+
/** Optional human title. */
|
|
129
|
+
title?: string;
|
|
130
|
+
}
|
|
131
|
+
/** MCP-style session mode advertised in current_mode_update. */
|
|
132
|
+
export interface SessionMode {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
description?: string | undefined;
|
|
136
|
+
}
|
|
137
|
+
export interface SessionConfigOption {
|
|
138
|
+
id: string;
|
|
139
|
+
name: string;
|
|
140
|
+
type: 'select' | string;
|
|
141
|
+
currentValue: string;
|
|
142
|
+
options: {
|
|
143
|
+
value: string;
|
|
144
|
+
name: string;
|
|
145
|
+
description?: string | undefined;
|
|
146
|
+
}[];
|
|
147
|
+
}
|
|
148
|
+
export interface ProtocolHandlerOptions {
|
|
149
|
+
transport: AgentServerTransport;
|
|
150
|
+
/** Where the server is running; used for new sessions' default cwd. */
|
|
151
|
+
defaultCwd: string;
|
|
152
|
+
/** Agent's per-turn implementation. */
|
|
153
|
+
runTurn: RunTurn;
|
|
154
|
+
/**
|
|
155
|
+
* Optional callbacks for the lifecycle events the server should
|
|
156
|
+
* surface to the client. All default to no-ops.
|
|
157
|
+
*/
|
|
158
|
+
onSessionNew?: ((state: SessionState) => void) | undefined;
|
|
159
|
+
/** Static list of available modes (advertised to clients). */
|
|
160
|
+
modes?: readonly SessionMode[] | undefined;
|
|
161
|
+
/** Static list of config options. */
|
|
162
|
+
configOptions?: readonly SessionConfigOption[] | undefined;
|
|
163
|
+
/** Agent name advertised in initialize. */
|
|
164
|
+
agentName?: string | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Optional source of replayable conversation history for `session/load`.
|
|
167
|
+
* Returns the `session/update` payloads (user/agent message chunks) to
|
|
168
|
+
* stream back to the client before the load response. Wired from
|
|
169
|
+
* `makeACPServerAgentTurn(...).replay`.
|
|
170
|
+
*/
|
|
171
|
+
replayFor?: ((sessionId: string) => Array<{
|
|
172
|
+
sessionUpdate: string;
|
|
173
|
+
content: unknown;
|
|
174
|
+
}>) | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Optional hook to prime the turn engine's session history on cold
|
|
177
|
+
* `session/load` (server restart). Wired from `makeACPServerAgentTurn(...).seed`
|
|
178
|
+
* — it re-feeds the persisted conversation into the next-created Agent so
|
|
179
|
+
* the model resumes, not just the client UI.
|
|
180
|
+
*/
|
|
181
|
+
seedFor?: ((sessionId: string, history: Array<{
|
|
182
|
+
sessionUpdate: string;
|
|
183
|
+
content: unknown;
|
|
184
|
+
}>) => void) | undefined;
|
|
185
|
+
/** Release per-session agent/history resources after close, delete, or handler teardown. */
|
|
186
|
+
disposeFor?: ((sessionId: string) => void) | undefined;
|
|
187
|
+
/** Maximum sessions retained concurrently by one protocol handler. Default 64. */
|
|
188
|
+
maxSessions?: number | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Optional durable session store. When set, sessions + their recorded
|
|
191
|
+
* history are persisted on create/prompt and restored on `session/load`,
|
|
192
|
+
* so a reconnecting client can resume after a server restart.
|
|
193
|
+
* (Structural type — `ACPSessionStore` satisfies it without a value import.)
|
|
194
|
+
*/
|
|
195
|
+
store?: SessionPersistence | undefined;
|
|
196
|
+
}
|
|
197
|
+
/** Minimal durable-store contract the handler uses (ACPSessionStore satisfies it). */
|
|
198
|
+
export interface SessionPersistence {
|
|
199
|
+
save(state: SessionState, history?: Array<{
|
|
200
|
+
sessionUpdate: string;
|
|
201
|
+
content: unknown;
|
|
202
|
+
}>): Promise<unknown>;
|
|
203
|
+
load(sessionId: string): Promise<(Partial<SessionState> & {
|
|
204
|
+
history?: Array<{
|
|
205
|
+
sessionUpdate: string;
|
|
206
|
+
content: unknown;
|
|
207
|
+
}> | undefined;
|
|
208
|
+
}) | null>;
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=protocol-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-contract.d.ts","sourceRoot":"","sources":["../../src/agent/protocol-contract.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAMnE,KAAK,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,KAAK,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AACnI,wBAAgB,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,UAAU,CAEnD;AAED,eAAO,MAAM,kBAAkB,QAAsB,CAAC;AACtD,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,eAAe,EAAE,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;IACjH,4FAA4F;IAC5F,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACvD,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;CACxC;AAED,sFAAsF;AACtF,MAAM,WAAW,kBAAkB;IACjC,IAAI,CACF,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,GAC3D,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,IAAI,CACF,SAAS,EAAE,MAAM,GAChB,OAAO,CACN,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG;QAAE,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,aAAa,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,OAAO,CAAA;SAAE,CAAC,GAAG,SAAS,CAAA;KAAE,CAAC,GACtG,IAAI,CACP,CAAC;CACH"}
|
|
@@ -42,195 +42,9 @@
|
|
|
42
42
|
* notification can stop the running turn mid-stream without tearing
|
|
43
43
|
* down the session. Multiple sessions can be active concurrently.
|
|
44
44
|
*/
|
|
45
|
-
import {
|
|
46
|
-
|
|
47
|
-
export
|
|
48
|
-
/** What kinds of content the agent accepts in a prompt. */
|
|
49
|
-
export interface PromptCapabilities {
|
|
50
|
-
image: boolean;
|
|
51
|
-
audio: boolean;
|
|
52
|
-
embeddedContext: boolean;
|
|
53
|
-
}
|
|
54
|
-
export interface AgentCapabilities {
|
|
55
|
-
loadSession: boolean;
|
|
56
|
-
promptCapabilities: PromptCapabilities;
|
|
57
|
-
}
|
|
58
|
-
export interface RunTurnInput {
|
|
59
|
-
sessionId: string;
|
|
60
|
-
/** Content blocks the client sent. */
|
|
61
|
-
prompt: readonly ContentBlock[];
|
|
62
|
-
/** Cancelled when the client sends `session/cancel` for this session. */
|
|
63
|
-
signal: AbortSignal;
|
|
64
|
-
}
|
|
65
|
-
export interface RunTurnResult {
|
|
66
|
-
stopReason: StopReason;
|
|
67
|
-
/** Optional summary text the agent produced. */
|
|
68
|
-
text?: string;
|
|
69
|
-
plan?: PlanEntry[];
|
|
70
|
-
usage?: {
|
|
71
|
-
used: number;
|
|
72
|
-
size: number;
|
|
73
|
-
cost?: UsageCost | undefined;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* A tool-call permission request the agent surfaces to the client.
|
|
78
|
-
*/
|
|
79
|
-
export interface RunTurnPermissionRequest {
|
|
80
|
-
toolCall: {
|
|
81
|
-
toolCallId: string;
|
|
82
|
-
title: string;
|
|
83
|
-
kind?: ToolKind | undefined;
|
|
84
|
-
};
|
|
85
|
-
options: PermissionOption[];
|
|
86
|
-
}
|
|
87
|
-
/** Client filesystem/terminal capabilities advertised at initialize. */
|
|
88
|
-
export interface ClientCapabilities {
|
|
89
|
-
fs?: {
|
|
90
|
-
readTextFile?: boolean | undefined;
|
|
91
|
-
writeTextFile?: boolean | undefined;
|
|
92
|
-
} | undefined;
|
|
93
|
-
terminal?: boolean | undefined;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Client-callback API handed to `runTurn`. Lets the agent's tools call back
|
|
97
|
-
* into the connected ACP client — ask for permission, and (when the client
|
|
98
|
-
* advertises the capability) use the client's filesystem and terminal so the
|
|
99
|
-
* editor's view (including unsaved buffers) is the source of truth.
|
|
100
|
-
*/
|
|
101
|
-
export interface RunTurnApi {
|
|
102
|
-
/**
|
|
103
|
-
* Ask the connected ACP client to approve/reject a tool call via the
|
|
104
|
-
* `session/request_permission` method. Resolves with the client's
|
|
105
|
-
* outcome. Rejects if no client channel is available or the request
|
|
106
|
-
* times out — the caller decides the fallback.
|
|
107
|
-
*/
|
|
108
|
-
requestPermission(req: RunTurnPermissionRequest): Promise<RequestPermissionOutcome>;
|
|
109
|
-
/** Capabilities the client advertised at initialize — gate tool wiring on these. */
|
|
110
|
-
clientCapabilities: ClientCapabilities;
|
|
111
|
-
/** Read a text file from the client's filesystem (`fs/read_text_file`). */
|
|
112
|
-
readTextFile(params: {
|
|
113
|
-
path: string;
|
|
114
|
-
line?: number;
|
|
115
|
-
limit?: number;
|
|
116
|
-
}): Promise<string>;
|
|
117
|
-
/** Write a text file in the client's filesystem (`fs/write_text_file`). */
|
|
118
|
-
writeTextFile(params: {
|
|
119
|
-
path: string;
|
|
120
|
-
content: string;
|
|
121
|
-
}): Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* Run a command in the client's terminal (`terminal/create` →
|
|
124
|
-
* `wait_for_exit` → `output` → `release`) and resolve with the combined
|
|
125
|
-
* output and exit code.
|
|
126
|
-
*/
|
|
127
|
-
runTerminal(params: {
|
|
128
|
-
command: string;
|
|
129
|
-
args?: string[] | undefined;
|
|
130
|
-
cwd?: string | undefined;
|
|
131
|
-
}): Promise<{
|
|
132
|
-
output: string;
|
|
133
|
-
exitCode: number | null;
|
|
134
|
-
}>;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* The agent's per-turn work. Streams `SessionUpdate` notifications to
|
|
138
|
-
* `emit` and resolves with the final stopReason. Errors thrown from
|
|
139
|
-
* this iterable are converted to a `prompt_failed` JSON-RPC error.
|
|
140
|
-
*
|
|
141
|
-
* `api` is an optional client-callback surface (permission requests).
|
|
142
|
-
* Older runTurn implementations that ignore it keep working unchanged.
|
|
143
|
-
*/
|
|
144
|
-
export type RunTurn = (input: RunTurnInput, emit: (update: unknown) => void, api?: RunTurnApi) => Promise<RunTurnResult>;
|
|
145
|
-
export interface SessionState {
|
|
146
|
-
id: string;
|
|
147
|
-
cwd: string;
|
|
148
|
-
/** Per-turn abort signal — aborted when the session is cancelled or closed. */
|
|
149
|
-
abort: AbortController;
|
|
150
|
-
/** Active mode, advertised to the client in current_mode_update. */
|
|
151
|
-
modeId: string;
|
|
152
|
-
/** Created at, for session/list ordering. */
|
|
153
|
-
createdAt: string;
|
|
154
|
-
/** Last activity timestamp, for session/info_update. */
|
|
155
|
-
updatedAt: string;
|
|
156
|
-
/** Optional human title. */
|
|
157
|
-
title?: string;
|
|
158
|
-
}
|
|
159
|
-
/** MCP-style session mode advertised in current_mode_update. */
|
|
160
|
-
export interface SessionMode {
|
|
161
|
-
id: string;
|
|
162
|
-
name: string;
|
|
163
|
-
description?: string | undefined;
|
|
164
|
-
}
|
|
165
|
-
export interface SessionConfigOption {
|
|
166
|
-
id: string;
|
|
167
|
-
name: string;
|
|
168
|
-
type: 'select' | string;
|
|
169
|
-
currentValue: string;
|
|
170
|
-
options: {
|
|
171
|
-
value: string;
|
|
172
|
-
name: string;
|
|
173
|
-
description?: string | undefined;
|
|
174
|
-
}[];
|
|
175
|
-
}
|
|
176
|
-
export interface ProtocolHandlerOptions {
|
|
177
|
-
transport: AgentServerTransport;
|
|
178
|
-
/** Where the server is running; used for new sessions' default cwd. */
|
|
179
|
-
defaultCwd: string;
|
|
180
|
-
/** Agent's per-turn implementation. */
|
|
181
|
-
runTurn: RunTurn;
|
|
182
|
-
/**
|
|
183
|
-
* Optional callbacks for the lifecycle events the server should
|
|
184
|
-
* surface to the client. All default to no-ops.
|
|
185
|
-
*/
|
|
186
|
-
onSessionNew?: ((state: SessionState) => void) | undefined;
|
|
187
|
-
/** Static list of available modes (advertised to clients). */
|
|
188
|
-
modes?: readonly SessionMode[] | undefined;
|
|
189
|
-
/** Static list of config options. */
|
|
190
|
-
configOptions?: readonly SessionConfigOption[] | undefined;
|
|
191
|
-
/** Agent name advertised in initialize. */
|
|
192
|
-
agentName?: string | undefined;
|
|
193
|
-
/**
|
|
194
|
-
* Optional source of replayable conversation history for `session/load`.
|
|
195
|
-
* Returns the `session/update` payloads (user/agent message chunks) to
|
|
196
|
-
* stream back to the client before the load response. Wired from
|
|
197
|
-
* `makeACPServerAgentTurn(...).replay`.
|
|
198
|
-
*/
|
|
199
|
-
replayFor?: ((sessionId: string) => Array<{
|
|
200
|
-
sessionUpdate: string;
|
|
201
|
-
content: unknown;
|
|
202
|
-
}>) | undefined;
|
|
203
|
-
/**
|
|
204
|
-
* Optional hook to prime the turn engine's session history on cold
|
|
205
|
-
* `session/load` (server restart). Wired from `makeACPServerAgentTurn(...).seed`
|
|
206
|
-
* — it re-feeds the persisted conversation into the next-created Agent so
|
|
207
|
-
* the model resumes, not just the client UI.
|
|
208
|
-
*/
|
|
209
|
-
seedFor?: ((sessionId: string, history: Array<{
|
|
210
|
-
sessionUpdate: string;
|
|
211
|
-
content: unknown;
|
|
212
|
-
}>) => void) | undefined;
|
|
213
|
-
/**
|
|
214
|
-
* Optional durable session store. When set, sessions + their recorded
|
|
215
|
-
* history are persisted on create/prompt and restored on `session/load`,
|
|
216
|
-
* so a reconnecting client can resume after a server restart.
|
|
217
|
-
* (Structural type — `ACPSessionStore` satisfies it without a value import.)
|
|
218
|
-
*/
|
|
219
|
-
store?: SessionPersistence | undefined;
|
|
220
|
-
}
|
|
221
|
-
/** Minimal durable-store contract the handler uses (ACPSessionStore satisfies it). */
|
|
222
|
-
export interface SessionPersistence {
|
|
223
|
-
save(state: SessionState, history?: Array<{
|
|
224
|
-
sessionUpdate: string;
|
|
225
|
-
content: unknown;
|
|
226
|
-
}>): Promise<unknown>;
|
|
227
|
-
load(sessionId: string): Promise<(Partial<SessionState> & {
|
|
228
|
-
history?: Array<{
|
|
229
|
-
sessionUpdate: string;
|
|
230
|
-
content: unknown;
|
|
231
|
-
}> | undefined;
|
|
232
|
-
}) | null>;
|
|
233
|
-
}
|
|
45
|
+
import { WRONGSTACK_VERSION, type ProtocolHandlerOptions } from './protocol-contract.js';
|
|
46
|
+
export { WRONGSTACK_VERSION };
|
|
47
|
+
export type { AgentCapabilities, ClientCapabilities, PromptCapabilities, ProtocolHandlerOptions, RunTurn, RunTurnApi, RunTurnInput, RunTurnPermissionRequest, RunTurnResult, SessionConfigOption, SessionMode, SessionPersistence, SessionState, } from './protocol-contract.js';
|
|
234
48
|
export declare class ACPProtocolHandler {
|
|
235
49
|
private readonly transport;
|
|
236
50
|
private readonly defaultCwd;
|
|
@@ -241,6 +55,8 @@ export declare class ACPProtocolHandler {
|
|
|
241
55
|
private readonly agentName;
|
|
242
56
|
private readonly replayFor;
|
|
243
57
|
private readonly seedFor;
|
|
58
|
+
private readonly disposeFor;
|
|
59
|
+
private readonly maxSessions;
|
|
244
60
|
private readonly store;
|
|
245
61
|
private initialized;
|
|
246
62
|
private clientCapabilities;
|
|
@@ -264,6 +80,7 @@ export declare class ACPProtocolHandler {
|
|
|
264
80
|
handleMessage(msg: unknown): Promise<boolean>;
|
|
265
81
|
/** Abort all active turns and drop session state. */
|
|
266
82
|
close(): void;
|
|
83
|
+
private disposeSession;
|
|
267
84
|
private handleRequest;
|
|
268
85
|
private handleInitialize;
|
|
269
86
|
private handleAuthenticate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-handler.d.ts","sourceRoot":"","sources":["../../src/agent/protocol-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,EAEL,
|
|
1
|
+
{"version":3,"file":"protocol-handler.d.ts","sourceRoot":"","sources":["../../src/agent/protocol-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,EAEL,kBAAkB,EAKlB,KAAK,sBAAsB,EAS5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,wBAAwB,EACxB,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,YAAY,GACb,MAAM,wBAAwB,CAA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lB,sBAAsB;YAStB,gBAAgB;YAKhB,mBAAmB;YAoGnB,aAAa;YAmBb,qBAAqB;YAwBrB,iBAAiB;YAsBjB,kBAAkB;YA6BlB,gBAAgB;IAI9B,2EAA2E;YAC7D,OAAO;YAYP,SAAS;IAWvB,OAAO,CAAC,OAAO;CAGhB"}
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* it. On abort, the adapter maps the resulting `AbortError` to
|
|
39
39
|
* `{stopReason: 'cancelled'}`.
|
|
40
40
|
*/
|
|
41
|
-
import type { Agent } from '@wrongstack/core';
|
|
41
|
+
import type { Agent } from '@wrongstack/core/agent';
|
|
42
42
|
import type { RunTurn, RunTurnApi, RunTurnResult } from './protocol-handler.js';
|
|
43
43
|
export interface ACPServerAgentTurnOptions {
|
|
44
44
|
/**
|
|
@@ -60,6 +60,10 @@ export interface ACPServerAgentTurnOptions {
|
|
|
60
60
|
* Default 5 minutes.
|
|
61
61
|
*/
|
|
62
62
|
timeoutMs?: number | undefined;
|
|
63
|
+
/** Maximum replay entries retained per session. Default 1000. */
|
|
64
|
+
maxHistoryEntries?: number | undefined;
|
|
65
|
+
/** Maximum serialized replay bytes retained per session. Default 8 MiB. */
|
|
66
|
+
maxHistoryBytes?: number | undefined;
|
|
63
67
|
}
|
|
64
68
|
/** A recorded conversation turn, replayable on `session/load`. */
|
|
65
69
|
interface SessionReplayUpdate {
|
|
@@ -87,6 +91,8 @@ export interface ACPServerAgentTurn {
|
|
|
87
91
|
sessionUpdate: string;
|
|
88
92
|
content: unknown;
|
|
89
93
|
}>): void;
|
|
94
|
+
/** Drop the session's Agent, timers, seed marker, and in-memory replay history. */
|
|
95
|
+
dispose(sessionId: string): void;
|
|
90
96
|
}
|
|
91
97
|
/**
|
|
92
98
|
* Build a `RunTurn` that owns per-session `Agent` instances and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-agent-turn.d.ts","sourceRoot":"","sources":["../../src/agent/server-agent-turn.ts"],"names":[],"mappings":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AA8D;IAC9D,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAAC;IACjD;;;;;OAKG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IACnG,mFAAmF;IACnF,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,yBAAyB,GAC9B,kBAAkB,CA2MpB;AA8GD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE;IAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;CAAE,GACnC,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -26,7 +26,12 @@ export declare class StdioTransport implements AgentServerTransport {
|
|
|
26
26
|
private closed;
|
|
27
27
|
private resolveRead;
|
|
28
28
|
private messageQueue;
|
|
29
|
-
|
|
29
|
+
private readonly maxFrameChars;
|
|
30
|
+
private readonly maxQueuedMessages;
|
|
31
|
+
constructor(opts?: {
|
|
32
|
+
maxFrameChars?: number;
|
|
33
|
+
maxQueuedMessages?: number;
|
|
34
|
+
});
|
|
30
35
|
sendStartupMarker(): void;
|
|
31
36
|
send(msg: ACPMessage): Promise<void>;
|
|
32
37
|
sendRaw(chunk: string): void;
|
|
@@ -52,6 +57,10 @@ export interface ClientTransportOptions {
|
|
|
52
57
|
* server-side transport (the default) keeps the marker check.
|
|
53
58
|
*/
|
|
54
59
|
skipHandshakeMarker?: boolean | undefined;
|
|
60
|
+
/** Maximum pending newline-delimited JSON frame size. Default 20 MiB. */
|
|
61
|
+
maxFrameChars?: number | undefined;
|
|
62
|
+
/** Maximum messages retained for the optional read() API. Default 1000. */
|
|
63
|
+
maxQueuedMessages?: number | undefined;
|
|
55
64
|
}
|
|
56
65
|
export interface ACPChildProcess extends EventEmitter {
|
|
57
66
|
stdout: NodeJS.ReadableStream;
|
|
@@ -68,6 +77,8 @@ export declare class ClientTransport implements ACPClientTransport {
|
|
|
68
77
|
private resolveRead;
|
|
69
78
|
private messageQueue;
|
|
70
79
|
private readonly opts;
|
|
80
|
+
private readonly maxFrameChars;
|
|
81
|
+
private readonly maxQueuedMessages;
|
|
71
82
|
constructor(options: ClientTransportOptions);
|
|
72
83
|
start(): Promise<void>;
|
|
73
84
|
send(msg: ACPMessage): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio-transport.d.ts","sourceRoot":"","sources":["../../src/agent/stdio-transport.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"stdio-transport.d.ts","sourceRoot":"","sources":["../../src/agent/stdio-transport.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAU3D,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,IAAI,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnC,KAAK,IAAI,IAAI,CAAC;IACd,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC3D;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAA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U,KAAK,IAAI,GAAG,MAAM,IAAI,CAGxD;IAED,IAAI,IAAI,IAAI,CAeX;IAED,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,QAAQ;CAqBjB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Translates WrongStack Tool definitions → ACP ACPToolDefinition format.
|
|
5
5
|
* Provides tool lookup and result assembly for the ACP protocol handler.
|
|
6
6
|
*/
|
|
7
|
-
import type { Tool } from '@wrongstack/core';
|
|
7
|
+
import type { Tool } from '@wrongstack/core/types';
|
|
8
8
|
import type { ACPToolList, ACPToolResult } from '../types/acp-messages.js';
|
|
9
9
|
export declare class ACPToolsRegistry {
|
|
10
10
|
private tools;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-registry.d.ts","sourceRoot":"","sources":["../../src/agent/tools-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tools-registry.d.ts","sourceRoot":"","sources":["../../src/agent/tools-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAEV,WAAW,EAEX,aAAa,EAEd,MAAM,0BAA0B,CAAC;AAElC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B,YAAY,KAAK,SAAe,EAE/B;IAED;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAI5B;IAED;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAG5B;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAElC;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzB;IAED,IAAI,IAAI,IAAI,EAAE,CAEb;IAED,8DAA8D;IAC9D,aAAa,IAAI,WAAW,CAM3B;IAED;;;OAGG;IACG,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAa/B;CACF"}
|
|
@@ -37,6 +37,8 @@ export interface WrongStackACPServerOptions {
|
|
|
37
37
|
sessionUpdate: string;
|
|
38
38
|
content: unknown;
|
|
39
39
|
}>) => void) | undefined;
|
|
40
|
+
/** Per-session cleanup hook, normally `makeACPServerAgentTurn(...).dispose`. */
|
|
41
|
+
disposeFor?: ((sessionId: string) => void) | undefined;
|
|
40
42
|
/**
|
|
41
43
|
* Durable session store. When set, sessions + history are persisted and
|
|
42
44
|
* restored across restarts for `session/load`. Pass an `ACPSessionStore`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrongstack-acp-agent.d.ts","sourceRoot":"","sources":["../../src/agent/wrongstack-acp-agent.ts"],"names":[],"mappings":"AA8BA,OAAO,EAEL,KAAK,OAAO,EAEZ,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAG/B,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IACzC,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,kEAAkE;IAClE,m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