@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/testkit.cjs
CHANGED
|
@@ -3099,6 +3099,26 @@ function resolveAssistantReplayParts(response) {
|
|
|
3099
3099
|
return response.assistant_replay_parts;
|
|
3100
3100
|
}
|
|
3101
3101
|
|
|
3102
|
+
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
3103
|
+
var RunRecoveryBlockedError = class extends Error {
|
|
3104
|
+
code = "RUN_RECOVERY_BLOCKED";
|
|
3105
|
+
constructor(message) {
|
|
3106
|
+
super(message);
|
|
3107
|
+
this.name = "RunRecoveryBlockedError";
|
|
3108
|
+
}
|
|
3109
|
+
};
|
|
3110
|
+
var RunPauseRequested = class extends Error {
|
|
3111
|
+
code = "RUN_PAUSE_REQUESTED";
|
|
3112
|
+
constructor(message = "Run paused by user") {
|
|
3113
|
+
super(message);
|
|
3114
|
+
this.name = "RunPauseRequested";
|
|
3115
|
+
}
|
|
3116
|
+
};
|
|
3117
|
+
function isRunPauseSignal(signal) {
|
|
3118
|
+
const reason = signal?.reason;
|
|
3119
|
+
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
3120
|
+
}
|
|
3121
|
+
|
|
3102
3122
|
// src/runtime-kernel/graph-engine/engine.ts
|
|
3103
3123
|
var logger2 = new Logger("GraphExecutor");
|
|
3104
3124
|
function isRecord4(value) {
|
|
@@ -3408,6 +3428,7 @@ var GraphExecutor = class {
|
|
|
3408
3428
|
reportStepsUsed(stepCount);
|
|
3409
3429
|
const signalRaw = state.local?.signal;
|
|
3410
3430
|
if (isAbortSignal2(signalRaw) && signalRaw.aborted) {
|
|
3431
|
+
if (!isRunPauseSignal(signalRaw)) await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
3411
3432
|
logger2.warn("[GraphExecutor] \u6536\u5230 AbortSignal\uFF0C\u7ACB\u5373\u505C\u6B62\u63A8\u7406\u5FAA\u73AF");
|
|
3412
3433
|
this.ephemeralLocals.delete(checkpointKey);
|
|
3413
3434
|
throwAbortError();
|
|
@@ -3458,6 +3479,12 @@ var GraphExecutor = class {
|
|
|
3458
3479
|
allEvents.push(...stepResolution.events);
|
|
3459
3480
|
}
|
|
3460
3481
|
state = stepResolution.state;
|
|
3482
|
+
const completedSignal = state.local?.signal;
|
|
3483
|
+
if (isAbortSignal2(completedSignal) && completedSignal.aborted && !isRunPauseSignal(completedSignal)) {
|
|
3484
|
+
await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
3485
|
+
this.ephemeralLocals.delete(checkpointKey);
|
|
3486
|
+
throwAbortError();
|
|
3487
|
+
}
|
|
3461
3488
|
if (stepResolution.action.kind === "route") {
|
|
3462
3489
|
logger2.info("[GraphExecutor] \u8DEF\u7531\u5207\u6362", {
|
|
3463
3490
|
fromNodeId: stepResolution.action.fromNodeId,
|
|
@@ -8667,26 +8694,6 @@ function buildCancelledToolBatchLocalState(local, runtimeEvents) {
|
|
|
8667
8694
|
function recordToolProtocolError(params) {
|
|
8668
8695
|
}
|
|
8669
8696
|
|
|
8670
|
-
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
8671
|
-
var RunRecoveryBlockedError = class extends Error {
|
|
8672
|
-
code = "RUN_RECOVERY_BLOCKED";
|
|
8673
|
-
constructor(message) {
|
|
8674
|
-
super(message);
|
|
8675
|
-
this.name = "RunRecoveryBlockedError";
|
|
8676
|
-
}
|
|
8677
|
-
};
|
|
8678
|
-
var RunPauseRequested = class extends Error {
|
|
8679
|
-
code = "RUN_PAUSE_REQUESTED";
|
|
8680
|
-
constructor(message = "Run paused by user") {
|
|
8681
|
-
super(message);
|
|
8682
|
-
this.name = "RunPauseRequested";
|
|
8683
|
-
}
|
|
8684
|
-
};
|
|
8685
|
-
function isRunPauseSignal(signal) {
|
|
8686
|
-
const reason = signal?.reason;
|
|
8687
|
-
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
8688
|
-
}
|
|
8689
|
-
|
|
8690
8697
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
8691
8698
|
async function executeRecoverableTool(input) {
|
|
8692
8699
|
const local = input.state.local;
|
|
@@ -8888,7 +8895,30 @@ var ToolNode = class {
|
|
|
8888
8895
|
async run(state) {
|
|
8889
8896
|
const events = [];
|
|
8890
8897
|
while (true) {
|
|
8891
|
-
|
|
8898
|
+
let result;
|
|
8899
|
+
try {
|
|
8900
|
+
result = await this.runNextPendingToolCall(state);
|
|
8901
|
+
} catch (error) {
|
|
8902
|
+
if (isToolExecutionAbort(error) && !isRunPauseSignal(state.local?.signal)) {
|
|
8903
|
+
await this.cancel(state);
|
|
8904
|
+
}
|
|
8905
|
+
throw error;
|
|
8906
|
+
}
|
|
8907
|
+
const signal = state.local?.signal;
|
|
8908
|
+
if (isAbortSignal(signal) && signal.aborted && !isRunPauseSignal(signal)) {
|
|
8909
|
+
await this.cancel(state);
|
|
8910
|
+
const error = new Error("The user aborted a request.");
|
|
8911
|
+
error.name = "AbortError";
|
|
8912
|
+
throw error;
|
|
8913
|
+
}
|
|
8914
|
+
if (result.kind === "interrupted") {
|
|
8915
|
+
await commitToolBoundary(state, {
|
|
8916
|
+
kind: "route",
|
|
8917
|
+
nextNodeId: "llm",
|
|
8918
|
+
events: result.events
|
|
8919
|
+
});
|
|
8920
|
+
throw result.error;
|
|
8921
|
+
}
|
|
8892
8922
|
await commitToolBoundary(state, result);
|
|
8893
8923
|
if (Array.isArray(result.events) && result.events.length > 0) {
|
|
8894
8924
|
events.push(...result.events);
|
|
@@ -8902,6 +8932,14 @@ var ToolNode = class {
|
|
|
8902
8932
|
};
|
|
8903
8933
|
}
|
|
8904
8934
|
}
|
|
8935
|
+
async cancel(state) {
|
|
8936
|
+
settlePendingToolCallsAfterAbort({
|
|
8937
|
+
state,
|
|
8938
|
+
calls: parsePendingToolCalls(state.local?.pendingToolCalls ?? []),
|
|
8939
|
+
toolCatalog: this.toolRuntime
|
|
8940
|
+
});
|
|
8941
|
+
await commitToolBoundary(state, { kind: "yield"});
|
|
8942
|
+
}
|
|
8905
8943
|
async runNextPendingToolCall(state) {
|
|
8906
8944
|
const calls = parsePendingToolCalls(state.local?.pendingToolCalls ?? []);
|
|
8907
8945
|
const signalRaw = state.local?.signal;
|
|
@@ -9321,7 +9359,11 @@ var ToolNode = class {
|
|
|
9321
9359
|
nextProtocolErrorCount: fuse.nextCount
|
|
9322
9360
|
});
|
|
9323
9361
|
if (fuse.shouldFuse && remainingCalls.length === 0) {
|
|
9324
|
-
|
|
9362
|
+
return {
|
|
9363
|
+
kind: "interrupted",
|
|
9364
|
+
error: createToolProtocolFuseError(fuse.nextCount, context.exec.error),
|
|
9365
|
+
events: context.bridge.getRuntimeEvents()
|
|
9366
|
+
};
|
|
9325
9367
|
}
|
|
9326
9368
|
if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
|
|
9327
9369
|
return { kind: "yield", events: context.bridge.getRuntimeEvents() };
|