@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.
Files changed (34) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/cli.cjs +64 -24
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +64 -24
  5. package/dist/cli.js.map +1 -1
  6. package/dist/context-manager.cjs.map +1 -1
  7. package/dist/context-manager.js.map +1 -1
  8. package/dist/index.cjs +64 -24
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.js +64 -24
  11. package/dist/index.js.map +1 -1
  12. package/dist/quickstart.cjs +64 -24
  13. package/dist/quickstart.cjs.map +1 -1
  14. package/dist/quickstart.js +64 -24
  15. package/dist/quickstart.js.map +1 -1
  16. package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +1 -0
  17. package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +1 -0
  18. package/dist/runtime-kernel/graph-engine/types.d.cts +2 -0
  19. package/dist/runtime-kernel/graph-engine/types.d.ts +2 -0
  20. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.cts +3 -1
  21. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +3 -1
  22. package/dist/runtime-kernel/run-supervisor/runSupervisor.d.cts +2 -2
  23. package/dist/runtime-kernel/run-supervisor/runSupervisor.d.ts +2 -2
  24. package/dist/runtime-kernel.cjs +64 -24
  25. package/dist/runtime-kernel.cjs.map +1 -1
  26. package/dist/runtime-kernel.js +64 -24
  27. package/dist/runtime-kernel.js.map +1 -1
  28. package/dist/testkit.cjs +64 -24
  29. package/dist/testkit.cjs.map +1 -1
  30. package/dist/testkit.js +64 -24
  31. package/dist/testkit.js.map +1 -1
  32. package/docs/integration/persistence.md +9 -0
  33. package/docs/integration/run-supervisor.md +2 -0
  34. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -12,7 +12,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
12
 
13
13
  ---
14
14
 
15
- ## [Unreleased]
15
+ ## [0.37.0] - 2026-09-12
16
+
17
+ ### Added
18
+
19
+ - Optional GraphNode cancellation settlement hook for already-admitted work at node transitions.
20
+ It never starts work and is not invoked for resumable pauses.
21
+
22
+ ### Fixed
23
+
24
+ - Commit cancelled ToolNode batches before AbortError leaves the graph, preserving completed
25
+ tool outcomes and pairing unstarted calls. Durable Hosts no longer discard their staged
26
+ terminal results when closing the execution checkpoint writer.
27
+
28
+ ## [0.36.0] - 2026-09-11
29
+
30
+ ### Added
31
+
32
+ - Explicit Host ownership of awaiting-user lifecycle for atomic checkpoint integrations.
33
+ Provisional interaction events no longer have to change execution ownership before commit.
34
+ - Pause commands can fence the expected execution identity inside the Supervisor control
35
+ lock, so a queued stale pause cannot interrupt a newly continued execution.
16
36
 
17
37
  ## [0.35.1] - 2026-09-11
18
38
 
package/dist/cli.cjs CHANGED
@@ -3007,6 +3007,26 @@ function resolveAssistantReplayParts(response) {
3007
3007
  return response.assistant_replay_parts;
3008
3008
  }
3009
3009
 
3010
+ // src/runtime-kernel/graph-engine/definitions/runContinuation.ts
3011
+ var RunRecoveryBlockedError = class extends Error {
3012
+ code = "RUN_RECOVERY_BLOCKED";
3013
+ constructor(message) {
3014
+ super(message);
3015
+ this.name = "RunRecoveryBlockedError";
3016
+ }
3017
+ };
3018
+ var RunPauseRequested = class extends Error {
3019
+ code = "RUN_PAUSE_REQUESTED";
3020
+ constructor(message = "Run paused by user") {
3021
+ super(message);
3022
+ this.name = "RunPauseRequested";
3023
+ }
3024
+ };
3025
+ function isRunPauseSignal(signal) {
3026
+ const reason = signal?.reason;
3027
+ return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
3028
+ }
3029
+
3010
3030
  // src/runtime-kernel/graph-engine/engine.ts
3011
3031
  var logger2 = new Logger("GraphExecutor");
3012
3032
  function isRecord4(value) {
@@ -3316,6 +3336,7 @@ var GraphExecutor = class {
3316
3336
  reportStepsUsed(stepCount);
3317
3337
  const signalRaw = state.local?.signal;
3318
3338
  if (isAbortSignal2(signalRaw) && signalRaw.aborted) {
3339
+ if (!isRunPauseSignal(signalRaw)) await this.nodes.get(state.nodeId)?.cancel?.(state);
3319
3340
  logger2.warn("[GraphExecutor] \u6536\u5230 AbortSignal\uFF0C\u7ACB\u5373\u505C\u6B62\u63A8\u7406\u5FAA\u73AF");
3320
3341
  this.ephemeralLocals.delete(checkpointKey);
3321
3342
  throwAbortError();
@@ -3366,6 +3387,12 @@ var GraphExecutor = class {
3366
3387
  allEvents.push(...stepResolution.events);
3367
3388
  }
3368
3389
  state = stepResolution.state;
3390
+ const completedSignal = state.local?.signal;
3391
+ if (isAbortSignal2(completedSignal) && completedSignal.aborted && !isRunPauseSignal(completedSignal)) {
3392
+ await this.nodes.get(state.nodeId)?.cancel?.(state);
3393
+ this.ephemeralLocals.delete(checkpointKey);
3394
+ throwAbortError();
3395
+ }
3369
3396
  if (stepResolution.action.kind === "route") {
3370
3397
  logger2.info("[GraphExecutor] \u8DEF\u7531\u5207\u6362", {
3371
3398
  fromNodeId: stepResolution.action.fromNodeId,
@@ -8296,26 +8323,6 @@ function buildCancelledToolBatchLocalState(local, runtimeEvents) {
8296
8323
  function recordToolProtocolError(params) {
8297
8324
  }
8298
8325
 
8299
- // src/runtime-kernel/graph-engine/definitions/runContinuation.ts
8300
- var RunRecoveryBlockedError = class extends Error {
8301
- code = "RUN_RECOVERY_BLOCKED";
8302
- constructor(message) {
8303
- super(message);
8304
- this.name = "RunRecoveryBlockedError";
8305
- }
8306
- };
8307
- var RunPauseRequested = class extends Error {
8308
- code = "RUN_PAUSE_REQUESTED";
8309
- constructor(message = "Run paused by user") {
8310
- super(message);
8311
- this.name = "RunPauseRequested";
8312
- }
8313
- };
8314
- function isRunPauseSignal(signal) {
8315
- const reason = signal?.reason;
8316
- return signal?.aborted === true && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "RUN_PAUSE_REQUESTED";
8317
- }
8318
-
8319
8326
  // src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
8320
8327
  async function executeRecoverableTool(input) {
8321
8328
  const local = input.state.local;
@@ -8517,7 +8524,22 @@ var ToolNode = class {
8517
8524
  async run(state) {
8518
8525
  const events = [];
8519
8526
  while (true) {
8520
- const result = await this.runNextPendingToolCall(state);
8527
+ let result;
8528
+ try {
8529
+ result = await this.runNextPendingToolCall(state);
8530
+ } catch (error) {
8531
+ if (isToolExecutionAbort(error) && !isRunPauseSignal(state.local?.signal)) {
8532
+ await this.cancel(state);
8533
+ }
8534
+ throw error;
8535
+ }
8536
+ const signal = state.local?.signal;
8537
+ if (isAbortSignal(signal) && signal.aborted && !isRunPauseSignal(signal)) {
8538
+ await this.cancel(state);
8539
+ const error = new Error("The user aborted a request.");
8540
+ error.name = "AbortError";
8541
+ throw error;
8542
+ }
8521
8543
  await commitToolBoundary(state, result);
8522
8544
  if (Array.isArray(result.events) && result.events.length > 0) {
8523
8545
  events.push(...result.events);
@@ -8531,6 +8553,14 @@ var ToolNode = class {
8531
8553
  };
8532
8554
  }
8533
8555
  }
8556
+ async cancel(state) {
8557
+ settlePendingToolCallsAfterAbort({
8558
+ state,
8559
+ calls: parsePendingToolCalls(state.local?.pendingToolCalls ?? []),
8560
+ toolCatalog: this.toolRuntime
8561
+ });
8562
+ await commitToolBoundary(state, { kind: "yield"});
8563
+ }
8534
8564
  async runNextPendingToolCall(state) {
8535
8565
  const calls = parsePendingToolCalls(state.local?.pendingToolCalls ?? []);
8536
8566
  const signalRaw = state.local?.signal;
@@ -11946,7 +11976,7 @@ function createAwaitingUserWatcher(options) {
11946
11976
  const onClose = () => {
11947
11977
  dispose();
11948
11978
  };
11949
- eventBus.on("event", onEvent);
11979
+ if (options.stateOwner !== "host") eventBus.on("event", onEvent);
11950
11980
  eventBus.on("close", onClose);
11951
11981
  return dispose;
11952
11982
  }
@@ -12422,6 +12452,7 @@ var DefaultRunSupervisor = class {
12422
12452
  this.runSlotLimiter = createRunSlotLimiter({ maxActiveRuns: options.maxActiveRuns });
12423
12453
  this.runConcurrencyKeys = createRunConcurrencyKeyRegistry();
12424
12454
  this.awaitingUserWatcher = createAwaitingUserWatcher({
12455
+ stateOwner: options.awaitingUserStateOwner,
12425
12456
  markAwaitingUser: (runId, patch) => this.getHandle(runId).markAwaitingUser(patch),
12426
12457
  onDisposed: (runId) => {
12427
12458
  this.eventWatchDisposers.delete(runId);
@@ -12618,8 +12649,17 @@ var DefaultRunSupervisor = class {
12618
12649
  canRestoreRun: this.canRestoreRun
12619
12650
  });
12620
12651
  }
12621
- async pause(runId, reason) {
12622
- await this.withRunControlLock(runId, () => this.getHandle(runId).pause(reason));
12652
+ async pause(runId, reason, expectedExecutionId) {
12653
+ await this.withRunControlLock(runId, async () => {
12654
+ const handle = this.getHandle(runId);
12655
+ if (expectedExecutionId !== void 0) {
12656
+ const record = await this.registryStore.load(runId);
12657
+ if (record?.metadata?.executionId !== expectedExecutionId) {
12658
+ throw new RunInteractionConflictError(runId, "pause execution ownership has changed");
12659
+ }
12660
+ }
12661
+ await handle.pause(reason);
12662
+ });
12623
12663
  }
12624
12664
  async resumePausedRun(input) {
12625
12665
  return this.withRunControlLock(input.runId, async () => {