@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/testkit.js
CHANGED
|
@@ -5361,13 +5361,11 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5361
5361
|
"llmCallStartedAt",
|
|
5362
5362
|
"llmResp",
|
|
5363
5363
|
"llmCallDurationMs",
|
|
5364
|
-
"executorLocalPatch",
|
|
5365
5364
|
"contextUsage"
|
|
5366
5365
|
],
|
|
5367
5366
|
async run(ctx) {
|
|
5368
5367
|
let cloudQuotaFallbackAppliedModelId;
|
|
5369
5368
|
let modelFallbackAudit;
|
|
5370
|
-
let lastSuccessfulLlmModelId;
|
|
5371
5369
|
let contextUsage;
|
|
5372
5370
|
const modelFallbackRejections = [];
|
|
5373
5371
|
const promptBudget = ctx.promptBudget;
|
|
@@ -5388,8 +5386,7 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5388
5386
|
onCloudQuotaFallbackApplied(fallbackModelId) {
|
|
5389
5387
|
cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
|
|
5390
5388
|
},
|
|
5391
|
-
onLlmAttemptSucceeded(
|
|
5392
|
-
lastSuccessfulLlmModelId = readNonEmptyString3(activeModelId);
|
|
5389
|
+
onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
|
|
5393
5390
|
contextUsage = attemptContextUsage;
|
|
5394
5391
|
},
|
|
5395
5392
|
onModelFallbackApplied(info) {
|
|
@@ -5490,7 +5487,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5490
5487
|
llmCallStartedAt,
|
|
5491
5488
|
llmResp,
|
|
5492
5489
|
llmCallDurationMs,
|
|
5493
|
-
executorLocalPatch: lastSuccessfulLlmModelId ? { lastSuccessfulLlmModelId } : void 0,
|
|
5494
5490
|
contextUsage
|
|
5495
5491
|
};
|
|
5496
5492
|
}
|
|
@@ -8399,6 +8395,7 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
|
|
|
8399
8395
|
"conversationView",
|
|
8400
8396
|
"userQuery",
|
|
8401
8397
|
"modelId",
|
|
8398
|
+
"activeModelId",
|
|
8402
8399
|
"conversationId",
|
|
8403
8400
|
"turnId",
|
|
8404
8401
|
"runId",
|
|
@@ -8732,6 +8729,12 @@ function parseToolArgs(call) {
|
|
|
8732
8729
|
};
|
|
8733
8730
|
}
|
|
8734
8731
|
}
|
|
8732
|
+
function readRunLockedModelId(local) {
|
|
8733
|
+
const executorLocal = local.executorLocal;
|
|
8734
|
+
if (!isRecord9(executorLocal)) return void 0;
|
|
8735
|
+
const lockedModelId = executorLocal.runLockedModelId;
|
|
8736
|
+
return typeof lockedModelId === "string" && lockedModelId.trim() ? lockedModelId : void 0;
|
|
8737
|
+
}
|
|
8735
8738
|
function prepareToolNodeContext(state) {
|
|
8736
8739
|
const local = state.local || {};
|
|
8737
8740
|
const toolContext = isRecord9(local.toolContext) ? local.toolContext : {};
|
|
@@ -8749,6 +8752,7 @@ function prepareToolNodeContext(state) {
|
|
|
8749
8752
|
}
|
|
8750
8753
|
});
|
|
8751
8754
|
attachWorkingHistoryView({ state, toolContext });
|
|
8755
|
+
toolContext.activeModelId = readRunLockedModelId(local) ?? toolContext.modelId;
|
|
8752
8756
|
return {
|
|
8753
8757
|
state,
|
|
8754
8758
|
local,
|
|
@@ -8991,9 +8995,49 @@ function recordToolProtocolError(params) {
|
|
|
8991
8995
|
}
|
|
8992
8996
|
|
|
8993
8997
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
8998
|
+
var DEFAULT_TOOL_ABORT_GRACE_MS = 3e3;
|
|
8999
|
+
function settleToolWithinAbortGrace(input) {
|
|
9000
|
+
const { execution, signal, graceMs } = input;
|
|
9001
|
+
if (!signal) return execution;
|
|
9002
|
+
return new Promise((resolve, reject) => {
|
|
9003
|
+
let timer;
|
|
9004
|
+
const cleanup = () => {
|
|
9005
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
9006
|
+
signal.removeEventListener("abort", startGrace);
|
|
9007
|
+
};
|
|
9008
|
+
function startGrace() {
|
|
9009
|
+
timer = setTimeout(() => {
|
|
9010
|
+
cleanup();
|
|
9011
|
+
execution.catch(() => void 0);
|
|
9012
|
+
input.onAbandon?.();
|
|
9013
|
+
const error = new Error("Tool did not stop within the abort grace period; its late outcome is discarded.");
|
|
9014
|
+
error.name = "AbortError";
|
|
9015
|
+
reject(error);
|
|
9016
|
+
}, graceMs);
|
|
9017
|
+
}
|
|
9018
|
+
if (signal.aborted) startGrace();
|
|
9019
|
+
else signal.addEventListener("abort", startGrace, { once: true });
|
|
9020
|
+
execution.then(
|
|
9021
|
+
(value) => {
|
|
9022
|
+
cleanup();
|
|
9023
|
+
resolve(value);
|
|
9024
|
+
},
|
|
9025
|
+
(error) => {
|
|
9026
|
+
cleanup();
|
|
9027
|
+
reject(error);
|
|
9028
|
+
}
|
|
9029
|
+
);
|
|
9030
|
+
});
|
|
9031
|
+
}
|
|
8994
9032
|
async function executeRecoverableTool(input) {
|
|
8995
9033
|
const local = input.state.local;
|
|
8996
|
-
|
|
9034
|
+
const run = () => settleToolWithinAbortGrace({
|
|
9035
|
+
execution: input.execute(),
|
|
9036
|
+
signal: local?.signal,
|
|
9037
|
+
graceMs: input.abortGraceMs ?? DEFAULT_TOOL_ABORT_GRACE_MS,
|
|
9038
|
+
onAbandon: input.onAbandon
|
|
9039
|
+
});
|
|
9040
|
+
if (!local?.commitExecutionBoundary) return run();
|
|
8997
9041
|
if (local.executingToolCallId) {
|
|
8998
9042
|
if (local.executingToolCallId !== input.call.id) {
|
|
8999
9043
|
throw new RunRecoveryBlockedError("Pending tool identity does not match execution intent");
|
|
@@ -9006,7 +9050,7 @@ async function executeRecoverableTool(input) {
|
|
|
9006
9050
|
}
|
|
9007
9051
|
local.executingToolCallId = input.call.id;
|
|
9008
9052
|
await local.commitExecutionBoundary(input.state);
|
|
9009
|
-
const result = await
|
|
9053
|
+
const result = await run();
|
|
9010
9054
|
if (!result.success && isRunPauseSignal(local.signal)) {
|
|
9011
9055
|
const error = new Error("Tool execution paused before its outcome was confirmed");
|
|
9012
9056
|
error.name = "AbortError";
|
|
@@ -9126,7 +9170,9 @@ var ToolNode = class {
|
|
|
9126
9170
|
auditPort;
|
|
9127
9171
|
modelInputResolver;
|
|
9128
9172
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
9173
|
+
abortGraceMs;
|
|
9129
9174
|
constructor(dependencies) {
|
|
9175
|
+
this.abortGraceMs = dependencies.abortGraceMs;
|
|
9130
9176
|
this.toolRuntime = dependencies.toolRuntime;
|
|
9131
9177
|
this.observationPreview = dependencies.observationPreview;
|
|
9132
9178
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
@@ -9344,6 +9390,13 @@ var ToolNode = class {
|
|
|
9344
9390
|
state,
|
|
9345
9391
|
call,
|
|
9346
9392
|
context: prepared.toolContext,
|
|
9393
|
+
abortGraceMs: this.abortGraceMs,
|
|
9394
|
+
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", {
|
|
9395
|
+
toolName: execution.toolName,
|
|
9396
|
+
toolCallId: execution.toolCallId,
|
|
9397
|
+
conversationId: prepared.conversationId,
|
|
9398
|
+
turnId: prepared.turnId
|
|
9399
|
+
}),
|
|
9347
9400
|
execute: () => executeToolWithIdempotency({
|
|
9348
9401
|
idempotencyKey: execution.idempotencyKey,
|
|
9349
9402
|
inFlight: this.idempotencyInFlight,
|
|
@@ -9965,6 +10018,7 @@ var executor = z.object({
|
|
|
9965
10018
|
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
9966
10019
|
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
9967
10020
|
runLockedModelId: z.string().optional(),
|
|
10021
|
+
// 0.45 及更早的 checkpoint 可能带这个已删除字段;照常接受,读入时丢弃。
|
|
9968
10022
|
lastSuccessfulLlmModelId: z.string().optional(),
|
|
9969
10023
|
llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
|
|
9970
10024
|
llmInvocationCount: counter.optional(),
|
|
@@ -9974,7 +10028,7 @@ var executor = z.object({
|
|
|
9974
10028
|
committedCount: counter,
|
|
9975
10029
|
lastCommittedFingerprint: z.string().optional()
|
|
9976
10030
|
}).strict().optional()
|
|
9977
|
-
}).strict();
|
|
10031
|
+
}).strict().transform(({ lastSuccessfulLlmModelId: _retired, ...state }) => state);
|
|
9978
10032
|
var checkpoint = z.object({
|
|
9979
10033
|
nodeId: z.string().min(1),
|
|
9980
10034
|
schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|