@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/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,22 @@ 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
|
+
}
|
|
8632
8654
|
await commitToolBoundary(state, result);
|
|
8633
8655
|
if (Array.isArray(result.events) && result.events.length > 0) {
|
|
8634
8656
|
events.push(...result.events);
|
|
@@ -8642,6 +8664,14 @@ var ToolNode = class {
|
|
|
8642
8664
|
};
|
|
8643
8665
|
}
|
|
8644
8666
|
}
|
|
8667
|
+
async cancel(state) {
|
|
8668
|
+
settlePendingToolCallsAfterAbort({
|
|
8669
|
+
state,
|
|
8670
|
+
calls: parsePendingToolCalls(state.local?.pendingToolCalls ?? []),
|
|
8671
|
+
toolCatalog: this.toolRuntime
|
|
8672
|
+
});
|
|
8673
|
+
await commitToolBoundary(state, { kind: "yield"});
|
|
8674
|
+
}
|
|
8645
8675
|
async runNextPendingToolCall(state) {
|
|
8646
8676
|
const calls = parsePendingToolCalls(state.local?.pendingToolCalls ?? []);
|
|
8647
8677
|
const signalRaw = state.local?.signal;
|