@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.57

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 (275) hide show
  1. package/CHANGELOG.md +229 -0
  2. package/README.md +201 -52
  3. package/dist/acp-package.d.ts +2 -0
  4. package/dist/adapters.d.ts +15 -3
  5. package/dist/adapters.js +17 -6
  6. package/dist/agent-package.d.ts +3 -3
  7. package/dist/agent-package.js +17 -8
  8. package/dist/api-keys.d.ts +76 -0
  9. package/dist/api-keys.js +217 -0
  10. package/dist/api-only.d.ts +17 -5
  11. package/dist/api-only.js +34 -8
  12. package/dist/browser-hold.d.ts +23 -0
  13. package/dist/browser-hold.js +48 -0
  14. package/dist/browser-person.d.ts +3 -0
  15. package/dist/browser-person.js +4 -1
  16. package/dist/chatgpt-plan.d.ts +18 -8
  17. package/dist/chatgpt-plan.js +91 -34
  18. package/dist/claude-login.d.ts +74 -16
  19. package/dist/claude-login.js +215 -56
  20. package/dist/claude-sign-in.d.ts +17 -6
  21. package/dist/claude-sign-in.js +42 -39
  22. package/dist/cli.js +63 -6
  23. package/dist/composio-made.d.ts +4 -0
  24. package/dist/composio-made.js +4 -0
  25. package/dist/composio-preset.d.ts +43 -2
  26. package/dist/composio-preset.js +92 -4
  27. package/dist/computer-held-routes.d.ts +5 -4
  28. package/dist/computer-held-routes.js +29 -8
  29. package/dist/computer-held.d.ts +6 -1
  30. package/dist/computer-held.js +14 -0
  31. package/dist/computer-record.js +4 -2
  32. package/dist/computer-viewer.js +4 -1
  33. package/dist/console/assets/{backend-Boh7tC4i.js → backend-DVhHzJX2.js} +19 -19
  34. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  35. package/dist/console/assets/index-okP-y8PK.js +747 -0
  36. package/dist/console/index.html +2 -2
  37. package/dist/decisions.d.ts +1 -1
  38. package/dist/decisions.js +1 -1
  39. package/dist/docker-host-addresses.d.ts +22 -11
  40. package/dist/docker-host-addresses.js +38 -26
  41. package/dist/env-switch.d.ts +10 -0
  42. package/dist/env-switch.js +33 -2
  43. package/dist/errors.d.ts +1 -0
  44. package/dist/errors.js +2 -0
  45. package/dist/fal-price.d.ts +58 -20
  46. package/dist/fal-price.js +341 -82
  47. package/dist/handed-values.d.ts +43 -1
  48. package/dist/handed-values.js +119 -2
  49. package/dist/harness-archive.d.ts +13 -10
  50. package/dist/harness-archive.js +60 -34
  51. package/dist/harness-check.d.ts +3 -1
  52. package/dist/harness-check.js +25 -46
  53. package/dist/harness-keys.d.ts +73 -27
  54. package/dist/harness-keys.js +194 -61
  55. package/dist/harness-recipe-entry.d.ts +8 -7
  56. package/dist/harness-recipe-entry.js +21 -32
  57. package/dist/harness-recipe.d.ts +38 -25
  58. package/dist/harness-recipe.js +49 -36
  59. package/dist/harness-sign-in.js +12 -23
  60. package/dist/harness-table.d.ts +10 -3
  61. package/dist/harness-table.js +26 -21
  62. package/dist/harness.d.ts +1 -0
  63. package/dist/harness.js +17 -5
  64. package/dist/hosted-search.d.ts +1 -1
  65. package/dist/hosted-search.js +1 -2
  66. package/dist/import-worker.d.ts +4 -2
  67. package/dist/import-worker.js +9 -2
  68. package/dist/in-flight.d.ts +26 -0
  69. package/dist/in-flight.js +52 -0
  70. package/dist/key-refusal.d.ts +9 -4
  71. package/dist/key-refusal.js +107 -25
  72. package/dist/learn/secrets.d.ts +13 -3
  73. package/dist/learn/secrets.js +118 -17
  74. package/dist/learning-cost.d.ts +6 -3
  75. package/dist/learning-cost.js +4 -2
  76. package/dist/link-check.js +1 -1
  77. package/dist/llms.txt +1 -1
  78. package/dist/marketplace.d.ts +77 -0
  79. package/dist/marketplace.js +224 -0
  80. package/dist/mcp-api-only-origins.d.ts +30 -0
  81. package/dist/mcp-api-only-origins.js +57 -0
  82. package/dist/mcp-gateway.d.ts +7 -5
  83. package/dist/mcp-gateway.js +9 -12
  84. package/dist/mcp-secret-writes.js +5 -3
  85. package/dist/mcp-servers-store.d.ts +28 -6
  86. package/dist/mcp-servers-store.js +53 -4
  87. package/dist/media-duration.d.ts +3 -0
  88. package/dist/media-duration.js +90 -9
  89. package/dist/model-form.d.ts +5 -4
  90. package/dist/model-form.js +11 -7
  91. package/dist/model.d.ts +5 -2
  92. package/dist/model.js +9 -5
  93. package/dist/ollama-provider.d.ts +7 -1
  94. package/dist/ollama-provider.js +14 -2
  95. package/dist/openapi.js +178 -27
  96. package/dist/otel/genai.d.ts +65 -0
  97. package/dist/otel/genai.js +116 -0
  98. package/dist/otel/tracer.d.ts +55 -0
  99. package/dist/otel/tracer.js +308 -0
  100. package/dist/page.d.ts +2 -0
  101. package/dist/page.js +3 -1
  102. package/dist/paid-calls.d.ts +1 -32
  103. package/dist/paid-calls.js +4 -39
  104. package/dist/provider.d.ts +9 -0
  105. package/dist/provider.js +50 -3
  106. package/dist/redact/match.d.ts +30 -3
  107. package/dist/redact/match.js +422 -41
  108. package/dist/refusal-words.d.ts +11 -0
  109. package/dist/refusal-words.js +11 -0
  110. package/dist/run-census.d.ts +67 -0
  111. package/dist/run-census.js +240 -0
  112. package/dist/run-computer.d.ts +6 -3
  113. package/dist/run-computer.js +4 -1
  114. package/dist/run-cut.d.ts +15 -6
  115. package/dist/run-cut.js +30 -9
  116. package/dist/run-files.d.ts +3 -0
  117. package/dist/run-files.js +3 -0
  118. package/dist/run-launch.d.ts +12 -1
  119. package/dist/run-launch.js +9 -10
  120. package/dist/run-learning-served.d.ts +2 -0
  121. package/dist/run-model-key.d.ts +8 -0
  122. package/dist/run-model-key.js +31 -1
  123. package/dist/run-reads-over-store.d.ts +24 -6
  124. package/dist/run-reads-over-store.js +67 -23
  125. package/dist/run-recordings.d.ts +5 -1
  126. package/dist/run-recordings.js +39 -14
  127. package/dist/run-timeline-served.d.ts +2 -0
  128. package/dist/run-timeline-served.js +2 -2
  129. package/dist/run-usage.d.ts +1 -0
  130. package/dist/runnable.d.ts +10 -1
  131. package/dist/runnable.js +20 -8
  132. package/dist/runner/adapter-loop.d.ts +11 -0
  133. package/dist/runner/adapter-loop.js +55 -10
  134. package/dist/runner/adapter-run-spec.d.ts +45 -8
  135. package/dist/runner/adapter-run-spec.js +150 -28
  136. package/dist/runner/adapters/pi.js +25 -3
  137. package/dist/runner/beside.js +4 -3
  138. package/dist/runner/big-writes.js +1 -10
  139. package/dist/runner/claim-secrets.d.ts +18 -3
  140. package/dist/runner/claim-secrets.js +35 -6
  141. package/dist/runner/cli-run-spec.d.ts +6 -0
  142. package/dist/runner/cli-run-spec.js +82 -35
  143. package/dist/runner/computer-journal.d.ts +9 -1
  144. package/dist/runner/computer-journal.js +26 -0
  145. package/dist/runner/conformance/harness.js +1 -1
  146. package/dist/runner/feedback-round.js +3 -0
  147. package/dist/runner/harness-loops.d.ts +6 -5
  148. package/dist/runner/harness-loops.js +7 -7
  149. package/dist/runner/held.d.ts +11 -5
  150. package/dist/runner/journal-kinds.d.ts +5 -0
  151. package/dist/runner/journal-kinds.js +5 -0
  152. package/dist/runner/main.js +7 -2
  153. package/dist/runner/mcp-claim.js +30 -3
  154. package/dist/runner/mcp-run.d.ts +12 -0
  155. package/dist/runner/mcp-run.js +12 -5
  156. package/dist/runner/model-route.d.ts +17 -0
  157. package/dist/runner/model-route.js +120 -2
  158. package/dist/runner/run-child-host.d.ts +3 -0
  159. package/dist/runner/run-child-host.js +69 -28
  160. package/dist/runner/run-child.js +5 -2
  161. package/dist/runner/runner.d.ts +14 -3
  162. package/dist/runner/runner.js +129 -33
  163. package/dist/runner/store-port.d.ts +1 -1
  164. package/dist/runner/store-secrets.d.ts +6 -0
  165. package/dist/runner/store-secrets.js +49 -7
  166. package/dist/runner/subagent.js +4 -40
  167. package/dist/runner/workflow-first.d.ts +11 -4
  168. package/dist/runner/workflow-first.js +14 -8
  169. package/dist/runner/workflow-spec.js +3 -2
  170. package/dist/runs-over-store.d.ts +15 -6
  171. package/dist/runs-over-store.js +33 -21
  172. package/dist/scrub-command.d.ts +73 -0
  173. package/dist/scrub-command.js +307 -0
  174. package/dist/secret-cut.d.ts +73 -0
  175. package/dist/secret-cut.js +291 -4
  176. package/dist/secret-rules.d.ts +143 -0
  177. package/dist/secret-rules.js +2564 -0
  178. package/dist/secrets.d.ts +7 -0
  179. package/dist/secrets.js +20 -0
  180. package/dist/server-keys.d.ts +20 -0
  181. package/dist/server-keys.js +25 -6
  182. package/dist/server.d.ts +52 -11
  183. package/dist/server.js +345 -118
  184. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  185. package/dist/store/index.d.ts +1 -1
  186. package/dist/store/index.js +1 -1
  187. package/dist/store/journal/storage.js +1 -1
  188. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  189. package/dist/store/schema.d.ts +6 -0
  190. package/dist/store/schema.js +11 -1
  191. package/dist/store/seal.d.ts +6 -1
  192. package/dist/store/seal.js +5 -3
  193. package/dist/store/sqlite/run-launch.d.ts +9 -1
  194. package/dist/store/sqlite/run-launch.js +24 -13
  195. package/dist/store/sqlite/run-patch.d.ts +1 -1
  196. package/dist/store/sqlite/run-patch.js +13 -4
  197. package/dist/store/sqlite/store.js +34 -4
  198. package/dist/store/store.d.ts +43 -2
  199. package/dist/store/store.js +20 -0
  200. package/dist/store-reads/learning.d.ts +6 -3
  201. package/dist/store-reads/learning.js +22 -7
  202. package/dist/store-view.d.ts +3 -0
  203. package/dist/store-view.js +3 -3
  204. package/dist/suggestions.js +3 -2
  205. package/dist/template-eval.d.ts +20 -9
  206. package/dist/template-eval.js +115 -33
  207. package/dist/template-import.d.ts +10 -0
  208. package/dist/template-import.js +16 -7
  209. package/dist/templates.d.ts +10 -2
  210. package/dist/templates.js +28 -8
  211. package/dist/timeline/labels.d.ts +6 -4
  212. package/dist/timeline/labels.js +18 -6
  213. package/dist/timeline/timeline.d.ts +5 -0
  214. package/dist/timeline/timeline.js +14 -8
  215. package/dist/timeline/util.js +1 -1
  216. package/dist/timeline/web-calls.d.ts +26 -9
  217. package/dist/timeline/web-calls.js +124 -37
  218. package/dist/tool-gate.d.ts +42 -3
  219. package/dist/tool-gate.js +66 -5
  220. package/dist/tool-keys-store.d.ts +2 -4
  221. package/dist/tool-keys-store.js +5 -21
  222. package/dist/tool-keys.d.ts +2 -2
  223. package/dist/tool-keys.js +2 -2
  224. package/dist/tool-list.js +1 -1
  225. package/dist/tool-plane.d.ts +2 -2
  226. package/dist/tool-plane.js +35 -33
  227. package/dist/tools.js +13 -7
  228. package/dist/trigger-targets.d.ts +4 -0
  229. package/dist/trigger-targets.js +9 -2
  230. package/dist/triggers.d.ts +67 -4
  231. package/dist/triggers.js +171 -22
  232. package/dist/until.d.ts +3 -0
  233. package/dist/until.js +11 -0
  234. package/dist/web-fake.d.ts +1 -3
  235. package/dist/web-fake.js +7 -18
  236. package/dist/web-fetch.d.ts +6 -72
  237. package/dist/web-fetch.js +11 -265
  238. package/dist/web-run.d.ts +31 -0
  239. package/dist/web-run.js +90 -0
  240. package/dist/web-save.d.ts +6 -4
  241. package/dist/web-save.js +9 -12
  242. package/dist/web-search.d.ts +9 -127
  243. package/dist/web-search.js +23 -259
  244. package/dist/wires.d.ts +13 -0
  245. package/dist/wires.js +11 -0
  246. package/dist/workflow-run.d.ts +5 -4
  247. package/dist/workflow-run.js +5 -4
  248. package/dist/workspace/computer-deps.d.ts +2 -1
  249. package/dist/workspace/computer-deps.js +9 -2
  250. package/dist/workspace/computer-for-claim.d.ts +12 -1
  251. package/dist/workspace/computer-for-claim.js +77 -8
  252. package/dist/workspace/computer-kept.d.ts +3 -0
  253. package/dist/workspace/computer-kept.js +11 -2
  254. package/dist/workspace/index.d.ts +1 -1
  255. package/dist/workspace/index.js +1 -1
  256. package/dist/workspace/kind-skills.d.ts +4 -0
  257. package/dist/workspace/kind-skills.js +9 -0
  258. package/dist/workspace/synced-folder.js +3 -4
  259. package/dist/wrapped.d.ts +13 -5
  260. package/dist/wrapped.js +52 -26
  261. package/package.json +17 -11
  262. package/skills/agentrun-serve/SKILL.md +4 -0
  263. package/templates/README.md +30 -8
  264. package/dist/console/assets/index-CQ3cJRzI.js +0 -746
  265. package/dist/console/assets/index-DKkaS3a0.css +0 -1
  266. package/dist/exa-keyless.d.ts +0 -34
  267. package/dist/exa-keyless.js +0 -118
  268. package/dist/firecrawl-keyless.d.ts +0 -41
  269. package/dist/firecrawl-keyless.js +0 -152
  270. package/dist/keyless-mcp.d.ts +0 -36
  271. package/dist/keyless-mcp.js +0 -127
  272. package/dist/text-urls.d.ts +0 -38
  273. package/dist/text-urls.js +0 -170
  274. package/dist/web-fetch-direct.d.ts +0 -119
  275. package/dist/web-fetch-direct.js +0 -190
@@ -21,6 +21,7 @@ import { turnEndedOnAsk } from "../store-reads/journal.js";
21
21
  import { CAP_REFUSED, CAP_WRAPUP, COMPUTER_NOTE, endsTurn, HOST_PHASE, MESSAGE_ORIGIN, originOf, REQUEST_ENDED, REQUEST_STARTED, RUN_RESUMED } from "../timeline/index.js";
22
22
  import { raiseFollowUpId } from "../run-view.js";
23
23
  import { durableWait } from "../workflow/pi-versions.js";
24
+ import { genAiTracing } from "../otel/tracer.js";
24
25
  /** The root entries a claim writes before its turn, whatever the run's turns are (its session's key, a phase row, a
25
26
  * takeover's note, its computer's hold, the learning seed it laid, the computer it made): read past when a claim asks
26
27
  * whether the run's root ends on its end (a fresh reopen). */
@@ -594,6 +595,12 @@ function adapterLoop(specOf, options, deps) {
594
595
  const retry = options.retry ?? MODEL_RETRY;
595
596
  const stream = options.stream ?? MODEL_STREAM;
596
597
  const now = options.now ?? Date.now;
598
+ /** The runs' GenAI tracing (none unless the env turns it on), and this claim's trace of its run, open once its spec is
599
+ * known: its chat spans from the session's model port (counted), its tool spans from the session's events (io.onEvent),
600
+ * ended with the claim (traced). */
601
+ let tracing;
602
+ const tracingMade = (options.tracing ?? genAiTracing()).then((now) => (tracing = { now }), () => (tracing = { now: undefined }));
603
+ let trace;
597
604
  /** The gate's clock as main's card says a time: ISO. */
598
605
  const isoNow = () => new Date(now()).toISOString();
599
606
  const inbox = [];
@@ -1350,7 +1357,25 @@ function adapterLoop(specOf, options, deps) {
1350
1357
  await specNow?.hooks?.afterMessageSent?.();
1351
1358
  return session.turnEnd();
1352
1359
  };
1360
+ /** run(claim), its trace ended with it: every span still open ends, with the claim's failure where it failed, handed to
1361
+ * the exporter, which sends it in the background (tracer.ts: the claim's end never waits on a collector, and never
1362
+ * throws). */
1363
+ async function traced(claim) {
1364
+ try {
1365
+ const end = await run(claim);
1366
+ await trace?.end(end.state === "failed" ? end.error.code : undefined);
1367
+ return end;
1368
+ }
1369
+ catch (error) {
1370
+ await trace?.end("run-error");
1371
+ throw error;
1372
+ }
1373
+ finally {
1374
+ trace = undefined;
1375
+ }
1376
+ }
1353
1377
  async function run(claim) {
1378
+ const claimedAt = Date.now();
1354
1379
  context = withAbortSignal(deps.signal, BACKGROUND_CONTEXT);
1355
1380
  // Every row the runner read for this claim is with the loop once delivered resolves (at once without a runner's).
1356
1381
  void (deps.delivered ?? Promise.resolve()).then(() => {
@@ -1542,6 +1567,10 @@ function adapterLoop(specOf, options, deps) {
1542
1567
  }
1543
1568
  throw error;
1544
1569
  }
1570
+ // The run's trace, from its claim's start, once its spec says what runs (a restart's spec changes nothing of it).
1571
+ // The tracing is made long before (as the loop is): waited for only on the rare claim whose spec beat it.
1572
+ trace ??= (tracing ?? (await tracingMade)).now?.open({ startedAt: claimedAt, mcp: (name) => mcp?.catalogOf(specNow?.facts?.hostName?.(name) ?? name) !== undefined });
1573
+ trace?.known({ runId: claim.runId, harness: spec.adapter.id, ...(spec.facts?.wire === "plan" ? { plan: true } : {}), ...spec.trace });
1545
1574
  mcp = spec.mcp;
1546
1575
  specNow = spec;
1547
1576
  specKnown = true;
@@ -1582,18 +1611,18 @@ function adapterLoop(specOf, options, deps) {
1582
1611
  // in flight may be the one that asked for the call (Claude Code books its cost after its calls; Codex starts a call
1583
1612
  // with its response open), so the call is judged beside it and never waits on it. pi's request has answered by then.
1584
1613
  // A call settled above its hold (a fal job whose output states more than its input asked, a monid call charged above
1585
- // its maxCost) can take what the run was
1586
- // charged past its cap. From then on, a settle that leaves the run's charges over its cap stops the run at once in
1587
- // the cap's words (overCap, settled charges only), as a stop for good (paid-calls.ts stopRun): no tool runs after it,
1588
- // a script's own calls included. A charge is never given back, so that stop holds; a call still in flight counts
1589
- // only toward admissions (the cap's rule), where it refuses a new call, never stops the run. Its hold, kept from its
1590
- // admission, tells an overrun.
1614
+ // its maxCost) can take the run's charges past its cap: from then on, a settle that leaves them over it stops the run
1615
+ // in the cap's words (overCap, settled charges only; paid-calls.ts stopRun). A call still in flight counts only
1616
+ // toward admissions. Its hold, kept from its admission until it settles, tells an overrun (a host tool call's paid
1617
+ // steps, bookedIn below). An admit its ref had booked already opens no step and is never settled, so it keeps
1618
+ // nothing.
1591
1619
  const holds = new Map();
1592
1620
  let overran = false;
1593
1621
  const paidUnder = {
1594
1622
  admit: async (request) => {
1595
1623
  const admitted = await paid.admit({ ...request, under: spec.session.key });
1596
- holds.set(request.id, request.holdUsd);
1624
+ if (admitted?.booked !== true)
1625
+ holds.set(request.id, request.holdUsd);
1597
1626
  return admitted;
1598
1627
  },
1599
1628
  settle: async (id, usd, options) => {
@@ -2234,6 +2263,8 @@ function adapterLoop(specOf, options, deps) {
2234
2263
  bookingsWriting = 0;
2235
2264
  // The conversation each request of this claim was asked in, by its turn, where its client named one.
2236
2265
  const askedIn = new Map();
2266
+ // Each admitted model request's chat span, by its turn, until its afterRequest ends it (a paid tool's step is none).
2267
+ const chats = new Map();
2237
2268
  const counted = {
2238
2269
  beforeRequest: async (request) => {
2239
2270
  // The CLI's next request of its main model after its question to the person: never admitted, it asks for the
@@ -2265,6 +2296,8 @@ function adapterLoop(specOf, options, deps) {
2265
2296
  carried = undefined;
2266
2297
  }
2267
2298
  unbooked += 1;
2299
+ if (ticket && trace && request.paid === undefined)
2300
+ chats.set(ticket.turn, trace.request(request.model, request.route));
2268
2301
  // The conversation that asked, as its client named it (pi's, one of several asking at once): whose answer reads
2269
2302
  // this request's booking (bookedCost).
2270
2303
  const conversation = request.conversation;
@@ -2296,6 +2329,11 @@ function adapterLoop(specOf, options, deps) {
2296
2329
  const held = carried?.turn !== undefined && carried.turn === ticket?.turn ? carried : undefined;
2297
2330
  if (held)
2298
2331
  carried = undefined;
2332
+ const chat = ticket ? chats.get(ticket.turn) : undefined;
2333
+ if (chat) {
2334
+ chats.delete(ticket.turn);
2335
+ chat(usage, ended);
2336
+ }
2299
2337
  // An answer the model gave, not the provider's error inside one (a stream ended in an error event, a translated
2300
2338
  // route's failure in words included: the client drops it and asks again).
2301
2339
  const row = held && ended?.end === "answered" && ended.label !== "error" ? tell(held) : undefined;
@@ -2430,7 +2468,13 @@ function adapterLoop(specOf, options, deps) {
2430
2468
  ended: (callId, output, failed) => ownWrite(record.end(callId, failed ? "failed" : "done", output).catch(unlessSealed)),
2431
2469
  }
2432
2470
  : undefined;
2433
- const io = { writer, models: counted, signal: deps.signal, onEvent: record ? onEvent(record) : () => { }, gate: bridgeGate, ...(permission ? { permission } : {}), hostTool: hosted, ...(ownCalls ? { ownCalls } : {}), bookedCost, keepCalls, ...(record ? {} : { nestedEnded }) };
2471
+ // Every harness's events reach its trace first (its tool calls, a plan harness's turns), with a record or without.
2472
+ const recorded = record ? onEvent(record) : undefined;
2473
+ const traceAnd = (event) => {
2474
+ trace?.event(event);
2475
+ recorded?.(event);
2476
+ };
2477
+ const io = { writer, models: counted, signal: deps.signal, onEvent: traceAnd, gate: bridgeGate, ...(permission ? { permission } : {}), hostTool: hosted, ...(ownCalls ? { ownCalls } : {}), bookedCost, keepCalls, ...(record ? {} : { nestedEnded }) };
2434
2478
  // The end-of-run turn an earlier claim asked and never saw end (its runner lost mid look-back or mid compile): the
2435
2479
  // root's newest input still in flight is that turn's (end-of-run.ts REFLECT_PREFIX), which pi picks up again as its
2436
2480
  // session opens. The job's turn ended before it, answered: this pass runs no job turn (no recovery as the job's, no
@@ -2448,7 +2492,8 @@ function adapterLoop(specOf, options, deps) {
2448
2492
  reflecting = lookingBackOpen || jobKept;
2449
2493
  // The MCP tools are host tools like any other (mcp.tools, wrapped above): every harness gets them on its own channel
2450
2494
  // for host tools, each call through the gate before its intent.
2451
- session = await spec.adapter.open({ ...spec.session, tools, deferCatalog: deferred }, io);
2495
+ // A harness's own search defers only where the host offers none (its facts' ownToolSearch).
2496
+ session = await spec.adapter.open({ ...spec.session, tools, deferCatalog: deferred && !offered }, io);
2452
2497
  root = await harness.root(context);
2453
2498
  // The root as the claim found it, before this pass writes anything of its own there (the computer's show-up, a
2454
2499
  // takeover's note): what the reopen check below reads, so a fresh reopen is told by the run's own last entry.
@@ -4166,7 +4211,7 @@ function adapterLoop(specOf, options, deps) {
4166
4211
  }
4167
4212
  return {
4168
4213
  start(claim) {
4169
- finished = run(claim);
4214
+ finished = traced(claim);
4170
4215
  return finished;
4171
4216
  },
4172
4217
  async command(command) {
@@ -5,7 +5,7 @@ import type { Approvals } from "../approvals.js";
5
5
  import type { installForClaim, installSettled } from "../harness-install.js";
6
6
  import type { LiveHandover, LiveViewerStore } from "../browser-live.js";
7
7
  import { type RunnerLive } from "../live-reach.js";
8
- import { type PinnedModel, type Tier } from "../model.js";
8
+ import { type ModelRef, type PinnedModel, type Tier } from "../model.js";
9
9
  import { type RunLaunch } from "../run-launch.js";
10
10
  import type { Store } from "../store/store.js";
11
11
  import { type ArgumentsOf, type Permission, type RunFiles, type SettingFrom, type ToolEffect } from "../tool-gate.js";
@@ -31,7 +31,7 @@ import { type RunComputerHold } from "./computer-journal.js";
31
31
  import type { KeptKind, MadeKind, Replaced } from "../workspace/computer-for-claim.js";
32
32
  import type { ShellPlace } from "../workspace/resolve-computer.js";
33
33
  import type { Workspace } from "../workspace/workspace.js";
34
- import { type HeldRedact } from "./redact.js";
34
+ import { type HeldRedact, type Redact } from "./redact.js";
35
35
  import { type MonidFake } from "./monid-run.js";
36
36
  /** What a claim gives the shared computerForClaim: the run, its epoch, the claim itself (a live view's row is fenced on it
37
37
  * and names its runner), its revision, its place and any computer choice. */
@@ -166,26 +166,53 @@ export interface AdapterSpecDeps {
166
166
  * case, and its harness's own search is never offered (web-fake.ts, fakedPlane). `now`: its clock, the date and time it
167
167
  * is told wherever it reads "now" (environment.ts environmentLine, claude-agent's turn date); absent, the real clock.
168
168
  * `monid`: its monid endpoints answer as monid unreachable does, never sent (monid-run.ts monidForClaim). `email`: the
169
- * case's fake mail account's servers (eval-mailbox.ts), the only account its email tools open (email/tools.ts). */
169
+ * case's fake mail account's servers (eval-mailbox.ts), the only account its email tools open (email/tools.ts). `files`:
170
+ * the case's files, by their path in the run's work folder, written there at its claim (seedEvalFiles). */
170
171
  export type EvalFakes = {
171
172
  readonly web?: WebFake;
172
173
  readonly now?: Date;
173
174
  readonly monid?: MonidFake;
174
175
  readonly email?: EmailFake;
176
+ readonly files?: Readonly<Record<string, string>>;
175
177
  };
178
+ /** A template eval case's files (EvalFakes.files) written into the run's work folder at its claim, after its inputs and
179
+ * before its computer and its first turn, so they reach a computer's /workspace as its uploads do. Each one the folder
180
+ * does not hold yet: a claim that resumes the run keeps what the run made of it. A write that fails ends the run failed,
181
+ * saying which file. */
182
+ export declare function seedEvalFiles(workspace: Workspace, files: Readonly<Record<string, string>> | undefined): Promise<void>;
176
183
  /** A model as the cap prices it, from the route's catalog cost: its price WITH TIERS (the money rule — a request past a
177
184
  * model's tier is held and booked at the tier, as main's calculateCost does). `api` is the proxy's shape, for the
178
185
  * overhead its provider adds; the output ceiling is the route's when it carries one, else none. */
179
186
  export declare function capModelOf(route: ModelRoute): CapModel;
187
+ /** The model of a held run its model kept from running at its create (run-launch.ts hold.refused): as its revision names
188
+ * it (`provider/model-id`). Its launch pins none (runs-over-store.ts skips modelOf for it). Nothing chooses it and
189
+ * nothing prices it. */
190
+ export declare function heldModelOf(ref: string | undefined): ModelRef;
191
+ /** The route of a held run its model kept from running at its create (run-launch.ts hold.refused): its provider is the
192
+ * stand-in (provider.ts heldRefusedProvider), so a host with no key for its model still opens its claim and holds its
193
+ * computer. Its agent never starts (its start and every message are refused in `why`, its create's words:
194
+ * computer-held.ts), and a request that reached its proxy anyway is refused in them too, and never sent. */
195
+ export declare function heldRefusedRoute(model: ModelRef, why: string): ModelRoute;
180
196
  /** Particle requests are never automatically replayed after an uncertain failure. Retry is a harness-wide setting,
181
197
  * so a claim with any Particle route disables it for all its conversations, including subagents on other tiers. */
182
198
  export declare function modelRetryOf(routes: Iterable<Pick<ModelRoute, "like">>): Pick<AdapterRunSpec, "retry">;
199
+ /** A model route as the run's GenAI trace names it: its provider, the host its requests go to, its model. A route that
200
+ * translates its model's requests (its own `fetch`) is named by its upstream's host (ModelRoute.upstreamOrigin), never
201
+ * its proxy's placeholder origin; one whose upstream is unknown names no host. */
202
+ export declare const traceOfRoute: (route: ModelRoute) => import("../otel/genai.js").RouteTrace;
203
+ /** The model a replay run's or an audit shadow's grader runs on (graderRouteOf): the revision's modelTiers.fast, else
204
+ * `env`'s fast tier (AGENT_MODEL_FAST); undefined when there is neither, or the revision names agree_on (no grader). */
205
+ export declare function graderModelOf(body: {
206
+ readonly modelTiers?: Readonly<Partial<Record<SubagentTier, string>>>;
207
+ readonly learning?: unknown;
208
+ }, env: NodeJS.ProcessEnv): string | undefined;
183
209
  /** A replay run's or an audit shadow's grader route (runner/compare-end.ts): its fast model (the revision's
184
210
  * modelTiers.fast, else AGENT_MODEL_FAST) when its revision names no agree_on, on pi's wires. A fast model may be another
185
211
  * provider's than the run's own, whose key claimSecrets never opened: so its route reads every model key the server
186
- * holds (savedModelKeys) as a subagent's tier does, held by the run's redactor, on the route's env alone. A run with its
187
- * own model key carries that key, and no saved key is read. Undefined when there is no fast model, the revision names
188
- * agree_on, or no route can be made (logged: the pair is then compared whole). */
212
+ * holds (savedModelKeys) as a subagent's tier does, held by the run's redactor, on the route's env alone; in a run's own
213
+ * process its runner hands it the fast model's provider's keys alone (run-child-host.ts savedModelKeys, graderModelOf). A
214
+ * run with its own model key carries that key, and no saved key is read. Undefined when there is no fast model, the
215
+ * revision names agree_on, or no route can be made (logged: the pair is then compared whole). */
189
216
  export declare function graderRouteOf(body: {
190
217
  readonly modelTiers?: Readonly<Partial<Record<SubagentTier, string>>>;
191
218
  readonly learning?: unknown;
@@ -219,6 +246,11 @@ export declare function modelAskOf(pinned: {
219
246
  *
220
247
  * Whether anyone can answer an ask is the store's too (server-approvers.ts), read once at the claim: no one (the
221
248
  * server's accounts off), an asked call is refused at once in words, never parked.
249
+ *
250
+ * The run's computer once off for the run (RunGate.computerOff): a call of its tools is refused before any settings read.
251
+ * `turnedOff`: an earlier claim turned it off (computer-journal.ts computerTurnedOff), so this claim's gate starts off.
252
+ * `onComputerOff`: told the computer's kind, and awaited, when this claim's first deny of a call of its tools turns it off,
253
+ * for the run's journal (computer-journal.ts recordComputerOff), so a later claim starts it off too.
222
254
  */
223
255
  /** The run's tool permissions as a learned workflow's call nodes are held to them (learned-workflow.ts policy, denyFrom,
224
256
  * refresh): the same gate as the run's own calls, its settings read again from the store before each call node. */
@@ -238,6 +270,8 @@ export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pi
238
270
  readonly effectOf?: (name: string) => ToolEffect | undefined;
239
271
  readonly argumentsOf?: ArgumentsOf;
240
272
  readonly facts: AdapterFacts | undefined;
273
+ readonly turnedOff?: boolean;
274
+ readonly onComputerOff?: (kind: string) => Promise<void>;
241
275
  }): Promise<NonNullable<AdapterRunSpec["gate"]> & {
242
276
  readonly permissions: RunPermissions;
243
277
  readonly learn: (flows: readonly LearnedWorkflow[]) => void;
@@ -323,8 +357,11 @@ export declare function liveViewersOf(store: LiveViewerStore, sealKey: Buffer |
323
357
  };
324
358
  /** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor). A web call's answer is cut
325
359
  * string by string inside its JSON (timeline/web-calls.ts webCut), so what the harness stores still parses and keeps
326
- * its links whole for a grader's link check. */
327
- export declare function answersCut(tool: HostTool, cut: (text: string) => string): HostTool;
360
+ * its links whole for a grader's link check; one whose strings, read joined, hold a held value no cut in place takes (a
361
+ * value split across two of them) is "[redacted]" (webHeld). The join is read against the values `cut` holds
362
+ * (key-refusal.ts withheldWhole), or through `cut` itself when it does not know them (joinCut). Each string is cut once
363
+ * in a call, for the join's read and the answer both. */
364
+ export declare function answersCut(tool: HostTool, cut: Redact): HostTool;
328
365
  /** The ToolHost a run's non-hand tools bind through, the one both the pi spec and the CLI spec build: the run's folder and
329
366
  * the claim's environment (claim-secrets.ts: the run's keys from the store, its plane set), the run's registry for an
330
367
  * extension a binding installs, the install lifecycle (`life`, run by the adapter loop from the spec's `lifecycle`), the