@langchain/langgraph-sdk 1.9.23 → 1.9.25
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/_virtual/_rolldown/runtime.cjs +2 -0
- package/dist/_virtual/_rolldown/runtime.js +24 -0
- package/dist/node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.cjs +244 -0
- package/dist/node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.js +240 -0
- package/dist/node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.js.map +1 -0
- package/dist/node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index2.cjs +13 -0
- package/dist/node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index2.cjs.map +1 -0
- package/dist/node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index2.js +8 -0
- package/dist/node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index2.js.map +1 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.1/node_modules/is-network-error/index.cjs +25 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.1/node_modules/is-network-error/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.1/node_modules/is-network-error/index.js +25 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.1/node_modules/is-network-error/index.js.map +1 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/index.cjs +596 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/index.js +596 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/lower-bound.cjs +18 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/lower-bound.cjs.map +1 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/lower-bound.js +18 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/lower-bound.js.map +1 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/priority-queue.cjs +41 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/priority-queue.cjs.map +1 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/priority-queue.js +41 -0
- package/dist/node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/priority-queue.js.map +1 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.1/node_modules/p-retry/index.cjs +141 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.1/node_modules/p-retry/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.1/node_modules/p-retry/index.js +141 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.1/node_modules/p-retry/index.js.map +1 -0
- package/dist/node_modules/.pnpm/p-timeout@7.0.1/node_modules/p-timeout/index.cjs +63 -0
- package/dist/node_modules/.pnpm/p-timeout@7.0.1/node_modules/p-timeout/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/p-timeout@7.0.1/node_modules/p-timeout/index.js +62 -0
- package/dist/node_modules/.pnpm/p-timeout@7.0.1/node_modules/p-timeout/index.js.map +1 -0
- package/dist/stream/controller.cjs +29 -3
- 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 +30 -4
- package/dist/stream/controller.js.map +1 -1
- package/dist/stream/optimistic-input.cjs +32 -0
- package/dist/stream/optimistic-input.cjs.map +1 -1
- package/dist/stream/optimistic-input.js +32 -1
- package/dist/stream/optimistic-input.js.map +1 -1
- package/dist/stream/root-message-projection.cjs +14 -2
- package/dist/stream/root-message-projection.cjs.map +1 -1
- package/dist/stream/root-message-projection.js +14 -2
- package/dist/stream/root-message-projection.js.map +1 -1
- package/dist/stream/submit-coordinator.cjs +14 -1
- package/dist/stream/submit-coordinator.cjs.map +1 -1
- package/dist/stream/submit-coordinator.js +14 -1
- package/dist/stream/submit-coordinator.js.map +1 -1
- package/dist/stream/types.d.cts +27 -1
- package/dist/stream/types.d.cts.map +1 -1
- package/dist/stream/types.d.ts +27 -1
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/ui/types.d.cts +13 -1
- package/dist/ui/types.d.cts.map +1 -1
- package/dist/ui/types.d.ts +13 -1
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/utils/async_caller.cjs +14 -8
- 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 +13 -4
- package/dist/utils/async_caller.js.map +1 -1
- package/package.json +7 -6
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/p-timeout@7.0.1/node_modules/p-timeout/index.js
|
|
2
|
+
var TimeoutError = class TimeoutError extends Error {
|
|
3
|
+
name = "TimeoutError";
|
|
4
|
+
constructor(message, options) {
|
|
5
|
+
super(message, options);
|
|
6
|
+
Error.captureStackTrace?.(this, TimeoutError);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
const getAbortedReason = (signal) => signal.reason ?? new DOMException("This operation was aborted.", "AbortError");
|
|
10
|
+
function pTimeout(promise, options) {
|
|
11
|
+
const { milliseconds, fallback, message, customTimers = {
|
|
12
|
+
setTimeout,
|
|
13
|
+
clearTimeout
|
|
14
|
+
}, signal } = options;
|
|
15
|
+
let timer;
|
|
16
|
+
let abortHandler;
|
|
17
|
+
const cancelablePromise = new Promise((resolve, reject) => {
|
|
18
|
+
if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
|
|
19
|
+
if (signal?.aborted) {
|
|
20
|
+
reject(getAbortedReason(signal));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (signal) {
|
|
24
|
+
abortHandler = () => {
|
|
25
|
+
reject(getAbortedReason(signal));
|
|
26
|
+
};
|
|
27
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
28
|
+
}
|
|
29
|
+
promise.then(resolve, reject);
|
|
30
|
+
if (milliseconds === Number.POSITIVE_INFINITY) return;
|
|
31
|
+
const timeoutError = new TimeoutError();
|
|
32
|
+
timer = customTimers.setTimeout.call(void 0, () => {
|
|
33
|
+
if (fallback) {
|
|
34
|
+
try {
|
|
35
|
+
resolve(fallback());
|
|
36
|
+
} catch (error) {
|
|
37
|
+
reject(error);
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (typeof promise.cancel === "function") promise.cancel();
|
|
42
|
+
if (message === false) resolve();
|
|
43
|
+
else if (message instanceof Error) reject(message);
|
|
44
|
+
else {
|
|
45
|
+
timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;
|
|
46
|
+
reject(timeoutError);
|
|
47
|
+
}
|
|
48
|
+
}, milliseconds);
|
|
49
|
+
}).finally(() => {
|
|
50
|
+
cancelablePromise.clear();
|
|
51
|
+
if (abortHandler && signal) signal.removeEventListener("abort", abortHandler);
|
|
52
|
+
});
|
|
53
|
+
cancelablePromise.clear = () => {
|
|
54
|
+
customTimers.clearTimeout.call(void 0, timer);
|
|
55
|
+
timer = void 0;
|
|
56
|
+
};
|
|
57
|
+
return cancelablePromise;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { TimeoutError, pTimeout as default };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../../../node_modules/.pnpm/p-timeout@7.0.1/node_modules/p-timeout/index.js"],"sourcesContent":["export class TimeoutError extends Error {\n\tname = 'TimeoutError';\n\n\tconstructor(message, options) {\n\t\tsuper(message, options);\n\t\tError.captureStackTrace?.(this, TimeoutError);\n\t}\n}\n\nconst getAbortedReason = signal => signal.reason ?? new DOMException('This operation was aborted.', 'AbortError');\n\nexport default function pTimeout(promise, options) {\n\tconst {\n\t\tmilliseconds,\n\t\tfallback,\n\t\tmessage,\n\t\tcustomTimers = {setTimeout, clearTimeout},\n\t\tsignal,\n\t} = options;\n\n\tlet timer;\n\tlet abortHandler;\n\n\tconst wrappedPromise = new Promise((resolve, reject) => {\n\t\tif (typeof milliseconds !== 'number' || Math.sign(milliseconds) !== 1) {\n\t\t\tthrow new TypeError(`Expected \\`milliseconds\\` to be a positive number, got \\`${milliseconds}\\``);\n\t\t}\n\n\t\tif (signal?.aborted) {\n\t\t\treject(getAbortedReason(signal));\n\t\t\treturn;\n\t\t}\n\n\t\tif (signal) {\n\t\t\tabortHandler = () => {\n\t\t\t\treject(getAbortedReason(signal));\n\t\t\t};\n\n\t\t\tsignal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\t// Use .then() instead of async IIFE to preserve stack traces\n\t\t// eslint-disable-next-line promise/prefer-await-to-then, promise/prefer-catch\n\t\tpromise.then(resolve, reject);\n\n\t\tif (milliseconds === Number.POSITIVE_INFINITY) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We create the error outside of `setTimeout` to preserve the stack trace.\n\t\tconst timeoutError = new TimeoutError();\n\n\t\t// `.call(undefined, ...)` is needed for custom timers to avoid context issues\n\t\ttimer = customTimers.setTimeout.call(undefined, () => {\n\t\t\tif (fallback) {\n\t\t\t\ttry {\n\t\t\t\t\tresolve(fallback());\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (typeof promise.cancel === 'function') {\n\t\t\t\tpromise.cancel();\n\t\t\t}\n\n\t\t\tif (message === false) {\n\t\t\t\tresolve();\n\t\t\t} else if (message instanceof Error) {\n\t\t\t\treject(message);\n\t\t\t} else {\n\t\t\t\ttimeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;\n\t\t\t\treject(timeoutError);\n\t\t\t}\n\t\t}, milliseconds);\n\t});\n\n\t// eslint-disable-next-line promise/prefer-await-to-then\n\tconst cancelablePromise = wrappedPromise.finally(() => {\n\t\tcancelablePromise.clear();\n\t\tif (abortHandler && signal) {\n\t\t\tsignal.removeEventListener('abort', abortHandler);\n\t\t}\n\t});\n\n\tcancelablePromise.clear = () => {\n\t\t// `.call(undefined, ...)` is needed for custom timers to avoid context issues\n\t\tcustomTimers.clearTimeout.call(undefined, timer);\n\t\ttimer = undefined;\n\t};\n\n\treturn cancelablePromise;\n}\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAa,eAAb,MAAa,qBAAqB,MAAM;CACvC,OAAO;CAEP,YAAY,SAAS,SAAS;AAC7B,QAAM,SAAS,QAAQ;AACvB,QAAM,oBAAoB,MAAM,aAAa;;;AAI/C,MAAM,oBAAmB,WAAU,OAAO,UAAU,IAAI,aAAa,+BAA+B,aAAa;AAEjH,SAAwB,SAAS,SAAS,SAAS;CAClD,MAAM,EACL,cACA,UACA,SACA,eAAe;EAAC;EAAY;EAAa,EACzC,WACG;CAEJ,IAAI;CACJ,IAAI;CA2DJ,MAAM,oBAzDiB,IAAI,SAAS,SAAS,WAAW;AACvD,MAAI,OAAO,iBAAiB,YAAY,KAAK,KAAK,aAAa,KAAK,EACnE,OAAM,IAAI,UAAU,4DAA4D,aAAa,IAAI;AAGlG,MAAI,QAAQ,SAAS;AACpB,UAAO,iBAAiB,OAAO,CAAC;AAChC;;AAGD,MAAI,QAAQ;AACX,wBAAqB;AACpB,WAAO,iBAAiB,OAAO,CAAC;;AAGjC,UAAO,iBAAiB,SAAS,cAAc,EAAC,MAAM,MAAK,CAAC;;AAK7D,UAAQ,KAAK,SAAS,OAAO;AAE7B,MAAI,iBAAiB,OAAO,kBAC3B;EAID,MAAM,eAAe,IAAI,cAAc;AAGvC,UAAQ,aAAa,WAAW,KAAK,KAAA,SAAiB;AACrD,OAAI,UAAU;AACb,QAAI;AACH,aAAQ,UAAU,CAAC;aACX,OAAO;AACf,YAAO,MAAM;;AAGd;;AAGD,OAAI,OAAO,QAAQ,WAAW,WAC7B,SAAQ,QAAQ;AAGjB,OAAI,YAAY,MACf,UAAS;YACC,mBAAmB,MAC7B,QAAO,QAAQ;QACT;AACN,iBAAa,UAAU,WAAW,2BAA2B,aAAa;AAC1E,WAAO,aAAa;;KAEnB,aAAa;GACf,CAGuC,cAAc;AACtD,oBAAkB,OAAO;AACzB,MAAI,gBAAgB,OACnB,QAAO,oBAAoB,SAAS,aAAa;GAEjD;AAEF,mBAAkB,cAAc;AAE/B,eAAa,aAAa,KAAK,KAAA,GAAW,MAAM;AAChD,UAAQ,KAAA;;AAGT,QAAO"}
|
|
@@ -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
|