@langchain/langgraph-sdk 1.9.28 → 1.9.30
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/client/stream/types.d.cts +4 -4
- package/dist/client/stream/types.d.ts +4 -4
- package/dist/schema.d.cts +7 -0
- package/dist/schema.d.cts.map +1 -1
- package/dist/schema.d.ts +7 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/stream/controller.cjs +135 -71
- package/dist/stream/controller.cjs.map +1 -1
- package/dist/stream/controller.d.cts +12 -23
- package/dist/stream/controller.d.cts.map +1 -1
- package/dist/stream/controller.d.ts +12 -23
- package/dist/stream/controller.d.ts.map +1 -1
- package/dist/stream/controller.js +135 -71
- package/dist/stream/controller.js.map +1 -1
- package/dist/stream/lifecycle-loading-tracker.cjs +12 -2
- package/dist/stream/lifecycle-loading-tracker.cjs.map +1 -1
- package/dist/stream/lifecycle-loading-tracker.js +12 -2
- package/dist/stream/lifecycle-loading-tracker.js.map +1 -1
- package/dist/stream/message-reconciliation.cjs +80 -4
- package/dist/stream/message-reconciliation.cjs.map +1 -1
- package/dist/stream/message-reconciliation.js +80 -4
- package/dist/stream/message-reconciliation.js.map +1 -1
- package/dist/stream/projections/channel.cjs +4 -6
- package/dist/stream/projections/channel.cjs.map +1 -1
- package/dist/stream/projections/channel.d.cts.map +1 -1
- package/dist/stream/projections/channel.d.ts.map +1 -1
- package/dist/stream/projections/channel.js +4 -6
- package/dist/stream/projections/channel.js.map +1 -1
- package/dist/stream/projections/messages.cjs +1 -1
- package/dist/stream/projections/messages.cjs.map +1 -1
- package/dist/stream/projections/messages.js +2 -2
- package/dist/stream/projections/messages.js.map +1 -1
- package/dist/stream/root-message-projection.cjs +12 -6
- package/dist/stream/root-message-projection.cjs.map +1 -1
- package/dist/stream/root-message-projection.js +13 -7
- package/dist/stream/root-message-projection.js.map +1 -1
- package/dist/stream/submit-coordinator.cjs +6 -5
- package/dist/stream/submit-coordinator.cjs.map +1 -1
- package/dist/stream/submit-coordinator.js +6 -5
- package/dist/stream/submit-coordinator.js.map +1 -1
- package/dist/stream/types.d.cts +3 -3
- package/dist/stream/types.d.ts +3 -3
- package/dist/utils/async_caller.cjs +1 -1
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.d.cts.map +1 -1
- package/dist/utils/async_caller.d.ts.map +1 -1
- package/dist/utils/async_caller.js +1 -1
- package/dist/utils/async_caller.js.map +1 -1
- package/package.json +7 -7
|
@@ -180,10 +180,10 @@ interface ThreadModules {
|
|
|
180
180
|
* Matches the in-process `InterruptPayload` type.
|
|
181
181
|
*
|
|
182
182
|
* {@link ThreadStream.interrupts} collects these entries in arrival order.
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
183
|
+
* The same pending interrupts (including nested namespaces) are also
|
|
184
|
+
* mirrored onto {@link RootSnapshot.interrupts} / framework
|
|
185
|
+
* `stream.interrupts` for UI rendering; `respond()` resolves `namespace`
|
|
186
|
+
* from either list when only `interruptId` is supplied.
|
|
187
187
|
*/
|
|
188
188
|
interface InterruptPayload<TPayload = unknown> {
|
|
189
189
|
interruptId: string;
|
|
@@ -180,10 +180,10 @@ interface ThreadModules {
|
|
|
180
180
|
* Matches the in-process `InterruptPayload` type.
|
|
181
181
|
*
|
|
182
182
|
* {@link ThreadStream.interrupts} collects these entries in arrival order.
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
183
|
+
* The same pending interrupts (including nested namespaces) are also
|
|
184
|
+
* mirrored onto {@link RootSnapshot.interrupts} / framework
|
|
185
|
+
* `stream.interrupts` for UI rendering; `respond()` resolves `namespace`
|
|
186
|
+
* from either list when only `interruptId` is supplied.
|
|
187
187
|
*/
|
|
188
188
|
interface InterruptPayload<TPayload = unknown> {
|
|
189
189
|
interruptId: string;
|
package/dist/schema.d.cts
CHANGED
|
@@ -128,6 +128,13 @@ interface Interrupt<TValue = unknown> {
|
|
|
128
128
|
* The value of the interrupt.
|
|
129
129
|
*/
|
|
130
130
|
value?: TValue;
|
|
131
|
+
/**
|
|
132
|
+
* Protocol namespace tuple for resume targeting (`[]` at root).
|
|
133
|
+
* Populated for nested subgraph / subagent interrupts so
|
|
134
|
+
* `respond({ interruptId })` can resume without a separate
|
|
135
|
+
* `getThread()?.interrupts` lookup.
|
|
136
|
+
*/
|
|
137
|
+
namespace?: string[];
|
|
131
138
|
/**
|
|
132
139
|
* Will be deprecated in the future.
|
|
133
140
|
* @deprecated Will be removed in the future.
|
package/dist/schema.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.cts","names":[],"sources":["../src/schema.ts"],"mappings":";;;KAEK,QAAA,MAAc,CAAA;AAAA,KAEP,SAAA;AAAA,KAQA,YAAA;AAAA,KAEP,iBAAA;AAAA,KAEO,YAAA;AAAA,KAEA,MAAA;EAhBQ;AAEpB;;;EAmBE,IAAA;EAnBmB;AAQrB;;;EAiBE,eAAA;EAjBsB;AAA6C;;EAsBnE,YAAA;IApBoB;;AAEtB;IAsBI,SAAA,GAAY,QAAA;IAtBQ;;;IA2BpB,aAAA,GAAgB,QAAA;IAAA,CAEf,GAAA;EAAA;AAAA;AAAA,UAIY,WAAA;EApBf;;;EAwBA,QAAA;EAVE;;;;EAgBF,YAAA,GAAe,WAAA;EAVA;;;;EAgBf,aAAA,GAAgB,WAAA;EAMD;;;;EAAf,YAAA,GAAe,WAAA;EAlBf;;;;EAwBA,aAAA,GAAgB,WAAA;EANhB;;;;EAYA,cAAA,GAAiB,WAAA;AAAA;AAAA,KAGP,SAAA,GAAY,MAAA,SAAe,WAAA;AAAA,KAE3B,QAAA,GAAW,QAAA;EACrB,MAAA;EAEA,IAAA;EAEA,MAAA,GAAS,MAAA;EAET,OAAA,GAAU,MAAA;EAAA,CAET,GAAA;AAAA;AAAA,UAGc,aAAA;;EAEf,YAAA;EAPU;EAUV,QAAA;EAjB6B;EAoB7B,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AU,QAAA;EA1DqB;EA6D/B,kBAAA,EAAoB,QAAA,CAAS,iBAAA;AAAA;AAAA,KAGnB,UAAA;EACV,SAAA;EACA,aAAA;EACA,aAAA,EAAe,QAAA;EACf,cAAA,EAAgB,QAAA,CAAS,MAAA;AAAA;AAAA,UAGV,qBAAA;EACf,UAAA;AAAA;AAAA,UAEe,IAAA;EACf,SAAA;EACA,GAAA;EAEA,KAAA,EAAO,MAAA;EACP,SAAA;EACA,SAAA;AAAA;AAAA,UAGe,UAAA,SAAmB,IAAA;EAClC,KAAA;AAAA;AAAA,UAEe,mBAAA;EACf,KAAA,EAAO,UAAA;AAAA;AAAA,UAGQ,kBAAA;EACf,OAAA;EACA,YAAA;EACA,SAAA;EACA,OAAA;EACA,OAAA,EAAS,MAAA;EACT,QAAA;EACA,aAAA;EACA,QAAA;EACA,UAAA;EACA,UAAA;EACA,QAAA,EAAU,QAAA;AAAA;AAAA,UAGK,2BAAA,SAAoC,IAAA,CACnD,kBAAA;EAGA,SAAA;AAAA;AAAA,KAGU,eAAA;AAAA,KAOA,YAAA;AAAA,KAOA,UAAA;AAAA,KAQA,SAAA;AAAA,KAKA,oBAAA;AAAA,KAYA,iBAAA;AAAA,KAYA,cAAA;AAAA,KAWA,eAAA"}
|
package/dist/schema.d.ts
CHANGED
|
@@ -128,6 +128,13 @@ interface Interrupt<TValue = unknown> {
|
|
|
128
128
|
* The value of the interrupt.
|
|
129
129
|
*/
|
|
130
130
|
value?: TValue;
|
|
131
|
+
/**
|
|
132
|
+
* Protocol namespace tuple for resume targeting (`[]` at root).
|
|
133
|
+
* Populated for nested subgraph / subagent interrupts so
|
|
134
|
+
* `respond({ interruptId })` can resume without a separate
|
|
135
|
+
* `getThread()?.interrupts` lookup.
|
|
136
|
+
*/
|
|
137
|
+
namespace?: string[];
|
|
131
138
|
/**
|
|
132
139
|
* Will be deprecated in the future.
|
|
133
140
|
* @deprecated Will be removed in the future.
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1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,UAAA;AAAA;AAAA,UAGQ,kBAAA;EACf,OAAA;EACA,YAAA;EACA,SAAA;EACA,OAAA;EACA,OAAA,EAAS,MAAA;EACT,QAAA;EACA,aAAA;EACA,QAAA;EACA,UAAA;EACA,UAAA;EACA,QAAA,EAAU,QAAA;AAAA;AAAA,UAGK,2BAAA,SAAoC,IAAA,CACnD,kBAAA;EAGA,SAAA;AAAA;AAAA,KAGU,eAAA;AAAA,KAOA,YAAA;AAAA,KAOA,UAAA;AAAA,KAQA,SAAA;AAAA,KAKA,oBAAA;AAAA,KAYA,iBAAA;AAAA,KAYA,cAAA;AAAA,KAWA,eAAA"}
|
|
@@ -170,13 +170,31 @@ var StreamController = class {
|
|
|
170
170
|
*/
|
|
171
171
|
#submitGeneration = 0;
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
173
|
+
* Monotonic counter bumped at the start of each `#teardownThread`.
|
|
174
|
+
* The root pump captures the generation when it starts and drops
|
|
175
|
+
* any event whose generation no longer matches — including queued
|
|
176
|
+
* events that `SubscriptionHandle.close()` still drains after the
|
|
177
|
+
* snapshot has already been cleared by `hydrate()`.
|
|
178
|
+
*/
|
|
179
|
+
#rootPumpGeneration = 0;
|
|
180
|
+
/**
|
|
181
|
+
* Thread ids this controller minted client-side on first `submit()`.
|
|
182
|
+
* `hydrate()` skips `threads.getState()` for these — we know there
|
|
183
|
+
* is nothing checkpointed yet. Cleared once dispatch commits the
|
|
184
|
+
* thread server-side.
|
|
177
185
|
*/
|
|
178
186
|
#selfCreatedThreadIds = /* @__PURE__ */ new Set();
|
|
179
187
|
/**
|
|
188
|
+
* Caller-supplied thread ids that 404'd on hydrate. Unlike
|
|
189
|
+
* {@link #selfCreatedThreadIds}, these are revalidated on every
|
|
190
|
+
* hydrate: another client may create the same id between visits.
|
|
191
|
+
* While marked missing, `submit()` still defers the root SSE pump
|
|
192
|
+
* until `run.start` / `commands` commits the row — joining
|
|
193
|
+
* `/stream/events` beforehand leaves a dead subscription on
|
|
194
|
+
* langgraph_api's in-mem runtime.
|
|
195
|
+
*/
|
|
196
|
+
#missingThreadIds = /* @__PURE__ */ new Set();
|
|
197
|
+
/**
|
|
180
198
|
* In-flight per-subagent namespace resolutions, keyed by tool-call
|
|
181
199
|
* id. De-dupes concurrent {@link resolveSubagentNamespace} calls so
|
|
182
200
|
* re-renders / multiple consumers of the same subagent don't issue
|
|
@@ -271,12 +289,14 @@ var StreamController = class {
|
|
|
271
289
|
rememberSelfCreatedThreadId: (threadId) => {
|
|
272
290
|
this.#selfCreatedThreadIds.add(threadId);
|
|
273
291
|
},
|
|
292
|
+
isSelfCreatedThreadId: (threadId) => this.#selfCreatedThreadIds.has(threadId) || this.#missingThreadIds.has(threadId),
|
|
274
293
|
hydrate: (threadId) => this.hydrate(threadId),
|
|
275
294
|
ensureThread: (threadId, deferRootPump) => this.#ensureThread(threadId, deferRootPump),
|
|
276
295
|
startDeferredRootPump: () => this.#startDeferredRootPump(),
|
|
277
296
|
abandonDeferredRootPump: () => this.#abandonDeferredRootPump(),
|
|
278
297
|
forgetSelfCreatedThreadId: (threadId) => {
|
|
279
298
|
this.#selfCreatedThreadIds.delete(threadId);
|
|
299
|
+
this.#missingThreadIds.delete(threadId);
|
|
280
300
|
},
|
|
281
301
|
waitForRootPumpReady: () => this.#rootPumpReady,
|
|
282
302
|
awaitNextTerminal: (signal) => this.#awaitNextTerminal(signal),
|
|
@@ -380,13 +400,16 @@ var StreamController = class {
|
|
|
380
400
|
* Suspense boundary remounted against the new id suspends again.
|
|
381
401
|
*/
|
|
382
402
|
this.#resetHydrationPromise();
|
|
383
|
-
await this.#teardownThread();
|
|
384
403
|
/**
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
404
|
+
* Kick teardown so the synchronous abort (unbind, drop onEvent,
|
|
405
|
+
* close the root subscription, reset assemblers) runs before we
|
|
406
|
+
* touch the snapshot. Then reset immediately so the UI does not
|
|
407
|
+
* wait on pump/close. An interrupted thread parks the root pump
|
|
408
|
+
* on `waitForResume()`; awaiting teardown *before* this reset
|
|
409
|
+
* left `threadId` null while `messages` still showed the previous
|
|
410
|
+
* conversation (`useStream` fire-and-forgets `hydrate()`).
|
|
389
411
|
*/
|
|
412
|
+
const teardown = this.#teardownThread();
|
|
390
413
|
this.rootStore.setState(() => ({
|
|
391
414
|
...this.#createInitialSnapshot(),
|
|
392
415
|
threadId: this.#currentThreadId
|
|
@@ -397,6 +420,7 @@ var StreamController = class {
|
|
|
397
420
|
* surprising. Mirrors the legacy `StreamOrchestrator` behaviour.
|
|
398
421
|
*/
|
|
399
422
|
this.queueStore.setState(() => require_submit_coordinator.EMPTY_QUEUE);
|
|
423
|
+
await teardown;
|
|
400
424
|
}
|
|
401
425
|
if (this.#currentThreadId == null) {
|
|
402
426
|
this.rootStore.setState((s) => ({
|
|
@@ -427,12 +451,14 @@ var StreamController = class {
|
|
|
427
451
|
const hydratedThreadId = this.#currentThreadId;
|
|
428
452
|
let hydrationError;
|
|
429
453
|
let threadExists = false;
|
|
454
|
+
let threadMissing = false;
|
|
430
455
|
let threadActive = true;
|
|
431
456
|
try {
|
|
432
457
|
const state = await this.#fetchHydrationState();
|
|
433
458
|
if (this.#disposed || this.#currentThreadId !== hydratedThreadId) return;
|
|
434
459
|
threadExists = state != null;
|
|
435
460
|
threadActive = isThreadStateActive(state);
|
|
461
|
+
this.#missingThreadIds.delete(hydratedThreadId);
|
|
436
462
|
if (state?.values != null) {
|
|
437
463
|
/**
|
|
438
464
|
* `threads.getState()` returns the legacy `ThreadState` shape
|
|
@@ -517,6 +543,8 @@ var StreamController = class {
|
|
|
517
543
|
const activeIds = /* @__PURE__ */ new Set();
|
|
518
544
|
for (const task of state.tasks) {
|
|
519
545
|
if (!Array.isArray(task?.interrupts)) continue;
|
|
546
|
+
const checkpointNs = task?.checkpoint?.checkpoint_ns;
|
|
547
|
+
const namespace = typeof checkpointNs === "string" && checkpointNs.length > 0 ? checkpointNs.split("|").filter((segment) => segment.length > 0) : [...ROOT_NAMESPACE];
|
|
520
548
|
for (const interrupt of task.interrupts) {
|
|
521
549
|
const typed = interrupt;
|
|
522
550
|
const id = typed?.id;
|
|
@@ -524,7 +552,8 @@ var StreamController = class {
|
|
|
524
552
|
activeIds.add(id);
|
|
525
553
|
activeInterrupts.push(require_interrupts.normalizeInterruptForClient({
|
|
526
554
|
id,
|
|
527
|
-
value: typed?.value
|
|
555
|
+
value: typed?.value,
|
|
556
|
+
namespace: Array.isArray(typed?.namespace) ? [...typed.namespace] : namespace
|
|
528
557
|
}));
|
|
529
558
|
}
|
|
530
559
|
}
|
|
@@ -542,7 +571,7 @@ var StreamController = class {
|
|
|
542
571
|
...s,
|
|
543
572
|
error
|
|
544
573
|
}));
|
|
545
|
-
}
|
|
574
|
+
} else threadMissing = true;
|
|
546
575
|
} finally {
|
|
547
576
|
this.rootStore.setState((s) => ({
|
|
548
577
|
...s,
|
|
@@ -552,6 +581,20 @@ var StreamController = class {
|
|
|
552
581
|
else this.#resolveHydration();
|
|
553
582
|
}
|
|
554
583
|
/**
|
|
584
|
+
* Missing threads must not open `/stream/events`. The in-mem
|
|
585
|
+
* runtime accepts the join against a not-yet-created id but the
|
|
586
|
+
* subscription never attaches to the live channel — the first run
|
|
587
|
+
* then delivers 0 bytes until idle reconnect. Park the pump until
|
|
588
|
+
* `submit()`'s `run.start` creates the row (see
|
|
589
|
+
* {@link #startDeferredRootPump}). Tracked in `#missingThreadIds`
|
|
590
|
+
* (not `#selfCreatedThreadIds`) so a later hydrate revalidates —
|
|
591
|
+
* another client may create the same id between visits.
|
|
592
|
+
*/
|
|
593
|
+
if (threadMissing) {
|
|
594
|
+
this.#missingThreadIds.add(hydratedThreadId);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
555
598
|
* Open the shared subscription on mount so in-flight server-side
|
|
556
599
|
* runs are observed even when no local `submit()` is active — BUT
|
|
557
600
|
* only when the thread is actually active (see
|
|
@@ -688,7 +731,7 @@ var StreamController = class {
|
|
|
688
731
|
*/
|
|
689
732
|
async #trySeedProjectionFromHistory(params) {
|
|
690
733
|
const threadId = this.#currentThreadId;
|
|
691
|
-
if (this.#disposed || threadId == null || params.namespace.length === 0 || !this.#rootPumpDeferred || this.#selfCreatedThreadIds.has(threadId)) return false;
|
|
734
|
+
if (this.#disposed || threadId == null || params.namespace.length === 0 || !this.#rootPumpDeferred || this.#selfCreatedThreadIds.has(threadId) || this.#missingThreadIds.has(threadId)) return false;
|
|
692
735
|
if (await this.#skipDefaultSubagentProjection(params.namespace, threadId)) return true;
|
|
693
736
|
if (this.#disposed || this.#currentThreadId !== threadId || !this.#rootPumpDeferred) return false;
|
|
694
737
|
const seed = await this.#getScopedHistorySeed(threadId, params.namespace);
|
|
@@ -896,14 +939,15 @@ var StreamController = class {
|
|
|
896
939
|
* oldest and picks the first entry whose `interruptId` has not already
|
|
897
940
|
* been resolved by a prior `respond()` call. That entry may be at the
|
|
898
941
|
* root (`namespace: []`) or inside a subgraph (non-empty `namespace`).
|
|
899
|
-
*
|
|
900
|
-
* `
|
|
901
|
-
*
|
|
942
|
+
* {@link RootSnapshot.interrupts `rootStore.interrupts`} /
|
|
943
|
+
* framework `stream.interrupts` mirrors the same pending interrupts
|
|
944
|
+
* (including nested namespaces) for UI rendering.
|
|
902
945
|
*
|
|
903
946
|
* Omitting `interruptId` is fine when exactly one interrupt is pending.
|
|
904
947
|
* When several can be active (parallel subagents, fan-out, nested
|
|
905
|
-
* graphs), pass an explicit `interruptId`
|
|
906
|
-
*
|
|
948
|
+
* graphs), pass an explicit `interruptId` so you resume the interrupt
|
|
949
|
+
* the user acted on. `namespace` is resolved automatically from
|
|
950
|
+
* `thread.interrupts` / `stream.interrupts` when omitted.
|
|
907
951
|
*
|
|
908
952
|
* To resume several interrupts pending at the same checkpoint in one
|
|
909
953
|
* command, use {@link respondAll} — sequential single `respond()` calls
|
|
@@ -911,9 +955,8 @@ var StreamController = class {
|
|
|
911
955
|
* others with no interrupted run to respond to.
|
|
912
956
|
*
|
|
913
957
|
* The server validates `namespace` against the pending interrupt. Root
|
|
914
|
-
* interrupts use `namespace: []
|
|
915
|
-
*
|
|
916
|
-
* `getThread()?.interrupts` — see the example below.
|
|
958
|
+
* interrupts use `namespace: []`. Subgraph interrupts carry the exact
|
|
959
|
+
* tuple on each {@link Interrupt} / {@link InterruptPayload} entry.
|
|
917
960
|
*
|
|
918
961
|
* @param response - Payload sent back to the interrupted namespace.
|
|
919
962
|
* @param options - Optional target (`interruptId` / `namespace`) and
|
|
@@ -934,33 +977,22 @@ var StreamController = class {
|
|
|
934
977
|
* );
|
|
935
978
|
* ```
|
|
936
979
|
*
|
|
937
|
-
* @example Multiple
|
|
980
|
+
* @example Multiple / nested interrupts — target by id
|
|
938
981
|
* ```tsx
|
|
939
982
|
* for (const intr of stream.interrupts) {
|
|
940
983
|
* await stream.respond(decide(intr.value), { interruptId: intr.id! });
|
|
941
984
|
* }
|
|
942
985
|
* ```
|
|
943
986
|
*
|
|
944
|
-
* @
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
* for (const entry of thread?.interrupts ?? []) {
|
|
948
|
-
* await stream.respond(buildResponse(entry.payload), {
|
|
949
|
-
* interruptId: entry.interruptId,
|
|
950
|
-
* namespace: entry.namespace,
|
|
951
|
-
* });
|
|
952
|
-
* }
|
|
953
|
-
* ```
|
|
954
|
-
*
|
|
955
|
-
* Each {@link InterruptPayload} on `thread.interrupts` mirrors an
|
|
956
|
-
* `input.requested` event: `{ interruptId, payload, namespace }`.
|
|
957
|
-
* Nested interrupts may appear here but not on `stream.interrupts`.
|
|
987
|
+
* Each {@link InterruptPayload} on `thread.interrupts` and each
|
|
988
|
+
* {@link Interrupt} on `stream.interrupts` mirrors an
|
|
989
|
+
* `input.requested` event with its protocol `namespace`.
|
|
958
990
|
*/
|
|
959
991
|
async respond(response, options) {
|
|
960
992
|
if (this.#disposed || this.#thread == null) throw new Error("No active thread to respond to.");
|
|
961
993
|
const resolved = options?.interruptId != null ? {
|
|
962
994
|
interruptId: options.interruptId,
|
|
963
|
-
namespace: options.namespace
|
|
995
|
+
namespace: this.#resolveNamespaceForInterruptId(options.interruptId, options.namespace)
|
|
964
996
|
} : this.#resolveInterruptForResume();
|
|
965
997
|
if (resolved == null) throw new Error("No pending interrupt to respond to.");
|
|
966
998
|
const thread = this.#thread;
|
|
@@ -1030,11 +1062,10 @@ var StreamController = class {
|
|
|
1030
1062
|
const entries = Object.entries(responsesById);
|
|
1031
1063
|
if (entries.length === 0) throw new Error("respondAll() requires at least one response.");
|
|
1032
1064
|
const thread = this.#thread;
|
|
1033
|
-
const pending = thread.interrupts;
|
|
1034
1065
|
const responses = entries.map(([interruptId, response]) => ({
|
|
1035
1066
|
interrupt_id: interruptId,
|
|
1036
1067
|
response: require_hitl_interrupt_payload.normalizeHitlResponseForServer(response),
|
|
1037
|
-
namespace:
|
|
1068
|
+
namespace: this.#resolveNamespaceForInterruptId(interruptId)
|
|
1038
1069
|
}));
|
|
1039
1070
|
const prepared = options?.update != null ? this.#beginOptimistic(options.update) : void 0;
|
|
1040
1071
|
const dispatchUpdate = this.#resolveDispatchUpdate(options?.update, prepared);
|
|
@@ -1201,16 +1232,11 @@ var StreamController = class {
|
|
|
1201
1232
|
* Without this, the controller would be wedged in a state where:
|
|
1202
1233
|
* - `#thread` is wired but no content pump is open
|
|
1203
1234
|
* - `#rootPumpDeferred` stays `true`
|
|
1204
|
-
* - `selfCreatedThreadIds` still holds the id
|
|
1205
1235
|
*
|
|
1206
|
-
* A retry submit
|
|
1207
|
-
* `
|
|
1208
|
-
*
|
|
1209
|
-
* `#thread
|
|
1210
|
-
* would have an id committed to the URL but no live subscription.
|
|
1211
|
-
*
|
|
1212
|
-
* Tearing down `#thread` so the next submit re-runs `#ensureThread`
|
|
1213
|
-
* from scratch is the simplest recovery — the failed dispatch
|
|
1236
|
+
* A retry submit must re-run `#ensureThread` from scratch (with
|
|
1237
|
+
* `deferRootPump` still true — the id stays in
|
|
1238
|
+
* `#selfCreatedThreadIds` until a successful dispatch). Tearing
|
|
1239
|
+
* down `#thread` is the simplest recovery; the failed dispatch
|
|
1214
1240
|
* means there was nothing to subscribe to anyway.
|
|
1215
1241
|
*/
|
|
1216
1242
|
#abandonDeferredRootPump() {
|
|
@@ -1222,6 +1248,14 @@ var StreamController = class {
|
|
|
1222
1248
|
* Close the current thread stream and reset per-thread assembly state.
|
|
1223
1249
|
*/
|
|
1224
1250
|
async #teardownThread() {
|
|
1251
|
+
/**
|
|
1252
|
+
* Invalidate the in-flight root pump before `close()` unparks it.
|
|
1253
|
+
* `SubscriptionHandle.close()` leaves queued events intact and the
|
|
1254
|
+
* iterator drains them before observing `closed`, so without this
|
|
1255
|
+
* bump a parked interrupted pump would still dispatch stale
|
|
1256
|
+
* `values` / `messages` into a snapshot `hydrate()` already cleared.
|
|
1257
|
+
*/
|
|
1258
|
+
this.#rootPumpGeneration += 1;
|
|
1225
1259
|
const thread = this.#thread;
|
|
1226
1260
|
this.#thread = void 0;
|
|
1227
1261
|
this.registry.bind(void 0);
|
|
@@ -1234,16 +1268,16 @@ var StreamController = class {
|
|
|
1234
1268
|
*/
|
|
1235
1269
|
this.#rootEventListeners.delete(this.#lifecycleLoading.listener);
|
|
1236
1270
|
this.#rootEventListeners.delete(this.#runLifecycleListener);
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1271
|
+
/**
|
|
1272
|
+
* Close first so a pump parked on `waitForResume()` (interrupted
|
|
1273
|
+
* run) unparks even if the unsubscribe RPC is slow. `close()` is
|
|
1274
|
+
* idempotent; `unsubscribe()` is then a no-op once closed.
|
|
1275
|
+
*/
|
|
1276
|
+
const subscription = this.#rootSubscription;
|
|
1240
1277
|
this.#rootSubscription = void 0;
|
|
1278
|
+
subscription?.close();
|
|
1241
1279
|
this.#rootPumpReady = void 0;
|
|
1242
1280
|
this.#rootPumpDeferred = false;
|
|
1243
|
-
try {
|
|
1244
|
-
await this.#rootPump;
|
|
1245
|
-
} catch {}
|
|
1246
|
-
this.#rootPump = void 0;
|
|
1247
1281
|
this.#rootMessages.reset();
|
|
1248
1282
|
this.#rootToolAssembler = new require_tools.ToolCallAssembler();
|
|
1249
1283
|
this.#lifecycleLoading.reset();
|
|
@@ -1255,6 +1289,13 @@ var StreamController = class {
|
|
|
1255
1289
|
this.#messageMetadata.reset();
|
|
1256
1290
|
this.#hydratedActiveInterruptIds = null;
|
|
1257
1291
|
this.queueStore.setState(() => require_submit_coordinator.EMPTY_QUEUE);
|
|
1292
|
+
try {
|
|
1293
|
+
await subscription?.unsubscribe();
|
|
1294
|
+
} catch {}
|
|
1295
|
+
try {
|
|
1296
|
+
await this.#rootPump;
|
|
1297
|
+
} catch {}
|
|
1298
|
+
this.#rootPump = void 0;
|
|
1258
1299
|
if (thread != null) {
|
|
1259
1300
|
try {
|
|
1260
1301
|
await thread.close();
|
|
@@ -1278,6 +1319,7 @@ var StreamController = class {
|
|
|
1278
1319
|
*/
|
|
1279
1320
|
#startRootPump(thread) {
|
|
1280
1321
|
if (this.#rootPump != null) return;
|
|
1322
|
+
const pumpGeneration = this.#rootPumpGeneration;
|
|
1281
1323
|
let resolveReady;
|
|
1282
1324
|
this.#rootPumpReady = new Promise((resolve) => {
|
|
1283
1325
|
resolveReady = resolve;
|
|
@@ -1336,6 +1378,14 @@ var StreamController = class {
|
|
|
1336
1378
|
resolveReady = void 0;
|
|
1337
1379
|
});
|
|
1338
1380
|
const subscription = await subscriptionPromise;
|
|
1381
|
+
if (pumpGeneration !== this.#rootPumpGeneration) {
|
|
1382
|
+
resolveReady?.();
|
|
1383
|
+
resolveReady = void 0;
|
|
1384
|
+
try {
|
|
1385
|
+
subscription.close();
|
|
1386
|
+
} catch {}
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1339
1389
|
resolveReady?.();
|
|
1340
1390
|
resolveReady = void 0;
|
|
1341
1391
|
this.#rootSubscription = subscription;
|
|
@@ -1349,9 +1399,9 @@ var StreamController = class {
|
|
|
1349
1399
|
* for every resumed iteration until the subscription is
|
|
1350
1400
|
* permanently closed or the controller is disposed.
|
|
1351
1401
|
*/
|
|
1352
|
-
while (!this.#disposed) {
|
|
1402
|
+
while (!this.#disposed && pumpGeneration === this.#rootPumpGeneration) {
|
|
1353
1403
|
for await (const event of subscription) {
|
|
1354
|
-
if (this.#disposed) break;
|
|
1404
|
+
if (this.#disposed || pumpGeneration !== this.#rootPumpGeneration) break;
|
|
1355
1405
|
/**
|
|
1356
1406
|
* Resilience: isolate per-event dispatch from the pump loop.
|
|
1357
1407
|
*
|
|
@@ -1383,7 +1433,7 @@ var StreamController = class {
|
|
|
1383
1433
|
this.#onRootEvent(event);
|
|
1384
1434
|
} catch {}
|
|
1385
1435
|
}
|
|
1386
|
-
if (this.#disposed) break;
|
|
1436
|
+
if (this.#disposed || pumpGeneration !== this.#rootPumpGeneration) break;
|
|
1387
1437
|
if (!subscription.isPaused) break;
|
|
1388
1438
|
await subscription.waitForResume();
|
|
1389
1439
|
}
|
|
@@ -1413,16 +1463,14 @@ var StreamController = class {
|
|
|
1413
1463
|
this.#subgraphs.push(event);
|
|
1414
1464
|
this.#lifecycleLoading.handle(event);
|
|
1415
1465
|
/**
|
|
1416
|
-
*
|
|
1417
|
-
* subgraph) are not observable via the narrow content pump.
|
|
1418
|
-
* `
|
|
1419
|
-
*
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
* UI state does not depend on the narrower content pump being the
|
|
1423
|
-
* first consumer to see the event.
|
|
1466
|
+
* `input.requested` events (including HITL inside a subagent /
|
|
1467
|
+
* subgraph) are not always observable via the narrow content pump.
|
|
1468
|
+
* Mirror every namespace into `rootStore.interrupts` here so UI
|
|
1469
|
+
* state does not depend on the content pump being the first
|
|
1470
|
+
* consumer. `ThreadStream.interrupts` is updated in parallel for
|
|
1471
|
+
* resume targeting.
|
|
1424
1472
|
*/
|
|
1425
|
-
this.#
|
|
1473
|
+
this.#recordInterrupt(event);
|
|
1426
1474
|
}
|
|
1427
1475
|
/**
|
|
1428
1476
|
* Process one root-pump event and update all root projections.
|
|
@@ -1515,7 +1563,7 @@ var StreamController = class {
|
|
|
1515
1563
|
return;
|
|
1516
1564
|
}
|
|
1517
1565
|
if (event.method === "input.requested") {
|
|
1518
|
-
this.#
|
|
1566
|
+
this.#recordInterrupt(event);
|
|
1519
1567
|
return;
|
|
1520
1568
|
}
|
|
1521
1569
|
if (event.method === "lifecycle") event.params.data;
|
|
@@ -1643,21 +1691,22 @@ var StreamController = class {
|
|
|
1643
1691
|
}
|
|
1644
1692
|
}
|
|
1645
1693
|
/**
|
|
1646
|
-
* Mirror
|
|
1694
|
+
* Mirror protocol interrupts (any namespace) into the root snapshot.
|
|
1647
1695
|
*
|
|
1648
1696
|
* This can be called from both the wildcard lifecycle/input watcher and the
|
|
1649
1697
|
* root content pump. Store-level dedup keeps the user-facing list stable.
|
|
1650
1698
|
*/
|
|
1651
|
-
#
|
|
1699
|
+
#recordInterrupt(event) {
|
|
1652
1700
|
if (event.method !== "input.requested") return;
|
|
1653
|
-
if (!require_namespace.isRootNamespace(event.params.namespace)) return;
|
|
1654
1701
|
const data = event.params.data;
|
|
1655
1702
|
const interruptId = data?.interrupt_id;
|
|
1656
1703
|
if (typeof interruptId !== "string" || this.#resolvedInterrupts.has(interruptId)) return;
|
|
1657
1704
|
if (this.#hydratedActiveInterruptIds != null && !this.#hydratedActiveInterruptIds.has(interruptId)) return;
|
|
1705
|
+
const namespace = Array.isArray(event.params.namespace) ? [...event.params.namespace] : [...ROOT_NAMESPACE];
|
|
1658
1706
|
const interrupt = require_interrupts.normalizeInterruptForClient({
|
|
1659
1707
|
id: interruptId,
|
|
1660
|
-
value: data.payload
|
|
1708
|
+
value: data.payload,
|
|
1709
|
+
namespace
|
|
1661
1710
|
});
|
|
1662
1711
|
this.rootStore.setState((s) => {
|
|
1663
1712
|
if (s.interrupts.some((entry) => entry.id === interruptId)) return s;
|
|
@@ -1670,6 +1719,21 @@ var StreamController = class {
|
|
|
1670
1719
|
});
|
|
1671
1720
|
}
|
|
1672
1721
|
/**
|
|
1722
|
+
* Resolve the protocol namespace for a targeted resume.
|
|
1723
|
+
*
|
|
1724
|
+
* Prefer an explicit caller-supplied namespace, then the matching
|
|
1725
|
+
* {@link ThreadStream.interrupts} entry, then the UI mirror on
|
|
1726
|
+
* `rootStore.interrupts`, finally root (`[]`).
|
|
1727
|
+
*/
|
|
1728
|
+
#resolveNamespaceForInterruptId(interruptId, explicitNamespace) {
|
|
1729
|
+
if (explicitNamespace != null) return [...explicitNamespace];
|
|
1730
|
+
const fromThread = this.#thread?.interrupts.find((entry) => entry.interruptId === interruptId)?.namespace;
|
|
1731
|
+
if (fromThread != null) return [...fromThread];
|
|
1732
|
+
const fromRoot = this.rootStore.getSnapshot().interrupts.find((entry) => entry.id === interruptId)?.namespace;
|
|
1733
|
+
if (fromRoot != null) return [...fromRoot];
|
|
1734
|
+
return [...ROOT_NAMESPACE];
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1673
1737
|
* Mark an interrupt resolved for replay filtering and mirror the
|
|
1674
1738
|
* removal into the root snapshot the framework hooks read.
|
|
1675
1739
|
*/
|