@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
@@ -353,6 +353,13 @@ export function learnedStatus(text) {
353
353
  const status = front.get("status") ?? "active";
354
354
  return status === "active" || status === "pending" ? status : "retired";
355
355
  }
356
+ /** Whether `text` reads retired (learnedStatus) only because it can't be read: its front matter reads no way, its status
357
+ * is not one plain line, or its status is none the host writes. No one retired it: a view says the host could not read
358
+ * it, never that a run or a person retired it. */
359
+ export function unclearFront(text) {
360
+ const front = frontMatter(text);
361
+ return !front || !statusOnOneLine(text) || !["active", "pending", "retired"].includes(front.get("status") ?? "active");
362
+ }
356
363
  /** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
357
364
  * status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
358
365
  * them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
@@ -678,9 +685,52 @@ const toolingNodes = (dsl, doc) => dsl.inspectWorkflow(doc).nodes.flatMap((node)
678
685
  /** What a learned draft whose output names no path is refused with. */
679
686
  export const LEARNED_OUTPUT_PATH = "its output names no path: a learned workflow's output is the value at output.path";
680
687
  /** What a learned workflow is refused with when a node needs more than its runner gives the DSL (learned-workflow.ts:
681
- * runNode and runEffect alone): a judge, pick or sift node, a route by question, a verify or an ask needs a decision
682
- * provider (runJudge) a run is not given. Refused at learn time and before a call runs any node, never after. */
683
- export const LEARNED_NODES = "a learned workflow runs model and tool-call nodes";
688
+ * runNode, runEffect, and runJudge only when the run has decision providers): a judge, pick or sift node, a route by
689
+ * question, a verify or an ask on a run with none. Refused at learn time and before a call runs any node, never after. */
690
+ export const LEARNED_NODES = "a learned workflow runs model and tool-call nodes, and decision nodes on a run with decision providers";
691
+ /** The providers a draft's decision node may name on this run, by id, as the check reads them (unrunnableNodes: the run's
692
+ * providers; gatedDecisions: deny alone refuses one). None when the run has no `decisions`, so a decision node is
693
+ * refused (LEARNED_NODES): the one place the rule is read, for the check and for what the reflect prompt allows. */
694
+ export const draftDecisionProviders = (decisions) => decisions ? Object.keys(decisions.providers).filter((id) => !Object.hasOwn(decisions.gated ?? {}, id) || decisions.gated[id] !== "deny") : [];
695
+ /** Each decision a draft asks, by the node that asks it (the DSL's inspection lists each node and its pointer, a composed
696
+ * workflow's inner ones too): its kind, its pointer and its provider's id, the one it names or else `fallback`, the
697
+ * run's default. A judge, pick or sift node; a route by question (not by value); a loop's or an escalate's ask
698
+ * predicate; a model node's verify (asked of the default). */
699
+ export function decisionsAsked(dsl, doc, fallback) {
700
+ return dsl.inspectWorkflow(doc).nodes.flatMap((node) => {
701
+ const fields = at(doc, node.path) ?? {};
702
+ const named = (choice) => {
703
+ const provider = choice?.provider;
704
+ return typeof provider === "string" ? provider : fallback;
705
+ };
706
+ const asked = (choice) => [{ kind: node.kind, path: node.path, provider: named(choice) }];
707
+ if (node.kind === "judge" || node.kind === "pick" || node.kind === "sift")
708
+ return asked(fields);
709
+ if (node.kind === "route" && typeof fields.valuePath !== "string")
710
+ return asked(fields);
711
+ if (node.kind === "loop" && fields.until?.predicate === "ask")
712
+ return asked(fields.until);
713
+ if (node.kind === "escalate" && fields.when?.predicate === "ask")
714
+ return asked(fields.when);
715
+ if (fields.verify && typeof fields.verify === "object")
716
+ return [{ kind: node.kind, path: node.path, provider: fallback }];
717
+ return [];
718
+ });
719
+ }
720
+ /** What a decision node asking `provider` is refused with when the run's gate denies it, worded as a call node's tool is
721
+ * (gatedNodes), with the node's place. */
722
+ export const deniedDecisionWords = (provider, from, kind, path) => `This workflow's decision node asks ${provider}, which is set to deny ${denyPlace(from)}. (the ${kind} node at ${path})`;
723
+ /** A draft's decision nodes whose provider the run's gate denies (`decisions.gated`): deny alone refuses, as the runner
724
+ * hands a claim a provider's keys while its gate's policy is not deny (a provider is a settings key that is allow or
725
+ * deny; a gate that reads no setting of it answers ask, which refuses nothing here). */
726
+ const gatedDecisions = (dsl, doc, decisions) => {
727
+ if (!decisions?.gated)
728
+ return [];
729
+ return decisionsAsked(dsl, doc, decisions.default).flatMap(({ kind, path, provider }) => {
730
+ const setting = Object.hasOwn(decisions.gated, provider) ? decisions.gated[provider] : undefined;
731
+ return setting === "deny" ? [{ rule: "workflow", detail: deniedDecisionWords(provider, decisions.deniedBy?.[provider], kind, path) }] : [];
732
+ });
733
+ };
684
734
  const denyPlace = (from = "server") => (from === "agent" ? "for this agent" : from === "default" ? "by default" : "on this server");
685
735
  /** A draft's call nodes that call a tool in `gated` (by name, what the gate holds it to: ask or deny), a composed
686
736
  * workflow node's inner ones too (the DSL's inspection lists them, by their pointer under it): the run would park on it
@@ -806,9 +856,12 @@ const longNodes = (dsl, doc) => dsl.inspectWorkflow(doc).nodes.flatMap((node) =>
806
856
  });
807
857
  /** The node the learned runner cannot run, as the DSL's own check says it (assertWorkflowCapabilities, which runWorkflow
808
858
  * makes before any node runs) with the runner's deps: none when it can run every one. */
809
- const unrunnableNodes = (dsl, doc) => {
859
+ const unrunnableNodes = (dsl, doc, decisions) => {
810
860
  const workflow = dsl.desugarWorkflow(doc);
811
- const runner = { runNode: async () => ({}), runEffect: async () => ({}) };
861
+ // With the run's decision providers, a decision node is runnable when its provider is one of them and answers what it
862
+ // asks (the DSL's checkDecisionProviders): the same registry the call's judge is built on.
863
+ const judging = decisions ? { runJudge: async () => ({}), decisionProviders: { providers: decisions.providers, default: decisions.default } } : {};
864
+ const runner = { runNode: async () => ({}), runEffect: async () => ({}), ...judging };
812
865
  try {
813
866
  dsl.assertWorkflowCapabilities(workflow.root, runner, workflow);
814
867
  return [];
@@ -821,7 +874,7 @@ const issuesOf = (dsl, doc, tools) => {
821
874
  const valid = dsl.validateWorkflow(doc, { executeCode: false, ...(tools ? { tools } : {}) });
822
875
  return valid.ok ? [] : valid.issues;
823
876
  };
824
- export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}, ask) {
877
+ export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}, ask, decisions) {
825
878
  let doc;
826
879
  try {
827
880
  doc = JSON.parse(text);
@@ -837,7 +890,7 @@ export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}, ask)
837
890
  return issues.slice(0, 5).map((issue) => ({ rule: "workflow", detail: `the workflow DSL refuses it: ${issue.code} at ${issue.path || "/"}: ${issue.message.slice(0, 200)}` }));
838
891
  let out;
839
892
  try {
840
- out = [...toolingNodes(dsl, doc), ...executableNodes(dsl, doc), ...unrunnableNodes(dsl, doc), ...longNodes(dsl, doc), ...gatedNodes(dsl, doc, gated, deniedBy), ...[...synthesisProblems(doc, dsl), ...loopProblems(doc)].map((detail) => ({ rule: "workflow", detail }))];
893
+ out = [...toolingNodes(dsl, doc), ...executableNodes(dsl, doc), ...unrunnableNodes(dsl, doc, decisions), ...longNodes(dsl, doc), ...gatedNodes(dsl, doc, gated, deniedBy), ...gatedDecisions(dsl, doc, decisions), ...[...synthesisProblems(doc, dsl), ...loopProblems(doc)].map((detail) => ({ rule: "workflow", detail }))];
841
894
  // A learned workflow answers the value at its output's path: one that names none would answer its whole state, which
842
895
  // fails its output schema when the call ends, after every node spent.
843
896
  const path = doc?.output?.path;
@@ -4,11 +4,15 @@ export declare const LEARNED_NODES = "agentrun.learned_nodes";
4
4
  /** The most nodes a call keeps: a map over a long list runs its body once per item. */
5
5
  export declare const LEARNED_NODES_MAX = 64;
6
6
  /** One node of a learned workflow's run, as the DSL ended it (its `node.end` event): its label, its kind, how it ended
7
- * (`ok`, `failed`, `escalated`) and how long it took. Never why it failed: the DSL cuts that text at 300 characters,
8
- * which can leave the start of a secret the run's cut no longer recognizes, so none of it is kept. */
7
+ * (`ok`, `failed`, `escalated`) and how long it took; a model node also the model it ran on (`model`, as the run's route
8
+ * names it) and the tier it named (`tier`, absent for none). Never why it failed: the DSL cuts that text at 300
9
+ * characters, which can leave the start of a secret the run's cut no longer recognizes, so none of it is kept. A call
10
+ * node has no model. */
9
11
  export type LearnedNode = {
10
12
  readonly label: string;
11
13
  readonly kind: string;
12
14
  readonly status: string;
13
15
  readonly duration_ms: number;
16
+ readonly model?: string;
17
+ readonly tier?: string;
14
18
  };
@@ -6,6 +6,11 @@ import { type Ledger } from "./paid-calls.js";
6
6
  import type { Plane } from "./tool-plane.js";
7
7
  import { type SettingFrom } from "./tool-gate.js";
8
8
  import type { Complete } from "./llm.js";
9
+ import type { SearchOn } from "./web-search.js";
10
+ import type { Workspace } from "./workspace/workspace.js";
11
+ import type { DecisionProvider } from "@parcha/agentrun-dsl";
12
+ import type { Refusal } from "@parcha/agentrun-kernel";
13
+ import type { RunDecisions } from "@parcha/agentrun-kernel/kernel/cap";
9
14
  /** What a learned_workflow call's approval card says of its MCP calls' arguments: the workflow decides them as it runs. */
10
15
  export declare const LEARNED_MCP_ARGUMENTS = "decided by the workflow while it runs, from its input and its earlier steps";
11
16
  /** What a learned_workflow call's card shows of the MCP tools set to ask that the workflow can call: that their arguments
@@ -27,11 +32,12 @@ export declare const learnedApprovedTools: (card: Readonly<Record<string, unknow
27
32
  * one that does not read. The run's gate asks about them before the workflow's call runs (adapter-run-spec.ts). */
28
33
  export declare function learnedMcpTools(workflow: string): Promise<string[]>;
29
34
  export declare const LEARNED_WORKFLOW_TOOL = "learned_workflow";
30
- /** One line of a learned workflow's output for its row: an object's fields as `name value`, each value whole or, when
31
- * longer than VALUE_MAX, only as its size, and whole fields only until LINE_MAX. Nothing is ever cut inside a value:
32
- * the timeline redacts the line as it says it (its summary's words), and its redactor matches a held value only whole,
33
- * so a cut value could leave a prefix it would not find. Newlines are flattened, so the one line it keeps holds every
34
- * field. An output already cut for the model (learnedText) says so. */
35
+ /** One line of a learned workflow's output for its row: an object's fields as `name value`, and a text output (learnedOutput
36
+ * hands one back as it is, #2412) its lines, each value or line whole or, when longer than VALUE_MAX, only as its size,
37
+ * and whole ones only until LINE_MAX. Nothing is ever cut inside a value or a line: the timeline redacts the line as it
38
+ * says it (its summary's words), and its redactor matches a held value only whole, so a cut one could leave a prefix it
39
+ * would not find. Newlines are flattened, so the one line it keeps holds every part. An output already cut for the
40
+ * model (learnedText) says so. */
35
41
  export declare function outputLine(text: string): string | undefined;
36
42
  /** The models a learned workflow's model nodes run on, as pi-ai's: on pi the run's own (capped and marked: app.ts), on
37
43
  * another harness the session's port (port-models.ts). */
@@ -54,8 +60,15 @@ export type LearnedWorkflowRun = {
54
60
  models: RunModels;
55
61
  /** The run's model a model node of `tier` runs on: the tier's, else the run's own. */
56
62
  modelOf(tier: string | undefined): ModelRef | undefined;
63
+ /** The session's model as a person reads it, the id the run's route names it by: what a node's trace says it ran on
64
+ * (its `model`) when modelOf answers with the session's own port (PORT_PROVIDER), whose model id names no model. A
65
+ * ref of another provider (a tier's own model) is named by its model id. */
66
+ modelName?(tier: string | undefined): string | undefined;
57
67
  /** The `llm` tool's completion, for a call node that names it. */
58
68
  complete?: Complete;
69
+ /** The run's models a call node's native web_search goes through (EffectRun.search): on the runner, the session's
70
+ * port. */
71
+ search?: SearchOn;
59
72
  /** The run's gate's permission of a tool now (tool-gate.ts RunGate policy): a call node's tool set to ask or deny is
60
73
  * refused before any node runs, and asked again as each call node runs, a composed workflow's inner ones too, so one
61
74
  * set to either since the call began is refused there, never run. Required: a learned workflow never runs a tool
@@ -68,6 +81,22 @@ export type LearnedWorkflowRun = {
68
81
  * each call node runs, before `policy` is asked: a tool set to deny since the call began is then refused. None: the
69
82
  * gate reads its settings live (main's process). */
70
83
  refresh?: () => Promise<void>;
84
+ /** The run's own Workspace (on the runner: its local folder in Mode 1, its folder on the run's disk in Mode 2), which
85
+ * a decision node's images are read through. Absent: the local folder at `work`. */
86
+ workspace?: Workspace;
87
+ /** The run's decisions (LS-07): its decision providers (decisions.ts decisionProvidersIn over the run's keys) and the
88
+ * one a node that names none is asked of; `book`, the run's decisions on its one cap (the adapter loop's
89
+ * ledger.decisions: DECISION_SESSION); `pause`, the run's pause on a refusal of that cap (ledger.pause), so its next
90
+ * request is refused in the cap's words and the run parks there. None: a decision node is refused before any node
91
+ * runs. */
92
+ decisions?: {
93
+ readonly providers: {
94
+ readonly providers: Readonly<Record<string, DecisionProvider>>;
95
+ readonly default: string;
96
+ };
97
+ readonly book: RunDecisions;
98
+ readonly pause?: (refusal: Refusal) => Promise<void>;
99
+ };
71
100
  /** The run's MCP tools by catalog name (`mcp:<server>/<tool>`): those the claim's pin holds, which its revision grants.
72
101
  * A call node may name one of these; it runs through the run's own MCP, as the loop wrapped it (host-calls.ts). */
73
102
  mcpTools?: readonly string[];
@@ -80,7 +109,7 @@ export type LearnedWorkflowRun = {
80
109
  /** The most characters of a learned workflow's output its answer holds, monid's bound (monid.ts CLIP): within the
81
110
  * host's result bound, which each CLI is told to pass whole (host-bounds.test). */
82
111
  export declare const LEARNED_CLIP = 60000;
83
- /** `text`, a learned workflow's output as JSON, cut at LEARNED_CLIP characters (never inside a surrogate pair), saying
112
+ /** `text`, a learned workflow's output as its tool hands it back (learnedOutput), cut at LEARNED_CLIP characters (never inside a surrogate pair), saying
84
113
  * so. */
85
114
  export declare function learnedText(text: string): string;
86
115
  /** What a learned workflow's model node is refused with when it names a tool: it runs in a session of its own here.
@@ -88,12 +117,17 @@ export declare function learnedText(text: string): string;
88
117
  export declare const NODE_TOOLS_REFUSED = "a learned workflow's model node runs without tools here";
89
118
  /** The tool's description, sent with every model request of the run, so it holds what a model needs to call it right and
90
119
  * no more: one line of what the tool does (one call, by name, a JSON input with the listed fields, `*` marking a required
91
- * one; what it answers), then each workflow on a line of its own (workflowLine): its name, its input's fields and the
92
- * line its README says what it does with. */
120
+ * one; what it answers: a text output as it is, to reply with unchanged, since a model handed it otherwise writes its own
121
+ * reply around it and a format the workflow's last node wrote is lost, #2412), then each workflow on a line of its own
122
+ * (workflowLine): its name, its input's fields and the line its README says what it does with. */
93
123
  export declare const learnedWorkflowDescription: (workflows: readonly LearnedWorkflow[]) => string;
124
+ /** A learned workflow's output as its tool hands it back: its text when it is text, a string or an object of one string
125
+ * field (a node's record of one field, as a last node that writes the answer gives it), so the lines its last node wrote
126
+ * reach the model as lines; else JSON. */
127
+ export declare function learnedOutput(output: unknown): string;
94
128
  /** The run's `learned_workflow` tool over `run.workflows`. */
95
129
  export declare function learnedWorkflowTool(run: LearnedWorkflowRun): ToolRegistration;
96
- /** `flow` run on `input` for `run`: its output as JSON, or why it did not run, and each of its nodes that ran (at most
130
+ /** `flow` run on `input` for `run`: its output as its tool hands it back (learnedOutput), or why it did not run, and each of its nodes that ran (at most
97
131
  * LEARNED_NODES_MAX), none for one refused before any node ran. Never throws, but on an abort. `ledger`: the tool call's,
98
132
  * which each call node's paid requests are booked under, as a call of its own within it. `nodes`: where each node is
99
133
  * added as it ends, the caller's to keep when the call is aborted (and so throws) part way. */
@@ -6,12 +6,19 @@
6
6
  // unavailable, a model node that names any tool, a code node or a shell or executor call is refused before any node
7
7
  // runs, never after earlier ones spent), then runs it with the workflow DSL's runWorkflow:
8
8
  // - a model node (agent, decide, extract, report) on the run's model of its tier, else the run's own model (the one
9
- // model the run was made with and handed the key of: app.ts), in a fresh session of its own (agentrun-pi's host
10
- // runner), with no tool of its own;
9
+ // model the run was made with and handed the key of: app.ts), in a fresh session of its own (the host
10
+ // runner, workflow/host-session.ts), with no tool of its own;
11
11
  // - a call node `via: "tool"` on the tool table's effect, as a workflow revision's (app.ts), for a tool the agent has,
12
12
  // its paid requests booked under the tool's call (paid-calls.ts), each node's under a call of its own; web_search
13
13
  // where it resolves native on the provider's hosted search through the run's models (hosted-search.ts), on a harness
14
14
  // whose own search it is too (harness-app.ts gives that harness no host tool of the name).
15
+ // - a decision node (judge, pick, sift, a route by question, an ask predicate, a verify: LS-07), on a run handed its
16
+ // decisions (`run.decisions`: its decision providers on its own keys, and the adapter loop's ledger.decisions on
17
+ // the run's one cap), asked of the provider it names, else the run's default, held to the run's gate under that
18
+ // provider's bare id (tool-plane.ts DECISION_PROVIDER_KEYS: allow or deny), refused only on deny; each admitted on the run's cap before it is sent, priced as a
19
+ // workflow agent's decision is (runner/workflow-spec.ts decisionJudge), settled at what it charged, and one the cap
20
+ // has no room for never sent, the run paused on the cap's refusal (ledger.pause). A run handed none runs no
21
+ // decision node: the check refuses it before any node runs.
15
22
  // Each model request is a request on the run's one route, so what the workflow spends is the run's cost, under its cap:
16
23
  // on pi the run's models, as a side request (request-start.ts, cap.ts: marked, and costed on the run's timeline as
17
24
  // `learned_workflow`); on another harness the session's model proxy, under a side key (port-models.ts): the harness's
@@ -23,8 +30,11 @@ import { registerLabel, registerOutcome } from "./timeline/index.js";
23
30
  import { sideRequests } from "./cap.js";
24
31
  import { LEARNED_NODES, LEARNED_NODES_MAX } from "./learned-nodes.js";
25
32
  import { draftProblems, LEARNED_MAX_TURNS } from "./learn/index.js";
33
+ import { decisionsAsked, deniedDecisionWords } from "./learn/skills.js";
34
+ import { DEFAULT_DECISION_PROVIDER } from "./decisions.js";
26
35
  import { workflowLine } from "./learning.js";
27
36
  import { ledgerOf } from "./paid-calls.js";
37
+ import { PORT_PROVIDER } from "./port-models.js";
28
38
  import { forModel } from "./result.js";
29
39
  import { ARGS_PREVIEW_BYTES, deniedText } from "./tool-gate.js";
30
40
  import { allows, CALL_TOOLS, learnedDraftTools, toolOf, workflowTools } from "./tools.js";
@@ -80,40 +90,45 @@ export const LEARNED_WORKFLOW_TOOL = "learned_workflow";
80
90
  /** The most of a learned workflow's output its result line shows, and the longest value it shows as written. */
81
91
  const LINE_MAX = 120;
82
92
  const VALUE_MAX = 60;
83
- /** One line of a learned workflow's output for its row: an object's fields as `name value`, each value whole or, when
84
- * longer than VALUE_MAX, only as its size, and whole fields only until LINE_MAX. Nothing is ever cut inside a value:
85
- * the timeline redacts the line as it says it (its summary's words), and its redactor matches a held value only whole,
86
- * so a cut value could leave a prefix it would not find. Newlines are flattened, so the one line it keeps holds every
87
- * field. An output already cut for the model (learnedText) says so. */
93
+ /** One line of a learned workflow's output for its row: an object's fields as `name value`, and a text output (learnedOutput
94
+ * hands one back as it is, #2412) its lines, each value or line whole or, when longer than VALUE_MAX, only as its size,
95
+ * and whole ones only until LINE_MAX. Nothing is ever cut inside a value or a line: the timeline redacts the line as it
96
+ * says it (its summary's words), and its redactor matches a held value only whole, so a cut one could leave a prefix it
97
+ * would not find. Newlines are flattened, so the one line it keeps holds every part. An output already cut for the
98
+ * model (learnedText) says so. */
88
99
  export function outputLine(text) {
89
100
  const clipped = /\n\[the workflow's output is cut at (\d+) of (\d+) characters\]$/.exec(text);
90
101
  if (clipped)
91
102
  return `its output is long, cut at ${clipped[1]} of ${clipped[2]} characters`;
103
+ const said = (value) => {
104
+ const flat = (typeof value === "string" ? value : JSON.stringify(value) ?? String(value)).replace(/\s+/g, " ").trim();
105
+ return flat.length > VALUE_MAX ? `(${flat.length} characters)` : flat;
106
+ };
107
+ /** `parts` whole, joined by `by`, until LINE_MAX: then an ellipsis. */
108
+ const joined = (parts, by) => {
109
+ const kept = [];
110
+ let length = 0;
111
+ for (const part of parts) {
112
+ if (kept.length && length + by.length + part.length > LINE_MAX) {
113
+ kept.push("…");
114
+ break;
115
+ }
116
+ kept.push(part);
117
+ length += (kept.length > 1 ? by.length : 0) + part.length;
118
+ }
119
+ return kept.length ? kept.join(by) : undefined;
120
+ };
92
121
  let output;
93
122
  try {
94
123
  output = JSON.parse(text);
95
124
  }
96
125
  catch {
97
- return undefined;
126
+ // Text, as it is: its lines that hold words.
127
+ return joined(text.split("\n").filter((line) => line.trim()).map(said), " / ");
98
128
  }
99
- const said = (value) => {
100
- const flat = (typeof value === "string" ? value : JSON.stringify(value) ?? String(value)).replace(/\s+/g, " ").trim();
101
- return flat.length > VALUE_MAX ? `(${flat.length} characters)` : flat;
102
- };
103
129
  if (!output || typeof output !== "object" || Array.isArray(output))
104
130
  return said(output);
105
- const fields = [];
106
- let length = 0;
107
- for (const [key, value] of Object.entries(output)) {
108
- const field = `${key} ${said(value)}`;
109
- if (fields.length && length + 2 + field.length > LINE_MAX) {
110
- fields.push("…");
111
- break;
112
- }
113
- fields.push(field);
114
- length += (fields.length > 1 ? 2 : 0) + field.length;
115
- }
116
- return fields.length ? fields.join(", ") : undefined;
131
+ return joined(Object.entries(output).map(([key, value]) => `${key} ${said(value)}`), ", ");
117
132
  }
118
133
  // The timeline's words for a learned workflow's call: the workflow it ran (its name), and, once it returns, its output.
119
134
  registerLabel(LEARNED_WORKFLOW_TOOL, (a) => (typeof a.name === "string" && a.name ? `Ran the learned workflow ${a.name}` : "Ran a learned workflow"), undefined, { name: "Run a learned workflow" });
@@ -124,7 +139,7 @@ registerOutcome(LEARNED_WORKFLOW_TOOL, (result) => {
124
139
  /** The most characters of a learned workflow's output its answer holds, monid's bound (monid.ts CLIP): within the
125
140
  * host's result bound, which each CLI is told to pass whole (host-bounds.test). */
126
141
  export const LEARNED_CLIP = 60_000;
127
- /** `text`, a learned workflow's output as JSON, cut at LEARNED_CLIP characters (never inside a surrogate pair), saying
142
+ /** `text`, a learned workflow's output as its tool hands it back (learnedOutput), cut at LEARNED_CLIP characters (never inside a surrogate pair), saying
128
143
  * so. */
129
144
  export function learnedText(text) {
130
145
  if (text.length <= LEARNED_CLIP)
@@ -137,12 +152,26 @@ export function learnedText(text) {
137
152
  export const NODE_TOOLS_REFUSED = "a learned workflow's model node runs without tools here";
138
153
  /** The tool's description, sent with every model request of the run, so it holds what a model needs to call it right and
139
154
  * no more: one line of what the tool does (one call, by name, a JSON input with the listed fields, `*` marking a required
140
- * one; what it answers), then each workflow on a line of its own (workflowLine): its name, its input's fields and the
141
- * line its README says what it does with. */
155
+ * one; what it answers: a text output as it is, to reply with unchanged, since a model handed it otherwise writes its own
156
+ * reply around it and a format the workflow's last node wrote is lost, #2412), then each workflow on a line of its own
157
+ * (workflowLine): its name, its input's fields and the line its README says what it does with. */
142
158
  export const learnedWorkflowDescription = (workflows) => [
143
- "Runs one of this agent's learned workflows in one call, by name, on a JSON input with the fields below (* required). Answers its output as JSON, or why it did not run.",
159
+ "Runs a learned workflow in one call, by name, on a JSON input: fields below (* required). Text output: reply with it unchanged. Else JSON, or why it did not run.",
144
160
  ...workflows.map(workflowLine),
145
161
  ].join("\n");
162
+ /** A learned workflow's output as its tool hands it back: its text when it is text, a string or an object of one string
163
+ * field (a node's record of one field, as a last node that writes the answer gives it), so the lines its last node wrote
164
+ * reach the model as lines; else JSON. */
165
+ export function learnedOutput(output) {
166
+ if (typeof output === "string")
167
+ return output;
168
+ if (output && typeof output === "object" && !Array.isArray(output)) {
169
+ const values = Object.values(output);
170
+ if (values.length === 1 && typeof values[0] === "string")
171
+ return values[0];
172
+ }
173
+ return JSON.stringify(output ?? null);
174
+ }
146
175
  /** One model request as a pi-ai event stream, sent through `models.completeSimple` as the run's own request, under its
147
176
  * cap: on pi marked and costed on the run's timeline under `learned_workflow` (sideRequests), on another harness booked
148
177
  * by the session's proxy, labelled by the side key it goes under. */
@@ -209,7 +238,7 @@ export function learnedWorkflowTool(run) {
209
238
  },
210
239
  });
211
240
  }
212
- /** `flow` run on `input` for `run`: its output as JSON, or why it did not run, and each of its nodes that ran (at most
241
+ /** `flow` run on `input` for `run`: its output as its tool hands it back (learnedOutput), or why it did not run, and each of its nodes that ran (at most
213
242
  * LEARNED_NODES_MAX), none for one refused before any node ran. Never throws, but on an abort. `ledger`: the tool call's,
214
243
  * which each call node's paid requests are booked under, as a call of its own within it. `nodes`: where each node is
215
244
  * added as it ends, the caller's to keep when the call is aborted (and so throws) part way. */
@@ -239,13 +268,13 @@ export async function runLearned(run, flow, input, signal, ledger, nodes = []) {
239
268
  deniedBy[name] = run.denyFrom(name);
240
269
  }
241
270
  }
242
- const problems = draftProblems(dsl, flow.workflow, tools, gated, deniedBy);
271
+ const problems = draftProblems(dsl, flow.workflow, tools, gated, deniedBy, undefined, decisionsOf(run, dsl, flow.workflow));
243
272
  if (problems.length)
244
273
  return refuse(problems.map(({ detail }) => detail).join("; "));
245
274
  const doc = JSON.parse(flow.workflow);
246
- // agentrun-pi's root loads its host runner and @earendil-works/pi-coding-agent, an optional peer of agentrun-pi: serve
247
- // depends on it (package.json) so an installed server has it, not only this repository.
248
- const { createPiHostRunner } = await import("@parcha/agentrun-pi");
275
+ const runJudge = run.decisions ? await learnedJudge(run, run.decisions) : undefined;
276
+ // The host runner loads @earendil-works/pi-coding-agent and pi-agent-core, serve's own dependencies (package.json).
277
+ const { createPiHostRunner } = await import("./workflow/host-session.js");
249
278
  const runners = new Map();
250
279
  const runnerFor = async (tier) => {
251
280
  const known = runners.get(tier ?? "default");
@@ -262,9 +291,17 @@ export async function runLearned(run, flow, input, signal, ledger, nodes = []) {
262
291
  runners.set(tier ?? "default", runner);
263
292
  return runner;
264
293
  };
294
+ // Each model node's model and tier by its execution path, as it runs: its node.end (the same path) puts them on its
295
+ // trace. Never by its label, which a workflow may repeat. Only a model node runs here: a call node never has one.
296
+ const ranOn = new Map();
265
297
  const runNode = async (request) => {
266
298
  if (request.tools?.length)
267
299
  throw new Error(`${NODE_TOOLS_REFUSED}: its node "${request.label}" names ${request.tools.join(", ")}`);
300
+ const tier = typeof request.tier === "string" ? request.tier : undefined;
301
+ const ref = run.modelOf(tier);
302
+ const model = !ref ? undefined : ref.provider === PORT_PROVIDER ? (run.modelName?.(tier) ?? undefined) : ref.modelId;
303
+ if (model && typeof request.executionPath === "string")
304
+ ranOn.set(request.executionPath, { model, ...(tier ? { tier } : {}) });
268
305
  // Its own signal, which the DSL ties to the call's (a sibling's failure, a deadline, the call's stop).
269
306
  return (await runnerFor(request.tier))(request);
270
307
  };
@@ -310,20 +347,22 @@ export async function runLearned(run, flow, input, signal, ledger, nodes = []) {
310
347
  throw new Error(`This ${tool} call needs a person's approval, which a workflow's call node cannot wait for; it was not run.`);
311
348
  // Its paid requests booked under the tool's call, as a call of its own: the node, its execution path, its item in a map.
312
349
  const booked = ledger ? { ledger: { call: callId, record: ledger.record } } : {};
313
- return effect(given, { signal: own, env: run.env, work: run.work, ...(run.complete ? { complete: run.complete } : {}), ...booked });
350
+ return effect(given, { signal: own, env: run.env, work: run.work, ...(run.complete ? { complete: run.complete } : {}), ...(run.search ? { search: run.search } : {}), ...booked });
314
351
  };
315
352
  // Each node as it ends, by the DSL's own event: what the call's timeline row shows of it.
316
353
  const onEvent = (event) => {
317
354
  if (event.type !== "node.end" || nodes.length >= LEARNED_NODES_MAX)
318
355
  return;
319
356
  const detail = (event.detail ?? {});
320
- nodes.push({ label: String(event.label), kind: String(detail.kind ?? ""), status: String(detail.status ?? ""), duration_ms: typeof detail.duration_ms === "number" ? detail.duration_ms : 0 });
357
+ const ran = typeof event.executionPath === "string" ? ranOn.get(event.executionPath) : undefined;
358
+ nodes.push({ label: String(event.label), kind: String(detail.kind ?? ""), status: String(detail.status ?? ""), duration_ms: typeof detail.duration_ms === "number" ? detail.duration_ms : 0, ...ran });
321
359
  };
322
360
  try {
323
- const result = await dsl.runWorkflow(doc, input, { runNode: runNode, runEffect: runEffect, onEvent, ...(signal ? { signal } : {}) });
361
+ const judging = runJudge && run.decisions ? { runJudge, decisionProviders: run.decisions.providers } : {};
362
+ const result = await dsl.runWorkflow(doc, input, { runNode: runNode, runEffect: runEffect, onEvent, ...judging, ...(signal ? { signal } : {}) });
324
363
  if (result.status !== "complete")
325
364
  return refuse(`it ended ${result.status}`);
326
- return { text: learnedText(JSON.stringify(result.output ?? null)), isError: false, nodes };
365
+ return { text: learnedText(learnedOutput(result.output)), isError: false, nodes };
327
366
  }
328
367
  catch (error) {
329
368
  if (signal?.aborted)
@@ -331,3 +370,55 @@ export async function runLearned(run, flow, input, signal, ledger, nodes = []) {
331
370
  return { text: `The learned workflow ${flow.name} failed: ${String(error?.message ?? error).slice(0, 1000)}`, isError: true, nodes };
332
371
  }
333
372
  }
373
+ /** The draft check's decisions for `run` (learn/skills.ts DraftDecisions): its providers, and the gate's setting of each
374
+ * provider `text` asks (its bare id as the settings key) where it is not allow, with where a deny was set. A run handed
375
+ * no decisions (its claim was handed no key: none named, or each denied) has no provider, so a decision node is refused
376
+ * in the gate's words when its provider is denied, else as one the host does not have; never asked. */
377
+ function decisionsOf(run, dsl, text) {
378
+ const providers = run.decisions?.providers ?? { providers: {}, default: DEFAULT_DECISION_PROVIDER };
379
+ const gated = {};
380
+ // A deny comes from a layer or the default, never from approvals (learnedDraftTools' rule).
381
+ const deniedBy = {};
382
+ let doc;
383
+ try {
384
+ doc = JSON.parse(text);
385
+ }
386
+ catch {
387
+ return { providers: providers.providers, default: providers.default };
388
+ }
389
+ for (const { provider } of decisionsAsked(dsl, doc, providers.default)) {
390
+ const setting = run.policy(provider);
391
+ if (setting === "allow")
392
+ continue;
393
+ gated[provider] = setting;
394
+ if (setting === "deny")
395
+ deniedBy[provider] = run.denyFrom(provider);
396
+ }
397
+ return { providers: providers.providers, default: providers.default, gated, deniedBy };
398
+ }
399
+ /** A learned workflow's judge (the DSL's runJudge) for `run`: its providers' judge (judgeFromProviders), each decision
400
+ * first held to the run's gate as it is asked (a provider set to deny since the call began is refused, never sent, as
401
+ * a call node's tool is at its effect; deny alone refuses, the rule the runner hands a claim its keys by), then admitted on the run's one cap and settled at what it charged
402
+ * (decisionJudge, as a workflow agent's decision is). A refusal of the cap pauses the run (`decisions.pause`): the
403
+ * decision node fails with the cap's words, and nothing is sent. */
404
+ async function learnedJudge(run, decisions) {
405
+ const [{ judgeFromProviders }, { decisionJudge }, { imageLoader }] = await Promise.all([import("@parcha/agentrun-dsl"), import("./runner/workflow-spec.js"), import("./pdf-pages.js")]);
406
+ // A decision node's images (a page drawn by pdf_pages, a screenshot, an upload) are read through the run's own Workspace
407
+ // (Mode 2: its folder on the run's disk, never the runner's local path), as a workflow agent's are (pdf-pages.ts
408
+ // imageLoader).
409
+ const inner = judgeFromProviders({ providers: decisions.providers.providers, default: decisions.providers.default, loadImage: imageLoader(run.workspace ?? run.work) });
410
+ const capped = decisionJudge(inner, {
411
+ getCap: () => decisions.book,
412
+ providers: decisions.providers,
413
+ park: (refusal) => {
414
+ void decisions.pause?.({ refuse: refusal.message, forGood: refusal.forGood, code: "spend_cap_reached", ...(refusal.figures ? { figures: refusal.figures } : {}) });
415
+ },
416
+ });
417
+ return (async (params) => {
418
+ const provider = params.provider ?? decisions.providers.default;
419
+ await run.refresh?.();
420
+ if (run.policy(provider) === "deny")
421
+ throw new Error(deniedDecisionWords(provider, run.denyFrom(provider), "decision", params.label));
422
+ return capped(params);
423
+ });
424
+ }