@tangle-network/agent-runtime 0.293.1 → 0.293.2

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 (28) hide show
  1. package/dist/agent.js +1 -1
  2. package/dist/{coordination-driver-LbUK3IMQ.js → coordination-driver-DSaxqusu.js} +59 -5
  3. package/dist/coordination-driver-DSaxqusu.js.map +1 -0
  4. package/dist/{delegate-CDuZlRT_.js → delegate-D2I093YC.js} +2 -2
  5. package/dist/{delegate-CDuZlRT_.js.map → delegate-D2I093YC.js.map} +1 -1
  6. package/dist/durable.js +1 -1
  7. package/dist/{graph-DSwixoKG.js → graph-zehf9BmZ.js} +3 -3
  8. package/dist/{graph-DSwixoKG.js.map → graph-zehf9BmZ.js.map} +1 -1
  9. package/dist/index.js +3 -3
  10. package/dist/kernel.js +6 -6
  11. package/dist/{loop-runner-bin-L71Va2It.js → loop-runner-bin-oVxfhyGL.js} +2 -2
  12. package/dist/{loop-runner-bin-L71Va2It.js.map → loop-runner-bin-oVxfhyGL.js.map} +1 -1
  13. package/dist/loop-runner-bin.js +1 -1
  14. package/dist/mcp/bin.js +2 -2
  15. package/dist/mcp/index.js +3 -3
  16. package/dist/{provision-supervisor-fe4drWIA.js → provision-supervisor-b8XxFaiS.js} +2 -2
  17. package/dist/{provision-supervisor-fe4drWIA.js.map → provision-supervisor-b8XxFaiS.js.map} +1 -1
  18. package/dist/{runtime-CPcPipCE.js → runtime-DMrS3EkC.js} +6 -6
  19. package/dist/{runtime-CPcPipCE.js.map → runtime-DMrS3EkC.js.map} +1 -1
  20. package/dist/{server-B4IYJBai.js → server-nZw7hk9T.js} +2 -2
  21. package/dist/{server-B4IYJBai.js.map → server-nZw7hk9T.js.map} +1 -1
  22. package/dist/{supervise-C7fKoVK8.js → supervise-CCEhJufC.js} +10 -6
  23. package/dist/supervise-CCEhJufC.js.map +1 -0
  24. package/dist/testing.js +11 -11
  25. package/dist/tui/index.js +1 -1
  26. package/package.json +1 -1
  27. package/dist/coordination-driver-LbUK3IMQ.js.map +0 -1
  28. package/dist/supervise-C7fKoVK8.js.map +0 -1
package/dist/agent.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Ci as sandboxActProfileMaterialization, Ei as worktreeCliProfileMaterialization, Ti as validateProfileMaterialization, _i as promptControlProfileMaterialization, bi as promptResourceProfileMaterialization, di as AGENT_PROFILE_MATERIALIZATION_AXES, fi as assertProfileMaterialization, gi as profileMaterializationAxes, hi as fullProfileMaterialization, hn as createSandboxForSpec, mi as defineProfileMaterializationContract, pi as controlProfileMaterialization, sa as mapSandboxEvent, vi as promptModelProfileMaterialization, xi as renderProfileMaterializationIssues, yi as promptOnlyProfileMaterialization } from "./supervisor-Ca4b5Lt7.js";
2
- import "./runtime-CPcPipCE.js";
2
+ import "./runtime-DMrS3EkC.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import { existsSync, readFileSync, statSync } from "node:fs";
5
5
  import { isAbsolute, join, relative, resolve, sep } from "node:path";
@@ -7,6 +7,7 @@ import { randomUUID } from "node:crypto";
7
7
  import { mkdirSync, readFileSync, watch } from "node:fs";
8
8
  import { join } from "node:path";
9
9
  import { registry } from "zod";
10
+ import { AsyncLocalStorage } from "node:async_hooks";
10
11
  //#region src/runtime/supervise/detector-monitor.ts
11
12
  /**
12
13
  *
@@ -128,6 +129,53 @@ function createEventBus(now = Date.now) {
128
129
  };
129
130
  }
130
131
  //#endregion
132
+ //#region src/mcp/tools/coordination-request-context.ts
133
+ /**
134
+ * The header a harness sends to a remote MCP server whose tool-call timeout it
135
+ * raised, carrying the applied timeout in milliseconds. The Tangle profile
136
+ * materializer writes it beside `MCP_TOOL_TIMEOUT` (Claude Code) and
137
+ * `tool_timeout_sec` (Codex) when an attachment declares
138
+ * `metadata.toolTimeoutMs`. Without it the server must assume the harness
139
+ * default, 60 s for Claude Code 2.1.287 and Codex (measured 2026-10-03).
140
+ */
141
+ const MCP_TOOL_TIMEOUT_HEADER = "x-mcp-tool-timeout-ms";
142
+ /** The tool-call timeout Runtime asks harnesses to give its coordination server. */
143
+ const COORDINATION_CLIENT_TOOL_TIMEOUT_MS = 3e5;
144
+ /**
145
+ * The longest `await_event` holds for a caller that declared a raised timeout.
146
+ * A held response through the Sandbox edge was measured to 200 s on 2026-10-03.
147
+ */
148
+ const MAX_DECLARED_AWAIT_FENCE_MS = 18e4;
149
+ const MIN_DECLARED_TOOL_TIMEOUT_MS = 1e3;
150
+ const MAX_DECLARED_TOOL_TIMEOUT_MS = 36e5;
151
+ const requestContext = new AsyncLocalStorage();
152
+ /**
153
+ * The tool-call timeout a request declared through {@link MCP_TOOL_TIMEOUT_HEADER},
154
+ * or `undefined` when it is absent or malformed. A malformed value is treated as
155
+ * absent: the caller then gets the default fence, which every harness tolerates.
156
+ */
157
+ function declaredToolTimeoutMs(header) {
158
+ if (typeof header !== "string" || !/^[0-9]{1,8}$/.test(header)) return void 0;
159
+ const value = Number(header);
160
+ return value >= MIN_DECLARED_TOOL_TIMEOUT_MS && value <= MAX_DECLARED_TOOL_TIMEOUT_MS ? value : void 0;
161
+ }
162
+ /**
163
+ * How long `await_event` may hold for a caller that declared `declaredMs`: 60% of
164
+ * it, so the answer leaves well before the client gives up, and at most
165
+ * {@link MAX_DECLARED_AWAIT_FENCE_MS}.
166
+ */
167
+ function declaredAwaitFenceMs(declaredMs) {
168
+ return Math.min(MAX_DECLARED_AWAIT_FENCE_MS, Math.floor(declaredMs * .6));
169
+ }
170
+ /** Run one coordination request with the fence its caller declared, if any. */
171
+ function withCoordinationAwaitFence(awaitFenceMs, run) {
172
+ return awaitFenceMs === void 0 ? run() : requestContext.run({ awaitFenceMs }, run);
173
+ }
174
+ /** The fence the current coordination request declared, or `undefined`. */
175
+ function coordinationRequestAwaitFenceMs() {
176
+ return requestContext.getStore()?.awaitFenceMs;
177
+ }
178
+ //#endregion
131
179
  //#region src/mcp/tools/worker-output.ts
132
180
  const WORKER_OUTPUT_PAGE_CHARS = 16384;
133
181
  function workerOutputReadOptions(raw) {
@@ -1852,11 +1900,16 @@ function createCoordinationToolsForManager(opts, lifetime) {
1852
1900
  });
1853
1901
  return inFlightDrain;
1854
1902
  };
1903
+ const awaitFenceMs = () => {
1904
+ const declared = coordinationRequestAwaitFenceMs();
1905
+ return declared !== void 0 && awaitTimeoutMs > 0 ? declared : awaitTimeoutMs;
1906
+ };
1855
1907
  const raceDrainWithTimeout = async (drain) => {
1856
- if (awaitTimeoutMs <= 0) return { drained: await drain };
1908
+ const fenceMs = awaitFenceMs();
1909
+ if (fenceMs <= 0) return { drained: await drain };
1857
1910
  let timer;
1858
1911
  const timeout = new Promise((resolve) => {
1859
- timer = setTimeout(() => resolve(void 0), awaitTimeoutMs);
1912
+ timer = setTimeout(() => resolve(void 0), fenceMs);
1860
1913
  if (typeof timer?.unref === "function") timer.unref();
1861
1914
  });
1862
1915
  try {
@@ -2285,7 +2338,8 @@ function createCoordinationToolsForManager(opts, lifetime) {
2285
2338
  };
2286
2339
  };
2287
2340
  if (max > 1) {
2288
- const fenceAt = awaitTimeoutMs > 0 ? Date.now() + awaitTimeoutMs / 2 : Infinity;
2341
+ const fenceMs = awaitFenceMs();
2342
+ const fenceAt = fenceMs > 0 ? Date.now() + fenceMs / 2 : Infinity;
2289
2343
  if (!inFlightDrain) {
2290
2344
  inFlightDrain = (async () => {
2291
2345
  let drained = false;
@@ -4567,6 +4621,6 @@ function safeJson(v) {
4567
4621
  }
4568
4622
  }
4569
4623
  //#endregion
4570
- export { createCoordinationTools as A, applyRunCancellation as C, analystToolGroupNames as D, DEFAULT_AWAIT_EVENT_TIMEOUT_MS as E, questionEscalationTargets as F, createEventBus as I, defaultToolDetectors as L, downMessageRefusalReasons as M, normalizeAnalyzeOnSettle as N, canonicalFindingEvent as O, parseAuthoredAnalystDefinition as P, watchTrace as R, foldCoordinationRecords as S, ANALYST_DEFINITION_BOUNDS as T, renderAnytimeTable as _, allOf as a, withRunContext as b, createProgressTracker as c, progressStop as d, sampleFromSettled as f, plateauLength as g, bestSoFar as h, finalizeBestDelivered as i, createCoordinationToolsForManager as j, coordinationVerbNames as k, noProgressFor as l, areaUnderCurve as m, createSteerAcknowledger as n, allWorkersStalled as o, anytimeReport as p, driverAgent as r, anyOf as s, createCancelAcknowledger as t, plateau as u, createFileRunContext as v, watchRunCancellation as w, FileCoordinationLog as x, createInMemoryRunContext as y };
4624
+ export { createCoordinationTools as A, withCoordinationAwaitFence as B, applyRunCancellation as C, analystToolGroupNames as D, DEFAULT_AWAIT_EVENT_TIMEOUT_MS as E, questionEscalationTargets as F, defaultToolDetectors as H, COORDINATION_CLIENT_TOOL_TIMEOUT_MS as I, MCP_TOOL_TIMEOUT_HEADER as L, downMessageRefusalReasons as M, normalizeAnalyzeOnSettle as N, canonicalFindingEvent as O, parseAuthoredAnalystDefinition as P, declaredAwaitFenceMs as R, foldCoordinationRecords as S, ANALYST_DEFINITION_BOUNDS as T, watchTrace as U, createEventBus as V, renderAnytimeTable as _, allOf as a, withRunContext as b, createProgressTracker as c, progressStop as d, sampleFromSettled as f, plateauLength as g, bestSoFar as h, finalizeBestDelivered as i, createCoordinationToolsForManager as j, coordinationVerbNames as k, noProgressFor as l, areaUnderCurve as m, createSteerAcknowledger as n, allWorkersStalled as o, anytimeReport as p, driverAgent as r, anyOf as s, createCancelAcknowledger as t, plateau as u, createFileRunContext as v, watchRunCancellation as w, FileCoordinationLog as x, createInMemoryRunContext as y, declaredToolTimeoutMs as z };
4571
4625
 
4572
- //# sourceMappingURL=coordination-driver-LbUK3IMQ.js.map
4626
+ //# sourceMappingURL=coordination-driver-DSaxqusu.js.map