@linnlabs/linnkit 0.36.0 → 0.37.1
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 +22 -0
- package/dist/cli.cjs +64 -22
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +64 -22
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.js.map +1 -1
- package/dist/contracts/token-accounting.d.cts +8 -8
- package/dist/contracts/token-accounting.d.ts +8 -8
- package/dist/index.cjs +64 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +64 -22
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +64 -22
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +64 -22
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +1 -0
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +1 -0
- package/dist/runtime-kernel/graph-engine/types.d.cts +2 -0
- package/dist/runtime-kernel/graph-engine/types.d.ts +2 -0
- package/dist/runtime-kernel.cjs +64 -22
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.js +64 -22
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +64 -22
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +64 -22
- package/dist/testkit.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/integration/persistence.md +19 -0
- package/docs/integration/tools.md +12 -0
- package/package.json +2 -2
package/dist/quickstart.js
CHANGED
|
@@ -3118,6 +3118,26 @@ function resolveAssistantReplayParts(response) {
|
|
|
3118
3118
|
return response.assistant_replay_parts;
|
|
3119
3119
|
}
|
|
3120
3120
|
|
|
3121
|
+
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
3122
|
+
var RunRecoveryBlockedError = class extends Error {
|
|
3123
|
+
code = "RUN_RECOVERY_BLOCKED";
|
|
3124
|
+
constructor(message) {
|
|
3125
|
+
super(message);
|
|
3126
|
+
this.name = "RunRecoveryBlockedError";
|
|
3127
|
+
}
|
|
3128
|
+
};
|
|
3129
|
+
var RunPauseRequested = class extends Error {
|
|
3130
|
+
code = "RUN_PAUSE_REQUESTED";
|
|
3131
|
+
constructor(message = "Run paused by user") {
|
|
3132
|
+
super(message);
|
|
3133
|
+
this.name = "RunPauseRequested";
|
|
3134
|
+
}
|
|
3135
|
+
};
|
|
3136
|
+
function isRunPauseSignal(signal) {
|
|
3137
|
+
const reason = signal?.reason;
|
|
3138
|
+
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3121
3141
|
// src/runtime-kernel/graph-engine/engine.ts
|
|
3122
3142
|
var logger2 = new Logger("GraphExecutor");
|
|
3123
3143
|
function isRecord4(value) {
|
|
@@ -3427,6 +3447,7 @@ var GraphExecutor = class {
|
|
|
3427
3447
|
reportStepsUsed(stepCount);
|
|
3428
3448
|
const signalRaw = state.local?.signal;
|
|
3429
3449
|
if (isAbortSignal2(signalRaw) && signalRaw.aborted) {
|
|
3450
|
+
if (!isRunPauseSignal(signalRaw)) await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
3430
3451
|
logger2.warn("[GraphExecutor] \u6536\u5230 AbortSignal\uFF0C\u7ACB\u5373\u505C\u6B62\u63A8\u7406\u5FAA\u73AF");
|
|
3431
3452
|
this.ephemeralLocals.delete(checkpointKey);
|
|
3432
3453
|
throwAbortError();
|
|
@@ -3477,6 +3498,12 @@ var GraphExecutor = class {
|
|
|
3477
3498
|
allEvents.push(...stepResolution.events);
|
|
3478
3499
|
}
|
|
3479
3500
|
state = stepResolution.state;
|
|
3501
|
+
const completedSignal = state.local?.signal;
|
|
3502
|
+
if (isAbortSignal2(completedSignal) && completedSignal.aborted && !isRunPauseSignal(completedSignal)) {
|
|
3503
|
+
await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
3504
|
+
this.ephemeralLocals.delete(checkpointKey);
|
|
3505
|
+
throwAbortError();
|
|
3506
|
+
}
|
|
3480
3507
|
if (stepResolution.action.kind === "route") {
|
|
3481
3508
|
logger2.info("[GraphExecutor] \u8DEF\u7531\u5207\u6362", {
|
|
3482
3509
|
fromNodeId: stepResolution.action.fromNodeId,
|
|
@@ -8407,26 +8434,6 @@ function buildCancelledToolBatchLocalState(local, runtimeEvents) {
|
|
|
8407
8434
|
function recordToolProtocolError(params) {
|
|
8408
8435
|
}
|
|
8409
8436
|
|
|
8410
|
-
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
8411
|
-
var RunRecoveryBlockedError = class extends Error {
|
|
8412
|
-
code = "RUN_RECOVERY_BLOCKED";
|
|
8413
|
-
constructor(message) {
|
|
8414
|
-
super(message);
|
|
8415
|
-
this.name = "RunRecoveryBlockedError";
|
|
8416
|
-
}
|
|
8417
|
-
};
|
|
8418
|
-
var RunPauseRequested = class extends Error {
|
|
8419
|
-
code = "RUN_PAUSE_REQUESTED";
|
|
8420
|
-
constructor(message = "Run paused by user") {
|
|
8421
|
-
super(message);
|
|
8422
|
-
this.name = "RunPauseRequested";
|
|
8423
|
-
}
|
|
8424
|
-
};
|
|
8425
|
-
function isRunPauseSignal(signal) {
|
|
8426
|
-
const reason = signal?.reason;
|
|
8427
|
-
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
8428
|
-
}
|
|
8429
|
-
|
|
8430
8437
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
8431
8438
|
async function executeRecoverableTool(input) {
|
|
8432
8439
|
const local = input.state.local;
|
|
@@ -8628,7 +8635,30 @@ var ToolNode = class {
|
|
|
8628
8635
|
async run(state) {
|
|
8629
8636
|
const events = [];
|
|
8630
8637
|
while (true) {
|
|
8631
|
-
|
|
8638
|
+
let result;
|
|
8639
|
+
try {
|
|
8640
|
+
result = await this.runNextPendingToolCall(state);
|
|
8641
|
+
} catch (error) {
|
|
8642
|
+
if (isToolExecutionAbort(error) && !isRunPauseSignal(state.local?.signal)) {
|
|
8643
|
+
await this.cancel(state);
|
|
8644
|
+
}
|
|
8645
|
+
throw error;
|
|
8646
|
+
}
|
|
8647
|
+
const signal = state.local?.signal;
|
|
8648
|
+
if (isAbortSignal(signal) && signal.aborted && !isRunPauseSignal(signal)) {
|
|
8649
|
+
await this.cancel(state);
|
|
8650
|
+
const error = new Error("The user aborted a request.");
|
|
8651
|
+
error.name = "AbortError";
|
|
8652
|
+
throw error;
|
|
8653
|
+
}
|
|
8654
|
+
if (result.kind === "interrupted") {
|
|
8655
|
+
await commitToolBoundary(state, {
|
|
8656
|
+
kind: "route",
|
|
8657
|
+
nextNodeId: "llm",
|
|
8658
|
+
events: result.events
|
|
8659
|
+
});
|
|
8660
|
+
throw result.error;
|
|
8661
|
+
}
|
|
8632
8662
|
await commitToolBoundary(state, result);
|
|
8633
8663
|
if (Array.isArray(result.events) && result.events.length > 0) {
|
|
8634
8664
|
events.push(...result.events);
|
|
@@ -8642,6 +8672,14 @@ var ToolNode = class {
|
|
|
8642
8672
|
};
|
|
8643
8673
|
}
|
|
8644
8674
|
}
|
|
8675
|
+
async cancel(state) {
|
|
8676
|
+
settlePendingToolCallsAfterAbort({
|
|
8677
|
+
state,
|
|
8678
|
+
calls: parsePendingToolCalls(state.local?.pendingToolCalls ?? []),
|
|
8679
|
+
toolCatalog: this.toolRuntime
|
|
8680
|
+
});
|
|
8681
|
+
await commitToolBoundary(state, { kind: "yield"});
|
|
8682
|
+
}
|
|
8645
8683
|
async runNextPendingToolCall(state) {
|
|
8646
8684
|
const calls = parsePendingToolCalls(state.local?.pendingToolCalls ?? []);
|
|
8647
8685
|
const signalRaw = state.local?.signal;
|
|
@@ -9061,7 +9099,11 @@ var ToolNode = class {
|
|
|
9061
9099
|
nextProtocolErrorCount: fuse.nextCount
|
|
9062
9100
|
});
|
|
9063
9101
|
if (fuse.shouldFuse && remainingCalls.length === 0) {
|
|
9064
|
-
|
|
9102
|
+
return {
|
|
9103
|
+
kind: "interrupted",
|
|
9104
|
+
error: createToolProtocolFuseError(fuse.nextCount, context.exec.error),
|
|
9105
|
+
events: context.bridge.getRuntimeEvents()
|
|
9106
|
+
};
|
|
9065
9107
|
}
|
|
9066
9108
|
if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
|
|
9067
9109
|
return { kind: "yield", events: context.bridge.getRuntimeEvents() };
|