@langchain/langgraph-sdk 1.9.22 → 1.9.24

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.
Files changed (35) hide show
  1. package/dist/stream/channel-registry.cjs +20 -7
  2. package/dist/stream/channel-registry.cjs.map +1 -1
  3. package/dist/stream/channel-registry.d.cts +4 -3
  4. package/dist/stream/channel-registry.d.cts.map +1 -1
  5. package/dist/stream/channel-registry.d.ts +4 -3
  6. package/dist/stream/channel-registry.d.ts.map +1 -1
  7. package/dist/stream/channel-registry.js +20 -7
  8. package/dist/stream/channel-registry.js.map +1 -1
  9. package/dist/stream/controller.cjs +29 -3
  10. package/dist/stream/controller.cjs.map +1 -1
  11. package/dist/stream/controller.d.cts.map +1 -1
  12. package/dist/stream/controller.d.ts.map +1 -1
  13. package/dist/stream/controller.js +30 -4
  14. package/dist/stream/controller.js.map +1 -1
  15. package/dist/stream/optimistic-input.cjs +32 -0
  16. package/dist/stream/optimistic-input.cjs.map +1 -1
  17. package/dist/stream/optimistic-input.js +32 -1
  18. package/dist/stream/optimistic-input.js.map +1 -1
  19. package/dist/stream/root-message-projection.cjs +14 -2
  20. package/dist/stream/root-message-projection.cjs.map +1 -1
  21. package/dist/stream/root-message-projection.js +14 -2
  22. package/dist/stream/root-message-projection.js.map +1 -1
  23. package/dist/stream/submit-coordinator.cjs +14 -1
  24. package/dist/stream/submit-coordinator.cjs.map +1 -1
  25. package/dist/stream/submit-coordinator.js +14 -1
  26. package/dist/stream/submit-coordinator.js.map +1 -1
  27. package/dist/stream/types.d.cts +27 -1
  28. package/dist/stream/types.d.cts.map +1 -1
  29. package/dist/stream/types.d.ts +27 -1
  30. package/dist/stream/types.d.ts.map +1 -1
  31. package/dist/ui/types.d.cts +13 -1
  32. package/dist/ui/types.d.cts.map +1 -1
  33. package/dist/ui/types.d.ts +13 -1
  34. package/dist/ui/types.d.ts.map +1 -1
  35. package/package.json +6 -6
@@ -14,7 +14,7 @@ import { collectSubgraphHostNamespaces, getHistoryPage, mapSubagentNamespaces, r
14
14
  import { MessageMetadataTracker } from "./message-metadata-tracker.js";
15
15
  import { LifecycleLoadingTracker } from "./lifecycle-loading-tracker.js";
16
16
  import { RootMessageProjection } from "./root-message-projection.js";
17
- import { prepareOptimisticInput } from "./optimistic-input.js";
17
+ import { prepareOptimisticInput, serializeUpdateMessages } from "./optimistic-input.js";
18
18
  import { EMPTY_QUEUE, SubmitCoordinator } from "./submit-coordinator.js";
19
19
  import { reconcileToolCallsFromMessages, seedToolCallsFromMessages, upsertToolCall } from "./tool-calls.js";
20
20
  import { v7 } from "@langchain/core/utils/uuid";
@@ -961,17 +961,21 @@ var StreamController = class {
961
961
  } : this.#resolveInterruptForResume();
962
962
  if (resolved == null) throw new Error("No pending interrupt to respond to.");
963
963
  const thread = this.#thread;
964
+ const prepared = options?.update != null ? this.#beginOptimistic(options.update) : void 0;
965
+ const dispatchUpdate = this.#resolveDispatchUpdate(options?.update, prepared);
964
966
  try {
965
967
  await this.#submitter.dispatchResume(async () => {
966
968
  await thread.respondInput({
967
969
  namespace: resolved.namespace,
968
970
  interrupt_id: resolved.interruptId,
969
971
  response: normalizeHitlResponseForServer(response),
972
+ ...dispatchUpdate != null ? { update: dispatchUpdate } : {},
973
+ ...options?.goto != null ? { goto: options.goto } : {},
970
974
  config: options?.config,
971
975
  metadata: options?.metadata
972
976
  });
973
977
  this.#markInterruptResolvedInRootStore(resolved.interruptId);
974
- });
978
+ }, prepared?.handle);
975
979
  } catch (error) {
976
980
  if (this.#disposed && isAbortLikeError(error)) return;
977
981
  throw error;
@@ -1029,15 +1033,19 @@ var StreamController = class {
1029
1033
  response: normalizeHitlResponseForServer(response),
1030
1034
  namespace: pending.find((entry) => entry.interruptId === interruptId)?.namespace ?? [...ROOT_NAMESPACE]
1031
1035
  }));
1036
+ const prepared = options?.update != null ? this.#beginOptimistic(options.update) : void 0;
1037
+ const dispatchUpdate = this.#resolveDispatchUpdate(options?.update, prepared);
1032
1038
  try {
1033
1039
  await this.#submitter.dispatchResume(async () => {
1034
1040
  await thread.respondInput({
1035
1041
  responses,
1042
+ ...dispatchUpdate != null ? { update: dispatchUpdate } : {},
1043
+ ...options?.goto != null ? { goto: options.goto } : {},
1036
1044
  config: options?.config,
1037
1045
  metadata: options?.metadata
1038
1046
  });
1039
1047
  for (const { interrupt_id: interruptId } of responses) this.#markInterruptResolvedInRootStore(interruptId);
1040
- });
1048
+ }, prepared?.handle);
1041
1049
  } catch (error) {
1042
1050
  if (this.#disposed && isAbortLikeError(error)) return;
1043
1051
  throw error;
@@ -1538,7 +1546,7 @@ var StreamController = class {
1538
1546
  prevValue: currentValues[key]
1539
1547
  }));
1540
1548
  this.#sawValuesForRun = false;
1541
- this.#rootMessages.appendOptimistic(prepared.optimisticMessages, prepared.extraValues);
1549
+ this.#rootMessages.appendOptimistic(prepared.optimisticMessages, prepared.extraValues, { sync: true });
1542
1550
  if (prepared.echoedIds.length > 0) this.#messageMetadata.markPending(prepared.echoedIds);
1543
1551
  return {
1544
1552
  dispatchInput: prepared.dispatchInput,
@@ -1549,6 +1557,24 @@ var StreamController = class {
1549
1557
  };
1550
1558
  }
1551
1559
  /**
1560
+ * Pick the `update` payload to dispatch on a resume (`respond` /
1561
+ * `respondAll`).
1562
+ *
1563
+ * When the optimistic path ran ({@link #beginOptimistic} returned a handle),
1564
+ * its `dispatchInput` already carries the minted message ids the server must
1565
+ * echo back, so dispatch that — the echo reconciles the optimistic messages
1566
+ * by id (no duplicate). Otherwise (optimistic UI disabled, or an `update`
1567
+ * with no echoable messages — e.g. the tuple-entry form) fall back to
1568
+ * serializing `BaseMessage` instances to dicts, exactly as before. Returns
1569
+ * `undefined` when there is no `update`, so the server still sees a plain
1570
+ * resume.
1571
+ */
1572
+ #resolveDispatchUpdate(update, prepared) {
1573
+ if (prepared != null) return prepared.dispatchInput;
1574
+ if (update == null) return void 0;
1575
+ return serializeUpdateMessages(update, this.#messagesKey);
1576
+ }
1577
+ /**
1552
1578
  * Reconcile optimistic state when a run terminates.
1553
1579
  *
1554
1580
  * - Messages: any echoed id still `"pending"` (never echoed by the