@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.36

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 (450) hide show
  1. package/CHANGELOG.md +263 -0
  2. package/README.md +339 -179
  3. package/dist/adapters.d.ts +15 -2
  4. package/dist/adapters.js +34 -2
  5. package/dist/agent-rows.d.ts +3 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +25 -5
  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 +90 -8
  13. package/dist/archil-settings.js +150 -14
  14. package/dist/attach-images.d.ts +15 -0
  15. package/dist/attach-images.js +59 -0
  16. package/dist/background.d.ts +0 -6
  17. package/dist/background.js +0 -28
  18. package/dist/bash-read-only.d.ts +13 -0
  19. package/dist/bash-read-only.js +77 -0
  20. package/dist/box-image.d.ts +1 -97
  21. package/dist/box-image.js +4 -284
  22. package/dist/box-paths.d.ts +2 -7
  23. package/dist/box-paths.js +7 -13
  24. package/dist/box-settings.d.ts +0 -11
  25. package/dist/box-settings.js +4 -29
  26. package/dist/browser-commands.js +1 -1
  27. package/dist/browser-computer.d.ts +47 -3
  28. package/dist/browser-computer.js +286 -18
  29. package/dist/browser-cost.d.ts +2 -2
  30. package/dist/browser-cost.js +6 -4
  31. package/dist/browser-person.d.ts +19 -2
  32. package/dist/browser-person.js +55 -6
  33. package/dist/browser-wait-ended.d.ts +23 -0
  34. package/dist/browser-wait-ended.js +42 -0
  35. package/dist/cap.d.ts +19 -44
  36. package/dist/cap.js +31 -77
  37. package/dist/cli.js +36 -27
  38. package/dist/computer-keys.d.ts +20 -10
  39. package/dist/computer-keys.js +36 -57
  40. package/dist/computer-routes.d.ts +1 -4
  41. package/dist/computer-routes.js +3 -5
  42. package/dist/computer-setting.d.ts +8 -5
  43. package/dist/computer-setting.js +91 -26
  44. package/dist/computer-view.d.ts +11 -2
  45. package/dist/computer-view.js +2 -1
  46. package/dist/computers.d.ts +54 -8
  47. package/dist/computers.js +101 -22
  48. package/dist/console/assets/index-BI4Byidu.js +550 -0
  49. package/dist/console/assets/index-C19gUF2n.css +1 -0
  50. package/dist/console/index.html +2 -2
  51. package/dist/content-filter.d.ts +7 -0
  52. package/dist/content-filter.js +23 -0
  53. package/dist/decision-cap.d.ts +7 -29
  54. package/dist/decision-cap.js +3 -94
  55. package/dist/docker-daemon.d.ts +2 -2
  56. package/dist/docker-daemon.js +2 -2
  57. package/dist/errors.d.ts +1 -0
  58. package/dist/errors.js +8 -5
  59. package/dist/explain.js +3 -1
  60. package/dist/faux-computers.js +4 -0
  61. package/dist/files.d.ts +1 -9
  62. package/dist/files.js +1 -9
  63. package/dist/github-connection.js +25 -7
  64. package/dist/github-faux.d.ts +26 -0
  65. package/dist/github-faux.js +76 -0
  66. package/dist/github.d.ts +28 -4
  67. package/dist/github.js +46 -10
  68. package/dist/gpu-words.d.ts +14 -0
  69. package/dist/gpu-words.js +21 -0
  70. package/dist/graph-served.d.ts +5 -3
  71. package/dist/graph-served.js +14 -6
  72. package/dist/graph-view.d.ts +2 -0
  73. package/dist/graph-view.js +29 -2
  74. package/dist/handed-values.d.ts +1 -1
  75. package/dist/handed-values.js +1 -1
  76. package/dist/harness-install.d.ts +60 -3
  77. package/dist/harness-install.js +322 -34
  78. package/dist/harness-opencode/harness.js +0 -1
  79. package/dist/harness-opencode/host/policy.js +2 -2
  80. package/dist/harness.js +1 -1
  81. package/dist/host-tools.d.ts +8 -9
  82. package/dist/host-tools.js +7 -7
  83. package/dist/index.d.ts +2 -3
  84. package/dist/index.js +2 -2
  85. package/dist/key-refusal.d.ts +1 -1
  86. package/dist/key-refusal.js +2 -2
  87. package/dist/learn/check.d.ts +10 -2
  88. package/dist/learn/check.js +126 -8
  89. package/dist/learn/commit.d.ts +40 -6
  90. package/dist/learn/commit.js +164 -20
  91. package/dist/learn/folder.d.ts +11 -3
  92. package/dist/learn/folder.js +40 -16
  93. package/dist/learn/grade.d.ts +22 -2
  94. package/dist/learn/grade.js +127 -19
  95. package/dist/learn/index.d.ts +2 -2
  96. package/dist/learn/index.js +2 -2
  97. package/dist/learn/learning.sh +11 -13
  98. package/dist/learn/notes.d.ts +17 -3
  99. package/dist/learn/notes.js +19 -6
  100. package/dist/learn/reflect.d.ts +5 -2
  101. package/dist/learn/reflect.js +48 -32
  102. package/dist/learn/skills.d.ts +52 -5
  103. package/dist/learn/skills.js +104 -21
  104. package/dist/learned-nodes.d.ts +18 -0
  105. package/dist/learned-nodes.js +8 -0
  106. package/dist/learned-workflow.d.ts +27 -13
  107. package/dist/learned-workflow.js +110 -38
  108. package/dist/learning-cost.d.ts +79 -0
  109. package/dist/learning-cost.js +69 -0
  110. package/dist/learning-routes.d.ts +48 -2
  111. package/dist/learning-routes.js +99 -28
  112. package/dist/learning-run.d.ts +7 -5
  113. package/dist/learning-run.js +9 -6
  114. package/dist/learning-words.d.ts +3 -0
  115. package/dist/learning-words.js +6 -2
  116. package/dist/learning.d.ts +13 -28
  117. package/dist/learning.js +4 -18
  118. package/dist/llm.d.ts +4 -1
  119. package/dist/llm.js +4 -2
  120. package/dist/mcp-gateway.d.ts +6 -0
  121. package/dist/mcp-gateway.js +11 -1
  122. package/dist/mcp-probe.d.ts +8 -1
  123. package/dist/mcp-probe.js +62 -20
  124. package/dist/mcp-secret-writes.js +4 -0
  125. package/dist/mcp-servers-store.d.ts +12 -12
  126. package/dist/mcp-servers-store.js +8 -3
  127. package/dist/model.d.ts +8 -5
  128. package/dist/model.js +14 -6
  129. package/dist/openapi.d.ts +2 -0
  130. package/dist/openapi.js +236 -55
  131. package/dist/owner.d.ts +0 -1
  132. package/dist/owner.js +0 -2
  133. package/dist/pause.d.ts +2 -19
  134. package/dist/pause.js +5 -74
  135. package/dist/place-offers.d.ts +97 -0
  136. package/dist/place-offers.js +206 -0
  137. package/dist/place.d.ts +9 -13
  138. package/dist/place.js +22 -32
  139. package/dist/port-models.d.ts +12 -4
  140. package/dist/port-models.js +31 -9
  141. package/dist/print.d.ts +1 -8
  142. package/dist/print.js +1 -14
  143. package/dist/propose.d.ts +3 -0
  144. package/dist/propose.js +25 -19
  145. package/dist/run-cut.d.ts +5 -0
  146. package/dist/run-cut.js +19 -0
  147. package/dist/run-db.js +3 -3
  148. package/dist/run-launch.d.ts +18 -3
  149. package/dist/run-launch.js +11 -5
  150. package/dist/run-learning-served.d.ts +12 -1
  151. package/dist/run-manifest.d.ts +2 -2
  152. package/dist/run-manifest.js +2 -2
  153. package/dist/run-reads-over-store.d.ts +4 -2
  154. package/dist/run-reads-over-store.js +10 -8
  155. package/dist/run-secrets.js +3 -3
  156. package/dist/run-timeline-served.js +60 -38
  157. package/dist/run-view.d.ts +35 -16
  158. package/dist/run-view.js +64 -35
  159. package/dist/runnable.d.ts +6 -3
  160. package/dist/runnable.js +20 -4
  161. package/dist/runner/adapter-loop.d.ts +46 -5
  162. package/dist/runner/adapter-loop.js +381 -56
  163. package/dist/runner/adapter-run-spec.d.ts +46 -4
  164. package/dist/runner/adapter-run-spec.js +200 -45
  165. package/dist/runner/adapters/pi.d.ts +39 -3
  166. package/dist/runner/adapters/pi.js +124 -29
  167. package/dist/runner/beside.d.ts +8 -0
  168. package/dist/runner/beside.js +24 -2
  169. package/dist/runner/claim-secrets.d.ts +6 -0
  170. package/dist/runner/claim-secrets.js +15 -1
  171. package/dist/runner/cli-run-spec.d.ts +10 -0
  172. package/dist/runner/cli-run-spec.js +207 -64
  173. package/dist/runner/commands.d.ts +5 -1
  174. package/dist/runner/commands.js +3 -3
  175. package/dist/runner/conformance/harness.d.ts +1 -1
  176. package/dist/runner/conformance/harness.js +13 -10
  177. package/dist/runner/github-app.d.ts +7 -2
  178. package/dist/runner/github-app.js +46 -15
  179. package/dist/runner/harness-loops.d.ts +6 -1
  180. package/dist/runner/harness-loops.js +24 -1
  181. package/dist/runner/journal-kinds.d.ts +53 -7
  182. package/dist/runner/journal-kinds.js +29 -1
  183. package/dist/runner/learning-end.d.ts +15 -0
  184. package/dist/runner/learning-end.js +113 -20
  185. package/dist/runner/learning-factory.js +6 -2
  186. package/dist/runner/learning-loop.d.ts +75 -1
  187. package/dist/runner/learning-loop.js +215 -22
  188. package/dist/runner/learning-seed.d.ts +8 -0
  189. package/dist/runner/learning-seed.js +7 -1
  190. package/dist/runner/loop-contract.d.ts +12 -0
  191. package/dist/runner/loop-contract.js +6 -0
  192. package/dist/runner/loop.d.ts +5 -1
  193. package/dist/runner/loop.js +20 -0
  194. package/dist/runner/main.d.ts +9 -4
  195. package/dist/runner/main.js +38 -13
  196. package/dist/runner/mcp-claim.d.ts +7 -0
  197. package/dist/runner/mcp-claim.js +35 -2
  198. package/dist/runner/mcp-github.d.ts +15 -4
  199. package/dist/runner/mcp-github.js +55 -11
  200. package/dist/runner/mcp-run.d.ts +2 -0
  201. package/dist/runner/mcp-run.js +2 -0
  202. package/dist/runner/metrics.d.ts +18 -1
  203. package/dist/runner/metrics.js +81 -1
  204. package/dist/runner/model-route.d.ts +6 -0
  205. package/dist/runner/model-route.js +5 -2
  206. package/dist/runner/pr-checkout.d.ts +59 -0
  207. package/dist/runner/pr-checkout.js +176 -0
  208. package/dist/runner/reflect-hook.d.ts +1 -0
  209. package/dist/runner/reflect-hook.js +3 -3
  210. package/dist/runner/runner.js +136 -19
  211. package/dist/runner/spec-holds.d.ts +13 -3
  212. package/dist/runner/spec-holds.js +13 -10
  213. package/dist/runner/store-port.d.ts +4 -1
  214. package/dist/runner/store-secrets.js +17 -1
  215. package/dist/runner/subagent.d.ts +44 -0
  216. package/dist/runner/subagent.js +188 -0
  217. package/dist/runner/workflow-host.d.ts +25 -4
  218. package/dist/runner/workflow-host.js +26 -4
  219. package/dist/runner/workflow-loop.d.ts +9 -3
  220. package/dist/runner/workflow-loop.js +17 -10
  221. package/dist/runner/workflow-spec.d.ts +28 -13
  222. package/dist/runner/workflow-spec.js +247 -102
  223. package/dist/runs-over-store.d.ts +18 -7
  224. package/dist/runs-over-store.js +149 -31
  225. package/dist/seal-key.d.ts +0 -2
  226. package/dist/seal-key.js +0 -2
  227. package/dist/sealing.js +1 -2
  228. package/dist/secret-cut.d.ts +1 -1
  229. package/dist/secret-cut.js +1 -1
  230. package/dist/server-lock.js +4 -5
  231. package/dist/server.d.ts +49 -63
  232. package/dist/server.js +429 -230
  233. package/dist/stop-signals.d.ts +4 -2
  234. package/dist/stop-signals.js +5 -3
  235. package/dist/store/agent-body.d.ts +14 -3
  236. package/dist/store/agent-body.js +22 -8
  237. package/dist/store/deadline.d.ts +18 -0
  238. package/dist/store/deadline.js +49 -0
  239. package/dist/store/index.d.ts +3 -3
  240. package/dist/store/index.js +2 -2
  241. package/dist/store/journal/storage.js +2 -1
  242. package/dist/store/postgres/connection.d.ts +4 -0
  243. package/dist/store/postgres/connection.js +64 -13
  244. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  245. package/dist/store/schema.d.ts +2 -1
  246. package/dist/store/schema.js +11 -8
  247. package/dist/store/seal.d.ts +13 -0
  248. package/dist/store/seal.js +19 -0
  249. package/dist/store/sqlite/connection.d.ts +5 -0
  250. package/dist/store/sqlite/connection.js +88 -82
  251. package/dist/store/sqlite/run-patch.d.ts +18 -2
  252. package/dist/store/sqlite/run-patch.js +31 -2
  253. package/dist/store/sqlite/store.js +65 -11
  254. package/dist/store/store.d.ts +62 -12
  255. package/dist/store/store.js +22 -1
  256. package/dist/store-reads/analytics.js +3 -2
  257. package/dist/store-reads/cap.d.ts +1 -3
  258. package/dist/store-reads/cap.js +8 -6
  259. package/dist/store-reads/decisions.d.ts +2 -2
  260. package/dist/store-reads/decisions.js +3 -6
  261. package/dist/store-reads/journal.js +83 -15
  262. package/dist/store-reads/learning.d.ts +73 -3
  263. package/dist/store-reads/learning.js +232 -9
  264. package/dist/store-reads/runs.d.ts +6 -4
  265. package/dist/store-reads/runs.js +17 -10
  266. package/dist/store-reads/stats.js +5 -1
  267. package/dist/store-view.d.ts +15 -1
  268. package/dist/store-view.js +88 -29
  269. package/dist/template-eval.js +2 -1
  270. package/dist/templates.d.ts +73 -4
  271. package/dist/templates.js +113 -23
  272. package/dist/timeline/timeline.d.ts +11 -1
  273. package/dist/timeline/timeline.js +19 -4
  274. package/dist/tool-blurbs.js +1 -0
  275. package/dist/tool-budget.d.ts +26 -0
  276. package/dist/tool-budget.js +56 -0
  277. package/dist/tool-gate.d.ts +13 -3
  278. package/dist/tool-gate.js +15 -7
  279. package/dist/tool-plane.d.ts +42 -29
  280. package/dist/tool-plane.js +64 -27
  281. package/dist/tools.d.ts +53 -39
  282. package/dist/tools.js +174 -79
  283. package/dist/trigger-signatures.d.ts +1 -0
  284. package/dist/trigger-signatures.js +3 -1
  285. package/dist/triggers.d.ts +3 -3
  286. package/dist/triggers.js +2 -2
  287. package/dist/turn-end.d.ts +0 -3
  288. package/dist/turn-end.js +0 -3
  289. package/dist/uploads.d.ts +28 -5
  290. package/dist/uploads.js +82 -9
  291. package/dist/usage-lines.d.ts +1 -1
  292. package/dist/usage.d.ts +1 -47
  293. package/dist/usage.js +3 -82
  294. package/dist/validate.d.ts +8 -0
  295. package/dist/validate.js +40 -3
  296. package/dist/webhooks.d.ts +2 -1
  297. package/dist/webhooks.js +5 -2
  298. package/dist/workflow/decision-recovery.d.ts +23 -0
  299. package/dist/workflow/decision-recovery.js +80 -0
  300. package/dist/workflow/decisions.d.ts +134 -0
  301. package/dist/workflow/decisions.js +46 -0
  302. package/dist/workflow/host-session.d.ts +5 -0
  303. package/dist/workflow/host-session.js +85 -0
  304. package/dist/workflow/host-tools.d.ts +3 -0
  305. package/dist/workflow/host-tools.js +3 -0
  306. package/dist/workflow/node-runner.d.ts +112 -0
  307. package/dist/workflow/node-runner.js +270 -0
  308. package/dist/workflow/node.d.ts +88 -0
  309. package/dist/workflow/node.js +99 -0
  310. package/dist/workflow/operator-error.d.ts +4 -0
  311. package/dist/workflow/operator-error.js +4 -0
  312. package/dist/workflow/pi-versions.d.ts +9 -0
  313. package/dist/workflow/pi-versions.js +8 -0
  314. package/dist/workflow/readers.d.ts +36 -0
  315. package/dist/workflow/readers.js +145 -0
  316. package/dist/workflow/record-file.d.ts +10 -0
  317. package/dist/workflow/record-file.js +56 -0
  318. package/dist/workflow/record-tool.d.ts +76 -0
  319. package/dist/workflow/record-tool.js +126 -0
  320. package/dist/workflow/record.d.ts +151 -0
  321. package/dist/workflow/record.js +401 -0
  322. package/dist/workflow/run-error.d.ts +16 -0
  323. package/dist/workflow/run-error.js +26 -0
  324. package/dist/workflow/runner.d.ts +6 -0
  325. package/dist/workflow/runner.js +240 -0
  326. package/dist/workflow/store.d.ts +23 -0
  327. package/dist/workflow/store.js +242 -0
  328. package/dist/workflow/task.d.ts +133 -0
  329. package/dist/workflow/task.js +411 -0
  330. package/dist/workflow/thinking.d.ts +3 -0
  331. package/dist/workflow/thinking.js +7 -0
  332. package/dist/workflow/tool-context.d.ts +21 -0
  333. package/dist/workflow/tool-context.js +13 -0
  334. package/dist/workflow/types.d.ts +126 -0
  335. package/dist/workflow/types.js +1 -0
  336. package/dist/workflow/wal.d.ts +11 -0
  337. package/dist/workflow/wal.js +106 -0
  338. package/dist/workflow-run.d.ts +1 -1
  339. package/dist/workspace/agent-computer.d.ts +137 -0
  340. package/dist/workspace/agent-computer.js +292 -0
  341. package/dist/workspace/archil-claim.d.ts +13 -2
  342. package/dist/workspace/archil-claim.js +22 -13
  343. package/dist/workspace/archil-disk.d.ts +10 -1
  344. package/dist/workspace/archil-disk.js +4 -0
  345. package/dist/workspace/archil-disks.d.ts +49 -0
  346. package/dist/workspace/archil-disks.js +185 -0
  347. package/dist/workspace/archil-exec.d.ts +12 -2
  348. package/dist/workspace/archil-exec.js +18 -3
  349. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  350. package/dist/workspace/archil-mount-credential.js +13 -4
  351. package/dist/workspace/archil.d.ts +2 -2
  352. package/dist/workspace/archil.js +25 -5
  353. package/dist/workspace/attach.js +2 -0
  354. package/dist/workspace/computer-deps.d.ts +18 -11
  355. package/dist/workspace/computer-deps.js +64 -40
  356. package/dist/workspace/computer-for-claim.d.ts +47 -9
  357. package/dist/workspace/computer-for-claim.js +236 -24
  358. package/dist/workspace/computer-janitor.d.ts +3 -2
  359. package/dist/workspace/computer-janitor.js +43 -9
  360. package/dist/workspace/computer-ledger.d.ts +3 -8
  361. package/dist/workspace/computer-ledger.js +7 -3
  362. package/dist/workspace/computer-providers.d.ts +5 -3
  363. package/dist/workspace/computer-providers.js +11 -9
  364. package/dist/workspace/hands.d.ts +5 -2
  365. package/dist/workspace/hands.js +4 -3
  366. package/dist/workspace/index.d.ts +5 -4
  367. package/dist/workspace/index.js +2 -1
  368. package/dist/workspace/local.d.ts +3 -0
  369. package/dist/workspace/local.js +9 -0
  370. package/dist/workspace/paths.js +3 -2
  371. package/dist/workspace/pi-env.d.ts +4 -0
  372. package/dist/workspace/pi-env.js +3 -2
  373. package/dist/workspace/resolve-computer.d.ts +48 -12
  374. package/dist/workspace/resolve-computer.js +88 -19
  375. package/dist/workspace/run-disk.d.ts +34 -0
  376. package/dist/workspace/run-disk.js +91 -0
  377. package/dist/workspace/run-tools.d.ts +6 -4
  378. package/dist/workspace/run-tools.js +17 -9
  379. package/dist/workspace/server-run-workspace.d.ts +3 -2
  380. package/dist/workspace/server-run-workspace.js +17 -4
  381. package/dist/workspace/workspace.d.ts +5 -0
  382. package/dist/workspace.d.ts +0 -3
  383. package/dist/workspace.js +2 -15
  384. package/package.json +11 -16
  385. package/skills/agentrun-serve/SKILL.md +1 -1
  386. package/templates/README.md +11 -8
  387. package/templates/code-review/agent.md +27 -11
  388. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  389. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  390. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  391. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  392. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  393. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  394. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  395. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  396. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  397. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  398. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  399. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  400. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  401. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  402. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  403. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  404. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  405. package/templates/code-review/evals/re-review/prompt.md +1 -1
  406. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  407. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  408. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  409. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  410. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  411. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  412. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  413. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  414. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  415. package/templates/code-review/findings.schema.json +131 -27
  416. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  417. package/templates/code-review/skills/review/DEEP.md +130 -0
  418. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  419. package/templates/code-review/skills/review/SKILL.md +104 -154
  420. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  421. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  422. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  423. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  424. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  425. package/templates/release-notes/agent.md +11 -0
  426. package/dist/box/record.d.ts +0 -6
  427. package/dist/box/record.js +0 -41
  428. package/dist/box/sweep.d.ts +0 -53
  429. package/dist/box/sweep.js +0 -193
  430. package/dist/box-egress-vm.d.ts +0 -118
  431. package/dist/box-egress-vm.js +0 -354
  432. package/dist/box-egress.d.ts +0 -105
  433. package/dist/box-egress.js +0 -256
  434. package/dist/box-relay-vm.d.ts +0 -84
  435. package/dist/box-relay-vm.js +0 -437
  436. package/dist/box-relay.d.ts +0 -36
  437. package/dist/box-relay.js +0 -207
  438. package/dist/boxes.d.ts +0 -109
  439. package/dist/boxes.js +0 -249
  440. package/dist/budget.d.ts +0 -76
  441. package/dist/budget.js +0 -204
  442. package/dist/console/assets/index-RPHGlXmM.js +0 -540
  443. package/dist/console/assets/index-opTN5Naq.css +0 -1
  444. package/dist/daytona-api.d.ts +0 -10
  445. package/dist/daytona-api.js +0 -20
  446. package/dist/egress-proxy.d.ts +0 -45
  447. package/dist/egress-proxy.js +0 -416
  448. package/dist/egress-table.d.ts +0 -24
  449. package/dist/egress-table.js +0 -165
  450. package/templates/code-review/rules/REVIEW.md +0 -41
@@ -15,7 +15,9 @@ export declare const DRAFT_AFTER_RUNS = 3;
15
15
  * name: the prompt gains one line asking for that job as a workflow draft. None when not given. `described`, with a
16
16
  * draft asked for: what each of `tools` takes and gives a call node, in the server's own words (tools.ts ToolEntry
17
17
  * summary), said under the ask, one line each (at most DESCRIBED_MAX characters, unseen characters and line breaks made
18
- * spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for. */
18
+ * spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for. `workflows`, false
19
+ * for a run of a revision that says `learning: "notes"`: the prompt asks for notes and a skill alone, says to keep no
20
+ * workflow draft, and asks for none (`draftFor` and `described` are not said). */
19
21
  export declare function reflectPrompt(options: {
20
22
  dir: string;
21
23
  active: number;
@@ -25,10 +27,11 @@ export declare function reflectPrompt(options: {
25
27
  readonly name: string;
26
28
  readonly does: string;
27
29
  }[];
30
+ workflows?: boolean;
28
31
  }): string;
29
32
  /** The end-of-run turn asked again, once, when the parser refused its answer: why, in the parser's own words (`detail`,
30
33
  * parseReflection's), and the whole answer again in the format. */
31
- export declare function reflectAgain(detail: string): string;
34
+ export declare function reflectAgain(detail: string, workflows?: false): string;
32
35
  /** The end-of-run turn asked again, once, when the checks left a workflow draft out because its dry run failed: which
33
36
  * draft, in the host's own words, and why (`detail`, the check's words, made from the draft's own text: a step's label,
34
37
  * a path) inside a data fence alone, cleaned of control and format characters and capped, its token one the detail
@@ -6,7 +6,7 @@
6
6
  import { createHash } from "node:crypto";
7
7
  import { CAPS } from "./check.js";
8
8
  import { INDEX_FILE, INDEX_LINES } from "./notes.js";
9
- import { SKILL_NAME } from "./skills.js";
9
+ import { LEARNED_MCP_TOOL, SKILL_NAME } from "./skills.js";
10
10
  /** Control and invisible characters: none may reach the prompt through a value the host puts in it. */
11
11
  const UNSEEN = /[\p{Cc}\p{Cf}]/u;
12
12
  /** The info word that opens a note's block in the answer: ```note <file>. */
@@ -18,8 +18,10 @@ export const WORKFLOW_BLOCK = "workflow";
18
18
  /** How many earlier runs of an agent a learned skill has been given to before the host asks for its job as a workflow
19
19
  * draft (`draftFor`): a run proposes one only when it thinks to, and few do. */
20
20
  export const DRAFT_AFTER_RUNS = 3;
21
- /** A tool's name as the prompt may print it. */
21
+ /** A tool's name as the prompt may print it: a table tool's, or an MCP tool's a learned workflow may run (skills.ts
22
+ * LEARNED_MCP_TOOL). */
22
23
  const TOOL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
24
+ const printable = (tool) => TOOL_NAME.test(tool) || LEARNED_MCP_TOOL.test(tool);
23
25
  /** The end-of-run turn's message. `dir` is the run's copy of the folder relative to the run's workspace (`.learning`),
24
26
  * where the agent can read its notes: the prompt never names a path of the host's, which a box would not see. `active`
25
27
  * is how many notes are active in it, so how many lines the index has left. `tools`, the tools a workflow draft's
@@ -28,14 +30,16 @@ const TOOL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
28
30
  * name: the prompt gains one line asking for that job as a workflow draft. None when not given. `described`, with a
29
31
  * draft asked for: what each of `tools` takes and gives a call node, in the server's own words (tools.ts ToolEntry
30
32
  * summary), said under the ask, one line each (at most DESCRIBED_MAX characters, unseen characters and line breaks made
31
- * spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for. */
33
+ * spaces); one for a tool not in `tools` is left out. Nothing is described unless a draft is asked for. `workflows`, false
34
+ * for a run of a revision that says `learning: "notes"`: the prompt asks for notes and a skill alone, says to keep no
35
+ * workflow draft, and asks for none (`draftFor` and `described` are not said). */
32
36
  export function reflectPrompt(options) {
33
- const { dir, active, tools = [], draftFor = [], described = [] } = options;
37
+ const { dir, active, tools = [], draftFor = [], described = [], workflows = true } = options;
34
38
  if (typeof dir !== "string" || dir === "" || dir.startsWith("/") || UNSEEN.test(dir))
35
39
  throw new Error("the directory must be a path relative to the run's workspace, with no control or unseen characters");
36
40
  if (!Number.isSafeInteger(active) || active < 0)
37
41
  throw new Error("the count of active notes must be a whole number, 0 or more");
38
- if (!Array.isArray(tools) || tools.some((tool) => typeof tool !== "string" || !TOOL_NAME.test(tool)))
42
+ if (!Array.isArray(tools) || tools.some((tool) => typeof tool !== "string" || !printable(tool)))
39
43
  throw new Error("each tool must be a tool's name");
40
44
  if (!Array.isArray(draftFor) || draftFor.some((name) => typeof name !== "string" || !SKILL_NAME.test(name)))
41
45
  throw new Error("each skill a draft is asked for must be a skill's name");
@@ -81,19 +85,29 @@ export function reflectPrompt(options) {
81
85
  "site, a source or a seller, or names where money or data goes.",
82
86
  "What `# Learned` in your instructions, and this message, say about learning itself is not a lesson: never put it in a note or a skill, nor the sentence you say when you keep something.",
83
87
  "",
84
- "## Skills and workflow drafts, only when the work repeats",
85
- "",
86
- "When this run did, to the end, a job this agent will be asked to do again, you may also keep one skill and one",
87
- "workflow draft for that job. Most runs keep neither. Neither holds this case's data: each is about the job, not the one case.",
88
+ ...(workflows ? [
89
+ "## Skills and workflow drafts, only when the work repeats",
90
+ "",
91
+ "When this run did, to the end, a job this agent will be asked to do again, you may also keep one skill and one",
92
+ "workflow draft for that job. Most runs keep neither. Neither holds this case's data: each is about the job, not the one case.",
93
+ ] : [
94
+ "## Skills, only when the work repeats",
95
+ "",
96
+ "When this run did, to the end, a job this agent will be asked to do again, you may also keep one skill for that job.",
97
+ "Most runs keep none. It holds none of this case's data: it is about the job, not the one case.",
98
+ "Keep no workflow draft: this agent learns notes and skills alone.",
99
+ ]),
88
100
  "Steps the person asks you to follow every time a task comes back are a skill, not a note: keep them as the skill, in",
89
101
  "their words and with the exact output format they gave, and do not repeat them in a note.",
90
102
  "A job you keep a skill for needs no note beside it.",
91
103
  "A rule for every reply applies whatever the job is. Keep it as a note, which every later run reads. Steps or a format",
92
104
  "for one kind of job, named by when it applies (\"whenever I ask for a weekly summary\", \"when you open a PR\"), are a",
93
105
  "skill. A note holds its own lesson: never repeat another note's rule in it, so a retired rule stays retired.",
94
- "A job that runs end to end as model and tool-call steps, from a defined input to a defined output, is a workflow draft,",
95
- "and so is one the person asks you to keep as a workflow; its steps may also be a skill.",
96
- ...(draftFor.length ? [draftAsk(draftFor), ...describedLines(described, tools)] : []),
106
+ ...(workflows ? [
107
+ "A job that runs end to end as model and tool-call steps, from a defined input to a defined output, is a workflow draft,",
108
+ "and so is one the person asks you to keep as a workflow; its steps may also be a skill.",
109
+ ...(draftFor.length ? [draftAsk(draftFor), ...describedLines(described, tools)] : []),
110
+ ] : []),
97
111
  "",
98
112
  `A skill is how to do the job, step by step, as a SKILL.md: front matter with its \`name\` (lowercase letters, digits`,
99
113
  "and single dashes) and a `description` of when to use it, then the steps. Open its block with four backticks, so a",
@@ -108,22 +122,24 @@ export function reflectPrompt(options) {
108
122
  "1. Open the store's policies page first.",
109
123
  "````",
110
124
  "",
111
- "A workflow draft does the job as one workflow DSL document: front matter with one line that says what it does and",
112
- "when to use it, then the JSON. It uses model and tool-call nodes only: no judge, pick or sift node, no code node, no shell or",
113
- `executor call. Its model nodes name no tool. ${tools.length ? `Its call nodes may run only these tools: ${tools.join(", ")}.` : "It has no call node on a tool."} At most ${CAPS.file} bytes of JSON.`,
114
- "To change a draft you were given, give it again whole under its name.",
115
- "Its schemas are declared once under `schemas`, and `input` and `output` name one each by `schemaId`, never a schema",
116
- "written in place.",
117
- "Give its front matter an `example:` line too: one JSON object on one line, the input this run would have given it.",
118
- "The host dry-runs the draft on it before it is kept (no model or tool is called) and never keeps the example.",
119
- "",
120
- `\`\`\`\`${WORKFLOW_BLOCK} find-policies`,
121
- "---",
122
- "description: Finds a store's refund policy from its public pages; use when a case asks for it",
123
- `example: ${JSON.stringify(tools.includes("web_fetch") ? { url: "https://shop.example/policies" } : { text: "Refunds are accepted within 30 days of delivery." })}`,
124
- "---",
125
- JSON.stringify(exampleDraft(tools.includes("web_fetch"))),
126
- "````",
125
+ ...(workflows ? [
126
+ "A workflow draft does the job as one workflow DSL document: front matter with one line that says what it does and",
127
+ "when to use it, then the JSON. It uses model and tool-call nodes only: no judge, pick or sift node, no code node, no shell or",
128
+ `executor call. Its model nodes name no tool. ${tools.length ? `Its call nodes may run only these tools: ${tools.join(", ")}.` : "It has no call node on a tool."} At most ${CAPS.file} bytes of JSON.`,
129
+ "To change a draft you were given, give it again whole under its name.",
130
+ "Its schemas are declared once under `schemas`, and `input` and `output` name one each by `schemaId`, never a schema",
131
+ "written in place.",
132
+ "Give its front matter an `example:` line too: one JSON object on one line, the input this run would have given it.",
133
+ "The host dry-runs the draft on it before it is kept (no model or tool is called) and never keeps the example.",
134
+ "",
135
+ `\`\`\`\`${WORKFLOW_BLOCK} find-policies`,
136
+ "---",
137
+ "description: Finds a store's refund policy from its public pages; use when a case asks for it",
138
+ `example: ${JSON.stringify(tools.includes("web_fetch") ? { url: "https://shop.example/policies" } : { text: "Refunds are accepted within 30 days of delivery." })}`,
139
+ "---",
140
+ JSON.stringify(exampleDraft(tools.includes("web_fetch"))),
141
+ "````",
142
+ ] : []),
127
143
  ].join("\n");
128
144
  }
129
145
  /** The most of one tool's words the draft ask's description gives it. */
@@ -144,13 +160,13 @@ const describedLines = (described, tools) => {
144
160
  const draftAsk = (names) => {
145
161
  const listed = names.map((name) => `\`${name}\``).join(", ");
146
162
  return names.length === 1
147
- ? `Your skill ${listed} has now served ${DRAFT_AFTER_RUNS} or more runs: this time, also keep its job as a workflow draft named \`${names[0]}\`, its steps as nodes, if the job runs end to end as model and tool-call steps.`
148
- : `Your skills ${listed} have each served ${DRAFT_AFTER_RUNS} or more runs: this time, also keep one of their jobs as a workflow draft named like its skill, its steps as nodes, if the job runs end to end as model and tool-call steps.`;
163
+ ? `Your skill ${listed} has now served ${DRAFT_AFTER_RUNS} or more runs: this time, also keep its job as a workflow draft named \`${names[0]}\`, its steps as nodes, if the job runs end to end as model and tool-call steps. Its output is the job's answer in the output format the skill gives: its last node writes it, and \`output\` names that node's text.`
164
+ : `Your skills ${listed} have each served ${DRAFT_AFTER_RUNS} or more runs: this time, also keep one of their jobs as a workflow draft named like its skill, its steps as nodes, if the job runs end to end as model and tool-call steps. Its output is the job's answer in the output format its skill gives: its last node writes it, and \`output\` names that node's text.`;
149
165
  };
150
166
  /** The end-of-run turn asked again, once, when the parser refused its answer: why, in the parser's own words (`detail`,
151
167
  * parseReflection's), and the whole answer again in the format. */
152
- export function reflectAgain(detail) {
153
- return `Your answer could not be read: ${detail}. Give the whole answer again in the format asked for above, every note, skill and workflow block in it, and nothing else.`;
168
+ export function reflectAgain(detail, workflows) {
169
+ return `Your answer could not be read: ${detail}. Give the whole answer again in the format asked for above, every ${workflows === false ? "note and skill" : "note, skill and workflow"} block in it, and nothing else.`;
154
170
  }
155
171
  /** The end-of-run turn asked again, once, when the checks left a workflow draft out because its dry run failed: which
156
172
  * draft, in the host's own words, and why (`detail`, the check's words, made from the draft's own text: a step's label,
@@ -74,22 +74,41 @@ export declare const isHeld: (text: string) => boolean;
74
74
  * retiredLearned), which take the `status:` line out whole, can edit. One set any other way reads unclear (learnedStatus:
75
75
  * retired), never held or active, and no writer edits it, so a write never leaves part of it behind. The host writes
76
76
  * only one-line statuses (held, retiredLearned). */
77
- export declare function statusOnOneLine(text: string): boolean;
77
+ export declare const statusOnOneLine: (text: string) => boolean;
78
78
  /** `text`, a SKILL.md or a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
79
79
  * pending` last in its front matter, with LF line ends. Throws on a text with no front matter, which the checker never
80
80
  * passes. */
81
81
  export declare function held(text: string): string;
82
82
  /** `text`, a held SKILL.md or draft README.md, as the host leaves it when its owner approves it: its front matter with
83
- * no `status` line, so it is given to every later run. Throws on a text with no front matter. */
83
+ * no `status` or `retired_from` line, so it is given to every later run. Throws on a text with no front matter. */
84
84
  export declare function released(text: string): string;
85
+ /** The status a retired SKILL.md or draft README.md goes back to when a person restores it (`retired_from`, which its
86
+ * retire recorded), read by the one reader (frontMatter: its quoting, its one-line rule): `active` only when it reads
87
+ * `active` one way, on one plain line; `pending` otherwise, a retire that recorded none or one that reads unclear among
88
+ * them (fail closed: only an approval makes a skill or a draft active). */
89
+ export declare function retiredFrom(text: string): "active" | "pending";
90
+ /** Whether a retired SKILL.md or draft README.md can be restored by the host's writer: its front matter reads one way
91
+ * (frontMatter), and its `status` and `retired_from` are each one plain line, the only ones the writer takes out whole.
92
+ * One that is not is refused until it is written so (a restore never edits half a value). */
93
+ export declare const restorable: (text: string) => boolean;
94
+ /** `text`, a retired SKILL.md or draft README.md, as the host leaves it when a person restores it: back in the status its
95
+ * retire recorded (retiredFrom), active, or waiting for its owner's OK. Throws on a text whose front matter does not read
96
+ * one way, or whose status is not one plain line (released). */
97
+ export declare const restoredLearned: (text: string) => string;
85
98
  /** What a SKILL.md or a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
86
99
  * the folder's snapshot, the console's: `pending` while it waits for its owner's OK, `retired` once a person retired
87
100
  * it, `active` when it sets no status or `active`. A front matter that does not read one way, or a status that is none
88
101
  * of these, is `retired`: never active, since another reader could read it as held or retired; no run is given it, and
89
102
  * a restore refuses it until it reads one way. A run is given only an active one. */
90
103
  export declare function learnedStatus(text: string): "active" | "pending" | "retired";
91
- /** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` last in its front matter
92
- * (any status line before it dropped), so no later run is given it. Throws on a text with no front matter. */
104
+ /** Whether `text` reads retired (learnedStatus) only because it can't be read: its front matter reads no way, its status
105
+ * 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
106
+ * it, never that a run or a person retired it. */
107
+ export declare function unclearFront(text: string): boolean;
108
+ /** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
109
+ * status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
110
+ * them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
111
+ * matter. */
93
112
  export declare function retiredLearned(text: string): string;
94
113
  /** A draft's `README.md` as the host writes it, from the workflow's name and the one-line description its block gives. */
95
114
  export declare const readmeOf: (name: string, description: string) => string;
@@ -180,6 +199,28 @@ export declare const LEARNED_NODES = "a learned workflow runs model and tool-cal
180
199
  /** Where a deny was set (tool-gate.ts SettingFrom), and its words (tool-gate.ts denyPlace), kept here so the learn
181
200
  * module needs no import of the gate. */
182
201
  type SettingFrom = "agent" | "server" | "default";
202
+ /** An MCP tool a learned workflow's call node may run, by its address (`via: "tool"`, `tool: "mcp:<server>/<tool>"`,
203
+ * LS-07): its server's name as a server is named (mcp-probe.ts MCP_SERVER_NAME) and one tool's name in MCP's own
204
+ * charset, never a wildcard. The one rule for it: the tools a draft may name (tools.ts learnedWorkflowTools), the
205
+ * end-of-run prompt that prints them (reflect.ts), and what the grader is told of a draft (grade.ts). */
206
+ export declare const LEARNED_MCP_TOOL: RegExp;
207
+ /** The MCP tools a draft's call nodes run, each once, in the order they come (LS-07): every call node in `doc`, nested
208
+ * ones too, whose tool is an MCP tool's address. Read from the JSON as it is, for the grader's words; never a check. */
209
+ export declare function draftMcpTools(doc: unknown): string[];
210
+ /** One step of a learned workflow that runs an MCP tool with no declared per-call price: its label, the tool and its
211
+ * server. */
212
+ export type UnpricedCall = {
213
+ readonly label: string;
214
+ readonly tool: string;
215
+ readonly server: string;
216
+ };
217
+ /** The call nodes of a learned workflow (`doc`, its parsed workflow.json, nested ones too) whose tool is an MCP tool
218
+ * (LEARNED_MCP_TOOL) that `priceOf` gives no price for (mcp-probe.ts McpPrices: none declared). Such a tool runs "not
219
+ * metered", outside the run's cost and cap (mcp-gateway.ts), so a learned workflow that calls one unattended waits for
220
+ * its owner's OK whatever the grade (LS-07): a structural fact, held in code. Each step once, in order. */
221
+ export declare function unpricedCalls(doc: unknown, priceOf: (tool: string) => number | undefined): UnpricedCall[];
222
+ /** Why a learned workflow that calls `call` waits for its owner's OK, in a person's words. */
223
+ export declare const unpricedLine: (call: UnpricedCall) => string;
183
224
  /** Every string a learned workflow's workflow.json decodes to, each object's keys too, as JSON.parse reads them (its
184
225
  * escapes decoded: what draftProblems and a learned call's run read, and a model node is given). Text a scan of the
185
226
  * stored JSON misses, spelled in \u escapes, is there as it will be read. None for a text that does not parse (the
@@ -197,5 +238,11 @@ export declare const LEARNED_MAX_TURNS = 8;
197
238
  * apply_patch) is never on the list. A model node that names any tool is refused (MODEL_NODE_TOOLS), and a node the
198
239
  * learned runner cannot run (LEARNED_NODES: a judge's). With no list it
199
240
  * fails closed: a draft the DSL refuses only once given an empty list names a tool. */
200
- export declare function draftProblems(dsl: DraftReader, text: string, tools?: readonly string[], gated?: Readonly<Record<string, string>>, deniedBy?: Readonly<Record<string, SettingFrom>>): DraftProblem[];
241
+ /** The MCP tools set to ask a learned call would ask its approver about (`asked`, learnedDraftTools), and whether a card
242
+ * names them all (`fits`: learned-workflow.ts learnedAskFits, the gate's own rule, handed in so it is never copied). */
243
+ export type DraftAsk = {
244
+ readonly asked: readonly string[];
245
+ readonly fits: (asks: readonly string[]) => boolean;
246
+ };
247
+ export declare function draftProblems(dsl: DraftReader, text: string, tools?: readonly string[], gated?: Readonly<Record<string, string>>, deniedBy?: Readonly<Record<string, SettingFrom>>, ask?: DraftAsk): DraftProblem[];
201
248
  export {};
@@ -285,16 +285,19 @@ export const isHeld = (text) => learnedStatus(text) === "pending";
285
285
  * retiredLearned), which take the `status:` line out whole, can edit. One set any other way reads unclear (learnedStatus:
286
286
  * retired), never held or active, and no writer edits it, so a write never leaves part of it behind. The host writes
287
287
  * only one-line statuses (held, retiredLearned). */
288
- export function statusOnOneLine(text) {
288
+ export const statusOnOneLine = (text) => onOneLine(text, "status");
289
+ /** Whether `key`, when the front matter sets it, is one plain line (`key: <value>`, nothing of it on the lines after):
290
+ * statusOnOneLine's rule, for each key the host's writers take out whole (`status`, `retired_from`). */
291
+ function onOneLine(text, key) {
289
292
  const front = frontMatter(text);
290
- if (!front?.has("status"))
293
+ if (!front?.has(key))
291
294
  return true;
292
295
  const lf = text.replace(/\r\n/g, "\n");
293
- const own = lf.slice(4, closeOf(lf)).split("\n").find((line) => line.startsWith("status:"))?.slice("status:".length).trim() ?? "";
296
+ const own = lf.slice(4, closeOf(lf)).split("\n").find((line) => line.startsWith(`${key}:`))?.slice(key.length + 1).trim() ?? "";
294
297
  if (!own || /^[>|]/.test(own) || (/^["']/.test(own) && !closedQuote(own)))
295
298
  return false;
296
299
  // A plain value that wraps onto the next lines reads longer than its own line.
297
- return unquote(own) === front.get("status");
300
+ return unquote(own) === front.get(key);
298
301
  }
299
302
  /** `text`, a SKILL.md or a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
300
303
  * pending` last in its front matter, with LF line ends. Throws on a text with no front matter, which the checker never
@@ -306,20 +309,36 @@ export function held(text) {
306
309
  return `${front.lf.slice(0, front.end)}\nstatus: pending${front.lf.slice(front.end)}`;
307
310
  }
308
311
  /** `text`, a held SKILL.md or draft README.md, as the host leaves it when its owner approves it: its front matter with
309
- * no `status` line, so it is given to every later run. Throws on a text with no front matter. */
312
+ * no `status` or `retired_from` line, so it is given to every later run. Throws on a text with no front matter. */
310
313
  export function released(text) {
311
314
  const front = frontOf(text);
312
315
  if (typeof front === "string")
313
316
  throw new Error(`it cannot be approved: ${front}`);
314
- if (!statusOnOneLine(text))
317
+ // Its status and retired_from are taken out whole, so each must be one plain line; what is left reads back active, or
318
+ // the write fails: never an OK over a skill no run is given.
319
+ if (!statusOnOneLine(text) || !onOneLine(text, "retired_from"))
315
320
  throw new Error("it cannot be approved: its status is not one plain line");
316
- const kept = front.lf.slice(4, front.end).split("\n").filter((line) => !line.startsWith("status:"));
321
+ const kept = front.lf.slice(4, front.end).split("\n").filter((line) => !line.startsWith("status:") && !line.startsWith("retired_from:"));
317
322
  const out = `---\n${kept.join("\n")}${front.lf.slice(front.end)}`;
318
- // What it leaves reads back active, or the approve fails: never an OK over a skill no run is given.
319
323
  if (learnedStatus(out) !== "active")
320
324
  throw new Error(`it cannot be approved: its status would read ${learnedStatus(out)}`);
321
325
  return out;
322
326
  }
327
+ /** The status a retired SKILL.md or draft README.md goes back to when a person restores it (`retired_from`, which its
328
+ * retire recorded), read by the one reader (frontMatter: its quoting, its one-line rule): `active` only when it reads
329
+ * `active` one way, on one plain line; `pending` otherwise, a retire that recorded none or one that reads unclear among
330
+ * them (fail closed: only an approval makes a skill or a draft active). */
331
+ export function retiredFrom(text) {
332
+ return onOneLine(text, "retired_from") && frontMatter(text)?.get("retired_from") === "active" ? "active" : "pending";
333
+ }
334
+ /** Whether a retired SKILL.md or draft README.md can be restored by the host's writer: its front matter reads one way
335
+ * (frontMatter), and its `status` and `retired_from` are each one plain line, the only ones the writer takes out whole.
336
+ * One that is not is refused until it is written so (a restore never edits half a value). */
337
+ export const restorable = (text) => frontMatter(text) !== undefined && statusOnOneLine(text) && onOneLine(text, "retired_from");
338
+ /** `text`, a retired SKILL.md or draft README.md, as the host leaves it when a person restores it: back in the status its
339
+ * retire recorded (retiredFrom), active, or waiting for its owner's OK. Throws on a text whose front matter does not read
340
+ * one way, or whose status is not one plain line (released). */
341
+ export const restoredLearned = (text) => (retiredFrom(text) === "active" ? released(text) : held(released(text)));
323
342
  /** What a SKILL.md or a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
324
343
  * the folder's snapshot, the console's: `pending` while it waits for its owner's OK, `retired` once a person retired
325
344
  * it, `active` when it sets no status or `active`. A front matter that does not read one way, or a status that is none
@@ -334,17 +353,29 @@ export function learnedStatus(text) {
334
353
  const status = front.get("status") ?? "active";
335
354
  return status === "active" || status === "pending" ? status : "retired";
336
355
  }
337
- /** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` last in its front matter
338
- * (any status line before it dropped), so no later run is given it. Throws on a text with no front matter. */
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
+ }
363
+ /** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
364
+ * status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
365
+ * them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
366
+ * matter. */
339
367
  export function retiredLearned(text) {
340
368
  const front = frontOf(text);
341
369
  if (typeof front === "string")
342
370
  throw new Error(`it cannot be retired: ${front}`);
343
- if (!statusOnOneLine(text))
371
+ if (!statusOnOneLine(text) || !onOneLine(text, "retired_from"))
344
372
  throw new Error("it cannot be retired: its status is not one plain line");
345
- const kept = front.lf.slice(4, front.end).split("\n").filter((line) => !line.startsWith("status:"));
346
- const out = `---\n${[...kept, "status: retired"].join("\n")}${front.lf.slice(front.end)}`;
347
- if (!frontMatter(out) || learnedStatus(out) !== "retired")
373
+ // What it goes back to on a restore: active only when it reads active now; anything else (held, or a text read as
374
+ // retired already) is held again (fail closed).
375
+ const from = learnedStatus(text) === "active" ? "active" : "pending";
376
+ const kept = front.lf.slice(4, front.end).split("\n").filter((line) => !line.startsWith("status:") && !line.startsWith("retired_from:"));
377
+ const out = `---\n${[...kept, "status: retired", `retired_from: ${from}`].join("\n")}${front.lf.slice(front.end)}`;
378
+ if (!frontMatter(out) || learnedStatus(out) !== "retired" || retiredFrom(out) !== from)
348
379
  throw new Error("it cannot be retired: its front matter would not read retired");
349
380
  return out;
350
381
  }
@@ -674,6 +705,59 @@ const gatedNodes = (dsl, doc, gated, deniedBy) => dsl.inspectWorkflow(doc).nodes
674
705
  : `This workflow's call node calls ${tool}, which is set to ask, and a workflow's call node can't wait for an approval: set it to allow for this agent.`;
675
706
  return [{ rule: "workflow", detail: `${words} (the call node at ${node.path})` }];
676
707
  });
708
+ /** An MCP tool a learned workflow's call node may run, by its address (`via: "tool"`, `tool: "mcp:<server>/<tool>"`,
709
+ * LS-07): its server's name as a server is named (mcp-probe.ts MCP_SERVER_NAME) and one tool's name in MCP's own
710
+ * charset, never a wildcard. The one rule for it: the tools a draft may name (tools.ts learnedWorkflowTools), the
711
+ * end-of-run prompt that prints them (reflect.ts), and what the grader is told of a draft (grade.ts). */
712
+ export const LEARNED_MCP_TOOL = /^mcp:[a-z][a-z0-9-]{0,31}\/[A-Za-z0-9_][A-Za-z0-9._-]{0,127}$/;
713
+ /** The MCP tools a draft's call nodes run, each once, in the order they come (LS-07): every call node in `doc`, nested
714
+ * ones too, whose tool is an MCP tool's address. Read from the JSON as it is, for the grader's words; never a check. */
715
+ export function draftMcpTools(doc) {
716
+ const found = new Set();
717
+ for (const node of callNodes(doc))
718
+ if (node.via === "tool" && typeof node.tool === "string" && LEARNED_MCP_TOOL.test(node.tool))
719
+ found.add(node.tool);
720
+ return [...found];
721
+ }
722
+ /** Every call node of `doc` (a parsed workflow.json), in document order: only the workflow's node positions, as the
723
+ * DSL's inspection visits them (its root, a chain's steps, a parallel's branches, a map's and a loop's body, a route's
724
+ * branches' bodies, a nested workflow's root), never an object in a call's args, a schema or any other data, however
725
+ * it is shaped. Walked with a stack of its own, never the call stack, so no draft's nesting can throw here. */
726
+ function callNodes(doc) {
727
+ const out = [];
728
+ const asNode = (value) => (value && typeof value === "object" && !Array.isArray(value) ? value : undefined);
729
+ const stack = [asNode(doc)?.root];
730
+ while (stack.length) {
731
+ const node = asNode(stack.pop());
732
+ if (!node)
733
+ continue;
734
+ if (node.node === "call")
735
+ out.push(node);
736
+ const children = node.node === "chain" && Array.isArray(node.steps) ? node.steps
737
+ : node.node === "parallel" && Array.isArray(node.branches) ? node.branches
738
+ : (node.node === "map" || node.node === "loop") ? [node.body]
739
+ : node.node === "route" && asNode(node.branches) ? Object.values(node.branches).map((branch) => asNode(branch)?.body)
740
+ : node.node === "workflow" ? [asNode(node.workflow)?.root]
741
+ : [];
742
+ for (let i = children.length - 1; i >= 0; i--)
743
+ stack.push(children[i]);
744
+ }
745
+ return out;
746
+ }
747
+ /** The call nodes of a learned workflow (`doc`, its parsed workflow.json, nested ones too) whose tool is an MCP tool
748
+ * (LEARNED_MCP_TOOL) that `priceOf` gives no price for (mcp-probe.ts McpPrices: none declared). Such a tool runs "not
749
+ * metered", outside the run's cost and cap (mcp-gateway.ts), so a learned workflow that calls one unattended waits for
750
+ * its owner's OK whatever the grade (LS-07): a structural fact, held in code. Each step once, in order. */
751
+ export function unpricedCalls(doc, priceOf) {
752
+ return callNodes(doc).flatMap((node) => {
753
+ if (node.via !== "tool" || typeof node.tool !== "string" || !LEARNED_MCP_TOOL.test(node.tool) || priceOf(node.tool) !== undefined)
754
+ return [];
755
+ const [server, tool] = node.tool.slice("mcp:".length).split("/");
756
+ return [{ label: typeof node.label === "string" ? node.label : "(unnamed)", tool, server }];
757
+ });
758
+ }
759
+ /** Why a learned workflow that calls `call` waits for its owner's OK, in a person's words. */
760
+ export const unpricedLine = (call) => `its step ${call.label} calls ${call.tool} on ${call.server}, which has no price here, so it runs outside the run's cost and cap`;
677
761
  /** Every string a learned workflow's workflow.json decodes to, each object's keys too, as JSON.parse reads them (its
678
762
  * escapes decoded: what draftProblems and a learned call's run read, and a model node is given). Text a scan of the
679
763
  * stored JSON misses, spelled in \u escapes, is there as it will be read. None for a text that does not parse (the
@@ -744,13 +828,7 @@ const issuesOf = (dsl, doc, tools) => {
744
828
  const valid = dsl.validateWorkflow(doc, { executeCode: false, ...(tools ? { tools } : {}) });
745
829
  return valid.ok ? [] : valid.issues;
746
830
  };
747
- /** Why `workflows/<name>/workflow.json` is not a draft the host can run; empty when it is. The DSL's own
748
- * `validateWorkflow` judges it, with `executeCode: false` so no code it holds is run (a code node is syntax-checked),
749
- * and with `tools`, so a node that names a tool outside them is its error: a harness's own tool (Bash, exec_command,
750
- * apply_patch) is never on the list. A model node that names any tool is refused (MODEL_NODE_TOOLS), and a node the
751
- * learned runner cannot run (LEARNED_NODES: a judge's). With no list it
752
- * fails closed: a draft the DSL refuses only once given an empty list names a tool. */
753
- export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}) {
831
+ export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}, ask) {
754
832
  let doc;
755
833
  try {
756
834
  doc = JSON.parse(text);
@@ -772,6 +850,11 @@ export function draftProblems(dsl, text, tools, gated = {}, deniedBy = {}) {
772
850
  const path = doc?.output?.path;
773
851
  if (typeof path !== "string" || !path)
774
852
  out.push({ rule: "workflow", detail: LEARNED_OUTPUT_PATH });
853
+ // Its MCP tools set to ask, on one approval card per learned call (#2424): a card that can't name them all is refused
854
+ // at the gate at every call, so the draft is refused here, in the gate's words.
855
+ const asks = ask ? draftMcpTools(doc).filter((tool) => ask.asked.includes(tool)) : [];
856
+ if (ask && asks.length && !ask.fits(asks))
857
+ out.push({ rule: "workflow", detail: `its approval card can't name all ${asks.length} MCP tools it would call that are set to ask: set some of them to allow or deny for this agent.` });
775
858
  // A composed workflow node's child too: its output is the value at its own output.path, or it fails the same way.
776
859
  for (const node of dsl.inspectWorkflow(doc).nodes) {
777
860
  if (node.kind !== "workflow")
@@ -0,0 +1,18 @@
1
+ /** The journal entry a learned_workflow call keeps beside itself: `{ call, workflow, nodes }`, its call's id, the
2
+ * workflow's name and each of its nodes that ran (LearnedNode). */
3
+ export declare const LEARNED_NODES = "agentrun.learned_nodes";
4
+ /** The most nodes a call keeps: a map over a long list runs its body once per item. */
5
+ export declare const LEARNED_NODES_MAX = 64;
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; 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. */
11
+ export type LearnedNode = {
12
+ readonly label: string;
13
+ readonly kind: string;
14
+ readonly status: string;
15
+ readonly duration_ms: number;
16
+ readonly model?: string;
17
+ readonly tier?: string;
18
+ };
@@ -0,0 +1,8 @@
1
+ // What a learned_workflow call keeps of its workflow's run beside itself in the run's journal: each node that ran, as
2
+ // the workflow DSL ended it (learned-workflow.ts runLearned writes it; store-reads/journal.ts runTimeline puts it on the
3
+ // call's result row as `learned_nodes`). Its own module, so the timeline's reader needs none of the tool's imports.
4
+ /** The journal entry a learned_workflow call keeps beside itself: `{ call, workflow, nodes }`, its call's id, the
5
+ * workflow's name and each of its nodes that ran (LearnedNode). */
6
+ export const LEARNED_NODES = "agentrun.learned_nodes";
7
+ /** The most nodes a call keeps: a map over a long list runs its body once per item. */
8
+ export const LEARNED_NODES_MAX = 64;
@@ -1,4 +1,5 @@
1
1
  import { type ToolRegistration } from "@earendil-works/pi-durable";
2
+ import { type LearnedNode } from "./learned-nodes.js";
2
3
  import { type LearnedWorkflow } from "./learning.js";
3
4
  import type { ModelRef } from "./model.js";
4
5
  import { type Ledger } from "./paid-calls.js";
@@ -26,11 +27,12 @@ export declare const learnedApprovedTools: (card: Readonly<Record<string, unknow
26
27
  * one that does not read. The run's gate asks about them before the workflow's call runs (adapter-run-spec.ts). */
27
28
  export declare function learnedMcpTools(workflow: string): Promise<string[]>;
28
29
  export declare const LEARNED_WORKFLOW_TOOL = "learned_workflow";
29
- /** One line of a learned workflow's output for its row: an object's fields as `name value`, each value whole or, when
30
- * longer than VALUE_MAX, only as its size, and whole fields only until LINE_MAX. Nothing is ever cut inside a value:
31
- * the timeline redacts the line as it says it (its summary's words), and its redactor matches a held value only whole,
32
- * so a cut value could leave a prefix it would not find. Newlines are flattened, so the one line it keeps holds every
33
- * field. An output already cut for the model (learnedText) says so. */
30
+ /** One line of a learned workflow's output for its row: an object's fields as `name value`, and a text output (learnedOutput
31
+ * hands one back as it is, #2412) its lines, each value or line whole or, when longer than VALUE_MAX, only as its size,
32
+ * and whole ones only until LINE_MAX. Nothing is ever cut inside a value or a line: the timeline redacts the line as it
33
+ * says it (its summary's words), and its redactor matches a held value only whole, so a cut one could leave a prefix it
34
+ * would not find. Newlines are flattened, so the one line it keeps holds every part. An output already cut for the
35
+ * model (learnedText) says so. */
34
36
  export declare function outputLine(text: string): string | undefined;
35
37
  /** 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
36
38
  * another harness the session's port (port-models.ts). */
@@ -40,8 +42,8 @@ type RunModels = {
40
42
  completeSimple(model: never, context: never, options?: never): Promise<unknown>;
41
43
  };
42
44
  export type LearnedWorkflowRun = {
43
- /** The run's learned workflows (learning.ts chooseWorkflows): on the server those its pin names (pinnedWorkflows), on
44
- * the runner those its claim's seed lay chose (runner/learning-seed.ts). */
45
+ /** The run's learned workflows (learning.ts chooseWorkflows): those its claim's seed lay chose
46
+ * (runner/learning-seed.ts). */
45
47
  workflows: readonly LearnedWorkflow[];
46
48
  /** The tools the agent's revision grants: a workflow's call node may name only those a call node runs here
47
49
  * (tools.ts learnedWorkflowTools), and of those, none `plane` resolves unavailable. */
@@ -53,6 +55,10 @@ export type LearnedWorkflowRun = {
53
55
  models: RunModels;
54
56
  /** The run's model a model node of `tier` runs on: the tier's, else the run's own. */
55
57
  modelOf(tier: string | undefined): ModelRef | undefined;
58
+ /** 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
59
+ * (its `model`) when modelOf answers with the session's own port (PORT_PROVIDER), whose model id names no model. A
60
+ * ref of another provider (a tier's own model) is named by its model id. */
61
+ modelName?(tier: string | undefined): string | undefined;
56
62
  /** The `llm` tool's completion, for a call node that names it. */
57
63
  complete?: Complete;
58
64
  /** 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
@@ -79,7 +85,7 @@ export type LearnedWorkflowRun = {
79
85
  /** The most characters of a learned workflow's output its answer holds, monid's bound (monid.ts CLIP): within the
80
86
  * host's result bound, which each CLI is told to pass whole (host-bounds.test). */
81
87
  export declare const LEARNED_CLIP = 60000;
82
- /** `text`, a learned workflow's output as JSON, cut at LEARNED_CLIP characters (never inside a surrogate pair), saying
88
+ /** `text`, a learned workflow's output as its tool hands it back (learnedOutput), cut at LEARNED_CLIP characters (never inside a surrogate pair), saying
83
89
  * so. */
84
90
  export declare function learnedText(text: string): string;
85
91
  /** What a learned workflow's model node is refused with when it names a tool: it runs in a session of its own here.
@@ -87,15 +93,23 @@ export declare function learnedText(text: string): string;
87
93
  export declare const NODE_TOOLS_REFUSED = "a learned workflow's model node runs without tools here";
88
94
  /** The tool's description, sent with every model request of the run, so it holds what a model needs to call it right and
89
95
  * no more: one line of what the tool does (one call, by name, a JSON input with the listed fields, `*` marking a required
90
- * one; what it answers), then each workflow on a line of its own (workflowLine): its name, its input's fields and the
91
- * line its README says what it does with. */
96
+ * one; what it answers: a text output as it is, to reply with unchanged, since a model handed it otherwise writes its own
97
+ * reply around it and a format the workflow's last node wrote is lost, #2412), then each workflow on a line of its own
98
+ * (workflowLine): its name, its input's fields and the line its README says what it does with. */
92
99
  export declare const learnedWorkflowDescription: (workflows: readonly LearnedWorkflow[]) => string;
100
+ /** 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
101
+ * 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
102
+ * reach the model as lines; else JSON. */
103
+ export declare function learnedOutput(output: unknown): string;
93
104
  /** The run's `learned_workflow` tool over `run.workflows`. */
94
105
  export declare function learnedWorkflowTool(run: LearnedWorkflowRun): ToolRegistration;
95
- /** `flow` run on `input` for `run`: its output as JSON, or why it did not run. Never throws, but on an abort. `ledger`:
96
- * the tool call's, which each call node's paid requests are booked under, as a call of its own within it. */
97
- export declare function runLearned(run: LearnedWorkflowRun, flow: LearnedWorkflow, input: unknown, signal?: AbortSignal, ledger?: Ledger): Promise<{
106
+ /** `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
107
+ * LEARNED_NODES_MAX), none for one refused before any node ran. Never throws, but on an abort. `ledger`: the tool call's,
108
+ * which each call node's paid requests are booked under, as a call of its own within it. `nodes`: where each node is
109
+ * added as it ends, the caller's to keep when the call is aborted (and so throws) part way. */
110
+ export declare function runLearned(run: LearnedWorkflowRun, flow: LearnedWorkflow, input: unknown, signal?: AbortSignal, ledger?: Ledger, nodes?: LearnedNode[]): Promise<{
98
111
  text: string;
99
112
  isError: boolean;
113
+ nodes: LearnedNode[];
100
114
  }>;
101
115
  export {};