@linnlabs/linnkit 0.36.0 → 0.37.1

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 CHANGED
@@ -14,6 +14,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
 
15
15
  ## [Unreleased]
16
16
 
17
+ ## [0.37.1] - 2026-09-12
18
+
19
+ ### Fixed
20
+
21
+ - Commit the complete tool batch before raising a protocol fuse. Atomic checkpoint Hosts
22
+ retain every admitted tool's terminal output when closing the execution, and explicit
23
+ continuation consumes the committed error history without repeating rejected calls.
24
+ A failed checkpoint commit remains a storage error rather than a falsely settled fuse.
25
+
26
+ ## [0.37.0] - 2026-09-12
27
+
28
+ ### Added
29
+
30
+ - Optional GraphNode cancellation settlement hook for already-admitted work at node transitions.
31
+ It never starts work and is not invoked for resumable pauses.
32
+
33
+ ### Fixed
34
+
35
+ - Commit cancelled ToolNode batches before AbortError leaves the graph, preserving completed
36
+ tool outcomes and pairing unstarted calls. Durable Hosts no longer discard their staged
37
+ terminal results when closing the execution checkpoint writer.
38
+
17
39
  ## [0.36.0] - 2026-09-11
18
40
 
19
41
  ### Added
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,30 @@ 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
+ }
8543
+ if (result.kind === "interrupted") {
8544
+ await commitToolBoundary(state, {
8545
+ kind: "route",
8546
+ nextNodeId: "llm",
8547
+ events: result.events
8548
+ });
8549
+ throw result.error;
8550
+ }
8521
8551
  await commitToolBoundary(state, result);
8522
8552
  if (Array.isArray(result.events) && result.events.length > 0) {
8523
8553
  events.push(...result.events);
@@ -8531,6 +8561,14 @@ var ToolNode = class {
8531
8561
  };
8532
8562
  }
8533
8563
  }
8564
+ async cancel(state) {
8565
+ settlePendingToolCallsAfterAbort({
8566
+ state,
8567
+ calls: parsePendingToolCalls(state.local?.pendingToolCalls ?? []),
8568
+ toolCatalog: this.toolRuntime
8569
+ });
8570
+ await commitToolBoundary(state, { kind: "yield"});
8571
+ }
8534
8572
  async runNextPendingToolCall(state) {
8535
8573
  const calls = parsePendingToolCalls(state.local?.pendingToolCalls ?? []);
8536
8574
  const signalRaw = state.local?.signal;
@@ -8950,7 +8988,11 @@ var ToolNode = class {
8950
8988
  nextProtocolErrorCount: fuse.nextCount
8951
8989
  });
8952
8990
  if (fuse.shouldFuse && remainingCalls.length === 0) {
8953
- throw createToolProtocolFuseError(fuse.nextCount, context.exec.error);
8991
+ return {
8992
+ kind: "interrupted",
8993
+ error: createToolProtocolFuseError(fuse.nextCount, context.exec.error),
8994
+ events: context.bridge.getRuntimeEvents()
8995
+ };
8954
8996
  }
8955
8997
  if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
8956
8998
  return { kind: "yield", events: context.bridge.getRuntimeEvents() };