@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
|
@@ -14,6 +14,8 @@ interface ToolNodeDependencies {
|
|
|
14
14
|
telemetryPort?: TelemetryPort;
|
|
15
15
|
auditPort?: AuditPort;
|
|
16
16
|
modelInputResolver?: ToolModelInputResolverPort;
|
|
17
|
+
/** 停止信号发出后等工具自行结束的期限;默认 3 秒,超时按中断处理并丢弃迟到结果。 */
|
|
18
|
+
abortGraceMs?: number;
|
|
17
19
|
}
|
|
18
20
|
declare class ToolNode implements GraphNode {
|
|
19
21
|
id: string;
|
|
@@ -23,6 +25,7 @@ declare class ToolNode implements GraphNode {
|
|
|
23
25
|
private readonly auditPort;
|
|
24
26
|
private readonly modelInputResolver?;
|
|
25
27
|
private readonly idempotencyInFlight;
|
|
28
|
+
private readonly abortGraceMs?;
|
|
26
29
|
constructor(dependencies: ToolNodeDependencies);
|
|
27
30
|
/**
|
|
28
31
|
* B2-engine Batch 2: 上报 tool_call 事件到宿主侧 TelemetryPort。
|
|
@@ -14,6 +14,8 @@ interface ToolNodeDependencies {
|
|
|
14
14
|
telemetryPort?: TelemetryPort;
|
|
15
15
|
auditPort?: AuditPort;
|
|
16
16
|
modelInputResolver?: ToolModelInputResolverPort;
|
|
17
|
+
/** 停止信号发出后等工具自行结束的期限;默认 3 秒,超时按中断处理并丢弃迟到结果。 */
|
|
18
|
+
abortGraceMs?: number;
|
|
17
19
|
}
|
|
18
20
|
declare class ToolNode implements GraphNode {
|
|
19
21
|
id: string;
|
|
@@ -23,6 +25,7 @@ declare class ToolNode implements GraphNode {
|
|
|
23
25
|
private readonly auditPort;
|
|
24
26
|
private readonly modelInputResolver?;
|
|
25
27
|
private readonly idempotencyInFlight;
|
|
28
|
+
private readonly abortGraceMs?;
|
|
26
29
|
constructor(dependencies: ToolNodeDependencies);
|
|
27
30
|
/**
|
|
28
31
|
* B2-engine Batch 2: 上报 tool_call 事件到宿主侧 TelemetryPort。
|
package/dist/runtime-kernel.cjs
CHANGED
|
@@ -8805,9 +8805,49 @@ function recordToolProtocolError(params) {
|
|
|
8805
8805
|
}
|
|
8806
8806
|
|
|
8807
8807
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
8808
|
+
var DEFAULT_TOOL_ABORT_GRACE_MS = 3e3;
|
|
8809
|
+
function settleToolWithinAbortGrace(input) {
|
|
8810
|
+
const { execution, signal, graceMs } = input;
|
|
8811
|
+
if (!signal) return execution;
|
|
8812
|
+
return new Promise((resolve, reject) => {
|
|
8813
|
+
let timer;
|
|
8814
|
+
const cleanup = () => {
|
|
8815
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
8816
|
+
signal.removeEventListener("abort", startGrace);
|
|
8817
|
+
};
|
|
8818
|
+
function startGrace() {
|
|
8819
|
+
timer = setTimeout(() => {
|
|
8820
|
+
cleanup();
|
|
8821
|
+
execution.catch(() => void 0);
|
|
8822
|
+
input.onAbandon?.();
|
|
8823
|
+
const error = new Error("Tool did not stop within the abort grace period; its late outcome is discarded.");
|
|
8824
|
+
error.name = "AbortError";
|
|
8825
|
+
reject(error);
|
|
8826
|
+
}, graceMs);
|
|
8827
|
+
}
|
|
8828
|
+
if (signal.aborted) startGrace();
|
|
8829
|
+
else signal.addEventListener("abort", startGrace, { once: true });
|
|
8830
|
+
execution.then(
|
|
8831
|
+
(value) => {
|
|
8832
|
+
cleanup();
|
|
8833
|
+
resolve(value);
|
|
8834
|
+
},
|
|
8835
|
+
(error) => {
|
|
8836
|
+
cleanup();
|
|
8837
|
+
reject(error);
|
|
8838
|
+
}
|
|
8839
|
+
);
|
|
8840
|
+
});
|
|
8841
|
+
}
|
|
8808
8842
|
async function executeRecoverableTool(input) {
|
|
8809
8843
|
const local = input.state.local;
|
|
8810
|
-
|
|
8844
|
+
const run = () => settleToolWithinAbortGrace({
|
|
8845
|
+
execution: input.execute(),
|
|
8846
|
+
signal: local?.signal,
|
|
8847
|
+
graceMs: input.abortGraceMs ?? DEFAULT_TOOL_ABORT_GRACE_MS,
|
|
8848
|
+
onAbandon: input.onAbandon
|
|
8849
|
+
});
|
|
8850
|
+
if (!local?.commitExecutionBoundary) return run();
|
|
8811
8851
|
if (local.executingToolCallId) {
|
|
8812
8852
|
if (local.executingToolCallId !== input.call.id) {
|
|
8813
8853
|
throw new RunRecoveryBlockedError("Pending tool identity does not match execution intent");
|
|
@@ -8820,7 +8860,7 @@ async function executeRecoverableTool(input) {
|
|
|
8820
8860
|
}
|
|
8821
8861
|
local.executingToolCallId = input.call.id;
|
|
8822
8862
|
await local.commitExecutionBoundary(input.state);
|
|
8823
|
-
const result = await
|
|
8863
|
+
const result = await run();
|
|
8824
8864
|
if (!result.success && isRunPauseSignal(local.signal)) {
|
|
8825
8865
|
const error = new Error("Tool execution paused before its outcome was confirmed");
|
|
8826
8866
|
error.name = "AbortError";
|
|
@@ -8940,7 +8980,9 @@ var ToolNode = class {
|
|
|
8940
8980
|
auditPort;
|
|
8941
8981
|
modelInputResolver;
|
|
8942
8982
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
8983
|
+
abortGraceMs;
|
|
8943
8984
|
constructor(dependencies) {
|
|
8985
|
+
this.abortGraceMs = dependencies.abortGraceMs;
|
|
8944
8986
|
this.toolRuntime = dependencies.toolRuntime;
|
|
8945
8987
|
this.observationPreview = dependencies.observationPreview;
|
|
8946
8988
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
@@ -9158,6 +9200,13 @@ var ToolNode = class {
|
|
|
9158
9200
|
state,
|
|
9159
9201
|
call,
|
|
9160
9202
|
context: prepared.toolContext,
|
|
9203
|
+
abortGraceMs: this.abortGraceMs,
|
|
9204
|
+
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", {
|
|
9205
|
+
toolName: execution.toolName,
|
|
9206
|
+
toolCallId: execution.toolCallId,
|
|
9207
|
+
conversationId: prepared.conversationId,
|
|
9208
|
+
turnId: prepared.turnId
|
|
9209
|
+
}),
|
|
9161
9210
|
execute: () => executeToolWithIdempotency({
|
|
9162
9211
|
idempotencyKey: execution.idempotencyKey,
|
|
9163
9212
|
inFlight: this.idempotencyInFlight,
|