@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.js
CHANGED
|
@@ -9835,9 +9835,49 @@ function recordToolProtocolError(params) {
|
|
|
9835
9835
|
}
|
|
9836
9836
|
|
|
9837
9837
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
9838
|
+
var DEFAULT_TOOL_ABORT_GRACE_MS = 3e3;
|
|
9839
|
+
function settleToolWithinAbortGrace(input) {
|
|
9840
|
+
const { execution, signal, graceMs } = input;
|
|
9841
|
+
if (!signal) return execution;
|
|
9842
|
+
return new Promise((resolve, reject) => {
|
|
9843
|
+
let timer;
|
|
9844
|
+
const cleanup = () => {
|
|
9845
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
9846
|
+
signal.removeEventListener("abort", startGrace);
|
|
9847
|
+
};
|
|
9848
|
+
function startGrace() {
|
|
9849
|
+
timer = setTimeout(() => {
|
|
9850
|
+
cleanup();
|
|
9851
|
+
execution.catch(() => void 0);
|
|
9852
|
+
input.onAbandon?.();
|
|
9853
|
+
const error = new Error("Tool did not stop within the abort grace period; its late outcome is discarded.");
|
|
9854
|
+
error.name = "AbortError";
|
|
9855
|
+
reject(error);
|
|
9856
|
+
}, graceMs);
|
|
9857
|
+
}
|
|
9858
|
+
if (signal.aborted) startGrace();
|
|
9859
|
+
else signal.addEventListener("abort", startGrace, { once: true });
|
|
9860
|
+
execution.then(
|
|
9861
|
+
(value) => {
|
|
9862
|
+
cleanup();
|
|
9863
|
+
resolve(value);
|
|
9864
|
+
},
|
|
9865
|
+
(error) => {
|
|
9866
|
+
cleanup();
|
|
9867
|
+
reject(error);
|
|
9868
|
+
}
|
|
9869
|
+
);
|
|
9870
|
+
});
|
|
9871
|
+
}
|
|
9838
9872
|
async function executeRecoverableTool(input) {
|
|
9839
9873
|
const local = input.state.local;
|
|
9840
|
-
|
|
9874
|
+
const run = () => settleToolWithinAbortGrace({
|
|
9875
|
+
execution: input.execute(),
|
|
9876
|
+
signal: local?.signal,
|
|
9877
|
+
graceMs: input.abortGraceMs ?? DEFAULT_TOOL_ABORT_GRACE_MS,
|
|
9878
|
+
onAbandon: input.onAbandon
|
|
9879
|
+
});
|
|
9880
|
+
if (!local?.commitExecutionBoundary) return run();
|
|
9841
9881
|
if (local.executingToolCallId) {
|
|
9842
9882
|
if (local.executingToolCallId !== input.call.id) {
|
|
9843
9883
|
throw new RunRecoveryBlockedError("Pending tool identity does not match execution intent");
|
|
@@ -9850,7 +9890,7 @@ async function executeRecoverableTool(input) {
|
|
|
9850
9890
|
}
|
|
9851
9891
|
local.executingToolCallId = input.call.id;
|
|
9852
9892
|
await local.commitExecutionBoundary(input.state);
|
|
9853
|
-
const result = await
|
|
9893
|
+
const result = await run();
|
|
9854
9894
|
if (!result.success && isRunPauseSignal(local.signal)) {
|
|
9855
9895
|
const error = new Error("Tool execution paused before its outcome was confirmed");
|
|
9856
9896
|
error.name = "AbortError";
|
|
@@ -9970,7 +10010,9 @@ var ToolNode = class {
|
|
|
9970
10010
|
auditPort;
|
|
9971
10011
|
modelInputResolver;
|
|
9972
10012
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
10013
|
+
abortGraceMs;
|
|
9973
10014
|
constructor(dependencies) {
|
|
10015
|
+
this.abortGraceMs = dependencies.abortGraceMs;
|
|
9974
10016
|
this.toolRuntime = dependencies.toolRuntime;
|
|
9975
10017
|
this.observationPreview = dependencies.observationPreview;
|
|
9976
10018
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
@@ -10188,6 +10230,13 @@ var ToolNode = class {
|
|
|
10188
10230
|
state,
|
|
10189
10231
|
call,
|
|
10190
10232
|
context: prepared.toolContext,
|
|
10233
|
+
abortGraceMs: this.abortGraceMs,
|
|
10234
|
+
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", {
|
|
10235
|
+
toolName: execution.toolName,
|
|
10236
|
+
toolCallId: execution.toolCallId,
|
|
10237
|
+
conversationId: prepared.conversationId,
|
|
10238
|
+
turnId: prepared.turnId
|
|
10239
|
+
}),
|
|
10191
10240
|
execute: () => executeToolWithIdempotency({
|
|
10192
10241
|
idempotencyKey: execution.idempotencyKey,
|
|
10193
10242
|
inFlight: this.idempotencyInFlight,
|