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