@langchain/langgraph-sdk 1.9.30 → 1.9.31
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/stream/controller.cjs +68 -8
- package/dist/stream/controller.cjs.map +1 -1
- package/dist/stream/controller.d.cts.map +1 -1
- package/dist/stream/controller.d.ts.map +1 -1
- package/dist/stream/controller.js +68 -8
- package/dist/stream/controller.js.map +1 -1
- package/dist/stream/submit-coordinator.cjs +1 -1
- package/dist/stream/submit-coordinator.cjs.map +1 -1
- package/dist/stream/submit-coordinator.js +1 -1
- package/dist/stream/submit-coordinator.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.cts","names":[],"sources":["../../src/stream/controller.ts"],"mappings":";;;;;;;;;;;;;;AA6KA;;cAAa,kBAAA,WAA6B,OAAA;;AAkC1C;;;;;;;;;;;;cAAa,gBAAA,4BACgB,MAAA,8EAEO,MAAA;EAAA;WAEzB,SAAA,EAAW,WAAA,CAAY,YAAA,CAAa,SAAA,EAAW,aAAA;EAAA,SAC/C,aAAA,EAAe,WAAA,CAAY,WAAA;EAAA,SAC3B,aAAA,EAAe,WAAA,CAAY,WAAA;EAAA,SAC3B,mBAAA,EAAqB,WAAA,CAAY,iBAAA;EAAA,SACjC,oBAAA,EAAsB,WAAA,CAAY,kBAAA;EAAA,SAClC,UAAA,EAAY,WAAA,CAAY,uBAAA,CAAwB,SAAA;EAAA,SAChD,QAAA,EAAU,eAAA;
|
|
1
|
+
{"version":3,"file":"controller.d.cts","names":[],"sources":["../../src/stream/controller.ts"],"mappings":";;;;;;;;;;;;;;AA6KA;;cAAa,kBAAA,WAA6B,OAAA;;AAkC1C;;;;;;;;;;;;cAAa,gBAAA,4BACgB,MAAA,8EAEO,MAAA;EAAA;WAEzB,SAAA,EAAW,WAAA,CAAY,YAAA,CAAa,SAAA,EAAW,aAAA;EAAA,SAC/C,aAAA,EAAe,WAAA,C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E,QAAA,GAAW,MAAA,EAAQ,YAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","names":[],"sources":["../../src/stream/controller.ts"],"mappings":";;;;;;;;;;;;;;;AA6KA;cAAa,kBAAA,WAA6B,OAAA;;;AAkC1C;;;;;;;;;;;cAAa,gBAAA,4BACgB,MAAA,8EAEO,MAAA;EAAA;WAEzB,SAAA,EAAW,WAAA,CAAY,YAAA,CAAa,SAAA,EAAW,aAAA;EAAA,SAC/C,aAAA,EAAe,WAAA,CAAY,WAAA;EAAA,SAC3B,aAAA,EAAe,WAAA,CAAY,WAAA;EAAA,SAC3B,mBAAA,EAAqB,WAAA,CAAY,iBAAA;EAAA,SACjC,oBAAA,EAAsB,WAAA,CAAY,kBAAA;EAAA,SAClC,UAAA,EAAY,WAAA,CAAY,uBAAA,CAAwB,SAAA;EAAA,SAChD,QAAA,EAAU,eAAA;EAAA;;;;;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","names":[],"sources":["../../src/stream/controller.ts"],"mappings":";;;;;;;;;;;;;;;AA6KA;cAAa,kBAAA,WAA6B,OAAA;;;AAkC1C;;;;;;;;;;;cAAa,gBAAA,4BACgB,MAAA,8EAEO,MAAA;EAAA;WAEzB,SAAA,EAAW,WAAA,CAAY,YAAA,CAAa,SAAA,EAAW,aAAA;EAAA,SAC/C,aAAA,EAAe,WAAA,CAAY,WAAA;EAAA,SAC3B,aAAA,EAAe,WAAA,CAAY,WAAA;EAAA,SAC3B,mBAAA,EAAqB,WAAA,CAAY,iBAAA;EAAA,SACjC,oBAAA,EAAsB,WAAA,CAAY,kBAAA;EAAA,SAClC,UAAA,EAAY,WAAA,CAAY,uBAAA,CAAwB,SAAA;EAAA,SAChD,QAAA,EAAU,eAAA;EAAA;;;;;EAqJnB,WAAA,CAAY,OAAA,EAAS,uBAAA,CAAwB,SAAA;EAszBb;;;;;;;EAAA,IA5rB5B,gBAAA,CAAA,GAAoB,OAAA;EAkyBJ;;;;;;;;EAzuBd,OAAA,CAAQ,QAAA,mBAA2B,OAAA;EA8gC5B;;;;;;;;;;;;;;EAjpBP,wBAAA,CAAyB,UAAA,WAAqB,OAAA;EA1sB3C;;;;;;;;EA88BH,MAAA,CACJ,KAAA,WACA,OAAA,GAAU,mBAAA,CAAoB,SAAA,EAAW,gBAAA,IACxC,OAAA;EA98BM;;;;;;EAw9BH,IAAA,CAAK,OAAA,GAAU,iBAAA,GAAoB,OAAA;EAt9BhC;;;;EA0+BH,UAAA,CAAA,GAAc,OAAA;EAr1BR;;;;;;;;;;;EAq5BN,YAAA,CAAa,EAAA,WAAa,OAAA;EA/FA;;;EAsG1B,UAAA,CAAA,GAAc,OAAA;EA3Fd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwJA,OAAA,CACJ,QAAA,WACA,OAAA,GAAU,oBAAA,CAAqB,gBAAA,IAC9B,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiHG,UAAA,CACJ,aAAA,EAAe,MAAA,mBACf,OAAA,GAAU,uBAAA,CAAwB,gBAAA,IACjC,OAAA;;;;EA4DG,OAAA,CAAA,GAAW,OAAA;;;;;;;;;;;;;;;;EAyBjB,QAAA,CAAA;;;;;;EA4BA,SAAA,CAAA,GAAa,YAAA;;;;;;;;EAWb,eAAA,CACE,QAAA,GAAW,MAAA,EAAQ,YAAA;AAAA"}
|
|
@@ -154,12 +154,25 @@ var StreamController = class {
|
|
|
154
154
|
* SSE replay re-adds historically-requested interrupts that have
|
|
155
155
|
* since been resolved (no `input.responded` event exists in the
|
|
156
156
|
* protocol, so the SDK has no other way to tell replay from live
|
|
157
|
-
* for an idle thread).
|
|
158
|
-
*
|
|
159
|
-
* cleared at the start of `submit()` for the same reason.
|
|
157
|
+
* for an idle thread). After a command is accepted, events newer
|
|
158
|
+
* than {@link #interruptReplayThroughSeq} bypass the allowlist.
|
|
160
159
|
*/
|
|
161
160
|
#hydratedActiveInterruptIds = null;
|
|
162
161
|
/**
|
|
162
|
+
* Highest event sequence already applied when the latest run command
|
|
163
|
+
* was accepted. Interrupts outside the hydrate-time allowlist remain
|
|
164
|
+
* filtered through this sequence, while newer events are live output
|
|
165
|
+
* from the newly-started run and must be accepted.
|
|
166
|
+
*/
|
|
167
|
+
#interruptReplayThroughSeq;
|
|
168
|
+
/**
|
|
169
|
+
* Unknown interrupt events received between local command dispatch and its
|
|
170
|
+
* response. The response supplies the sequence barrier needed to classify
|
|
171
|
+
* each event as historical replay or live output from the new run.
|
|
172
|
+
*/
|
|
173
|
+
#pendingInterruptEvents = [];
|
|
174
|
+
#interruptCommandPending = false;
|
|
175
|
+
/**
|
|
163
176
|
* Monotonic counter bumped at the start of each `submit()` and used
|
|
164
177
|
* by {@link hydrate} to skip its post-fetch allowlist write when a
|
|
165
178
|
* submit started while the state fetch was in flight. Without this
|
|
@@ -301,13 +314,20 @@ var StreamController = class {
|
|
|
301
314
|
awaitNextTerminal: (signal) => this.#awaitNextTerminal(signal),
|
|
302
315
|
awaitResumedRunTerminal: (signal) => this.#awaitResumedRunTerminal(signal),
|
|
303
316
|
onSubmitStart: () => {
|
|
304
|
-
this.#hydratedActiveInterruptIds = null;
|
|
305
317
|
this.#submitGeneration += 1;
|
|
318
|
+
this.#interruptCommandPending = this.#hydratedActiveInterruptIds != null;
|
|
319
|
+
this.#pendingInterruptEvents = [];
|
|
306
320
|
},
|
|
307
321
|
onRunStart: () => this.#markLocalRunStart(),
|
|
308
|
-
onRunCreated: (runId) =>
|
|
322
|
+
onRunCreated: (runId) => {
|
|
323
|
+
this.#advanceInterruptReplayBarrier();
|
|
324
|
+
this.#notifyCreated(runId);
|
|
325
|
+
},
|
|
309
326
|
onRunCompleted: (reason, runId) => this.#notifyCompleted(reason, runId),
|
|
310
|
-
onRunEnd: () =>
|
|
327
|
+
onRunEnd: () => {
|
|
328
|
+
this.#interruptCommandPending = false;
|
|
329
|
+
this.#markLocalRunEnd();
|
|
330
|
+
},
|
|
311
331
|
beginOptimistic: (input) => this.#beginOptimistic(input),
|
|
312
332
|
settleOptimistic: (handle, event) => this.#settleOptimistic(handle, event)
|
|
313
333
|
});
|
|
@@ -561,7 +581,10 @@ var StreamController = class {
|
|
|
561
581
|
interrupts: activeInterrupts,
|
|
562
582
|
interrupt: activeInterrupts[0]
|
|
563
583
|
}));
|
|
564
|
-
if (this.#submitGeneration === generationAtFetch)
|
|
584
|
+
if (this.#submitGeneration === generationAtFetch) {
|
|
585
|
+
this.#hydratedActiveInterruptIds = activeIds;
|
|
586
|
+
this.#interruptReplayThroughSeq = void 0;
|
|
587
|
+
}
|
|
565
588
|
}
|
|
566
589
|
} catch (error) {
|
|
567
590
|
if (error?.status !== 404) {
|
|
@@ -1008,9 +1031,11 @@ var StreamController = class {
|
|
|
1008
1031
|
config: options?.config,
|
|
1009
1032
|
metadata: options?.metadata
|
|
1010
1033
|
});
|
|
1034
|
+
this.#advanceInterruptReplayBarrier();
|
|
1011
1035
|
this.#markInterruptResolvedInRootStore(resolved.interruptId);
|
|
1012
1036
|
}, prepared?.handle);
|
|
1013
1037
|
} catch (error) {
|
|
1038
|
+
this.#discardPendingInterruptEvents();
|
|
1014
1039
|
if (this.#disposed && isAbortLikeError(error)) return;
|
|
1015
1040
|
throw error;
|
|
1016
1041
|
}
|
|
@@ -1077,9 +1102,11 @@ var StreamController = class {
|
|
|
1077
1102
|
config: options?.config,
|
|
1078
1103
|
metadata: options?.metadata
|
|
1079
1104
|
});
|
|
1105
|
+
this.#advanceInterruptReplayBarrier();
|
|
1080
1106
|
for (const { interrupt_id: interruptId } of responses) this.#markInterruptResolvedInRootStore(interruptId);
|
|
1081
1107
|
}, prepared?.handle);
|
|
1082
1108
|
} catch (error) {
|
|
1109
|
+
this.#discardPendingInterruptEvents();
|
|
1083
1110
|
if (this.#disposed && isAbortLikeError(error)) return;
|
|
1084
1111
|
throw error;
|
|
1085
1112
|
}
|
|
@@ -1287,6 +1314,8 @@ var StreamController = class {
|
|
|
1287
1314
|
this.#localRunDepth = 0;
|
|
1288
1315
|
this.#messageMetadata.reset();
|
|
1289
1316
|
this.#hydratedActiveInterruptIds = null;
|
|
1317
|
+
this.#interruptReplayThroughSeq = void 0;
|
|
1318
|
+
this.#discardPendingInterruptEvents();
|
|
1290
1319
|
this.queueStore.setState(() => EMPTY_QUEUE);
|
|
1291
1320
|
try {
|
|
1292
1321
|
await subscription?.unsubscribe();
|
|
@@ -1700,7 +1729,13 @@ var StreamController = class {
|
|
|
1700
1729
|
const data = event.params.data;
|
|
1701
1730
|
const interruptId = data?.interrupt_id;
|
|
1702
1731
|
if (typeof interruptId !== "string" || this.#resolvedInterrupts.has(interruptId)) return;
|
|
1703
|
-
|
|
1732
|
+
const eventSeq = typeof event.seq === "number" ? event.seq : void 0;
|
|
1733
|
+
const isUnknownInterrupt = this.#hydratedActiveInterruptIds != null && !this.#hydratedActiveInterruptIds.has(interruptId);
|
|
1734
|
+
if (isUnknownInterrupt && this.#interruptCommandPending) {
|
|
1735
|
+
this.#pendingInterruptEvents.push(event);
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1738
|
+
if (isUnknownInterrupt && (this.#interruptReplayThroughSeq == null || eventSeq != null && eventSeq <= this.#interruptReplayThroughSeq)) return;
|
|
1704
1739
|
const namespace = Array.isArray(event.params.namespace) ? [...event.params.namespace] : [...ROOT_NAMESPACE];
|
|
1705
1740
|
const interrupt = normalizeInterruptForClient({
|
|
1706
1741
|
id: interruptId,
|
|
@@ -1718,6 +1753,31 @@ var StreamController = class {
|
|
|
1718
1753
|
});
|
|
1719
1754
|
}
|
|
1720
1755
|
/**
|
|
1756
|
+
* Convert the hydrate-time allowlist into a replay barrier after a command
|
|
1757
|
+
* is accepted. Built-in transports update `lastAppliedThroughSeq` from the
|
|
1758
|
+
* command response before resolving `submitRun` / `respondInput`.
|
|
1759
|
+
*/
|
|
1760
|
+
#advanceInterruptReplayBarrier() {
|
|
1761
|
+
if (this.#hydratedActiveInterruptIds == null) {
|
|
1762
|
+
this.#discardPendingInterruptEvents();
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
const throughSeq = this.#thread?.ordering?.lastAppliedThroughSeq;
|
|
1766
|
+
if (typeof throughSeq === "number") this.#interruptReplayThroughSeq = throughSeq;
|
|
1767
|
+
else {
|
|
1768
|
+
this.#hydratedActiveInterruptIds = null;
|
|
1769
|
+
this.#interruptReplayThroughSeq = void 0;
|
|
1770
|
+
}
|
|
1771
|
+
this.#interruptCommandPending = false;
|
|
1772
|
+
const pendingEvents = this.#pendingInterruptEvents;
|
|
1773
|
+
this.#pendingInterruptEvents = [];
|
|
1774
|
+
for (const event of pendingEvents) this.#recordInterrupt(event);
|
|
1775
|
+
}
|
|
1776
|
+
#discardPendingInterruptEvents() {
|
|
1777
|
+
this.#interruptCommandPending = false;
|
|
1778
|
+
this.#pendingInterruptEvents = [];
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1721
1781
|
* Resolve the protocol namespace for a targeted resume.
|
|
1722
1782
|
*
|
|
1723
1783
|
* Prefer an explicit caller-supplied namespace, then the matching
|