stitchkit 0.132.1 → 0.132.2
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/CHANGELOG.md +7 -0
- package/dist/agent-executor/acp/v1-handlers.d.ts +2 -1
- package/dist/agent-executor/acp/v1-handlers.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-permission.d.ts +2 -0
- package/dist/agent-executor/acp/v1-permission.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-probe.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session-options.d.ts +19 -0
- package/dist/agent-executor/acp/v1-session-options.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-turn.d.ts +7 -1
- package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +5 -5
- package/dist/agent-runtime/sql-rows.d.ts +10 -10
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/entrypoints/agent-executor/acp.js +290 -160
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,13 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
|
|
|
15
15
|
|
|
16
16
|
## [Unreleased]
|
|
17
17
|
|
|
18
|
+
## [0.132.2] - 2026-11-27
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- `stitchkit/agent-executor/acp` — reject `AcpPermissionRequestEvent.respond` and `AgentEngineTurn.respond` once an ACP session is closing, disconnected, or aborted, ignore `AgentEngineTurn.interrupt` after teardown, stop delivering `onUpdate` / `onPermissionRequest` during `session/close` and after `AbortSignal` cancellation, deduplicate concurrent `close()` calls, and fail active turns with the closing or abort reason instead of settling late responses.
|
|
23
|
+
**Affects:** `stitchkit/agent-executor/acp` createAcpDriver(open), AcpSession, AcpPermissionRequestEvent, AcpUpdateEvent; `stitchkit/agent-executor` AgentEngineTurn
|
|
24
|
+
|
|
18
25
|
## [0.132.1] - 2026-11-27
|
|
19
26
|
|
|
20
27
|
### Fixed
|
|
@@ -31,11 +31,12 @@ export interface AcpPermissionRequestEvent {
|
|
|
31
31
|
readonly delta: Extract<ExecutorDelta, {
|
|
32
32
|
type: 'request';
|
|
33
33
|
}>;
|
|
34
|
-
/** Answer this permission request once; throws `TypeError` if invalid or already resolved. */
|
|
34
|
+
/** Answer this permission request once; rejects if the session is no longer alive, or throws `TypeError` if invalid or already resolved. */
|
|
35
35
|
respond(reply: InteractionReply['reply']): Promise<void>;
|
|
36
36
|
}
|
|
37
37
|
interface AcpHandlersState {
|
|
38
38
|
externalPending: Map<string, PendingExternalAcpRequest>;
|
|
39
|
+
ensureAlive: () => void;
|
|
39
40
|
isOpened: () => boolean;
|
|
40
41
|
getTurn: () => AcpTurnSlot | undefined;
|
|
41
42
|
onSessionMeta: (meta: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-handlers.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAKL,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAK7C,sGAAsG;AACtG,MAAM,MAAM,kBAAkB,GAAG,CAC/B,MAAM,EAAE,gBAAgB,KACrB,gBAAgB,GAAG,SAAS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,SAAS,eAAe,EAAE,CAAC;QAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KAC9B,KAAK,IAAI,CAAC;IACX,eAAe,CAAC,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjF,yBAAyB,CAAC,EAAE,eAAe,GAAG,KAAK,CAAC;IACpD,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B;AAWD,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,gBAAgB,EACrB,SAAS,EAAE,kBAAkB,GAAG,SAAS,GACxC,SAAS,gBAAgB,EAAE,CAQ7B;AAgPD,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB;IAQrD,cAAc,WAAW,MAAM,UAAU,YAAY,GAAG,SAAS;IAIjE,SAAS,WAAW,MAAM,UAAU,YAAY,GAAG,SAAS,MAAM,MAAM,GAAG,MAAM;IAIjF,KAAK,UAxRQ,KAAK,KAAK,IAAI;EA0R9B"}
|
|
@@ -14,6 +14,8 @@ export interface PendingExternalAcpRequest {
|
|
|
14
14
|
readonly detail: AcpPermissionDetail;
|
|
15
15
|
resolve(answer: JsonRpcValue): void;
|
|
16
16
|
}
|
|
17
|
+
/** Resolve and remove every pending external permission request with `ACP_CANCELLED`. */
|
|
18
|
+
export declare function drainExternalAcpPending(externalPending: Map<string, PendingExternalAcpRequest>): void;
|
|
17
19
|
/**
|
|
18
20
|
* Build the `request` delta fields for one ACP `session/request_permission` payload.
|
|
19
21
|
* Preserves existing top-level `rawInput`/`args` keys while exposing `options`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-permission.d.ts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AI,EAAE,iBAAiB,CAAC,YAAY,EAAE,mBAAmB,CAAC,EAC1D,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAClC,IAAI,CAON;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,IAAI,EAAE,iBAAiB,CAAC,YAAY,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAAC;IACvE,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IACxD,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CAClC,GAAG,IAAI,CAeP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-probe.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-probe.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,qBAAqB,EAAiB,MAAM,YAAY,CAAC;AAEvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EAMrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAKzB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"v1-probe.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-probe.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,qBAAqB,EAAiB,MAAM,YAAY,CAAC;AAEvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EAMrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAKzB,MAAM,eAAe,CAAC;AAKvB,qDAAqD;AACrD,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,iDAAiD;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C,sGAAsG;IACtG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,mGAAmG;IACnG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAC/E;AAED,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,gGAAgG;IAChG,QAAQ,CAAC,aAAa,EAAE,SAAS,eAAe,EAAE,CAAC;IACnD,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,uGAAuG;IACvG,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AA+ED,uGAAuG;AACvG,wBAAsB,cAAc,CAClC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,aAAa,EACzB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB;AA8BD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CAsD/B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { JsonRpcPeer } from '../json-rpc-peer.js';
|
|
3
|
+
import { type AcpConfigOption, type AcpSessionStateSchema } from './v1-protocol.js';
|
|
4
|
+
/** Merge initial `configOptions` from `session/new` / `session/load` with any earlier `config_option_update`. */
|
|
5
|
+
export declare function mergeInitialAcpConfigOptions(current: readonly AcpConfigOption[], incoming: readonly AcpConfigOption[] | null | undefined, sawConfigOptionUpdate: boolean): readonly AcpConfigOption[];
|
|
6
|
+
/** Update one ACP config option on an open session, returning the agent's latest option list. */
|
|
7
|
+
export declare function setAcpConfigOption(peer: JsonRpcPeer, sessionId: string, options: readonly AcpConfigOption[], category: string, value: string, signal?: AbortSignal): Promise<readonly AcpConfigOption[]>;
|
|
8
|
+
/** Apply initial `model`, `thoughtLevel`, and `mode` selections right after opening a session. */
|
|
9
|
+
export declare function applyAcpSessionSelections(input: {
|
|
10
|
+
peer: JsonRpcPeer;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
configOptions: readonly AcpConfigOption[];
|
|
13
|
+
models: z.infer<typeof AcpSessionStateSchema>['models'];
|
|
14
|
+
signal: AbortSignal;
|
|
15
|
+
model?: string;
|
|
16
|
+
thoughtLevel?: string;
|
|
17
|
+
mode?: string;
|
|
18
|
+
}): Promise<readonly AcpConfigOption[]>;
|
|
19
|
+
//# sourceMappingURL=v1-session-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1-session-options.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-session-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAG3B,MAAM,eAAe,CAAC;AAUvB,iHAAiH;AACjH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,QAAQ,EAAE,SAAS,eAAe,EAAE,GAAG,IAAI,GAAG,SAAS,EACvD,qBAAqB,EAAE,OAAO,GAC7B,SAAS,eAAe,EAAE,CAM5B;AAED,iGAAiG;AACjG,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CAiBrC;AAED,kGAAkG;AAClG,wBAAsB,yBAAyB,CAAC,KAAK,EAAE;IACrD,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,SAAS,eAAe,EAAE,CAAC;IAC1C,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CA2BtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-session.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"v1-session.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL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oD;IACpD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,wFAAwF;IACxF,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CAAC;IACtF,oHAAoH;IACpH,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF;;;OAGG;IACH,SAAS,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3E;AA0LD,wBAAsB,cAAc,CAClC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,UAAU,CAAC,CA2JrB"}
|
|
@@ -21,6 +21,11 @@ export interface AcpTurnSlot extends EngineRequestTurn<JsonRpcValue, AcpPermissi
|
|
|
21
21
|
settled: boolean;
|
|
22
22
|
}
|
|
23
23
|
export declare function newAcpTurn(turnId: string): AcpTurnSlot;
|
|
24
|
+
/**
|
|
25
|
+
* Mark a turn settled and fail its delta stream. When `sendCancelled` is `true`, pending
|
|
26
|
+
* permission requests are drained with `ACP_CANCELLED`; when `false`, they are dropped silently.
|
|
27
|
+
*/
|
|
28
|
+
export declare function settleAcpTurn(turn: AcpTurnSlot | undefined, reason: unknown, sendCancelled: boolean): void;
|
|
24
29
|
/**
|
|
25
30
|
* Send one `session/prompt` generation and settle the turn once the latest generation completes:
|
|
26
31
|
* accumulated usage, optional `watchPromptOutcome` override (`errorKind`, `threadDisposition`),
|
|
@@ -33,12 +38,13 @@ export declare function runAcpPrompt(input: {
|
|
|
33
38
|
prompt: readonly JsonRpcValue[];
|
|
34
39
|
turn: AcpTurnSlot;
|
|
35
40
|
generation: number;
|
|
41
|
+
ensureAlive: () => void;
|
|
36
42
|
usageInputIncludesCachedRead?: boolean;
|
|
37
43
|
checkOutcome?: AcpCheckPromptOutcome;
|
|
38
44
|
done: () => void;
|
|
39
45
|
}): void;
|
|
40
46
|
/** The turn as the executor steers it: interrupt with `session/cancel`, answer permission requests. */
|
|
41
|
-
export declare function acpTurnHandle(peer: JsonRpcPeer, sessionId: string, turn: AcpTurnSlot): AgentEngineTurn;
|
|
47
|
+
export declare function acpTurnHandle(peer: JsonRpcPeer, sessionId: string, turn: AcpTurnSlot, ensureAlive: () => void): AgentEngineTurn;
|
|
42
48
|
/** Build `startTurn` and `steerTurn` for an open ACP session. */
|
|
43
49
|
export declare function createAcpTurnControls(input: {
|
|
44
50
|
config: AcpDriverConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-turn.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-turn.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAEL,KAAK,iBAAiB,EAGvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EAMpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,eAAe,CAAC;AAS5E,uGAAuG;AACvG,MAAM,MAAM,qBAAqB,GAAG,CAClC,MAAM,EAAE,eAAe,KACpB,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,GAAG,wBA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aAAa,CAC3B,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,WAAW,EACjB,WAAW,EAAE,MAAM,IAAI,GACtB,eAAe,CAoBjB;AAED,iEAAiE;AACjE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;IACxB,WAAW,IAAI,IAAI,CAAC;IACpB,OAAO,IAAI,WAAW,GAAG,SAAS,CAAC;IACnC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAAC;CAC9C;IAOS,SAAS,YAAY;QACzB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;KACpC,GAAG,OAAO,CAAC,eAAe,CAAC;IAuCtB,SAAS,aAAa;QAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;KAC7C,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;EAiE3C"}
|
|
@@ -134,6 +134,11 @@ export declare function branchObservation(ids: BranchIdentities, kind: string, r
|
|
|
134
134
|
artifactId?: string | undefined;
|
|
135
135
|
payloadOmitted?: "max-payload-bytes" | undefined;
|
|
136
136
|
payloadSha256: string;
|
|
137
|
+
} | {
|
|
138
|
+
stepName: string;
|
|
139
|
+
encoded: string;
|
|
140
|
+
runId: string;
|
|
141
|
+
id?: string | undefined;
|
|
137
142
|
} | {
|
|
138
143
|
kind: "sleep";
|
|
139
144
|
name: string;
|
|
@@ -147,11 +152,6 @@ export declare function branchObservation(ids: BranchIdentities, kind: string, r
|
|
|
147
152
|
id: string;
|
|
148
153
|
encoded?: string | undefined;
|
|
149
154
|
runId: string;
|
|
150
|
-
} | {
|
|
151
|
-
stepName: string;
|
|
152
|
-
encoded: string;
|
|
153
|
-
runId: string;
|
|
154
|
-
id?: string | undefined;
|
|
155
155
|
} | {
|
|
156
156
|
event: string;
|
|
157
157
|
id: string;
|
|
@@ -124,6 +124,16 @@ export declare function parseRunRow(value: unknown): {
|
|
|
124
124
|
provider: string;
|
|
125
125
|
data: Record<string, z.JSONType>;
|
|
126
126
|
} | undefined;
|
|
127
|
+
} | {
|
|
128
|
+
type: "file";
|
|
129
|
+
mediaType: string;
|
|
130
|
+
reference: string;
|
|
131
|
+
filename?: string | undefined;
|
|
132
|
+
} | {
|
|
133
|
+
type: "source";
|
|
134
|
+
sourceId: string;
|
|
135
|
+
url?: string | undefined;
|
|
136
|
+
title?: string | undefined;
|
|
127
137
|
} | {
|
|
128
138
|
type: "tool-call";
|
|
129
139
|
callId: string;
|
|
@@ -140,16 +150,6 @@ export declare function parseRunRow(value: unknown): {
|
|
|
140
150
|
toolName: string;
|
|
141
151
|
outcome: "error" | "interrupted" | "success";
|
|
142
152
|
output?: z.JSONType | undefined;
|
|
143
|
-
} | {
|
|
144
|
-
type: "file";
|
|
145
|
-
mediaType: string;
|
|
146
|
-
reference: string;
|
|
147
|
-
filename?: string | undefined;
|
|
148
|
-
} | {
|
|
149
|
-
type: "source";
|
|
150
|
-
sourceId: string;
|
|
151
|
-
url?: string | undefined;
|
|
152
|
-
title?: string | undefined;
|
|
153
153
|
} | {
|
|
154
154
|
type: "tool-approval-request";
|
|
155
155
|
approvalId: string;
|
|
@@ -141,16 +141,6 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
141
141
|
provider: string;
|
|
142
142
|
data: Record<string, import("zod").JSONType>;
|
|
143
143
|
} | undefined;
|
|
144
|
-
} | {
|
|
145
|
-
type: "file";
|
|
146
|
-
mediaType: string;
|
|
147
|
-
reference: string;
|
|
148
|
-
filename?: string | undefined;
|
|
149
|
-
} | {
|
|
150
|
-
type: "source";
|
|
151
|
-
sourceId: string;
|
|
152
|
-
url?: string | undefined;
|
|
153
|
-
title?: string | undefined;
|
|
154
144
|
} | {
|
|
155
145
|
type: "tool-call";
|
|
156
146
|
callId: string;
|
|
@@ -167,6 +157,16 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
167
157
|
toolName: string;
|
|
168
158
|
outcome: "error" | "interrupted" | "success";
|
|
169
159
|
output?: import("zod").JSONType | undefined;
|
|
160
|
+
} | {
|
|
161
|
+
type: "file";
|
|
162
|
+
mediaType: string;
|
|
163
|
+
reference: string;
|
|
164
|
+
filename?: string | undefined;
|
|
165
|
+
} | {
|
|
166
|
+
type: "source";
|
|
167
|
+
sourceId: string;
|
|
168
|
+
url?: string | undefined;
|
|
169
|
+
title?: string | undefined;
|
|
170
170
|
} | {
|
|
171
171
|
type: "tool-approval-request";
|
|
172
172
|
approvalId: string;
|
|
@@ -321,16 +321,6 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
321
321
|
provider: string;
|
|
322
322
|
data: Record<string, import("zod").JSONType>;
|
|
323
323
|
} | undefined;
|
|
324
|
-
} | {
|
|
325
|
-
type: "file";
|
|
326
|
-
mediaType: string;
|
|
327
|
-
reference: string;
|
|
328
|
-
filename?: string | undefined;
|
|
329
|
-
} | {
|
|
330
|
-
type: "source";
|
|
331
|
-
sourceId: string;
|
|
332
|
-
url?: string | undefined;
|
|
333
|
-
title?: string | undefined;
|
|
334
324
|
} | {
|
|
335
325
|
type: "tool-call";
|
|
336
326
|
callId: string;
|
|
@@ -347,6 +337,16 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
347
337
|
toolName: string;
|
|
348
338
|
outcome: "error" | "interrupted" | "success";
|
|
349
339
|
output?: import("zod").JSONType | undefined;
|
|
340
|
+
} | {
|
|
341
|
+
type: "file";
|
|
342
|
+
mediaType: string;
|
|
343
|
+
reference: string;
|
|
344
|
+
filename?: string | undefined;
|
|
345
|
+
} | {
|
|
346
|
+
type: "source";
|
|
347
|
+
sourceId: string;
|
|
348
|
+
url?: string | undefined;
|
|
349
|
+
title?: string | undefined;
|
|
350
350
|
} | {
|
|
351
351
|
type: "tool-approval-request";
|
|
352
352
|
approvalId: string;
|
|
@@ -16,6 +16,16 @@ export declare function userMessage(conversationId: string, id: string): {
|
|
|
16
16
|
provider: string;
|
|
17
17
|
data: Record<string, import("zod").JSONType>;
|
|
18
18
|
} | undefined;
|
|
19
|
+
} | {
|
|
20
|
+
type: "file";
|
|
21
|
+
mediaType: string;
|
|
22
|
+
reference: string;
|
|
23
|
+
filename?: string | undefined;
|
|
24
|
+
} | {
|
|
25
|
+
type: "source";
|
|
26
|
+
sourceId: string;
|
|
27
|
+
url?: string | undefined;
|
|
28
|
+
title?: string | undefined;
|
|
19
29
|
} | {
|
|
20
30
|
type: "tool-call";
|
|
21
31
|
callId: string;
|
|
@@ -32,16 +42,6 @@ export declare function userMessage(conversationId: string, id: string): {
|
|
|
32
42
|
toolName: string;
|
|
33
43
|
outcome: "error" | "interrupted" | "success";
|
|
34
44
|
output?: import("zod").JSONType | undefined;
|
|
35
|
-
} | {
|
|
36
|
-
type: "file";
|
|
37
|
-
mediaType: string;
|
|
38
|
-
reference: string;
|
|
39
|
-
filename?: string | undefined;
|
|
40
|
-
} | {
|
|
41
|
-
type: "source";
|
|
42
|
-
sourceId: string;
|
|
43
|
-
url?: string | undefined;
|
|
44
|
-
title?: string | undefined;
|
|
45
45
|
} | {
|
|
46
46
|
type: "tool-approval-request";
|
|
47
47
|
approvalId: string;
|
|
@@ -41,16 +41,6 @@ export declare function appliedSnapshot(result: AgentStoreMutationResult, operat
|
|
|
41
41
|
provider: string;
|
|
42
42
|
data: Record<string, import("zod").JSONType>;
|
|
43
43
|
} | undefined;
|
|
44
|
-
} | {
|
|
45
|
-
type: "file";
|
|
46
|
-
mediaType: string;
|
|
47
|
-
reference: string;
|
|
48
|
-
filename?: string | undefined;
|
|
49
|
-
} | {
|
|
50
|
-
type: "source";
|
|
51
|
-
sourceId: string;
|
|
52
|
-
url?: string | undefined;
|
|
53
|
-
title?: string | undefined;
|
|
54
44
|
} | {
|
|
55
45
|
type: "tool-call";
|
|
56
46
|
callId: string;
|
|
@@ -67,6 +57,16 @@ export declare function appliedSnapshot(result: AgentStoreMutationResult, operat
|
|
|
67
57
|
toolName: string;
|
|
68
58
|
outcome: "error" | "interrupted" | "success";
|
|
69
59
|
output?: import("zod").JSONType | undefined;
|
|
60
|
+
} | {
|
|
61
|
+
type: "file";
|
|
62
|
+
mediaType: string;
|
|
63
|
+
reference: string;
|
|
64
|
+
filename?: string | undefined;
|
|
65
|
+
} | {
|
|
66
|
+
type: "source";
|
|
67
|
+
sourceId: string;
|
|
68
|
+
url?: string | undefined;
|
|
69
|
+
title?: string | undefined;
|
|
70
70
|
} | {
|
|
71
71
|
type: "tool-approval-request";
|
|
72
72
|
approvalId: string;
|
|
@@ -719,6 +719,12 @@ var ACP_CANCELLED = { outcome: { outcome: "cancelled" } };
|
|
|
719
719
|
var AcpOptionSelectionInputSchema = z4.strictObject({
|
|
720
720
|
optionId: z4.string().min(1)
|
|
721
721
|
});
|
|
722
|
+
function drainExternalAcpPending(externalPending) {
|
|
723
|
+
for (const [interactionId, pending] of [...externalPending]) {
|
|
724
|
+
externalPending.delete(interactionId);
|
|
725
|
+
pending.resolve(ACP_CANCELLED);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
722
728
|
function isPlainJsonRecord(value) {
|
|
723
729
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
724
730
|
}
|
|
@@ -810,6 +816,14 @@ function answerAcpSessionRequest(input) {
|
|
|
810
816
|
// src/agent-executor/acp/v1-handlers.ts
|
|
811
817
|
var JSON_RPC_INTERNAL_ERROR = -32603;
|
|
812
818
|
var MAX_EXTERNAL_PENDING_REQUESTS = 256;
|
|
819
|
+
function isHandlersAlive(state) {
|
|
820
|
+
try {
|
|
821
|
+
state.ensureAlive();
|
|
822
|
+
return true;
|
|
823
|
+
} catch {
|
|
824
|
+
return false;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
813
827
|
function normalizeTransformedUpdates(raw, transform) {
|
|
814
828
|
if (transform === undefined)
|
|
815
829
|
return [raw];
|
|
@@ -856,6 +870,8 @@ function handleAcpNotification(state, externalState, method, params) {
|
|
|
856
870
|
try {
|
|
857
871
|
updates = normalizeTransformedUpdates(parsed.data.update, state.transformUpdate);
|
|
858
872
|
} catch (error) {
|
|
873
|
+
if (!isHandlersAlive(state))
|
|
874
|
+
return;
|
|
859
875
|
if (turn !== undefined) {
|
|
860
876
|
turn.chunk += 1;
|
|
861
877
|
offerTurnDelta(turn.channel, {
|
|
@@ -871,6 +887,8 @@ function handleAcpNotification(state, externalState, method, params) {
|
|
|
871
887
|
}
|
|
872
888
|
const opened = state.isOpened();
|
|
873
889
|
for (const update of updates) {
|
|
890
|
+
if (!isHandlersAlive(state))
|
|
891
|
+
return;
|
|
874
892
|
state.onSessionMeta({
|
|
875
893
|
...update.configOptions !== undefined && { configOptions: update.configOptions },
|
|
876
894
|
...update.sessionUpdate === "session_info_update" && typeof update.title === "string" && { title: update.title },
|
|
@@ -936,7 +954,7 @@ function handleAcpRequest(state, method, params, id) {
|
|
|
936
954
|
resolve
|
|
937
955
|
});
|
|
938
956
|
});
|
|
939
|
-
if (state.permissionRequestDelivery === "all" && state.onPermissionRequest !== undefined && turn.pending.has(interactionId)) {
|
|
957
|
+
if (state.permissionRequestDelivery === "all" && state.onPermissionRequest !== undefined && turn.pending.has(interactionId) && isHandlersAlive(state)) {
|
|
940
958
|
const observer = state.onPermissionRequest;
|
|
941
959
|
invokeSafely(() => observer({
|
|
942
960
|
interactionId,
|
|
@@ -945,6 +963,7 @@ function handleAcpRequest(state, method, params, id) {
|
|
|
945
963
|
duringActiveTurn: true,
|
|
946
964
|
delta,
|
|
947
965
|
async respond(reply) {
|
|
966
|
+
state.ensureAlive();
|
|
948
967
|
answerActiveAcpTurnRequest(turn, interactionId, reply);
|
|
949
968
|
}
|
|
950
969
|
}));
|
|
@@ -978,6 +997,8 @@ function handleAcpRequest(state, method, params, id) {
|
|
|
978
997
|
if (state.externalPending.get(interactionId) !== entry)
|
|
979
998
|
return;
|
|
980
999
|
state.externalPending.delete(interactionId);
|
|
1000
|
+
if (!isHandlersAlive(state))
|
|
1001
|
+
return;
|
|
981
1002
|
if (error instanceof JsonRpcError2)
|
|
982
1003
|
reject(error);
|
|
983
1004
|
else
|
|
@@ -991,6 +1012,7 @@ function handleAcpRequest(state, method, params, id) {
|
|
|
991
1012
|
duringActiveTurn: false,
|
|
992
1013
|
delta,
|
|
993
1014
|
async respond(reply) {
|
|
1015
|
+
state.ensureAlive();
|
|
994
1016
|
answerAcpSessionRequest({
|
|
995
1017
|
turn: undefined,
|
|
996
1018
|
externalPending: state.externalPending,
|
|
@@ -1000,8 +1022,23 @@ function handleAcpRequest(state, method, params, id) {
|
|
|
1000
1022
|
});
|
|
1001
1023
|
}
|
|
1002
1024
|
});
|
|
1003
|
-
|
|
1004
|
-
|
|
1025
|
+
const thenable = typeof outcome === "object" && outcome !== null && "then" in outcome && typeof outcome.then === "function";
|
|
1026
|
+
if (!isHandlersAlive(state)) {
|
|
1027
|
+
if (state.externalPending.get(interactionId) === entry) {
|
|
1028
|
+
state.externalPending.delete(interactionId);
|
|
1029
|
+
}
|
|
1030
|
+
if (thenable)
|
|
1031
|
+
Promise.resolve(outcome).catch(() => {
|
|
1032
|
+
return;
|
|
1033
|
+
});
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
if (thenable) {
|
|
1037
|
+
Promise.resolve(outcome).then(() => {
|
|
1038
|
+
if (!isHandlersAlive(state) && state.externalPending.get(interactionId) === entry) {
|
|
1039
|
+
state.externalPending.delete(interactionId);
|
|
1040
|
+
}
|
|
1041
|
+
}, onObserverError);
|
|
1005
1042
|
}
|
|
1006
1043
|
} catch (error) {
|
|
1007
1044
|
onObserverError(error);
|
|
@@ -1013,13 +1050,70 @@ function createAcpHandlers(state) {
|
|
|
1013
1050
|
chunk: 0,
|
|
1014
1051
|
track: { segment: 0, toolNames: new Map }
|
|
1015
1052
|
};
|
|
1053
|
+
const dropClosedRequest = () => new Promise(() => {
|
|
1054
|
+
return;
|
|
1055
|
+
});
|
|
1016
1056
|
return {
|
|
1017
|
-
onNotification: (method, params) =>
|
|
1018
|
-
|
|
1057
|
+
onNotification: (method, params) => {
|
|
1058
|
+
if (!isHandlersAlive(state))
|
|
1059
|
+
return;
|
|
1060
|
+
handleAcpNotification(state, externalState, method, params);
|
|
1061
|
+
},
|
|
1062
|
+
onRequest: (method, params, id) => {
|
|
1063
|
+
if (!isHandlersAlive(state))
|
|
1064
|
+
return dropClosedRequest();
|
|
1065
|
+
return handleAcpRequest(state, method, params, id);
|
|
1066
|
+
},
|
|
1019
1067
|
onEnd: state.onEnd
|
|
1020
1068
|
};
|
|
1021
1069
|
}
|
|
1022
1070
|
|
|
1071
|
+
// src/agent-executor/acp/v1-session-options.ts
|
|
1072
|
+
function optionOf(options, category) {
|
|
1073
|
+
return options.find((option) => option.category === category) ?? options.find((option) => option.id === category);
|
|
1074
|
+
}
|
|
1075
|
+
function mergeInitialAcpConfigOptions(current, incoming, sawConfigOptionUpdate) {
|
|
1076
|
+
if (incoming == null)
|
|
1077
|
+
return current;
|
|
1078
|
+
if (!sawConfigOptionUpdate || current.length === 0 && incoming.length > 0) {
|
|
1079
|
+
return incoming;
|
|
1080
|
+
}
|
|
1081
|
+
return current;
|
|
1082
|
+
}
|
|
1083
|
+
async function setAcpConfigOption(peer, sessionId, options, category, value, signal) {
|
|
1084
|
+
const option = optionOf(options, category);
|
|
1085
|
+
if (option === undefined)
|
|
1086
|
+
throw new Error(`The ACP agent offers no ${category} option`);
|
|
1087
|
+
const values = acpOptionValues(option);
|
|
1088
|
+
if (values.length > 0 && !values.includes(value)) {
|
|
1089
|
+
throw new Error(`The ACP agent's ${category} option has no value ${value} (offered: ${values.join(", ")})`);
|
|
1090
|
+
}
|
|
1091
|
+
const answer = AcpSetConfigOptionResultSchema.parse(await peer.request("session/set_config_option", { sessionId, configId: option.id, value }, signal !== undefined ? { signal } : undefined));
|
|
1092
|
+
return answer.configOptions ?? options;
|
|
1093
|
+
}
|
|
1094
|
+
async function applyAcpSessionSelections(input) {
|
|
1095
|
+
let options = input.configOptions;
|
|
1096
|
+
const setCat = (category, value) => setAcpConfigOption(input.peer, input.sessionId, options, category, value, input.signal);
|
|
1097
|
+
if (input.model !== undefined) {
|
|
1098
|
+
if (optionOf(options, "model") !== undefined) {
|
|
1099
|
+
options = await setCat("model", input.model);
|
|
1100
|
+
} else if (input.models !== undefined && input.models !== null) {
|
|
1101
|
+
const available = input.models.availableModels?.map((entry) => entry.modelId) ?? [];
|
|
1102
|
+
if (available.length > 0 && !available.includes(input.model)) {
|
|
1103
|
+
throw new Error(`The ACP agent's model option has no value ${input.model} (offered: ${available.join(", ")})`);
|
|
1104
|
+
}
|
|
1105
|
+
await input.peer.request("session/set_model", { sessionId: input.sessionId, modelId: input.model }, { signal: input.signal });
|
|
1106
|
+
} else {
|
|
1107
|
+
throw new Error("The ACP agent offers no model option");
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
if (input.thoughtLevel !== undefined)
|
|
1111
|
+
options = await setCat("thought_level", input.thoughtLevel);
|
|
1112
|
+
if (input.mode !== undefined)
|
|
1113
|
+
options = await setCat("mode", input.mode);
|
|
1114
|
+
return options;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1023
1117
|
// src/agent-executor/acp/v1-probe.ts
|
|
1024
1118
|
var DEFAULT_PROBE_TIMEOUT_MS = 30000;
|
|
1025
1119
|
var ProbeSessionId = AcpNewSessionResultSchema.pick({ sessionId: true });
|
|
@@ -1134,9 +1228,7 @@ async function probeAcpCapabilities(config, input) {
|
|
|
1134
1228
|
let result;
|
|
1135
1229
|
try {
|
|
1136
1230
|
const session = await readProbeSession(config, connection, input.cwd, deadlineSignal);
|
|
1137
|
-
|
|
1138
|
-
configOptions = session.configOptions;
|
|
1139
|
-
}
|
|
1231
|
+
configOptions = mergeInitialAcpConfigOptions(configOptions, session.configOptions, sawConfigOptionUpdate);
|
|
1140
1232
|
deadlineSignal.throwIfAborted();
|
|
1141
1233
|
const models = extractProbeModels(configOptions, session.models?.availableModels);
|
|
1142
1234
|
result = {
|
|
@@ -1175,11 +1267,23 @@ function newAcpTurn(turnId) {
|
|
|
1175
1267
|
settled: false
|
|
1176
1268
|
};
|
|
1177
1269
|
}
|
|
1270
|
+
function settleAcpTurn(turn, reason, sendCancelled) {
|
|
1271
|
+
if (turn === undefined)
|
|
1272
|
+
return;
|
|
1273
|
+
turn.settled = true;
|
|
1274
|
+
if (sendCancelled) {
|
|
1275
|
+
loseEngineTurn(turn, () => ACP_CANCELLED, reason);
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1278
|
+
turn.pending.clear();
|
|
1279
|
+
turn.channel.fail(reason);
|
|
1280
|
+
}
|
|
1178
1281
|
function runAcpPrompt(input) {
|
|
1179
|
-
const { peer, sessionId, prompt, turn, generation, checkOutcome, done } = input;
|
|
1282
|
+
const { peer, sessionId, prompt, turn, generation, ensureAlive, checkOutcome, done } = input;
|
|
1180
1283
|
peer.request("session/prompt", { sessionId, prompt: [...prompt] }, { timeoutMs: null }).then(async (result) => {
|
|
1181
1284
|
if (turn.settled)
|
|
1182
1285
|
return;
|
|
1286
|
+
ensureAlive();
|
|
1183
1287
|
const parsed = AcpPromptResultSchema.parse(result);
|
|
1184
1288
|
if (parsed.usage !== undefined && parsed.usage !== null) {
|
|
1185
1289
|
turn.accumulatedUsage = addAcpTokenUsage(turn.accumulatedUsage, normalizeAcpUsage(parsed.usage, {
|
|
@@ -1193,6 +1297,7 @@ function runAcpPrompt(input) {
|
|
|
1193
1297
|
const rawOverride = !turn.state.interruptRequested && checkOutcome !== undefined ? await checkOutcome(parsed) : undefined;
|
|
1194
1298
|
if (turn.settled || generation !== turn.promptGeneration)
|
|
1195
1299
|
return;
|
|
1300
|
+
ensureAlive();
|
|
1196
1301
|
const override = rawOverride !== undefined ? AcpPromptOutcomeOverrideSchema.parse(rawOverride) : undefined;
|
|
1197
1302
|
const outcome = override !== undefined ? "failed" : acpOutcome(parsed.stopReason, turn.state.interruptRequested);
|
|
1198
1303
|
const raw = { source: "acp", type: `session/prompt/${parsed.stopReason}` };
|
|
@@ -1242,8 +1347,21 @@ function runAcpPrompt(input) {
|
|
|
1242
1347
|
if (turn.settled || generation !== turn.promptGeneration)
|
|
1243
1348
|
return;
|
|
1244
1349
|
turn.settled = true;
|
|
1245
|
-
|
|
1246
|
-
|
|
1350
|
+
let failure = error;
|
|
1351
|
+
let alive = true;
|
|
1352
|
+
try {
|
|
1353
|
+
ensureAlive();
|
|
1354
|
+
} catch (aliveError) {
|
|
1355
|
+
alive = false;
|
|
1356
|
+
failure = aliveError;
|
|
1357
|
+
}
|
|
1358
|
+
if (!alive) {
|
|
1359
|
+
settleAcpTurn(turn, failure, false);
|
|
1360
|
+
done();
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
const kind = classifyAcpRpcRefusal(failure);
|
|
1364
|
+
if (kind !== undefined && failure instanceof Error) {
|
|
1247
1365
|
const raw = { source: "acp", type: "session/prompt" };
|
|
1248
1366
|
endEngineTurn(turn, () => ACP_CANCELLED, [
|
|
1249
1367
|
{
|
|
@@ -1252,7 +1370,7 @@ function runAcpPrompt(input) {
|
|
|
1252
1370
|
itemId: "failure",
|
|
1253
1371
|
raw,
|
|
1254
1372
|
kind,
|
|
1255
|
-
message:
|
|
1373
|
+
message: failure.message
|
|
1256
1374
|
},
|
|
1257
1375
|
{
|
|
1258
1376
|
type: "turn-end",
|
|
@@ -1263,20 +1381,28 @@ function runAcpPrompt(input) {
|
|
|
1263
1381
|
}
|
|
1264
1382
|
]);
|
|
1265
1383
|
} else {
|
|
1266
|
-
loseEngineTurn(turn, () => ACP_CANCELLED,
|
|
1384
|
+
loseEngineTurn(turn, () => ACP_CANCELLED, failure);
|
|
1267
1385
|
}
|
|
1268
1386
|
done();
|
|
1269
1387
|
});
|
|
1270
1388
|
}
|
|
1271
|
-
function acpTurnHandle(peer, sessionId, turn) {
|
|
1389
|
+
function acpTurnHandle(peer, sessionId, turn, ensureAlive) {
|
|
1272
1390
|
return {
|
|
1273
1391
|
deltas: turn.channel,
|
|
1274
1392
|
async interrupt() {
|
|
1393
|
+
if (turn.settled)
|
|
1394
|
+
return;
|
|
1395
|
+
try {
|
|
1396
|
+
ensureAlive();
|
|
1397
|
+
} catch {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1275
1400
|
turn.state.interruptRequested = true;
|
|
1276
1401
|
peer.notify("session/cancel", { sessionId });
|
|
1277
1402
|
drainEngineRequests(turn, () => ACP_CANCELLED);
|
|
1278
1403
|
},
|
|
1279
1404
|
async respond(interactionId, rawReply) {
|
|
1405
|
+
ensureAlive();
|
|
1280
1406
|
answerActiveAcpTurnRequest(turn, interactionId, rawReply);
|
|
1281
1407
|
}
|
|
1282
1408
|
};
|
|
@@ -1299,6 +1425,7 @@ function createAcpTurnControls(input) {
|
|
|
1299
1425
|
let checkOutcome;
|
|
1300
1426
|
try {
|
|
1301
1427
|
prompt = await acpPromptBlocks(turnInput.input, input.limits);
|
|
1428
|
+
input.ensureAlive();
|
|
1302
1429
|
if (input.config.watchPromptOutcome !== undefined) {
|
|
1303
1430
|
checkOutcome = await input.config.watchPromptOutcome({
|
|
1304
1431
|
sessionId: input.sessionId,
|
|
@@ -1318,13 +1445,14 @@ function createAcpTurnControls(input) {
|
|
|
1318
1445
|
prompt,
|
|
1319
1446
|
turn,
|
|
1320
1447
|
generation: 1,
|
|
1448
|
+
ensureAlive: input.ensureAlive,
|
|
1321
1449
|
...input.config.usageInputIncludesCachedRead !== undefined && {
|
|
1322
1450
|
usageInputIncludesCachedRead: input.config.usageInputIncludesCachedRead
|
|
1323
1451
|
},
|
|
1324
1452
|
...checkOutcome !== undefined && { checkOutcome },
|
|
1325
1453
|
done: () => releaseTurn(turn)
|
|
1326
1454
|
});
|
|
1327
|
-
return acpTurnHandle(input.peer, input.sessionId, turn);
|
|
1455
|
+
return acpTurnHandle(input.peer, input.sessionId, turn, input.ensureAlive);
|
|
1328
1456
|
},
|
|
1329
1457
|
async steerTurn(steerInput) {
|
|
1330
1458
|
if ((input.config.steerMode ?? "none") !== "prompt") {
|
|
@@ -1373,6 +1501,7 @@ function createAcpTurnControls(input) {
|
|
|
1373
1501
|
prompt,
|
|
1374
1502
|
turn,
|
|
1375
1503
|
generation: nextGeneration,
|
|
1504
|
+
ensureAlive: input.ensureAlive,
|
|
1376
1505
|
...input.config.usageInputIncludesCachedRead !== undefined && {
|
|
1377
1506
|
usageInputIncludesCachedRead: input.config.usageInputIncludesCachedRead
|
|
1378
1507
|
},
|
|
@@ -1385,68 +1514,41 @@ function createAcpTurnControls(input) {
|
|
|
1385
1514
|
}
|
|
1386
1515
|
|
|
1387
1516
|
// src/agent-executor/acp/v1-session.ts
|
|
1388
|
-
function
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
if (available.length > 0 && !available.includes(input.model)) {
|
|
1410
|
-
throw new Error(`The ACP agent's model option has no value ${input.model} (offered: ${available.join(", ")})`);
|
|
1517
|
+
function createAcpSessionClose(input) {
|
|
1518
|
+
const { state, linked, externalPending } = input;
|
|
1519
|
+
let closePromise;
|
|
1520
|
+
return () => {
|
|
1521
|
+
if (closePromise !== undefined)
|
|
1522
|
+
return closePromise;
|
|
1523
|
+
closePromise = (async () => {
|
|
1524
|
+
const alreadyTerminated = state.dead !== undefined || linked.signal.aborted;
|
|
1525
|
+
const closeReason = state.dead ?? (linked.signal.aborted ? abortReason(linked.signal) : new Error("The ACP session is closing"));
|
|
1526
|
+
state.closing = true;
|
|
1527
|
+
const turn = state.current;
|
|
1528
|
+
state.current = undefined;
|
|
1529
|
+
settleAcpTurn(turn, closeReason, !alreadyTerminated);
|
|
1530
|
+
if (alreadyTerminated)
|
|
1531
|
+
externalPending.clear();
|
|
1532
|
+
else
|
|
1533
|
+
drainExternalAcpPending(externalPending);
|
|
1534
|
+
if (!alreadyTerminated && acpCan(input.connected, "close")) {
|
|
1535
|
+
await input.connected.peer.request("session/close", { sessionId: input.sessionId }, { timeoutMs: closeRequestTimeoutMs(input.config), signal: linked.signal }).catch(() => {
|
|
1536
|
+
return;
|
|
1537
|
+
});
|
|
1411
1538
|
}
|
|
1412
|
-
await input.
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
} else {
|
|
1417
|
-
throw new Error("The ACP agent offers no model option");
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
if (input.thoughtLevel !== undefined) {
|
|
1421
|
-
options = await setOption(input.peer, input.sessionId, options, "thought_level", input.thoughtLevel);
|
|
1422
|
-
}
|
|
1423
|
-
if (input.mode !== undefined) {
|
|
1424
|
-
options = await setOption(input.peer, input.sessionId, options, "mode", input.mode);
|
|
1425
|
-
}
|
|
1426
|
-
return options;
|
|
1427
|
-
}
|
|
1428
|
-
function drainExternalPending(externalPending) {
|
|
1429
|
-
for (const [interactionId, pending] of [...externalPending]) {
|
|
1430
|
-
externalPending.delete(interactionId);
|
|
1431
|
-
pending.resolve(ACP_CANCELLED);
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
function mergeInitialConfigOptions(current, incoming, sawConfigOptionUpdate) {
|
|
1435
|
-
if (incoming == null)
|
|
1436
|
-
return current;
|
|
1437
|
-
if (!sawConfigOptionUpdate || current.length === 0 && incoming.length > 0) {
|
|
1438
|
-
return incoming;
|
|
1439
|
-
}
|
|
1440
|
-
return current;
|
|
1539
|
+
await input.stop();
|
|
1540
|
+
})();
|
|
1541
|
+
return closePromise;
|
|
1542
|
+
};
|
|
1441
1543
|
}
|
|
1442
1544
|
async function openOrReopenAcpSession(input) {
|
|
1443
|
-
const { connected, cwd, nativeThreadId, mcpServers, meta } = input;
|
|
1545
|
+
const { connected, cwd, nativeThreadId, mcpServers, meta, signal } = input;
|
|
1444
1546
|
if (nativeThreadId === undefined) {
|
|
1445
1547
|
const created = AcpNewSessionResultSchema.parse(await connected.peer.request("session/new", {
|
|
1446
1548
|
cwd,
|
|
1447
1549
|
mcpServers,
|
|
1448
1550
|
...meta !== undefined && { _meta: meta }
|
|
1449
|
-
}));
|
|
1551
|
+
}, { signal }));
|
|
1450
1552
|
return {
|
|
1451
1553
|
sessionId: created.sessionId,
|
|
1452
1554
|
configOptions: created.configOptions,
|
|
@@ -1459,35 +1561,104 @@ async function openOrReopenAcpSession(input) {
|
|
|
1459
1561
|
cwd,
|
|
1460
1562
|
mcpServers,
|
|
1461
1563
|
...meta !== undefined && { _meta: meta }
|
|
1462
|
-
}) ?? {});
|
|
1564
|
+
}, { signal }) ?? {});
|
|
1463
1565
|
return {
|
|
1464
1566
|
sessionId: nativeThreadId,
|
|
1465
1567
|
configOptions: reopened.configOptions,
|
|
1466
1568
|
models: reopened.models
|
|
1467
1569
|
};
|
|
1468
1570
|
}
|
|
1571
|
+
function buildAcpSession(input) {
|
|
1572
|
+
const { config, connected, sessionId, linked, externalPending, state, ensureAlive, stop } = input;
|
|
1573
|
+
const { peer, initialized } = connected;
|
|
1574
|
+
const limits = {
|
|
1575
|
+
images: initialized.agentCapabilities?.promptCapabilities?.image === true,
|
|
1576
|
+
maxImageBytes: config.maxImageBytes ?? DEFAULT_MAX_IMAGE_BYTES,
|
|
1577
|
+
...config.resolveFile && { resolveFile: config.resolveFile }
|
|
1578
|
+
};
|
|
1579
|
+
const turnControls = createAcpTurnControls({
|
|
1580
|
+
config,
|
|
1581
|
+
peer,
|
|
1582
|
+
sessionId,
|
|
1583
|
+
limits,
|
|
1584
|
+
ensureAlive,
|
|
1585
|
+
getTurn: () => state.current,
|
|
1586
|
+
setTurn: (turn) => {
|
|
1587
|
+
state.current = turn;
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
const close = createAcpSessionClose({
|
|
1591
|
+
config,
|
|
1592
|
+
connected,
|
|
1593
|
+
sessionId,
|
|
1594
|
+
linked,
|
|
1595
|
+
externalPending,
|
|
1596
|
+
state,
|
|
1597
|
+
stop
|
|
1598
|
+
});
|
|
1599
|
+
ensureAlive();
|
|
1600
|
+
state.opened = true;
|
|
1601
|
+
return {
|
|
1602
|
+
nativeThreadId: sessionId,
|
|
1603
|
+
get providerPid() {
|
|
1604
|
+
return state.closing || state.dead !== undefined || linked.signal.aborted ? undefined : state.livePid;
|
|
1605
|
+
},
|
|
1606
|
+
approvalEnforcement: "agent-initiated",
|
|
1607
|
+
get configOptions() {
|
|
1608
|
+
return state.configOptions;
|
|
1609
|
+
},
|
|
1610
|
+
get title() {
|
|
1611
|
+
return state.title;
|
|
1612
|
+
},
|
|
1613
|
+
get commands() {
|
|
1614
|
+
return state.commands;
|
|
1615
|
+
},
|
|
1616
|
+
async setConfigOption(configId, value) {
|
|
1617
|
+
ensureAlive();
|
|
1618
|
+
state.configOptions = await setAcpConfigOption(peer, sessionId, state.configOptions, configId, value, linked.signal);
|
|
1619
|
+
return state.configOptions;
|
|
1620
|
+
},
|
|
1621
|
+
async respond(interactionId, reply) {
|
|
1622
|
+
ensureAlive();
|
|
1623
|
+
answerAcpSessionRequest({ turn: state.current, externalPending, interactionId, reply });
|
|
1624
|
+
},
|
|
1625
|
+
...turnControls,
|
|
1626
|
+
close
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1469
1629
|
async function openAcpSession(config, input) {
|
|
1470
1630
|
assertAcpDriverOptions(config);
|
|
1471
1631
|
const mcpServers = (config.mcpServers ?? []).map((server) => AcpMcpServerSchema.parse(server));
|
|
1472
1632
|
const linked = sessionAbort(input.signal);
|
|
1473
1633
|
const externalPending = new Map;
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1634
|
+
const state = {
|
|
1635
|
+
current: undefined,
|
|
1636
|
+
opened: false,
|
|
1637
|
+
closing: false,
|
|
1638
|
+
dead: undefined,
|
|
1639
|
+
livePid: undefined,
|
|
1640
|
+
pidNotified: false,
|
|
1641
|
+
configOptions: [],
|
|
1642
|
+
sawConfigOptionUpdate: false,
|
|
1643
|
+
title: undefined,
|
|
1644
|
+
commands: []
|
|
1645
|
+
};
|
|
1484
1646
|
let connected;
|
|
1647
|
+
const ensureAlive = () => {
|
|
1648
|
+
if (state.closing)
|
|
1649
|
+
throw new Error("The ACP session is closing");
|
|
1650
|
+
if (state.dead !== undefined)
|
|
1651
|
+
throw state.dead;
|
|
1652
|
+
if (linked.signal.aborted)
|
|
1653
|
+
throw abortReason(linked.signal);
|
|
1654
|
+
};
|
|
1485
1655
|
const recordPid = (pid) => {
|
|
1486
|
-
if (pid === undefined || closing || dead !== undefined)
|
|
1656
|
+
if (pid === undefined || state.closing || state.dead !== undefined || linked.signal.aborted) {
|
|
1487
1657
|
return;
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1658
|
+
}
|
|
1659
|
+
state.livePid = pid;
|
|
1660
|
+
if (!state.pidNotified && config.onProviderPid !== undefined) {
|
|
1661
|
+
state.pidNotified = true;
|
|
1491
1662
|
invokeSafely(() => config.onProviderPid?.(pid));
|
|
1492
1663
|
}
|
|
1493
1664
|
};
|
|
@@ -1495,17 +1666,18 @@ async function openAcpSession(config, input) {
|
|
|
1495
1666
|
connected = await connectAcp(config, input.profile, input.cwd, linked.signal, {
|
|
1496
1667
|
...createAcpHandlers({
|
|
1497
1668
|
externalPending,
|
|
1498
|
-
|
|
1499
|
-
|
|
1669
|
+
ensureAlive,
|
|
1670
|
+
isOpened: () => state.opened,
|
|
1671
|
+
getTurn: () => state.current,
|
|
1500
1672
|
onSessionMeta(meta) {
|
|
1501
1673
|
if (meta.configOptions !== undefined) {
|
|
1502
|
-
configOptions = meta.configOptions;
|
|
1503
|
-
sawConfigOptionUpdate = true;
|
|
1674
|
+
state.configOptions = meta.configOptions;
|
|
1675
|
+
state.sawConfigOptionUpdate = true;
|
|
1504
1676
|
}
|
|
1505
1677
|
if (meta.title !== undefined)
|
|
1506
|
-
title = meta.title;
|
|
1678
|
+
state.title = meta.title;
|
|
1507
1679
|
if (meta.commands !== undefined)
|
|
1508
|
-
commands = meta.commands;
|
|
1680
|
+
state.commands = meta.commands;
|
|
1509
1681
|
},
|
|
1510
1682
|
...config.transformUpdate !== undefined && {
|
|
1511
1683
|
transformUpdate: config.transformUpdate
|
|
@@ -1518,15 +1690,15 @@ async function openAcpSession(config, input) {
|
|
|
1518
1690
|
permissionRequestDelivery: config.permissionRequestDelivery
|
|
1519
1691
|
},
|
|
1520
1692
|
onEnd(error) {
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1693
|
+
const abortedByCaller = input.signal?.aborted === true;
|
|
1694
|
+
const shouldNotify = state.opened && !state.closing && !abortedByCaller;
|
|
1695
|
+
if (!state.closing && !abortedByCaller)
|
|
1696
|
+
state.dead = error;
|
|
1697
|
+
state.livePid = undefined;
|
|
1698
|
+
const turn = state.current;
|
|
1699
|
+
state.current = undefined;
|
|
1526
1700
|
externalPending.clear();
|
|
1527
|
-
|
|
1528
|
-
turn.settled = true;
|
|
1529
|
-
loseEngineTurn(turn, () => ACP_CANCELLED, error);
|
|
1701
|
+
settleAcpTurn(turn, abortedByCaller ? abortReason(linked.signal) : error, !abortedByCaller);
|
|
1530
1702
|
linked.abort();
|
|
1531
1703
|
if (shouldNotify)
|
|
1532
1704
|
invokeSafely(() => config.onDisconnect?.(error));
|
|
@@ -1535,7 +1707,7 @@ async function openAcpSession(config, input) {
|
|
|
1535
1707
|
onProviderPid: recordPid,
|
|
1536
1708
|
...input.onStartupPhase !== undefined && { onStartupPhase: input.onStartupPhase }
|
|
1537
1709
|
});
|
|
1538
|
-
if (livePid === undefined && !closing && dead === undefined) {
|
|
1710
|
+
if (state.livePid === undefined && !state.closing && state.dead === undefined && !linked.signal.aborted) {
|
|
1539
1711
|
recordPid(await connected.engine.pidReady ?? connected.engine.pid);
|
|
1540
1712
|
}
|
|
1541
1713
|
} catch (error) {
|
|
@@ -1543,16 +1715,14 @@ async function openAcpSession(config, input) {
|
|
|
1543
1715
|
throw error;
|
|
1544
1716
|
}
|
|
1545
1717
|
const { peer, initialized } = connected;
|
|
1546
|
-
const ensureAlive = () => {
|
|
1547
|
-
if (closing)
|
|
1548
|
-
throw new Error("The ACP session is closing");
|
|
1549
|
-
if (dead !== undefined)
|
|
1550
|
-
throw dead;
|
|
1551
|
-
};
|
|
1552
1718
|
const stop = async (primary) => {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1719
|
+
const terminated = state.dead !== undefined || linked.signal.aborted;
|
|
1720
|
+
state.closing = true;
|
|
1721
|
+
state.livePid = undefined;
|
|
1722
|
+
if (terminated)
|
|
1723
|
+
externalPending.clear();
|
|
1724
|
+
else
|
|
1725
|
+
drainExternalAcpPending(externalPending);
|
|
1556
1726
|
linked.abort();
|
|
1557
1727
|
try {
|
|
1558
1728
|
await stopConnection(connected, primary);
|
|
@@ -1567,74 +1737,34 @@ async function openAcpSession(config, input) {
|
|
|
1567
1737
|
cwd: input.cwd,
|
|
1568
1738
|
nativeThreadId: input.nativeThreadId,
|
|
1569
1739
|
mcpServers,
|
|
1570
|
-
meta
|
|
1740
|
+
meta,
|
|
1741
|
+
signal: linked.signal
|
|
1571
1742
|
});
|
|
1572
1743
|
const sessionId = openedSession.sessionId;
|
|
1573
|
-
configOptions =
|
|
1744
|
+
state.configOptions = mergeInitialAcpConfigOptions(state.configOptions, openedSession.configOptions, state.sawConfigOptionUpdate);
|
|
1574
1745
|
const desiredModel = input.model ?? config.model;
|
|
1575
1746
|
const desiredThoughtLevel = input.thoughtLevel ?? config.thoughtLevel;
|
|
1576
1747
|
const desiredMode = input.mode ?? config.mode;
|
|
1577
|
-
configOptions = await
|
|
1748
|
+
state.configOptions = await applyAcpSessionSelections({
|
|
1578
1749
|
peer,
|
|
1579
1750
|
sessionId,
|
|
1580
|
-
configOptions,
|
|
1751
|
+
configOptions: state.configOptions,
|
|
1581
1752
|
models: openedSession.models,
|
|
1753
|
+
signal: linked.signal,
|
|
1582
1754
|
...desiredModel !== undefined && { model: desiredModel },
|
|
1583
1755
|
...desiredThoughtLevel !== undefined && { thoughtLevel: desiredThoughtLevel },
|
|
1584
1756
|
...desiredMode !== undefined && { mode: desiredMode }
|
|
1585
1757
|
});
|
|
1586
|
-
|
|
1587
|
-
images: initialized.agentCapabilities?.promptCapabilities?.image === true,
|
|
1588
|
-
maxImageBytes: config.maxImageBytes ?? DEFAULT_MAX_IMAGE_BYTES,
|
|
1589
|
-
...config.resolveFile && { resolveFile: config.resolveFile }
|
|
1590
|
-
};
|
|
1591
|
-
const turnControls = createAcpTurnControls({
|
|
1758
|
+
return buildAcpSession({
|
|
1592
1759
|
config,
|
|
1593
|
-
|
|
1760
|
+
connected,
|
|
1594
1761
|
sessionId,
|
|
1595
|
-
|
|
1762
|
+
linked,
|
|
1763
|
+
externalPending,
|
|
1764
|
+
state,
|
|
1596
1765
|
ensureAlive,
|
|
1597
|
-
|
|
1598
|
-
setTurn: (turn) => {
|
|
1599
|
-
current = turn;
|
|
1600
|
-
}
|
|
1766
|
+
stop
|
|
1601
1767
|
});
|
|
1602
|
-
opened = true;
|
|
1603
|
-
return {
|
|
1604
|
-
nativeThreadId: sessionId,
|
|
1605
|
-
get providerPid() {
|
|
1606
|
-
return closing || dead !== undefined ? undefined : livePid;
|
|
1607
|
-
},
|
|
1608
|
-
approvalEnforcement: "agent-initiated",
|
|
1609
|
-
get configOptions() {
|
|
1610
|
-
return configOptions;
|
|
1611
|
-
},
|
|
1612
|
-
get title() {
|
|
1613
|
-
return title;
|
|
1614
|
-
},
|
|
1615
|
-
get commands() {
|
|
1616
|
-
return commands;
|
|
1617
|
-
},
|
|
1618
|
-
async setConfigOption(configId, value) {
|
|
1619
|
-
ensureAlive();
|
|
1620
|
-
configOptions = await setOption(peer, sessionId, configOptions, configId, value);
|
|
1621
|
-
return configOptions;
|
|
1622
|
-
},
|
|
1623
|
-
async respond(interactionId, reply) {
|
|
1624
|
-
ensureAlive();
|
|
1625
|
-
answerAcpSessionRequest({ turn: current, externalPending, interactionId, reply });
|
|
1626
|
-
},
|
|
1627
|
-
...turnControls,
|
|
1628
|
-
async close() {
|
|
1629
|
-
closing = true;
|
|
1630
|
-
drainExternalPending(externalPending);
|
|
1631
|
-
if (acpCan(connected, "close"))
|
|
1632
|
-
await peer.request("session/close", { sessionId }, { timeoutMs: closeRequestTimeoutMs(config) }).catch(() => {
|
|
1633
|
-
return;
|
|
1634
|
-
});
|
|
1635
|
-
await stop();
|
|
1636
|
-
}
|
|
1637
|
-
};
|
|
1638
1768
|
} catch (error) {
|
|
1639
1769
|
await stop({ error });
|
|
1640
1770
|
throw error;
|
package/package.json
CHANGED