@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/runtime-kernel.js
CHANGED
|
@@ -5173,13 +5173,11 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5173
5173
|
"llmCallStartedAt",
|
|
5174
5174
|
"llmResp",
|
|
5175
5175
|
"llmCallDurationMs",
|
|
5176
|
-
"executorLocalPatch",
|
|
5177
5176
|
"contextUsage"
|
|
5178
5177
|
],
|
|
5179
5178
|
async run(ctx) {
|
|
5180
5179
|
let cloudQuotaFallbackAppliedModelId;
|
|
5181
5180
|
let modelFallbackAudit;
|
|
5182
|
-
let lastSuccessfulLlmModelId;
|
|
5183
5181
|
let contextUsage;
|
|
5184
5182
|
const modelFallbackRejections = [];
|
|
5185
5183
|
const promptBudget = ctx.promptBudget;
|
|
@@ -5200,8 +5198,7 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5200
5198
|
onCloudQuotaFallbackApplied(fallbackModelId) {
|
|
5201
5199
|
cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
|
|
5202
5200
|
},
|
|
5203
|
-
onLlmAttemptSucceeded(
|
|
5204
|
-
lastSuccessfulLlmModelId = readNonEmptyString3(activeModelId);
|
|
5201
|
+
onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
|
|
5205
5202
|
contextUsage = attemptContextUsage;
|
|
5206
5203
|
},
|
|
5207
5204
|
onModelFallbackApplied(info) {
|
|
@@ -5302,7 +5299,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5302
5299
|
llmCallStartedAt,
|
|
5303
5300
|
llmResp,
|
|
5304
5301
|
llmCallDurationMs,
|
|
5305
|
-
executorLocalPatch: lastSuccessfulLlmModelId ? { lastSuccessfulLlmModelId } : void 0,
|
|
5306
5302
|
contextUsage
|
|
5307
5303
|
};
|
|
5308
5304
|
}
|
|
@@ -8211,6 +8207,7 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
|
|
|
8211
8207
|
"conversationView",
|
|
8212
8208
|
"userQuery",
|
|
8213
8209
|
"modelId",
|
|
8210
|
+
"activeModelId",
|
|
8214
8211
|
"conversationId",
|
|
8215
8212
|
"turnId",
|
|
8216
8213
|
"runId",
|
|
@@ -8544,6 +8541,12 @@ function parseToolArgs(call) {
|
|
|
8544
8541
|
};
|
|
8545
8542
|
}
|
|
8546
8543
|
}
|
|
8544
|
+
function readRunLockedModelId(local) {
|
|
8545
|
+
const executorLocal = local.executorLocal;
|
|
8546
|
+
if (!isRecord9(executorLocal)) return void 0;
|
|
8547
|
+
const lockedModelId = executorLocal.runLockedModelId;
|
|
8548
|
+
return typeof lockedModelId === "string" && lockedModelId.trim() ? lockedModelId : void 0;
|
|
8549
|
+
}
|
|
8547
8550
|
function prepareToolNodeContext(state) {
|
|
8548
8551
|
const local = state.local || {};
|
|
8549
8552
|
const toolContext = isRecord9(local.toolContext) ? local.toolContext : {};
|
|
@@ -8561,6 +8564,7 @@ function prepareToolNodeContext(state) {
|
|
|
8561
8564
|
}
|
|
8562
8565
|
});
|
|
8563
8566
|
attachWorkingHistoryView({ state, toolContext });
|
|
8567
|
+
toolContext.activeModelId = readRunLockedModelId(local) ?? toolContext.modelId;
|
|
8564
8568
|
return {
|
|
8565
8569
|
state,
|
|
8566
8570
|
local,
|
|
@@ -8803,9 +8807,49 @@ function recordToolProtocolError(params) {
|
|
|
8803
8807
|
}
|
|
8804
8808
|
|
|
8805
8809
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
8810
|
+
var DEFAULT_TOOL_ABORT_GRACE_MS = 3e3;
|
|
8811
|
+
function settleToolWithinAbortGrace(input) {
|
|
8812
|
+
const { execution, signal, graceMs } = input;
|
|
8813
|
+
if (!signal) return execution;
|
|
8814
|
+
return new Promise((resolve, reject) => {
|
|
8815
|
+
let timer;
|
|
8816
|
+
const cleanup = () => {
|
|
8817
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
8818
|
+
signal.removeEventListener("abort", startGrace);
|
|
8819
|
+
};
|
|
8820
|
+
function startGrace() {
|
|
8821
|
+
timer = setTimeout(() => {
|
|
8822
|
+
cleanup();
|
|
8823
|
+
execution.catch(() => void 0);
|
|
8824
|
+
input.onAbandon?.();
|
|
8825
|
+
const error = new Error("Tool did not stop within the abort grace period; its late outcome is discarded.");
|
|
8826
|
+
error.name = "AbortError";
|
|
8827
|
+
reject(error);
|
|
8828
|
+
}, graceMs);
|
|
8829
|
+
}
|
|
8830
|
+
if (signal.aborted) startGrace();
|
|
8831
|
+
else signal.addEventListener("abort", startGrace, { once: true });
|
|
8832
|
+
execution.then(
|
|
8833
|
+
(value) => {
|
|
8834
|
+
cleanup();
|
|
8835
|
+
resolve(value);
|
|
8836
|
+
},
|
|
8837
|
+
(error) => {
|
|
8838
|
+
cleanup();
|
|
8839
|
+
reject(error);
|
|
8840
|
+
}
|
|
8841
|
+
);
|
|
8842
|
+
});
|
|
8843
|
+
}
|
|
8806
8844
|
async function executeRecoverableTool(input) {
|
|
8807
8845
|
const local = input.state.local;
|
|
8808
|
-
|
|
8846
|
+
const run = () => settleToolWithinAbortGrace({
|
|
8847
|
+
execution: input.execute(),
|
|
8848
|
+
signal: local?.signal,
|
|
8849
|
+
graceMs: input.abortGraceMs ?? DEFAULT_TOOL_ABORT_GRACE_MS,
|
|
8850
|
+
onAbandon: input.onAbandon
|
|
8851
|
+
});
|
|
8852
|
+
if (!local?.commitExecutionBoundary) return run();
|
|
8809
8853
|
if (local.executingToolCallId) {
|
|
8810
8854
|
if (local.executingToolCallId !== input.call.id) {
|
|
8811
8855
|
throw new RunRecoveryBlockedError("Pending tool identity does not match execution intent");
|
|
@@ -8818,7 +8862,7 @@ async function executeRecoverableTool(input) {
|
|
|
8818
8862
|
}
|
|
8819
8863
|
local.executingToolCallId = input.call.id;
|
|
8820
8864
|
await local.commitExecutionBoundary(input.state);
|
|
8821
|
-
const result = await
|
|
8865
|
+
const result = await run();
|
|
8822
8866
|
if (!result.success && isRunPauseSignal(local.signal)) {
|
|
8823
8867
|
const error = new Error("Tool execution paused before its outcome was confirmed");
|
|
8824
8868
|
error.name = "AbortError";
|
|
@@ -8938,7 +8982,9 @@ var ToolNode = class {
|
|
|
8938
8982
|
auditPort;
|
|
8939
8983
|
modelInputResolver;
|
|
8940
8984
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
8985
|
+
abortGraceMs;
|
|
8941
8986
|
constructor(dependencies) {
|
|
8987
|
+
this.abortGraceMs = dependencies.abortGraceMs;
|
|
8942
8988
|
this.toolRuntime = dependencies.toolRuntime;
|
|
8943
8989
|
this.observationPreview = dependencies.observationPreview;
|
|
8944
8990
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
@@ -9156,6 +9202,13 @@ var ToolNode = class {
|
|
|
9156
9202
|
state,
|
|
9157
9203
|
call,
|
|
9158
9204
|
context: prepared.toolContext,
|
|
9205
|
+
abortGraceMs: this.abortGraceMs,
|
|
9206
|
+
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", {
|
|
9207
|
+
toolName: execution.toolName,
|
|
9208
|
+
toolCallId: execution.toolCallId,
|
|
9209
|
+
conversationId: prepared.conversationId,
|
|
9210
|
+
turnId: prepared.turnId
|
|
9211
|
+
}),
|
|
9159
9212
|
execute: () => executeToolWithIdempotency({
|
|
9160
9213
|
idempotencyKey: execution.idempotencyKey,
|
|
9161
9214
|
inFlight: this.idempotencyInFlight,
|
|
@@ -9777,6 +9830,7 @@ var executor = z.object({
|
|
|
9777
9830
|
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
9778
9831
|
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
9779
9832
|
runLockedModelId: z.string().optional(),
|
|
9833
|
+
// 0.45 及更早的 checkpoint 可能带这个已删除字段;照常接受,读入时丢弃。
|
|
9780
9834
|
lastSuccessfulLlmModelId: z.string().optional(),
|
|
9781
9835
|
llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
|
|
9782
9836
|
llmInvocationCount: counter.optional(),
|
|
@@ -9786,7 +9840,7 @@ var executor = z.object({
|
|
|
9786
9840
|
committedCount: counter,
|
|
9787
9841
|
lastCommittedFingerprint: z.string().optional()
|
|
9788
9842
|
}).strict().optional()
|
|
9789
|
-
}).strict();
|
|
9843
|
+
}).strict().transform(({ lastSuccessfulLlmModelId: _retired, ...state }) => state);
|
|
9790
9844
|
var checkpoint = z.object({
|
|
9791
9845
|
nodeId: z.string().min(1),
|
|
9792
9846
|
schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|