@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37

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 (522) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/README.md +417 -219
  3. package/dist/adapters.d.ts +12 -2
  4. package/dist/adapters.js +27 -2
  5. package/dist/agent-rows.d.ts +2 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +9 -4
  8. package/dist/api-only.d.ts +2 -1
  9. package/dist/api-only.js +3 -1
  10. package/dist/archil-routes.d.ts +40 -7
  11. package/dist/archil-routes.js +167 -54
  12. package/dist/archil-settings.d.ts +79 -7
  13. package/dist/archil-settings.js +140 -14
  14. package/dist/attach-conformance-cli.d.ts +1 -0
  15. package/dist/attach-conformance-cli.js +18 -0
  16. package/dist/attach-conformance.d.ts +25 -0
  17. package/dist/attach-conformance.js +343 -0
  18. package/dist/attach-images.d.ts +15 -0
  19. package/dist/attach-images.js +59 -0
  20. package/dist/background.d.ts +0 -6
  21. package/dist/background.js +0 -28
  22. package/dist/box-image.d.ts +1 -97
  23. package/dist/box-image.js +4 -284
  24. package/dist/box-paths.d.ts +2 -7
  25. package/dist/box-paths.js +7 -13
  26. package/dist/box-settings.d.ts +0 -11
  27. package/dist/box-settings.js +4 -29
  28. package/dist/browser-commands.js +1 -1
  29. package/dist/browser-computer.d.ts +47 -3
  30. package/dist/browser-computer.js +286 -18
  31. package/dist/browser-cost.d.ts +1 -1
  32. package/dist/browser-live.d.ts +20 -8
  33. package/dist/browser-live.js +50 -27
  34. package/dist/browser-person.d.ts +19 -2
  35. package/dist/browser-person.js +55 -6
  36. package/dist/browser-wait-ended.d.ts +23 -0
  37. package/dist/browser-wait-ended.js +42 -0
  38. package/dist/cap.d.ts +12 -57
  39. package/dist/cap.js +20 -160
  40. package/dist/catalog.d.ts +1 -12
  41. package/dist/catalog.js +3 -33
  42. package/dist/cli.js +17 -26
  43. package/dist/composio-preset.d.ts +36 -0
  44. package/dist/composio-preset.js +179 -0
  45. package/dist/computer-attach.d.ts +125 -0
  46. package/dist/computer-attach.js +330 -0
  47. package/dist/computer-calls.d.ts +48 -0
  48. package/dist/computer-calls.js +126 -0
  49. package/dist/computer-channel.d.ts +57 -0
  50. package/dist/computer-channel.js +115 -0
  51. package/dist/computer-commands.d.ts +1 -1
  52. package/dist/computer-held-routes.d.ts +35 -0
  53. package/dist/computer-held-routes.js +106 -0
  54. package/dist/computer-held.d.ts +48 -0
  55. package/dist/computer-held.js +87 -0
  56. package/dist/computer-keys.d.ts +21 -1
  57. package/dist/computer-keys.js +53 -11
  58. package/dist/computer-live.d.ts +160 -0
  59. package/dist/computer-live.js +643 -0
  60. package/dist/computer-routes.d.ts +1 -4
  61. package/dist/computer-routes.js +3 -5
  62. package/dist/computer-setting.d.ts +2 -0
  63. package/dist/computer-setting.js +38 -1
  64. package/dist/computer-view.d.ts +24 -2
  65. package/dist/computer-view.js +51 -3
  66. package/dist/computer-viewer.d.ts +6 -0
  67. package/dist/computer-viewer.js +297 -0
  68. package/dist/computers.d.ts +79 -12
  69. package/dist/computers.js +147 -28
  70. package/dist/console/assets/index-Cn6JX1uH.js +563 -0
  71. package/dist/console/assets/index-DRN62V5v.css +1 -0
  72. package/dist/console/index.html +2 -2
  73. package/dist/docker-daemon.d.ts +2 -2
  74. package/dist/docker-daemon.js +2 -2
  75. package/dist/errors.js +5 -5
  76. package/dist/faux-computers.d.ts +9 -20
  77. package/dist/faux-computers.js +56 -24
  78. package/dist/files.d.ts +1 -9
  79. package/dist/files.js +1 -9
  80. package/dist/github-connection.d.ts +10 -2
  81. package/dist/github-connection.js +65 -2
  82. package/dist/github-faux.js +1 -1
  83. package/dist/github.d.ts +22 -2
  84. package/dist/github.js +42 -8
  85. package/dist/gpu-words.d.ts +14 -0
  86. package/dist/gpu-words.js +21 -0
  87. package/dist/graph-view.d.ts +3 -1
  88. package/dist/graph-view.js +25 -1
  89. package/dist/handed-values.d.ts +1 -1
  90. package/dist/handed-values.js +1 -1
  91. package/dist/harness-install.d.ts +60 -3
  92. package/dist/harness-install.js +322 -34
  93. package/dist/harness.d.ts +1 -0
  94. package/dist/harness.js +36 -2
  95. package/dist/host-tools.d.ts +9 -10
  96. package/dist/host-tools.js +7 -7
  97. package/dist/hosted-search.d.ts +5 -4
  98. package/dist/hosted-search.js +2 -7
  99. package/dist/import-sources.d.ts +10 -0
  100. package/dist/import-sources.js +44 -2
  101. package/dist/import.d.ts +3 -3
  102. package/dist/import.js +37 -6
  103. package/dist/index.d.ts +1 -3
  104. package/dist/index.js +1 -2
  105. package/dist/key-refusal.d.ts +1 -1
  106. package/dist/key-refusal.js +2 -2
  107. package/dist/learn/check.d.ts +11 -2
  108. package/dist/learn/check.js +124 -6
  109. package/dist/learn/commit.d.ts +43 -7
  110. package/dist/learn/commit.js +166 -22
  111. package/dist/learn/folder.d.ts +11 -0
  112. package/dist/learn/folder.js +37 -1
  113. package/dist/learn/general.d.ts +66 -0
  114. package/dist/learn/general.js +73 -0
  115. package/dist/learn/grade.d.ts +22 -1
  116. package/dist/learn/grade.js +107 -16
  117. package/dist/learn/index.d.ts +1 -1
  118. package/dist/learn/index.js +1 -1
  119. package/dist/learn/learning.sh +12 -1
  120. package/dist/learn/notes.d.ts +3 -0
  121. package/dist/learn/notes.js +3 -0
  122. package/dist/learn/reflect.d.ts +14 -2
  123. package/dist/learn/reflect.js +54 -30
  124. package/dist/learn/skills.d.ts +37 -5
  125. package/dist/learn/skills.js +60 -7
  126. package/dist/learned-nodes.d.ts +6 -2
  127. package/dist/learned-workflow.d.ts +43 -9
  128. package/dist/learned-workflow.js +128 -37
  129. package/dist/learning-batch.d.ts +283 -0
  130. package/dist/learning-batch.js +574 -0
  131. package/dist/learning-cost.d.ts +79 -0
  132. package/dist/learning-cost.js +69 -0
  133. package/dist/learning-evals.d.ts +33 -0
  134. package/dist/learning-evals.js +98 -0
  135. package/dist/learning-routes.d.ts +32 -4
  136. package/dist/learning-routes.js +48 -12
  137. package/dist/learning-words.d.ts +9 -0
  138. package/dist/learning-words.js +12 -2
  139. package/dist/learning.d.ts +39 -19
  140. package/dist/learning.js +88 -46
  141. package/dist/live/stream.js +6 -3
  142. package/dist/live/translate.d.ts +4 -3
  143. package/dist/live/translate.js +8 -4
  144. package/dist/live-reach.d.ts +37 -0
  145. package/dist/live-reach.js +62 -0
  146. package/dist/mcp-gateway.d.ts +9 -0
  147. package/dist/mcp-gateway.js +60 -11
  148. package/dist/mcp-oauth.d.ts +57 -7
  149. package/dist/mcp-oauth.js +133 -18
  150. package/dist/mcp-private-hosts.d.ts +4 -4
  151. package/dist/mcp-private-hosts.js +20 -12
  152. package/dist/mcp-probe.d.ts +27 -3
  153. package/dist/mcp-probe.js +106 -29
  154. package/dist/mcp-secret-writes.js +8 -0
  155. package/dist/mcp-servers-store.d.ts +38 -15
  156. package/dist/mcp-servers-store.js +120 -23
  157. package/dist/mcp-store.d.ts +10 -4
  158. package/dist/mcp-store.js +17 -6
  159. package/dist/model-form.d.ts +26 -0
  160. package/dist/model-form.js +80 -0
  161. package/dist/model.d.ts +5 -5
  162. package/dist/model.js +29 -16
  163. package/dist/openapi.d.ts +2 -0
  164. package/dist/openapi.js +586 -64
  165. package/dist/owner.d.ts +0 -1
  166. package/dist/owner.js +0 -2
  167. package/dist/page.d.ts +18 -0
  168. package/dist/page.js +48 -20
  169. package/dist/paid-calls.d.ts +1 -1
  170. package/dist/paid-calls.js +1 -1
  171. package/dist/place-offers.d.ts +96 -0
  172. package/dist/place-offers.js +202 -0
  173. package/dist/place.d.ts +9 -13
  174. package/dist/place.js +21 -32
  175. package/dist/port-models.d.ts +2 -1
  176. package/dist/port-models.js +5 -3
  177. package/dist/print.d.ts +16 -9
  178. package/dist/print.js +15 -17
  179. package/dist/propose.d.ts +4 -0
  180. package/dist/propose.js +34 -11
  181. package/dist/provider.js +3 -2
  182. package/dist/reflect-range.d.ts +8 -1
  183. package/dist/reflect-range.js +1 -1
  184. package/dist/run-cut.d.ts +5 -0
  185. package/dist/run-cut.js +19 -0
  186. package/dist/run-launch.d.ts +28 -3
  187. package/dist/run-launch.js +14 -4
  188. package/dist/run-learning-served.d.ts +2 -2
  189. package/dist/run-manifest.d.ts +2 -2
  190. package/dist/run-manifest.js +2 -2
  191. package/dist/run-reads-over-store.d.ts +1 -1
  192. package/dist/run-repo.d.ts +20 -0
  193. package/dist/run-repo.js +63 -0
  194. package/dist/run-secrets.js +3 -3
  195. package/dist/run-timeline-served.d.ts +1 -1
  196. package/dist/run-timeline-served.js +56 -44
  197. package/dist/run-view.d.ts +8 -5
  198. package/dist/run-view.js +18 -10
  199. package/dist/runnable.d.ts +2 -2
  200. package/dist/runnable.js +6 -2
  201. package/dist/runner/adapter-loop.d.ts +39 -8
  202. package/dist/runner/adapter-loop.js +770 -83
  203. package/dist/runner/adapter-run-spec.d.ts +36 -7
  204. package/dist/runner/adapter-run-spec.js +171 -37
  205. package/dist/runner/adapters/pi-computer.d.ts +7 -0
  206. package/dist/runner/adapters/pi-computer.js +43 -0
  207. package/dist/runner/adapters/pi.d.ts +20 -7
  208. package/dist/runner/adapters/pi.js +111 -26
  209. package/dist/runner/beside.d.ts +7 -3
  210. package/dist/runner/beside.js +26 -12
  211. package/dist/runner/claim-secrets.d.ts +4 -0
  212. package/dist/runner/claim-secrets.js +6 -1
  213. package/dist/runner/cli-run-spec.d.ts +27 -3
  214. package/dist/runner/cli-run-spec.js +198 -74
  215. package/dist/runner/commands.d.ts +8 -2
  216. package/dist/runner/commands.js +31 -6
  217. package/dist/runner/computer-channel.d.ts +34 -0
  218. package/dist/runner/computer-channel.js +61 -0
  219. package/dist/runner/conformance/harness.d.ts +0 -1
  220. package/dist/runner/conformance/harness.js +87 -18
  221. package/dist/runner/conformance/subject.d.ts +1 -1
  222. package/dist/runner/dispatch.js +3 -0
  223. package/dist/runner/end-of-run.d.ts +22 -12
  224. package/dist/runner/end-of-run.js +38 -16
  225. package/dist/runner/github-app.d.ts +2 -1
  226. package/dist/runner/github-app.js +6 -4
  227. package/dist/runner/harness-loops.js +16 -2
  228. package/dist/runner/held-run.d.ts +65 -0
  229. package/dist/runner/held-run.js +158 -0
  230. package/dist/runner/journal-kinds.d.ts +35 -6
  231. package/dist/runner/journal-kinds.js +20 -1
  232. package/dist/runner/journal-reader.d.ts +5 -4
  233. package/dist/runner/journal-reader.js +12 -10
  234. package/dist/runner/learning-ask.d.ts +7 -1
  235. package/dist/runner/learning-ask.js +21 -6
  236. package/dist/runner/learning-dispatch.d.ts +22 -0
  237. package/dist/runner/learning-dispatch.js +77 -10
  238. package/dist/runner/learning-end.d.ts +37 -1
  239. package/dist/runner/learning-end.js +115 -14
  240. package/dist/runner/learning-factory.d.ts +1 -1
  241. package/dist/runner/learning-factory.js +15 -5
  242. package/dist/runner/learning-loop.d.ts +139 -7
  243. package/dist/runner/learning-loop.js +369 -32
  244. package/dist/runner/learning-seed.d.ts +9 -0
  245. package/dist/runner/learning-seed.js +14 -1
  246. package/dist/runner/live-ticker.js +1 -0
  247. package/dist/runner/loop-contract.d.ts +16 -1
  248. package/dist/runner/loop-contract.js +6 -0
  249. package/dist/runner/loop.d.ts +10 -2
  250. package/dist/runner/loop.js +22 -1
  251. package/dist/runner/main.d.ts +13 -1
  252. package/dist/runner/main.js +38 -6
  253. package/dist/runner/mcp-claim.d.ts +11 -4
  254. package/dist/runner/mcp-claim.js +140 -23
  255. package/dist/runner/mcp-github.d.ts +4 -2
  256. package/dist/runner/mcp-github.js +1 -8
  257. package/dist/runner/mcp-run.d.ts +6 -4
  258. package/dist/runner/mcp-run.js +16 -3
  259. package/dist/runner/metrics.d.ts +15 -2
  260. package/dist/runner/metrics.js +21 -2
  261. package/dist/runner/model-route.d.ts +3 -0
  262. package/dist/runner/model-route.js +5 -2
  263. package/dist/runner/pr-checkout.d.ts +60 -0
  264. package/dist/runner/pr-checkout.js +176 -0
  265. package/dist/runner/reflect-hook.d.ts +19 -0
  266. package/dist/runner/reflect-hook.js +20 -8
  267. package/dist/runner/runner.d.ts +26 -0
  268. package/dist/runner/runner.js +231 -27
  269. package/dist/runner/scratch-sweep.d.ts +13 -0
  270. package/dist/runner/scratch-sweep.js +62 -0
  271. package/dist/runner/sessions.d.ts +1 -1
  272. package/dist/runner/spec-holds.d.ts +8 -3
  273. package/dist/runner/spec-holds.js +12 -10
  274. package/dist/runner/store-port.d.ts +7 -2
  275. package/dist/runner/store-secrets.js +21 -4
  276. package/dist/runner/subagent.d.ts +44 -0
  277. package/dist/runner/subagent.js +190 -0
  278. package/dist/runner/workflow-host.d.ts +24 -3
  279. package/dist/runner/workflow-host.js +24 -4
  280. package/dist/runner/workflow-loop.d.ts +6 -3
  281. package/dist/runner/workflow-loop.js +9 -8
  282. package/dist/runner/workflow-spec.d.ts +39 -15
  283. package/dist/runner/workflow-spec.js +143 -40
  284. package/dist/runs-over-store.d.ts +16 -6
  285. package/dist/runs-over-store.js +145 -29
  286. package/dist/seal-key.js +3 -3
  287. package/dist/sealed-settings-store.d.ts +5 -2
  288. package/dist/sealed-settings-store.js +10 -4
  289. package/dist/sealing.js +1 -2
  290. package/dist/secret-cut.d.ts +1 -1
  291. package/dist/secret-cut.js +1 -1
  292. package/dist/secret-writes.d.ts +5 -4
  293. package/dist/secret-writes.js +5 -4
  294. package/dist/server-secrets-store.d.ts +4 -3
  295. package/dist/server-secrets-store.js +15 -9
  296. package/dist/server-secrets.js +3 -2
  297. package/dist/server.d.ts +75 -63
  298. package/dist/server.js +712 -316
  299. package/dist/settings-wake.d.ts +21 -0
  300. package/dist/settings-wake.js +59 -0
  301. package/dist/standard-webhooks.d.ts +4 -1
  302. package/dist/standard-webhooks.js +8 -4
  303. package/dist/store/agent-body.d.ts +9 -2
  304. package/dist/store/agent-body.js +16 -8
  305. package/dist/store/command-wake.d.ts +12 -0
  306. package/dist/store/command-wake.js +37 -0
  307. package/dist/store/deadline.js +9 -5
  308. package/dist/store/dialect.d.ts +6 -0
  309. package/dist/store/dialect.js +5 -0
  310. package/dist/store/index.d.ts +4 -4
  311. package/dist/store/index.js +2 -2
  312. package/dist/store/journal/storage.d.ts +3 -2
  313. package/dist/store/journal/storage.js +15 -6
  314. package/dist/store/postgres/connection.js +9 -4
  315. package/dist/store/postgres/dialect.js +4 -0
  316. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  317. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  318. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  319. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  320. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  321. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  322. package/dist/store/schema.d.ts +2 -1
  323. package/dist/store/schema.js +85 -13
  324. package/dist/store/seal.d.ts +13 -0
  325. package/dist/store/seal.js +19 -0
  326. package/dist/store/sqlite/connection.d.ts +5 -0
  327. package/dist/store/sqlite/connection.js +88 -47
  328. package/dist/store/sqlite/run-patch.d.ts +25 -7
  329. package/dist/store/sqlite/run-patch.js +58 -14
  330. package/dist/store/sqlite/store.js +331 -59
  331. package/dist/store/store.d.ts +330 -21
  332. package/dist/store/store.js +34 -2
  333. package/dist/store-reads/analytics.js +3 -2
  334. package/dist/store-reads/cap.d.ts +2 -4
  335. package/dist/store-reads/cap.js +16 -7
  336. package/dist/store-reads/decisions.d.ts +3 -3
  337. package/dist/store-reads/decisions.js +3 -6
  338. package/dist/store-reads/import-summary.d.ts +1 -1
  339. package/dist/store-reads/journal.d.ts +5 -4
  340. package/dist/store-reads/journal.js +118 -27
  341. package/dist/store-reads/learning.d.ts +34 -4
  342. package/dist/store-reads/learning.js +137 -23
  343. package/dist/store-reads/runs.d.ts +7 -5
  344. package/dist/store-reads/runs.js +17 -10
  345. package/dist/store-reads/stats.js +5 -1
  346. package/dist/store-reads/workflow.d.ts +1 -1
  347. package/dist/store-view.d.ts +5 -0
  348. package/dist/store-view.js +70 -29
  349. package/dist/template-eval.js +8 -5
  350. package/dist/template-github-permissions.d.ts +22 -8
  351. package/dist/template-github-permissions.js +35 -15
  352. package/dist/templates.d.ts +64 -0
  353. package/dist/templates.js +101 -16
  354. package/dist/timeline/timeline.d.ts +30 -1
  355. package/dist/timeline/timeline.js +29 -13
  356. package/dist/timeline/util.d.ts +4 -0
  357. package/dist/timeline/util.js +14 -0
  358. package/dist/tool-blurbs.js +1 -0
  359. package/dist/tool-budget.d.ts +27 -7
  360. package/dist/tool-budget.js +21 -9
  361. package/dist/tool-gate.d.ts +23 -10
  362. package/dist/tool-gate.js +60 -44
  363. package/dist/tool-plane.d.ts +46 -28
  364. package/dist/tool-plane.js +73 -31
  365. package/dist/tools.d.ts +31 -38
  366. package/dist/tools.js +117 -74
  367. package/dist/trigger-adapter.d.ts +4 -0
  368. package/dist/trigger-secrets-shown.d.ts +2 -2
  369. package/dist/trigger-secrets-shown.js +1 -1
  370. package/dist/trigger-signatures.d.ts +26 -6
  371. package/dist/trigger-signatures.js +44 -8
  372. package/dist/trigger-targets.d.ts +2 -0
  373. package/dist/trigger-targets.js +1 -0
  374. package/dist/trigger-webhook.js +5 -2
  375. package/dist/triggers.d.ts +10 -6
  376. package/dist/triggers.js +37 -7
  377. package/dist/turn-end.d.ts +0 -3
  378. package/dist/turn-end.js +0 -3
  379. package/dist/turns.js +16 -1
  380. package/dist/usage-lines.d.ts +1 -1
  381. package/dist/validate.d.ts +6 -0
  382. package/dist/validate.js +41 -4
  383. package/dist/web-fetch.d.ts +1 -1
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +147 -103
  387. package/dist/webhooks.js +564 -324
  388. package/dist/workflow/decision-recovery.d.ts +23 -0
  389. package/dist/workflow/decision-recovery.js +80 -0
  390. package/dist/workflow/decisions.d.ts +134 -0
  391. package/dist/workflow/decisions.js +46 -0
  392. package/dist/workflow/host-session.d.ts +5 -0
  393. package/dist/workflow/host-session.js +85 -0
  394. package/dist/workflow/host-tools.d.ts +3 -0
  395. package/dist/workflow/host-tools.js +3 -0
  396. package/dist/workflow/node-runner.d.ts +113 -0
  397. package/dist/workflow/node-runner.js +270 -0
  398. package/dist/workflow/node.d.ts +89 -0
  399. package/dist/workflow/node.js +101 -0
  400. package/dist/workflow/operator-error.d.ts +4 -0
  401. package/dist/workflow/operator-error.js +4 -0
  402. package/dist/workflow/pi-versions.d.ts +32 -0
  403. package/dist/workflow/pi-versions.js +65 -0
  404. package/dist/workflow/record-file.d.ts +10 -0
  405. package/dist/workflow/record-file.js +56 -0
  406. package/dist/workflow/record-tool.d.ts +77 -0
  407. package/dist/workflow/record-tool.js +126 -0
  408. package/dist/workflow/record.d.ts +151 -0
  409. package/dist/workflow/record.js +401 -0
  410. package/dist/workflow/run-error.d.ts +16 -0
  411. package/dist/workflow/run-error.js +26 -0
  412. package/dist/workflow/runner.d.ts +6 -0
  413. package/dist/workflow/runner.js +240 -0
  414. package/dist/workflow/store.d.ts +23 -0
  415. package/dist/workflow/store.js +242 -0
  416. package/dist/workflow/task.d.ts +133 -0
  417. package/dist/workflow/task.js +412 -0
  418. package/dist/workflow/thinking.d.ts +3 -0
  419. package/dist/workflow/thinking.js +7 -0
  420. package/dist/workflow/tool-context.d.ts +21 -0
  421. package/dist/workflow/tool-context.js +13 -0
  422. package/dist/workflow/types.d.ts +126 -0
  423. package/dist/workflow/types.js +1 -0
  424. package/dist/workflow-run.d.ts +2 -2
  425. package/dist/workspace/agent-computer.d.ts +137 -0
  426. package/dist/workspace/agent-computer.js +292 -0
  427. package/dist/workspace/archil-claim.d.ts +11 -0
  428. package/dist/workspace/archil-claim.js +18 -10
  429. package/dist/workspace/archil-disks.d.ts +49 -0
  430. package/dist/workspace/archil-disks.js +185 -0
  431. package/dist/workspace/archil-exec.js +2 -3
  432. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  433. package/dist/workspace/archil-mount-credential.js +13 -4
  434. package/dist/workspace/attached-computers.d.ts +41 -0
  435. package/dist/workspace/attached-computers.js +114 -0
  436. package/dist/workspace/computer-deps.d.ts +32 -17
  437. package/dist/workspace/computer-deps.js +37 -14
  438. package/dist/workspace/computer-for-claim.d.ts +58 -13
  439. package/dist/workspace/computer-for-claim.js +267 -26
  440. package/dist/workspace/computer-hold.d.ts +11 -27
  441. package/dist/workspace/computer-hold.js +36 -56
  442. package/dist/workspace/computer-janitor.d.ts +3 -2
  443. package/dist/workspace/computer-janitor.js +43 -9
  444. package/dist/workspace/computer-ledger.d.ts +5 -1
  445. package/dist/workspace/computer-ledger.js +11 -0
  446. package/dist/workspace/computer-mcp.d.ts +25 -0
  447. package/dist/workspace/computer-mcp.js +41 -0
  448. package/dist/workspace/computer-ports.d.ts +4 -13
  449. package/dist/workspace/computer-ports.js +4 -107
  450. package/dist/workspace/computer-script.d.ts +37 -0
  451. package/dist/workspace/computer-script.js +138 -0
  452. package/dist/workspace/executors.d.ts +1 -1
  453. package/dist/workspace/index.d.ts +7 -4
  454. package/dist/workspace/index.js +4 -1
  455. package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
  456. package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
  457. package/dist/workspace/resolve-computer.d.ts +45 -11
  458. package/dist/workspace/resolve-computer.js +72 -14
  459. package/dist/workspace/run-disk.d.ts +34 -0
  460. package/dist/workspace/run-disk.js +91 -0
  461. package/dist/workspace/run-tools.d.ts +35 -18
  462. package/dist/workspace/run-tools.js +24 -29
  463. package/dist/workspace/server-run-workspace.d.ts +3 -2
  464. package/dist/workspace/server-run-workspace.js +17 -4
  465. package/dist/workspace.js +1 -1
  466. package/package.json +19 -21
  467. package/templates/README.md +9 -6
  468. package/templates/code-review/agent.md +27 -11
  469. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  470. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  471. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  472. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  473. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  474. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  475. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  476. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  477. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  478. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  479. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  480. package/templates/code-review/evals/re-review/prompt.md +1 -1
  481. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  482. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  483. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  484. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  485. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  486. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  487. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  488. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  489. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  490. package/templates/code-review/findings.schema.json +131 -27
  491. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  492. package/templates/code-review/skills/review/DEEP.md +130 -0
  493. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  494. package/templates/code-review/skills/review/SKILL.md +104 -154
  495. package/templates/market-monitor/agent.md +1 -1
  496. package/dist/box/record.d.ts +0 -6
  497. package/dist/box/record.js +0 -41
  498. package/dist/box/sweep.d.ts +0 -53
  499. package/dist/box/sweep.js +0 -193
  500. package/dist/box-egress-vm.d.ts +0 -118
  501. package/dist/box-egress-vm.js +0 -354
  502. package/dist/box-egress.d.ts +0 -105
  503. package/dist/box-egress.js +0 -256
  504. package/dist/box-relay-vm.d.ts +0 -84
  505. package/dist/box-relay-vm.js +0 -437
  506. package/dist/box-relay.d.ts +0 -36
  507. package/dist/box-relay.js +0 -207
  508. package/dist/boxes.d.ts +0 -109
  509. package/dist/boxes.js +0 -249
  510. package/dist/budget.d.ts +0 -71
  511. package/dist/budget.js +0 -199
  512. package/dist/console/assets/index-B7NKTU8E.css +0 -1
  513. package/dist/console/assets/index-CXZMgJE7.js +0 -550
  514. package/dist/daytona-api.d.ts +0 -10
  515. package/dist/daytona-api.js +0 -20
  516. package/dist/egress-proxy.d.ts +0 -45
  517. package/dist/egress-proxy.js +0 -416
  518. package/dist/egress-table.d.ts +0 -24
  519. package/dist/egress-table.js +0 -165
  520. package/dist/run-db.d.ts +0 -53
  521. package/dist/run-db.js +0 -116
  522. package/templates/code-review/rules/REVIEW.md +0 -41
@@ -43,6 +43,8 @@ export type Target = {
43
43
  run_id: string;
44
44
  input: Json;
45
45
  };
46
+ /** What the webhook did with a trigger.failed message (webhooks.ts emitTrigger). */
47
+ type Told = "queued" | "unsaved" | "off" | "closed";
46
48
  /** What a trigger.failed webhook message says (webhooks.ts). */
47
49
  export type TriggerFailed = {
48
50
  trigger_id: string;
@@ -55,7 +57,7 @@ export type TriggerFailed = {
55
57
  };
56
58
  auto_paused: boolean;
57
59
  };
58
- /** A run's provenance, kept in its serve.json: the trigger that started it, and the firing. `name`: the trigger's name as
60
+ /** A run's provenance, kept with its launch row: the trigger that started it, and the firing. `name`: the trigger's name as
59
61
  * it was at the firing, put on the run so its Timeline row names the trigger without a store read (runs.ts
60
62
  * servedTriggerRow); a rename pushes the new name (server.ts triggerChanged). */
61
63
  export type RunTrigger = {
@@ -101,6 +103,7 @@ export type TriggerDeps = {
101
103
  * once, durable before it is answered; a trigger's settings removed with it. Undefined for an adapter that keeps none. */
102
104
  settings(adapterId: string): {
103
105
  mint(scope: string, field: string): Promise<string>;
106
+ set(scope: string, field: string, value: string, as?: "utf8"): Promise<void>;
104
107
  remove(scope: string): Promise<void>;
105
108
  } | undefined;
106
109
  /** A run's status, or null when there is no such run. */
@@ -112,7 +115,7 @@ export type TriggerDeps = {
112
115
  } | null>;
113
116
  /** Queues a trigger.failed webhook message under `key`, the firing's (webhooks.ts emitTrigger): `off` when there is no
114
117
  * webhook to send it to; `unsaved` or `closed` when it is not in the outbox. */
115
- notify(failed: TriggerFailed, key: string): Promise<"queued" | "unsaved" | "off" | "closed">;
118
+ notify(failed: TriggerFailed, key: string): Told | Promise<Told>;
116
119
  say(fields: Record<string, string | number>): void;
117
120
  clock?: TriggerClock;
118
121
  /** The sources this engine reads: the registry's (trigger-adapters.ts), unless a test gives its own. */
@@ -273,8 +276,9 @@ export declare class Triggers {
273
276
  } | null;
274
277
  hook_url?: string | undefined;
275
278
  }>;
276
- /** A trigger's new signing secret, shown this once; the old one signs nothing from now on. */
277
- rotate(id: string): Promise<Record<string, string>>;
279
+ /** A trigger's new signing secret, shown this once; the old one signs nothing from now on. One whose sender gives its
280
+ * secret (Composio's) takes it as `given` and shows nothing: none is made for it. */
281
+ rotate(id: string, given?: unknown): Promise<Record<string, string>>;
278
282
  /** Whether `id` is a trigger of the pushed source `kind` that is on: the one a request delivered for `kind` may fire. */
279
283
  hookable(id: string, kind: string): Promise<boolean>;
280
284
  /** The source of trigger `id` when it is hookable: what its pushed source's check and parse read (its filter). With no
@@ -454,10 +458,10 @@ export declare class Triggers {
454
458
  * check. */
455
459
  private given;
456
460
  /** A run's title, from the trigger that starts it: "<its source> <its name>" (the word its Timeline row begins with,
457
- * pi-durable-agent's TRIGGER_LABELS), and the event its payload's tag names, when one does ("Webhook reviews:
461
+ * TRIGGER_LABELS), and the event its payload's tag names, when one does ("Webhook reviews:
458
462
  * pull_request opened"); never its input, which may be a sender's markup. */
459
463
  private titleOf;
460
- /** Who a firing's input is from (pi-durable-agent's MessageOrigin): the trigger, by its definition as it fires, never
464
+ /** Who a firing's input is from (a MessageOrigin): the trigger, by its definition as it fires, never
461
465
  * by its payload. Only a source whose words are its owner's (a schedule's, fired on time or by hand) gives owner true;
462
466
  * a pushed source's come from outside, its body empty or not. */
463
467
  private originOf;
package/dist/triggers.js CHANGED
@@ -151,6 +151,20 @@ function capIssues(adapters, source, target) {
151
151
  return [{ field: "max_active_runs", reason: "not_allowed", message: "max_active_runs bounds the runs a trigger starts, and a message_run target starts none. Set it to null to clear it." }];
152
152
  return [];
153
153
  }
154
+ /** What is wrong with the secret a rotation gives for a trigger of `source`: a source whose sender gives its secret
155
+ * (Composio's) needs one, a string (the store checks its length and form); any other takes none, it is minted. A create
156
+ * never takes one: Composio makes the secret once the trigger's URL is registered, so a composio trigger starts with none
157
+ * and refuses every request until it is set. */
158
+ function givenSecretIssues(adapter, source, secret) {
159
+ const gives = adapter?.givesSecret?.(source) === true;
160
+ if (gives && secret === undefined)
161
+ return [{ field: "secret", reason: "missing", message: "This trigger's sender gives its secret (Composio's webhook subscription secret): send it as secret." }];
162
+ if (!gives && secret !== undefined)
163
+ return [{ field: "secret", reason: "not_allowed", message: "This trigger's secret is made by this server: send no secret." }];
164
+ if (gives && typeof secret !== "string")
165
+ return [{ field: "secret", reason: "wrong_type", message: "secret is a string" }];
166
+ return [];
167
+ }
154
168
  /** A POST /triggers body's own fields, read as create reads them with the sources of `adapters`: its source, target,
155
169
  * settings, name and enabled, with every issue. What it names (the agent, the run) is create's own check
156
170
  * (TriggerDeps.targetIssues). */
@@ -271,12 +285,17 @@ export class Triggers {
271
285
  // What it minted, shown this once, by field: a webhook's `secret`.
272
286
  return { ...(await this.view(asTrigger(row))), ...minted };
273
287
  }
274
- /** A trigger's new signing secret, shown this once; the old one signs nothing from now on. */
275
- async rotate(id) {
288
+ /** A trigger's new signing secret, shown this once; the old one signs nothing from now on. One whose sender gives its
289
+ * secret (Composio's) takes it as `given` and shows nothing: none is made for it. */
290
+ async rotate(id, given) {
276
291
  const trigger = await this.need(id);
277
- if (!mints(this.adapter(trigger.source)))
292
+ const adapter = this.adapter(trigger.source);
293
+ if (!mints(adapter))
278
294
  throw invalid([{ field: "source.kind", reason: "not_allowed", message: "Only a webhook trigger has a secret." }]);
279
- return this.mint(trigger.source, id);
295
+ const issues = givenSecretIssues(adapter, trigger.source, given);
296
+ if (issues.length)
297
+ throw invalid(issues);
298
+ return this.mint(trigger.source, id, given);
280
299
  }
281
300
  /** Whether `id` is a trigger of the pushed source `kind` that is on: the one a request delivered for `kind` may fire. */
282
301
  async hookable(id, kind) {
@@ -412,6 +431,9 @@ export class Triggers {
412
431
  const trigger = await this.need(id);
413
432
  if (source && source.kind !== trigger.source.kind)
414
433
  throw invalid([{ field: "source.kind", reason: "not_allowed", message: "A trigger's source kind is fixed: make a new trigger for another." }]);
434
+ // Whose secret it keeps (the sender's, or one this server made) is fixed with its scheme: make a new trigger for the other.
435
+ if (source && (this.adapter(source).givesSecret?.(source) === true) !== (this.adapter(trigger.source).givesSecret?.(trigger.source) === true))
436
+ throw invalid([{ field: "source.signature", reason: "not_allowed", message: "A trigger's signature cannot move between a secret its sender gives (composio) and one this server makes: make a new trigger for the other." }]);
415
437
  const now = this.clock.now();
416
438
  const enabled = typeof body.enabled === "boolean" ? body.enabled : trigger.enabled;
417
439
  const adapter = this.adapter(trigger.source);
@@ -863,13 +885,21 @@ export class Triggers {
863
885
  }
864
886
  /** Each field `source`'s adapter mints for its triggers, made now for trigger `id`, by field: none for one that keeps
865
887
  * no trigger-scoped secret. */
866
- async mint(source, id) {
888
+ async mint(source, id, given) {
867
889
  const adapter = this.adapter(source);
868
890
  if (!mints(adapter))
869
891
  return {};
870
892
  const store = this.deps.settings(adapter.id);
871
893
  if (!store)
872
894
  throw new Error(`no sealed settings for ${adapter.id}`);
895
+ // The sender's own secret, sealed as a minted one is, and never answered; none yet, none made.
896
+ if (adapter.givesSecret?.(source)) {
897
+ if (given === undefined)
898
+ return {};
899
+ const field = Object.entries(adapter.settings.fields).find(([, f]) => f.mint)[0];
900
+ await store.set(id, field, given, "utf8");
901
+ return {};
902
+ }
873
903
  return Object.fromEntries(await Promise.all(Object.entries(adapter.settings.fields).filter(([, f]) => f.mint).map(async ([field]) => [field, await store.mint(id, field)])));
874
904
  }
875
905
  /** A scope belongs to one trigger: `source`'s (its adapter's scopeOf), for a trigger `id` that is to be on, is refused
@@ -913,7 +943,7 @@ export class Triggers {
913
943
  return { ...target, input: this.inputOf(trigger, { by: "manual", nominalAt: now, payload: null }) };
914
944
  }
915
945
  /** A run's title, from the trigger that starts it: "<its source> <its name>" (the word its Timeline row begins with,
916
- * pi-durable-agent's TRIGGER_LABELS), and the event its payload's tag names, when one does ("Webhook reviews:
946
+ * TRIGGER_LABELS), and the event its payload's tag names, when one does ("Webhook reviews:
917
947
  * pull_request opened"); never its input, which may be a sender's markup. */
918
948
  titleOf(trigger, firing) {
919
949
  const source = TRIGGER_LABELS[trigger.source.kind] ?? trigger.source.kind;
@@ -922,7 +952,7 @@ export class Triggers {
922
952
  const action = attrs?.action;
923
953
  return `${source} ${trigger.name}${event ? `: ${event}${action ? ` ${action}` : ""}` : ""}`;
924
954
  }
925
- /** Who a firing's input is from (pi-durable-agent's MessageOrigin): the trigger, by its definition as it fires, never
955
+ /** Who a firing's input is from (a MessageOrigin): the trigger, by its definition as it fires, never
926
956
  * by its payload. Only a source whose words are its owner's (a schedule's, fired on time or by hand) gives owner true;
927
957
  * a pushed source's come from outside, its body empty or not. */
928
958
  originOf(trigger) {
@@ -7,9 +7,6 @@ export { TURN_END } from "./timeline/index.js";
7
7
  * for a message an older bridge sent and wrote no end for, the run's next process writes it as it opens. */
8
8
  export declare const MESSAGE = "adapter.message";
9
9
  export declare const MESSAGE_END = "adapter.message_end";
10
- /** The root's marker of a paid request already written as a pi.assistant entry (`{ key, request, unpriced? }`, in the
11
- * entry's commit): `unpriced` when its cost was not in yet, which a REQUEST_COST_LATE naming it brings. */
12
- export declare const BOOKED = "adapter.request";
13
10
  /** What a turn's end says: the message it took (the MESSAGE id), the session's own outcome (`failed` too when the bridge
14
11
  * wrote the turn's error, in `error`), the entry of the turn's answer (its last request with text and no call; null
15
12
  * when the turn showed no text), and whether a request it made is still unbooked (its cost then comes later, as a
package/dist/turn-end.js CHANGED
@@ -10,9 +10,6 @@ export { TURN_END } from "./timeline/index.js";
10
10
  * for a message an older bridge sent and wrote no end for, the run's next process writes it as it opens. */
11
11
  export const MESSAGE = "adapter.message";
12
12
  export const MESSAGE_END = "adapter.message_end";
13
- /** The root's marker of a paid request already written as a pi.assistant entry (`{ key, request, unpriced? }`, in the
14
- * entry's commit): `unpriced` when its cost was not in yet, which a REQUEST_COST_LATE naming it brings. */
15
- export const BOOKED = "adapter.request";
16
13
  /** The `api` of every assistant message serve's bridge writes for a claude-agent or codex request (harness-app.ts): its
17
14
  * stop reason says nothing of the turn's end (a cost, a cut, an interruption and an answer read alike). */
18
15
  export const ADAPTER_API = "agentrun-adapter";
package/dist/turns.js CHANGED
@@ -6,6 +6,7 @@
6
6
  // codex as it is sent (or dropped by a stop), and TURN_END, in the commit of the turn's last entries.
7
7
  // A message is open from the moment the run took it until its turn's end closes it, so a follow-up queued behind a turn
8
8
  // keeps the run open whatever the door says meanwhile.
9
+ import { KINDS } from "./runner/journal-kinds.js";
9
10
  import { ADAPTER_API, MESSAGE, MESSAGE_END, TURN_END } from "./turn-end.js";
10
11
  /** The request id prefix of a run's end-of-run turn (learning-run.ts): the server's message, never the person's. */
11
12
  export const REFLECT_REQUEST = "learn-reflect-";
@@ -41,8 +42,10 @@ export class Turns {
41
42
  const fresh = id === undefined || id > this.#seen;
42
43
  if (id !== undefined && fresh) {
43
44
  this.#seen = id;
45
+ // A CLI record's entry says when it was written (`at`): that is the progress, since a CLI run's live tick moves only
46
+ // with the tool it holds, never with each entry. Any other entry's is the read's `now`.
44
47
  if (this.open > 0)
45
- this.#progress = now;
48
+ this.#progress = isObject(value.data) && typeof value.data.at === "number" ? value.data.at : now;
46
49
  }
47
50
  const data = isObject(value.data) ? value.data : undefined;
48
51
  const first = Array.isArray(value.model) && isObject(value.model[0]) ? value.model[0] : undefined;
@@ -61,6 +64,18 @@ export class Turns {
61
64
  if (fresh)
62
65
  this.#sinceError = first.errorMessage;
63
66
  }
67
+ else if (value.kind === KINDS.turnStart && id !== undefined) {
68
+ // A CLI run's turn, open from the commit of the message that starts it until its turn end (adapter-loop.ts CliRecord).
69
+ this.#take(`c:${id}`, typeof data?.at === "number" ? data.at : now, id);
70
+ }
71
+ else if (value.kind === KINDS.turnEnd && data) {
72
+ // Turns are taken one at a time, so the end closes the oldest turn still open.
73
+ const message = [...this.#messages.values()].find((one) => one.key.startsWith("c:") && !one.end);
74
+ if (!message)
75
+ continue;
76
+ const status = data.status === "completed" ? "answered" : data.status === "interrupted" ? "interrupted" : "failed";
77
+ message.end = { status, answer: null, ...(typeof data.error === "string" ? { error: data.error } : {}) };
78
+ }
64
79
  else if (value.kind === MESSAGE && typeof data?.id === "string") {
65
80
  this.#take(`m:${data.id}`, now, id ?? this.#seen);
66
81
  }
@@ -1,4 +1,4 @@
1
- /** A run's meters, from its store (cap.ts metersIn) or its live rows: each null when one of its charges is unknown. */
1
+ /** A run's meters, from the one store (store-reads/cap.ts metersOverStore) or its live rows: each null when one of its charges is unknown. */
2
2
  export type RunMeters = {
3
3
  tools: number | null;
4
4
  tokens: number | null;
@@ -9,12 +9,18 @@ export declare const isObject: (value: unknown) => value is Json;
9
9
  export declare const IDEMPOTENCY_TTL_S = 86400;
10
10
  export declare const stable: (value: unknown) => string;
11
11
  export declare const DEFINITION_FIELDS: string[];
12
+ /** What an agentic definition may ask the server to check out in each run's folder before its first turn
13
+ * (runner/pr-checkout.ts): `pull_request`, the pull request the run's GitHub event names, at its head, read-only, in
14
+ * `repo/`; `none` clears it on an edit. */
15
+ export declare const CHECKOUTS: readonly ["pull_request", "none"];
12
16
  /** Why a field a definition may have elsewhere has no place in an agent store's revision. */
13
17
  export declare const NOT_KEPT: Record<string, string>;
14
18
  /** The most tool calls an agent's budget (max_tool_calls, tool-budget.ts) may name. */
15
19
  export declare const MAX_TOOL_CALLS = 1000;
16
20
  /** The most bytes an agent's output_schema takes, as JSON. */
17
21
  export declare const MAX_OUTPUT_SCHEMA_BYTES: number;
22
+ /** The tiers an agentic revision may name a model for (`model_tiers`): those a subagent runs on (runner/subagent.ts). */
23
+ export declare const MODEL_TIER_NAMES: readonly ["fast", "strong"];
18
24
  /** `provider/model-id`. */
19
25
  export declare const MODEL_REF: RegExp;
20
26
  /** A body's fields that `allowed` does not name, each as the 422's not_allowed issue. */
package/dist/validate.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { invalid } from "./errors.js";
3
3
  import { HARNESSES } from "./harness.js";
4
4
  import { THINKING_LEVELS } from "./model.js";
5
+ import { likelyModel, modelShape } from "./model-form.js";
5
6
  import { placeIssues } from "./place.js";
6
7
  import { computerIssues, settingConflict } from "./computer-setting.js";
7
8
  import { settingsIssues } from "./tool-plane.js";
@@ -17,7 +18,11 @@ export const isObject = (value) => typeof value === "object" && value !== null &
17
18
  /** How long an Idempotency-Key answers with its first answer (capabilities' limits.idempotency_ttl_s). */
18
19
  export const IDEMPOTENCY_TTL_S = 86_400;
19
20
  export const stable = (value) => Array.isArray(value) ? `[${value.map(stable).join(",")}]` : isObject(value) ? `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stable(value[k])}`).join(",")}}` : JSON.stringify(value);
20
- export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "cap_mode", "output_schema", "max_tool_calls"];
21
+ export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "model_tiers", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "cap_mode", "output_schema", "max_tool_calls", "checkout"];
22
+ /** What an agentic definition may ask the server to check out in each run's folder before its first turn
23
+ * (runner/pr-checkout.ts): `pull_request`, the pull request the run's GitHub event names, at its head, read-only, in
24
+ * `repo/`; `none` clears it on an edit. */
25
+ export const CHECKOUTS = ["pull_request", "none"];
21
26
  /** Why a field a definition may have elsewhere has no place in an agent store's revision. */
22
27
  export const NOT_KEPT = {
23
28
  input_schema: "The agent store keeps no input_schema: an agentic run takes {content}, and a workflow checks its input against its own schema.",
@@ -26,8 +31,19 @@ export const NOT_KEPT = {
26
31
  export const MAX_TOOL_CALLS = 1_000;
27
32
  /** The most bytes an agent's output_schema takes, as JSON. */
28
33
  export const MAX_OUTPUT_SCHEMA_BYTES = 64 * 1024;
34
+ /** The tiers an agentic revision may name a model for (`model_tiers`): those a subagent runs on (runner/subagent.ts). */
35
+ export const MODEL_TIER_NAMES = ["fast", "strong"];
29
36
  /** `provider/model-id`. */
30
37
  export const MODEL_REF = /^[^/\s]+\/\S+$/;
38
+ /** What a model that is no `provider/model-id` is told: the form `harness` takes, with examples, and the likely id when
39
+ * one is obvious. Structural, so it knows no keys here: the likely id is named in both forms (the vendor's own, and
40
+ * OpenRouter's), never one that a server with only the other key could not run. */
41
+ function modelFormIssue(harness, given) {
42
+ const own = typeof given === "string" ? likelyModel({}, harness, given) : undefined;
43
+ const routed = typeof given === "string" ? likelyModel({ OPENROUTER_API_KEY: "-" }, harness, given) : undefined;
44
+ const likely = own && routed && own !== routed ? `${own}, or ${routed} through OpenRouter` : own;
45
+ return `${modelShape({}, harness)}: ${typeof given === "string" ? `"${given}"` : "that"} is not one.${likely ? ` Did you mean ${likely}?` : ""}`;
46
+ }
31
47
  const SKILL_FILE = "/SKILL.md";
32
48
  const issue = (field, reason, message, fix) => ({ field, reason, message, ...(fix ? { fix } : {}) });
33
49
  /** A body's fields that `allowed` does not name, each as the 422's not_allowed issue. */
@@ -77,7 +93,21 @@ export function definitionIssues(definition, { at = "definition", creating = tru
77
93
  if (d.workflow !== undefined)
78
94
  out.push(issue(`${at}.model`, "not_allowed", "A workflow revision keeps no model: its model nodes run on this host's default.", `Remove ${at}.model.`));
79
95
  else if (typeof d.model !== "string" || !MODEL_REF.test(d.model))
80
- out.push(issue(`${at}.model`, "bad_format", `${at}.model is "provider/model-id"`));
96
+ out.push(issue(`${at}.model`, "bad_format", modelFormIssue(typeof d.harness === "string" ? d.harness : "pi", d.model)));
97
+ }
98
+ if (d.model_tiers !== undefined) {
99
+ if (d.workflow !== undefined)
100
+ out.push(issue(`${at}.model_tiers`, "not_allowed", "A workflow revision keeps no model tiers: each model node names its tier, run on this host's model for it.", `Remove ${at}.model_tiers.`));
101
+ else if (!isObject(d.model_tiers) || !Object.keys(d.model_tiers).length)
102
+ out.push(issue(`${at}.model_tiers`, "wrong_type", `${at}.model_tiers is an object of ${MODEL_TIER_NAMES.join(", ")} to "provider/model-id"`));
103
+ else {
104
+ for (const [tier, ref] of Object.entries(d.model_tiers)) {
105
+ if (!MODEL_TIER_NAMES.includes(tier))
106
+ out.push(issue(`${at}.model_tiers.${tier}`, "not_allowed", `${at}.model_tiers names ${MODEL_TIER_NAMES.join(" and ")} alone`, `Remove ${at}.model_tiers.${tier}.`));
107
+ else if (typeof ref !== "string" || !MODEL_REF.test(ref))
108
+ out.push(issue(`${at}.model_tiers.${tier}`, "bad_format", `${at}.model_tiers.${tier} is "provider/model-id"`));
109
+ }
110
+ }
81
111
  }
82
112
  if (d.harness !== undefined && !HARNESSES.includes(d.harness))
83
113
  out.push(issue(`${at}.harness`, "not_an_option", `${at}.harness is one of ${HARNESSES.join(", ")}`));
@@ -94,8 +124,8 @@ export function definitionIssues(definition, { at = "definition", creating = tru
94
124
  if (d.learning !== undefined) {
95
125
  if (d.workflow !== undefined)
96
126
  out.push(issue(`${at}.learning`, "not_allowed", "A workflow revision does not learn: only an agentic run reflects on its work.", `Remove ${at}.learning.`));
97
- else if (typeof d.learning !== "boolean")
98
- out.push(issue(`${at}.learning`, "wrong_type", `${at}.learning is true or false`));
127
+ else if (typeof d.learning !== "boolean" && d.learning !== "notes")
128
+ out.push(issue(`${at}.learning`, "wrong_type", `${at}.learning is true, false or "notes": true learns notes, skills and workflows, "notes" notes and skills alone`));
99
129
  }
100
130
  // An agentic revision's structured answer: the JSON Schema its final answer's last fenced json block meets, read into a
101
131
  // completed run's result.output (answer-json.ts structuredAnswer). A workflow's output is its workflow's own.
@@ -132,6 +162,13 @@ export function definitionIssues(definition, { at = "definition", creating = tru
132
162
  if (!(typeof d.max_cost_usd === "number" && Number.isFinite(d.max_cost_usd) && d.max_cost_usd >= 0))
133
163
  out.push(issue(`${at}.max_cost_usd`, "wrong_type", `${at}.max_cost_usd is a number of at least 0, in US dollars: above 0 sets the agent's default cap, 0 clears it`));
134
164
  }
165
+ // The server's checkout before each run's first turn: kept by an edit that leaves it out, cleared by `none`.
166
+ if (d.checkout !== undefined) {
167
+ if (d.workflow !== undefined)
168
+ out.push(issue(`${at}.checkout`, "not_allowed", "A workflow revision keeps no checkout: only an agentic run starts in a checkout.", `Remove ${at}.checkout.`));
169
+ else if (!CHECKOUTS.includes(d.checkout))
170
+ out.push(issue(`${at}.checkout`, "not_an_option", `${at}.checkout is one of ${CHECKOUTS.join(", ")}: pull_request checks out the pull request the run's GitHub event names, at its head, in repo/ before the first turn; none clears it`));
171
+ }
135
172
  // The tool calls each conversation of an agentic run may make (tool-budget.ts): above 0 sets the budget, 0 clears it, and
136
173
  // an edit that leaves it out keeps the agent's, as the default cap is kept.
137
174
  if (d.max_tool_calls !== undefined) {
@@ -1,4 +1,4 @@
1
- import type { JsonValue } from "@earendil-works/chord";
1
+ import type { JsonValue } from "@earendil-works/chord/json";
2
2
  import type { TSchema } from "typebox";
3
3
  import { type ToolRegistration } from "@earendil-works/pi-durable";
4
4
  import type { PublicFetchOptions } from "@parcha/pi-browser";
@@ -1,6 +1,7 @@
1
1
  import type { TSchema } from "typebox";
2
- import type { JsonValue } from "@earendil-works/chord";
2
+ import type { JsonValue } from "@earendil-works/chord/json";
3
3
  import { type ToolRegistration } from "@earendil-works/pi-durable";
4
+ import { type SearchModels } from "./hosted-search.js";
4
5
  import { type Extract } from "./web-fetch.js";
5
6
  export declare const WEB_SEARCH_TOOL = "web_search";
6
7
  /** The tools that reach the web, each through the provider its run's plane resolves it to. */
@@ -47,8 +48,12 @@ export declare const searchArgs: (args: Record<string, unknown>) => {
47
48
  };
48
49
  /** `{query, n?}` searched through `parallel` (null: the run holds no key), as a Search. */
49
50
  export declare function webSearch(args: Record<string, unknown>, parallel: Extract | null, signal?: AbortSignal): Promise<Search>;
50
- /** `{query, n?}` searched by the provider the run's plane resolves web_search to, as a Search. */
51
- export declare function searchFor(env: NodeJS.ProcessEnv, args: Record<string, unknown>, signal?: AbortSignal): Promise<Search>;
51
+ /** The run's models a native search goes through, asked when a search runs (the runner's: the session's port, up once
52
+ * the session is open): ToolHost.search, EffectRun.search. */
53
+ export type SearchOn = () => Promise<SearchModels | undefined>;
54
+ /** `{query, n?}` searched by the provider the run's plane resolves web_search to, as a Search. `models`: the run's own
55
+ * models a native search goes through (none: a native search has no model to search on). */
56
+ export declare function searchFor(env: NodeJS.ProcessEnv, args: Record<string, unknown>, signal?: AbortSignal, models?: SearchOn): Promise<Search>;
52
57
  /** The agent's tool: the Search as JSON text. A run whose web_search resolves to Parallel reads its key as the tool is
53
- * made, when the run opens. */
54
- export declare function webSearchTool(env: NodeJS.ProcessEnv): ToolRegistration<TSchema, JsonValue>;
58
+ * made, when the run opens; one that resolves native searches through `models`, the run's own (ToolHost.search). */
59
+ export declare function webSearchTool(env: NodeJS.ProcessEnv, models?: SearchOn): ToolRegistration<TSchema, JsonValue>;
@@ -88,8 +88,9 @@ export async function webSearch(args, parallel, signal) {
88
88
  return { error: error?.name === "TimeoutError" ? "Parallel's search did not answer within 60 s" : `Parallel's search failed: ${error?.message ?? String(error)}` };
89
89
  }
90
90
  }
91
- /** `{query, n?}` searched by the provider the run's plane resolves web_search to, as a Search. */
92
- export async function searchFor(env, args, signal) {
91
+ /** `{query, n?}` searched by the provider the run's plane resolves web_search to, as a Search. `models`: the run's own
92
+ * models a native search goes through (none: a native search has no model to search on). */
93
+ export async function searchFor(env, args, signal, models) {
93
94
  const plane = planeOf(env);
94
95
  if (plane.web_search === "parallel")
95
96
  return webSearch(args, parallelOf(env), signal);
@@ -99,7 +100,7 @@ export async function searchFor(env, args, signal) {
99
100
  if (!query)
100
101
  return { error: "web_search needs a query" };
101
102
  if (plane.web_search === "native")
102
- return hostedSearch(query, n, plane.model, signal);
103
+ return hostedSearch(query, n, plane.model, signal, await models?.());
103
104
  // Under --faux, Exa is the faux module's or none: a test never reaches the network.
104
105
  const faux = await fauxFetch(env, FAUX_EXA_ENV);
105
106
  if (env[FAUX_ENV] && !faux)
@@ -109,8 +110,8 @@ export async function searchFor(env, args, signal) {
109
110
  return "limit" in found ? { error: found.error } : found;
110
111
  }
111
112
  /** The agent's tool: the Search as JSON text. A run whose web_search resolves to Parallel reads its key as the tool is
112
- * made, when the run opens. */
113
- export function webSearchTool(env) {
113
+ * made, when the run opens; one that resolves native searches through `models`, the run's own (ToolHost.search). */
114
+ export function webSearchTool(env, models) {
114
115
  const provider = planeOf(env).web_search;
115
116
  const parallel = provider === "parallel";
116
117
  if (parallel)
@@ -129,7 +130,7 @@ export function webSearchTool(env) {
129
130
  },
130
131
  replay: "safe",
131
132
  execute: async (args, _api, context) => {
132
- const answer = fitSearch(await searchFor(env, args, context?.abortSignal));
133
+ const answer = fitSearch(await searchFor(env, args, context?.abortSignal, models));
133
134
  return forModel(searchText(answer), { details: answer });
134
135
  },
135
136
  });