@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
@@ -174,10 +174,12 @@ export async function readSession(file, source, { turns: keep = true, seen } = {
174
174
  const provider = {};
175
175
  const current = { keyed: new Map(), seen: seen ?? new Set(), copied: new Set() };
176
176
  const codex = { events: false, held: [], records: false, responses: new Set(), items: new Map(), results: new Map() };
177
+ const titles = { summaries: [], uuids: new Set() };
177
178
  const add = (turn, index = turns.length) => {
178
179
  if (turn.role === "user") {
179
180
  session.users += 1;
180
181
  session.firstPrompt ??= turn.text;
182
+ session.titleText ??= personsWords(turn.text);
181
183
  }
182
184
  if (keep)
183
185
  turns.splice(index, 0, turn);
@@ -199,7 +201,7 @@ export async function readSession(file, source, { turns: keep = true, seen } = {
199
201
  continue;
200
202
  const at = timeOf(value.timestamp);
201
203
  // A copy of a record read already moves no time: its time was counted where it was first read.
202
- const copy = record(value, at ?? last ?? 0, session, { add, names, turns, priced, provider, current, codex }) === false;
204
+ const copy = record(value, at ?? last ?? 0, session, { add, names, turns, priced, provider, current, codex, titles }) === false;
203
205
  if (copy)
204
206
  session.copies += 1;
205
207
  if (at !== undefined && !copy) {
@@ -218,6 +220,9 @@ export async function readSession(file, source, { turns: keep = true, seen } = {
218
220
  codex.held.forEach(({ index, turn }, k) => add(turn, index + k));
219
221
  if (!session.id)
220
222
  session.id = source === "pi" ? basename(file, ".jsonl").split("_").pop() : basename(file, ".jsonl");
223
+ const sourceTitle = titles.custom ?? titles.ai ?? titles.summaries.findLast(({ leaf }) => leaf === undefined || titles.uuids.has(leaf))?.title;
224
+ if (sourceTitle)
225
+ session.sourceTitle = sourceTitle;
221
226
  if (first !== undefined)
222
227
  session.startedAt = new Date(first).toISOString();
223
228
  if (last !== undefined)
@@ -242,14 +247,51 @@ export function mostEffortOf(turns) {
242
247
  return most;
243
248
  }
244
249
  const INTERRUPTED = /^\[Request interrupted by user/;
250
+ // The titles Claude Code writes into a session's file, each again as it changes, and the field each holds it in.
251
+ const CLAUDE_TITLES = new Map([
252
+ ["custom-title", "customTitle"],
253
+ ["ai-title", "aiTitle"],
254
+ ["summary", "summary"],
255
+ ]);
256
+ /** One of Claude Code's title records: kept by kind, the latest of each. A summary names the last message of the
257
+ * conversation it titles (leafUuid), which can be another session's: held until the file's end. */
258
+ function titleRecord(value, session, titles) {
259
+ // As written: the cut matches a key or a passphrase as the source wrote it, so the title is put on one line after it.
260
+ const title = str(value[CLAUDE_TITLES.get(value.type)])?.trim();
261
+ if (!title || (str(value.sessionId) && value.sessionId !== session.id))
262
+ return;
263
+ if (value.type === "custom-title")
264
+ titles.custom = title;
265
+ else if (value.type === "ai-title")
266
+ titles.ai = title;
267
+ else
268
+ titles.summaries.push({ title, ...(str(value.leafUuid) ? { leaf: value.leafUuid } : {}) });
269
+ }
270
+ // What Claude Code writes into a user message for the person's slash command (/clear, /model, /init, /resume …): the
271
+ // command's name, message and arguments, each in its own element, then its output and the preamble it puts before a
272
+ // local command's output. Only these elements, whole: a prompt the person wrote around them is theirs.
273
+ const CLI_ELEMENT = /<(command-name|command-message|command-args|local-command-stdout|local-command-stderr)>[\s\S]*?<\/\1>/g;
274
+ const CLI_PREAMBLE = /^Caveat: The messages below were generated by the user while running local commands\b/;
275
+ /** The person's own words in a user message's text, as they wrote them (spaces and lines kept, so a cut still matches
276
+ * a secret in them): none when the CLI wrote all of it (a slash command, its output, its preamble), or when there are
277
+ * no words at all. */
278
+ export function personsWords(text) {
279
+ const words = text.replace(CLI_ELEMENT, " ").trim();
280
+ const line = words.replace(/\s+/g, " ");
281
+ return line && !CLI_PREAMBLE.test(line) && !INTERRUPTED.test(line) ? words : undefined;
282
+ }
245
283
  /** Claude Code's record; false for one read already (the import's earlier file, or this file's own repeat). */
246
- function claudeRecord(value, at, session, { add, names, current }) {
284
+ function claudeRecord(value, at, session, { add, names, current, titles }) {
247
285
  if (!session.id && str(value.sessionId))
248
286
  session.id = value.sessionId;
249
287
  if (!session.cwd && str(value.cwd))
250
288
  session.cwd = value.cwd;
251
289
  if (value.isSidechain === true)
252
290
  session.child = true;
291
+ if (CLAUDE_TITLES.has(value.type))
292
+ return titleRecord(value, session, titles);
293
+ if (str(value.uuid))
294
+ titles.uuids.add(value.uuid);
253
295
  if (value.type === "cost-state") {
254
296
  // The last one is the session's: unknown when the CLI could not price a model it used.
255
297
  session.costUsd = typeof value.totalCostUSD === "number" && Number.isFinite(value.totalCostUSD) && value.totalCostUSD >= 0 && value.hasUnknownModelCost !== true ? value.totalCostUSD : undefined;
package/dist/import.d.ts CHANGED
@@ -131,11 +131,11 @@ export declare function transcriptOf(session: Session, cut: (value: unknown) =>
131
131
  };
132
132
  /** The secrets this server made and keeps, by value: its API token and its sign-in sessions' secret (still files beside the
133
133
  * store), and its webhook's signing secret (`whsec_...`; webhooks.ts) and every value a trigger source keeps sealed, as
134
- * store rows (server-secrets-store.ts), opened with the seal key of `env`, which the caller has (a dry run over a store that
135
- * keeps no secret has none, and does not ask); each signing secret's key in every spelling too. One pasted into a
134
+ * store rows (server-secrets-store.ts), opened with the seal key of `env`, which the caller has (a dry run over a store
135
+ * that keeps no secret has none, and does not ask); each signing secret's key in every spelling too. One pasted into a
136
136
  * session is this server's own, so an import cuts it wherever it is, as it cuts the environment's keys. Not among them: a key-shaped value this server did not make (a
137
137
  * `whsec_` from elsewhere). The per-run door token is gone (the runner cutover deleted it). A sealed value that does not
138
- * open is said to `say`: the import goes on, and does not cut it. */
138
+ * open is said to `say` (the webhook's secret once, naming the data directory): the import goes on, and does not cut it. */
139
139
  export declare function ownSecrets(store: {
140
140
  triggerSettings: Pick<Store["triggerSettings"], "get" | "put" | "removeScope">;
141
141
  flush(): Promise<void>;
package/dist/import.js CHANGED
@@ -386,9 +386,12 @@ function merged(parts) {
386
386
  // Known only when each file's is: a file whose spending is unknown (an unpriced model, no cost written) leaves the
387
387
  // session's unknown, never a part of it stored as the whole.
388
388
  const costUsd = priced.length < parts.length ? undefined : first.source === "claude-code" ? Math.max(...priced) : priced.reduce((n, cost) => n + cost, 0);
389
- const { model: _model, startedAt: _start, endedAt: _end, costUsd: _cost, firstPrompt: _prompt, effort: _effort, ...rest } = first;
389
+ const { model: _model, startedAt: _start, endedAt: _end, costUsd: _cost, firstPrompt: _prompt, sourceTitle: _sourceTitle, titleText: _title, effort: _effort, ...rest } = first;
390
390
  const model = last.model ?? first.model;
391
391
  const firstPrompt = ordered.find((part) => part.firstPrompt !== undefined)?.firstPrompt;
392
+ // The session's title as its latest file wrote it, and the person's first words as its first file has them.
393
+ const sourceTitle = ordered.findLast((part) => part.sourceTitle !== undefined)?.sourceTitle;
394
+ const titleText = ordered.find((part) => part.titleText !== undefined)?.titleText;
392
395
  return {
393
396
  ...rest,
394
397
  ...(model ? { model } : {}),
@@ -397,6 +400,8 @@ function merged(parts) {
397
400
  state: last.state,
398
401
  ...(costUsd !== undefined ? { costUsd } : {}),
399
402
  ...(firstPrompt !== undefined ? { firstPrompt } : {}),
403
+ ...(sourceTitle !== undefined ? { sourceTitle } : {}),
404
+ ...(titleText !== undefined ? { titleText } : {}),
400
405
  turns,
401
406
  users: sum("users"),
402
407
  activeMs: sum("activeMs"),
@@ -783,13 +788,30 @@ async function revisionFor(store, agentId, source, files, model, cut) {
783
788
  const id = randomUUID();
784
789
  return { id, create: { id, kind: "agentic", body, skills, note } };
785
790
  }
791
+ /** An imported run's title, whole: the source's own (Claude Code's), else the person's first words, else where the
792
+ * session ran ("Session in billing-api"), never a CLI's command markup. A folder a key touches (as `keptName` judges it,
793
+ * a key across the folder and its parent among them) is not named at all: the cut of the title matches only a whole key,
794
+ * so the piece of one the folder holds would be left in it. */
795
+ function runTitleOf(session, cut) {
796
+ const generic = `${session.source} session`;
797
+ if (session.sourceTitle !== undefined)
798
+ return session.sourceTitle;
799
+ if (session.titleText !== undefined)
800
+ return session.titleText;
801
+ const cwd = session.cwd ?? "";
802
+ const parts = cwd.split("/");
803
+ const last = parts.findLastIndex((segment) => segment !== "");
804
+ if (last < 0)
805
+ return generic;
806
+ return touchedSegments(cwd, cut).includes(last) ? generic : `Session in ${parts[last]}`;
807
+ }
786
808
  /** The secrets this server made and keeps, by value: its API token and its sign-in sessions' secret (still files beside the
787
809
  * store), and its webhook's signing secret (`whsec_...`; webhooks.ts) and every value a trigger source keeps sealed, as
788
- * store rows (server-secrets-store.ts), opened with the seal key of `env`, which the caller has (a dry run over a store that
789
- * keeps no secret has none, and does not ask); each signing secret's key in every spelling too. One pasted into a
810
+ * store rows (server-secrets-store.ts), opened with the seal key of `env`, which the caller has (a dry run over a store
811
+ * that keeps no secret has none, and does not ask); each signing secret's key in every spelling too. One pasted into a
790
812
  * session is this server's own, so an import cuts it wherever it is, as it cuts the environment's keys. Not among them: a key-shaped value this server did not make (a
791
813
  * `whsec_` from elsewhere). The per-run door token is gone (the runner cutover deleted it). A sealed value that does not
792
- * open is said to `say`: the import goes on, and does not cut it. */
814
+ * open is said to `say` (the webhook's secret once, naming the data directory): the import goes on, and does not cut it. */
793
815
  export async function ownSecrets(store, data, env, say = () => { }) {
794
816
  if (!sealKeyOf(env[SEAL_KEY_ENV]))
795
817
  throw new Error(`the server's own secrets open only under its seal key (${SEAL_KEY_ENV}), and none was handed`);
@@ -867,6 +889,9 @@ export async function runImport(store, plan, options) {
867
889
  // Every file of it read: one holding only copies adds no records, but its subagents' folder is read with the rest.
868
890
  const searched = [];
869
891
  let read;
892
+ // The session's own title as the file written last holds it: a moved copy's /rename too, though its turns are
893
+ // copies the import leaves out.
894
+ let titled;
870
895
  let changed = false;
871
896
  for (const { file } of files) {
872
897
  const stats = await stat(file).catch(() => null);
@@ -874,6 +899,8 @@ export async function runImport(store, plan, options) {
874
899
  if (!part || !stats)
875
900
  continue;
876
901
  searched.push(part);
902
+ if (part.sourceTitle !== undefined && (!titled || stats.mtimeMs >= titled.at))
903
+ titled = { at: stats.mtimeMs, title: part.sourceTitle };
877
904
  // A file of it holding only copies adds nothing to it.
878
905
  if (ownless(part)) {
879
906
  report.skipped.push({ what: file, why: "holds only records of sessions imported already", kind: "copies" });
@@ -887,6 +914,8 @@ export async function runImport(store, plan, options) {
887
914
  if (!read)
888
915
  continue;
889
916
  const session = merged(parts);
917
+ if (titled)
918
+ session.sourceTitle = titled.title;
890
919
  // A file of it changed since the scan above (a session still being written): what it holds now, read through
891
920
  // secretlint again before any of it is cut.
892
921
  if (changed)
@@ -908,7 +937,9 @@ export async function runImport(store, plan, options) {
908
937
  if (estimate !== undefined)
909
938
  Object.assign(metrics, { costUsdEst: estimate, costBasis: "catalog" });
910
939
  const answer = session.turns.findLast((t) => t.role === "assistant" && t.text)?.text;
911
- const title = clip(text(session.firstPrompt ?? `${session.source} session`), 120);
940
+ // Cut, then put on one line and clipped: a key the clip cut short, or a passphrase whose spaces were changed, would
941
+ // match no cut.
942
+ const title = clip(text(runTitleOf(session, text)).replace(/\s+/g, " ").trim(), 120);
912
943
  await store.importRun({
913
944
  id: randomUUID(),
914
945
  agentId: project.agentId,
@@ -918,7 +949,7 @@ export async function runImport(store, plan, options) {
918
949
  // An imported session is ended as it ended: a plain completion reads as 'ended', a stop or a failure as its own.
919
950
  state: session.state === "completed" ? "ended" : session.state,
920
951
  ...(session.costUsd !== undefined ? { costUsd: session.costUsd } : {}),
921
- ...((answer ?? session.firstPrompt) ? { summary: text(answer ?? session.firstPrompt) } : {}),
952
+ ...((answer ?? session.titleText) ? { summary: text(answer ?? session.titleText) } : {}),
922
953
  metrics,
923
954
  startedAt: Date.parse(session.startedAt ?? epoch0),
924
955
  endedAt: Date.parse(session.endedAt ?? session.startedAt ?? epoch0),
package/dist/index.d.ts CHANGED
@@ -3,6 +3,4 @@ export { serveWithRunner } from "./runner/beside.js";
3
3
  export { SERVER_LOCK, type ServerLock, ServerLockHeldError, takeServerLock } from "./server-lock.js";
4
4
  export { ApiError, ERROR_STATUS, type ErrorCode } from "./errors.js";
5
5
  export { defaultMaxRuns, type Health } from "./host.js";
6
- export { banner, type TokenSource } from "./print.js";
7
- export { ASK_TOOL, BOUND_TOOLS, TOOLS, type ToolEntry } from "./tools.js";
8
- export type { FauxHelpers } from "./model.js";
6
+ export { BOUND_TOOLS, TOOLS } from "./tools.js";
package/dist/index.js CHANGED
@@ -3,5 +3,4 @@ export { serveWithRunner } from "./runner/beside.js";
3
3
  export { SERVER_LOCK, ServerLockHeldError, takeServerLock } from "./server-lock.js";
4
4
  export { ApiError, ERROR_STATUS } from "./errors.js";
5
5
  export { defaultMaxRuns } from "./host.js";
6
- export { banner } from "./print.js";
7
- export { ASK_TOOL, BOUND_TOOLS, TOOLS } from "./tools.js";
6
+ export { BOUND_TOOLS, TOOLS } from "./tools.js";
@@ -34,7 +34,7 @@ export declare function redactedAnswer(text: string, secrets: readonly string[])
34
34
  * included (a dictionary field can be keyed by anything a run wrote), its shape kept. Two names of one object that come
35
35
  * out the same would merge one value over the other: that object is withheld whole, as "[redacted]". */
36
36
  export declare function redactedOutput(value: unknown, secrets: readonly string[]): unknown;
37
- /** What a thinking or text block may show while it streams (pi-durable-agent's `redactLive`): what has streamed so far,
37
+ /** What a thinking or text block may show while it streams: what has streamed so far,
38
38
  * redacted by the same rule as redacted(), less a fixed tail held back until the block ends, when its settled row
39
39
  * replaces this one whole. A key whose head has streamed but not its tail cannot be found by any redactor, and a key
40
40
  * ending inside the tail would show its head. So the tail is the most a held value takes in its widest form (6 times it,
@@ -44,7 +44,7 @@ function detailOf(rest) {
44
44
  return (text.split(/(?<=[.!?])\s/)[0] ?? "").slice(0, 200).replace(/[.\s]+$/, "");
45
45
  }
46
46
  /** The most of a run's error or a tool's output serve ever shows: a Timeline row's text, cut at 2000 characters
47
- * (pi-durable-agent's CAPS.text; a summary and a tool result's preview at 500), which the error box reads too. */
47
+ * (`CAPS.text` in timeline/; a summary and a tool result's preview at 500), which the error box reads too. */
48
48
  const SHOWN = 2000;
49
49
  /** `text`, a run's error as serve shows it, with no held secret in it: the one rule learning's checker uses
50
50
  * (learn/secrets.ts redactSecrets: each value as written, JSON-escaped, base64 at each offset, hex and percent-encoded,
@@ -128,7 +128,7 @@ export function redactedOutput(value, secrets) {
128
128
  }
129
129
  return value;
130
130
  }
131
- /** What a thinking or text block may show while it streams (pi-durable-agent's `redactLive`): what has streamed so far,
131
+ /** What a thinking or text block may show while it streams: what has streamed so far,
132
132
  * redacted by the same rule as redacted(), less a fixed tail held back until the block ends, when its settled row
133
133
  * replaces this one whole. A key whose head has streamed but not its tail cannot be found by any redactor, and a key
134
134
  * ending inside the tail would show its head. So the tail is the most a held value takes in its widest form (6 times it,
@@ -1,5 +1,5 @@
1
1
  import { type LearnedNote } from "./notes.js";
2
- import { type DraftAsk, type DraftDryRun, type DraftReader } from "./skills.js";
2
+ import { type DraftAsk, type DraftDecisions, type DraftDryRun, type DraftReader } from "./skills.js";
3
3
  /** Byte caps (UTF-8) and counts. Over a cap is refused, never cut. */
4
4
  export declare const CAPS: Readonly<{
5
5
  /** One note's file. */
@@ -24,7 +24,7 @@ export declare const CAPS: Readonly<{
24
24
  workflows: 1;
25
25
  }>;
26
26
  /** The rule a problem breaks. SPEC.md lists each. */
27
- export type Rule = "too_many_files" | "outside" | "file_name" | "file_mode" | "encoding" | "edited" | "deleted" | "exists" | "too_large" | "too_many_notes" | "invisible_unicode" | "secret_shape" | "secret_value" | "note" | "status" | "supersedes" | "index_full" | "skill" | "skill_outcome" | "too_many_skills" | "workflow" | "too_many_workflows" | "no_tool_list" | "executable_node" | "skill_front_matter" | "skill_status";
27
+ export type Rule = "too_many_files" | "outside" | "file_name" | "file_mode" | "encoding" | "edited" | "deleted" | "exists" | "too_large" | "too_many_notes" | "invisible_unicode" | "secret_shape" | "secret_value" | "note" | "status" | "supersedes" | "index_full" | "skill" | "skill_outcome" | "too_many_skills" | "workflow" | "too_many_workflows" | "no_tool_list" | "executable_node" | "skill_front_matter" | "skill_status" | "duplicate";
28
28
  /** One problem with what a run proposed, printable as it is. */
29
29
  export type Problem = {
30
30
  readonly rule: Rule;
@@ -43,9 +43,12 @@ export type Change = {
43
43
  };
44
44
  /** The folder a proposal is checked against (the run's seed, or main at merge time): every path it holds, and its active
45
45
  * notes. */
46
+ /** What a proposal is checked against: every path at the seed's top, its active notes, and `rules`, when the caller read
47
+ * the active notes' texts, each one's rule (notes.ts ruleOf) to its file: a new note of the same rule is a duplicate. */
46
48
  export type Base = {
47
49
  readonly files: Iterable<string>;
48
50
  readonly active: readonly LearnedNote[];
51
+ readonly rules?: ReadonlyMap<string, string>;
49
52
  };
50
53
  /** A new note that passed, with its whole text. */
51
54
  export type ProposedNote = LearnedNote & {
@@ -69,8 +72,14 @@ export type CheckInput = {
69
72
  readonly ask?: DraftAsk;
70
73
  /** Where each of `gated`'s denies was set (this agent's settings or this server's), for the refusal's words. */
71
74
  readonly deniedBy?: Readonly<Record<string, "agent" | "server" | "default">>;
75
+ /** False for a run of a revision that says `learning: "notes"`: a workflow draft it gives is left out (rule `workflow`,
76
+ * NOTES_ONLY), and its notes and skill go on. */
77
+ readonly workflows?: false;
72
78
  /** The workflow DSL a draft is read with; a proposal that holds a draft is checked with it, never without. */
73
79
  readonly dsl?: DraftReader;
80
+ /** The decision providers a draft's decision nodes may ask, and the gate's setting of each (learn/skills.ts
81
+ * DraftDecisions, LS-07). Without them, a draft with a decision node is refused. */
82
+ readonly decisions?: DraftDecisions;
74
83
  /** Each draft's dry run (skills.ts draftDryRun), by its workflow.json's path: one that failed is refused, rule
75
84
  * `workflow`, when the draft has no other problem. A draft with none given is checked without one. */
76
85
  readonly dryRuns?: Readonly<Record<string, DraftDryRun>>;
@@ -4,7 +4,7 @@
4
4
  // here with its bytes; nothing the checker refuses is ever written to git. Every problem it reports is printable: its
5
5
  // path and detail are cut of the host's secrets and of text shaped like one, and a field over PRINT_MAX is redacted whole.
6
6
  import { hiddenCharacter } from "./invisible.js";
7
- import { INDEX_FILE, INDEX_LINES, NOTE_FILE, parseNoteFile } from "./notes.js";
7
+ import { INDEX_FILE, INDEX_LINES, NOTE_FILE, parseNoteFile, ruleOf } from "./notes.js";
8
8
  import { learnedSecretShapes, redactLearned, valueMatcher } from "./secrets.js";
9
9
  import { draftProblems, decodedStrings, DECODED_DEPTH, DRY_RUN_FAILED, frontKeys, frontValues, LEARNED_KEYS, learnedName, learnedPlace, setsStatus, skillProblems, WORKFLOWS_DIR } from "./skills.js";
10
10
  /** The most the host adds to a run's note as it merges it: `origin: you` and `status: pending`, a front matter line
@@ -34,6 +34,8 @@ export const CAPS = Object.freeze({
34
34
  workflows: 1,
35
35
  });
36
36
  const MODES = { "120000": "a link: never followed", "040000": "a folder: nothing in it was read" };
37
+ /** Why a draft from a run of a revision that learns notes alone (`learning: "notes"`) is left out. */
38
+ const NOTES_ONLY = "this agent learns notes and skills alone (learning: \"notes\"): it keeps no workflow draft";
37
39
  /** Why a run's path is none of what it may propose. */
38
40
  const OUTSIDE = "a run proposes notes at the folder's top, skills/<name>/SKILL.md, and workflows/<name>/ with its workflow.json and README.md";
39
41
  /** `problem` as it may be printed: its path and detail cut of `values` and of every shape learning refuses, a bank's
@@ -137,6 +139,8 @@ function learnedChecked(change, place, refused, input, add) {
137
139
  return add("file_name", place.kind === "skill" ? "a skill's name is lowercase letters, digits and single dashes, at most 64" : "a workflow's name is lowercase letters, digits, dashes and underscores, at most 64, starting with a letter or digit", path);
138
140
  if (change.status === "deleted")
139
141
  return add("deleted", "a run never deletes a skill or a workflow", path);
142
+ if (place.kind === "workflow" && input.workflows === false)
143
+ return add("workflow", NOTES_ONLY, path);
140
144
  if (change.mode !== undefined && change.mode !== "100644")
141
145
  return add("file_mode", MODES[change.mode] ?? "not a regular file: never read", path);
142
146
  const size = change.size ?? change.bytes?.length ?? 0;
@@ -153,7 +157,7 @@ function learnedChecked(change, place, refused, input, add) {
153
157
  if (place.kind === "workflow") {
154
158
  if (!input.dsl)
155
159
  throw new TypeError(`${path}: a workflow draft is read with the workflow DSL, which was not given`);
156
- const problems = draftProblems(input.dsl, text, input.tools, input.gated, input.deniedBy, input.ask);
160
+ const problems = draftProblems(input.dsl, text, input.tools, input.gated, input.deniedBy, input.ask, input.decisions);
157
161
  for (const { rule, detail } of problems)
158
162
  add(rule, detail, path);
159
163
  // A draft the checks pass whose dry run failed: its wiring breaks at run time, before any node is paid for.
@@ -224,7 +228,9 @@ export function checkProposal(input) {
224
228
  }
225
229
  const changes = given.slice(0, CAPS.changes);
226
230
  const base = new Set(input.base.files);
227
- const notes = [];
231
+ // The new notes that pass their own checks, in the answer's order. Which of them is a duplicate is settled after,
232
+ // with the merge's checks (settled below).
233
+ const candidates = [];
228
234
  const skills = [];
229
235
  const workflows = new Set();
230
236
  const added = [];
@@ -258,7 +264,7 @@ export function checkProposal(input) {
258
264
  return;
259
265
  if (["status", "superseded_by", "retired_from", "origin"].some((key) => note.keys.includes(key)))
260
266
  return add("status", "a run never sets status, superseded_by, retired_from or origin: the host does, when it merges the note, a later one supersedes it or a person retires it", path);
261
- notes.push(note);
267
+ candidates.push(note);
262
268
  };
263
269
  for (const change of changes)
264
270
  one(change);
@@ -280,9 +286,121 @@ export function checkProposal(input) {
280
286
  if (after.has(json) !== after.has(readme))
281
287
  add("workflow", `the folder holds ${after.has(json) ? "workflow.json" : "README.md"} without the other file`, after.has(json) ? readme : json);
282
288
  }
283
- if (!problems.length)
284
- problems.push(...mergeProblems(input.base, notes, values));
289
+ const notes = problems.length ? [] : settled(candidates);
285
290
  return { ok: problems.length === 0, problems, notes: problems.length ? [] : notes };
291
+ /** `candidates` once nothing else is wrong, settled in one order, so no note is ever lost to another's failure:
292
+ * 1. Each note alone against the base (ownProblems): what it supersedes, active there, and how many. One that fails
293
+ * is left out with its own reason.
294
+ * 2. The survivors by rule: the first of a rule holds it, the rest are its alternates. A rule the seed's active
295
+ * notes hold is held already (an alternate that supersedes its holder is an update, and holds it).
296
+ * 3. The holders' shared checks (sharedProblems): two notes superseding one note, the supersedes cap over the run,
297
+ * the index's lines, each counted in order, after the duplicates are out. A holder they refuse is left out with
298
+ * that reason, and its next alternate holds the rule in its place; then 3 again, until nothing changes (each
299
+ * round leaves one note out or more: bounded by the count).
300
+ * 4. Only then the alternates no rule needed are left out, each as the duplicate of its rule's holder.
301
+ * The notes that pass, in the answer's order. */
302
+ function settled(all) {
303
+ const survivors = all.filter((note) => {
304
+ const own = ownProblems(input.base, note);
305
+ for (const problem of own)
306
+ add(problem.rule, problem.detail, problem.path);
307
+ return own.length === 0;
308
+ });
309
+ const out = new Set();
310
+ for (;;) {
311
+ const { holders } = byRule(survivors.filter((note) => !out.has(note.file)));
312
+ const shared = sharedProblems(input.base, holders);
313
+ if (!shared.length) {
314
+ const { holders: kept, alternates } = byRule(survivors.filter((note) => !out.has(note.file)));
315
+ for (const [note, holder] of alternates)
316
+ add("duplicate", `it says what ${holder} says`, note.file);
317
+ return kept;
318
+ }
319
+ for (const problem of shared) {
320
+ add(problem.rule, problem.detail, problem.path);
321
+ out.add(problem.path);
322
+ }
323
+ }
324
+ }
325
+ /** `notes` by rule, in order: the first of a rule holds it, the rest are its alternates (each with its holder). A
326
+ * rule the seed's active notes hold is held by that note, unless the new note supersedes it (an update), or any of
327
+ * `notes` does: a note this proposal supersedes keeps no rule after it, so a copy of its rule under another name is
328
+ * no duplicate, and the rule is never left with no active note. */
329
+ function byRule(notes) {
330
+ const going = new Set(notes.flatMap((note) => note.supersedes));
331
+ const rules = new Map([...(input.base.rules ?? [])].filter(([, holder]) => !going.has(holder)));
332
+ const holders = [];
333
+ const alternates = [];
334
+ for (const note of notes) {
335
+ const rule = ruleOf(note.body);
336
+ const holder = rules.get(rule);
337
+ if (holder !== undefined && !note.supersedes.includes(holder)) {
338
+ // An update of the holder the seed has, after a copy of its rule: the update holds the rule, the copy is its
339
+ // alternate (else the update is dropped as the copy's duplicate, and the copy as the seed's, on the next pass).
340
+ const original = input.base.rules?.get(rule);
341
+ const at = holders.findIndex((one) => one.file === holder);
342
+ if (original !== undefined && holder !== original && at >= 0 && note.supersedes.includes(original)) {
343
+ // At its own place in the answer (the end of the holders so far), not the copy's: the shared checks name notes
344
+ // in answer order, so an update must not jump ahead of a note between the two.
345
+ alternates.push([holders.splice(at, 1)[0], note.file]);
346
+ holders.push(note);
347
+ rules.set(rule, note.file);
348
+ continue;
349
+ }
350
+ alternates.push([note, holder]);
351
+ continue;
352
+ }
353
+ rules.set(rule, note.file);
354
+ holders.push(note);
355
+ }
356
+ return { holders, alternates };
357
+ }
358
+ }
359
+ /** What `note` alone cannot join `base` with, needing no other note: a `supersedes` that names no active note of `base`,
360
+ * or more of them than CAPS.supersedes. */
361
+ function ownProblems(base, note) {
362
+ const active = new Set(base.active.map((one) => one.file));
363
+ const out = note.supersedes.filter((old) => !active.has(old)).map((old) => ({ rule: "supersedes", path: note.file, detail: `it supersedes ${old}, which is not an active note` }));
364
+ if (note.supersedes.length > CAPS.supersedes)
365
+ out.push({ rule: "supersedes", path: note.file, detail: `it supersedes ${note.supersedes.length} notes; the cap is ${CAPS.supersedes} a run` });
366
+ return out;
367
+ }
368
+ /** What stops the holders `notes` (one a rule, each passing ownProblems) from joining `base` together, each named by the
369
+ * note it falls on. In the answer's order: a note that supersedes one an earlier note supersedes, or that takes the
370
+ * notes superseded past CAPS.supersedes (a note named counts toward neither, so a later one that fits is kept). Then
371
+ * the index over the rest, whole (each active new note a line, each note it supersedes one fewer), so a note that frees
372
+ * lines counts wherever it stands: past INDEX_LINES, the notes that add lines are named from the answer's end until
373
+ * it fits. */
374
+ function sharedProblems(base, notes) {
375
+ const out = [];
376
+ const replaced = new Set();
377
+ const fits = [];
378
+ for (const note of notes) {
379
+ const twice = note.supersedes.find((old) => replaced.has(old));
380
+ if (twice) {
381
+ out.push({ rule: "supersedes", path: note.file, detail: `${twice} is superseded by another new note too` });
382
+ continue;
383
+ }
384
+ const would = new Set([...replaced, ...note.supersedes]);
385
+ if (would.size > CAPS.supersedes) {
386
+ out.push({ rule: "supersedes", path: note.file, detail: `with it the new notes supersede ${would.size} notes; the cap is ${CAPS.supersedes} a run` });
387
+ continue;
388
+ }
389
+ for (const old of note.supersedes)
390
+ replaced.add(old);
391
+ fits.push(note);
392
+ }
393
+ const net = (note) => (note.status === "active" ? 1 : 0) - note.supersedes.length;
394
+ let lines = base.active.length + fits.reduce((sum, note) => sum + net(note), 0);
395
+ for (const note of [...fits].reverse()) {
396
+ if (lines <= INDEX_LINES)
397
+ break;
398
+ if (net(note) <= 0)
399
+ continue;
400
+ out.push({ rule: "index_full", path: note.file, detail: `with it the index would hold ${lines} lines; it holds at most ${INDEX_LINES}, so supersede a note rather than add one` });
401
+ lines -= net(note);
402
+ }
403
+ return out;
286
404
  }
287
405
  /** The notes the active ones of `notes` supersede, each by the note that supersedes it. A note that waits for its
288
406
  * owner's OK (`status: pending`) supersedes nothing until it is approved: what it names stays active. The one rule the
@@ -3,8 +3,10 @@ import type { IndexEntry, NoteText } from "./grade.js";
3
3
  import type { Workspace } from "../workspace/index.js";
4
4
  export type LearningChange = {
5
5
  kind: "merge";
6
- /** The run that learned: the commit's Run-Id trailer and the diff file's name. */
6
+ /** The run that learned: the commit's Run-Id trailer and, with `round`, the diff file's name (runDiffKey). */
7
7
  runId: string;
8
+ /** Which of the run's looks back merges (absent: its first): a follow-up's later round merges once of its own. */
9
+ round?: number;
8
10
  /** The grader's reason: the commit's message and the log's `reason`. */
9
11
  reason: string;
10
12
  /** What merges, already checked: notes, a skill's files, a draft's files, each whole. */
@@ -26,6 +28,19 @@ export type LearningChange = {
26
28
  * it (a person retired or approved it, another run's merge changed it) is a conflict, never written over. The
27
29
  * script checks it on main as it commits. Optional, past COMMIT-API.md v1. */
28
30
  seed?: string;
31
+ /** New notes written over the note main holds by the same name: each one the run's note supersedes by its own
32
+ * name (the learning loop's takenOnMain), its blob on main in `graded`, so a change since is a conflict. Any
33
+ * other new note main holds a note by when the merge commits is left out alone (`left`, `taken`). */
34
+ replace?: string[];
35
+ /** Skills re-filed as notes (grade.ts skillAsNote): each skill's SKILL.md main holds is retired in this write, so
36
+ * no old skill stays served beside the note that replaces it; not when `note` was left out as `taken` (another
37
+ * note holds that name, so the skill's rule would be lost). Its file is checked against the run's seed as a
38
+ * skill's file the merge writes is. */
39
+ retire?: {
40
+ skill: string;
41
+ note: string;
42
+ rule: string;
43
+ }[];
29
44
  } | {
30
45
  kind: "person";
31
46
  action: "edited" | "created" | "retired" | "approved" | "restored";
@@ -43,11 +58,20 @@ export type LearningChange = {
43
58
  /** Approved-Via: console. */
44
59
  via?: "console";
45
60
  };
61
+ /** A new note a merge left out, settled against the main it commits on: `same`, a rule main's active notes (or an
62
+ * earlier note of the merge) already hold, or main's note by that name says it (no change); `taken`, main holds a note
63
+ * by that name with another rule, never written over. */
64
+ export type LeftNote = {
65
+ path: string;
66
+ reason: "same" | "taken";
67
+ };
46
68
  export type LearningCommitResult = {
47
69
  ok: true;
48
70
  main: string;
49
71
  commit: string;
50
72
  files: string[];
73
+ left?: LeftNote[];
74
+ already?: true;
51
75
  } | {
52
76
  ok: false;
53
77
  reason: "conflict";
@@ -64,23 +88,35 @@ export type LearningCommitResult = {
64
88
  /**
65
89
  * One write on the folder's main, one exec of the learning script: a run's merge or a person's write, as `change` says.
66
90
  * `ok` with the new main (its commit) and the paths the commit changed; `conflict` when an oid the caller read is
67
- * another blob on main now; `refused` when the folder as it would be is refused (a name main holds already, the index
68
- * past its lines, a note out of shape); `unavailable` when the workspace or the exec failed (retry later). A merge whose
91
+ * another blob on main now; `refused` when the folder as it would be is refused (the index past its lines, a note out
92
+ * of shape); a new note named like one main holds, or of a rule one holds, is left out alone (`left`); `unavailable` when the workspace or the exec failed (retry later). A merge whose
69
93
  * run already merged here is `ok` with the commit that holds it, and writes nothing.
70
94
  */
71
95
  export declare function learningCommit(ws: Workspace, change: LearningChange, opts?: {
72
96
  retries?: number;
73
97
  }): Promise<LearningCommitResult>;
74
- /** Main as the grader reads it (the runner's learning loop `readMain`): every active note's index
75
- * line, the whole text of each note the proposal supersedes, and the blob each of those was read at (`graded`, which
76
- * the merge checks); or `problems` when the proposal cannot join main as it is (learn/check.ts mergeProblems). From
77
- * the folder's snapshot and its bodies: no git, no exec. */
98
+ /** The texts main holds at `paths`, each a note's file, by path: one main holds no note at is not in it. From the
99
+ * folder's snapshot and its bodies: no git, no exec. What a skill the grader re-filed as a note (grade.ts skillAsNote)
100
+ * would be written over, read before its merge. */
101
+ export declare function mainTexts(ws: Workspace, paths: readonly string[]): Promise<Record<string, string>>;
102
+ /** Run `runId`'s merge on the folder, when its diff file names one (readRunDiff): the texts its own commit holds at
103
+ * `paths`, each a note's file (one it holds nothing at is not in it), read at that commit, those paths alone (textsAt:
104
+ * one read-only exec, bounded by the paths asked, never the whole folder or its log), never main's now, which a person
105
+ * may have edited since. Undefined when the run merged nothing here. */
106
+ export declare function mergedAt(ws: Workspace, runId: string, paths: readonly string[], round?: number): Promise<{
107
+ texts: Record<string, string>;
108
+ } | undefined>;
109
+ /** Main as the grader reads it (the runner's learning loop `readMain`): every active note's index line, the whole text
110
+ * of each note the proposal supersedes, and the blob each of those was read at (`graded`, which the merge checks); the
111
+ * proposal's notes named like a note main holds now, settled alone (`taken`); or `problems` when the proposal cannot
112
+ * join main as it is (learn/check.ts mergeProblems). From the folder's snapshot and its bodies: no git, no exec. */
78
113
  export declare function readMain(ws: Workspace, proposal: {
79
114
  readonly notes: readonly NoteText[];
80
115
  }): Promise<{
81
116
  active: IndexEntry[];
82
117
  superseded: NoteText[];
83
118
  graded: Record<string, string>;
119
+ taken?: LeftNote[];
84
120
  } | {
85
121
  problems: Problem[];
86
122
  }>;