@parcha/agentrun-serve 0.1.0-beta.58 → 0.1.0-beta.60

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 (474) hide show
  1. package/CHANGELOG.md +402 -1
  2. package/README.md +516 -190
  3. package/dist/acp-package.d.ts +5 -1
  4. package/dist/acp-package.js +19 -2
  5. package/dist/adapters.d.ts +23 -2
  6. package/dist/adapters.js +106 -33
  7. package/dist/agent-delete.d.ts +6 -9
  8. package/dist/agent-delete.js +5 -3
  9. package/dist/agent-package.js +11 -1
  10. package/dist/agents-store.js +1 -1
  11. package/dist/answer-text.d.ts +3 -0
  12. package/dist/answer-text.js +22 -0
  13. package/dist/api-only.d.ts +2 -2
  14. package/dist/api-only.js +3 -3
  15. package/dist/archil-routes.d.ts +4 -1
  16. package/dist/archil-routes.js +15 -12
  17. package/dist/archil-settings.d.ts +18 -8
  18. package/dist/archil-settings.js +35 -17
  19. package/dist/attach-conformance.js +5 -4
  20. package/dist/box-paths.d.ts +3 -2
  21. package/dist/box-paths.js +5 -4
  22. package/dist/browser-computer.d.ts +3 -8
  23. package/dist/browser-computer.js +12 -35
  24. package/dist/browser-cost.js +94 -20
  25. package/dist/capacity.d.ts +1 -1
  26. package/dist/capacity.js +3 -3
  27. package/dist/chatgpt-plan.d.ts +7 -0
  28. package/dist/chatgpt-plan.js +35 -11
  29. package/dist/claude-login-token.d.ts +20 -11
  30. package/dist/claude-login-token.js +175 -107
  31. package/dist/claude-login.d.ts +124 -33
  32. package/dist/claude-login.js +562 -85
  33. package/dist/claude-sign-in.d.ts +3 -0
  34. package/dist/claude-sign-in.js +10 -1
  35. package/dist/cli-learning/connections.js +1 -1
  36. package/dist/cli.js +323 -292
  37. package/dist/composio-made.d.ts +1 -6
  38. package/dist/composio-made.js +1 -6
  39. package/dist/composio-owners.d.ts +26 -0
  40. package/dist/composio-owners.js +36 -0
  41. package/dist/composio-preset.d.ts +56 -23
  42. package/dist/composio-preset.js +173 -77
  43. package/dist/composio-triggers.d.ts +4 -4
  44. package/dist/composio-triggers.js +6 -7
  45. package/dist/compute-cost.js +11 -2
  46. package/dist/computer-attach.d.ts +6 -3
  47. package/dist/computer-attach.js +41 -29
  48. package/dist/computer-held-routes.d.ts +1 -1
  49. package/dist/computer-held-routes.js +9 -4
  50. package/dist/computer-keys.d.ts +11 -1
  51. package/dist/computer-keys.js +26 -1
  52. package/dist/computer-record.js +3 -1
  53. package/dist/computer-view.d.ts +5 -3
  54. package/dist/computer-view.js +10 -6
  55. package/dist/computer-viewer.js +36 -7
  56. package/dist/computers.d.ts +2 -1
  57. package/dist/computers.js +6 -3
  58. package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
  59. package/dist/console/assets/backend-QnwGVBeU.js +166 -0
  60. package/dist/console/assets/index-DZi-muIj.js +629 -0
  61. package/dist/console/assets/share-pz61zIn9.js +6 -0
  62. package/dist/console/assets/styles-CcceGcu2.js +291 -0
  63. package/dist/console/assets/styles-fjQBFfMv.css +1 -0
  64. package/dist/console/index.html +4 -3
  65. package/dist/console/share.html +17 -0
  66. package/dist/decisions.d.ts +17 -7
  67. package/dist/decisions.js +41 -15
  68. package/dist/dial-relay.js +10 -4
  69. package/dist/docker-daemon.js +4 -5
  70. package/dist/docker-host-addresses.js +29 -11
  71. package/dist/email/account.d.ts +6 -0
  72. package/dist/email/account.js +6 -0
  73. package/dist/email/authentication.d.ts +21 -0
  74. package/dist/email/authentication.js +106 -0
  75. package/dist/email/email-faux.d.ts +11 -2
  76. package/dist/email/email-faux.js +21 -5
  77. package/dist/email/mail.d.ts +25 -0
  78. package/dist/email/mail.js +58 -2
  79. package/dist/email/names.js +2 -2
  80. package/dist/email/tools.d.ts +9 -4
  81. package/dist/email/tools.js +95 -13
  82. package/dist/env-switch.d.ts +12 -2
  83. package/dist/env-switch.js +23 -3
  84. package/dist/errors.d.ts +1 -0
  85. package/dist/errors.js +2 -0
  86. package/dist/factory-activity.d.ts +68 -0
  87. package/dist/factory-activity.js +153 -0
  88. package/dist/factory-runs.d.ts +11 -0
  89. package/dist/factory-runs.js +52 -0
  90. package/dist/fal-price.d.ts +11 -1
  91. package/dist/fal-price.js +33 -0
  92. package/dist/faux-computers.js +1 -1
  93. package/dist/filed-answer.d.ts +2 -2
  94. package/dist/filed-answer.js +2 -2
  95. package/dist/filed-tool.d.ts +32 -0
  96. package/dist/filed-tool.js +122 -0
  97. package/dist/graph-served.d.ts +10 -5
  98. package/dist/graph-served.js +40 -10
  99. package/dist/handed-values.js +1 -2
  100. package/dist/harness-check.d.ts +2 -1
  101. package/dist/harness-check.js +45 -12
  102. package/dist/harness-keys.d.ts +1 -2
  103. package/dist/harness-keys.js +10 -8
  104. package/dist/harness-opencode/facts.js +2 -0
  105. package/dist/harness-recipe-entry.d.ts +9 -3
  106. package/dist/harness-recipe-entry.js +18 -9
  107. package/dist/harness-recipe.d.ts +21 -0
  108. package/dist/harness-recipe.js +25 -3
  109. package/dist/harness-table.d.ts +12 -0
  110. package/dist/harness-table.js +21 -6
  111. package/dist/harness.js +6 -2
  112. package/dist/helper-env.d.ts +4 -1
  113. package/dist/helper-env.js +4 -1
  114. package/dist/host-check.d.ts +2 -3
  115. package/dist/host-check.js +13 -7
  116. package/dist/hosted-search.js +1 -1
  117. package/dist/import-worker.js +2 -2
  118. package/dist/import.d.ts +20 -8
  119. package/dist/import.js +448 -187
  120. package/dist/key-refusal.d.ts +14 -2
  121. package/dist/key-refusal.js +97 -33
  122. package/dist/learn/audit.d.ts +28 -27
  123. package/dist/learn/audit.js +87 -62
  124. package/dist/learn/check.js +1 -1
  125. package/dist/learn/commit.d.ts +35 -43
  126. package/dist/learn/commit.js +62 -270
  127. package/dist/learn/compile.d.ts +9 -6
  128. package/dist/learn/compile.js +51 -28
  129. package/dist/learn/corrections.js +1 -1
  130. package/dist/learn/delete.d.ts +5 -12
  131. package/dist/learn/delete.js +17 -30
  132. package/dist/learn/field-check.d.ts +111 -0
  133. package/dist/learn/field-check.js +174 -0
  134. package/dist/learn/forget-run.d.ts +16 -0
  135. package/dist/learn/forget-run.js +53 -0
  136. package/dist/learn/index.js +1 -1
  137. package/dist/learn/learning-of.d.ts +0 -4
  138. package/dist/learn/learning-of.js +0 -5
  139. package/dist/learn/ledger.d.ts +32 -29
  140. package/dist/learn/ledger.js +26 -19
  141. package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
  142. package/dist/learn/{folder.js → legacy/folder.js} +4 -7
  143. package/dist/learn/legacy/place.d.ts +16 -0
  144. package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
  145. package/dist/learn/legacy/scrub.d.ts +28 -0
  146. package/dist/learn/legacy/scrub.js +258 -0
  147. package/dist/learn/promote.d.ts +119 -102
  148. package/dist/learn/promote.js +119 -262
  149. package/dist/learn/reset-ledger.d.ts +18 -0
  150. package/dist/learn/reset-ledger.js +14 -0
  151. package/dist/learn/rows.d.ts +186 -0
  152. package/dist/learn/rows.js +376 -0
  153. package/dist/learn/secrets.d.ts +4 -0
  154. package/dist/learn/secrets.js +12 -0
  155. package/dist/learn/workflow-draft.d.ts +4 -1
  156. package/dist/learn/workflow-draft.js +12 -2
  157. package/dist/learned-nodes.d.ts +8 -5
  158. package/dist/learned-nodes.js +8 -5
  159. package/dist/learned-workflow.d.ts +2 -1
  160. package/dist/learned-workflow.js +13 -10
  161. package/dist/learning-cost.d.ts +25 -8
  162. package/dist/learning-cost.js +23 -8
  163. package/dist/learning-reset.d.ts +1 -1
  164. package/dist/learning-reset.js +9 -11
  165. package/dist/learning-routes.d.ts +60 -81
  166. package/dist/learning-routes.js +187 -360
  167. package/dist/learning-setting.d.ts +6 -0
  168. package/dist/learning-setting.js +11 -1
  169. package/dist/learning-words.d.ts +2 -0
  170. package/dist/learning-words.js +2 -0
  171. package/dist/learning.d.ts +18 -24
  172. package/dist/learning.js +35 -66
  173. package/dist/listen-first.d.ts +5 -4
  174. package/dist/listen-first.js +4 -5
  175. package/dist/live-reach.d.ts +7 -0
  176. package/dist/live-reach.js +7 -0
  177. package/dist/mcp-api-only-origins.d.ts +15 -0
  178. package/dist/mcp-api-only-origins.js +40 -0
  179. package/dist/mcp-gateway.d.ts +22 -2
  180. package/dist/mcp-gateway.js +85 -11
  181. package/dist/mcp-oauth.d.ts +1 -1
  182. package/dist/mcp-oauth.js +3 -2
  183. package/dist/mcp-probe.d.ts +3 -0
  184. package/dist/mcp-probe.js +3 -0
  185. package/dist/mcp-resources.d.ts +1 -1
  186. package/dist/mcp-secret-writes.d.ts +24 -2
  187. package/dist/mcp-secret-writes.js +30 -2
  188. package/dist/mcp-servers-store.d.ts +52 -14
  189. package/dist/mcp-servers-store.js +165 -61
  190. package/dist/mcp-sources.d.ts +1 -2
  191. package/dist/mcp-sources.js +1 -2
  192. package/dist/mcp-store.d.ts +5 -5
  193. package/dist/mcp-store.js +3 -3
  194. package/dist/mcp.js +1 -1
  195. package/dist/model-gateway.d.ts +1 -1
  196. package/dist/model-gateway.js +20 -36
  197. package/dist/native/discovery.d.ts +6 -0
  198. package/dist/native/discovery.js +14 -1
  199. package/dist/native/remote.d.ts +5 -0
  200. package/dist/native/remote.js +16 -0
  201. package/dist/native/runtime.js +3 -2
  202. package/dist/observation/observer.d.ts +6 -6
  203. package/dist/ollama-provider.d.ts +23 -9
  204. package/dist/ollama-provider.js +49 -20
  205. package/dist/openapi.js +290 -79
  206. package/dist/otel/genai.d.ts +83 -7
  207. package/dist/otel/genai.js +69 -9
  208. package/dist/otel/tracer.d.ts +42 -13
  209. package/dist/otel/tracer.js +241 -56
  210. package/dist/page.d.ts +7 -1
  211. package/dist/page.js +76 -22
  212. package/dist/paid-calls.d.ts +6 -4
  213. package/dist/paid-calls.js +15 -7
  214. package/dist/place-offers.d.ts +58 -34
  215. package/dist/place-offers.js +96 -54
  216. package/dist/place.d.ts +41 -20
  217. package/dist/place.js +97 -47
  218. package/dist/print.js +1 -1
  219. package/dist/provider.d.ts +3 -2
  220. package/dist/provider.js +17 -8
  221. package/dist/purged-workflow.d.ts +0 -33
  222. package/dist/purged-workflow.js +3 -71
  223. package/dist/redact/match.d.ts +42 -9
  224. package/dist/redact/match.js +356 -54
  225. package/dist/run-census.d.ts +1 -1
  226. package/dist/run-census.js +4 -5
  227. package/dist/run-cut.js +4 -5
  228. package/dist/run-export-store.d.ts +15 -0
  229. package/dist/run-export-store.js +30 -0
  230. package/dist/run-export.d.ts +139 -0
  231. package/dist/run-export.js +379 -0
  232. package/dist/run-file-cut.d.ts +5 -0
  233. package/dist/run-file-cut.js +13 -0
  234. package/dist/run-launch.d.ts +3 -3
  235. package/dist/run-launch.js +16 -3
  236. package/dist/run-learning-served.d.ts +3 -3
  237. package/dist/run-learning-served.js +1 -1
  238. package/dist/run-listing.d.ts +1 -1
  239. package/dist/run-model-key.d.ts +15 -6
  240. package/dist/run-model-key.js +30 -31
  241. package/dist/run-reads-over-store.js +4 -4
  242. package/dist/run-secrets.js +3 -5
  243. package/dist/run-timeline-served.d.ts +1 -1
  244. package/dist/run-timeline-served.js +8 -5
  245. package/dist/runnable.js +26 -9
  246. package/dist/runner/adapter-loop.d.ts +35 -18
  247. package/dist/runner/adapter-loop.js +94 -47
  248. package/dist/runner/adapter-run-spec.d.ts +14 -1
  249. package/dist/runner/adapter-run-spec.js +73 -46
  250. package/dist/runner/adapters/pi.js +4 -2
  251. package/dist/runner/audit.d.ts +10 -9
  252. package/dist/runner/audit.js +64 -67
  253. package/dist/runner/beside.js +5 -6
  254. package/dist/runner/claim-secrets.d.ts +10 -3
  255. package/dist/runner/claim-secrets.js +29 -13
  256. package/dist/runner/cli-run-spec.d.ts +18 -0
  257. package/dist/runner/cli-run-spec.js +87 -58
  258. package/dist/runner/compare-end.d.ts +2 -3
  259. package/dist/runner/compare-end.js +30 -11
  260. package/dist/runner/conformance/harness.js +2 -3
  261. package/dist/runner/conformance/subject.d.ts +4 -1
  262. package/dist/runner/disk-free.d.ts +15 -4
  263. package/dist/runner/disk-free.js +25 -7
  264. package/dist/runner/feedback-round.d.ts +1 -1
  265. package/dist/runner/feedback-round.js +2 -2
  266. package/dist/runner/harness-loops.js +3 -4
  267. package/dist/runner/held.d.ts +5 -12
  268. package/dist/runner/held.js +0 -25
  269. package/dist/runner/journal-kinds.d.ts +8 -2
  270. package/dist/runner/journal-kinds.js +23 -5
  271. package/dist/runner/learned-first.d.ts +0 -2
  272. package/dist/runner/learned-first.js +23 -7
  273. package/dist/runner/learning-end.d.ts +14 -24
  274. package/dist/runner/learning-end.js +52 -94
  275. package/dist/runner/learning-seed.d.ts +13 -16
  276. package/dist/runner/learning-seed.js +13 -23
  277. package/dist/runner/live-ticker.js +7 -5
  278. package/dist/runner/loop-contract.d.ts +0 -2
  279. package/dist/runner/loop.d.ts +7 -0
  280. package/dist/runner/loop.js +1 -0
  281. package/dist/runner/main.js +13 -12
  282. package/dist/runner/mcp-claim.js +21 -5
  283. package/dist/runner/mcp-run.d.ts +4 -0
  284. package/dist/runner/mcp-run.js +2 -0
  285. package/dist/runner/meta-tools.js +3 -2
  286. package/dist/runner/metrics.d.ts +7 -0
  287. package/dist/runner/metrics.js +19 -0
  288. package/dist/runner/model-route.d.ts +10 -7
  289. package/dist/runner/model-route.js +79 -15
  290. package/dist/runner/native-loop.js +12 -11
  291. package/dist/runner/presence.d.ts +1 -4
  292. package/dist/runner/presence.js +6 -8
  293. package/dist/runner/promotion.d.ts +39 -36
  294. package/dist/runner/promotion.js +168 -112
  295. package/dist/runner/redact.d.ts +3 -1
  296. package/dist/runner/redact.js +5 -3
  297. package/dist/runner/reflect-hook.d.ts +2 -2
  298. package/dist/runner/reflect-hook.js +4 -1
  299. package/dist/runner/responses-fetch.d.ts +36 -0
  300. package/dist/runner/responses-fetch.js +511 -0
  301. package/dist/runner/run-child-host.d.ts +21 -14
  302. package/dist/runner/run-child-host.js +187 -141
  303. package/dist/runner/run-child.js +11 -4
  304. package/dist/runner/runner-check.js +5 -1
  305. package/dist/runner/runner.d.ts +3 -4
  306. package/dist/runner/runner.js +13 -9
  307. package/dist/runner/sdk-loop.js +10 -12
  308. package/dist/runner/spec-holds.d.ts +8 -1
  309. package/dist/runner/spec-holds.js +9 -4
  310. package/dist/runner/workflow-calls.d.ts +9 -0
  311. package/dist/runner/workflow-calls.js +150 -0
  312. package/dist/runner/workflow-first.d.ts +120 -32
  313. package/dist/runner/workflow-first.js +218 -94
  314. package/dist/runner/workflow-spec.js +1 -1
  315. package/dist/runs-over-store.js +8 -7
  316. package/dist/save-once.d.ts +14 -0
  317. package/dist/save-once.js +31 -0
  318. package/dist/scrub-command.d.ts +34 -31
  319. package/dist/scrub-command.js +116 -147
  320. package/dist/sdk/check.d.ts +1 -4
  321. package/dist/sdk/check.js +2 -3
  322. package/dist/sdk/runs.d.ts +26 -7
  323. package/dist/sdk/runs.js +194 -78
  324. package/dist/seal-key.js +4 -4
  325. package/dist/secret-cut.d.ts +3 -0
  326. package/dist/secret-cut.js +7 -1
  327. package/dist/secret-rules.d.ts +8 -1
  328. package/dist/secret-rules.js +482 -53
  329. package/dist/secrets.d.ts +55 -9
  330. package/dist/secrets.js +345 -21
  331. package/dist/server-fs.d.ts +1 -1
  332. package/dist/server-fs.js +1 -1
  333. package/dist/server-keys.d.ts +10 -3
  334. package/dist/server-keys.js +16 -3
  335. package/dist/server-secrets-store.js +2 -4
  336. package/dist/server.d.ts +30 -18
  337. package/dist/server.js +520 -238
  338. package/dist/share-context.d.ts +22 -0
  339. package/dist/share-context.js +76 -0
  340. package/dist/shell-lex.d.ts +105 -0
  341. package/dist/shell-lex.js +646 -0
  342. package/dist/sign-ins-store.d.ts +5 -7
  343. package/dist/sign-ins-store.js +12 -16
  344. package/dist/sign-ins.d.ts +7 -11
  345. package/dist/sign-ins.js +40 -41
  346. package/dist/skills/agentrun-serve/SKILL.md +5 -2
  347. package/dist/source-sync/auxiliary.js +2 -2
  348. package/dist/start-switches.d.ts +6 -5
  349. package/dist/start-switches.js +8 -4
  350. package/dist/stats.d.ts +5 -1
  351. package/dist/stats.js +1 -1
  352. package/dist/store/agent-body.js +2 -2
  353. package/dist/store/dialect.d.ts +4 -0
  354. package/dist/store/dialect.js +1 -0
  355. package/dist/store/index.d.ts +2 -2
  356. package/dist/store/index.js +1 -1
  357. package/dist/store/mcp-record-keys.d.ts +10 -0
  358. package/dist/store/mcp-record-keys.js +13 -0
  359. package/dist/store/postgres/dialect.js +2 -0
  360. package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
  361. package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
  362. package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
  363. package/dist/store/postgres/migrations/0032_learning_rows.sql +65 -0
  364. package/dist/store/postgres/store.js +4 -0
  365. package/dist/store/schema.d.ts +60 -11
  366. package/dist/store/schema.js +147 -17
  367. package/dist/store/seal.d.ts +4 -1
  368. package/dist/store/sqlite/learning-rows.d.ts +23 -0
  369. package/dist/store/sqlite/learning-rows.js +559 -0
  370. package/dist/store/sqlite/run-launch.d.ts +3 -10
  371. package/dist/store/sqlite/run-launch.js +12 -23
  372. package/dist/store/sqlite/run-patch.d.ts +17 -10
  373. package/dist/store/sqlite/run-patch.js +50 -13
  374. package/dist/store/sqlite/store.d.ts +9 -0
  375. package/dist/store/sqlite/store.js +194 -46
  376. package/dist/store/store-schema.js +3 -4
  377. package/dist/store/store.d.ts +286 -38
  378. package/dist/store/store.js +27 -11
  379. package/dist/store-reads/analytics.d.ts +2 -1
  380. package/dist/store-reads/analytics.js +7 -5
  381. package/dist/store-reads/journal.d.ts +33 -3
  382. package/dist/store-reads/journal.js +99 -4
  383. package/dist/store-reads/learning.d.ts +50 -45
  384. package/dist/store-reads/learning.js +153 -116
  385. package/dist/store-reads/loop.js +1 -1
  386. package/dist/store-reads/stats.d.ts +2 -2
  387. package/dist/store-reads/stats.js +13 -7
  388. package/dist/store-view.d.ts +24 -2
  389. package/dist/store-view.js +49 -17
  390. package/dist/suggestions.d.ts +1 -1
  391. package/dist/suggestions.js +29 -13
  392. package/dist/template-eval.d.ts +72 -9
  393. package/dist/template-eval.js +358 -64
  394. package/dist/templates.d.ts +10 -2
  395. package/dist/templates.js +31 -4
  396. package/dist/timeline/labels.d.ts +1 -1
  397. package/dist/timeline/labels.js +4 -3
  398. package/dist/timeline/timeline.d.ts +23 -11
  399. package/dist/timeline/timeline.js +115 -31
  400. package/dist/timeline/web-calls.d.ts +8 -6
  401. package/dist/timeline/web-calls.js +10 -6
  402. package/dist/tool-gate.d.ts +13 -1
  403. package/dist/tool-gate.js +43 -3
  404. package/dist/tool-keys-store.js +2 -4
  405. package/dist/tool-keys.d.ts +11 -0
  406. package/dist/tool-keys.js +16 -0
  407. package/dist/tool-plane.d.ts +54 -13
  408. package/dist/tool-plane.js +103 -32
  409. package/dist/tools.d.ts +5 -1
  410. package/dist/tools.js +7 -7
  411. package/dist/trigger-email.js +12 -6
  412. package/dist/triggers.d.ts +15 -34
  413. package/dist/triggers.js +119 -126
  414. package/dist/validate.d.ts +8 -1
  415. package/dist/validate.js +163 -23
  416. package/dist/web-fake.d.ts +2 -1
  417. package/dist/web-fake.js +8 -6
  418. package/dist/web-fetch.d.ts +8 -6
  419. package/dist/web-fetch.js +13 -11
  420. package/dist/web-holds.d.ts +34 -0
  421. package/dist/web-holds.js +89 -0
  422. package/dist/web-run.d.ts +32 -5
  423. package/dist/web-run.js +76 -28
  424. package/dist/web-save.js +23 -12
  425. package/dist/web-search.js +14 -25
  426. package/dist/wires.d.ts +4 -3
  427. package/dist/wires.js +5 -4
  428. package/dist/workspace/archil-claim.d.ts +12 -5
  429. package/dist/workspace/archil-claim.js +45 -5
  430. package/dist/workspace/archil-exec.js +1 -1
  431. package/dist/workspace/archil.d.ts +1 -1
  432. package/dist/workspace/archil.js +1 -1
  433. package/dist/workspace/attach.js +52 -19
  434. package/dist/workspace/attached-computers.d.ts +6 -2
  435. package/dist/workspace/attached-computers.js +5 -4
  436. package/dist/workspace/computer-deps.d.ts +23 -6
  437. package/dist/workspace/computer-deps.js +38 -18
  438. package/dist/workspace/computer-for-claim.d.ts +21 -4
  439. package/dist/workspace/computer-for-claim.js +160 -54
  440. package/dist/workspace/computer-intervals.d.ts +2 -0
  441. package/dist/workspace/computer-intervals.js +1 -1
  442. package/dist/workspace/computer-janitor.d.ts +48 -14
  443. package/dist/workspace/computer-janitor.js +153 -44
  444. package/dist/workspace/computer-kept.d.ts +158 -32
  445. package/dist/workspace/computer-kept.js +288 -63
  446. package/dist/workspace/computer-providers.d.ts +19 -4
  447. package/dist/workspace/computer-providers.js +40 -6
  448. package/dist/workspace/index.d.ts +2 -3
  449. package/dist/workspace/index.js +2 -3
  450. package/dist/workspace/local.js +41 -1
  451. package/dist/workspace/mount-revoke-left.d.ts +31 -0
  452. package/dist/workspace/mount-revoke-left.js +72 -0
  453. package/dist/workspace/paired-route.js +4 -5
  454. package/dist/workspace/paths.d.ts +0 -4
  455. package/dist/workspace/paths.js +0 -6
  456. package/dist/workspace/resolve-computer.d.ts +5 -2
  457. package/dist/workspace/resolve-computer.js +9 -3
  458. package/dist/workspace/run-end-computers.d.ts +11 -5
  459. package/dist/workspace/run-end-computers.js +153 -28
  460. package/dist/workspace/run-tools.d.ts +22 -3
  461. package/dist/workspace/run-tools.js +17 -5
  462. package/dist/workspace/run-workspace.d.ts +14 -1
  463. package/dist/workspace/run-workspace.js +34 -1
  464. package/dist/workspace/workspace.d.ts +7 -1
  465. package/dist/workspace/workspace.js +1 -1
  466. package/package.json +13 -14
  467. package/skills/agentrun-serve/SKILL.md +5 -2
  468. package/templates/README.md +22 -6
  469. package/templates/TOOLS.md +46 -0
  470. package/dist/console/assets/backend-CSAWUqtZ.js +0 -166
  471. package/dist/console/assets/index-Bwn1oTem.css +0 -1
  472. package/dist/console/assets/index-DPh29cyz.js +0 -747
  473. package/dist/workspace/learning-workspace.d.ts +0 -24
  474. /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
@@ -17,8 +17,9 @@ import { existsSync } from "node:fs";
17
17
  import { chmod, mkdir, rm } from "node:fs/promises";
18
18
  import { dirname, join } from "node:path";
19
19
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
20
- import { encode, OTEL_PAIR, SECRET_NAMES, SECRETS_FD_ENV, SECRETS_LEN_ENV, withoutSecrets } from "../secrets.js";
21
- import { otelSettings } from "../otel/tracer.js";
20
+ import { encode, SECRET_NAMES, SECRETS_FD_ENV, SECRETS_LEN_ENV, withoutSecrets } from "../secrets.js";
21
+ import { genAiTracing, tracePosts } from "../otel/tracer.js";
22
+ import { agentOfRun } from "../otel/genai.js";
22
23
  import { putLiveViewer, dropLiveViewer } from "../browser-live.js";
23
24
  import { CALENDAR_EVENTS } from "../calendar/names.js";
24
25
  import { openCalendar } from "../calendar/address.js";
@@ -35,25 +36,26 @@ import { DECISION_PROVIDER_KEYS } from "../tool-plane.js";
35
36
  import { learningEndOfRun } from "./learning-end.js";
36
37
  import { cutDeep, runnerSecrets } from "./redact.js";
37
38
  import { storeSecrets } from "./store-secrets.js";
38
- import { FAUX_ENV, FAUX_PROVIDER, GATEWAY_KEY_ENV } from "../model.js";
39
+ import { FAUX_ENV, GATEWAY_KEY_ENV } from "../model.js";
39
40
  import { SAVED_GATEWAY_ENV, savedGatewayIn } from "../model-gateway.js";
40
41
  import { FAUX_VENDOR_API_ENV } from "../tools.js";
41
42
  import { withinCarried } from "../paid-calls.js";
42
43
  import { openRunMcpAuth, sealRunMcpAuth } from "../store/seal.js";
43
44
  import { runZone } from "../environment.js";
44
45
  import { shadowRunId } from "../learn/audit.js";
45
- import { LEARNING_SCRIPT, learningWorkspace } from "../learn/folder.js";
46
46
  import { agreeOnOf } from "../learning-setting.js";
47
- import { openRunWorkspace } from "../workspace/run-workspace.js";
47
+ import { openedAtUse, openRunWorkspace } from "../workspace/run-workspace.js";
48
48
  import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
49
49
  import { agentDirName, recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
50
50
  import { keptKeyOf } from "../workspace/computer-kept.js";
51
- import { claimModelKey, claimSecrets, claimSpendOff, hostDecisionKeys, learnedDecisionKeys, openRunModelKey, savedModelKeys, serverKeyless, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
51
+ import { waitEndedKey } from "../browser-wait-ended.js";
52
+ import { browserHoldKey } from "../browser-hold.js";
53
+ import { claimModelKey, claimSecrets, claimSpendOff, hostDecisionKeys, learnedDecisionKeys, openRunModelKey, savedModelKeys, sendsNoModelKey, serverKeyless, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
52
54
  import { githubAppAccess } from "./github-app.js";
53
55
  import { githubPullOf, githubTargetOf } from "../github.js";
54
56
  import { isObject } from "../validate.js";
55
57
  import { liveForRun, runnerLiveOf } from "../live-reach.js";
56
- import { learningFolderOf, secretsShown } from "../learning.js";
58
+ import { secretsShown } from "../learning.js";
57
59
  import { learningStartOf, seedFailed } from "../run-launch.js";
58
60
  import { messageText } from "../run-manifest.js";
59
61
  import { filesToCopy, placeRunInputs } from "../uploads.js";
@@ -67,7 +69,9 @@ import { createDispatchLoop } from "./dispatch.js";
67
69
  import { refuseRecipeTriggerRun, resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
68
70
  import { isWorkflowRevision } from "./workflow-loop.js";
69
71
  import { loginForRun } from "../claude-login.js";
70
- import { agentRunLogin, LOGIN_NOT_HANDED, loginRunnerInProcess, loginTokensFor } from "../claude-login-token.js";
72
+ import { harnessOfBody } from "../harness.js";
73
+ import { agentRunLogin, LOGIN_CHANGED_SINCE_CLAIM, loginRunnerInProcess, loginTokensFor } from "../claude-login-token.js";
74
+ import { logLine } from "../print.js";
71
75
  import { heardComputerHold } from "./computer-journal.js";
72
76
  import { ClaimRefused } from "./loop-contract.js";
73
77
  import { Channel, ChannelClosed } from "./run-channel.js";
@@ -75,12 +79,13 @@ import { registerRunErrors } from "./run-errors.js";
75
79
  import { exposeSaveSlots } from "./save-slots.js";
76
80
  import { runBigWrites } from "./big-writes.js";
77
81
  import { SERVER_SLOTS } from "../web-save.js";
82
+ import { holdsEnv, noteHold } from "../web-holds.js";
78
83
  import { launchOnItsDisk, readLaunchBody } from "../run-launch.js";
79
84
  import { routedSubagentTiers, SUBAGENT_TOOL } from "./subagent.js";
80
85
  import { sourceSyncOf } from "../source-sync/types.js";
81
86
  import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
82
87
  import { beginSourceIO } from "../source-sync/io.js";
83
- import { runTools } from "../workspace/run-tools.js";
88
+ import { attachedIn, runTools } from "../workspace/run-tools.js";
84
89
  import { ProjectHostGate } from "./project-host.js";
85
90
  import { runProjectCheckpoint } from "./project-checkpoint.js";
86
91
  /** The image's helper that starts a run's process as its slot's uid (packages/serve/runas). */
@@ -392,20 +397,58 @@ const always = () => true;
392
397
  /** The settings a run's process may read, the server's own configuration its loop and tools read: its tool settings,
393
398
  * its Archil settings (no credential), its MCP hosts and server names, its Claude-login mode and its approvers. */
394
399
  const SHARED_SETTINGS = new Set(["tool-settings", "archil", "mcp.private_oauth_hosts", "mcp.server_own", "claude_login", "approvers"]);
400
+ /** The rows of the claim's own run that its process writes, and removes, itself, each with its string fields (beside the
401
+ * claim's epoch): its browser's wait that ended (browser-wait-ended.ts) and its browser's take (browser-hold.ts), each
402
+ * the run's process's report of its own browser to the server's reads. No other row is its to write. */
403
+ const ownWrittenSettings = (bound) => new Map([
404
+ [waitEndedKey(bound.claim.runId), ["at", "why"]],
405
+ [browserHoldKey(bound.claim.runId), ["session", "at"]],
406
+ ]);
407
+ /** The most one of those rows may take, as JSON bytes: a session's tag, a time and a timeline row's words fit many times
408
+ * over, and the server parses the row on every read of the run and every Screen poll. */
409
+ const OWN_ROW_MAX_BYTES = 4096;
395
410
  /** The settings of the claim's own run and agent a run's process may read: its run's Archil disk, SDK record, kept
396
- * computer and browser wait, and its agent's Archil disk and promotions. Every other row (another run's or agent's) is
397
- * not its to read. */
411
+ * computer, browser wait and browser take, and its agent's Archil disk. Every other row (another run's or agent's)
412
+ * is not its to read. */
398
413
  const ownSettings = (bound) => new Set([
399
414
  `archil.run.${bound.claim.runId}`,
400
415
  `sdk-run:${bound.claim.runId}`,
401
416
  keptKeyOf(bound.claim.runId),
402
- `browser_wait_ended:${bound.claim.runId}`,
417
+ ...ownWrittenSettings(bound).keys(),
403
418
  `archil.agent.${bound.agentId}`,
404
- `learning.promotions.${bound.agentId}`,
405
419
  ]);
406
420
  /** Whether a run's process may read setting `key`. */
407
421
  export const settingReadable = (key, bound) => typeof key === "string" && (SHARED_SETTINGS.has(key) || ownSettings(bound).has(key));
408
422
  const readableSetting = (args, bound) => settingReadable(args[0], bound);
423
+ /** Whether a run's process may remove setting `key`: only its own run's browser rows (ownWrittenSettings), and only one no
424
+ * later claim wrote (removeOwnRow, which reads the row). */
425
+ const removableSetting = (args, bound) => typeof args[0] === "string" && ownWrittenSettings(bound).has(args[0]);
426
+ /** The remove of one of the claim's own browser rows (removableSetting): a row a later claim of the run wrote stays, as
427
+ * a write takes only the claim's own epoch (writableSetting), so a claim still closing never clears the take or the
428
+ * ended wait of the claim that holds the run now. The row goes only while it is the one read (Settings.removeIf), so a
429
+ * later claim's write that lands between the read and the remove stays too. A key with no row is left as it is. */
430
+ async function removeOwnRow(settings, key, bound, log) {
431
+ const row = await settings.get(key);
432
+ if (row === undefined)
433
+ return;
434
+ const epoch = typeof row === "object" && row !== null ? row.epoch : undefined;
435
+ if (typeof epoch === "number" && epoch > bound.claim.epoch) {
436
+ log(`run ${bound.claim.runId}: its process asked the store for settings.remove of ${key}, which a later claim (epoch ${epoch}) wrote and a run's process may not remove`);
437
+ throw new ClaimRefused("a run's process may not call the store's settings.remove of a row a later claim wrote");
438
+ }
439
+ await settings.removeIf(key, row);
440
+ }
441
+ /** Whether a run's process may write `value` to setting `key`: one of its own run's browser rows, with that row's fields
442
+ * alone, each a string, the claim's own epoch, and at most OWN_ROW_MAX_BYTES. A row with a later epoch would be kept by
443
+ * every clear of this claim (browser-hold.ts), so a later claim would read a take nobody holds. */
444
+ const writableSetting = ([key, value], bound) => {
445
+ const fields = typeof key === "string" ? ownWrittenSettings(bound).get(key) : undefined;
446
+ if (!fields || typeof value !== "object" || value === null || Array.isArray(value))
447
+ return false;
448
+ const row = value;
449
+ return Object.keys(row).length === fields.length + 1 && row.epoch === bound.claim.epoch && fields.every((field) => typeof row[field] === "string")
450
+ && Buffer.byteLength(JSON.stringify(row)) <= OWN_ROW_MAX_BYTES;
451
+ };
409
452
  /** The store's methods a run's loop calls, each with what binds it to the claim. A method not here is refused, and the
410
453
  * refusal is said on the runner's log. Reads of the claim's run, its launch, its commands and its agent's revisions;
411
454
  * of what was spent beside it (its learning grades, its own audit's shadow run's row and launch, which its cap gates
@@ -428,6 +471,8 @@ const STORE_CALLS = new Map([
428
471
  ["agents.revision", always],
429
472
  ["agents.revisions", ownAgent],
430
473
  ["settings.get", readableSetting],
474
+ ["settings.put", writableSetting],
475
+ ["settings.remove", removableSetting],
431
476
  // Its rows filtered to the readable ones (storeCall).
432
477
  ["settings.all", always],
433
478
  ["mcp.pin", ownRun],
@@ -437,6 +482,8 @@ const STORE_CALLS = new Map([
437
482
  ["learning.proposals", ownAgent],
438
483
  ["learning.list", ownAgent],
439
484
  ["learning.get", always],
485
+ // Its agent's learning at a save (learning-seed.ts layLearningSeed): read only, its agent's alone.
486
+ ["learning.itemsAt", ownAgent],
440
487
  ["computerLedger.book", ownClaim],
441
488
  ["computerLedger.list", ownRun],
442
489
  ["live.put", ownClaim],
@@ -456,6 +503,8 @@ export async function storeCall(store, method, args, bound, log) {
456
503
  }
457
504
  if (method === "readJournal")
458
505
  return journalRead(store, args);
506
+ if (method === "settings.remove")
507
+ return removeOwnRow(store.settings, args[0], bound, log);
459
508
  const path = method.split(".");
460
509
  let target = store;
461
510
  for (const part of path.slice(0, -1))
@@ -612,6 +661,8 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
612
661
  };
613
662
  const fromGitHub = launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github";
614
663
  const github = () => githubAppAccess(store, sealKey, launch.input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) });
664
+ /** The run's folder as the computer this claim made mounts it (Mode 2), where the claim's MCP files once it is made. */
665
+ let mountedFolder;
615
666
  /** Mode 2's Archil claim, made once for the claim on the runner, its folder the run's. */
616
667
  let archil;
617
668
  const archilOf = () => (archil ??= (async () => {
@@ -626,19 +677,15 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
626
677
  * handed none of the server's (claim-secrets.ts keyedAtClaim, held here for the runner's answers). */
627
678
  const runKeyed = async () => (await openRunModelKey(keys, claim.runId)) !== undefined;
628
679
  /** Whether the claim's run is held, its model kept from running at its create (hold.refused): it routes no model, so
629
- * whatever its process asks, the runner hands it no model key, answers it keyless and refuses it a learning step (its
630
- * learned workflows and its end-of-run step), as its spec asks for none of them (adapter-run-spec.ts, cli-run-spec.ts). */
680
+ * whatever its process asks, the runner hands it no model key (keyless, below), answers it keyless, opens it no harness
681
+ * key and no MCP, and refuses it a learning step (its learned workflows and its end-of-run step), as its spec asks for
682
+ * none of them (adapter-run-spec.ts, cli-run-spec.ts). */
631
683
  const modelRefused = launch.hold?.refused !== undefined;
684
+ /** Whether the claim's run sends no model key (claim-secrets.ts sendsNoModelKey: a held run as above, any run on a --faux
685
+ * runner, a faux-pinned one; `deps.env` is the claim's environment): the runner answers its process no tier's model key.
686
+ * A faux run still runs its learned steps on the faux model: only modelRefused refuses them. */
687
+ const keyless = sendsNoModelKey(launch, deps.env ?? {});
632
688
  const refusedSpend = () => new ClaimRefused("a held run its model kept from running asks its runner for no model spend: it routes no model and takes no learning step");
633
- const learningFolder = async () => {
634
- const made = await archilOf();
635
- return made === undefined ? learningFolderOf(deps.data, run.agentId) : learningWorkspace({ mode: "archil", agentId: run.agentId, archil: made });
636
- };
637
- /** The learning folder's reader, made once the claim's Archil claim is known (learnedFirst's folder is synchronous). */
638
- const folderNow = async () => {
639
- const made = await archilOf();
640
- return () => (made === undefined ? learningFolderOf(deps.data, run.agentId) : learningWorkspace({ mode: "archil", agentId: run.agentId, archil: made }));
641
- };
642
689
  /** What a learned workflow must never hold, as this runner sees it: every secret it holds (learning-seed.ts). */
643
690
  const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(store, sealKey, deps.data)), { local: true });
644
691
  /** The workflows the claim's learned_workflow tool runs, as this runner chose them (held.learnedFirst): what scopes the
@@ -714,21 +761,35 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
714
761
  // or refused); never its folder or its refresh token. Each token is carried into the runner's redactor for this run
715
762
  // (redact.ts carry) before it is handed, a renewed one too: model text that repeats it is cut from the run's journal
716
763
  // as the runner writes it (runner.ts fenced), from what it stages and from its rows, as the run's own tool keys are.
717
- // This answer is the claim's one decision whether it goes on the login: none, it does not; a login other than
718
- // AgentRun's own folder is refused in words, never left to a model key. The process reads no setting or machine id.
764
+ // This answer is the one decision whether the run goes on the login: none, it does not. Its claim read the setting
765
+ // (staysInRunner); a claim that read it off is never put on it, whatever the setting says now. A claim that read it on
766
+ // has it read again here, at the start, with the claim's settings, data folder, harness and place. Its environment is
767
+ // the claim's (the process's, when the runner was given none) with a saved gateway laid over it (withSavedGatewayDeps),
768
+ // not always the very one the claim read with; that
769
+ // difference can only refuse the start, never hand another folder, since the login is handed only when both reads name
770
+ // the same folder: a turn-off, or a move to another folder,
771
+ // between the claim and the start refuses the start in LOGIN_CHANGED_SINCE_CLAIM's fixed words (no folder in them),
772
+ // never a start on a login the setting no longer names nor a fall to a model key the run was not claimed on. Nothing
773
+ // else of the claim is read again. A run with a model key of its own, and a login other than AgentRun's own folder,
774
+ // were each decided at the claim (staysInRunner: no login read for the one, LOGIN_MACHINE_NEEDS_SERVER_USER for the
775
+ // other), so neither reaches here on a login. The process reads no setting or machine id.
776
+ // None for a run that sends no model key (keyless: a held run, any run on a --faux runner, a faux-pinned one), whatever
777
+ // its claim read: the login is a model credential like any key.
719
778
  claudeLogin: async () => {
720
- if (await runKeyed())
779
+ if (keyless)
721
780
  return undefined;
722
- const harness = launch.harness ?? revision.body.harness;
723
- const at = await loginForRun(store.settings, deps.data, deps.env ?? {}, harness, launch.place);
781
+ const at = reads.login;
724
782
  if (!at)
725
783
  return undefined;
726
- if (!agentRunLogin(at, deps.data))
727
- throw new ClaimRefused(LOGIN_NOT_HANDED);
784
+ const now = await loginForRun(store.settings, deps.data, deps.env ?? {}, harnessOfBody(launch), launch.place);
785
+ if (now?.dir !== at.dir)
786
+ throw new ClaimRefused(LOGIN_CHANGED_SINCE_CLAIM);
728
787
  const carry = cut.carry;
729
788
  if (!carry)
730
789
  throw new ClaimRefused("This runner has no redactor that can cut the login's token from what its run writes, so it hands none.");
731
- const tokens = loginTokensFor(at);
790
+ // Each renewal's outcome on the runner's log, in the server's line (print.ts logLine) under event claude_login:
791
+ // fixed words, a status and an OAuth error code, never a token.
792
+ const tokens = loginTokensFor(at, (fields) => log(logLine("claude_login", fields)));
732
793
  return {
733
794
  token: async () => {
734
795
  const token = await tokens.token();
@@ -744,10 +805,27 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
744
805
  return runSignIn(store, sealKey, claim, String(resolution), { vendors: vendorsOver(() => claimed, vendorFetch), log });
745
806
  },
746
807
  verifySignIn: (kept, at) => verifyRunSignIn(store, sealKey, claim, kept, Number(at)),
808
+ // None for a held run its model kept from running: nothing can call it, so no credential of it is opened.
747
809
  mcp: (ask) => projectCall(async () => {
810
+ if (modelRefused)
811
+ return undefined;
748
812
  const reach = await mcpReachOf(deps);
749
813
  const harness = { commit: (change) => change({ appendEntry: async (_conversation, entry) => void (await ask.appendRoot(dataOnly(entry))) }) };
750
- const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => runFolder(deps.data, run.agentId, claim.runId), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, undefined, launch) });
814
+ // What the gateway files goes in the run's own files. In Mode 1 that is the run's folder on this machine. In Mode 2
815
+ // it is the run's disk: through the computer this claim made once it mounts the folder (mountedFolder, the computer
816
+ // answer's), since the mount holds the disk's write delegation; over the disk's file API when no computer mounts it.
817
+ // That Workspace is opened at the first answer that files something, not at the claim: a claim whose MCP files
818
+ // nothing opens none (an open lists the run's folder, and makes it when it is missing). It only writes files over the
819
+ // disk's file API and runs no command, so it sweeps no exec spill folder, at its open or at its end (sweep: false): it
820
+ // opens mid-run, beside the archil answer's Workspace, whose commands may still be reading their spill files there.
821
+ // Opened once, and let go at the claim's release; an open that failed is tried again at the next answer. Its release is
822
+ // registered here, before any open, so an open still running at the release is ended too, and a filing after it opens
823
+ // nothing (openedAtUse). work() is read only when a call's answer files something (mcp-gateway.ts textOf, fileResults).
824
+ const disk = await archilOf();
825
+ const overTheDisk = disk === undefined ? undefined : openedAtUse(() => openRunWorkspace({ mode: 2, agentId: run.agentId, runId: claim.runId, archil: disk, sweep: false, log }));
826
+ if (overTheDisk)
827
+ releases.push(() => overTheDisk.end());
828
+ const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, toolSettings: revision.body.toolSettings, work: () => (overTheDisk === undefined ? runFolder(deps.data, run.agentId, claim.runId) : mountedFolder ?? overTheDisk.workspace()), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, undefined, launch) });
751
829
  if (!made)
752
830
  return undefined;
753
831
  releases.push(() => made.release());
@@ -788,10 +866,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
788
866
  // that tier's model's key alone (through a gateway, the gateway's), none when the revision names agree_on (no
789
867
  // grader). A learning run's grade and an SDK run's compile turn stay in the runner (runsInRunner): their process
790
868
  // never asks, and gets none. And never for a run that holds a key of its own (its launch's, read now): the server's
791
- // keys are not its to spend, whatever its process asks; nor for a held run its model kept from running, which routes
792
- // no model and grades nothing.
793
- const subagent = !modelRefused && revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL);
794
- const grades = !modelRefused && (launch.replay !== undefined || launch.audit !== undefined) && !agreeOnOf(revision.body.learning)?.length;
869
+ // keys are not its to spend, whatever its process asks; nor for a run that sends no model key (keyless: a held run,
870
+ // which routes no model and grades nothing, or a faux one, whose model sends none).
871
+ const subagent = !keyless && revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL);
872
+ const grades = !keyless && (launch.replay !== undefined || launch.audit !== undefined) && !agreeOnOf(revision.body.learning)?.length;
795
873
  if (!subagent && !grades)
796
874
  return {};
797
875
  const { tiers, refs } = routedSubagentTiers(revision.body, keys.env ?? {});
@@ -801,9 +879,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
801
879
  tierModelKeys: async (tiers) => {
802
880
  // The tiers the claim's learned workflows name (learnedTiers), as this runner chose them (learnedFirst below): a
803
881
  // tier the process names beyond them gets no key, and none before the choice (a held run its model kept from running
804
- // makes none: its learnedFirst is refused).
882
+ // makes none: its learnedFirst is refused), nor to a run that sends no model key (keyless: a faux one's tiers run on
883
+ // the faux model).
805
884
  const asked = new Set(tiers.filter((tier) => typeof tier === "string"));
806
- const named = !modelRefused && learnsWorkflows(revision.kind, learnedFlows) ? learnedTiers(learnedFlows).filter((tier) => asked.has(tier)) : [];
885
+ const named = !keyless && learnsWorkflows(revision.kind, learnedFlows) ? learnedTiers(learnedFlows).filter((tier) => asked.has(tier)) : [];
807
886
  const keyed = await runKeyed();
808
887
  const got = keyed ? {} : await tierModelKeys(keys, named);
809
888
  const plan = planOf(got);
@@ -825,9 +904,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
825
904
  // harness is a plan-billed recipe on this runner's table, and never another harness's. Opened for the recipe file
826
905
  // the process loaded (`digest`), never the one this runner's table read at its start: a file swapped for another
827
906
  // vendor's under the same id since then runs its own binary, and a key bound to the first file never opens for it.
907
+ // None for a held run its model kept from running: its agent never starts.
828
908
  harnessKeys: async (digest) => {
829
909
  const harness = launch.harness ?? revision.body.harness;
830
- const recipe = harness === undefined ? undefined : planRecipeOf(deps.env, harness);
910
+ const recipe = harness === undefined || modelRefused ? undefined : planRecipeOf(deps.env, harness);
831
911
  return recipe?.keys.length && typeof digest === "string" ? openHarnessKeys(store, sealKey, { ...recipe, digest }) : {};
832
912
  },
833
913
  liveViewerPut: (handover) => putLiveViewer(store, sealKey, claim, handover),
@@ -845,7 +925,6 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
845
925
  signInForgotten: (resolution) => forgottenSignIns(store, sealKey, run.agentId, String(resolution)),
846
926
  emailAccount: async () => (grantsEmail(granted) ? openAccount(store, sealKey) : undefined),
847
927
  calendar: async () => (granted.includes(CALENDAR_EVENTS) ? openCalendar(store, sealKey) : undefined),
848
- learning: async (method, args) => learningCall(await learningFolder(), method, args),
849
928
  install: async (name, signal) => {
850
929
  const harness = launch.harness ?? revision.body.harness;
851
930
  const entry = harness === undefined ? undefined : harnessOf(deps.env, harness);
@@ -870,13 +949,21 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
870
949
  hadComputer: async () => (await ask.hadComputer()) === true,
871
950
  ...(typeof ask.turnedOff === "string" ? { turnedOff: ask.turnedOff } : {}),
872
951
  ...(ask.signal instanceof AbortSignal ? { signal: ask.signal } : {}),
873
- ...(made ? { revokeMount: () => made.revoke(), inheritMount: () => made.inherit() } : {}),
952
+ ...(made ? { revokeMount: () => made.revoke(), inheritMount: () => made.inherit(), mountDisk: () => made.disk.id } : {}),
874
953
  ...(typeof ask.onImageWait === "function" ? { onImageWait: ask.onImageWait } : {}),
875
954
  ...(typeof ask.onStarting === "function" ? { onStarting: ask.onStarting } : {}),
876
955
  ...(typeof ask.onConnected === "function" ? { onConnected: ask.onConnected } : {}),
877
956
  ...(typeof ask.onComputerNote === "function" ? { onComputerNote: ask.onComputerNote } : {}),
878
957
  });
879
958
  releases.push(() => ws.end());
959
+ // A Mode 2 computer that mounts the run's folder holds the disk's write delegation: what the claim's MCP files then
960
+ // goes through it, attached here as the run's process attaches it. A failed attach leaves the MCP on the disk's file
961
+ // API, which says in its answer that the file could not be saved.
962
+ if (mode === 2)
963
+ mountedFolder = await attachedIn(ws.workspace, got?.computer).catch((error) => {
964
+ log(`the run's folder could not be attached for the MCP's files: ${error?.message ?? String(error)}`);
965
+ return undefined;
966
+ });
880
967
  // The computer let go by this runner at the claim's release too, before its folder: a process that crashed or broke
881
968
  // its channel never calls its release. Idempotent with the process's own release and with its park (which keeps it).
882
969
  const claimed = got;
@@ -889,7 +976,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
889
976
  const { syncProject: _sync, ...exposed } = got;
890
977
  return { ...exposed, ...(exposed.computer ? { computer: projectGate.capability(exposed.computer) } : {}),
891
978
  release: (...args) => cleanProject(() => exposed.release(...args)),
892
- ...(exposed.park ? { park: (...args) => cleanProject(() => exposed.park(...args)) } : {}) };
979
+ ...(exposed.park ? { park: (...args) => cleanProject(() => exposed.park(...args)) } : {}),
980
+ // The park's keep written ahead of it lands the folder's delta first, so it waits for the project's work as the
981
+ // park does.
982
+ ...(exposed.keepRow ? { keepRow: () => cleanProject(() => exposed.keepRow()) } : {}) };
893
983
  }
894
984
  return got;
895
985
  }),
@@ -915,14 +1005,13 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
915
1005
  // compares its answer with the other one through its grader, handed in by the run's process (runner/compare-end.ts).
916
1006
  // This runner reads both answers and the learning ledger, which no run's process may.
917
1007
  if (launch.replay || launch.audit) {
918
- const compare = compareEndOfRun(launch, { store, folder: await folderNow(), log, redact: cut });
1008
+ const compare = compareEndOfRun(launch, { store, log, redact: cut });
919
1009
  const grade = input.grade;
920
1010
  const rows = compare && grade && typeof input.grader === "string"
921
1011
  ? await compare({ runId: claim.runId, agentId: run.agentId, claim, outcome: input.outcome === "failed" ? "failed" : "completed", ...(input.cut === undefined ? {} : { cut: "faulted" }), grader: input.grader, grade: (request) => grade(request), ask: input.ask, signal: input.signal })
922
1012
  : undefined;
923
1013
  return rows?.compared ? { also: [], compared: dataOnly(rows.compared) } : undefined;
924
1014
  }
925
- const made = await archilOf();
926
1015
  // The audit's spend, skipped as the run's spec skips it (claim-secrets.ts claimSpendOff): over the claim's own key.
927
1016
  const spendOff = await claimSpendOff(keys, await claimModelKey(keys, claim.runId));
928
1017
  // The audit's start after the step (audit.ts withAudit) is this runner's too: it reads the run's journal and writes
@@ -936,8 +1025,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
936
1025
  stored: () => storeSecrets(store, sealKey, deps.data),
937
1026
  log,
938
1027
  decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys(keys, DECISION_PROVIDER_KEYS)) }),
939
- learningFolder: made === undefined ? (agentId) => learningFolderOf(deps.data, agentId) : (agentId) => learningWorkspace({ mode: "archil", agentId, archil: made }),
940
- }), { store, agentId: run.agentId, revisionId: run.revisionId, context: BACKGROUND_CONTEXT, folder: await folderNow(), shown, log, sealKey, spendOff, launch, redact: cut, admitAuxiliary });
1028
+ }), { store, agentId: run.agentId, revisionId: run.revisionId, context: BACKGROUND_CONTEXT, shown, log, sealKey, spendOff, launch, redact: cut, admitAuxiliary });
941
1029
  if (!step)
942
1030
  return undefined;
943
1031
  // keptOf is the run's process's, asked over the channel: read once, for the round learningEndOfRun reads (the
@@ -965,11 +1053,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
965
1053
  // the process's lay chose them: none where its lay laid none (`laid` false: a read that failed, a seed with no
966
1054
  // workflows).
967
1055
  const start = learningStartOf(launch);
968
- const folder = await folderNow();
969
- const laid = ask?.laid === true && start && !seedFailed(start) && !start.noWorkflows ? await workflowsAt({ folder, store, shown }, start.seed).catch(() => []) : [];
1056
+ const laid = ask?.laid === true && start && !seedFailed(start) && !start.noWorkflows ? await workflowsAt({ store, agentId: run.agentId, shown }, start.seed).catch(() => []) : [];
970
1057
  const spendOff = await claimSpendOff(keys, await claimModelKey(keys, claim.runId));
971
1058
  const outputSchema = revision.body.outputSchema;
972
- const got = await learnedFirst({ store, sealKey, agentId: run.agentId, runId: claim.runId, revisionId: run.revisionId, kind: revision.kind, ...(outputSchema !== undefined ? { outputSchema } : {}), launch, context: BACKGROUND_CONTEXT, log, folder, shown, spendOff, admitAuxiliary }, laid);
1059
+ const got = await learnedFirst({ store, sealKey, agentId: run.agentId, runId: claim.runId, revisionId: run.revisionId, kind: revision.kind, ...(outputSchema !== undefined ? { outputSchema } : {}), launch, context: BACKGROUND_CONTEXT, log, shown, spendOff, admitAuxiliary }, laid);
973
1060
  learnedFlows = got.workflows;
974
1061
  return cutDeep(dataOnly(got), cut);
975
1062
  })()),
@@ -1018,54 +1105,11 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
1018
1105
  }
1019
1106
  /** `env`'s string values. */
1020
1107
  const stringsOf = (env) => Object.fromEntries(Object.getOwnPropertyNames(env).flatMap((name) => (typeof env[name] === "string" ? [[name, env[name]]] : [])));
1021
- /** The learning-script ops a run's process may run (learn/folder.ts): its reads alone. The folder's writers (the
1022
- * end-of-run step's check, the learning run's merge, a repair) are the runner's. */
1023
- const LEARNING_OPS = new Set(["read", "show", "has", "log", "diff", "status"]);
1024
- /** A call of the learning folder a run's process asks (Held.learning), on the runner's own Workspace of the claim's
1025
- * agent's folder: reads pass, and the learning script runs its reads, with the script's own environment (the script
1026
- * laid by the runner as the folder's own); nothing the process asks writes there. */
1027
- export async function learningCall(folder, method, args) {
1028
- const ws = folder.workspace;
1029
- try {
1030
- switch (method) {
1031
- case "read":
1032
- return await ws.read(String(args[0]), args[1]);
1033
- case "stat":
1034
- return dataOnly(await ws.stat(String(args[0])));
1035
- case "list":
1036
- return dataOnly(await ws.list(String(args[0])));
1037
- case "grep":
1038
- return dataOnly(await ws.grep(String(args[0]), args[1]));
1039
- case "write":
1040
- // The learning script laid as learn/folder.ts lays it (ensureScript, before a script run): the runner's own text.
1041
- if (args[0] === LEARNING_SCRIPT.file())
1042
- return await LEARNING_SCRIPT.ensure(ws);
1043
- throw new ClaimRefused(`a run's process may not write ${JSON.stringify(args[0])} in its learning folder`);
1044
- case "append":
1045
- case "remove":
1046
- case "mkdir":
1047
- throw new ClaimRefused(`a run's process may not ${method} ${JSON.stringify(args[0])} in its learning folder`);
1048
- case "exec": {
1049
- const argv = args[0];
1050
- const options = (args[1] ?? {});
1051
- if (!Array.isArray(argv) || argv[0] !== "sh" || argv[1] !== LEARNING_SCRIPT.file() || !LEARNING_OPS.has(String(argv[2])) || !argv.every((part) => typeof part === "string"))
1052
- throw new ClaimRefused("a run's process runs no program in its learning folder but its learning script");
1053
- await LEARNING_SCRIPT.ensure(ws);
1054
- return dataOnly(await ws.exec(argv, { env: LEARNING_SCRIPT.env(), timeoutMs: LEARNING_SCRIPT.timeoutMs(), ...(options.stdin instanceof Uint8Array ? { stdin: options.stdin } : {}) }));
1055
- }
1056
- default:
1057
- throw new ClaimRefused(`a run's learning folder has no ${method} in its process`);
1058
- }
1059
- }
1060
- finally {
1061
- await folder.end().catch(() => undefined);
1062
- }
1063
- }
1064
1108
  /** The node and module a run's process starts with. */
1065
1109
  export const childArgv = () => [process.execPath, "--import", new URL("../secrets.js", import.meta.url).pathname, new URL("./run-child.js", import.meta.url).pathname];
1066
1110
  /** Whether a run stays in its runner's process rather than one of its own: one that runs no agent's code or tool here.
1067
1111
  * A built-in learning run (its launch names harness "learning"): its grade is one ask through the runner's model route,
1068
- * and its one write is the merge into the agent's learning folder, which no run's process may write. An SDK backend
1112
+ * and its one write is the merge into the agent's learning, which no run's process may write. An SDK backend
1069
1113
  * run (launch.sdk): its agent runs in the caller's application, and its loop here reads the evidence it posts and closes
1070
1114
  * its inbox. A CLI capture (launch.cli_learning) likewise only receives source evidence and serves owner corrections.
1071
1115
  * A native run (launch.native): its agent is the source machine's own sign-in, reached through the server's
@@ -1081,16 +1125,6 @@ export const loginRunnerInProcessWords = (other) => `This runner runs each run a
1081
1125
  /** The words a run on a harness recipe is refused in where each run is a user of its own (harness-table.ts recipeHarness). */
1082
1126
  export const RECIPE_NEEDS_SERVER_USER = `A run on a harness recipe needs runs under the server's own user, since its install, its check and its owner's sign-in are that user's alone, and this runner runs each run as a user of its own: set ${RUN_USER_ENV}=same on this runner.`;
1083
1127
  export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
1084
- /** Whether run `runId` stays in its runner's process: runsInRunner's, and a workflow run on a server with a documents
1085
- * directory (launch.documents), whose reads and writes (a pdf_pages call's pages) are rooted in a folder the server's
1086
- * user holds and no slot's user is given; its nodes run the server's own tools alone, no agent's code. A run on Claude
1087
- * Code's login on this machine (claude-login.ts loginForRun), where runs are the runner's own user (`process`), stays in
1088
- * the runner, its CLI on the login's folder. Where each run is a user of its own (`uid`), a run on AgentRun's own login
1089
- * folder is a process of its own handed the login's access token alone (held.ts claudeLogin, claude-login-token.ts),
1090
- * never the folder; it is refused at its claim (ClaimRefused, in words) on this machine's own login (machineFolder), and
1091
- * while a `process` runner on the same data folder is live (its CLI renews the folder's login itself). A run its caller
1092
- * handed a model key (model_key) runs on that key and never on the login (cli-run-spec.ts), so it is a process of its
1093
- * own like any other. */
1094
1128
  export async function staysInRunner(deps, harness, launch, runId, isolation) {
1095
1129
  // A recipe's harness reads its install, its check's note and its owner's sign-in, each the server user's alone: never
1096
1130
  // opened to a slot's user (the sign-in least of all), so where each run is a user of its own it is refused here. And a
@@ -1100,38 +1134,45 @@ export async function staysInRunner(deps, harness, launch, runId, isolation) {
1100
1134
  throw new ClaimRefused(RECIPE_NEEDS_SERVER_USER);
1101
1135
  await refuseRecipeTriggerRun(deps, harness, launch);
1102
1136
  if (runsInRunner(harness, launch))
1103
- return true;
1137
+ return STAYS;
1104
1138
  if (launch.documents !== undefined) {
1105
1139
  const run = await deps.store.runs.get(runId);
1106
1140
  const revision = run ? await deps.store.agents.revision(run.revisionId) : undefined;
1107
1141
  if (revision && isWorkflowRevision(revision))
1108
- return true;
1142
+ return STAYS;
1109
1143
  }
1110
1144
  const login = await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, harness, launch.place);
1111
1145
  if (login === undefined)
1112
- return false;
1146
+ return OFF_LOGIN;
1113
1147
  if ((await openRunModelKey({ store: deps.store, sealKey: deps.sealKey }, runId)) !== undefined)
1114
- return false;
1148
+ return OFF_LOGIN;
1115
1149
  if (isolation.kind !== "uid")
1116
- return true;
1150
+ return STAYS;
1117
1151
  if (!agentRunLogin(login, deps.data))
1118
1152
  throw new ClaimRefused(LOGIN_MACHINE_NEEDS_SERVER_USER);
1119
1153
  const other = await loginRunnerInProcess(deps.data, deps.store.runners);
1120
1154
  if (other !== undefined)
1121
1155
  throw new ClaimRefused(loginRunnerInProcessWords(other));
1122
- return false;
1156
+ return { stays: false, login };
1123
1157
  }
1158
+ const STAYS = { stays: true };
1159
+ const OFF_LOGIN = { stays: false, login: undefined };
1124
1160
  /** The runner's loop factory where each run is a process of its own: a ChildLoop per claim, but for a run that stays in
1125
1161
  * the runner (staysInRunner). */
1126
1162
  export function childLoops(options) {
1127
1163
  // Each slot locked on the data directory too: another runner on it whose range overlaps this one's never runs a run
1128
1164
  // on a slot this one holds.
1129
1165
  const slots = options.isolation.kind === "uid" ? new Slots(options.isolation.first, options.isolation.slots, slotLocks(options.deps.data)) : undefined;
1130
- const own = (loopDeps) => childLoop(options, slots, loopDeps);
1131
1166
  const here = resolveRunnerLoop(options.deps);
1132
1167
  return createDispatchLoop({
1133
1168
  launchOf: (runId) => options.deps.store.runs.launch(runId),
1134
- resolve: async (harness, launch, runId) => ((await staysInRunner(options.deps, harness, launch, runId, options.isolation)) ? here(harness, launch, runId) : own),
1169
+ resolve: async (harness, launch, runId) => {
1170
+ const place = await staysInRunner(options.deps, harness, launch, runId, options.isolation);
1171
+ if (place.stays)
1172
+ return here(harness, launch, runId);
1173
+ const own = (loopDeps) => childLoop(options, slots, loopDeps, place.login);
1174
+ return own;
1175
+ },
1135
1176
  });
1136
1177
  }
1137
1178
  registerRunErrors();
@@ -1142,12 +1183,6 @@ function withGatewayKey(claimed, key) {
1142
1183
  Object.defineProperty(out, GATEWAY_KEY_ENV, { value: key, enumerable: false, writable: false, configurable: false });
1143
1184
  return out;
1144
1185
  }
1145
- /** The pair a run's process is handed this runner's OpenTelemetry settings in (secrets.ts OTEL_PAIR): none when it has
1146
- * none. */
1147
- export const otelPair = (env = process.env) => {
1148
- const settings = otelSettings(env);
1149
- return Object.keys(settings).length ? [[OTEL_PAIR, JSON.stringify(settings)]] : [];
1150
- };
1151
1186
  /** The environment a run's process starts with: the runner's run environment's plain values (runEnv: its secrets are
1152
1187
  * not enumerable, so none is here), no key-shaped name, and where its keys come from. */
1153
1188
  function childEnv(base, keys, extra) {
@@ -1170,7 +1205,8 @@ export function runChannel(socket, onClose, gate = SERVER_SLOTS, more = {}) {
1170
1205
  saves = exposeSaveSlots(channel, gate);
1171
1206
  return channel;
1172
1207
  }
1173
- function childLoop(options, slots, loopDeps) {
1208
+ /** `login`: the Claude login this run's claim read (staysInRunner), the one its runner hands the run (ClaimReads). */
1209
+ function childLoop(options, slots, loopDeps, login) {
1174
1210
  const { deps, isolation } = options;
1175
1211
  const cut = loopDeps.redact ?? ((text) => text);
1176
1212
  const log = (line) => options.log(cut(line));
@@ -1252,33 +1288,26 @@ function childLoop(options, slots, loopDeps) {
1252
1288
  const savedGateway = savedGatewayIn(claimEnv);
1253
1289
  // The run's own keys: those its claim opens (claim-secrets.ts), the one list its loop in this process read. Its model
1254
1290
  // keys are its pinned model's (claimSecrets scopes them by the launch's model), the one its route sends: never the
1255
- // host's default's now, where its revision names no model and a key saved since moved that default.
1291
+ // host's default's now, where its revision names no model and a key saved since moved that default. On a --faux
1292
+ // runner, or pinned to the faux model, a run sends no model key (claim-secrets.ts sendsNoModelKey): its process is
1293
+ // handed none, not even its revision's model's.
1256
1294
  const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, launch, claim.runId);
1257
- // A --faux start alone is pinned to the faux model (model.ts chooseModel), which stands in for its revision's and
1258
- // sends no key: its process is handed its revision's model's key with them, as a run of that model is handed it.
1259
- // Only on a runner in faux mode too: a faux launch claimed where FAUX_ENV is unset gets no second claim. A held run its
1260
- // model kept from running at its create (hold.refused) is laid no model key here either: its model runs nowhere.
1261
- const ofRevision = launch.model?.provider === FAUX_PROVIDER && claimEnv[FAUX_ENV] ? await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, { ...(launch.plane ? { plane: launch.plane } : {}), ...(launch.hold ? { hold: launch.hold } : {}) }) : {};
1262
1295
  // A run that holds a model key of its own (model_key, its launch's) spends that key alone: its process is handed
1263
1296
  // none of the server's model keys, as its spec drops them from its tools' (claim-secrets.ts withoutModelKeys).
1264
1297
  // Copies: the runner's own reads (heldFor's `claimed`: what the run's learning must never keep) stay whole.
1265
1298
  const keyed = (await openRunModelKey({ store: deps.store, sealKey: deps.sealKey }, claim.runId)) !== undefined;
1266
- const toProcess = keyed ? [withoutModelKeys({ ...claimed }), withoutModelKeys({ ...ofRevision })] : [claimed, ofRevision];
1299
+ const toProcess = keyed ? withoutModelKeys({ ...claimed }) : claimed;
1267
1300
  // The saved gateway's key, kept off the claim's tool keys (claimSecrets), is handed for the run's model routes alone,
1268
1301
  // read as the server's model keys are (savedModelKeys, over the claim's environment the gateway was laid over), as a
1269
1302
  // run in this process reads it from its environment by name; none to a run that brings its own key, and none to a
1270
- // held run its model kept from running, which routes no model.
1271
- const gatewayKey = savedGateway && !launch.hold?.refused ? (keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }))[GATEWAY_KEY_ENV] || undefined : undefined;
1272
- const handed = (name) => (name === GATEWAY_KEY_ENV && savedGateway ? gatewayKey : toProcess.map((from) => from[name]).find((value) => typeof value === "string" && value !== ""));
1273
- const keys = encode([
1274
- ...SECRET_NAMES.flatMap((name) => {
1275
- const value = handed(name);
1276
- return value === undefined ? [] : [[name, value]];
1277
- }),
1278
- // The runner's OpenTelemetry settings, so the run's process exports its trace as this one would: on the pipe,
1279
- // since no run's environment has them (runEnv), never in the process's environment.
1280
- ...otelPair(),
1281
- ]);
1303
+ // run whose model sends no key (sendsNoModelKey: a held run its model kept from running, any run on a --faux runner,
1304
+ // a faux-pinned one).
1305
+ const gatewayKey = savedGateway && !sendsNoModelKey(launch, claimEnv) ? (keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }))[GATEWAY_KEY_ENV] || undefined : undefined;
1306
+ const handed = (name) => (name === GATEWAY_KEY_ENV && savedGateway ? gatewayKey : toProcess[name] || undefined);
1307
+ const keys = encode(SECRET_NAMES.flatMap((name) => {
1308
+ const value = handed(name);
1309
+ return value === undefined ? [] : [[name, value]];
1310
+ }));
1282
1311
  const slot = await slots?.take();
1283
1312
  if (slots && slot === undefined) {
1284
1313
  // Every free slot of this runner is held by another runner on the data directory (ranges that overlap): the run
@@ -1300,8 +1329,17 @@ function childLoop(options, slots, loopDeps) {
1300
1329
  const tops = runTops(deps.data, runRow.agentId, claim.runId);
1301
1330
  // The run's pieced writes (big-writes.ts): let go when its channel ends, or at the claim's release.
1302
1331
  const bigs = runBigWrites();
1303
- const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed, signal: loopDeps.signal, ...(loopDeps.incarnation ? { incarnation: loopDeps.incarnation } : {}) }, cut, log, bigs);
1332
+ const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed, signal: loopDeps.signal, login, ...(loopDeps.incarnation ? { incarnation: loopDeps.incarnation } : {}) }, cut, log, bigs);
1333
+ // The run's trace: its process posts each call of it (tracer.ts postedTracing), and this runner's tracing makes the
1334
+ // spans and exports them in the background. No exporter, flush or OTLP setting is ever the process's, so neither
1335
+ // its exit nor this claim's release waits on a collector. Made inside the claim's cleanup, so nothing it waits on
1336
+ // can keep the slot.
1337
+ let traced;
1304
1338
  try {
1339
+ const tracing = await (options.tracing ?? genAiTracing()).catch(() => undefined);
1340
+ // Its agent is the one this runner reads from the store, never one the process posts; a read that fails is the
1341
+ // agent's id alone (agentOfRun).
1342
+ traced = tracing ? tracePosts(tracing, claim.runId, cut, await agentOfRun(deps.store.agents, runRow.agentId)) : undefined;
1305
1343
  let extra = {};
1306
1344
  let argv = [...(options.argv ?? childArgv())];
1307
1345
  // A claim that resumes a run whose last runner ended before giving its folders back finds them its last slot's,
@@ -1320,7 +1358,8 @@ function childLoop(options, slots, loopDeps) {
1320
1358
  argv = [isolation.helper, "run", String(slot), "--keep-fd", "3", "--keep-fd", "4", "--", ...argv];
1321
1359
  }
1322
1360
  // The saved gateway's address and models go as plain variables (childEnv), and its mark says they are the saved one.
1323
- const env = childEnv(claimEnv, keys, savedGateway ? { ...extra, [SAVED_GATEWAY_ENV]: "1" } : extra);
1361
+ // The server's keyless holds now (web-holds.ts), so the run's Web starts with them: hold data alone.
1362
+ const env = childEnv(claimEnv, keys, { ...extra, ...holdsEnv(), ...(savedGateway ? { [SAVED_GATEWAY_ENV]: "1" } : {}) });
1324
1363
  const [program, ...rest] = argv;
1325
1364
  child = spawn(program, rest, { stdio: ["ignore", "inherit", "inherit", "pipe", "pipe"], env, detached: true });
1326
1365
  exited = new Promise((resolve) => {
@@ -1340,6 +1379,9 @@ function childLoop(options, slots, loopDeps) {
1340
1379
  const bound = { claim, agentId: runRow.agentId, revisionId: runRow.revisionId };
1341
1380
  channel.expose("store", (method, args) => storeCall(deps.store, method, args, bound, log));
1342
1381
  channel.expose("journal", journalTarget(loopDeps.journal(claim), cut));
1382
+ const posts = traced;
1383
+ if (posts)
1384
+ channel.expose("trace", (method, args) => posts.post(method, args));
1343
1385
  channel.expose("held", (method, args) => {
1344
1386
  // Its own members alone: a name of Object's prototype (constructor, toString) is no call of Held.
1345
1387
  const fn = Object.hasOwn(heldSide.held, method) ? heldSide.held[method] : undefined;
@@ -1361,6 +1403,8 @@ function childLoop(options, slots, loopDeps) {
1361
1403
  return undefined;
1362
1404
  case "log":
1363
1405
  return void log(String(args[0]));
1406
+ case "webHold":
1407
+ return void noteHold(args[0]);
1364
1408
  default:
1365
1409
  throw new ClaimRefused(`the runner has no ${method} for a run`);
1366
1410
  }
@@ -1368,7 +1412,7 @@ function childLoop(options, slots, loopDeps) {
1368
1412
  loopDeps.live?.(() => latest);
1369
1413
  const reach = await mcpReachOf(deps);
1370
1414
  const init = {
1371
- claim, data: deps.data, signal: loopDeps.signal, where: deps.store.where,
1415
+ claim, data: deps.data, signal: loopDeps.signal, where: deps.store.where, ...(traced ? { traced: true } : {}),
1372
1416
  ...(reach.loopback ? { mcpLoopback: true, mcpOwn: reach.own ?? [] } : {}),
1373
1417
  ...(deps.githubApi ? { githubApi: deps.githubApi } : {}),
1374
1418
  ...(deps.githubWeb ? { githubWeb: deps.githubWeb } : {}),
@@ -1396,6 +1440,8 @@ function childLoop(options, slots, loopDeps) {
1396
1440
  }
1397
1441
  finally {
1398
1442
  ready();
1443
+ // A process gone before it ended its trace: its spans end with the claim (after its own end, a no-op).
1444
+ await traced?.end("run-error");
1399
1445
  await heldSide.projectEnd?.();
1400
1446
  const reaped = await end(slot, tops).catch((error) => {
1401
1447
  log(`run ${claim.runId}: its process's end failed: ${error?.message ?? error}`);