@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/cli.js
CHANGED
|
@@ -3004,6 +3004,26 @@ function resolveAssistantReplayParts(response) {
|
|
|
3004
3004
|
return response.assistant_replay_parts;
|
|
3005
3005
|
}
|
|
3006
3006
|
|
|
3007
|
+
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
3008
|
+
var RunRecoveryBlockedError = class extends Error {
|
|
3009
|
+
code = "RUN_RECOVERY_BLOCKED";
|
|
3010
|
+
constructor(message) {
|
|
3011
|
+
super(message);
|
|
3012
|
+
this.name = "RunRecoveryBlockedError";
|
|
3013
|
+
}
|
|
3014
|
+
};
|
|
3015
|
+
var RunPauseRequested = class extends Error {
|
|
3016
|
+
code = "RUN_PAUSE_REQUESTED";
|
|
3017
|
+
constructor(message = "Run paused by user") {
|
|
3018
|
+
super(message);
|
|
3019
|
+
this.name = "RunPauseRequested";
|
|
3020
|
+
}
|
|
3021
|
+
};
|
|
3022
|
+
function isRunPauseSignal(signal) {
|
|
3023
|
+
const reason = signal?.reason;
|
|
3024
|
+
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3007
3027
|
// src/runtime-kernel/graph-engine/engine.ts
|
|
3008
3028
|
var logger2 = new Logger("GraphExecutor");
|
|
3009
3029
|
function isRecord4(value) {
|
|
@@ -3313,6 +3333,7 @@ var GraphExecutor = class {
|
|
|
3313
3333
|
reportStepsUsed(stepCount);
|
|
3314
3334
|
const signalRaw = state.local?.signal;
|
|
3315
3335
|
if (isAbortSignal2(signalRaw) && signalRaw.aborted) {
|
|
3336
|
+
if (!isRunPauseSignal(signalRaw)) await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
3316
3337
|
logger2.warn("[GraphExecutor] \u6536\u5230 AbortSignal\uFF0C\u7ACB\u5373\u505C\u6B62\u63A8\u7406\u5FAA\u73AF");
|
|
3317
3338
|
this.ephemeralLocals.delete(checkpointKey);
|
|
3318
3339
|
throwAbortError();
|
|
@@ -3363,6 +3384,12 @@ var GraphExecutor = class {
|
|
|
3363
3384
|
allEvents.push(...stepResolution.events);
|
|
3364
3385
|
}
|
|
3365
3386
|
state = stepResolution.state;
|
|
3387
|
+
const completedSignal = state.local?.signal;
|
|
3388
|
+
if (isAbortSignal2(completedSignal) && completedSignal.aborted && !isRunPauseSignal(completedSignal)) {
|
|
3389
|
+
await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
3390
|
+
this.ephemeralLocals.delete(checkpointKey);
|
|
3391
|
+
throwAbortError();
|
|
3392
|
+
}
|
|
3366
3393
|
if (stepResolution.action.kind === "route") {
|
|
3367
3394
|
logger2.info("[GraphExecutor] \u8DEF\u7531\u5207\u6362", {
|
|
3368
3395
|
fromNodeId: stepResolution.action.fromNodeId,
|
|
@@ -8293,26 +8320,6 @@ function buildCancelledToolBatchLocalState(local, runtimeEvents) {
|
|
|
8293
8320
|
function recordToolProtocolError(params) {
|
|
8294
8321
|
}
|
|
8295
8322
|
|
|
8296
|
-
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
8297
|
-
var RunRecoveryBlockedError = class extends Error {
|
|
8298
|
-
code = "RUN_RECOVERY_BLOCKED";
|
|
8299
|
-
constructor(message) {
|
|
8300
|
-
super(message);
|
|
8301
|
-
this.name = "RunRecoveryBlockedError";
|
|
8302
|
-
}
|
|
8303
|
-
};
|
|
8304
|
-
var RunPauseRequested = class extends Error {
|
|
8305
|
-
code = "RUN_PAUSE_REQUESTED";
|
|
8306
|
-
constructor(message = "Run paused by user") {
|
|
8307
|
-
super(message);
|
|
8308
|
-
this.name = "RunPauseRequested";
|
|
8309
|
-
}
|
|
8310
|
-
};
|
|
8311
|
-
function isRunPauseSignal(signal) {
|
|
8312
|
-
const reason = signal?.reason;
|
|
8313
|
-
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
8314
|
-
}
|
|
8315
|
-
|
|
8316
8323
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
8317
8324
|
async function executeRecoverableTool(input) {
|
|
8318
8325
|
const local = input.state.local;
|
|
@@ -8514,7 +8521,30 @@ var ToolNode = class {
|
|
|
8514
8521
|
async run(state) {
|
|
8515
8522
|
const events = [];
|
|
8516
8523
|
while (true) {
|
|
8517
|
-
|
|
8524
|
+
let result;
|
|
8525
|
+
try {
|
|
8526
|
+
result = await this.runNextPendingToolCall(state);
|
|
8527
|
+
} catch (error) {
|
|
8528
|
+
if (isToolExecutionAbort(error) && !isRunPauseSignal(state.local?.signal)) {
|
|
8529
|
+
await this.cancel(state);
|
|
8530
|
+
}
|
|
8531
|
+
throw error;
|
|
8532
|
+
}
|
|
8533
|
+
const signal = state.local?.signal;
|
|
8534
|
+
if (isAbortSignal(signal) && signal.aborted && !isRunPauseSignal(signal)) {
|
|
8535
|
+
await this.cancel(state);
|
|
8536
|
+
const error = new Error("The user aborted a request.");
|
|
8537
|
+
error.name = "AbortError";
|
|
8538
|
+
throw error;
|
|
8539
|
+
}
|
|
8540
|
+
if (result.kind === "interrupted") {
|
|
8541
|
+
await commitToolBoundary(state, {
|
|
8542
|
+
kind: "route",
|
|
8543
|
+
nextNodeId: "llm",
|
|
8544
|
+
events: result.events
|
|
8545
|
+
});
|
|
8546
|
+
throw result.error;
|
|
8547
|
+
}
|
|
8518
8548
|
await commitToolBoundary(state, result);
|
|
8519
8549
|
if (Array.isArray(result.events) && result.events.length > 0) {
|
|
8520
8550
|
events.push(...result.events);
|
|
@@ -8528,6 +8558,14 @@ var ToolNode = class {
|
|
|
8528
8558
|
};
|
|
8529
8559
|
}
|
|
8530
8560
|
}
|
|
8561
|
+
async cancel(state) {
|
|
8562
|
+
settlePendingToolCallsAfterAbort({
|
|
8563
|
+
state,
|
|
8564
|
+
calls: parsePendingToolCalls(state.local?.pendingToolCalls ?? []),
|
|
8565
|
+
toolCatalog: this.toolRuntime
|
|
8566
|
+
});
|
|
8567
|
+
await commitToolBoundary(state, { kind: "yield"});
|
|
8568
|
+
}
|
|
8531
8569
|
async runNextPendingToolCall(state) {
|
|
8532
8570
|
const calls = parsePendingToolCalls(state.local?.pendingToolCalls ?? []);
|
|
8533
8571
|
const signalRaw = state.local?.signal;
|
|
@@ -8947,7 +8985,11 @@ var ToolNode = class {
|
|
|
8947
8985
|
nextProtocolErrorCount: fuse.nextCount
|
|
8948
8986
|
});
|
|
8949
8987
|
if (fuse.shouldFuse && remainingCalls.length === 0) {
|
|
8950
|
-
|
|
8988
|
+
return {
|
|
8989
|
+
kind: "interrupted",
|
|
8990
|
+
error: createToolProtocolFuseError(fuse.nextCount, context.exec.error),
|
|
8991
|
+
events: context.bridge.getRuntimeEvents()
|
|
8992
|
+
};
|
|
8951
8993
|
}
|
|
8952
8994
|
if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
|
|
8953
8995
|
return { kind: "yield", events: context.bridge.getRuntimeEvents() };
|