@linnlabs/linnkit 0.44.0 → 0.45.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 CHANGED
@@ -12,6 +12,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
12
 
13
13
  ---
14
14
 
15
+ ## [0.45.0] - 2026-11-21
16
+
17
+ ### Added
18
+
19
+ - Abort grace period for tools. After a pause or cancel signal, `ToolNode`
20
+ waits at most `abortGraceMs` (new optional `ToolNodeDependencies` field,
21
+ default 3000 ms) for the running tool to
22
+ finish. A tool that ignores the signal is then treated as an `AbortError`,
23
+ exactly like a tool that honoured it: a pause leaves the call for
24
+ reconciliation before continuing, a cancel settles it as cancelled. Its late
25
+ result is discarded and never reaches history. The deadline starts only when
26
+ the signal fires and does not limit normal tool run time. Previously a
27
+ pause could stay unsettled (`status=paused`, no `pausedAt`) for as long as
28
+ such a tool ran, holding the conversation's concurrency slot.
29
+
30
+ ---
31
+
15
32
  ## [0.44.0] - 2026-11-18
16
33
 
17
34
  ### Added
package/dist/cli.cjs CHANGED
@@ -8621,9 +8621,49 @@ function recordToolProtocolError(params) {
8621
8621
  }
8622
8622
 
8623
8623
  // src/runtime-kernel/graph-engine/nodes/toolNode.recovery.ts
8624
+ var DEFAULT_TOOL_ABORT_GRACE_MS = 3e3;
8625
+ function settleToolWithinAbortGrace(input) {
8626
+ const { execution, signal, graceMs } = input;
8627
+ if (!signal) return execution;
8628
+ return new Promise((resolve5, reject) => {
8629
+ let timer;
8630
+ const cleanup = () => {
8631
+ if (timer !== void 0) clearTimeout(timer);
8632
+ signal.removeEventListener("abort", startGrace);
8633
+ };
8634
+ function startGrace() {
8635
+ timer = setTimeout(() => {
8636
+ cleanup();
8637
+ execution.catch(() => void 0);
8638
+ input.onAbandon?.();
8639
+ const error = new Error("Tool did not stop within the abort grace period; its late outcome is discarded.");
8640
+ error.name = "AbortError";
8641
+ reject(error);
8642
+ }, graceMs);
8643
+ }
8644
+ if (signal.aborted) startGrace();
8645
+ else signal.addEventListener("abort", startGrace, { once: true });
8646
+ execution.then(
8647
+ (value) => {
8648
+ cleanup();
8649
+ resolve5(value);
8650
+ },
8651
+ (error) => {
8652
+ cleanup();
8653
+ reject(error);
8654
+ }
8655
+ );
8656
+ });
8657
+ }
8624
8658
  async function executeRecoverableTool(input) {
8625
8659
  const local = input.state.local;
8626
- if (!local?.commitExecutionBoundary) return input.execute();
8660
+ const run = () => settleToolWithinAbortGrace({
8661
+ execution: input.execute(),
8662
+ signal: local?.signal,
8663
+ graceMs: input.abortGraceMs ?? DEFAULT_TOOL_ABORT_GRACE_MS,
8664
+ onAbandon: input.onAbandon
8665
+ });
8666
+ if (!local?.commitExecutionBoundary) return run();
8627
8667
  if (local.executingToolCallId) {
8628
8668
  if (local.executingToolCallId !== input.call.id) {
8629
8669
  throw new RunRecoveryBlockedError("Pending tool identity does not match execution intent");
@@ -8636,7 +8676,7 @@ async function executeRecoverableTool(input) {
8636
8676
  }
8637
8677
  local.executingToolCallId = input.call.id;
8638
8678
  await local.commitExecutionBoundary(input.state);
8639
- const result = await input.execute();
8679
+ const result = await run();
8640
8680
  if (!result.success && isRunPauseSignal(local.signal)) {
8641
8681
  const error = new Error("Tool execution paused before its outcome was confirmed");
8642
8682
  error.name = "AbortError";
@@ -8756,7 +8796,9 @@ var ToolNode = class {
8756
8796
  auditPort;
8757
8797
  modelInputResolver;
8758
8798
  idempotencyInFlight = /* @__PURE__ */ new Map();
8799
+ abortGraceMs;
8759
8800
  constructor(dependencies) {
8801
+ this.abortGraceMs = dependencies.abortGraceMs;
8760
8802
  this.toolRuntime = dependencies.toolRuntime;
8761
8803
  this.observationPreview = dependencies.observationPreview;
8762
8804
  this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
@@ -8974,6 +9016,13 @@ var ToolNode = class {
8974
9016
  state,
8975
9017
  call,
8976
9018
  context: prepared.toolContext,
9019
+ abortGraceMs: this.abortGraceMs,
9020
+ onAbandon: () => logger11.warn("[ToolNode] \u5DE5\u5177\u672A\u5728\u505C\u6B62\u671F\u9650\u5185\u7ED3\u675F\uFF0C\u6309\u4E2D\u65AD\u5904\u7406\u5E76\u4E22\u5F03\u8FDF\u5230\u7ED3\u679C", {
9021
+ toolName: execution.toolName,
9022
+ toolCallId: execution.toolCallId,
9023
+ conversationId: prepared.conversationId,
9024
+ turnId: prepared.turnId
9025
+ }),
8977
9026
  execute: () => executeToolWithIdempotency({
8978
9027
  idempotencyKey: execution.idempotencyKey,
8979
9028
  inFlight: this.idempotencyInFlight,