@langchain/langgraph-sdk 1.9.23 → 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.
@@ -962,17 +962,21 @@ var StreamController = class {
962
962
  } : this.#resolveInterruptForResume();
963
963
  if (resolved == null) throw new Error("No pending interrupt to respond to.");
964
964
  const thread = this.#thread;
965
+ const prepared = options?.update != null ? this.#beginOptimistic(options.update) : void 0;
966
+ const dispatchUpdate = this.#resolveDispatchUpdate(options?.update, prepared);
965
967
  try {
966
968
  await this.#submitter.dispatchResume(async () => {
967
969
  await thread.respondInput({
968
970
  namespace: resolved.namespace,
969
971
  interrupt_id: resolved.interruptId,
970
972
  response: require_hitl_interrupt_payload.normalizeHitlResponseForServer(response),
973
+ ...dispatchUpdate != null ? { update: dispatchUpdate } : {},
974
+ ...options?.goto != null ? { goto: options.goto } : {},
971
975
  config: options?.config,
972
976
  metadata: options?.metadata
973
977
  });
974
978
  this.#markInterruptResolvedInRootStore(resolved.interruptId);
975
- });
979
+ }, prepared?.handle);
976
980
  } catch (error) {
977
981
  if (this.#disposed && isAbortLikeError(error)) return;
978
982
  throw error;
@@ -1030,15 +1034,19 @@ var StreamController = class {
1030
1034
  response: require_hitl_interrupt_payload.normalizeHitlResponseForServer(response),
1031
1035
  namespace: pending.find((entry) => entry.interruptId === interruptId)?.namespace ?? [...ROOT_NAMESPACE]
1032
1036
  }));
1037
+ const prepared = options?.update != null ? this.#beginOptimistic(options.update) : void 0;
1038
+ const dispatchUpdate = this.#resolveDispatchUpdate(options?.update, prepared);
1033
1039
  try {
1034
1040
  await this.#submitter.dispatchResume(async () => {
1035
1041
  await thread.respondInput({
1036
1042
  responses,
1043
+ ...dispatchUpdate != null ? { update: dispatchUpdate } : {},
1044
+ ...options?.goto != null ? { goto: options.goto } : {},
1037
1045
  config: options?.config,
1038
1046
  metadata: options?.metadata
1039
1047
  });
1040
1048
  for (const { interrupt_id: interruptId } of responses) this.#markInterruptResolvedInRootStore(interruptId);
1041
- });
1049
+ }, prepared?.handle);
1042
1050
  } catch (error) {
1043
1051
  if (this.#disposed && isAbortLikeError(error)) return;
1044
1052
  throw error;
@@ -1539,7 +1547,7 @@ var StreamController = class {
1539
1547
  prevValue: currentValues[key]
1540
1548
  }));
1541
1549
  this.#sawValuesForRun = false;
1542
- this.#rootMessages.appendOptimistic(prepared.optimisticMessages, prepared.extraValues);
1550
+ this.#rootMessages.appendOptimistic(prepared.optimisticMessages, prepared.extraValues, { sync: true });
1543
1551
  if (prepared.echoedIds.length > 0) this.#messageMetadata.markPending(prepared.echoedIds);
1544
1552
  return {
1545
1553
  dispatchInput: prepared.dispatchInput,
@@ -1550,6 +1558,24 @@ var StreamController = class {
1550
1558
  };
1551
1559
  }
1552
1560
  /**
1561
+ * Pick the `update` payload to dispatch on a resume (`respond` /
1562
+ * `respondAll`).
1563
+ *
1564
+ * When the optimistic path ran ({@link #beginOptimistic} returned a handle),
1565
+ * its `dispatchInput` already carries the minted message ids the server must
1566
+ * echo back, so dispatch that — the echo reconciles the optimistic messages
1567
+ * by id (no duplicate). Otherwise (optimistic UI disabled, or an `update`
1568
+ * with no echoable messages — e.g. the tuple-entry form) fall back to
1569
+ * serializing `BaseMessage` instances to dicts, exactly as before. Returns
1570
+ * `undefined` when there is no `update`, so the server still sees a plain
1571
+ * resume.
1572
+ */
1573
+ #resolveDispatchUpdate(update, prepared) {
1574
+ if (prepared != null) return prepared.dispatchInput;
1575
+ if (update == null) return void 0;
1576
+ return require_optimistic_input.serializeUpdateMessages(update, this.#messagesKey);
1577
+ }
1578
+ /**
1553
1579
  * Reconcile optimistic state when a run terminates.
1554
1580
  *
1555
1581
  * - Messages: any echoed id still `"pending"` (never echoed by the