@langchain/langgraph-sdk 1.9.29 → 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/stream/controller.cjs +51 -15
- 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 +51 -15
- 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/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/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,WAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwJf,OAAA,CACJ,QAAA,WACA,OAAA,GAAU,oBAAA,CAAqB,gBAAA,IAC9B,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+GG,UAAA,CACJ,aAAA,EAAe,MAAA,mBACf,OAAA,GAAU,uBAAA,CAAwB,gBAAA,IACjC,OAAA;;;;EA0DG,OAAA,CAAA,GAAW,OAAA;;;;;;;;;;;;;;;;EAyBjB,QAAA,CAAA;;;;;;EA4BA,SAAA,CAAA,GAAa,YAAA;;;;;;;;EAWb,eAAA,CACE,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,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;;;;EAWb,eAAA,CACE,QAAA,GAAW,MAAA,EAAQ,YAAA;AAAA"}
|
|
@@ -169,6 +169,14 @@ var StreamController = class {
|
|
|
169
169
|
*/
|
|
170
170
|
#submitGeneration = 0;
|
|
171
171
|
/**
|
|
172
|
+
* Monotonic counter bumped at the start of each `#teardownThread`.
|
|
173
|
+
* The root pump captures the generation when it starts and drops
|
|
174
|
+
* any event whose generation no longer matches — including queued
|
|
175
|
+
* events that `SubscriptionHandle.close()` still drains after the
|
|
176
|
+
* snapshot has already been cleared by `hydrate()`.
|
|
177
|
+
*/
|
|
178
|
+
#rootPumpGeneration = 0;
|
|
179
|
+
/**
|
|
172
180
|
* Thread ids this controller minted client-side on first `submit()`.
|
|
173
181
|
* `hydrate()` skips `threads.getState()` for these — we know there
|
|
174
182
|
* is nothing checkpointed yet. Cleared once dispatch commits the
|
|
@@ -391,13 +399,16 @@ var StreamController = class {
|
|
|
391
399
|
* Suspense boundary remounted against the new id suspends again.
|
|
392
400
|
*/
|
|
393
401
|
this.#resetHydrationPromise();
|
|
394
|
-
await this.#teardownThread();
|
|
395
402
|
/**
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
403
|
+
* Kick teardown so the synchronous abort (unbind, drop onEvent,
|
|
404
|
+
* close the root subscription, reset assemblers) runs before we
|
|
405
|
+
* touch the snapshot. Then reset immediately so the UI does not
|
|
406
|
+
* wait on pump/close. An interrupted thread parks the root pump
|
|
407
|
+
* on `waitForResume()`; awaiting teardown *before* this reset
|
|
408
|
+
* left `threadId` null while `messages` still showed the previous
|
|
409
|
+
* conversation (`useStream` fire-and-forgets `hydrate()`).
|
|
400
410
|
*/
|
|
411
|
+
const teardown = this.#teardownThread();
|
|
401
412
|
this.rootStore.setState(() => ({
|
|
402
413
|
...this.#createInitialSnapshot(),
|
|
403
414
|
threadId: this.#currentThreadId
|
|
@@ -408,6 +419,7 @@ var StreamController = class {
|
|
|
408
419
|
* surprising. Mirrors the legacy `StreamOrchestrator` behaviour.
|
|
409
420
|
*/
|
|
410
421
|
this.queueStore.setState(() => EMPTY_QUEUE);
|
|
422
|
+
await teardown;
|
|
411
423
|
}
|
|
412
424
|
if (this.#currentThreadId == null) {
|
|
413
425
|
this.rootStore.setState((s) => ({
|
|
@@ -1235,6 +1247,14 @@ var StreamController = class {
|
|
|
1235
1247
|
* Close the current thread stream and reset per-thread assembly state.
|
|
1236
1248
|
*/
|
|
1237
1249
|
async #teardownThread() {
|
|
1250
|
+
/**
|
|
1251
|
+
* Invalidate the in-flight root pump before `close()` unparks it.
|
|
1252
|
+
* `SubscriptionHandle.close()` leaves queued events intact and the
|
|
1253
|
+
* iterator drains them before observing `closed`, so without this
|
|
1254
|
+
* bump a parked interrupted pump would still dispatch stale
|
|
1255
|
+
* `values` / `messages` into a snapshot `hydrate()` already cleared.
|
|
1256
|
+
*/
|
|
1257
|
+
this.#rootPumpGeneration += 1;
|
|
1238
1258
|
const thread = this.#thread;
|
|
1239
1259
|
this.#thread = void 0;
|
|
1240
1260
|
this.registry.bind(void 0);
|
|
@@ -1247,16 +1267,16 @@ var StreamController = class {
|
|
|
1247
1267
|
*/
|
|
1248
1268
|
this.#rootEventListeners.delete(this.#lifecycleLoading.listener);
|
|
1249
1269
|
this.#rootEventListeners.delete(this.#runLifecycleListener);
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1270
|
+
/**
|
|
1271
|
+
* Close first so a pump parked on `waitForResume()` (interrupted
|
|
1272
|
+
* run) unparks even if the unsubscribe RPC is slow. `close()` is
|
|
1273
|
+
* idempotent; `unsubscribe()` is then a no-op once closed.
|
|
1274
|
+
*/
|
|
1275
|
+
const subscription = this.#rootSubscription;
|
|
1253
1276
|
this.#rootSubscription = void 0;
|
|
1277
|
+
subscription?.close();
|
|
1254
1278
|
this.#rootPumpReady = void 0;
|
|
1255
1279
|
this.#rootPumpDeferred = false;
|
|
1256
|
-
try {
|
|
1257
|
-
await this.#rootPump;
|
|
1258
|
-
} catch {}
|
|
1259
|
-
this.#rootPump = void 0;
|
|
1260
1280
|
this.#rootMessages.reset();
|
|
1261
1281
|
this.#rootToolAssembler = new ToolCallAssembler();
|
|
1262
1282
|
this.#lifecycleLoading.reset();
|
|
@@ -1268,6 +1288,13 @@ var StreamController = class {
|
|
|
1268
1288
|
this.#messageMetadata.reset();
|
|
1269
1289
|
this.#hydratedActiveInterruptIds = null;
|
|
1270
1290
|
this.queueStore.setState(() => EMPTY_QUEUE);
|
|
1291
|
+
try {
|
|
1292
|
+
await subscription?.unsubscribe();
|
|
1293
|
+
} catch {}
|
|
1294
|
+
try {
|
|
1295
|
+
await this.#rootPump;
|
|
1296
|
+
} catch {}
|
|
1297
|
+
this.#rootPump = void 0;
|
|
1271
1298
|
if (thread != null) {
|
|
1272
1299
|
try {
|
|
1273
1300
|
await thread.close();
|
|
@@ -1291,6 +1318,7 @@ var StreamController = class {
|
|
|
1291
1318
|
*/
|
|
1292
1319
|
#startRootPump(thread) {
|
|
1293
1320
|
if (this.#rootPump != null) return;
|
|
1321
|
+
const pumpGeneration = this.#rootPumpGeneration;
|
|
1294
1322
|
let resolveReady;
|
|
1295
1323
|
this.#rootPumpReady = new Promise((resolve) => {
|
|
1296
1324
|
resolveReady = resolve;
|
|
@@ -1349,6 +1377,14 @@ var StreamController = class {
|
|
|
1349
1377
|
resolveReady = void 0;
|
|
1350
1378
|
});
|
|
1351
1379
|
const subscription = await subscriptionPromise;
|
|
1380
|
+
if (pumpGeneration !== this.#rootPumpGeneration) {
|
|
1381
|
+
resolveReady?.();
|
|
1382
|
+
resolveReady = void 0;
|
|
1383
|
+
try {
|
|
1384
|
+
subscription.close();
|
|
1385
|
+
} catch {}
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1352
1388
|
resolveReady?.();
|
|
1353
1389
|
resolveReady = void 0;
|
|
1354
1390
|
this.#rootSubscription = subscription;
|
|
@@ -1362,9 +1398,9 @@ var StreamController = class {
|
|
|
1362
1398
|
* for every resumed iteration until the subscription is
|
|
1363
1399
|
* permanently closed or the controller is disposed.
|
|
1364
1400
|
*/
|
|
1365
|
-
while (!this.#disposed) {
|
|
1401
|
+
while (!this.#disposed && pumpGeneration === this.#rootPumpGeneration) {
|
|
1366
1402
|
for await (const event of subscription) {
|
|
1367
|
-
if (this.#disposed) break;
|
|
1403
|
+
if (this.#disposed || pumpGeneration !== this.#rootPumpGeneration) break;
|
|
1368
1404
|
/**
|
|
1369
1405
|
* Resilience: isolate per-event dispatch from the pump loop.
|
|
1370
1406
|
*
|
|
@@ -1396,7 +1432,7 @@ var StreamController = class {
|
|
|
1396
1432
|
this.#onRootEvent(event);
|
|
1397
1433
|
} catch {}
|
|
1398
1434
|
}
|
|
1399
|
-
if (this.#disposed) break;
|
|
1435
|
+
if (this.#disposed || pumpGeneration !== this.#rootPumpGeneration) break;
|
|
1400
1436
|
if (!subscription.isPaused) break;
|
|
1401
1437
|
await subscription.waitForResume();
|
|
1402
1438
|
}
|