@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
@@ -0,0 +1,23 @@
1
+ import { type DecisionExchange, type DecisionReceipt } from "@parcha/agentrun-dsl";
2
+ import type { DocumentReader } from "@earendil-works/pi-durable";
3
+ import type { WorkflowInvocation } from "./task.js";
4
+ type Context = WorkflowInvocation["context"];
5
+ /** The interpreter's two decision hooks over one invocation of a workflow task. */
6
+ export type DecisionRecovery = {
7
+ /** The interpreter's `recordDecision`: commits the receipt's row after every row recorded before it, and resolves
8
+ * once that commit is durable; a commit that fails rejects this receipt's call. The task's state is untouched. */
9
+ recordDecision(receipt: DecisionReceipt, exchange: DecisionExchange): Promise<void>;
10
+ /** The interpreter's `recovery.decision`: the receipt rebuilt from the last answered row this run recorded under
11
+ * `id`, or undefined when it recorded none (a request that failed, one recorded without its identity, or one another
12
+ * run recorded, is asked again). */
13
+ decision(id: string): Promise<DecisionReceipt | undefined>;
14
+ };
15
+ /** The decision hooks a durable host gives the interpreter inside `WorkflowTaskHost.run`, over the invocation it is
16
+ * handed (the run's key, the task's runtime and context): `recordDecision` as the interpreter's own, and `decision` as
17
+ * `recovery.decision` beside the driver's recovery hooks. */
18
+ export declare function decisionRecovery(invocation: {
19
+ key: string;
20
+ runtime: Pick<WorkflowInvocation["runtime"], "commit"> & DocumentReader;
21
+ context: Context;
22
+ }): DecisionRecovery;
23
+ export {};
@@ -0,0 +1,80 @@
1
+ // A workflow task's decision receipts, durable in its run's Session: each receipt is a row (decisions.ts) committed
2
+ // through the task's own commit before the interpreter acts on its answers, and a resumed run's request is answered
3
+ // from the row its earlier process committed, so the judge is not asked again and the run decides what it decided.
4
+ // Every run in the Session shares the rows' document, and a receipt's id does not name its run, so each row carries
5
+ // the run's key and a run is answered only from its own rows.
6
+ import { DECISION_RECEIPT_VERSION } from "@parcha/agentrun-dsl";
7
+ import { appendDecision, DECISION_ROW_VERSION, readDecisionsFrom } from "./decisions.js";
8
+ /** What a receipt says of its provider beside its answers, each only when present: who answered, the sources, the
9
+ * questions refused, where each confidence came from, the images it carried and the state the judge saw. A replay gives the run all of it again. */
10
+ const kept = (from) => ({
11
+ ...(from.provider !== undefined ? { provider: from.provider } : {}),
12
+ ...(from.images !== undefined ? { images: from.images } : {}),
13
+ ...(from.cost_basis !== undefined ? { cost_basis: from.cost_basis } : {}),
14
+ ...(from.state !== undefined ? { state: from.state, state_truncated: from.state_truncated === true } : {}),
15
+ ...(from.evidence !== undefined ? { evidence: from.evidence } : {}),
16
+ ...(from.refused !== undefined ? { refused: from.refused } : {}),
17
+ ...(from.confidence_source !== undefined ? { confidence_source: from.confidence_source } : {}),
18
+ });
19
+ /** A receipt as the row the run `key` stores: the receipt's own fields, its identity, and the request's size. */
20
+ function rowOf(receipt, exchange, key) {
21
+ return {
22
+ v: DECISION_ROW_VERSION, at: receipt.at, node: receipt.node, kind: receipt.kind, item: receipt.item, execution_path: receipt.execution_path,
23
+ request_sha256: receipt.request_sha256,
24
+ request_bytes: Buffer.byteLength(JSON.stringify({ state: exchange.request.state, questions: exchange.request.questions })),
25
+ model: receipt.model, questions: receipt.questions, answers: receipt.answers, rule: receipt.rule, action: receipt.action,
26
+ usage: receipt.usage, cost_usd: receipt.cost_usd, latency_ms: receipt.latency_ms,
27
+ // An error the receipt kept cut says so, and the row keeps saying it: a host holds its tail back (serve graph-served.ts).
28
+ ...(receipt.error !== undefined ? { error: receipt.error, ...(receipt.error_truncated === true ? { error_truncated: true } : {}) } : {}),
29
+ status: receipt.status, ...kept(receipt),
30
+ decision_id: receipt.id, request: receipt.request, state_sha256: receipt.state_sha256, run_key: key,
31
+ };
32
+ }
33
+ /** The receipt the run `key`'s last answered row under `id` is: a rule is set only on an answered receipt, and an
34
+ * answered one carries no error. */
35
+ function answeredReceipt(rows, id, key) {
36
+ const row = rows.findLast((stored) => stored.run_key === key && stored.decision_id === id && stored.rule !== null && stored.error === undefined
37
+ && stored.request !== undefined && stored.state_sha256 !== undefined && stored.execution_path !== null);
38
+ if (!row)
39
+ return undefined;
40
+ return {
41
+ v: DECISION_RECEIPT_VERSION, id, at: row.at, node: row.node, kind: row.kind, item: row.item, execution_path: row.execution_path,
42
+ request: row.request, status: "answered", state_sha256: row.state_sha256,
43
+ questions: row.questions, answers: row.answers, rule: row.rule, action: row.action,
44
+ model: row.model, usage: row.usage, cost_usd: row.cost_usd, request_sha256: row.request_sha256, latency_ms: row.latency_ms,
45
+ ...kept(row),
46
+ };
47
+ }
48
+ /** The decision hooks a durable host gives the interpreter inside `WorkflowTaskHost.run`, over the invocation it is
49
+ * handed (the run's key, the task's runtime and context): `recordDecision` as the interpreter's own, and `decision` as
50
+ * `recovery.decision` beside the driver's recovery hooks. */
51
+ export function decisionRecovery(invocation) {
52
+ const { key, runtime, context } = invocation;
53
+ const harness = {
54
+ commit: async (change) => {
55
+ let result;
56
+ await runtime.commit(async (tx) => { result = await change(tx); return undefined; }, context);
57
+ return result;
58
+ },
59
+ // The form the store holds is settled once per invocation, from this reader: the run's open.
60
+ snapshot: ((...args) => runtime.snapshot(...args)),
61
+ };
62
+ // The run's rows as read so far: a resumed process reads the store once, and each later answer reads only the rows after them.
63
+ const known = [];
64
+ let next = 0;
65
+ let chain = Promise.resolve();
66
+ return {
67
+ recordDecision(receipt, exchange) {
68
+ const row = rowOf(receipt, exchange, key);
69
+ const committed = chain.then(() => appendDecision(harness, row, context));
70
+ chain = committed.catch(() => undefined);
71
+ return committed;
72
+ },
73
+ async decision(id) {
74
+ const read = await readDecisionsFrom(harness, next, context);
75
+ known.push(...read.rows);
76
+ next = read.next;
77
+ return answeredReceipt(known, id, key);
78
+ },
79
+ };
80
+ }
@@ -0,0 +1,134 @@
1
+ import type { Context } from "@earendil-works/chord/context";
2
+ import { type DocumentReader, type Harness } from "@earendil-works/pi-durable";
3
+ /** The session document that holds a run's decision rows. */
4
+ export declare const DECISION_RECEIPTS_DOC = "agentrun.decisions";
5
+ /** The stored row's version. */
6
+ export declare const DECISION_ROW_VERSION = 1;
7
+ /** How the answers became the action, with every threshold applied. */
8
+ export type DecisionRowRule =
9
+ /** judge: each question's decoded value (choice, noul at 0.5, rounded score). */
10
+ {
11
+ kind: "judge";
12
+ }
13
+ /** pick: the chosen option names an item by its position, or none. */
14
+ | {
15
+ kind: "pick";
16
+ options: string[];
17
+ none: string | null;
18
+ }
19
+ /** route: the chosen branch, or the unsure branch when the choice's confidence is below `gte`. */
20
+ | {
21
+ kind: "route";
22
+ unsure: {
23
+ gte: number;
24
+ branch: string;
25
+ } | null;
26
+ }
27
+ /** sift: an item is kept when its `keep` measure meets `gte`; every item without a keep rule. */
28
+ | {
29
+ kind: "sift";
30
+ items: number;
31
+ ids: string[];
32
+ keep: {
33
+ id: string;
34
+ measure: "confidence" | "value";
35
+ gte: number;
36
+ } | null;
37
+ }
38
+ /** ask: the predicate holds when p_yes meets `gte`. */
39
+ | {
40
+ kind: "ask";
41
+ gte: number;
42
+ }
43
+ /** verify: a noul question fails when p_yes is below its threshold (null: not judged, an empty field); a failed
44
+ * question the submission holds is doubted, a failed one it lacks is unmet. */
45
+ | {
46
+ kind: "verify";
47
+ thresholds: Record<string, number | null>;
48
+ present: string[];
49
+ };
50
+ /** One stored decision row. */
51
+ export type DecisionRow = {
52
+ v: typeof DECISION_ROW_VERSION;
53
+ at: string;
54
+ node: string;
55
+ kind: "judge" | "pick" | "sift" | "route" | "ask" | "verify";
56
+ item: number | null;
57
+ execution_path: string | null;
58
+ request_sha256: string | null;
59
+ request_bytes: number;
60
+ model: string | null;
61
+ questions: Record<string, unknown>;
62
+ answers: Record<string, unknown>;
63
+ rule: DecisionRowRule | null;
64
+ /** What the run did with the answers; null when the node did not act on them. */
65
+ action: unknown;
66
+ usage: {
67
+ input_tokens: number;
68
+ output_tokens: number;
69
+ } | null;
70
+ cost_usd: number | null;
71
+ latency_ms: number;
72
+ /** The request's error, as its receipt kept it: whole up to 64 KB, a longer one cut there with `error_truncated`. */
73
+ error?: string;
74
+ error_truncated?: boolean;
75
+ /** How the request ended (`answered`, `failed` or `cancelled`); absent on a row written before it was kept. */
76
+ status?: "answered" | "failed" | "cancelled";
77
+ /** The provider that answered, when the host's judge names it or the node pins it. */
78
+ provider?: string;
79
+ /** The sources the provider grounded its answers in, as the receipt has them; absent when it gave none. */
80
+ evidence?: Array<{
81
+ url: string;
82
+ title: string | null;
83
+ excerpts: string[];
84
+ scope: string;
85
+ }>;
86
+ /** The questions whose answer came back as a refusal. */
87
+ refused?: string[];
88
+ /** For each choice and score answer, whether its confidence is the provider's own or was derived. */
89
+ confidence_source?: Record<string, string>;
90
+ /** The images the request carried, by digest (token, reference, SHA-256, type, size), never their bytes. */
91
+ images?: Array<{
92
+ token: string;
93
+ ref: string;
94
+ sha256: string | null;
95
+ mime: string | null;
96
+ bytes: number | null;
97
+ }>;
98
+ /** The state the judge saw, or past 64 KB of JSON the first 64 KB of its text, with `state_truncated` saying which. */
99
+ state?: unknown;
100
+ state_truncated?: boolean;
101
+ /** The request's spend is on its frozen driver's state, so a cost fold counts it there, not here. */
102
+ driver_spend?: true;
103
+ /** The receipt's id, its place among its node's requests, the digest of the state it was asked with, and the key of
104
+ * the workflow run that asked it. A row that carries all four is the whole receipt again, so that run, resumed, can be
105
+ * answered from it (`decisionRecovery`); another run in the same Session never is. */
106
+ decision_id?: string;
107
+ request?: {
108
+ index: number;
109
+ count: number;
110
+ items?: number[];
111
+ };
112
+ state_sha256?: string;
113
+ run_key?: string;
114
+ /** The id its host admitted the request under before sending it, when the host admits its requests so that one the run
115
+ * stopped before it answered is still counted. The row settles that admission in the row's own commit: a cost fold
116
+ * counts an admission no row names, and never one a row names. */
117
+ admission?: string;
118
+ /** How the cost was reached (reported by the provider, estimated by the host, unknown), when the judge said. */
119
+ cost_basis?: "reported" | "estimate" | "unknown";
120
+ };
121
+ /** How many rows the keyed form holds: its next key. A few bytes, so rewriting it at every commit costs the same at every count. */
122
+ export declare const DECISION_COUNT_DOC = "agentrun.decisions.count";
123
+ /** A keyed row's key: its place, zero-padded so the keys sort in commit order. */
124
+ export declare const decisionKey: (place: number) => string;
125
+ /** Commit one row, appended after every row committed before it. */
126
+ export declare function appendDecision(harness: Pick<Harness, "commit">, row: DecisionRow, context?: Context): Promise<void>;
127
+ /** Every row the run's Session holds, in commit order. */
128
+ export declare function readDecisions(read: DocumentReader, context?: Context): Promise<DecisionRow[]>;
129
+ /** The rows from place `from` on and the place after the last: only the new ones are read, so a reader that keeps `next`
130
+ * reads each row once. */
131
+ export declare function readDecisionsFrom(read: Pick<DocumentReader, "snapshot">, from: number, context?: Context): Promise<{
132
+ rows: DecisionRow[];
133
+ next: number;
134
+ }>;
@@ -0,0 +1,46 @@
1
+ // A run's decision rows as pi-durable stores them, one row per typed question the run asked, in commit order: the KEYED
2
+ // family, one document of kind `agentrun.decisions` per row, written once. The row is a stored format (version 1); it
3
+ // does not change with the interpreter: a host maps `@parcha/agentrun-dsl`'s `DecisionReceipt` to a row, with the facts only
4
+ // the host has (the request's size and metering, whether the node acted on the answers), and this module stores and reads
5
+ // rows without looking inside them.
6
+ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
7
+ import { defineDoc, defineDocFamily } from "@earendil-works/pi-durable";
8
+ /** The session document that holds a run's decision rows. */
9
+ export const DECISION_RECEIPTS_DOC = "agentrun.decisions";
10
+ /** The stored row's version. */
11
+ export const DECISION_ROW_VERSION = 1;
12
+ /** The keyed form: one document per row, of the same kind, keyed by the row's place in the run's rows (`keyOf`), written once. The
13
+ * document's value is exactly the row. */
14
+ const DecisionRowDoc = defineDocFamily({ kind: DECISION_RECEIPTS_DOC, version: 1, scope: "session", family: true, initial: () => ({}), checkpointWhen: () => false });
15
+ /** How many rows the keyed form holds: its next key. A few bytes, so rewriting it at every commit costs the same at every count. */
16
+ export const DECISION_COUNT_DOC = "agentrun.decisions.count";
17
+ const DecisionCountDoc = defineDoc({ kind: DECISION_COUNT_DOC, version: 1, scope: "session", initial: () => ({ count: 0 }), checkpointWhen: () => false });
18
+ /** A keyed row's key: its place, zero-padded so the keys sort in commit order. */
19
+ export const decisionKey = (place) => String(place).padStart(8, "0");
20
+ /** Commit one row, appended after every row committed before it. */
21
+ export async function appendDecision(harness, row, context = BACKGROUND_CONTEXT) {
22
+ const stored = JSON.parse(JSON.stringify(row));
23
+ await harness.commit(async (tx) => {
24
+ const count = await tx.doc(DecisionCountDoc);
25
+ const place = count.count;
26
+ count.count = place + 1;
27
+ Object.assign(await tx.doc(DecisionRowDoc, decisionKey(place), null), stored);
28
+ }, context);
29
+ }
30
+ /** Every row the run's Session holds, in commit order. */
31
+ export async function readDecisions(read, context = BACKGROUND_CONTEXT) {
32
+ return (await readDecisionsFrom(read, 0, context)).rows;
33
+ }
34
+ /** The rows from place `from` on and the place after the last: only the new ones are read, so a reader that keeps `next`
35
+ * reads each row once. */
36
+ export async function readDecisionsFrom(read, from, context = BACKGROUND_CONTEXT) {
37
+ const total = (await read.snapshot(DecisionCountDoc, context))?.count ?? 0;
38
+ const rows = [];
39
+ for (let at = from; at < total; at += 64) {
40
+ const batch = await Promise.all(Array.from({ length: Math.min(64, total - at) }, (_, i) => read.snapshot(DecisionRowDoc, decisionKey(at + i), context)));
41
+ for (const doc of batch)
42
+ if (doc !== undefined)
43
+ rows.push(doc);
44
+ }
45
+ return { rows, next: total };
46
+ }
@@ -0,0 +1,5 @@
1
+ import { type PiRunner } from './runner.js';
2
+ import type { PiHostContext, PiHostRunnerOptions, PiSessionFactory } from './types.js';
3
+ export declare const PI_MODEL_SETUP_MESSAGE = "AgentRun requires an active Pi model. Use /login to connect a provider, then /model to select it. Try /agentrun demo without model access.";
4
+ export declare function createPiHostSessionFactory(context: PiHostContext): PiSessionFactory;
5
+ export declare function createPiHostRunner(context: PiHostContext, options?: PiHostRunnerOptions): PiRunner;
@@ -0,0 +1,85 @@
1
+ import { Agent } from '@earendil-works/pi-agent-core';
2
+ import { SUBMIT_TOOL } from './host-tools.js';
3
+ import { createPiRunner } from './runner.js';
4
+ import { workflowToolContext } from './tool-context.js';
5
+ import { OperatorError } from './operator-error.js';
6
+ export const PI_MODEL_SETUP_MESSAGE = 'AgentRun requires an active Pi model. Use /login to connect a provider, then /model to select it. Try /agentrun demo without model access.';
7
+ function selectedModel(context) {
8
+ const model = context.model;
9
+ if (!model)
10
+ throw new OperatorError(PI_MODEL_SETUP_MESSAGE);
11
+ if (!context.modelRegistry || typeof context.modelRegistry.streamSimple !== 'function' || typeof context.modelRegistry.getAll !== 'function') {
12
+ throw new OperatorError('AgentRun requires the host public model registry');
13
+ }
14
+ if (!context.modelRegistry.getAll().some(known => known.id === model.id && known.provider === model.provider && known.api === model.api)) {
15
+ throw new OperatorError(PI_MODEL_SETUP_MESSAGE);
16
+ }
17
+ return model;
18
+ }
19
+ export function createPiHostSessionFactory(context) {
20
+ const model = selectedModel(context);
21
+ const stream = context.modelRegistry.streamSimple.bind(context.modelRegistry);
22
+ const toolContext = workflowToolContext(context);
23
+ return async (options) => {
24
+ if (options.model !== model)
25
+ throw new Error('The child session must use the captured active Pi model');
26
+ let delivered = false, turns = 0;
27
+ const allowed = new Set(options.tools);
28
+ const tools = options.customTools.filter(tool => allowed.has(tool.name)).map(tool => ({
29
+ name: tool.name, label: tool.label, description: tool.description,
30
+ parameters: tool.parameters,
31
+ async execute(id, args, signal, onUpdate) {
32
+ const result = await tool.execute(id, args, signal, onUpdate, toolContext);
33
+ if (tool.name === SUBMIT_TOOL && result.details?.accepted === true)
34
+ delivered = true;
35
+ return result;
36
+ },
37
+ }));
38
+ const agent = new Agent({
39
+ initialState: { model, thinkingLevel: options.thinkingLevel, systemPrompt: options.resourceLoader.getSystemPrompt() ?? '', tools },
40
+ streamFn: (_model, transcript, streamOptions) => stream(model, transcript, streamOptions),
41
+ toolExecution: 'sequential',
42
+ finishTurn: () => {
43
+ turns++;
44
+ if (delivered || (options.maxTurns !== undefined && turns >= options.maxTurns))
45
+ return { action: 'end' };
46
+ },
47
+ });
48
+ let disposed = false;
49
+ const unsubscribers = new Set();
50
+ return { session: {
51
+ async prompt(text) {
52
+ if (disposed)
53
+ throw new Error('Pi host child session is disposed');
54
+ await agent.prompt(text);
55
+ },
56
+ subscribe(listener) {
57
+ if (disposed)
58
+ throw new Error('Pi host child session is disposed');
59
+ const unsubscribe = agent.subscribe(event => { listener(event); });
60
+ unsubscribers.add(unsubscribe);
61
+ return () => { unsubscribe(); unsubscribers.delete(unsubscribe); };
62
+ },
63
+ async abort() { agent.abort(); },
64
+ dispose() {
65
+ if (disposed)
66
+ return;
67
+ disposed = true;
68
+ agent.abort();
69
+ agent.clearAllQueues();
70
+ for (const unsubscribe of unsubscribers)
71
+ unsubscribe();
72
+ unsubscribers.clear();
73
+ },
74
+ } };
75
+ };
76
+ }
77
+ export function createPiHostRunner(context, options = {}) {
78
+ const model = selectedModel(context);
79
+ // The host session's thinking level is not a node's: a node that names none thinks at medium, unless the caller
80
+ // passes its own `thinkingLevel`.
81
+ return createPiRunner({
82
+ ...options, model, cwd: options.cwd ?? context.cwd,
83
+ sessionFactory: createPiHostSessionFactory(context),
84
+ });
85
+ }
@@ -0,0 +1,3 @@
1
+ /** The tool a workflow node delivers its result with (the runner's and the durable record tool's), so no host tool may
2
+ * take its name. */
3
+ export declare const SUBMIT_TOOL = "submit";
@@ -0,0 +1,3 @@
1
+ /** The tool a workflow node delivers its result with (the runner's and the durable record tool's), so no host tool may
2
+ * take its name. */
3
+ export const SUBMIT_TOOL = 'submit';
@@ -0,0 +1,113 @@
1
+ import type { Context } from "@earendil-works/chord/context";
2
+ import type { JsonValue } from "@earendil-works/chord/json";
3
+ import { type AgentChange, type ConversationId, type Extension, type Tx } from "@earendil-works/pi-durable";
4
+ import type { WorkflowDeps } from "@parcha/agentrun-dsl";
5
+ import { type RecoveryNodeParams } from "@parcha/agentrun-dsl/recovery";
6
+ import { type NodeScope } from "./node.js";
7
+ import { type Disagreement, type RecordContract } from "./record.js";
8
+ import { type RecordToolOptions } from "./record-tool.js";
9
+ /** A node's configuration: what its conversation's prompt and `submit` tool are drawn from. `input` is the node's
10
+ * prompt state, the JSON object its user text was stringified from, for a reader that shows what the node was given;
11
+ * it is absent when that text is not a JSON object, and in a document an older build wrote. A fork of the conversation
12
+ * starts without it, as with the record: the runner never attaches a fork, so a fork is no node and waits for nothing. */
13
+ export declare const NodeDoc: import("@earendil-works/pi-durable").ConversationDocToken<{
14
+ system: string;
15
+ label: string;
16
+ schema: JsonValue | null;
17
+ fileKey: string | null;
18
+ input?: {
19
+ [key: string]: JsonValue;
20
+ };
21
+ }>;
22
+ /** A node as the host is asked about it: the interpreter's request, and the attempt it runs as, with the sessions of
23
+ * the attempts before it (a host that refuses to repeat a call an earlier attempt left unknown reads them). */
24
+ export type NodeRequest = Omit<Parameters<NonNullable<WorkflowDeps["runNode"]>>[0], "review" | "signal"> & {
25
+ sessionId: string;
26
+ attempt: number;
27
+ earlierSessionIds: readonly string[];
28
+ };
29
+ /** What a host says of a node's record beside its schema. */
30
+ export type NodeRecord = Pick<RecordContract, "contracts" | "checks"> & {
31
+ /** What the model is told it delivers (default: `the <label> record`). */
32
+ label?: string;
33
+ /** The host's own delivery instructions, said with the contract that ends the node's task. */
34
+ instructions?: string;
35
+ /** The record may be delivered as a JSON file the node wrote in `workspace`, named under `key`. */
36
+ file?: {
37
+ key: string;
38
+ workspace: string;
39
+ };
40
+ };
41
+ export type NodeHost = {
42
+ /** The agent a node's conversation runs with: its model, thinking level, working directory and the host's own
43
+ * extensions and tools. The runner adds its extension and `submit` where the host did not place them. The node's
44
+ * own thinking level outranks the host's; when neither names one, the node thinks at medium (never at the level its
45
+ * conversation would copy from its owner's, and never off). */
46
+ agent(node: NodeRequest): AgentChange | Promise<AgentChange>;
47
+ /** Duty text for a node's system prompt, after the interpreter's. `offered` names the tools the agent lists. */
48
+ stance?(node: NodeRequest, offered: {
49
+ tools: readonly string[];
50
+ }): string | undefined;
51
+ record?(node: NodeRequest): NodeRecord | Promise<NodeRecord>;
52
+ /** A second reading of a node's record, before the node's own verify clause: what it disagrees with. */
53
+ verify?(record: unknown, node: NodeRequest, context: {
54
+ round: boolean;
55
+ }): Disagreement[] | Promise<Disagreement[]>;
56
+ /** Called, and awaited, when a node's conversation exists and before any request of this process reaches a model:
57
+ * the host attaches its observers to that conversation. A throw fails the node's call and releases nothing: what
58
+ * pi resumed of the node waits for the attempt's next entry, or ends with the Harness's close. */
59
+ onNodeOpen?(node: NodeRequest & {
60
+ conversationId: ConversationId;
61
+ resumed: boolean;
62
+ }): void | Promise<void>;
63
+ /** Written in the commit that creates a node's conversation, after the runner's own document: the documents the
64
+ * host's extensions read for it (a plane's configuration). */
65
+ init?(node: NodeRequest, tx: Tx, conversationId: ConversationId): void | Promise<void>;
66
+ /** Delivery attempts a node gets (default `DELIVERY_ATTEMPTS`). */
67
+ maxAttempts?: number;
68
+ /** The host's part in every `submit` call: its rows, and which errors are its own failure. The one delivery it may
69
+ * be told before `onNodeOpen` is `already`, the answer of a call that a process died inside after its commit. */
70
+ submit?: Pick<RecordToolOptions, "onDelivery" | "fatal" | "onFatal" | "fatalText">;
71
+ /** The digest an attempt is bound by. Absent, one of the node's label, path, kind, item and attempt. */
72
+ digest?(node: NodeRequest): string;
73
+ };
74
+ /** A node that delivered no record. `final` says a second attempt would spend the same again: the model did not
75
+ * answer, or the delivery attempts are spent. `unanswered` is pi's own account of a submission the model did not
76
+ * answer: its reason (`failed`, `aborted`, ...) and detail. */
77
+ export declare class NodeFailure extends Error {
78
+ readonly node: string;
79
+ readonly final: boolean;
80
+ readonly executionPath?: string | undefined;
81
+ readonly unanswered?: {
82
+ reason: string;
83
+ detail?: JsonValue;
84
+ } | undefined;
85
+ readonly code = "NODE_NOT_DELIVERED";
86
+ /** The item a map that collects its items' failures ends on this (`isItemFailure`): the node's delivery attempts are
87
+ * spent, or its model will not answer (`model_error`, as a provider's content filter). Never an abort, a stale or
88
+ * faulted run, a missing model, or a schema no record can satisfy. */
89
+ readonly itemFailure: boolean;
90
+ constructor(message: string, node: string, final: boolean, executionPath?: string | undefined, unanswered?: {
91
+ reason: string;
92
+ detail?: JsonValue;
93
+ } | undefined, itemFailure?: boolean);
94
+ }
95
+ /** The node runner over a host. Install `extension` in the registry before the Harness opens; `on` binds the runner
96
+ * to where its conversations live (`taskScope`, `hostScope`). */
97
+ export declare function nodeRunner(host: NodeHost, options?: {
98
+ name?: string;
99
+ }): {
100
+ extension: Extension;
101
+ /** The extension a conversation an older build opened still selects, under that build's name for it: the system
102
+ * text that build kept as the `task` section, and this runner's `submit`. Each of its requests and calls waits for
103
+ * the runner to reach the node, which then moves the conversation to `extension`. Install one for each node an
104
+ * older build left unfinished, before the Harness resumes. */
105
+ legacy(entry: {
106
+ extension: string;
107
+ system: string | null;
108
+ }): Extension;
109
+ on(scope: NodeScope, context: Context): {
110
+ runNode(params: RecoveryNodeParams): Promise<unknown>;
111
+ closeStepSession(sessionId: string): Promise<void>;
112
+ };
113
+ };