@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/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;
|
|
@@ -13305,7 +13335,7 @@ function createAwaitingUserWatcher(options) {
|
|
|
13305
13335
|
const onClose = () => {
|
|
13306
13336
|
dispose();
|
|
13307
13337
|
};
|
|
13308
|
-
eventBus.on("event", onEvent);
|
|
13338
|
+
if (options.stateOwner !== "host") eventBus.on("event", onEvent);
|
|
13309
13339
|
eventBus.on("close", onClose);
|
|
13310
13340
|
return dispose;
|
|
13311
13341
|
}
|
|
@@ -13781,6 +13811,7 @@ var DefaultRunSupervisor = class {
|
|
|
13781
13811
|
this.runSlotLimiter = createRunSlotLimiter({ maxActiveRuns: options.maxActiveRuns });
|
|
13782
13812
|
this.runConcurrencyKeys = createRunConcurrencyKeyRegistry();
|
|
13783
13813
|
this.awaitingUserWatcher = createAwaitingUserWatcher({
|
|
13814
|
+
stateOwner: options.awaitingUserStateOwner,
|
|
13784
13815
|
markAwaitingUser: (runId, patch) => this.getHandle(runId).markAwaitingUser(patch),
|
|
13785
13816
|
onDisposed: (runId) => {
|
|
13786
13817
|
this.eventWatchDisposers.delete(runId);
|
|
@@ -13977,8 +14008,17 @@ var DefaultRunSupervisor = class {
|
|
|
13977
14008
|
canRestoreRun: this.canRestoreRun
|
|
13978
14009
|
});
|
|
13979
14010
|
}
|
|
13980
|
-
async pause(runId, reason) {
|
|
13981
|
-
await this.withRunControlLock(runId, () =>
|
|
14011
|
+
async pause(runId, reason, expectedExecutionId) {
|
|
14012
|
+
await this.withRunControlLock(runId, async () => {
|
|
14013
|
+
const handle = this.getHandle(runId);
|
|
14014
|
+
if (expectedExecutionId !== void 0) {
|
|
14015
|
+
const record = await this.registryStore.load(runId);
|
|
14016
|
+
if (record?.metadata?.executionId !== expectedExecutionId) {
|
|
14017
|
+
throw new RunInteractionConflictError(runId, "pause execution ownership has changed");
|
|
14018
|
+
}
|
|
14019
|
+
}
|
|
14020
|
+
await handle.pause(reason);
|
|
14021
|
+
});
|
|
13982
14022
|
}
|
|
13983
14023
|
async resumePausedRun(input) {
|
|
13984
14024
|
return this.withRunControlLock(input.runId, async () => {
|