@automatalabs/acp-agents 0.14.0 → 0.16.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/dist/acp-client.d.ts +20 -3
- package/dist/acp-client.d.ts.map +1 -1
- package/dist/acp-client.js +236 -9
- package/dist/capabilities.d.ts +10 -7
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +15 -9
- package/dist/client-handlers.d.ts +19 -4
- package/dist/client-handlers.d.ts.map +1 -1
- package/dist/client-handlers.js +25 -8
- package/dist/events.d.ts +24 -2
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +3 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/interactive.d.ts +7 -5
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +2 -2
- package/dist/permissions.d.ts +5 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/pool.d.ts +3 -1
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +2 -0
- package/dist/protocol-coverage.js +5 -5
- package/dist/runner.d.ts +7 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +10 -1
- package/package.json +2 -2
package/dist/acp-client.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type ContentBlock, type AgentNotificationMethod, type AgentNotificationParamsByMethod, type AgentRequestMethod, type AgentRequestParamsByMethod, type AgentRequestResponsesByMethod, type DeleteSessionRequest, type ListSessionsRequest, type ListSessionsResponse, type PromptRequest, type PromptResponse, type RequestPermissionResponse, type SendRequestOptions, type SessionConfigOption, type SessionModeState, type SessionNotification, type SetSessionConfigOptionRequest, type SetSessionConfigOptionResponse, type SetSessionModeRequest, type SetSessionModeResponse } from "@agentclientprotocol/sdk";
|
|
1
|
+
import { type CreateElicitationResponse, type ContentBlock, type AgentNotificationMethod, type AgentNotificationParamsByMethod, type AgentRequestMethod, type AgentRequestParamsByMethod, type AgentRequestResponsesByMethod, type DeleteSessionRequest, type ListSessionsRequest, type ListSessionsResponse, type PromptRequest, type PromptResponse, type RequestPermissionResponse, type SendRequestOptions, type SessionConfigOption, type SessionModeState, type SessionNotification, type SetSessionConfigOptionRequest, type SetSessionConfigOptionResponse, type SetSessionModeRequest, type SetSessionModeResponse } from "@agentclientprotocol/sdk";
|
|
2
2
|
import type { TSchema } from "typebox";
|
|
3
3
|
import { type AgentHistoryEntry, type McpServerConfig } from "@automatalabs/shared-types";
|
|
4
4
|
import type { Backend, BackendId, StructuredSource } from "./backend.js";
|
|
5
5
|
import { type NegotiatedCapabilities } from "./capabilities.js";
|
|
6
6
|
import { type AcpEventSink } from "./events.js";
|
|
7
|
-
import { type PermissionResolver, type ToolPolicy } from "./permissions.js";
|
|
7
|
+
import { type ElicitationResolver, type PermissionResolver, type ToolPolicy } from "./permissions.js";
|
|
8
8
|
import { UsageAccumulator } from "./usage.js";
|
|
9
9
|
import { type ClientHandlers } from "./client-handlers.js";
|
|
10
10
|
interface RawResultSuccess {
|
|
@@ -18,19 +18,24 @@ declare class SessionState {
|
|
|
18
18
|
readonly cwd: string;
|
|
19
19
|
readonly policy: ToolPolicy;
|
|
20
20
|
readonly permissionResolver?: PermissionResolver | undefined;
|
|
21
|
+
readonly elicitationResolver?: ElicitationResolver | undefined;
|
|
21
22
|
readonly label?: string | undefined;
|
|
22
23
|
readonly runId?: string | undefined;
|
|
24
|
+
readonly mcpServerIds: readonly string[];
|
|
23
25
|
private readonly retainSessionLog;
|
|
24
26
|
readonly textChunks: string[];
|
|
25
27
|
readonly history: AgentHistoryEntry[];
|
|
26
28
|
readonly usage: UsageAccumulator;
|
|
27
29
|
readonly pendingPermissions: Set<(outcome: RequestPermissionResponse) => void>;
|
|
30
|
+
readonly pendingElicitations: Set<(outcome: CreateElicitationResponse) => void>;
|
|
31
|
+
readonly urlElicitationIds: Set<string>;
|
|
32
|
+
readonly mcpConnectionIds: Set<string>;
|
|
28
33
|
rawResultSuccess: RawResultSuccess | undefined;
|
|
29
34
|
modes: SessionModeState | null | undefined;
|
|
30
35
|
private turnStartIndex;
|
|
31
36
|
/** `label`/`runId` are carried here ONLY so the MultiplexClient can stamp them onto emitted
|
|
32
37
|
* events as context — they never affect routing or the wire request. */
|
|
33
|
-
constructor(cwd: string, policy: ToolPolicy, permissionResolver?: PermissionResolver | undefined, label?: string | undefined, runId?: string | undefined, modes?: SessionModeState | null, retainSessionLog?: boolean);
|
|
38
|
+
constructor(cwd: string, policy: ToolPolicy, permissionResolver?: PermissionResolver | undefined, elicitationResolver?: ElicitationResolver | undefined, label?: string | undefined, runId?: string | undefined, modes?: SessionModeState | null, mcpServerIds?: readonly string[], retainSessionLog?: boolean);
|
|
34
39
|
/** Mark the start of a new turn so currentTurnText()/structured_output read only this turn.
|
|
35
40
|
* Long-lived interactive sessions can opt out of retaining old text/history because hosts
|
|
36
41
|
* stream live events and keep their own transcript; clearing here prevents dead logs from
|
|
@@ -42,6 +47,9 @@ declare class SessionState {
|
|
|
42
47
|
/** Settle every deferred permission still parked on this session. Used by release/cancel/death
|
|
43
48
|
* teardown so an interactive resolver can never strand an ACP prompt turn. */
|
|
44
49
|
settlePendingPermissions(): void;
|
|
50
|
+
/** Same teardown guarantee for elicitation/create: a parked human prompt must not survive
|
|
51
|
+
* release/cancel/death after its ACP session is gone. */
|
|
52
|
+
settlePendingElicitations(): void;
|
|
45
53
|
}
|
|
46
54
|
export interface AcpSessionOptions {
|
|
47
55
|
/** Absolute working directory for the ACP session (worktree isolation). */
|
|
@@ -52,6 +60,9 @@ export interface AcpSessionOptions {
|
|
|
52
60
|
/** Session-scoped permission resolver. When present it wins over the runner default and
|
|
53
61
|
* replaces the synchronous ToolPolicy auto-response path for this session. */
|
|
54
62
|
permissionResolver?: PermissionResolver;
|
|
63
|
+
/** Session-scoped elicitation resolver. When present it wins over the runner default for this
|
|
64
|
+
* session; initialize-time advertisement still depends on the runner-wide resolver. */
|
|
65
|
+
elicitationResolver?: ElicitationResolver;
|
|
55
66
|
signal?: AbortSignal;
|
|
56
67
|
/** Client-provided MCP servers to attach at session/new. Omitted => `[]` (the default). */
|
|
57
68
|
mcpServers?: McpServerConfig[];
|
|
@@ -83,6 +94,11 @@ export interface PooledConnectionDeps {
|
|
|
83
94
|
onEvent?: AcpEventSink;
|
|
84
95
|
/** Runner-wide permission resolver default. SessionState.permissionResolver overrides it. */
|
|
85
96
|
permissionResolver?: PermissionResolver;
|
|
97
|
+
/** Runner-wide elicitation resolver default. SessionState.elicitationResolver overrides it. */
|
|
98
|
+
elicitationResolver?: ElicitationResolver;
|
|
99
|
+
/** Initialize-time elicitation advertisement; fixed per connection, so it is driven by the
|
|
100
|
+
* runner-wide resolver rather than session-scoped responders attached later. */
|
|
101
|
+
advertiseElicitation?: boolean;
|
|
86
102
|
/** Client-side ACP fs/terminal handlers advertised once and routed by sessionId. */
|
|
87
103
|
clientHandlers?: ClientHandlers;
|
|
88
104
|
}
|
|
@@ -102,6 +118,7 @@ export declare class PooledConnection {
|
|
|
102
118
|
private readonly onDead;
|
|
103
119
|
private readonly onEvent;
|
|
104
120
|
private readonly clientHandlers;
|
|
121
|
+
private readonly advertiseElicitation;
|
|
105
122
|
/** Set true at the start of dispose() so the graceful-shutdown death is NOT reported as a crash. */
|
|
106
123
|
private disposing;
|
|
107
124
|
/** Resolves once `initialize` completed (or rejects if the process died first). */
|
package/dist/acp-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-client.d.ts","sourceRoot":"","sources":["../src/acp-client.ts"],"names":[],"mappings":"AAwBA,OAAO,
|
|
1
|
+
{"version":3,"file":"acp-client.d.ts","sourceRoot":"","sources":["../src/acp-client.ts"],"names":[],"mappings":"AAwBA,OAAO,EAcL,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAGlC,KAAK,oB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IAAI,KAAK,IAAI,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAE/C;IAED;;;;;;;;;;;;;;;;;OAiBG;IACG,WAAW,CACf,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAgBjF;;;;;;;OAOG;YACW,mBAAmB;IAoDjC;;6EAEyE;YAC3D,iBAAiB;IAS/B,oFAAoF;IAC9E,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc5C,yEAAyE;IACnE,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAoB7G,2DAA2D;IAC3D,eAAe,IAAI,MAAM;IAIzB,qFAAqF;IACrF,mBAAmB,IAAI,OAAO;IAI9B,gGAAgG;IAC1F,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,6EAA6E;IACvE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B"}
|
package/dist/acp-client.js
CHANGED
|
@@ -26,9 +26,9 @@ import { AGENT_METHODS, client, CLIENT_METHODS, ndJsonStream, PROTOCOL_VERSION,
|
|
|
26
26
|
import { META_KEYS, WorkflowError, WorkflowErrorCode, } from "@automatalabs/shared-types";
|
|
27
27
|
import { adaptPromptContent, describeLifecycleAdvertisement, gateCustomMeta, isSupportedProtocolVersion, negotiateCapabilities, unsupportedMcpServer, } from "./capabilities.js";
|
|
28
28
|
import { emitSessionUpdate } from "./events.js";
|
|
29
|
-
import { decidePermission } from "./permissions.js";
|
|
29
|
+
import { decidePermission, } from "./permissions.js";
|
|
30
30
|
import { UsageAccumulator } from "./usage.js";
|
|
31
|
-
import { clientCapabilitiesFor, } from "./client-handlers.js";
|
|
31
|
+
import { clientCapabilitiesFor, hasFullMcpHandlers, } from "./client-handlers.js";
|
|
32
32
|
/** A benign client identity. NOT JetBrains/IntelliJ 2026.1 — that exact identity makes
|
|
33
33
|
* codex-acp disable session config options (our model/effort routing channel). */
|
|
34
34
|
const CLIENT_INFO = {
|
|
@@ -51,30 +51,41 @@ const GUARDED_STATEFUL_REQUESTS = new Map([
|
|
|
51
51
|
"no driven wrapper yet; raw forked sessions cannot be routed (permissions auto-cancel)",
|
|
52
52
|
],
|
|
53
53
|
]);
|
|
54
|
+
const parseConnectMcpRequest = (params) => params;
|
|
55
|
+
const parseMessageMcpRequest = (params) => params;
|
|
56
|
+
const parseMessageMcpNotification = (params) => params;
|
|
57
|
+
const parseDisconnectMcpRequest = (params) => params;
|
|
54
58
|
/** Per-session accumulator: assistant text, tool history, usage, the Claude raw structured_output,
|
|
55
59
|
* and the permission policy/resolver used to answer permission requests for THIS session. */
|
|
56
60
|
class SessionState {
|
|
57
61
|
cwd;
|
|
58
62
|
policy;
|
|
59
63
|
permissionResolver;
|
|
64
|
+
elicitationResolver;
|
|
60
65
|
label;
|
|
61
66
|
runId;
|
|
67
|
+
mcpServerIds;
|
|
62
68
|
retainSessionLog;
|
|
63
69
|
textChunks = [];
|
|
64
70
|
history = [];
|
|
65
71
|
usage = new UsageAccumulator();
|
|
66
72
|
pendingPermissions = new Set();
|
|
73
|
+
pendingElicitations = new Set();
|
|
74
|
+
urlElicitationIds = new Set();
|
|
75
|
+
mcpConnectionIds = new Set();
|
|
67
76
|
rawResultSuccess;
|
|
68
77
|
modes;
|
|
69
78
|
turnStartIndex = 0;
|
|
70
79
|
/** `label`/`runId` are carried here ONLY so the MultiplexClient can stamp them onto emitted
|
|
71
80
|
* events as context — they never affect routing or the wire request. */
|
|
72
|
-
constructor(cwd, policy, permissionResolver, label, runId, modes, retainSessionLog = true) {
|
|
81
|
+
constructor(cwd, policy, permissionResolver, elicitationResolver, label, runId, modes, mcpServerIds = [], retainSessionLog = true) {
|
|
73
82
|
this.cwd = cwd;
|
|
74
83
|
this.policy = policy;
|
|
75
84
|
this.permissionResolver = permissionResolver;
|
|
85
|
+
this.elicitationResolver = elicitationResolver;
|
|
76
86
|
this.label = label;
|
|
77
87
|
this.runId = runId;
|
|
88
|
+
this.mcpServerIds = mcpServerIds;
|
|
78
89
|
this.retainSessionLog = retainSessionLog;
|
|
79
90
|
this.modes = modes;
|
|
80
91
|
}
|
|
@@ -149,6 +160,12 @@ class SessionState {
|
|
|
149
160
|
for (const settle of [...this.pendingPermissions])
|
|
150
161
|
settle(cancelledPermissionResponse());
|
|
151
162
|
}
|
|
163
|
+
/** Same teardown guarantee for elicitation/create: a parked human prompt must not survive
|
|
164
|
+
* release/cancel/death after its ACP session is gone. */
|
|
165
|
+
settlePendingElicitations() {
|
|
166
|
+
for (const settle of [...this.pendingElicitations])
|
|
167
|
+
settle(cancelledElicitationResponse());
|
|
168
|
+
}
|
|
152
169
|
}
|
|
153
170
|
/** The single client-side handler set for one pooled connection (registered on the SDK's fluent
|
|
154
171
|
* client() app). It ROUTES every notification and permission request to the per-session
|
|
@@ -159,7 +176,11 @@ class MultiplexClient {
|
|
|
159
176
|
onEvent;
|
|
160
177
|
handlers;
|
|
161
178
|
permissionResolver;
|
|
179
|
+
elicitationResolver;
|
|
162
180
|
sessions = new Map();
|
|
181
|
+
urlElicitationContexts = new Map();
|
|
182
|
+
mcpServerSessions = new Map();
|
|
183
|
+
mcpConnectionSessions = new Map();
|
|
163
184
|
/** Recently unregistered sessions kept ONLY for the teardown window: ACP agents may
|
|
164
185
|
* legitimately release terminals (or finish fs/terminal cleanup) after this client releases
|
|
165
186
|
* the session because session/close is cancel + free resources and the Agent owns terminal
|
|
@@ -168,11 +189,12 @@ class MultiplexClient {
|
|
|
168
189
|
/** `backendId` stamps event context; `onEvent` (optional) bubbles every notification, permission
|
|
169
190
|
* request and session lifecycle change up to the runner's typed bus. `permissionResolver` is
|
|
170
191
|
* the runner-wide default; a SessionState resolver wins when present. */
|
|
171
|
-
constructor(backendId, onEvent, handlers, permissionResolver) {
|
|
192
|
+
constructor(backendId, onEvent, handlers, permissionResolver, elicitationResolver) {
|
|
172
193
|
this.backendId = backendId;
|
|
173
194
|
this.onEvent = onEvent;
|
|
174
195
|
this.handlers = handlers;
|
|
175
196
|
this.permissionResolver = permissionResolver;
|
|
197
|
+
this.elicitationResolver = elicitationResolver;
|
|
176
198
|
}
|
|
177
199
|
contextFor(sessionId, state) {
|
|
178
200
|
return { sessionId, backendId: this.backendId, label: state?.label, runId: state?.runId };
|
|
@@ -195,13 +217,24 @@ class MultiplexClient {
|
|
|
195
217
|
register(sessionId, state) {
|
|
196
218
|
this.tombstones.delete(sessionId);
|
|
197
219
|
this.sessions.set(sessionId, state);
|
|
220
|
+
for (const serverId of state.mcpServerIds)
|
|
221
|
+
this.mcpServerSessions.set(serverId, sessionId);
|
|
198
222
|
this.onEvent?.("session_open", this.contextFor(sessionId, state));
|
|
199
223
|
}
|
|
200
224
|
unregister(sessionId) {
|
|
201
225
|
const state = this.sessions.get(sessionId);
|
|
202
226
|
state?.settlePendingPermissions();
|
|
227
|
+
state?.settlePendingElicitations();
|
|
228
|
+
if (state)
|
|
229
|
+
this.disconnectMcpConnectionsForSession(sessionId, state);
|
|
203
230
|
this.sessions.delete(sessionId);
|
|
204
231
|
if (state) {
|
|
232
|
+
for (const serverId of state.mcpServerIds) {
|
|
233
|
+
if (this.mcpServerSessions.get(serverId) === sessionId)
|
|
234
|
+
this.mcpServerSessions.delete(serverId);
|
|
235
|
+
}
|
|
236
|
+
for (const elicitationId of state.urlElicitationIds)
|
|
237
|
+
this.urlElicitationContexts.delete(elicitationId);
|
|
205
238
|
this.tombstones.set(sessionId, {
|
|
206
239
|
cwd: state.cwd,
|
|
207
240
|
label: state.label,
|
|
@@ -219,11 +252,25 @@ class MultiplexClient {
|
|
|
219
252
|
settlePendingPermissions(sessionId) {
|
|
220
253
|
this.sessions.get(sessionId)?.settlePendingPermissions();
|
|
221
254
|
}
|
|
255
|
+
settlePendingElicitations(sessionId) {
|
|
256
|
+
this.sessions.get(sessionId)?.settlePendingElicitations();
|
|
257
|
+
}
|
|
222
258
|
settleAllPendingPermissions() {
|
|
223
259
|
for (const state of this.sessions.values()) {
|
|
224
260
|
state.settlePendingPermissions();
|
|
225
261
|
}
|
|
226
262
|
}
|
|
263
|
+
settleAllPendingElicitations() {
|
|
264
|
+
for (const state of this.sessions.values()) {
|
|
265
|
+
state.settlePendingElicitations();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
disconnectAllMcpConnections() {
|
|
269
|
+
for (const [sessionId, state] of this.sessions) {
|
|
270
|
+
this.disconnectMcpConnectionsForSession(sessionId, state);
|
|
271
|
+
}
|
|
272
|
+
this.mcpServerSessions.clear();
|
|
273
|
+
}
|
|
227
274
|
requestPermission(params) {
|
|
228
275
|
const state = this.sessions.get(params.sessionId);
|
|
229
276
|
// Unknown/closed session: refuse rather than silently allow a tool we can't attribute.
|
|
@@ -271,6 +318,63 @@ class MultiplexClient {
|
|
|
271
318
|
response.catch(() => { });
|
|
272
319
|
return response;
|
|
273
320
|
}
|
|
321
|
+
requestElicitation(params) {
|
|
322
|
+
const sessionId = sessionIdFromElicitationRequest(params);
|
|
323
|
+
if (!sessionId)
|
|
324
|
+
return declinedElicitationResponse();
|
|
325
|
+
const state = this.sessions.get(sessionId);
|
|
326
|
+
const ctx = this.contextFor(sessionId, state);
|
|
327
|
+
// Unknown/closed session: decline rather than asking a human for a prompt we cannot route.
|
|
328
|
+
if (!state) {
|
|
329
|
+
const outcome = declinedElicitationResponse();
|
|
330
|
+
this.onEvent?.("elicitation_request", { ...ctx, request: params, outcome });
|
|
331
|
+
return outcome;
|
|
332
|
+
}
|
|
333
|
+
this.trackUrlElicitation(params, state, ctx);
|
|
334
|
+
const resolver = state.elicitationResolver ?? this.elicitationResolver;
|
|
335
|
+
if (resolver)
|
|
336
|
+
return this.requestElicitationViaResolver(params, state, ctx, resolver);
|
|
337
|
+
const outcome = declinedElicitationResponse();
|
|
338
|
+
this.onEvent?.("elicitation_request", { ...ctx, request: params, outcome });
|
|
339
|
+
return outcome;
|
|
340
|
+
}
|
|
341
|
+
requestElicitationViaResolver(params, state, ctx, resolver) {
|
|
342
|
+
let settled = false;
|
|
343
|
+
let settle;
|
|
344
|
+
const response = new Promise((resolve) => {
|
|
345
|
+
settle = (outcome) => {
|
|
346
|
+
if (settled)
|
|
347
|
+
return;
|
|
348
|
+
settled = true;
|
|
349
|
+
state.pendingElicitations.delete(settle);
|
|
350
|
+
this.onEvent?.("elicitation_request", { ...ctx, request: params, outcome });
|
|
351
|
+
resolve(outcome);
|
|
352
|
+
};
|
|
353
|
+
state.pendingElicitations.add(settle);
|
|
354
|
+
this.onEvent?.("elicitation_pending", { ...ctx, request: params });
|
|
355
|
+
try {
|
|
356
|
+
Promise.resolve(resolver(params, ctx)).then((outcome) => {
|
|
357
|
+
settle(outcome);
|
|
358
|
+
}, () => {
|
|
359
|
+
// Resolver failure is observable as the FINAL cancel outcome; no extra error event is
|
|
360
|
+
// needed, and the prompt turn continues instead of hanging behind a rejected promise.
|
|
361
|
+
settle(cancelledElicitationResponse());
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
settle(cancelledElicitationResponse());
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
response.catch(() => { });
|
|
369
|
+
return response;
|
|
370
|
+
}
|
|
371
|
+
trackUrlElicitation(params, state, ctx) {
|
|
372
|
+
const elicitationId = urlElicitationId(params);
|
|
373
|
+
if (!elicitationId)
|
|
374
|
+
return;
|
|
375
|
+
state.urlElicitationIds.add(elicitationId);
|
|
376
|
+
this.urlElicitationContexts.set(elicitationId, ctx);
|
|
377
|
+
}
|
|
274
378
|
readTextFile(params) {
|
|
275
379
|
return this.dispatch(params, CLIENT_METHODS.fs_read_text_file, this.handlers?.fs?.readTextFile);
|
|
276
380
|
}
|
|
@@ -292,6 +396,51 @@ class MultiplexClient {
|
|
|
292
396
|
killTerminal(params) {
|
|
293
397
|
return this.dispatch(params, CLIENT_METHODS.terminal_kill, this.handlers?.terminal?.killTerminal);
|
|
294
398
|
}
|
|
399
|
+
async mcpConnect(params) {
|
|
400
|
+
const handler = this.handlers?.mcp?.connect;
|
|
401
|
+
if (typeof handler !== "function")
|
|
402
|
+
throw methodNotAdvertised(CLIENT_METHODS.mcp_connect);
|
|
403
|
+
const sessionId = this.mcpServerSessions.get(params.serverId);
|
|
404
|
+
if (!sessionId)
|
|
405
|
+
throw unknownMcpServer(params.serverId);
|
|
406
|
+
const response = await handler(params, this.handlerContext({ sessionId }));
|
|
407
|
+
this.mcpConnectionSessions.set(response.connectionId, sessionId);
|
|
408
|
+
this.sessions.get(sessionId)?.mcpConnectionIds.add(response.connectionId);
|
|
409
|
+
return response;
|
|
410
|
+
}
|
|
411
|
+
async mcpMessage(params) {
|
|
412
|
+
const handler = this.handlers?.mcp?.message;
|
|
413
|
+
if (typeof handler !== "function")
|
|
414
|
+
throw methodNotAdvertised(CLIENT_METHODS.mcp_message);
|
|
415
|
+
const ctx = this.handlerContext({ sessionId: this.sessionIdForMcpConnection(params.connectionId) });
|
|
416
|
+
return handler(params, ctx);
|
|
417
|
+
}
|
|
418
|
+
mcpMessageNotification(params) {
|
|
419
|
+
const handler = this.handlers?.mcp?.message;
|
|
420
|
+
if (typeof handler !== "function")
|
|
421
|
+
return;
|
|
422
|
+
const sessionId = this.mcpConnectionSessions.get(params.connectionId);
|
|
423
|
+
if (!sessionId)
|
|
424
|
+
return;
|
|
425
|
+
try {
|
|
426
|
+
Promise.resolve(handler(params, this.handlerContext({ sessionId }))).catch(() => { });
|
|
427
|
+
}
|
|
428
|
+
catch {
|
|
429
|
+
// Notifications have no response path; teardown remains best-effort and non-fatal.
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
async mcpDisconnect(params) {
|
|
433
|
+
const handler = this.handlers?.mcp?.disconnect;
|
|
434
|
+
if (typeof handler !== "function")
|
|
435
|
+
throw methodNotAdvertised(CLIENT_METHODS.mcp_disconnect);
|
|
436
|
+
const sessionId = this.sessionIdForMcpConnection(params.connectionId);
|
|
437
|
+
try {
|
|
438
|
+
return (await handler(params, this.handlerContext({ sessionId }))) ?? {};
|
|
439
|
+
}
|
|
440
|
+
finally {
|
|
441
|
+
this.dropMcpConnection(params.connectionId, sessionId);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
295
444
|
sessionUpdate(params) {
|
|
296
445
|
const state = this.sessions.get(params.sessionId);
|
|
297
446
|
// Fold into the accumulator FIRST (the drain contract), THEN bubble the event up unchanged.
|
|
@@ -317,13 +466,67 @@ class MultiplexClient {
|
|
|
317
466
|
message: rawMessage,
|
|
318
467
|
});
|
|
319
468
|
}
|
|
469
|
+
elicitationComplete(params) {
|
|
470
|
+
const ctx = this.urlElicitationContexts.get(params.elicitationId);
|
|
471
|
+
if (!ctx)
|
|
472
|
+
return;
|
|
473
|
+
this.urlElicitationContexts.delete(params.elicitationId);
|
|
474
|
+
this.sessions.get(ctx.sessionId)?.urlElicitationIds.delete(params.elicitationId);
|
|
475
|
+
this.onEvent?.("elicitation_complete", { ...ctx, notification: params });
|
|
476
|
+
}
|
|
477
|
+
sessionIdForMcpConnection(connectionId) {
|
|
478
|
+
const sessionId = this.mcpConnectionSessions.get(connectionId);
|
|
479
|
+
if (!sessionId)
|
|
480
|
+
throw unknownMcpConnection(connectionId);
|
|
481
|
+
return sessionId;
|
|
482
|
+
}
|
|
483
|
+
dropMcpConnection(connectionId, sessionId) {
|
|
484
|
+
this.mcpConnectionSessions.delete(connectionId);
|
|
485
|
+
this.sessions.get(sessionId)?.mcpConnectionIds.delete(connectionId);
|
|
486
|
+
}
|
|
487
|
+
disconnectMcpConnectionsForSession(sessionId, state) {
|
|
488
|
+
const handler = this.handlers?.mcp?.disconnect;
|
|
489
|
+
const ctx = { sessionId, cwd: state.cwd, label: state.label, runId: state.runId };
|
|
490
|
+
for (const connectionId of [...state.mcpConnectionIds]) {
|
|
491
|
+
this.mcpConnectionSessions.delete(connectionId);
|
|
492
|
+
state.mcpConnectionIds.delete(connectionId);
|
|
493
|
+
if (typeof handler !== "function")
|
|
494
|
+
continue;
|
|
495
|
+
try {
|
|
496
|
+
Promise.resolve(handler({ connectionId }, ctx)).catch(() => { });
|
|
497
|
+
}
|
|
498
|
+
catch {
|
|
499
|
+
// Best-effort teardown: a broken MCP cleanup hook must not block session release/death.
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
320
503
|
}
|
|
321
504
|
function unknownSession(sessionId) {
|
|
322
505
|
return RequestError.invalidParams({ sessionId }, `unknown session: ${sessionId}`);
|
|
323
506
|
}
|
|
507
|
+
function unknownMcpServer(serverId) {
|
|
508
|
+
return RequestError.invalidParams({ serverId }, `unknown MCP-over-ACP server: ${serverId}`);
|
|
509
|
+
}
|
|
510
|
+
function unknownMcpConnection(connectionId) {
|
|
511
|
+
return RequestError.invalidParams({ connectionId }, `unknown MCP-over-ACP connection: ${connectionId}`);
|
|
512
|
+
}
|
|
324
513
|
function cancelledPermissionResponse() {
|
|
325
514
|
return { outcome: { outcome: "cancelled" } };
|
|
326
515
|
}
|
|
516
|
+
function declinedElicitationResponse() {
|
|
517
|
+
return { action: "decline" };
|
|
518
|
+
}
|
|
519
|
+
function cancelledElicitationResponse() {
|
|
520
|
+
return { action: "cancel" };
|
|
521
|
+
}
|
|
522
|
+
function sessionIdFromElicitationRequest(params) {
|
|
523
|
+
return "sessionId" in params && typeof params.sessionId === "string" ? params.sessionId : undefined;
|
|
524
|
+
}
|
|
525
|
+
function urlElicitationId(params) {
|
|
526
|
+
return params.mode === "url" && "elicitationId" in params && typeof params.elicitationId === "string"
|
|
527
|
+
? params.elicitationId
|
|
528
|
+
: undefined;
|
|
529
|
+
}
|
|
327
530
|
function methodNotAdvertised(method) {
|
|
328
531
|
return new RequestError(-32601, `${method} was not advertised by this client`, { method });
|
|
329
532
|
}
|
|
@@ -376,6 +579,11 @@ function layerMeta(...layers) {
|
|
|
376
579
|
return undefined;
|
|
377
580
|
return Object.assign({}, ...present);
|
|
378
581
|
}
|
|
582
|
+
function acpMcpServerIds(servers) {
|
|
583
|
+
return servers
|
|
584
|
+
?.filter((server) => "type" in server && server.type === "acp")
|
|
585
|
+
.map((server) => server.serverId) ?? [];
|
|
586
|
+
}
|
|
379
587
|
/** Merge the engine runId correlation stamp into a backend's session/new `_meta`. Returns the
|
|
380
588
|
* meta unchanged when no runId is given (so a backend that sends no `_meta` keeps sending none). */
|
|
381
589
|
function stampRunId(meta, runId) {
|
|
@@ -411,6 +619,7 @@ export class PooledConnection {
|
|
|
411
619
|
onDead;
|
|
412
620
|
onEvent;
|
|
413
621
|
clientHandlers;
|
|
622
|
+
advertiseElicitation;
|
|
414
623
|
/** Set true at the start of dispose() so the graceful-shutdown death is NOT reported as a crash. */
|
|
415
624
|
disposing = false;
|
|
416
625
|
/** Resolves once `initialize` completed (or rejects if the process died first). */
|
|
@@ -430,7 +639,8 @@ export class PooledConnection {
|
|
|
430
639
|
this.onDead = deps.onDead;
|
|
431
640
|
this.onEvent = deps.onEvent;
|
|
432
641
|
this.clientHandlers = deps.clientHandlers;
|
|
433
|
-
this.
|
|
642
|
+
this.advertiseElicitation = deps.advertiseElicitation ?? Boolean(deps.elicitationResolver);
|
|
643
|
+
this.client = new MultiplexClient(this.backendId, this.onEvent, deps.clientHandlers, deps.permissionResolver, deps.elicitationResolver);
|
|
434
644
|
const { command, args, env } = backend.spawnConfig();
|
|
435
645
|
// NOTE: deliberately NO `cwd` here. cwd is per-SESSION (session/new), so one pooled process
|
|
436
646
|
// serves runs in different worktrees without losing isolation.
|
|
@@ -468,7 +678,9 @@ export class PooledConnection {
|
|
|
468
678
|
this.connection = client({ name: CLIENT_INFO.name })
|
|
469
679
|
.onNotification(CLIENT_METHODS.session_update, ({ params }) => this.client.sessionUpdate(params))
|
|
470
680
|
.onNotification(CLAUDE_RAW_MESSAGE_METHOD, (params) => (params ?? {}), ({ params }) => this.client.extNotification(CLAUDE_RAW_MESSAGE_METHOD, params))
|
|
681
|
+
.onNotification(CLIENT_METHODS.elicitation_complete, ({ params }) => this.client.elicitationComplete(params))
|
|
471
682
|
.onRequest(CLIENT_METHODS.session_request_permission, ({ params }) => this.client.requestPermission(params))
|
|
683
|
+
.onRequest(CLIENT_METHODS.elicitation_create, ({ params }) => this.client.requestElicitation(params))
|
|
472
684
|
.onRequest(CLIENT_METHODS.fs_read_text_file, ({ params }) => this.client.readTextFile(params))
|
|
473
685
|
.onRequest(CLIENT_METHODS.fs_write_text_file, ({ params }) => this.client.writeTextFile(params))
|
|
474
686
|
.onRequest(CLIENT_METHODS.terminal_create, ({ params }) => this.client.createTerminal(params))
|
|
@@ -476,6 +688,10 @@ export class PooledConnection {
|
|
|
476
688
|
.onRequest(CLIENT_METHODS.terminal_release, ({ params }) => this.client.releaseTerminal(params))
|
|
477
689
|
.onRequest(CLIENT_METHODS.terminal_wait_for_exit, ({ params }) => this.client.waitForTerminalExit(params))
|
|
478
690
|
.onRequest(CLIENT_METHODS.terminal_kill, ({ params }) => this.client.killTerminal(params))
|
|
691
|
+
.onRequest(CLIENT_METHODS.mcp_connect, parseConnectMcpRequest, ({ params }) => this.client.mcpConnect(params))
|
|
692
|
+
.onRequest(CLIENT_METHODS.mcp_message, parseMessageMcpRequest, ({ params }) => this.client.mcpMessage(params))
|
|
693
|
+
.onRequest(CLIENT_METHODS.mcp_disconnect, parseDisconnectMcpRequest, ({ params }) => this.client.mcpDisconnect(params))
|
|
694
|
+
.onNotification(CLIENT_METHODS.mcp_message, parseMessageMcpNotification, ({ params }) => this.client.mcpMessageNotification(params))
|
|
479
695
|
.connect(stream);
|
|
480
696
|
// Death detection. The connection's `signal` aborts the INSTANT the underlying stream closes
|
|
481
697
|
// (process crash or our own dispose) — in the SAME close() that rejects pending requests — so
|
|
@@ -515,10 +731,16 @@ export class PooledConnection {
|
|
|
515
731
|
}
|
|
516
732
|
assertSupportedMcpServers(opts) {
|
|
517
733
|
const unsupported = this.negotiated
|
|
518
|
-
? unsupportedMcpServer(opts.mcpServers, this.negotiated.agent
|
|
734
|
+
? unsupportedMcpServer(opts.mcpServers, this.negotiated.agent, {
|
|
735
|
+
clientCanServeAcp: hasFullMcpHandlers(this.clientHandlers?.mcp),
|
|
736
|
+
})
|
|
519
737
|
: undefined;
|
|
520
738
|
if (!unsupported)
|
|
521
739
|
return;
|
|
740
|
+
if (unsupported.reason === "client") {
|
|
741
|
+
throw new WorkflowError(`MCP server "${unsupported.name}" uses the "acp" transport, but this runner has no ` +
|
|
742
|
+
"complete clientHandlers.mcp implementation to serve it", WorkflowErrorCode.SCRIPT_VALIDATION_ERROR, { recoverable: false, agentLabel: opts.label });
|
|
743
|
+
}
|
|
522
744
|
throw new WorkflowError(`MCP server "${unsupported.name}" uses the "${unsupported.transport}" transport, which the ` +
|
|
523
745
|
`${this.backendId} agent does not support`, WorkflowErrorCode.SCRIPT_VALIDATION_ERROR, { recoverable: false, agentLabel: opts.label });
|
|
524
746
|
}
|
|
@@ -550,6 +772,8 @@ export class PooledConnection {
|
|
|
550
772
|
this.deathError = error;
|
|
551
773
|
this.resolveDead();
|
|
552
774
|
this.client.settleAllPendingPermissions();
|
|
775
|
+
this.client.settleAllPendingElicitations();
|
|
776
|
+
this.client.disconnectAllMcpConnections();
|
|
553
777
|
// A crash (not a graceful dispose) is worth surfacing for observability; the engine still
|
|
554
778
|
// handles it by retrying the run on a fresh process. Best-effort, after death is recorded.
|
|
555
779
|
if (this.onEvent && !this.disposing) {
|
|
@@ -593,7 +817,9 @@ export class PooledConnection {
|
|
|
593
817
|
protocolVersion: PROTOCOL_VERSION,
|
|
594
818
|
// Truthful advertisement: computed from the consumer-provided handlers registered on
|
|
595
819
|
// this runner. Omitted flags are unsupported; false flags are never sent deliberately.
|
|
596
|
-
clientCapabilities: clientCapabilitiesFor(this.clientHandlers
|
|
820
|
+
clientCapabilities: clientCapabilitiesFor(this.clientHandlers, {
|
|
821
|
+
elicitation: this.advertiseElicitation,
|
|
822
|
+
}),
|
|
597
823
|
clientInfo: { ...CLIENT_INFO },
|
|
598
824
|
})),
|
|
599
825
|
deadline,
|
|
@@ -644,7 +870,7 @@ export class PooledConnection {
|
|
|
644
870
|
...(meta ? { _meta: meta } : {}),
|
|
645
871
|
};
|
|
646
872
|
const response = await this.race(this.connection.agent.request(AGENT_METHODS.session_new, request));
|
|
647
|
-
const state = new SessionState(opts.cwd, opts.policy, opts.permissionResolver, opts.label, opts.runId, response.modes, opts.retainSessionLog ?? true);
|
|
873
|
+
const state = new SessionState(opts.cwd, opts.policy, opts.permissionResolver, opts.elicitationResolver, opts.label, opts.runId, response.modes, acpMcpServerIds(opts.mcpServers), opts.retainSessionLog ?? true);
|
|
648
874
|
this.client.register(response.sessionId, state);
|
|
649
875
|
return new SessionHandle(this, response.sessionId, state, response.configOptions ?? [], opts);
|
|
650
876
|
}
|
|
@@ -671,7 +897,7 @@ export class PooledConnection {
|
|
|
671
897
|
async reattachSession(method, sessionId, opts) {
|
|
672
898
|
this._activeSessions += 1;
|
|
673
899
|
let registered = false;
|
|
674
|
-
const state = new SessionState(opts.cwd, opts.policy, opts.permissionResolver, opts.label, opts.runId, undefined, opts.retainSessionLog ?? true);
|
|
900
|
+
const state = new SessionState(opts.cwd, opts.policy, opts.permissionResolver, opts.elicitationResolver, opts.label, opts.runId, undefined, acpMcpServerIds(opts.mcpServers), opts.retainSessionLog ?? true);
|
|
675
901
|
try {
|
|
676
902
|
await this.ready;
|
|
677
903
|
this.assertLifecycleSupported(method, opts.label);
|
|
@@ -740,6 +966,7 @@ export class PooledConnection {
|
|
|
740
966
|
/** Best-effort ACP cancel for one session (wired to opts.signal). The PROCESS stays pooled. */
|
|
741
967
|
async cancelSession(sessionId) {
|
|
742
968
|
this.client.settlePendingPermissions(sessionId);
|
|
969
|
+
this.client.settlePendingElicitations(sessionId);
|
|
743
970
|
if (!this._alive)
|
|
744
971
|
return;
|
|
745
972
|
try {
|
package/dist/capabilities.d.ts
CHANGED
|
@@ -56,13 +56,16 @@ export declare function gateCustomMeta(meta: Record<string, unknown> | undefined
|
|
|
56
56
|
* bracketed text notes so context is never silently lost. Returns the SAME array reference when
|
|
57
57
|
* no block changes and never mutates the input or any surviving block. */
|
|
58
58
|
export declare function adaptPromptContent(blocks: ContentBlock[], agent: AgentCapabilities, backendId: string): ContentBlock[];
|
|
59
|
-
/** The first client-provided MCP server whose transport
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
export declare function unsupportedMcpServer(servers: McpServerConfig[] | undefined, agent: AgentCapabilities
|
|
59
|
+
/** The first client-provided MCP server whose transport cannot be served, or undefined when every
|
|
60
|
+
* server is serviceable. stdio is ALWAYS serviceable (the baseline transport); http/sse keep the
|
|
61
|
+
* legacy leniency and gate only after any mcpCapabilities block exists. ACP transport is stricter:
|
|
62
|
+
* both sides must be explicit because the client is the MCP server host and an unwired declaration
|
|
63
|
+
* would otherwise spend tokens before failing at mcp/connect. */
|
|
64
|
+
export declare function unsupportedMcpServer(servers: McpServerConfig[] | undefined, agent: AgentCapabilities, options?: {
|
|
65
|
+
clientCanServeAcp?: boolean;
|
|
66
|
+
}): {
|
|
65
67
|
name: string;
|
|
66
|
-
transport: "http" | "sse";
|
|
68
|
+
transport: "http" | "sse" | "acp";
|
|
69
|
+
reason?: "client";
|
|
67
70
|
} | undefined;
|
|
68
71
|
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAkBA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MA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,EAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACjD,sBAAsB,CAkBxB;AAMD,qFAAqF;AACrF,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAiB/E;AAaD;;;;+DAI+D;AAC/D,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED;;;gEAGgE;AAChE,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC5C,SAAS,GAAE,SAAS,MAAM,EAA2B,GACpD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAWrC;AAED;;;;;2EAK2E;AAC3E,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EAAE,EACtB,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,MAAM,GAChB,YAAY,EAAE,CAchB;AAkCD;;;;kEAIkE;AAClE,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,eAAe,EAAE,GAAG,SAAS,EACtC,KAAK,EAAE,iBAAiB,EACxB,OAAO,GAAE;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,CAAA;CAAE,GAAG,SAAS,CAkBpF"}
|
package/dist/capabilities.js
CHANGED
|
@@ -153,22 +153,28 @@ function unsupportedPromptBlockNote(block, agent, backendId) {
|
|
|
153
153
|
return undefined;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
/** The first client-provided MCP server whose transport
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
export function unsupportedMcpServer(servers, agent) {
|
|
156
|
+
/** The first client-provided MCP server whose transport cannot be served, or undefined when every
|
|
157
|
+
* server is serviceable. stdio is ALWAYS serviceable (the baseline transport); http/sse keep the
|
|
158
|
+
* legacy leniency and gate only after any mcpCapabilities block exists. ACP transport is stricter:
|
|
159
|
+
* both sides must be explicit because the client is the MCP server host and an unwired declaration
|
|
160
|
+
* would otherwise spend tokens before failing at mcp/connect. */
|
|
161
|
+
export function unsupportedMcpServer(servers, agent, options = {}) {
|
|
162
162
|
const mcp = agent.mcpCapabilities;
|
|
163
|
-
if (!
|
|
163
|
+
if (!servers)
|
|
164
164
|
return undefined;
|
|
165
165
|
for (const server of servers) {
|
|
166
|
-
if ("type" in server && server.type === "http" && mcp.http !== true) {
|
|
166
|
+
if ("type" in server && server.type === "http" && mcp && mcp.http !== true) {
|
|
167
167
|
return { name: server.name, transport: "http" };
|
|
168
168
|
}
|
|
169
|
-
if ("type" in server && server.type === "sse" && mcp.sse !== true) {
|
|
169
|
+
if ("type" in server && server.type === "sse" && mcp && mcp.sse !== true) {
|
|
170
170
|
return { name: server.name, transport: "sse" };
|
|
171
171
|
}
|
|
172
|
+
if ("type" in server && server.type === "acp" && mcp?.acp !== true) {
|
|
173
|
+
return { name: server.name, transport: "acp" };
|
|
174
|
+
}
|
|
175
|
+
if ("type" in server && server.type === "acp" && options.clientCanServeAcp !== true) {
|
|
176
|
+
return { name: server.name, transport: "acp", reason: "client" };
|
|
177
|
+
}
|
|
172
178
|
}
|
|
173
179
|
return undefined;
|
|
174
180
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientCapabilities, CreateTerminalRequest, CreateTerminalResponse, KillTerminalRequest, KillTerminalResponse, ReadTextFileRequest, ReadTextFileResponse, ReleaseTerminalRequest, ReleaseTerminalResponse, TerminalOutputRequest, TerminalOutputResponse, WaitForTerminalExitRequest, WaitForTerminalExitResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk";
|
|
1
|
+
import type { ClientCapabilities, ConnectMcpRequest, ConnectMcpResponse, CreateTerminalRequest, CreateTerminalResponse, DisconnectMcpRequest, DisconnectMcpResponse, KillTerminalRequest, KillTerminalResponse, MessageMcpRequest, MessageMcpResponse, ReadTextFileRequest, ReadTextFileResponse, ReleaseTerminalRequest, ReleaseTerminalResponse, TerminalOutputRequest, TerminalOutputResponse, WaitForTerminalExitRequest, WaitForTerminalExitResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk";
|
|
2
2
|
export interface AcpSessionContext {
|
|
3
3
|
readonly sessionId: string;
|
|
4
4
|
readonly cwd: string;
|
|
@@ -16,15 +16,30 @@ export interface TerminalHandlers {
|
|
|
16
16
|
killTerminal(params: KillTerminalRequest, ctx: AcpSessionContext): Promise<KillTerminalResponse | void> | KillTerminalResponse | void;
|
|
17
17
|
releaseTerminal(params: ReleaseTerminalRequest, ctx: AcpSessionContext): Promise<ReleaseTerminalResponse | void> | ReleaseTerminalResponse | void;
|
|
18
18
|
}
|
|
19
|
+
export interface McpHandlers {
|
|
20
|
+
connect(params: ConnectMcpRequest, ctx: AcpSessionContext): Promise<ConnectMcpResponse> | ConnectMcpResponse;
|
|
21
|
+
message(params: MessageMcpRequest, ctx: AcpSessionContext): Promise<MessageMcpResponse> | MessageMcpResponse;
|
|
22
|
+
disconnect(params: DisconnectMcpRequest, ctx: AcpSessionContext): Promise<DisconnectMcpResponse | void> | DisconnectMcpResponse | void;
|
|
23
|
+
}
|
|
19
24
|
export interface ClientHandlers {
|
|
20
25
|
fs?: FsHandlers;
|
|
21
26
|
terminal?: TerminalHandlers;
|
|
27
|
+
mcp?: McpHandlers;
|
|
28
|
+
}
|
|
29
|
+
export interface ClientCapabilityOptions {
|
|
30
|
+
/** Advertise unstable ACP elicitation support only when this connection has a runner-wide
|
|
31
|
+
* responder. Initialize capabilities are fixed for the connection lifetime, so a later
|
|
32
|
+
* session-scoped responder alone cannot truthfully light this up. */
|
|
33
|
+
elicitation?: boolean;
|
|
22
34
|
}
|
|
23
35
|
/** The client capability advertisement: fs/terminal derived solely from registered consumer
|
|
24
36
|
* handlers, plus the capabilities this client supports natively regardless of handlers —
|
|
25
37
|
* boolean session config options (SessionHandle drives the catalog programmatically and
|
|
26
|
-
* handles `type: "boolean"` entries, e.g. codex-acp's Fast-mode toggle).
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
* handles `type: "boolean"` entries, e.g. codex-acp's Fast-mode toggle). The installed ACP SDK
|
|
39
|
+
* has no ClientCapabilities field for MCP-over-ACP; support is declared by sending
|
|
40
|
+
* `mcpServers[{ type: "acp" }]` on session/new and then gated against handlers at that site. */
|
|
41
|
+
export declare function clientCapabilitiesFor(handlers: ClientHandlers | undefined, options?: ClientCapabilityOptions): ClientCapabilities;
|
|
42
|
+
/** Fail-fast validation for JavaScript consumers bypassing the grouped handler types. */
|
|
29
43
|
export declare function validateClientHandlers(handlers: ClientHandlers | undefined): void;
|
|
44
|
+
export declare function hasFullMcpHandlers(mcp: McpHandlers | undefined): mcp is McpHandlers;
|
|
30
45
|
//# sourceMappingURL=client-handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-handlers.d.ts","sourceRoot":"","sources":["../src/client-handlers.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ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}
|
package/dist/client-handlers.js
CHANGED
|
@@ -5,12 +5,17 @@ const TERMINAL_HANDLER_METHODS = [
|
|
|
5
5
|
"killTerminal",
|
|
6
6
|
"releaseTerminal",
|
|
7
7
|
];
|
|
8
|
+
const MCP_HANDLER_METHODS = ["connect", "message", "disconnect"];
|
|
8
9
|
/** The client capability advertisement: fs/terminal derived solely from registered consumer
|
|
9
10
|
* handlers, plus the capabilities this client supports natively regardless of handlers —
|
|
10
11
|
* boolean session config options (SessionHandle drives the catalog programmatically and
|
|
11
|
-
* handles `type: "boolean"` entries, e.g. codex-acp's Fast-mode toggle).
|
|
12
|
-
|
|
12
|
+
* handles `type: "boolean"` entries, e.g. codex-acp's Fast-mode toggle). The installed ACP SDK
|
|
13
|
+
* has no ClientCapabilities field for MCP-over-ACP; support is declared by sending
|
|
14
|
+
* `mcpServers[{ type: "acp" }]` on session/new and then gated against handlers at that site. */
|
|
15
|
+
export function clientCapabilitiesFor(handlers, options = {}) {
|
|
13
16
|
const capabilities = { session: { configOptions: { boolean: {} } } };
|
|
17
|
+
if (options.elicitation)
|
|
18
|
+
capabilities.elicitation = { form: {}, url: {} };
|
|
14
19
|
if (!handlers)
|
|
15
20
|
return capabilities;
|
|
16
21
|
const fs = handlers.fs;
|
|
@@ -25,18 +30,30 @@ export function clientCapabilitiesFor(handlers) {
|
|
|
25
30
|
capabilities.terminal = true;
|
|
26
31
|
return capabilities;
|
|
27
32
|
}
|
|
28
|
-
/** Fail-fast validation for JavaScript consumers bypassing the
|
|
33
|
+
/** Fail-fast validation for JavaScript consumers bypassing the grouped handler types. */
|
|
29
34
|
export function validateClientHandlers(handlers) {
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
if (handlers?.terminal) {
|
|
36
|
+
const missing = missingTerminalMethods(handlers.terminal);
|
|
37
|
+
if (missing.length > 0) {
|
|
38
|
+
throw new Error(`clientHandlers.terminal missing required methods: ${missing.join(", ")}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (handlers?.mcp) {
|
|
42
|
+
const missing = missingMcpMethods(handlers.mcp);
|
|
43
|
+
if (missing.length > 0) {
|
|
44
|
+
throw new Error(`clientHandlers.mcp missing required methods: ${missing.join(", ")}`);
|
|
45
|
+
}
|
|
35
46
|
}
|
|
36
47
|
}
|
|
37
48
|
function hasFullTerminalHandlers(terminal) {
|
|
38
49
|
return Boolean(terminal && missingTerminalMethods(terminal).length === 0);
|
|
39
50
|
}
|
|
51
|
+
export function hasFullMcpHandlers(mcp) {
|
|
52
|
+
return Boolean(mcp && missingMcpMethods(mcp).length === 0);
|
|
53
|
+
}
|
|
40
54
|
function missingTerminalMethods(terminal) {
|
|
41
55
|
return TERMINAL_HANDLER_METHODS.filter((method) => typeof terminal[method] !== "function");
|
|
42
56
|
}
|
|
57
|
+
function missingMcpMethods(mcp) {
|
|
58
|
+
return MCP_HANDLER_METHODS.filter((method) => typeof mcp[method] !== "function");
|
|
59
|
+
}
|
package/dist/events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestPermissionRequest, RequestPermissionResponse, SessionNotification } from "@agentclientprotocol/sdk";
|
|
1
|
+
import type { CompleteElicitationNotification, CreateElicitationRequest, CreateElicitationResponse, RequestPermissionRequest, RequestPermissionResponse, SessionNotification } from "@agentclientprotocol/sdk";
|
|
2
2
|
import type { BackendId } from "./backend.js";
|
|
3
3
|
/** The ACP session/update discriminated union (every real-time update an agent can stream). */
|
|
4
4
|
export type AcpSessionUpdate = SessionNotification["update"];
|
|
@@ -36,6 +36,22 @@ export interface AcpPermissionEvent extends AcpEventContext {
|
|
|
36
36
|
request: RequestPermissionRequest;
|
|
37
37
|
outcome: RequestPermissionResponse;
|
|
38
38
|
}
|
|
39
|
+
/** An elicitation/create request parked on an async resolver. Resolver path only; the final
|
|
40
|
+
* response is reported by elicitation_request exactly once. */
|
|
41
|
+
export interface AcpElicitationPendingEvent extends AcpEventContext {
|
|
42
|
+
request: CreateElicitationRequest;
|
|
43
|
+
}
|
|
44
|
+
/** An elicitation/create request the runner answered, paired with the FINAL response returned
|
|
45
|
+
* to the agent. Fires exactly once for resolver-backed and auto-declined requests. */
|
|
46
|
+
export interface AcpElicitationEvent extends AcpEventContext {
|
|
47
|
+
request: CreateElicitationRequest;
|
|
48
|
+
outcome: CreateElicitationResponse;
|
|
49
|
+
}
|
|
50
|
+
/** Notification that a URL-based elicitation completed, correlated back to the session context
|
|
51
|
+
* captured when its elicitation/create request arrived. */
|
|
52
|
+
export interface AcpElicitationCompleteEvent extends AcpEventContext {
|
|
53
|
+
notification: CompleteElicitationNotification;
|
|
54
|
+
}
|
|
39
55
|
/** A vendor extension notification (e.g. Claude `_claude/sdkMessage`) routed to a session. */
|
|
40
56
|
export interface AcpRawMessageEvent extends AcpEventContext {
|
|
41
57
|
method: string;
|
|
@@ -61,6 +77,12 @@ export type AcpRunnerEventMap = AcpSessionUpdateEvents & {
|
|
|
61
77
|
permission_pending: AcpPermissionPendingEvent;
|
|
62
78
|
/** A permission request the runner answered, with the FINAL decision returned. */
|
|
63
79
|
permission_request: AcpPermissionEvent;
|
|
80
|
+
/** An elicitation/create request parked on an async resolver; resolver path only. */
|
|
81
|
+
elicitation_pending: AcpElicitationPendingEvent;
|
|
82
|
+
/** An elicitation/create request the runner answered, with the FINAL response returned. */
|
|
83
|
+
elicitation_request: AcpElicitationEvent;
|
|
84
|
+
/** An elicitation/complete notification correlated to the originating session context. */
|
|
85
|
+
elicitation_complete: AcpElicitationCompleteEvent;
|
|
64
86
|
/** A vendor extension notification arrived for a session. */
|
|
65
87
|
raw_message: AcpRawMessageEvent;
|
|
66
88
|
/** A new session was opened on a pooled connection. */
|
|
@@ -74,7 +96,7 @@ export type AcpEventName = keyof AcpRunnerEventMap;
|
|
|
74
96
|
export type AcpEventListener<K extends AcpEventName> = (event: AcpRunnerEventMap[K]) => void;
|
|
75
97
|
/** Non-session/update runner events. Kept exact by the type-level guard below so a new
|
|
76
98
|
* cross-cutting event cannot be added to AcpRunnerEventMap without updating forwarders. */
|
|
77
|
-
export declare const ACP_CROSS_CUTTING_EVENT_NAMES: readonly ["permission_pending", "permission_request", "raw_message", "session_open", "session_close", "backend_error"];
|
|
99
|
+
export declare const ACP_CROSS_CUTTING_EVENT_NAMES: readonly ["permission_pending", "permission_request", "elicitation_pending", "elicitation_request", "elicitation_complete", "raw_message", "session_open", "session_close", "backend_error"];
|
|
78
100
|
/** Internal emit boundary handed from the runner down through the pool to each connection. */
|
|
79
101
|
export interface AcpEventSink {
|
|
80
102
|
<K extends AcpEventName>(name: K, event: AcpRunnerEventMap[K]): void;
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,+FAA+F;AAC/F,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC7D,qGAAqG;AACrG,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;AAE9D;oGACoG;AACpG,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,SAAS,EAAE,SAAS,CAAC;IACrB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,mGAAmG;AACnG,KAAK,sBAAsB,GAAG;KAC3B,CAAC,IAAI,aAAa,GAAG,OAAO,CAAC,gBAAgB,EAAE;QAAE,aAAa,EAAE,CAAC,CAAA;KAAE,CAAC,GAAG,eAAe;CACxF,CAAC;AAEF;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iBAAiB,CAAC,QAAQ;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4D;IAEtF,6FAA6F;IAC7F,EAAE,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAUzF,+EAA+E;IAC/E,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAQ3F,GAAG,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAOpF,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,QAAQ,GAAG,IAAI;IAK/C,aAAa,CAAC,IAAI,EAAE,MAAM,QAAQ,GAAG,MAAM;IAI3C,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;CAYlE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI,CAI1G"}
|
package/dist/events.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { AcpRunnerOptions, DeleteSessionOptions, ListSessionsOptions, Reatt
|
|
|
3
3
|
export { InteractiveSession } from "./interactive.js";
|
|
4
4
|
export type { InteractiveSessionOptions, InteractiveTurn } from "./interactive.js";
|
|
5
5
|
export { AGENT_METHODS, CLIENT_METHODS } from "@agentclientprotocol/sdk";
|
|
6
|
-
export type { AgentNotificationMethod, AgentNotificationParamsByMethod, AgentRequestMethod, AgentRequestParamsByMethod, AgentRequestResponsesByMethod, DeleteSessionRequest, DeleteSessionResponse, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, ResumeSessionRequest, ResumeSessionResponse, SessionMode, SessionModeState, SessionInfo, SendRequestOptions, } from "@agentclientprotocol/sdk";
|
|
6
|
+
export type { AgentNotificationMethod, AgentNotificationParamsByMethod, AgentRequestMethod, AgentRequestParamsByMethod, AgentRequestResponsesByMethod, CompleteElicitationNotification, ConnectMcpRequest, ConnectMcpResponse, CreateElicitationRequest, CreateElicitationResponse, DeleteSessionRequest, DeleteSessionResponse, DisconnectMcpRequest, DisconnectMcpResponse, ElicitationAcceptAction, ElicitationCapabilities, ElicitationContentValue, ElicitationFormCapabilities, ElicitationFormMode, ElicitationId, ElicitationPropertySchema, ElicitationRequestScope, ElicitationSchema, ElicitationSchemaType, ElicitationSessionScope, ElicitationUrlCapabilities, ElicitationUrlMode, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, McpConnectionId, McpServerAcp, McpServerAcpId, MessageMcpNotification, MessageMcpRequest, MessageMcpResponse, ResumeSessionRequest, ResumeSessionResponse, SessionMode, SessionModeState, SessionInfo, SendRequestOptions, } from "@agentclientprotocol/sdk";
|
|
7
7
|
export { BACKENDS_ENV, registryWithRunBackends, resolveBackendRegistry } from "./registry.js";
|
|
8
8
|
export type { BackendRegistry, CustomBackendConfig, RegisteredBackend } from "./registry.js";
|
|
9
9
|
export { PooledConnection, SessionHandle } from "./acp-client.js";
|
|
@@ -15,16 +15,17 @@ export type { NegotiatedCapabilities } from "./capabilities.js";
|
|
|
15
15
|
export { AcpAgentPool, resolvePoolSize } from "./pool.js";
|
|
16
16
|
export type { AcpPoolOptions, AcpPoolDeps } from "./pool.js";
|
|
17
17
|
export { clientCapabilitiesFor } from "./client-handlers.js";
|
|
18
|
-
export type { AcpSessionContext, ClientHandlers, FsHandlers, TerminalHandlers } from "./client-handlers.js";
|
|
18
|
+
export type { AcpSessionContext, ClientCapabilityOptions, ClientHandlers, FsHandlers, McpHandlers, TerminalHandlers, } from "./client-handlers.js";
|
|
19
19
|
export { ACP_CROSS_CUTTING_EVENT_NAMES, TypedEventEmitter, emitSessionUpdate } from "./events.js";
|
|
20
|
-
export type { AcpRunnerEventMap, AcpEventName, AcpEventListener, AcpEventContext, AcpEventSink, AcpSessionUpdate, AcpUpdateKind, AcpPermissionPendingEvent, AcpPermissionEvent, AcpRawMessageEvent, AcpBackendErrorEvent, } from "./events.js";
|
|
20
|
+
export type { AcpRunnerEventMap, AcpEventName, AcpEventListener, AcpEventContext, AcpEventSink, AcpSessionUpdate, AcpUpdateKind, AcpElicitationCompleteEvent, AcpElicitationEvent, AcpElicitationPendingEvent, AcpPermissionPendingEvent, AcpPermissionEvent, AcpRawMessageEvent, AcpBackendErrorEvent, } from "./events.js";
|
|
21
21
|
export type { Backend, BackendId, BuiltinBackendId, SessionMetaInputs, SpawnConfig, StructuredSource, } from "./backend.js";
|
|
22
22
|
export { ClaudeBackend } from "./backends/claude.js";
|
|
23
23
|
export { CodexBackend } from "./backends/codex.js";
|
|
24
24
|
export { CustomAcpBackend } from "./backends/custom.js";
|
|
25
25
|
export { decidePermission } from "./permissions.js";
|
|
26
|
-
export type { PermissionResolver, ToolPolicy } from "./permissions.js";
|
|
26
|
+
export type { ElicitationResolver, PermissionResolver, ToolPolicy } from "./permissions.js";
|
|
27
27
|
export { UsageAccumulator } from "./usage.js";
|
|
28
|
+
export type { McpAcpServerConfig, McpServerConfig } from "@automatalabs/shared-types";
|
|
28
29
|
export { toJsonSchema, toStrictJsonSchema } from "./schema-strict.js";
|
|
29
30
|
export { extractValidated, findJsonBlock, parseFinalJson, resolveStructuredOutput, validateValue, } from "./structured-output.js";
|
|
30
31
|
export type { ResolveOptions, StructuredSession } from "./structured-output.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
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AAkB,EAClB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/interactive.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ import type { Backend, BackendId } from "./backend.js";
|
|
|
5
5
|
import type { NegotiatedCapabilities } from "./capabilities.js";
|
|
6
6
|
import type { PooledConnection, SessionHandle } from "./acp-client.js";
|
|
7
7
|
import type { AcpEventListener, AcpEventName } from "./events.js";
|
|
8
|
-
import type { PermissionResolver } from "./permissions.js";
|
|
8
|
+
import type { ElicitationResolver, PermissionResolver } from "./permissions.js";
|
|
9
9
|
/** Options for AcpAgentRunner.openSession(): backend selection and session/new inputs for one
|
|
10
10
|
* held-open interactive ACP session. `cwd` is required and absolute; unlike run(), there is no
|
|
11
11
|
* default to process.cwd() because the session can span many turns. The session-scoped
|
|
12
|
-
* permission
|
|
13
|
-
* when no resolver is present. */
|
|
12
|
+
* permission/elicitation resolvers win over the runner-wide defaults; tool allow/deny policy is
|
|
13
|
+
* used only when no permission resolver is present. */
|
|
14
14
|
export interface InteractiveSessionOptions {
|
|
15
15
|
/** Model spec (`provider/modelId`, bare model id, or registered custom backend route). */
|
|
16
16
|
model?: string;
|
|
@@ -26,6 +26,8 @@ export interface InteractiveSessionOptions {
|
|
|
26
26
|
disallowedToolNames?: string[];
|
|
27
27
|
/** Session-scoped permission resolver; overrides the runner-wide resolver for this session. */
|
|
28
28
|
onPermissionRequest?: PermissionResolver;
|
|
29
|
+
/** Session-scoped elicitation resolver; overrides the runner-wide resolver for this session. */
|
|
30
|
+
onElicitation?: ElicitationResolver;
|
|
29
31
|
/** The actually-resolved concrete model id (display/telemetry). */
|
|
30
32
|
onModelResolved?: RunOptions["onModelResolved"];
|
|
31
33
|
/** A requested model/tier spec that was not found and fell back to the session default. */
|
|
@@ -119,8 +121,8 @@ export declare class InteractiveSession {
|
|
|
119
121
|
* explicitly; use `session.sessionId` so the wire call targets this session. */
|
|
120
122
|
notify<Method extends AgentNotificationMethod>(method: Method, params: AgentNotificationParamsByMethod[Method]): Promise<void>;
|
|
121
123
|
notify<Params = unknown>(method: string, params?: Params): Promise<void>;
|
|
122
|
-
/** Best-effort ACP session/cancel for the active turn. Pending permission
|
|
123
|
-
* settled as cancelled by the SessionHandle/PooledConnection cancel path. */
|
|
124
|
+
/** Best-effort ACP session/cancel for the active turn. Pending permission/elicitation
|
|
125
|
+
* resolvers are settled as cancelled by the SessionHandle/PooledConnection cancel path. */
|
|
124
126
|
cancel(): Promise<void>;
|
|
125
127
|
/** Subscribe to runner events for THIS ACP session only. Events from other one-shot or
|
|
126
128
|
* interactive sessions on the same runner are filtered out by sessionId. The returned
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,uBAAuB,EACvB,+BAA+B,EAC/B,kBAAkB,EAClB,0BAA0B,EAC1B,6BAA6B,EAC7B,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,uBAAuB,EACvB,+BAA+B,EAC/B,kBAAkB,EAClB,0BAA0B,EAC1B,6BAA6B,EAC7B,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAA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AAC;IAChB,MAAM,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxE;gGAC4F;IACtF,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7B;;oGAEgG;IAChG,EAAE,CAAC,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAiB9E;4FACwF;IACxF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAKV,SAAS;IAkBvB,OAAO,CAAC,mBAAmB;CAK5B"}
|
package/dist/interactive.js
CHANGED
|
@@ -104,8 +104,8 @@ export class InteractiveSession {
|
|
|
104
104
|
throw new Error("InteractiveSession has been released");
|
|
105
105
|
await this.connection.notify(method, params);
|
|
106
106
|
}
|
|
107
|
-
/** Best-effort ACP session/cancel for the active turn. Pending permission
|
|
108
|
-
* settled as cancelled by the SessionHandle/PooledConnection cancel path. */
|
|
107
|
+
/** Best-effort ACP session/cancel for the active turn. Pending permission/elicitation
|
|
108
|
+
* resolvers are settled as cancelled by the SessionHandle/PooledConnection cancel path. */
|
|
109
109
|
async cancel() {
|
|
110
110
|
if (this.releasePromise)
|
|
111
111
|
return;
|
package/dist/permissions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestPermissionRequest, RequestPermissionResponse } from "@agentclientprotocol/sdk";
|
|
1
|
+
import type { CreateElicitationRequest, CreateElicitationResponse, RequestPermissionRequest, RequestPermissionResponse } from "@agentclientprotocol/sdk";
|
|
2
2
|
import type { AcpEventContext } from "./events.js";
|
|
3
3
|
/** Async human-in-the-loop decider for ACP permission requests. When present, it REPLACES the
|
|
4
4
|
* synchronous ToolPolicy path for the sessions it applies to: the agent turn parks until this
|
|
@@ -8,6 +8,10 @@ import type { AcpEventContext } from "./events.js";
|
|
|
8
8
|
* cancelled via session/cancel, or its connection dies, so teardown can never leave an agent
|
|
9
9
|
* turn hung behind an unanswered permission prompt. */
|
|
10
10
|
export type PermissionResolver = (params: RequestPermissionRequest, ctx: AcpEventContext) => Promise<RequestPermissionResponse> | RequestPermissionResponse;
|
|
11
|
+
/** Async human-in-the-loop responder for ACP elicitation/create. ACP marks elicitation
|
|
12
|
+
* UNSTABLE/@experimental; this library deliberately exposes the SDK request/response types
|
|
13
|
+
* directly so regular SDK bumps and wire tests catch drift instead of freezing a local copy. */
|
|
14
|
+
export type ElicitationResolver = (request: CreateElicitationRequest, context: AcpEventContext) => Promise<CreateElicitationResponse> | CreateElicitationResponse;
|
|
11
15
|
export interface ToolPolicy {
|
|
12
16
|
/** Allow-list (agentType `tools`). When non-empty, a tool that matches NOTHING is denied. */
|
|
13
17
|
allow?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAGzB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;wDAMwD;AACxD,MAAM,MAAM,kBAAkB,GAAG,CAC/B,MAAM,EAAE,wBAAwB,EAChC,GAAG,EAAE,eAAe,KACjB,OAAO,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;AAEpE;;iGAEiG;AACjG,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE,eAAe,KACrB,OAAO,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;AAEpE,MAAM,WAAW,UAAU;IACzB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;sGAEkG;IAClG,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACnC;AAKD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,UAAU,GACjB,yBAAyB,CAsC3B"}
|
package/dist/pool.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Backend } from "./backend.js";
|
|
|
2
2
|
import { SessionHandle, type AcpSessionOptions } from "./acp-client.js";
|
|
3
3
|
import { type ClientHandlers } from "./client-handlers.js";
|
|
4
4
|
import type { AcpEventSink } from "./events.js";
|
|
5
|
-
import type { PermissionResolver } from "./permissions.js";
|
|
5
|
+
import type { ElicitationResolver, PermissionResolver } from "./permissions.js";
|
|
6
6
|
export interface AcpPoolOptions {
|
|
7
7
|
/** Long-lived processes to keep PER backend. Default 1; falls back to AGENTPRISM_ACP_POOL_SIZE. */
|
|
8
8
|
size?: number;
|
|
@@ -14,6 +14,8 @@ export interface AcpPoolOptions {
|
|
|
14
14
|
export interface AcpPoolDeps {
|
|
15
15
|
onEvent?: AcpEventSink;
|
|
16
16
|
permissionResolver?: PermissionResolver;
|
|
17
|
+
elicitationResolver?: ElicitationResolver;
|
|
18
|
+
advertiseElicitation?: boolean;
|
|
17
19
|
}
|
|
18
20
|
/** Resolve the per-backend pool size: explicit option wins, else env, else 1. Clamped to >= 1. */
|
|
19
21
|
export declare function resolvePoolSize(option?: number): number;
|
package/dist/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,cAAc,CAAC;AACvD,OAAO,EAAoB,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAA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CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAS;gBAGvB,OAAO,GAAE,cAAmB,EACX,IAAI,GAAE,WAAgB;IAOzC,8FAA8F;IACxF,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAMhF;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IA4BxB,OAAO,CAAC,cAAc;IAStB,+DAA+D;IAC/D,OAAO,CAAC,IAAI;IAOZ,iEAAiE;IAC3D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,cAAc;IAMtB,gGAAgG;IAChG,OAAO,CAAC,WAAW;CAGpB"}
|
package/dist/pool.js
CHANGED
|
@@ -56,6 +56,8 @@ export class AcpAgentPool {
|
|
|
56
56
|
onDead: (dead) => this.drop(key, dead),
|
|
57
57
|
onEvent: this.deps.onEvent,
|
|
58
58
|
permissionResolver: this.deps.permissionResolver,
|
|
59
|
+
elicitationResolver: this.deps.elicitationResolver,
|
|
60
|
+
advertiseElicitation: this.deps.advertiseElicitation,
|
|
59
61
|
clientHandlers: this.clientHandlers,
|
|
60
62
|
});
|
|
61
63
|
connections.push(connection);
|
|
@@ -11,11 +11,11 @@ export const CLIENT_METHOD_COVERAGE = {
|
|
|
11
11
|
[CLIENT_METHODS.terminal_release]: "served",
|
|
12
12
|
[CLIENT_METHODS.terminal_wait_for_exit]: "served",
|
|
13
13
|
[CLIENT_METHODS.terminal_kill]: "served",
|
|
14
|
-
[CLIENT_METHODS.mcp_connect]: "
|
|
15
|
-
[CLIENT_METHODS.mcp_message]: "
|
|
16
|
-
[CLIENT_METHODS.mcp_disconnect]: "
|
|
17
|
-
[CLIENT_METHODS.elicitation_create]: "
|
|
18
|
-
[CLIENT_METHODS.elicitation_complete]: "
|
|
14
|
+
[CLIENT_METHODS.mcp_connect]: "served",
|
|
15
|
+
[CLIENT_METHODS.mcp_message]: "served",
|
|
16
|
+
[CLIENT_METHODS.mcp_disconnect]: "served",
|
|
17
|
+
[CLIENT_METHODS.elicitation_create]: "served",
|
|
18
|
+
[CLIENT_METHODS.elicitation_complete]: "served",
|
|
19
19
|
};
|
|
20
20
|
export const AGENT_METHOD_COVERAGE = {
|
|
21
21
|
[AGENT_METHODS.initialize]: "driven",
|
package/dist/runner.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type AcpEventListener, type AcpEventName } from "./events.js";
|
|
|
6
6
|
import type { Backend } from "./backend.js";
|
|
7
7
|
import { InteractiveSession, type InteractiveSessionOptions } from "./interactive.js";
|
|
8
8
|
import { type BackendRegistry, type CustomBackendConfig } from "./registry.js";
|
|
9
|
-
import type { PermissionResolver } from "./permissions.js";
|
|
9
|
+
import type { ElicitationResolver, PermissionResolver } from "./permissions.js";
|
|
10
10
|
interface LifecycleRoutingOptions {
|
|
11
11
|
/** Model spec used only to select the backend process. */
|
|
12
12
|
model?: string;
|
|
@@ -49,6 +49,9 @@ export interface AcpRunnerOptions extends AcpPoolOptions {
|
|
|
49
49
|
/** Runner-wide human-in-the-loop permission resolver. When set, it replaces ToolPolicy
|
|
50
50
|
* auto-decisions for every session that does not provide its own resolver. */
|
|
51
51
|
onPermissionRequest?: PermissionResolver;
|
|
52
|
+
/** Runner-wide ACP elicitation responder. When set, initialize advertises unstable
|
|
53
|
+
* elicitation form/url support on every connection; sessions may override the resolver. */
|
|
54
|
+
onElicitation?: ElicitationResolver;
|
|
52
55
|
}
|
|
53
56
|
export declare class AcpAgentRunner implements AgentRunner {
|
|
54
57
|
private readonly pool;
|
|
@@ -63,6 +66,7 @@ export declare class AcpAgentRunner implements AgentRunner {
|
|
|
63
66
|
* so dedicated interactive connections must receive the SAME deps the pool receives. */
|
|
64
67
|
private readonly clientHandlers;
|
|
65
68
|
private readonly permissionResolver;
|
|
69
|
+
private readonly elicitationResolver;
|
|
66
70
|
/** Held-open interactive sessions own dedicated ACP processes outside the pool. The runner
|
|
67
71
|
* tracks their connections so dispose() can release them and the process-exit hook can
|
|
68
72
|
* synchronously kill any dedicated children if the host exits without release(). */
|
|
@@ -74,7 +78,8 @@ export declare class AcpAgentRunner implements AgentRunner {
|
|
|
74
78
|
/**
|
|
75
79
|
* Listen in on the live ACP stream. `name` is an ACP `sessionUpdate` discriminant
|
|
76
80
|
* ("agent_message_chunk", "tool_call", "usage_update", …) or one of the cross-cutting events
|
|
77
|
-
* ("session_update" catch-all, "permission_pending", "permission_request",
|
|
81
|
+
* ("session_update" catch-all, "permission_pending", "permission_request",
|
|
82
|
+
* "elicitation_pending", "elicitation_request", "elicitation_complete", "raw_message",
|
|
78
83
|
* "session_open", "session_close", "backend_error"). The listener is typed to the event.
|
|
79
84
|
* Returns an unsubscribe thunk. A pooled runner multiplexes many concurrent runs, so each
|
|
80
85
|
* event carries `{ sessionId, backendId, label?, runId? }` for filtering. Listeners are
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAmBA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAGV,oBAAoB,EAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAItF,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,mBAAmB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AC9F,OAAO,CAAC,cAAc;IAmCtB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,cAAc;IAMtB,gGAAgG;IAChG,OAAO,CAAC,WAAW;CAGpB;AAED;;;qDAGqD;AACrD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,cAAc,CAE1E;AAsDD;;;;oCAIoC;AACpC,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,OAAO,CAM1G"}
|
package/dist/runner.js
CHANGED
|
@@ -42,6 +42,7 @@ export class AcpAgentRunner {
|
|
|
42
42
|
* so dedicated interactive connections must receive the SAME deps the pool receives. */
|
|
43
43
|
clientHandlers;
|
|
44
44
|
permissionResolver;
|
|
45
|
+
elicitationResolver;
|
|
45
46
|
/** Held-open interactive sessions own dedicated ACP processes outside the pool. The runner
|
|
46
47
|
* tracks their connections so dispose() can release them and the process-exit hook can
|
|
47
48
|
* synchronously kill any dedicated children if the host exits without release(). */
|
|
@@ -52,16 +53,20 @@ export class AcpAgentRunner {
|
|
|
52
53
|
constructor(options = {}) {
|
|
53
54
|
this.clientHandlers = options.clientHandlers;
|
|
54
55
|
this.permissionResolver = options.onPermissionRequest;
|
|
56
|
+
this.elicitationResolver = options.onElicitation;
|
|
55
57
|
this.pool = new AcpAgentPool(options, {
|
|
56
58
|
onEvent: this.emitEvent,
|
|
57
59
|
permissionResolver: options.onPermissionRequest,
|
|
60
|
+
elicitationResolver: options.onElicitation,
|
|
61
|
+
advertiseElicitation: Boolean(options.onElicitation),
|
|
58
62
|
});
|
|
59
63
|
this.backends = resolveBackendRegistry(options.backends);
|
|
60
64
|
}
|
|
61
65
|
/**
|
|
62
66
|
* Listen in on the live ACP stream. `name` is an ACP `sessionUpdate` discriminant
|
|
63
67
|
* ("agent_message_chunk", "tool_call", "usage_update", …) or one of the cross-cutting events
|
|
64
|
-
* ("session_update" catch-all, "permission_pending", "permission_request",
|
|
68
|
+
* ("session_update" catch-all, "permission_pending", "permission_request",
|
|
69
|
+
* "elicitation_pending", "elicitation_request", "elicitation_complete", "raw_message",
|
|
65
70
|
* "session_open", "session_close", "backend_error"). The listener is typed to the event.
|
|
66
71
|
* Returns an unsubscribe thunk. A pooled runner multiplexes many concurrent runs, so each
|
|
67
72
|
* event carries `{ sessionId, backendId, label?, runId? }` for filtering. Listeners are
|
|
@@ -272,6 +277,7 @@ export class AcpAgentRunner {
|
|
|
272
277
|
schema: undefined,
|
|
273
278
|
registry: this.backends,
|
|
274
279
|
permissionResolver: opts.permissionResolver ?? opts.onPermissionRequest,
|
|
280
|
+
elicitationResolver: opts.onElicitation,
|
|
275
281
|
retainSessionLog: opts.retainSessionLog ?? false,
|
|
276
282
|
});
|
|
277
283
|
this.installExitHook();
|
|
@@ -322,6 +328,8 @@ export class AcpAgentRunner {
|
|
|
322
328
|
onDead,
|
|
323
329
|
onEvent: this.emitEvent,
|
|
324
330
|
permissionResolver: this.permissionResolver,
|
|
331
|
+
elicitationResolver: this.elicitationResolver,
|
|
332
|
+
advertiseElicitation: Boolean(this.elicitationResolver),
|
|
325
333
|
clientHandlers: this.clientHandlers,
|
|
326
334
|
});
|
|
327
335
|
}
|
|
@@ -343,6 +351,7 @@ export class AcpAgentRunner {
|
|
|
343
351
|
schema: config.schema,
|
|
344
352
|
policy,
|
|
345
353
|
permissionResolver: config.permissionResolver,
|
|
354
|
+
elicitationResolver: config.elicitationResolver,
|
|
346
355
|
signal: config.signal,
|
|
347
356
|
mcpServers: opts.mcpServers,
|
|
348
357
|
// Generic session-scoped _meta passthrough (RunOptions.meta) — merged UNDER the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automatalabs/acp-agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@agentclientprotocol/claude-agent-acp": "0.56.0",
|
|
32
32
|
"@automatalabs/codex-acp": "1.4.0",
|
|
33
33
|
"typebox": "1.3.2",
|
|
34
|
-
"@automatalabs/shared-types": "0.
|
|
34
|
+
"@automatalabs/shared-types": "0.10.0"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc -b",
|