@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/index.js
CHANGED
|
@@ -6198,13 +6198,11 @@ function createExecuteLlmStage(dependencies) {
|
|
|
6198
6198
|
"llmCallStartedAt",
|
|
6199
6199
|
"llmResp",
|
|
6200
6200
|
"llmCallDurationMs",
|
|
6201
|
-
"executorLocalPatch",
|
|
6202
6201
|
"contextUsage"
|
|
6203
6202
|
],
|
|
6204
6203
|
async run(ctx) {
|
|
6205
6204
|
let cloudQuotaFallbackAppliedModelId;
|
|
6206
6205
|
let modelFallbackAudit;
|
|
6207
|
-
let lastSuccessfulLlmModelId;
|
|
6208
6206
|
let contextUsage;
|
|
6209
6207
|
const modelFallbackRejections = [];
|
|
6210
6208
|
const promptBudget = ctx.promptBudget;
|
|
@@ -6225,8 +6223,7 @@ function createExecuteLlmStage(dependencies) {
|
|
|
6225
6223
|
onCloudQuotaFallbackApplied(fallbackModelId) {
|
|
6226
6224
|
cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
|
|
6227
6225
|
},
|
|
6228
|
-
onLlmAttemptSucceeded(
|
|
6229
|
-
lastSuccessfulLlmModelId = readNonEmptyString3(activeModelId);
|
|
6226
|
+
onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
|
|
6230
6227
|
contextUsage = attemptContextUsage;
|
|
6231
6228
|
},
|
|
6232
6229
|
onModelFallbackApplied(info) {
|
|
@@ -6327,7 +6324,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
6327
6324
|
llmCallStartedAt,
|
|
6328
6325
|
llmResp,
|
|
6329
6326
|
llmCallDurationMs,
|
|
6330
|
-
executorLocalPatch: lastSuccessfulLlmModelId ? { lastSuccessfulLlmModelId } : void 0,
|
|
6331
6327
|
contextUsage
|
|
6332
6328
|
};
|
|
6333
6329
|
}
|
|
@@ -9236,6 +9232,7 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
|
|
|
9236
9232
|
"conversationView",
|
|
9237
9233
|
"userQuery",
|
|
9238
9234
|
"modelId",
|
|
9235
|
+
"activeModelId",
|
|
9239
9236
|
"conversationId",
|
|
9240
9237
|
"turnId",
|
|
9241
9238
|
"runId",
|
|
@@ -9569,6 +9566,12 @@ function parseToolArgs(call) {
|
|
|
9569
9566
|
};
|
|
9570
9567
|
}
|
|
9571
9568
|
}
|
|
9569
|
+
function readRunLockedModelId(local) {
|
|
9570
|
+
const executorLocal = local.executorLocal;
|
|
9571
|
+
if (!isRecord9(executorLocal)) return void 0;
|
|
9572
|
+
const lockedModelId = executorLocal.runLockedModelId;
|
|
9573
|
+
return typeof lockedModelId === "string" && lockedModelId.trim() ? lockedModelId : void 0;
|
|
9574
|
+
}
|
|
9572
9575
|
function prepareToolNodeContext(state) {
|
|
9573
9576
|
const local = state.local || {};
|
|
9574
9577
|
const toolContext = isRecord9(local.toolContext) ? local.toolContext : {};
|
|
@@ -9586,6 +9589,7 @@ function prepareToolNodeContext(state) {
|
|
|
9586
9589
|
}
|
|
9587
9590
|
});
|
|
9588
9591
|
attachWorkingHistoryView({ state, toolContext });
|
|
9592
|
+
toolContext.activeModelId = readRunLockedModelId(local) ?? toolContext.modelId;
|
|
9589
9593
|
return {
|
|
9590
9594
|
state,
|
|
9591
9595
|
local,
|
|
@@ -9835,9 +9839,49 @@ function recordToolProtocolError(params) {
|
|
|
9835
9839
|
}
|
|
9836
9840
|
|
|
9837
9841
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
9842
|
+
var DEFAULT_TOOL_ABORT_GRACE_MS = 3e3;
|
|
9843
|
+
function settleToolWithinAbortGrace(input) {
|
|
9844
|
+
const { execution, signal, graceMs } = input;
|
|
9845
|
+
if (!signal) return execution;
|
|
9846
|
+
return new Promise((resolve, reject) => {
|
|
9847
|
+
let timer;
|
|
9848
|
+
const cleanup = () => {
|
|
9849
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
9850
|
+
signal.removeEventListener("abort", startGrace);
|
|
9851
|
+
};
|
|
9852
|
+
function startGrace() {
|
|
9853
|
+
timer = setTimeout(() => {
|
|
9854
|
+
cleanup();
|
|
9855
|
+
execution.catch(() => void 0);
|
|
9856
|
+
input.onAbandon?.();
|
|
9857
|
+
const error = new Error("Tool did not stop within the abort grace period; its late outcome is discarded.");
|
|
9858
|
+
error.name = "AbortError";
|
|
9859
|
+
reject(error);
|
|
9860
|
+
}, graceMs);
|
|
9861
|
+
}
|
|
9862
|
+
if (signal.aborted) startGrace();
|
|
9863
|
+
else signal.addEventListener("abort", startGrace, { once: true });
|
|
9864
|
+
execution.then(
|
|
9865
|
+
(value) => {
|
|
9866
|
+
cleanup();
|
|
9867
|
+
resolve(value);
|
|
9868
|
+
},
|
|
9869
|
+
(error) => {
|
|
9870
|
+
cleanup();
|
|
9871
|
+
reject(error);
|
|
9872
|
+
}
|
|
9873
|
+
);
|
|
9874
|
+
});
|
|
9875
|
+
}
|
|
9838
9876
|
async function executeRecoverableTool(input) {
|
|
9839
9877
|
const local = input.state.local;
|
|
9840
|
-
|
|
9878
|
+
const run = () => settleToolWithinAbortGrace({
|
|
9879
|
+
execution: input.execute(),
|
|
9880
|
+
signal: local?.signal,
|
|
9881
|
+
graceMs: input.abortGraceMs ?? DEFAULT_TOOL_ABORT_GRACE_MS,
|
|
9882
|
+
onAbandon: input.onAbandon
|
|
9883
|
+
});
|
|
9884
|
+
if (!local?.commitExecutionBoundary) return run();
|
|
9841
9885
|
if (local.executingToolCallId) {
|
|
9842
9886
|
if (local.executingToolCallId !== input.call.id) {
|
|
9843
9887
|
throw new RunRecoveryBlockedError("Pending tool identity does not match execution intent");
|
|
@@ -9850,7 +9894,7 @@ async function executeRecoverableTool(input) {
|
|
|
9850
9894
|
}
|
|
9851
9895
|
local.executingToolCallId = input.call.id;
|
|
9852
9896
|
await local.commitExecutionBoundary(input.state);
|
|
9853
|
-
const result = await
|
|
9897
|
+
const result = await run();
|
|
9854
9898
|
if (!result.success && isRunPauseSignal(local.signal)) {
|
|
9855
9899
|
const error = new Error("Tool execution paused before its outcome was confirmed");
|
|
9856
9900
|
error.name = "AbortError";
|
|
@@ -9970,7 +10014,9 @@ var ToolNode = class {
|
|
|
9970
10014
|
auditPort;
|
|
9971
10015
|
modelInputResolver;
|
|
9972
10016
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
10017
|
+
abortGraceMs;
|
|
9973
10018
|
constructor(dependencies) {
|
|
10019
|
+
this.abortGraceMs = dependencies.abortGraceMs;
|
|
9974
10020
|
this.toolRuntime = dependencies.toolRuntime;
|
|
9975
10021
|
this.observationPreview = dependencies.observationPreview;
|
|
9976
10022
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
@@ -10188,6 +10234,13 @@ var ToolNode = class {
|
|
|
10188
10234
|
state,
|
|
10189
10235
|
call,
|
|
10190
10236
|
context: prepared.toolContext,
|
|
10237
|
+
abortGraceMs: this.abortGraceMs,
|
|
10238
|
+
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", {
|
|
10239
|
+
toolName: execution.toolName,
|
|
10240
|
+
toolCallId: execution.toolCallId,
|
|
10241
|
+
conversationId: prepared.conversationId,
|
|
10242
|
+
turnId: prepared.turnId
|
|
10243
|
+
}),
|
|
10191
10244
|
execute: () => executeToolWithIdempotency({
|
|
10192
10245
|
idempotencyKey: execution.idempotencyKey,
|
|
10193
10246
|
inFlight: this.idempotencyInFlight,
|
|
@@ -10809,6 +10862,7 @@ var executor = z.object({
|
|
|
10809
10862
|
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
10810
10863
|
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
10811
10864
|
runLockedModelId: z.string().optional(),
|
|
10865
|
+
// 0.45 及更早的 checkpoint 可能带这个已删除字段;照常接受,读入时丢弃。
|
|
10812
10866
|
lastSuccessfulLlmModelId: z.string().optional(),
|
|
10813
10867
|
llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
|
|
10814
10868
|
llmInvocationCount: counter.optional(),
|
|
@@ -10818,7 +10872,7 @@ var executor = z.object({
|
|
|
10818
10872
|
committedCount: counter,
|
|
10819
10873
|
lastCommittedFingerprint: z.string().optional()
|
|
10820
10874
|
}).strict().optional()
|
|
10821
|
-
}).strict();
|
|
10875
|
+
}).strict().transform(({ lastSuccessfulLlmModelId: _retired, ...state }) => state);
|
|
10822
10876
|
var checkpoint = z.object({
|
|
10823
10877
|
nodeId: z.string().min(1),
|
|
10824
10878
|
schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|