@linnlabs/linnkit 0.44.0 → 0.46.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 +48 -0
- package/dist/cli.cjs +61 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +61 -8
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs +2 -1
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.js +2 -1
- package/dist/context-manager.js.map +1 -1
- package/dist/index.cjs +62 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +62 -8
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +61 -8
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +61 -8
- 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/graph-engine/types.d.cts +1 -3
- package/dist/runtime-kernel/graph-engine/types.d.ts +1 -3
- package/dist/runtime-kernel/tools/toolContextRuntime.d.cts +1 -1
- package/dist/runtime-kernel/tools/toolContextRuntime.d.ts +1 -1
- package/dist/runtime-kernel/tools/toolExecutionContext.d.cts +10 -0
- package/dist/runtime-kernel/tools/toolExecutionContext.d.ts +10 -0
- package/dist/runtime-kernel.cjs +62 -8
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.js +62 -8
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +62 -8
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +62 -8
- package/dist/testkit.js.map +1 -1
- package/docs/integration/agent-registration-guide.md +1 -1
- package/docs/integration/context-engineering.md +5 -5
- package/docs/integration/run-supervisor.md +1 -0
- package/docs/integration/tool-development-guide.md +4 -2
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
+
## [Unreleased]
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## [0.46.0] - 2026-11-26
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- `ToolExecutionContext.activeModelId`: the model that will receive this tool
|
|
24
|
+
result, set by ToolNode before each tool runs. It equals `modelId` until a
|
|
25
|
+
cloud quota fallback locks the run to the fallback model, and then names the
|
|
26
|
+
fallback model. Hosts deciding whether a tool result may carry images should
|
|
27
|
+
read it instead of `modelId`; otherwise a text-only fallback model gets an
|
|
28
|
+
image and the next LLM call fails input preflight. It is a runtime-reserved
|
|
29
|
+
key, so Host tool-context patches cannot set it.
|
|
30
|
+
|
|
31
|
+
### Removed
|
|
32
|
+
|
|
33
|
+
- `ExecutorLocalState.lastSuccessfulLlmModelId` and its `ExecutorLocalPatch`
|
|
34
|
+
key. The LLM stage still wrote it, but nothing has read it since 0.42.0.
|
|
35
|
+
Checkpoints saved by 0.45.0 and earlier that carry the field still load; the
|
|
36
|
+
value is dropped on load.
|
|
37
|
+
|
|
38
|
+
### Documentation
|
|
39
|
+
|
|
40
|
+
- Tool development guide §7.4 now spells out why the Host must decide about
|
|
41
|
+
returning images before the tool runs: once an image reaches history, every
|
|
42
|
+
later LLM call on a route without image input fails preflight.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## [0.45.0] - 2026-11-21
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
- Abort grace period for tools. After a pause or cancel signal, `ToolNode`
|
|
51
|
+
waits at most `abortGraceMs` (new optional `ToolNodeDependencies` field,
|
|
52
|
+
default 3000 ms) for the running tool to
|
|
53
|
+
finish. A tool that ignores the signal is then treated as an `AbortError`,
|
|
54
|
+
exactly like a tool that honoured it: a pause leaves the call for
|
|
55
|
+
reconciliation before continuing, a cancel settles it as cancelled. Its late
|
|
56
|
+
result is discarded and never reaches history. The deadline starts only when
|
|
57
|
+
the signal fires and does not limit normal tool run time. Previously a
|
|
58
|
+
pause could stay unsettled (`status=paused`, no `pausedAt`) for as long as
|
|
59
|
+
such a tool ran, holding the conversation's concurrency slot.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
15
63
|
## [0.44.0] - 2026-11-18
|
|
16
64
|
|
|
17
65
|
### Added
|
package/dist/cli.cjs
CHANGED
|
@@ -5051,13 +5051,11 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5051
5051
|
"llmCallStartedAt",
|
|
5052
5052
|
"llmResp",
|
|
5053
5053
|
"llmCallDurationMs",
|
|
5054
|
-
"executorLocalPatch",
|
|
5055
5054
|
"contextUsage"
|
|
5056
5055
|
],
|
|
5057
5056
|
async run(ctx) {
|
|
5058
5057
|
let cloudQuotaFallbackAppliedModelId;
|
|
5059
5058
|
let modelFallbackAudit;
|
|
5060
|
-
let lastSuccessfulLlmModelId;
|
|
5061
5059
|
let contextUsage;
|
|
5062
5060
|
const modelFallbackRejections = [];
|
|
5063
5061
|
const promptBudget = ctx.promptBudget;
|
|
@@ -5078,8 +5076,7 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5078
5076
|
onCloudQuotaFallbackApplied(fallbackModelId) {
|
|
5079
5077
|
cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
|
|
5080
5078
|
},
|
|
5081
|
-
onLlmAttemptSucceeded(
|
|
5082
|
-
lastSuccessfulLlmModelId = readNonEmptyString3(activeModelId);
|
|
5079
|
+
onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
|
|
5083
5080
|
contextUsage = attemptContextUsage;
|
|
5084
5081
|
},
|
|
5085
5082
|
onModelFallbackApplied(info) {
|
|
@@ -5180,7 +5177,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5180
5177
|
llmCallStartedAt,
|
|
5181
5178
|
llmResp,
|
|
5182
5179
|
llmCallDurationMs,
|
|
5183
|
-
executorLocalPatch: lastSuccessfulLlmModelId ? { lastSuccessfulLlmModelId } : void 0,
|
|
5184
5180
|
contextUsage
|
|
5185
5181
|
};
|
|
5186
5182
|
}
|
|
@@ -8362,6 +8358,12 @@ function parseToolArgs(call) {
|
|
|
8362
8358
|
};
|
|
8363
8359
|
}
|
|
8364
8360
|
}
|
|
8361
|
+
function readRunLockedModelId(local) {
|
|
8362
|
+
const executorLocal = local.executorLocal;
|
|
8363
|
+
if (!isRecord9(executorLocal)) return void 0;
|
|
8364
|
+
const lockedModelId = executorLocal.runLockedModelId;
|
|
8365
|
+
return typeof lockedModelId === "string" && lockedModelId.trim() ? lockedModelId : void 0;
|
|
8366
|
+
}
|
|
8365
8367
|
function prepareToolNodeContext(state) {
|
|
8366
8368
|
const local = state.local || {};
|
|
8367
8369
|
const toolContext = isRecord9(local.toolContext) ? local.toolContext : {};
|
|
@@ -8379,6 +8381,7 @@ function prepareToolNodeContext(state) {
|
|
|
8379
8381
|
}
|
|
8380
8382
|
});
|
|
8381
8383
|
attachWorkingHistoryView({ state, toolContext });
|
|
8384
|
+
toolContext.activeModelId = readRunLockedModelId(local) ?? toolContext.modelId;
|
|
8382
8385
|
return {
|
|
8383
8386
|
state,
|
|
8384
8387
|
local,
|
|
@@ -8621,9 +8624,49 @@ function recordToolProtocolError(params) {
|
|
|
8621
8624
|
}
|
|
8622
8625
|
|
|
8623
8626
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
8627
|
+
var DEFAULT_TOOL_ABORT_GRACE_MS = 3e3;
|
|
8628
|
+
function settleToolWithinAbortGrace(input) {
|
|
8629
|
+
const { execution, signal, graceMs } = input;
|
|
8630
|
+
if (!signal) return execution;
|
|
8631
|
+
return new Promise((resolve5, reject) => {
|
|
8632
|
+
let timer;
|
|
8633
|
+
const cleanup = () => {
|
|
8634
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
8635
|
+
signal.removeEventListener("abort", startGrace);
|
|
8636
|
+
};
|
|
8637
|
+
function startGrace() {
|
|
8638
|
+
timer = setTimeout(() => {
|
|
8639
|
+
cleanup();
|
|
8640
|
+
execution.catch(() => void 0);
|
|
8641
|
+
input.onAbandon?.();
|
|
8642
|
+
const error = new Error("Tool did not stop within the abort grace period; its late outcome is discarded.");
|
|
8643
|
+
error.name = "AbortError";
|
|
8644
|
+
reject(error);
|
|
8645
|
+
}, graceMs);
|
|
8646
|
+
}
|
|
8647
|
+
if (signal.aborted) startGrace();
|
|
8648
|
+
else signal.addEventListener("abort", startGrace, { once: true });
|
|
8649
|
+
execution.then(
|
|
8650
|
+
(value) => {
|
|
8651
|
+
cleanup();
|
|
8652
|
+
resolve5(value);
|
|
8653
|
+
},
|
|
8654
|
+
(error) => {
|
|
8655
|
+
cleanup();
|
|
8656
|
+
reject(error);
|
|
8657
|
+
}
|
|
8658
|
+
);
|
|
8659
|
+
});
|
|
8660
|
+
}
|
|
8624
8661
|
async function executeRecoverableTool(input) {
|
|
8625
8662
|
const local = input.state.local;
|
|
8626
|
-
|
|
8663
|
+
const run = () => settleToolWithinAbortGrace({
|
|
8664
|
+
execution: input.execute(),
|
|
8665
|
+
signal: local?.signal,
|
|
8666
|
+
graceMs: input.abortGraceMs ?? DEFAULT_TOOL_ABORT_GRACE_MS,
|
|
8667
|
+
onAbandon: input.onAbandon
|
|
8668
|
+
});
|
|
8669
|
+
if (!local?.commitExecutionBoundary) return run();
|
|
8627
8670
|
if (local.executingToolCallId) {
|
|
8628
8671
|
if (local.executingToolCallId !== input.call.id) {
|
|
8629
8672
|
throw new RunRecoveryBlockedError("Pending tool identity does not match execution intent");
|
|
@@ -8636,7 +8679,7 @@ async function executeRecoverableTool(input) {
|
|
|
8636
8679
|
}
|
|
8637
8680
|
local.executingToolCallId = input.call.id;
|
|
8638
8681
|
await local.commitExecutionBoundary(input.state);
|
|
8639
|
-
const result = await
|
|
8682
|
+
const result = await run();
|
|
8640
8683
|
if (!result.success && isRunPauseSignal(local.signal)) {
|
|
8641
8684
|
const error = new Error("Tool execution paused before its outcome was confirmed");
|
|
8642
8685
|
error.name = "AbortError";
|
|
@@ -8756,7 +8799,9 @@ var ToolNode = class {
|
|
|
8756
8799
|
auditPort;
|
|
8757
8800
|
modelInputResolver;
|
|
8758
8801
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
8802
|
+
abortGraceMs;
|
|
8759
8803
|
constructor(dependencies) {
|
|
8804
|
+
this.abortGraceMs = dependencies.abortGraceMs;
|
|
8760
8805
|
this.toolRuntime = dependencies.toolRuntime;
|
|
8761
8806
|
this.observationPreview = dependencies.observationPreview;
|
|
8762
8807
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
@@ -8974,6 +9019,13 @@ var ToolNode = class {
|
|
|
8974
9019
|
state,
|
|
8975
9020
|
call,
|
|
8976
9021
|
context: prepared.toolContext,
|
|
9022
|
+
abortGraceMs: this.abortGraceMs,
|
|
9023
|
+
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", {
|
|
9024
|
+
toolName: execution.toolName,
|
|
9025
|
+
toolCallId: execution.toolCallId,
|
|
9026
|
+
conversationId: prepared.conversationId,
|
|
9027
|
+
turnId: prepared.turnId
|
|
9028
|
+
}),
|
|
8977
9029
|
execute: () => executeToolWithIdempotency({
|
|
8978
9030
|
idempotencyKey: execution.idempotencyKey,
|
|
8979
9031
|
inFlight: this.idempotencyInFlight,
|
|
@@ -9595,6 +9647,7 @@ var executor = zod.z.object({
|
|
|
9595
9647
|
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
9596
9648
|
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
9597
9649
|
runLockedModelId: zod.z.string().optional(),
|
|
9650
|
+
// 0.45 及更早的 checkpoint 可能带这个已删除字段;照常接受,读入时丢弃。
|
|
9598
9651
|
lastSuccessfulLlmModelId: zod.z.string().optional(),
|
|
9599
9652
|
llmInvocationKind: zod.z.enum(["user_initiated", "continuation"]).optional(),
|
|
9600
9653
|
llmInvocationCount: counter.optional(),
|
|
@@ -9604,7 +9657,7 @@ var executor = zod.z.object({
|
|
|
9604
9657
|
committedCount: counter,
|
|
9605
9658
|
lastCommittedFingerprint: zod.z.string().optional()
|
|
9606
9659
|
}).strict().optional()
|
|
9607
|
-
}).strict();
|
|
9660
|
+
}).strict().transform(({ lastSuccessfulLlmModelId: _retired, ...state }) => state);
|
|
9608
9661
|
var checkpoint = zod.z.object({
|
|
9609
9662
|
nodeId: zod.z.string().min(1),
|
|
9610
9663
|
schemaVersion: zod.z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|