@linnlabs/linnkit 0.36.0 → 0.37.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 +12 -1
- package/dist/cli.cjs +51 -21
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +51 -21
- 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/agentSpec.d.cts +30 -30
- package/dist/contracts/agentSpec.d.ts +30 -30
- package/dist/contracts/audit.d.cts +32 -32
- package/dist/contracts/audit.d.ts +32 -32
- package/dist/contracts/contextPolicy.d.cts +36 -36
- package/dist/contracts/contextPolicy.d.ts +36 -36
- package/dist/contracts/events.d.cts +1113 -1113
- package/dist/contracts/events.d.ts +1113 -1113
- package/dist/contracts/execution.d.cts +8 -8
- package/dist/contracts/execution.d.ts +8 -8
- package/dist/contracts/messages.d.cts +1178 -1178
- package/dist/contracts/messages.d.ts +1178 -1178
- package/dist/contracts/provider-continuation.d.cts +28 -28
- package/dist/contracts/provider-continuation.d.ts +28 -28
- package/dist/contracts/sse.d.cts +897 -897
- package/dist/contracts/sse.d.ts +897 -897
- package/dist/contracts/sub-run-trace-payload.d.cts +26 -26
- package/dist/contracts/sub-run-trace-payload.d.ts +26 -26
- package/dist/contracts/token-accounting.d.cts +46 -46
- package/dist/contracts/token-accounting.d.ts +46 -46
- package/dist/index.cjs +51 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -21
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +51 -21
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +51 -21
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/events/agentEvents.d.cts +172 -172
- package/dist/runtime-kernel/events/agentEvents.d.ts +172 -172
- 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 +51 -21
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.js +51 -21
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +51 -21
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +51 -21
- package/dist/testkit.js.map +1 -1
- package/docs/integration/persistence.md +9 -0
- package/package.json +2 -2
package/dist/runtime-kernel.js
CHANGED
|
@@ -2909,6 +2909,26 @@ function resolveAssistantReplayParts(response) {
|
|
|
2909
2909
|
return response.assistant_replay_parts;
|
|
2910
2910
|
}
|
|
2911
2911
|
|
|
2912
|
+
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
2913
|
+
var RunRecoveryBlockedError = class extends Error {
|
|
2914
|
+
code = "RUN_RECOVERY_BLOCKED";
|
|
2915
|
+
constructor(message) {
|
|
2916
|
+
super(message);
|
|
2917
|
+
this.name = "RunRecoveryBlockedError";
|
|
2918
|
+
}
|
|
2919
|
+
};
|
|
2920
|
+
var RunPauseRequested = class extends Error {
|
|
2921
|
+
code = "RUN_PAUSE_REQUESTED";
|
|
2922
|
+
constructor(message = "Run paused by user") {
|
|
2923
|
+
super(message);
|
|
2924
|
+
this.name = "RunPauseRequested";
|
|
2925
|
+
}
|
|
2926
|
+
};
|
|
2927
|
+
function isRunPauseSignal(signal) {
|
|
2928
|
+
const reason = signal?.reason;
|
|
2929
|
+
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2912
2932
|
// src/runtime-kernel/graph-engine/engine.ts
|
|
2913
2933
|
var logger2 = new Logger("GraphExecutor");
|
|
2914
2934
|
function isRecord4(value) {
|
|
@@ -3218,6 +3238,7 @@ var GraphExecutor = class {
|
|
|
3218
3238
|
reportStepsUsed(stepCount);
|
|
3219
3239
|
const signalRaw = state.local?.signal;
|
|
3220
3240
|
if (isAbortSignal2(signalRaw) && signalRaw.aborted) {
|
|
3241
|
+
if (!isRunPauseSignal(signalRaw)) await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
3221
3242
|
logger2.warn("[GraphExecutor] \u6536\u5230 AbortSignal\uFF0C\u7ACB\u5373\u505C\u6B62\u63A8\u7406\u5FAA\u73AF");
|
|
3222
3243
|
this.ephemeralLocals.delete(checkpointKey);
|
|
3223
3244
|
throwAbortError();
|
|
@@ -3268,6 +3289,12 @@ var GraphExecutor = class {
|
|
|
3268
3289
|
allEvents.push(...stepResolution.events);
|
|
3269
3290
|
}
|
|
3270
3291
|
state = stepResolution.state;
|
|
3292
|
+
const completedSignal = state.local?.signal;
|
|
3293
|
+
if (isAbortSignal2(completedSignal) && completedSignal.aborted && !isRunPauseSignal(completedSignal)) {
|
|
3294
|
+
await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
3295
|
+
this.ephemeralLocals.delete(checkpointKey);
|
|
3296
|
+
throwAbortError();
|
|
3297
|
+
}
|
|
3271
3298
|
if (stepResolution.action.kind === "route") {
|
|
3272
3299
|
logger2.info("[GraphExecutor] \u8DEF\u7531\u5207\u6362", {
|
|
3273
3300
|
fromNodeId: stepResolution.action.fromNodeId,
|
|
@@ -8477,26 +8504,6 @@ function buildCancelledToolBatchLocalState(local, runtimeEvents) {
|
|
|
8477
8504
|
function recordToolProtocolError(params) {
|
|
8478
8505
|
}
|
|
8479
8506
|
|
|
8480
|
-
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
8481
|
-
var RunRecoveryBlockedError = class extends Error {
|
|
8482
|
-
code = "RUN_RECOVERY_BLOCKED";
|
|
8483
|
-
constructor(message) {
|
|
8484
|
-
super(message);
|
|
8485
|
-
this.name = "RunRecoveryBlockedError";
|
|
8486
|
-
}
|
|
8487
|
-
};
|
|
8488
|
-
var RunPauseRequested = class extends Error {
|
|
8489
|
-
code = "RUN_PAUSE_REQUESTED";
|
|
8490
|
-
constructor(message = "Run paused by user") {
|
|
8491
|
-
super(message);
|
|
8492
|
-
this.name = "RunPauseRequested";
|
|
8493
|
-
}
|
|
8494
|
-
};
|
|
8495
|
-
function isRunPauseSignal(signal) {
|
|
8496
|
-
const reason = signal?.reason;
|
|
8497
|
-
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
8498
|
-
}
|
|
8499
|
-
|
|
8500
8507
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
8501
8508
|
async function executeRecoverableTool(input) {
|
|
8502
8509
|
const local = input.state.local;
|
|
@@ -8698,7 +8705,22 @@ var ToolNode = class {
|
|
|
8698
8705
|
async run(state) {
|
|
8699
8706
|
const events = [];
|
|
8700
8707
|
while (true) {
|
|
8701
|
-
|
|
8708
|
+
let result;
|
|
8709
|
+
try {
|
|
8710
|
+
result = await this.runNextPendingToolCall(state);
|
|
8711
|
+
} catch (error) {
|
|
8712
|
+
if (isToolExecutionAbort(error) && !isRunPauseSignal(state.local?.signal)) {
|
|
8713
|
+
await this.cancel(state);
|
|
8714
|
+
}
|
|
8715
|
+
throw error;
|
|
8716
|
+
}
|
|
8717
|
+
const signal = state.local?.signal;
|
|
8718
|
+
if (isAbortSignal(signal) && signal.aborted && !isRunPauseSignal(signal)) {
|
|
8719
|
+
await this.cancel(state);
|
|
8720
|
+
const error = new Error("The user aborted a request.");
|
|
8721
|
+
error.name = "AbortError";
|
|
8722
|
+
throw error;
|
|
8723
|
+
}
|
|
8702
8724
|
await commitToolBoundary(state, result);
|
|
8703
8725
|
if (Array.isArray(result.events) && result.events.length > 0) {
|
|
8704
8726
|
events.push(...result.events);
|
|
@@ -8712,6 +8734,14 @@ var ToolNode = class {
|
|
|
8712
8734
|
};
|
|
8713
8735
|
}
|
|
8714
8736
|
}
|
|
8737
|
+
async cancel(state) {
|
|
8738
|
+
settlePendingToolCallsAfterAbort({
|
|
8739
|
+
state,
|
|
8740
|
+
calls: parsePendingToolCalls(state.local?.pendingToolCalls ?? []),
|
|
8741
|
+
toolCatalog: this.toolRuntime
|
|
8742
|
+
});
|
|
8743
|
+
await commitToolBoundary(state, { kind: "yield"});
|
|
8744
|
+
}
|
|
8715
8745
|
async runNextPendingToolCall(state) {
|
|
8716
8746
|
const calls = parsePendingToolCalls(state.local?.pendingToolCalls ?? []);
|
|
8717
8747
|
const signalRaw = state.local?.signal;
|