@automatalabs/acp-agents 0.35.2 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -0
- package/dist/acp-client.d.ts +219 -0
- package/dist/acp-client.d.ts.map +1 -1
- package/dist/acp-client.js +320 -1
- package/dist/backends/opencode.d.ts.map +1 -1
- package/dist/backends/opencode.js +42 -15
- package/dist/capabilities.d.ts +6 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +15 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/interactive.d.ts +333 -1
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +662 -5
- package/dist/protocol-coverage.d.ts +14 -4
- package/dist/protocol-coverage.d.ts.map +1 -1
- package/dist/protocol-coverage.js +30 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +12 -1
- package/package.json +3 -3
package/dist/interactive.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AgentNotificationMethod, AgentNotificationParamsByMethod, AgentRequestMethod, AgentRequestParamsByMethod, AgentRequestResponsesByMethod, ContentBlock, SendRequestOptions, SessionModeState, StopReason } from "@agentclientprotocol/sdk";
|
|
2
2
|
import type { AgentHistoryEntry, AgentSessionRef, McpServerConfig, PromptImage } from "@automatalabs/shared-types";
|
|
3
3
|
import type { RunOptions } from "@automatalabs/shared-types";
|
|
4
|
+
import { WorkflowError } from "@automatalabs/shared-types";
|
|
5
|
+
import type { TSchema } from "typebox";
|
|
4
6
|
import type { Backend, BackendId } from "./backend.js";
|
|
5
7
|
import type { NegotiatedCapabilities } from "./capabilities.js";
|
|
6
8
|
import { type PooledConnection, type SessionHandle, type SteeringOutcome } from "./acp-client.js";
|
|
@@ -14,6 +16,17 @@ import type { ElicitationResolver, PermissionResolver } from "./permissions.js";
|
|
|
14
16
|
export interface InteractiveSessionOptions {
|
|
15
17
|
/** Model spec: registered first segment routes once; any remaining id is sent verbatim. */
|
|
16
18
|
model?: string;
|
|
19
|
+
/** Structured-output contract for this session's turns (same dialect `run()` accepts).
|
|
20
|
+
* Folded into the backend's native schema channels exactly like `run()`: session/new
|
|
21
|
+
* `_meta` for backends that carry the schema there (Claude), per-turn `_meta` for
|
|
22
|
+
* backends that forward it on the turn (Codex, custom), and — for backends whose agent
|
|
23
|
+
* may ignore the `_meta` forward entirely (`embedSchemaInPrompt`) — into the prompt
|
|
24
|
+
* text itself. The schema does not change the interactive contract otherwise: the host
|
|
25
|
+
* drives the repair ladder itself (e.g. `resolveStructuredOutput` over the session) and
|
|
26
|
+
* reads the result through `currentTurnText()`/`finalMessageText()`/`rawStructuredOutput()`.
|
|
27
|
+
* The client-hosted StructuredOutput capture tool is never injected on the interactive
|
|
28
|
+
* path (it is a per-call run() device). */
|
|
29
|
+
schema?: TSchema;
|
|
17
30
|
/** Agent-advertised session mode id. Strict: openSession fails rather than running unconfined. */
|
|
18
31
|
mode?: string;
|
|
19
32
|
/** Agent-advertised ACP session config options, applied verbatim in sorted option-id order. */
|
|
@@ -74,6 +87,8 @@ interface InteractiveSessionDeps {
|
|
|
74
87
|
readonly label?: string;
|
|
75
88
|
readonly cwd: string;
|
|
76
89
|
readonly keepSession: boolean;
|
|
90
|
+
/** The session's structured-output contract (see `InteractiveSessionOptions.schema`). */
|
|
91
|
+
readonly schema: TSchema | undefined;
|
|
77
92
|
}
|
|
78
93
|
/** A held-open multi-turn ACP session backed by a dedicated agent process. Only one prompt may
|
|
79
94
|
* be in flight at a time; hosts that want queued turns should serialize calls themselves so
|
|
@@ -94,8 +109,12 @@ export declare class InteractiveSession {
|
|
|
94
109
|
private readonly signal;
|
|
95
110
|
private readonly label;
|
|
96
111
|
private readonly subscriptions;
|
|
112
|
+
/** The re-attach arm's release watchers (see `waitForRelease`). */
|
|
113
|
+
private readonly releaseWatchers;
|
|
97
114
|
private readonly cwd;
|
|
98
115
|
private readonly keepSession;
|
|
116
|
+
/** The session's structured-output contract (see `InteractiveSessionOptions.schema`). */
|
|
117
|
+
private readonly schema;
|
|
99
118
|
private removeAbort;
|
|
100
119
|
private promptInFlight;
|
|
101
120
|
private releasePromise;
|
|
@@ -109,15 +128,54 @@ export declare class InteractiveSession {
|
|
|
109
128
|
get modes(): SessionModeState | null | undefined;
|
|
110
129
|
/** Assistant text accumulated in this session's retained log. */
|
|
111
130
|
get text(): string;
|
|
131
|
+
/** The latest turn's assistant text (turn-segmented, like `run()`'s
|
|
132
|
+
* no-schema result path). Added for the REPL broker's result shaping;
|
|
133
|
+
* additive passthrough to `SessionHandle`. */
|
|
134
|
+
currentTurnText(): string;
|
|
135
|
+
/** The latest turn's FINAL assistant message (the schema-extraction
|
|
136
|
+
* source `run()` uses; prose extraction over the whole turn would
|
|
137
|
+
* resurrect the first-JSON-wins bug for schema-shaped progress
|
|
138
|
+
* messages). Added for the REPL broker's structured-output ladder;
|
|
139
|
+
* additive passthrough to `SessionHandle`. */
|
|
140
|
+
finalMessageText(): string;
|
|
141
|
+
/** This session's structured-output contract (set at open via
|
|
142
|
+
* `InteractiveSessionOptions.schema`), or undefined for plain sessions. */
|
|
143
|
+
get outputSchema(): TSchema | undefined;
|
|
144
|
+
/** Claude's raw `structured_output` for the latest turn, if any (the
|
|
145
|
+
* native structured channel the runner's ladder tries first). Added
|
|
146
|
+
* for the REPL broker's structured-output ladder; additive passthrough
|
|
147
|
+
* to `SessionHandle`. */
|
|
148
|
+
rawStructuredOutput(): unknown;
|
|
112
149
|
/** Message/tool history accumulated in this session's retained log. */
|
|
113
150
|
get history(): readonly AgentHistoryEntry[];
|
|
114
151
|
/** Send one prompt turn. A concurrent prompt on the same InteractiveSession is rejected with a
|
|
115
152
|
* clear host-side error; queueing is deliberately left to the host so turn boundaries remain
|
|
116
153
|
* explicit. Per-turn images are appended only to this prompt, and SessionHandle.prompt()
|
|
117
|
-
* performs capability adaptation before sending.
|
|
154
|
+
* performs capability adaptation before sending.
|
|
155
|
+
*
|
|
156
|
+
* The `onHandoff` option is the host's explicit handoff acknowledgment: it fires exactly
|
|
157
|
+
* once the prompt has passed every preflight check (released session, aborted signal,
|
|
158
|
+
* prompt-in-flight, image validation) AND the underlying ACP session/prompt request has
|
|
159
|
+
* actually been invoked — the call below runs synchronously through request construction
|
|
160
|
+
* and the wire send, so by the time the acknowledgment fires the payload is on the wire:
|
|
161
|
+
* the point of no return. A host that records a "delivered" marker for the prompt (the
|
|
162
|
+
* REPL broker's queued-steer delivery marker) MUST record it here rather than when the
|
|
163
|
+
* returned promise is created: an async pre-handoff rejection (released session, aborted
|
|
164
|
+
* signal, or prompt-in-flight) never reaches this line, and a marker recorded before it
|
|
165
|
+
* would make a restore skip a turn that was never delivered. The acknowledgment firing
|
|
166
|
+
* AFTER the invocation is the crash-boundary contract (review regression: it used to
|
|
167
|
+
* fire BEFORE, so a crash in that interval left a durable "delivered" marker on a prompt
|
|
168
|
+
* the backend never received — and a restore then skipped a never-delivered turn): a
|
|
169
|
+
* crash before the acknowledgment leaves the prompt undelivered-in-the-store and a
|
|
170
|
+
* restore re-issues it (at-least-once); a crash after it would replay a turn that is
|
|
171
|
+
* already on the wire, which the marker's host prevents. A throwing callback aborts the
|
|
172
|
+
* turn — its error propagates through the normal mapping — but the backend prompt is
|
|
173
|
+
* ALREADY invoked at that point, so the turn is the host's delivery-failure path, never
|
|
174
|
+
* a not-sent turn. */
|
|
118
175
|
prompt(content: string | ContentBlock[], opts?: {
|
|
119
176
|
images?: readonly PromptImage[];
|
|
120
177
|
promptMeta?: Record<string, unknown>;
|
|
178
|
+
onHandoff?: () => void;
|
|
121
179
|
}): Promise<InteractiveTurn>;
|
|
122
180
|
/** Inject a follow-up into the prompt currently in flight. Idle callers must use prompt():
|
|
123
181
|
* steering has no client-owned turn, output, usage, or retry path. Concurrent steer calls are
|
|
@@ -141,13 +199,246 @@ export declare class InteractiveSession {
|
|
|
141
199
|
/** Best-effort ACP session/cancel for the active turn. Pending permission/elicitation
|
|
142
200
|
* resolvers are settled as cancelled by the SessionHandle/PooledConnection cancel path. */
|
|
143
201
|
cancel(): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* The loaded session's founding-turn completion — the re-attach arm's task
|
|
204
|
+
* source (phase D of the REPL orchestrator roadmap; the broker drives this
|
|
205
|
+
* on a session re-opened with `runner.loadSession()` after a daemon
|
|
206
|
+
* restart). Resolves with the turn that was in flight at the backend when
|
|
207
|
+
* the session was loaded, so a re-attached call's continuation fires
|
|
208
|
+
* exactly once, through the same record → settle → consume pump as a live
|
|
209
|
+
* call.
|
|
210
|
+
*
|
|
211
|
+
* **The authoritative-completion seam** (the spec-owed decision,
|
|
212
|
+
* documented here). Completion evidence comes from TWO channels, by
|
|
213
|
+
* backend class:
|
|
214
|
+
*
|
|
215
|
+
* 1. **The `_session/loaded_turn` vendor extension** (the steering-
|
|
216
|
+
* extension precedent; advertised at initialize
|
|
217
|
+
* (`_meta.loadedTurn.supported === true`), served by the in-repo
|
|
218
|
+
* `@automatalabs/pi-acp` and `@automatalabs/codex-acp`):
|
|
219
|
+
* `session/load` obliges the agent to replay the entire persisted
|
|
220
|
+
* conversation before resolving (the runner marks the LOAD BOUNDARY
|
|
221
|
+
* synchronously after the response), and the seam then asks the
|
|
222
|
+
* backend `_session/loaded_turn/query` whether the founding turn is
|
|
223
|
+
* still running RIGHT NOW. The backend answers with one of three
|
|
224
|
+
* terminal classifications:
|
|
225
|
+
*
|
|
226
|
+
* - **`running`** — the founding turn is still executing at the
|
|
227
|
+
* backend. The seam KEEPS THE LOADED SESSION ATTACHED and waits
|
|
228
|
+
* for the `_session/loaded_turn/ended` notification — the turn's
|
|
229
|
+
* authoritative terminal marker (a quiet gap is only a
|
|
230
|
+
* progress-stream gap, never terminal evidence; the notification
|
|
231
|
+
* fires when the turn ends, carrying the stop reason or the
|
|
232
|
+
* error). It absorbs the turn's live `session/update` stream
|
|
233
|
+
* meanwhile, so a completion settles with the turn's REAL
|
|
234
|
+
* accumulated text. The wait is bounded by
|
|
235
|
+
* `LOADED_TURN_MAX_WAIT_MS` (default 15 min;
|
|
236
|
+
* `AGENTPRISM_ACP_LOADED_TURN_MAX_WAIT_MS` — the "never hang
|
|
237
|
+
* unobserved" backstop); a bound expiry rejects with the
|
|
238
|
+
* `LoadedTurnStillRunningError` (the broker re-arms the wait on
|
|
239
|
+
* the still-attached session — the notification may still arrive
|
|
240
|
+
* later).
|
|
241
|
+
* - **`completed`** — no turn is running, and the founding turn
|
|
242
|
+
* observably completed while this host was down: the replay's
|
|
243
|
+
* trailing assistant message is its FINAL message, so the seam
|
|
244
|
+
* resolves with it IMMEDIATELY (`{ stopReason: "end_turn", text }`
|
|
245
|
+
* — the stop reason is synthesized because the protocol's replay
|
|
246
|
+
* carries none; the text is the turn's real accumulated outcome,
|
|
247
|
+
* and the broker's result-shaping ladder reads the same
|
|
248
|
+
* transcript). A backend that answers `completed` while the
|
|
249
|
+
* replay does NOT end with an assistant message contradicts
|
|
250
|
+
* itself — the final message is not in the replay, so the seam
|
|
251
|
+
* rejects with the safe-re-issue class.
|
|
252
|
+
* - **`interrupted`** — no turn is running, and the founding turn
|
|
253
|
+
* ended without a terminal assistant message (it was
|
|
254
|
+
* interrupted/failed/abandoned while the host was down). Its
|
|
255
|
+
* outcome is not observable, but nothing is running at the
|
|
256
|
+
* backend, so the seam rejects with the SAFE-RE-ISSUE class (the
|
|
257
|
+
* broker re-issues under the same call id — no duplication
|
|
258
|
+
* possible).
|
|
259
|
+
*
|
|
260
|
+
* A QUERY FAILURE (the capability gate or a wire error) is NOT the
|
|
261
|
+
* missing extension: the seam falls THROUGH to the observation path
|
|
262
|
+
* below instead of classifying unobservable (phase-F review round
|
|
263
|
+
* 2 — the loaded session may still be executing, and a
|
|
264
|
+
* possibly-running call is never released-and-re-issued).
|
|
265
|
+
*
|
|
266
|
+
* 2. **The observation path — backends WITHOUT the extension (the
|
|
267
|
+
* built-in claude and opencode backends today), and extension
|
|
268
|
+
* backends whose query failed.** The authoritative observation is
|
|
269
|
+
* the loaded session's OWN stream plus its replay, under the
|
|
270
|
+
* CONNECTION-DEATH CONTRACT (live-verified against the current
|
|
271
|
+
* built-in servers): every built-in ACP server terminates its
|
|
272
|
+
* sessions' in-flight turns when the client connection closes —
|
|
273
|
+
* claude-agent-acp and pi-acp exit on connection close and cancel
|
|
274
|
+
* their turns (`connection.closed.then(shutdown)` → teardown →
|
|
275
|
+
* cancel + kill), `opencode acp` exits on stdin EOF, and codex-acp
|
|
276
|
+
* ends/kills the codex process — and their persisted transcripts
|
|
277
|
+
* contain only COMPLETED messages. So after a daemon crash the
|
|
278
|
+
* founding turn is NEVER still running at the backend, and the
|
|
279
|
+
* replay's trailing content is authoritative: an assistant message
|
|
280
|
+
* is the turn's terminal message (completed while down); anything
|
|
281
|
+
* else means the turn died mid-way (interrupted — nothing running,
|
|
282
|
+
* safe to re-issue). The one caveat is the in-flight-wire race —
|
|
283
|
+
* content still streaming when the load response resolves — so the
|
|
284
|
+
* seam first runs a bounded POST-LOAD CONTINUATION WATCH
|
|
285
|
+
* (`LOADED_TURN_OBSERVE_MS`, default 1 s;
|
|
286
|
+
* `AGENTPRISM_ACP_LOADED_TURN_OBSERVE_MS`): any CONTENT update
|
|
287
|
+
* applied after the load boundary is LIVE CONTINUATION — the
|
|
288
|
+
* authoritative still-running signal — and flips the classification
|
|
289
|
+
* to the keep-attached wait (below). No content within the window
|
|
290
|
+
* → classify from the replay (completed / interrupted) — but ONLY
|
|
291
|
+
* on a VERIFIED BUILT-IN backend (`connectionDeathVerified`: the
|
|
292
|
+
* four built-in instances; a custom registry entry's
|
|
293
|
+
* connection-death behavior is not live-verified, so its quiet
|
|
294
|
+
* window is NOT terminal evidence — phase-F review round 3: the
|
|
295
|
+
* replay classification used to apply to every extension-less
|
|
296
|
+
* backend and every query failure, so a durable custom backend
|
|
297
|
+
* could have a still-running turn settled from stale/partial
|
|
298
|
+
* replay or re-issued, violating the no-duplicate invariant). The
|
|
299
|
+
* window
|
|
300
|
+
* is the spec-owed concrete decision replacing the rejected
|
|
301
|
+
* quiet-grace heuristic: the grace is bounded AND the classification
|
|
302
|
+
* rests on the connection-death contract, never on a quiet gap
|
|
303
|
+
* alone (phase-D review round 3 rejected the unbounded settle-from-
|
|
304
|
+
* trailing-chunk guess; a still-running turn's quiet parks are
|
|
305
|
+
* never settled here — a park produces no content, but for the
|
|
306
|
+
* built-ins no turn can be running at restore in the first place).
|
|
307
|
+
*
|
|
308
|
+
* **The keep-attached still-running wait** (both channels): the
|
|
309
|
+
* loaded session stays attached, the turn's live stream is absorbed,
|
|
310
|
+
* and the seam waits for the terminal state — the `_session/loaded_turn/ended`
|
|
311
|
+
* notification when the backend pushes one (an extension backend, or
|
|
312
|
+
* a seam-less backend that sends it anyway), the max-wait bound (the
|
|
313
|
+
* "never hang unobserved" backstop), or the session's release. A
|
|
314
|
+
* bound expiry rejects with the `LoadedTurnStillRunningError`, and
|
|
315
|
+
* the broker RE-ARMS the wait on the still-attached session (phase-F
|
|
316
|
+
* review round 2: a possibly-running call is never re-issued — the
|
|
317
|
+
* re-issue arm is reserved for observably-dead calls); a cancel or
|
|
318
|
+
* the broker's drain settles it.
|
|
319
|
+
*
|
|
320
|
+
* The unconditional arms stay: a handle that was never load-marked
|
|
321
|
+
* (not produced by the runner's `loadSession` path), and a transcript
|
|
322
|
+
* with no user message at all (the recorded session never received its
|
|
323
|
+
* prompt — nothing reached the backend), both reject immediately with
|
|
324
|
+
* the safe-re-issue class. A released/dead session mid-wait rejects
|
|
325
|
+
* through the same plain class (a dead process means the backend turn
|
|
326
|
+
* died with it — re-issue is safe; the broker's own teardown releases
|
|
327
|
+
* are handled by the broker's drain state).
|
|
328
|
+
*/
|
|
329
|
+
awaitCurrentTurn(): Promise<InteractiveTurn>;
|
|
330
|
+
/**
|
|
331
|
+
* The observation path — backends WITHOUT the `_session/loaded_turn`
|
|
332
|
+
* extension (the built-in claude and opencode backends today), and
|
|
333
|
+
* extension backends whose query failed (see `awaitCurrentTurn`'s
|
|
334
|
+
* doc for the full semantics — the connection-death contract, the
|
|
335
|
+
* post-load continuation watch, and the replay probe). Never settles
|
|
336
|
+
* a quiet gap, never re-issues a possibly-running turn: the
|
|
337
|
+
* classification is authoritative ONLY for the VERIFIED BUILT-INS
|
|
338
|
+
* (`connectionDeathVerified`) because their ACP servers terminate
|
|
339
|
+
* in-flight turns when the client connection closes (live-verified),
|
|
340
|
+
* and their replay holds only completed messages. A CUSTOM backend
|
|
341
|
+
* (a registered registry entry — its connection-death behavior is
|
|
342
|
+
* NOT live-verified) that stays quiet through the window is NOT
|
|
343
|
+
* classified from the replay: its turn may still be running at the
|
|
344
|
+
* backend, so the seam keeps the loaded session attached and waits
|
|
345
|
+
* for the authoritative terminal state instead (phase-F review round
|
|
346
|
+
* 3: the quiet-window-plus-replay classification used to apply to
|
|
347
|
+
* every extension-less backend and every query failure, so a durable
|
|
348
|
+
* custom backend could have a still-running turn settled from stale
|
|
349
|
+
* replay or re-issued — the no-duplicate invariant requires the
|
|
350
|
+
* verified assumption to be restricted to the verified backends).
|
|
351
|
+
*/
|
|
352
|
+
private observeLoadedTurn;
|
|
353
|
+
/** Is this session's backend one of the four built-ins whose ACP
|
|
354
|
+
* servers' connection-death behavior is LIVE-VERIFIED (claude,
|
|
355
|
+
* codex, opencode, pi — every built-in server terminates its
|
|
356
|
+
* sessions' in-flight turns when the client connection closes, so a
|
|
357
|
+
* restored session's replay holds only completed messages)? The
|
|
358
|
+
* observation path's quiet-window-plus-replay classification is
|
|
359
|
+
* authoritative ONLY for these; a CUSTOM backend (a registered
|
|
360
|
+
* registry entry — even one that shadows a built-in name) can keep a
|
|
361
|
+
* turn running while quiet, so its quiet window degrades to the
|
|
362
|
+
* keep-attached still-running wait (phase-F review round 3: the
|
|
363
|
+
* verified assumption must be restricted to the verified built-ins).
|
|
364
|
+
* Instance-based: a custom backend registered under a built-in name
|
|
365
|
+
* is a `CustomAcpBackend` and is never counted as verified. */
|
|
366
|
+
private get connectionDeathVerified();
|
|
367
|
+
/** The post-load continuation watch: resolve true on the first CONTENT
|
|
368
|
+
* update applied after the load boundary (live-continuation evidence —
|
|
369
|
+
* the authoritative still-running signal), false when the observation
|
|
370
|
+
* window elapses without one (or the session is released — the caller
|
|
371
|
+
* re-checks `releasePromise` before classifying). Bookkeeping updates
|
|
372
|
+
* (usage, mode, available commands — claude emits an
|
|
373
|
+
* `available_commands_update` right after every load) never count:
|
|
374
|
+
* the flag flips only on content updates. */
|
|
375
|
+
private waitForPostLoadContent;
|
|
376
|
+
/**
|
|
377
|
+
* The keep-attached still-running wait (the extension's `running` arm
|
|
378
|
+
* AND the observation path's live-continuation arm): the loaded
|
|
379
|
+
* session stays attached, the turn's live stream is absorbed, and the
|
|
380
|
+
* seam waits for the terminal state — the `_session/loaded_turn/ended`
|
|
381
|
+
* notification when the backend pushes one, the max-wait bound (the
|
|
382
|
+
* "never hang unobserved" backstop), or the session's release —
|
|
383
|
+
* whichever comes first (no polling: a long still-running turn is
|
|
384
|
+
* observed with zero busy work). A bound expiry rejects with the
|
|
385
|
+
* re-armable `LoadedTurnStillRunningError`: the broker re-arms the
|
|
386
|
+
* wait on the still-attached session — a later ended notification — or
|
|
387
|
+
* a cancel — still settles the call (phase-F review round 2: a
|
|
388
|
+
* possibly-running call is never re-issued).
|
|
389
|
+
*/
|
|
390
|
+
private waitForRunningLoadedTurn;
|
|
391
|
+
/** The `_session/loaded_turn/ended` resolution: the turn that was running
|
|
392
|
+
* at load ended. A turn that ended with an ERROR is a definite
|
|
393
|
+
* rejection (never settled as success — `LoadedTurnFailedError`, the
|
|
394
|
+
* settle-as-rejection class the broker records and delivers); a turn
|
|
395
|
+
* that ended with a response resolves with its stop reason (the
|
|
396
|
+
* notification's, restricted to the ACP vocabulary — a server-specific
|
|
397
|
+
* reason the seam does not speak synthesizes `end_turn`, exactly like
|
|
398
|
+
* the completed-while-down arm) and the accumulated text. */
|
|
399
|
+
private loadedTurnEndedResult;
|
|
400
|
+
/** Resolve on the session's next `_session/loaded_turn/ended`
|
|
401
|
+
* notification (the re-attach arm's authoritative terminal wait —
|
|
402
|
+
* zero polling; the subscription is one-shot and removed the moment it
|
|
403
|
+
* fires, and a notification that already arrived fires immediately). */
|
|
404
|
+
private nextLoadedTurnEnded;
|
|
144
405
|
/** Subscribe to runner events for THIS ACP session only. Events from other one-shot or
|
|
145
406
|
* interactive sessions on the same runner are filtered out by sessionId. The returned
|
|
146
407
|
* unsubscribe thunk and every still-live subscription are removed automatically on release. */
|
|
147
408
|
on<K extends AcpEventName>(name: K, listener: AcpEventListener<K>): () => void;
|
|
409
|
+
/** Resolve when the session is released (or immediately when it
|
|
410
|
+
* already is) — the re-attach arm's release watch, so a session that
|
|
411
|
+
* dies or is disposed while the seam waits unblocks the wait instead
|
|
412
|
+
* of parking it until the max-wait expiry. */
|
|
413
|
+
private waitForRelease;
|
|
148
414
|
/** Release the ACP session and close the dedicated process. Idempotent. Session close is
|
|
149
415
|
* best-effort and bounded by SessionHandle; process disposal mirrors pool teardown. */
|
|
150
416
|
release(): Promise<void>;
|
|
417
|
+
/** The loaded session's recorded founding-turn terminal state (the
|
|
418
|
+
* `_session/loaded_turn/ended` notification, when the backend pushed
|
|
419
|
+
* one — a seam-less backend that sends it anyway), or null when the
|
|
420
|
+
* turn has not ended (yet). The broker's non-re-armable settlement
|
|
421
|
+
* wait reads this surface instead of re-invoking a seam that can
|
|
422
|
+
* never observe the terminal state. */
|
|
423
|
+
loadedTurnEndedState(): {
|
|
424
|
+
stopReason?: string;
|
|
425
|
+
error?: {
|
|
426
|
+
name: string;
|
|
427
|
+
message: string;
|
|
428
|
+
};
|
|
429
|
+
} | null;
|
|
430
|
+
/** Watch the loaded-turn-ended channel: the listener fires when the
|
|
431
|
+
* `_session/loaded_turn/ended` notification arrives (and immediately
|
|
432
|
+
* for a notification that already arrived). Returns the unsubscribe
|
|
433
|
+
* thunk. The broker's non-re-armable settlement wait's observability
|
|
434
|
+
* surface (the same channel the seam's own wait subscribes to). */
|
|
435
|
+
subscribeLoadedTurnEnded(listener: () => void): () => void;
|
|
436
|
+
/** Resolve when the session is released (its dedicated process died or
|
|
437
|
+
* was disposed); never resolves on a live session. The broker's
|
|
438
|
+
* non-re-armable settlement wait's release watch — a released
|
|
439
|
+
* session means the backend turn died with the process (the
|
|
440
|
+
* safe-re-issue class). */
|
|
441
|
+
released(): Promise<void>;
|
|
151
442
|
/** The re-attach handle for this session — persist it, then re-open later with
|
|
152
443
|
* `runner.loadSession()`/`resumeSession()` (`backendId` doubles as the `model` routing spec).
|
|
153
444
|
* Reopen flags mirror the connected agent's advertised persistence; an agent that persists
|
|
@@ -156,5 +447,46 @@ export declare class InteractiveSession {
|
|
|
156
447
|
private doRelease;
|
|
157
448
|
private removeSubscriptions;
|
|
158
449
|
}
|
|
450
|
+
/** The re-attach arm's duplicate-risk rejection: the loaded session's
|
|
451
|
+
* founding turn MAY STILL BE RUNNING at the backend and its terminal
|
|
452
|
+
* state is unobservable — a `running`-classified turn produced no
|
|
453
|
+
* terminal notification within the max-wait bound (the observation
|
|
454
|
+
* path's live-continuation arm included). The host must NEVER settle
|
|
455
|
+
* partial output (a quiet gap is only a progress-stream gap) and NEVER
|
|
456
|
+
* re-issue a possibly-running call: the broker KEEPS THE LOADED SESSION
|
|
457
|
+
* ATTACHED and re-arms the seam on it — the doc's second reconciliation
|
|
458
|
+
* arm, re-attach to a still-running task — for every form of this
|
|
459
|
+
* rejection (phase-F review round 2: the old non-re-armable form
|
|
460
|
+
* pushed the broker to release the loaded session and re-issue the
|
|
461
|
+
* call, which could duplicate a still-running backend turn; re-issue
|
|
462
|
+
* is now reserved for the observably-dead classes). A later terminal
|
|
463
|
+
* notification — or a cancel — still settles the call. The marker
|
|
464
|
+
* property is structural, so third-party adapter seams can throw the
|
|
465
|
+
* same class of rejection; `rearmable` is retained for compatibility
|
|
466
|
+
* with those seams (the broker re-arms both forms). */
|
|
467
|
+
export declare class LoadedTurnStillRunningError extends Error {
|
|
468
|
+
readonly rearmable: boolean;
|
|
469
|
+
readonly loadedTurnStillRunning = true;
|
|
470
|
+
constructor(message: string, rearmable: boolean);
|
|
471
|
+
}
|
|
472
|
+
/** The re-attach arm's settle-as-rejection class: the loaded session's
|
|
473
|
+
* founding turn RAN and FAILED at the backend (the `_session/loaded_turn/
|
|
474
|
+
* ended` notification carried its error). A definite outcome — the host
|
|
475
|
+
* records and settles it as a rejection, exactly like a live prompt that
|
|
476
|
+
* rejects; it is never re-issued (the task already ran to a terminal
|
|
477
|
+
* state) and never settled as success (partial text is not an outcome).
|
|
478
|
+
* Marker property is structural, like `LoadedTurnStillRunningError`. */
|
|
479
|
+
export declare class LoadedTurnFailedError extends WorkflowError {
|
|
480
|
+
readonly loadedTurnFailed = true;
|
|
481
|
+
constructor(message: string);
|
|
482
|
+
}
|
|
483
|
+
/** Is this a loaded-turn still-running rejection (the broker's
|
|
484
|
+
* never-settle-a-quiet-gap classification)? Structural marker, so
|
|
485
|
+
* third-party adapter seams can throw the same class. */
|
|
486
|
+
export declare function isLoadedTurnStillRunningError(error: unknown): error is LoadedTurnStillRunningError;
|
|
487
|
+
/** Is this a loaded-turn failed-at-backend rejection (the broker's
|
|
488
|
+
* settle-as-rejection classification)? Structural marker, so third-party
|
|
489
|
+
* adapter seams can throw the same class. */
|
|
490
|
+
export declare function isLoadedTurnFailedError(error: unknown): error is LoadedTurnFailedError;
|
|
159
491
|
export {};
|
|
160
492
|
//# sourceMappingURL=interactive.d.ts.map
|
|
@@ -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,eAAe,EA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