@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/index.cjs
CHANGED
|
@@ -3901,6 +3901,26 @@ function resolveAssistantReplayParts(response) {
|
|
|
3901
3901
|
return response.assistant_replay_parts;
|
|
3902
3902
|
}
|
|
3903
3903
|
|
|
3904
|
+
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
3905
|
+
var RunRecoveryBlockedError = class extends Error {
|
|
3906
|
+
code = "RUN_RECOVERY_BLOCKED";
|
|
3907
|
+
constructor(message) {
|
|
3908
|
+
super(message);
|
|
3909
|
+
this.name = "RunRecoveryBlockedError";
|
|
3910
|
+
}
|
|
3911
|
+
};
|
|
3912
|
+
var RunPauseRequested = class extends Error {
|
|
3913
|
+
code = "RUN_PAUSE_REQUESTED";
|
|
3914
|
+
constructor(message = "Run paused by user") {
|
|
3915
|
+
super(message);
|
|
3916
|
+
this.name = "RunPauseRequested";
|
|
3917
|
+
}
|
|
3918
|
+
};
|
|
3919
|
+
function isRunPauseSignal(signal) {
|
|
3920
|
+
const reason = signal?.reason;
|
|
3921
|
+
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
3922
|
+
}
|
|
3923
|
+
|
|
3904
3924
|
// src/runtime-kernel/graph-engine/engine.ts
|
|
3905
3925
|
var logger2 = new Logger("GraphExecutor");
|
|
3906
3926
|
function isRecord4(value) {
|
|
@@ -4210,6 +4230,7 @@ var GraphExecutor = class {
|
|
|
4210
4230
|
reportStepsUsed(stepCount);
|
|
4211
4231
|
const signalRaw = state.local?.signal;
|
|
4212
4232
|
if (isAbortSignal2(signalRaw) && signalRaw.aborted) {
|
|
4233
|
+
if (!isRunPauseSignal(signalRaw)) await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
4213
4234
|
logger2.warn("[GraphExecutor] \u6536\u5230 AbortSignal\uFF0C\u7ACB\u5373\u505C\u6B62\u63A8\u7406\u5FAA\u73AF");
|
|
4214
4235
|
this.ephemeralLocals.delete(checkpointKey);
|
|
4215
4236
|
throwAbortError();
|
|
@@ -4260,6 +4281,12 @@ var GraphExecutor = class {
|
|
|
4260
4281
|
allEvents.push(...stepResolution.events);
|
|
4261
4282
|
}
|
|
4262
4283
|
state = stepResolution.state;
|
|
4284
|
+
const completedSignal = state.local?.signal;
|
|
4285
|
+
if (isAbortSignal2(completedSignal) && completedSignal.aborted && !isRunPauseSignal(completedSignal)) {
|
|
4286
|
+
await this.nodes.get(state.nodeId)?.cancel?.(state);
|
|
4287
|
+
this.ephemeralLocals.delete(checkpointKey);
|
|
4288
|
+
throwAbortError();
|
|
4289
|
+
}
|
|
4263
4290
|
if (stepResolution.action.kind === "route") {
|
|
4264
4291
|
logger2.info("[GraphExecutor] \u8DEF\u7531\u5207\u6362", {
|
|
4265
4292
|
fromNodeId: stepResolution.action.fromNodeId,
|
|
@@ -9486,26 +9513,6 @@ function recordToolProtocolError(params) {
|
|
|
9486
9513
|
recorder?.recordToolProtocolError?.(params);
|
|
9487
9514
|
}
|
|
9488
9515
|
|
|
9489
|
-
// src/runtime-kernel/graph-engine/definitions/runContinuation.ts
|
|
9490
|
-
var RunRecoveryBlockedError = class extends Error {
|
|
9491
|
-
code = "RUN_RECOVERY_BLOCKED";
|
|
9492
|
-
constructor(message) {
|
|
9493
|
-
super(message);
|
|
9494
|
-
this.name = "RunRecoveryBlockedError";
|
|
9495
|
-
}
|
|
9496
|
-
};
|
|
9497
|
-
var RunPauseRequested = class extends Error {
|
|
9498
|
-
code = "RUN_PAUSE_REQUESTED";
|
|
9499
|
-
constructor(message = "Run paused by user") {
|
|
9500
|
-
super(message);
|
|
9501
|
-
this.name = "RunPauseRequested";
|
|
9502
|
-
}
|
|
9503
|
-
};
|
|
9504
|
-
function isRunPauseSignal(signal) {
|
|
9505
|
-
const reason = signal?.reason;
|
|
9506
|
-
return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
|
|
9507
|
-
}
|
|
9508
|
-
|
|
9509
9516
|
// src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
|
|
9510
9517
|
async function executeRecoverableTool(input) {
|
|
9511
9518
|
const local = input.state.local;
|
|
@@ -9707,7 +9714,22 @@ var ToolNode = class {
|
|
|
9707
9714
|
async run(state) {
|
|
9708
9715
|
const events = [];
|
|
9709
9716
|
while (true) {
|
|
9710
|
-
|
|
9717
|
+
let result;
|
|
9718
|
+
try {
|
|
9719
|
+
result = await this.runNextPendingToolCall(state);
|
|
9720
|
+
} catch (error) {
|
|
9721
|
+
if (isToolExecutionAbort(error) && !isRunPauseSignal(state.local?.signal)) {
|
|
9722
|
+
await this.cancel(state);
|
|
9723
|
+
}
|
|
9724
|
+
throw error;
|
|
9725
|
+
}
|
|
9726
|
+
const signal = state.local?.signal;
|
|
9727
|
+
if (isAbortSignal(signal) && signal.aborted && !isRunPauseSignal(signal)) {
|
|
9728
|
+
await this.cancel(state);
|
|
9729
|
+
const error = new Error("The user aborted a request.");
|
|
9730
|
+
error.name = "AbortError";
|
|
9731
|
+
throw error;
|
|
9732
|
+
}
|
|
9711
9733
|
await commitToolBoundary(state, result);
|
|
9712
9734
|
if (Array.isArray(result.events) && result.events.length > 0) {
|
|
9713
9735
|
events.push(...result.events);
|
|
@@ -9721,6 +9743,14 @@ var ToolNode = class {
|
|
|
9721
9743
|
};
|
|
9722
9744
|
}
|
|
9723
9745
|
}
|
|
9746
|
+
async cancel(state) {
|
|
9747
|
+
settlePendingToolCallsAfterAbort({
|
|
9748
|
+
state,
|
|
9749
|
+
calls: parsePendingToolCalls(state.local?.pendingToolCalls ?? []),
|
|
9750
|
+
toolCatalog: this.toolRuntime
|
|
9751
|
+
});
|
|
9752
|
+
await commitToolBoundary(state, { kind: "yield"});
|
|
9753
|
+
}
|
|
9724
9754
|
async runNextPendingToolCall(state) {
|
|
9725
9755
|
const calls = parsePendingToolCalls(state.local?.pendingToolCalls ?? []);
|
|
9726
9756
|
const signalRaw = state.local?.signal;
|
|
@@ -14314,7 +14344,7 @@ function createAwaitingUserWatcher(options) {
|
|
|
14314
14344
|
const onClose = () => {
|
|
14315
14345
|
dispose();
|
|
14316
14346
|
};
|
|
14317
|
-
eventBus.on("event", onEvent);
|
|
14347
|
+
if (options.stateOwner !== "host") eventBus.on("event", onEvent);
|
|
14318
14348
|
eventBus.on("close", onClose);
|
|
14319
14349
|
return dispose;
|
|
14320
14350
|
}
|
|
@@ -14790,6 +14820,7 @@ var DefaultRunSupervisor = class {
|
|
|
14790
14820
|
this.runSlotLimiter = createRunSlotLimiter({ maxActiveRuns: options.maxActiveRuns });
|
|
14791
14821
|
this.runConcurrencyKeys = createRunConcurrencyKeyRegistry();
|
|
14792
14822
|
this.awaitingUserWatcher = createAwaitingUserWatcher({
|
|
14823
|
+
stateOwner: options.awaitingUserStateOwner,
|
|
14793
14824
|
markAwaitingUser: (runId, patch) => this.getHandle(runId).markAwaitingUser(patch),
|
|
14794
14825
|
onDisposed: (runId) => {
|
|
14795
14826
|
this.eventWatchDisposers.delete(runId);
|
|
@@ -14986,8 +15017,17 @@ var DefaultRunSupervisor = class {
|
|
|
14986
15017
|
canRestoreRun: this.canRestoreRun
|
|
14987
15018
|
});
|
|
14988
15019
|
}
|
|
14989
|
-
async pause(runId, reason) {
|
|
14990
|
-
await this.withRunControlLock(runId, () =>
|
|
15020
|
+
async pause(runId, reason, expectedExecutionId) {
|
|
15021
|
+
await this.withRunControlLock(runId, async () => {
|
|
15022
|
+
const handle = this.getHandle(runId);
|
|
15023
|
+
if (expectedExecutionId !== void 0) {
|
|
15024
|
+
const record = await this.registryStore.load(runId);
|
|
15025
|
+
if (record?.metadata?.executionId !== expectedExecutionId) {
|
|
15026
|
+
throw new RunInteractionConflictError(runId, "pause execution ownership has changed");
|
|
15027
|
+
}
|
|
15028
|
+
}
|
|
15029
|
+
await handle.pause(reason);
|
|
15030
|
+
});
|
|
14991
15031
|
}
|
|
14992
15032
|
async resumePausedRun(input) {
|
|
14993
15033
|
return this.withRunControlLock(input.runId, async () => {
|