@linnlabs/linnkit 0.44.0 → 0.45.0
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/CHANGELOG.md +17 -0
- package/dist/cli.cjs +51 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +51 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +51 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -2
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +51 -2
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +51 -2
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +3 -0
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +3 -0
- package/dist/runtime-kernel.cjs +51 -2
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.js +51 -2
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +51 -2
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +51 -2
- package/dist/testkit.js.map +1 -1
- package/docs/integration/run-supervisor.md +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9837,9 +9837,49 @@ function recordToolProtocolError(params) {
|
|
|
9837
9837
|
}
|
|
9838
9838
|
|
|
9839
9839
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
9840
|
+
var DEFAULT_TOOL_ABORT_GRACE_MS = 3e3;
|
|
9841
|
+
function settleToolWithinAbortGrace(input) {
|
|
9842
|
+
const { execution, signal, graceMs } = input;
|
|
9843
|
+
if (!signal) return execution;
|
|
9844
|
+
return new Promise((resolve, reject) => {
|
|
9845
|
+
let timer;
|
|
9846
|
+
const cleanup = () => {
|
|
9847
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
9848
|
+
signal.removeEventListener("abort", startGrace);
|
|
9849
|
+
};
|
|
9850
|
+
function startGrace() {
|
|
9851
|
+
timer = setTimeout(() => {
|
|
9852
|
+
cleanup();
|
|
9853
|
+
execution.catch(() => void 0);
|
|
9854
|
+
input.onAbandon?.();
|
|
9855
|
+
const error = new Error("Tool did not stop within the abort grace period; its late outcome is discarded.");
|
|
9856
|
+
error.name = "AbortError";
|
|
9857
|
+
reject(error);
|
|
9858
|
+
}, graceMs);
|
|
9859
|
+
}
|
|
9860
|
+
if (signal.aborted) startGrace();
|
|
9861
|
+
else signal.addEventListener("abort", startGrace, { once: true });
|
|
9862
|
+
execution.then(
|
|
9863
|
+
(value) => {
|
|
9864
|
+
cleanup();
|
|
9865
|
+
resolve(value);
|
|
9866
|
+
},
|
|
9867
|
+
(error) => {
|
|
9868
|
+
cleanup();
|
|
9869
|
+
reject(error);
|
|
9870
|
+
}
|
|
9871
|
+
);
|
|
9872
|
+
});
|
|
9873
|
+
}
|
|
9840
9874
|
async function executeRecoverableTool(input) {
|
|
9841
9875
|
const local = input.state.local;
|
|
9842
|
-
|
|
9876
|
+
const run = () => settleToolWithinAbortGrace({
|
|
9877
|
+
execution: input.execute(),
|
|
9878
|
+
signal: local?.signal,
|
|
9879
|
+
graceMs: input.abortGraceMs ?? DEFAULT_TOOL_ABORT_GRACE_MS,
|
|
9880
|
+
onAbandon: input.onAbandon
|
|
9881
|
+
});
|
|
9882
|
+
if (!local?.commitExecutionBoundary) return run();
|
|
9843
9883
|
if (local.executingToolCallId) {
|
|
9844
9884
|
if (local.executingToolCallId !== input.call.id) {
|
|
9845
9885
|
throw new RunRecoveryBlockedError("Pending tool identity does not match execution intent");
|
|
@@ -9852,7 +9892,7 @@ async function executeRecoverableTool(input) {
|
|
|
9852
9892
|
}
|
|
9853
9893
|
local.executingToolCallId = input.call.id;
|
|
9854
9894
|
await local.commitExecutionBoundary(input.state);
|
|
9855
|
-
const result = await
|
|
9895
|
+
const result = await run();
|
|
9856
9896
|
if (!result.success && isRunPauseSignal(local.signal)) {
|
|
9857
9897
|
const error = new Error("Tool execution paused before its outcome was confirmed");
|
|
9858
9898
|
error.name = "AbortError";
|
|
@@ -9972,7 +10012,9 @@ var ToolNode = class {
|
|
|
9972
10012
|
auditPort;
|
|
9973
10013
|
modelInputResolver;
|
|
9974
10014
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
10015
|
+
abortGraceMs;
|
|
9975
10016
|
constructor(dependencies) {
|
|
10017
|
+
this.abortGraceMs = dependencies.abortGraceMs;
|
|
9976
10018
|
this.toolRuntime = dependencies.toolRuntime;
|
|
9977
10019
|
this.observationPreview = dependencies.observationPreview;
|
|
9978
10020
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
@@ -10190,6 +10232,13 @@ var ToolNode = class {
|
|
|
10190
10232
|
state,
|
|
10191
10233
|
call,
|
|
10192
10234
|
context: prepared.toolContext,
|
|
10235
|
+
abortGraceMs: this.abortGraceMs,
|
|
10236
|
+
onAbandon: () => logger11.warn("[ToolNode] \u5DE5\u5177\u672A\u5728\u505C\u6B62\u671F\u9650\u5185\u7ED3\u675F\uFF0C\u6309\u4E2D\u65AD\u5904\u7406\u5E76\u4E22\u5F03\u8FDF\u5230\u7ED3\u679C", {
|
|
10237
|
+
toolName: execution.toolName,
|
|
10238
|
+
toolCallId: execution.toolCallId,
|
|
10239
|
+
conversationId: prepared.conversationId,
|
|
10240
|
+
turnId: prepared.turnId
|
|
10241
|
+
}),
|
|
10193
10242
|
execute: () => executeToolWithIdempotency({
|
|
10194
10243
|
idempotencyKey: execution.idempotencyKey,
|
|
10195
10244
|
inFlight: this.idempotencyInFlight,
|