@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/dist/cli.js
CHANGED
|
@@ -5048,13 +5048,11 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5048
5048
|
"llmCallStartedAt",
|
|
5049
5049
|
"llmResp",
|
|
5050
5050
|
"llmCallDurationMs",
|
|
5051
|
-
"executorLocalPatch",
|
|
5052
5051
|
"contextUsage"
|
|
5053
5052
|
],
|
|
5054
5053
|
async run(ctx) {
|
|
5055
5054
|
let cloudQuotaFallbackAppliedModelId;
|
|
5056
5055
|
let modelFallbackAudit;
|
|
5057
|
-
let lastSuccessfulLlmModelId;
|
|
5058
5056
|
let contextUsage;
|
|
5059
5057
|
const modelFallbackRejections = [];
|
|
5060
5058
|
const promptBudget = ctx.promptBudget;
|
|
@@ -5075,8 +5073,7 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5075
5073
|
onCloudQuotaFallbackApplied(fallbackModelId) {
|
|
5076
5074
|
cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
|
|
5077
5075
|
},
|
|
5078
|
-
onLlmAttemptSucceeded(
|
|
5079
|
-
lastSuccessfulLlmModelId = readNonEmptyString3(activeModelId);
|
|
5076
|
+
onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
|
|
5080
5077
|
contextUsage = attemptContextUsage;
|
|
5081
5078
|
},
|
|
5082
5079
|
onModelFallbackApplied(info) {
|
|
@@ -5177,7 +5174,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5177
5174
|
llmCallStartedAt,
|
|
5178
5175
|
llmResp,
|
|
5179
5176
|
llmCallDurationMs,
|
|
5180
|
-
executorLocalPatch: lastSuccessfulLlmModelId ? { lastSuccessfulLlmModelId } : void 0,
|
|
5181
5177
|
contextUsage
|
|
5182
5178
|
};
|
|
5183
5179
|
}
|
|
@@ -8359,6 +8355,12 @@ function parseToolArgs(call) {
|
|
|
8359
8355
|
};
|
|
8360
8356
|
}
|
|
8361
8357
|
}
|
|
8358
|
+
function readRunLockedModelId(local) {
|
|
8359
|
+
const executorLocal = local.executorLocal;
|
|
8360
|
+
if (!isRecord9(executorLocal)) return void 0;
|
|
8361
|
+
const lockedModelId = executorLocal.runLockedModelId;
|
|
8362
|
+
return typeof lockedModelId === "string" && lockedModelId.trim() ? lockedModelId : void 0;
|
|
8363
|
+
}
|
|
8362
8364
|
function prepareToolNodeContext(state) {
|
|
8363
8365
|
const local = state.local || {};
|
|
8364
8366
|
const toolContext = isRecord9(local.toolContext) ? local.toolContext : {};
|
|
@@ -8376,6 +8378,7 @@ function prepareToolNodeContext(state) {
|
|
|
8376
8378
|
}
|
|
8377
8379
|
});
|
|
8378
8380
|
attachWorkingHistoryView({ state, toolContext });
|
|
8381
|
+
toolContext.activeModelId = readRunLockedModelId(local) ?? toolContext.modelId;
|
|
8379
8382
|
return {
|
|
8380
8383
|
state,
|
|
8381
8384
|
local,
|
|
@@ -8618,9 +8621,49 @@ function recordToolProtocolError(params) {
|
|
|
8618
8621
|
}
|
|
8619
8622
|
|
|
8620
8623
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
8624
|
+
var DEFAULT_TOOL_ABORT_GRACE_MS = 3e3;
|
|
8625
|
+
function settleToolWithinAbortGrace(input) {
|
|
8626
|
+
const { execution, signal, graceMs } = input;
|
|
8627
|
+
if (!signal) return execution;
|
|
8628
|
+
return new Promise((resolve5, reject) => {
|
|
8629
|
+
let timer;
|
|
8630
|
+
const cleanup = () => {
|
|
8631
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
8632
|
+
signal.removeEventListener("abort", startGrace);
|
|
8633
|
+
};
|
|
8634
|
+
function startGrace() {
|
|
8635
|
+
timer = setTimeout(() => {
|
|
8636
|
+
cleanup();
|
|
8637
|
+
execution.catch(() => void 0);
|
|
8638
|
+
input.onAbandon?.();
|
|
8639
|
+
const error = new Error("Tool did not stop within the abort grace period; its late outcome is discarded.");
|
|
8640
|
+
error.name = "AbortError";
|
|
8641
|
+
reject(error);
|
|
8642
|
+
}, graceMs);
|
|
8643
|
+
}
|
|
8644
|
+
if (signal.aborted) startGrace();
|
|
8645
|
+
else signal.addEventListener("abort", startGrace, { once: true });
|
|
8646
|
+
execution.then(
|
|
8647
|
+
(value) => {
|
|
8648
|
+
cleanup();
|
|
8649
|
+
resolve5(value);
|
|
8650
|
+
},
|
|
8651
|
+
(error) => {
|
|
8652
|
+
cleanup();
|
|
8653
|
+
reject(error);
|
|
8654
|
+
}
|
|
8655
|
+
);
|
|
8656
|
+
});
|
|
8657
|
+
}
|
|
8621
8658
|
async function executeRecoverableTool(input) {
|
|
8622
8659
|
const local = input.state.local;
|
|
8623
|
-
|
|
8660
|
+
const run = () => settleToolWithinAbortGrace({
|
|
8661
|
+
execution: input.execute(),
|
|
8662
|
+
signal: local?.signal,
|
|
8663
|
+
graceMs: input.abortGraceMs ?? DEFAULT_TOOL_ABORT_GRACE_MS,
|
|
8664
|
+
onAbandon: input.onAbandon
|
|
8665
|
+
});
|
|
8666
|
+
if (!local?.commitExecutionBoundary) return run();
|
|
8624
8667
|
if (local.executingToolCallId) {
|
|
8625
8668
|
if (local.executingToolCallId !== input.call.id) {
|
|
8626
8669
|
throw new RunRecoveryBlockedError("Pending tool identity does not match execution intent");
|
|
@@ -8633,7 +8676,7 @@ async function executeRecoverableTool(input) {
|
|
|
8633
8676
|
}
|
|
8634
8677
|
local.executingToolCallId = input.call.id;
|
|
8635
8678
|
await local.commitExecutionBoundary(input.state);
|
|
8636
|
-
const result = await
|
|
8679
|
+
const result = await run();
|
|
8637
8680
|
if (!result.success && isRunPauseSignal(local.signal)) {
|
|
8638
8681
|
const error = new Error("Tool execution paused before its outcome was confirmed");
|
|
8639
8682
|
error.name = "AbortError";
|
|
@@ -8753,7 +8796,9 @@ var ToolNode = class {
|
|
|
8753
8796
|
auditPort;
|
|
8754
8797
|
modelInputResolver;
|
|
8755
8798
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
8799
|
+
abortGraceMs;
|
|
8756
8800
|
constructor(dependencies) {
|
|
8801
|
+
this.abortGraceMs = dependencies.abortGraceMs;
|
|
8757
8802
|
this.toolRuntime = dependencies.toolRuntime;
|
|
8758
8803
|
this.observationPreview = dependencies.observationPreview;
|
|
8759
8804
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
@@ -8971,6 +9016,13 @@ var ToolNode = class {
|
|
|
8971
9016
|
state,
|
|
8972
9017
|
call,
|
|
8973
9018
|
context: prepared.toolContext,
|
|
9019
|
+
abortGraceMs: this.abortGraceMs,
|
|
9020
|
+
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", {
|
|
9021
|
+
toolName: execution.toolName,
|
|
9022
|
+
toolCallId: execution.toolCallId,
|
|
9023
|
+
conversationId: prepared.conversationId,
|
|
9024
|
+
turnId: prepared.turnId
|
|
9025
|
+
}),
|
|
8974
9026
|
execute: () => executeToolWithIdempotency({
|
|
8975
9027
|
idempotencyKey: execution.idempotencyKey,
|
|
8976
9028
|
inFlight: this.idempotencyInFlight,
|
|
@@ -9592,6 +9644,7 @@ var executor = z.object({
|
|
|
9592
9644
|
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
9593
9645
|
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
9594
9646
|
runLockedModelId: z.string().optional(),
|
|
9647
|
+
// 0.45 及更早的 checkpoint 可能带这个已删除字段;照常接受,读入时丢弃。
|
|
9595
9648
|
lastSuccessfulLlmModelId: z.string().optional(),
|
|
9596
9649
|
llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
|
|
9597
9650
|
llmInvocationCount: counter.optional(),
|
|
@@ -9601,7 +9654,7 @@ var executor = z.object({
|
|
|
9601
9654
|
committedCount: counter,
|
|
9602
9655
|
lastCommittedFingerprint: z.string().optional()
|
|
9603
9656
|
}).strict().optional()
|
|
9604
|
-
}).strict();
|
|
9657
|
+
}).strict().transform(({ lastSuccessfulLlmModelId: _retired, ...state }) => state);
|
|
9605
9658
|
var checkpoint = z.object({
|
|
9606
9659
|
nodeId: z.string().min(1),
|
|
9607
9660
|
schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|