@linnlabs/linnkit 0.35.1 → 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 +21 -1
- package/dist/cli.cjs +64 -24
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +64 -24
- 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/index.cjs +64 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +64 -24
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +64 -24
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +64 -24
- 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/run-supervisor/definitions/runSupervisorContracts.d.cts +3 -1
- package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +3 -1
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.cts +2 -2
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.ts +2 -2
- package/dist/runtime-kernel.cjs +64 -24
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.js +64 -24
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +64 -24
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +64 -24
- package/dist/testkit.js.map +1 -1
- package/docs/integration/persistence.md +9 -0
- package/docs/integration/run-supervisor.md +2 -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,22 @@ 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
|
+
}
|
|
8892
8914
|
await commitToolBoundary(state, result);
|
|
8893
8915
|
if (Array.isArray(result.events) && result.events.length > 0) {
|
|
8894
8916
|
events.push(...result.events);
|
|
@@ -8902,6 +8924,14 @@ var ToolNode = class {
|
|
|
8902
8924
|
};
|
|
8903
8925
|
}
|
|
8904
8926
|
}
|
|
8927
|
+
async cancel(state) {
|
|
8928
|
+
settlePendingToolCallsAfterAbort({
|
|
8929
|
+
state,
|
|
8930
|
+
calls: parsePendingToolCalls(state.local?.pendingToolCalls ?? []),
|
|
8931
|
+
toolCatalog: this.toolRuntime
|
|
8932
|
+
});
|
|
8933
|
+
await commitToolBoundary(state, { kind: "yield"});
|
|
8934
|
+
}
|
|
8905
8935
|
async runNextPendingToolCall(state) {
|
|
8906
8936
|
const calls = parsePendingToolCalls(state.local?.pendingToolCalls ?? []);
|
|
8907
8937
|
const signalRaw = state.local?.signal;
|
|
@@ -13495,7 +13525,7 @@ function createAwaitingUserWatcher(options) {
|
|
|
13495
13525
|
const onClose = () => {
|
|
13496
13526
|
dispose();
|
|
13497
13527
|
};
|
|
13498
|
-
eventBus.on("event", onEvent);
|
|
13528
|
+
if (options.stateOwner !== "host") eventBus.on("event", onEvent);
|
|
13499
13529
|
eventBus.on("close", onClose);
|
|
13500
13530
|
return dispose;
|
|
13501
13531
|
}
|
|
@@ -13971,6 +14001,7 @@ var DefaultRunSupervisor = class {
|
|
|
13971
14001
|
this.runSlotLimiter = createRunSlotLimiter({ maxActiveRuns: options.maxActiveRuns });
|
|
13972
14002
|
this.runConcurrencyKeys = createRunConcurrencyKeyRegistry();
|
|
13973
14003
|
this.awaitingUserWatcher = createAwaitingUserWatcher({
|
|
14004
|
+
stateOwner: options.awaitingUserStateOwner,
|
|
13974
14005
|
markAwaitingUser: (runId, patch) => this.getHandle(runId).markAwaitingUser(patch),
|
|
13975
14006
|
onDisposed: (runId) => {
|
|
13976
14007
|
this.eventWatchDisposers.delete(runId);
|
|
@@ -14167,8 +14198,17 @@ var DefaultRunSupervisor = class {
|
|
|
14167
14198
|
canRestoreRun: this.canRestoreRun
|
|
14168
14199
|
});
|
|
14169
14200
|
}
|
|
14170
|
-
async pause(runId, reason) {
|
|
14171
|
-
await this.withRunControlLock(runId, () =>
|
|
14201
|
+
async pause(runId, reason, expectedExecutionId) {
|
|
14202
|
+
await this.withRunControlLock(runId, async () => {
|
|
14203
|
+
const handle = this.getHandle(runId);
|
|
14204
|
+
if (expectedExecutionId !== void 0) {
|
|
14205
|
+
const record = await this.registryStore.load(runId);
|
|
14206
|
+
if (record?.metadata?.executionId !== expectedExecutionId) {
|
|
14207
|
+
throw new RunInteractionConflictError(runId, "pause execution ownership has changed");
|
|
14208
|
+
}
|
|
14209
|
+
}
|
|
14210
|
+
await handle.pause(reason);
|
|
14211
|
+
});
|
|
14172
14212
|
}
|
|
14173
14213
|
async resumePausedRun(input) {
|
|
14174
14214
|
return this.withRunControlLock(input.runId, async () => {
|