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

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 (568) hide show
  1. package/CHANGELOG.md +452 -0
  2. package/README.md +311 -142
  3. package/dist/agent-rows.d.ts +1 -1
  4. package/dist/agents-store.d.ts +35 -3
  5. package/dist/agents-store.js +39 -14
  6. package/dist/answer-json.d.ts +34 -1
  7. package/dist/answer-json.js +91 -9
  8. package/dist/api-only.d.ts +1 -1
  9. package/dist/api-only.js +2 -2
  10. package/dist/attach-conformance-cli.d.ts +1 -0
  11. package/dist/attach-conformance-cli.js +18 -0
  12. package/dist/attach-conformance.d.ts +25 -0
  13. package/dist/attach-conformance.js +343 -0
  14. package/dist/browser-cost.d.ts +1 -1
  15. package/dist/browser-cost.js +52 -93
  16. package/dist/browser-live.d.ts +20 -8
  17. package/dist/browser-live.js +50 -27
  18. package/dist/cap.d.ts +0 -407
  19. package/dist/cap.js +4 -1028
  20. package/dist/catalog.d.ts +1 -12
  21. package/dist/catalog.js +4 -34
  22. package/dist/cli.js +13 -4
  23. package/dist/composio-preset.d.ts +53 -0
  24. package/dist/composio-preset.js +221 -0
  25. package/dist/computer-attach.d.ts +125 -0
  26. package/dist/computer-attach.js +330 -0
  27. package/dist/computer-calls.d.ts +60 -0
  28. package/dist/computer-calls.js +209 -0
  29. package/dist/computer-channel.d.ts +57 -0
  30. package/dist/computer-channel.js +115 -0
  31. package/dist/computer-commands.d.ts +1 -1
  32. package/dist/computer-held-routes.d.ts +35 -0
  33. package/dist/computer-held-routes.js +106 -0
  34. package/dist/computer-held.d.ts +48 -0
  35. package/dist/computer-held.js +87 -0
  36. package/dist/computer-keys.d.ts +21 -1
  37. package/dist/computer-keys.js +53 -11
  38. package/dist/computer-live.d.ts +165 -0
  39. package/dist/computer-live.js +655 -0
  40. package/dist/computer-setting.d.ts +15 -2
  41. package/dist/computer-setting.js +20 -4
  42. package/dist/computer-view.d.ts +14 -0
  43. package/dist/computer-view.js +51 -3
  44. package/dist/computer-viewer.d.ts +6 -0
  45. package/dist/computer-viewer.js +311 -0
  46. package/dist/computers.d.ts +37 -8
  47. package/dist/computers.js +62 -14
  48. package/dist/console/assets/index-CjqQirbo.css +1 -0
  49. package/dist/console/assets/index-b6-XY5A9.js +576 -0
  50. package/dist/console/index.html +2 -2
  51. package/dist/console-links.d.ts +2 -0
  52. package/dist/console-links.js +3 -0
  53. package/dist/decisions.js +4 -0
  54. package/dist/faux-computers.d.ts +9 -20
  55. package/dist/faux-computers.js +56 -26
  56. package/dist/github-connection.d.ts +10 -2
  57. package/dist/github-connection.js +65 -2
  58. package/dist/github-faux.js +1 -1
  59. package/dist/graph-view.d.ts +1 -1
  60. package/dist/harness-opencode/adapter.js +7 -3
  61. package/dist/harness-opencode/facts.js +0 -2
  62. package/dist/harness-opencode/host/policy.d.ts +2 -5
  63. package/dist/harness-opencode/host/policy.js +8 -32
  64. package/dist/harness-table.d.ts +0 -2
  65. package/dist/harness-table.js +0 -2
  66. package/dist/harness.d.ts +1 -0
  67. package/dist/harness.js +35 -1
  68. package/dist/host-tools.d.ts +2 -6
  69. package/dist/host-tools.js +7 -10
  70. package/dist/hosted-search.d.ts +5 -6
  71. package/dist/hosted-search.js +2 -28
  72. package/dist/import-sources.d.ts +10 -0
  73. package/dist/import-sources.js +44 -2
  74. package/dist/import.d.ts +3 -3
  75. package/dist/import.js +37 -6
  76. package/dist/key-words.d.ts +3 -2
  77. package/dist/key-words.js +4 -2
  78. package/dist/learn/check.d.ts +10 -2
  79. package/dist/learn/check.js +13 -5
  80. package/dist/learn/commit.d.ts +14 -2
  81. package/dist/learn/commit.js +23 -9
  82. package/dist/learn/compile.d.ts +243 -0
  83. package/dist/learn/compile.js +471 -0
  84. package/dist/learn/folder.d.ts +6 -0
  85. package/dist/learn/folder.js +4 -1
  86. package/dist/learn/general.d.ts +69 -0
  87. package/dist/learn/general.js +75 -0
  88. package/dist/learn/grade.d.ts +5 -1
  89. package/dist/learn/grade.js +29 -7
  90. package/dist/learn/notes.d.ts +8 -0
  91. package/dist/learn/notes.js +18 -0
  92. package/dist/learn/promote.d.ts +253 -0
  93. package/dist/learn/promote.js +428 -0
  94. package/dist/learn/refit.d.ts +39 -0
  95. package/dist/learn/refit.js +236 -0
  96. package/dist/learn/reflect.d.ts +9 -20
  97. package/dist/learn/reflect.js +18 -125
  98. package/dist/learn/replay-calls.d.ts +63 -0
  99. package/dist/learn/replay-calls.js +158 -0
  100. package/dist/learn/skills.d.ts +50 -14
  101. package/dist/learn/skills.js +183 -47
  102. package/dist/learn/workflow-nodes.d.ts +15 -0
  103. package/dist/learn/workflow-nodes.js +44 -0
  104. package/dist/learned-nodes.d.ts +50 -2
  105. package/dist/learned-nodes.js +41 -2
  106. package/dist/learned-workflow.d.ts +43 -3
  107. package/dist/learned-workflow.js +170 -28
  108. package/dist/learning-batch.d.ts +283 -0
  109. package/dist/learning-batch.js +574 -0
  110. package/dist/learning-cost.d.ts +18 -6
  111. package/dist/learning-cost.js +15 -7
  112. package/dist/learning-evals.d.ts +33 -0
  113. package/dist/learning-evals.js +98 -0
  114. package/dist/learning-routes.d.ts +37 -2
  115. package/dist/learning-routes.js +52 -8
  116. package/dist/learning-words.d.ts +13 -0
  117. package/dist/learning-words.js +13 -0
  118. package/dist/learning.d.ts +55 -17
  119. package/dist/learning.js +91 -48
  120. package/dist/live/stream.js +6 -3
  121. package/dist/live/translate.d.ts +4 -3
  122. package/dist/live/translate.js +8 -4
  123. package/dist/live-reach.d.ts +37 -0
  124. package/dist/live-reach.js +62 -0
  125. package/dist/llm.js +0 -3
  126. package/dist/mcp-gateway.d.ts +21 -20
  127. package/dist/mcp-gateway.js +76 -55
  128. package/dist/mcp-oauth.d.ts +62 -7
  129. package/dist/mcp-oauth.js +134 -19
  130. package/dist/mcp-pin-first.d.ts +37 -0
  131. package/dist/mcp-pin-first.js +107 -0
  132. package/dist/mcp-private-hosts.d.ts +4 -4
  133. package/dist/mcp-private-hosts.js +20 -12
  134. package/dist/mcp-probe.d.ts +27 -11
  135. package/dist/mcp-probe.js +60 -42
  136. package/dist/mcp-secret-writes.js +4 -0
  137. package/dist/mcp-servers-store.d.ts +115 -25
  138. package/dist/mcp-servers-store.js +241 -43
  139. package/dist/mcp-sources.d.ts +39 -0
  140. package/dist/mcp-sources.js +74 -0
  141. package/dist/mcp-store.d.ts +21 -4
  142. package/dist/mcp-store.js +33 -8
  143. package/dist/mcp-wire.d.ts +22 -0
  144. package/dist/mcp-wire.js +36 -0
  145. package/dist/mcp.js +3 -3
  146. package/dist/meta-tool-names.d.ts +1 -0
  147. package/dist/meta-tool-names.js +3 -0
  148. package/dist/model-form.d.ts +26 -0
  149. package/dist/model-form.js +80 -0
  150. package/dist/model.d.ts +13 -0
  151. package/dist/model.js +69 -25
  152. package/dist/monid.d.ts +51 -25
  153. package/dist/monid.js +226 -140
  154. package/dist/openapi.js +694 -59
  155. package/dist/page.d.ts +18 -0
  156. package/dist/page.js +48 -20
  157. package/dist/paid-calls.d.ts +26 -29
  158. package/dist/paid-calls.js +46 -102
  159. package/dist/place-offers.d.ts +2 -3
  160. package/dist/place-offers.js +3 -7
  161. package/dist/place.js +1 -2
  162. package/dist/print.d.ts +15 -1
  163. package/dist/print.js +14 -3
  164. package/dist/propose.d.ts +10 -1
  165. package/dist/propose.js +30 -10
  166. package/dist/provider.js +12 -4
  167. package/dist/reflect-range.d.ts +8 -1
  168. package/dist/reflect-range.js +3 -2
  169. package/dist/rows.d.ts +5 -3
  170. package/dist/rows.js +15 -4
  171. package/dist/run-launch.d.ts +27 -2
  172. package/dist/run-launch.js +15 -4
  173. package/dist/run-learning-served.d.ts +13 -2
  174. package/dist/run-manifest.d.ts +5 -0
  175. package/dist/run-manifest.js +20 -0
  176. package/dist/run-reads-over-store.d.ts +1 -1
  177. package/dist/run-repo.d.ts +20 -0
  178. package/dist/run-repo.js +63 -0
  179. package/dist/run-secrets.js +2 -3
  180. package/dist/run-timeline-served.d.ts +1 -1
  181. package/dist/run-timeline-served.js +5 -2
  182. package/dist/run-view.d.ts +19 -8
  183. package/dist/run-view.js +62 -26
  184. package/dist/runnable.d.ts +0 -3
  185. package/dist/runnable.js +37 -29
  186. package/dist/runner/adapter-loop.d.ts +47 -17
  187. package/dist/runner/adapter-loop.js +1427 -303
  188. package/dist/runner/adapter-run-spec.d.ts +23 -9
  189. package/dist/runner/adapter-run-spec.js +162 -56
  190. package/dist/runner/adapters/pi-computer.d.ts +9 -0
  191. package/dist/runner/adapters/pi-computer.js +51 -0
  192. package/dist/runner/adapters/pi.d.ts +25 -11
  193. package/dist/runner/adapters/pi.js +168 -45
  194. package/dist/runner/beside.d.ts +7 -3
  195. package/dist/runner/beside.js +21 -11
  196. package/dist/runner/claim-secrets.d.ts +4 -0
  197. package/dist/runner/claim-secrets.js +6 -1
  198. package/dist/runner/cli-run-spec.d.ts +20 -3
  199. package/dist/runner/cli-run-spec.js +174 -64
  200. package/dist/runner/commands.d.ts +3 -1
  201. package/dist/runner/commands.js +28 -3
  202. package/dist/runner/computer-channel.d.ts +34 -0
  203. package/dist/runner/computer-channel.js +62 -0
  204. package/dist/runner/conformance/harness.d.ts +3 -0
  205. package/dist/runner/conformance/harness.js +224 -17
  206. package/dist/runner/conformance/subject.d.ts +12 -5
  207. package/dist/runner/dispatch.js +3 -0
  208. package/dist/runner/end-of-run.d.ts +23 -12
  209. package/dist/runner/end-of-run.js +41 -16
  210. package/dist/runner/feedback-round.d.ts +52 -0
  211. package/dist/runner/feedback-round.js +79 -0
  212. package/dist/runner/github-app.d.ts +2 -1
  213. package/dist/runner/github-app.js +4 -2
  214. package/dist/runner/harness-loops.js +15 -1
  215. package/dist/runner/held-run.d.ts +65 -0
  216. package/dist/runner/held-run.js +158 -0
  217. package/dist/runner/journal-kinds.d.ts +44 -7
  218. package/dist/runner/journal-kinds.js +29 -0
  219. package/dist/runner/journal-reader.d.ts +5 -4
  220. package/dist/runner/journal-reader.js +12 -10
  221. package/dist/runner/learning-ask.d.ts +7 -1
  222. package/dist/runner/learning-ask.js +21 -6
  223. package/dist/runner/learning-dispatch.d.ts +22 -0
  224. package/dist/runner/learning-dispatch.js +77 -10
  225. package/dist/runner/learning-end.d.ts +69 -13
  226. package/dist/runner/learning-end.js +340 -87
  227. package/dist/runner/learning-factory.d.ts +1 -1
  228. package/dist/runner/learning-factory.js +11 -5
  229. package/dist/runner/learning-loop.d.ts +86 -8
  230. package/dist/runner/learning-loop.js +178 -23
  231. package/dist/runner/learning-seed.d.ts +11 -0
  232. package/dist/runner/learning-seed.js +27 -0
  233. package/dist/runner/live-ticker.js +1 -0
  234. package/dist/runner/loop-contract.d.ts +26 -3
  235. package/dist/runner/loop.d.ts +21 -2
  236. package/dist/runner/loop.js +23 -2
  237. package/dist/runner/main.d.ts +13 -1
  238. package/dist/runner/main.js +27 -5
  239. package/dist/runner/mcp-claim.d.ts +15 -8
  240. package/dist/runner/mcp-claim.js +176 -71
  241. package/dist/runner/mcp-github.js +1 -1
  242. package/dist/runner/mcp-run.d.ts +21 -57
  243. package/dist/runner/mcp-run.js +25 -85
  244. package/dist/runner/meta-tools.d.ts +37 -0
  245. package/dist/runner/meta-tools.js +268 -0
  246. package/dist/runner/metrics.d.ts +11 -2
  247. package/dist/runner/metrics.js +26 -5
  248. package/dist/runner/model-route.js +12 -3
  249. package/dist/runner/monid-run.d.ts +16 -0
  250. package/dist/runner/monid-run.js +96 -0
  251. package/dist/runner/pr-checkout.d.ts +1 -0
  252. package/dist/runner/pr-checkout.js +1 -1
  253. package/dist/runner/promotion.d.ts +80 -0
  254. package/dist/runner/promotion.js +562 -0
  255. package/dist/runner/reflect-hook.d.ts +46 -13
  256. package/dist/runner/reflect-hook.js +149 -48
  257. package/dist/runner/runner.d.ts +26 -0
  258. package/dist/runner/runner.js +208 -17
  259. package/dist/runner/scratch-sweep.d.ts +13 -0
  260. package/dist/runner/scratch-sweep.js +62 -0
  261. package/dist/runner/sessions.d.ts +9 -4
  262. package/dist/runner/sessions.js +5 -1
  263. package/dist/runner/step-guard.d.ts +62 -0
  264. package/dist/runner/step-guard.js +93 -0
  265. package/dist/runner/store-port.d.ts +4 -2
  266. package/dist/runner/store-secrets.js +4 -3
  267. package/dist/runner/subagent.d.ts +0 -3
  268. package/dist/runner/subagent.js +10 -13
  269. package/dist/runner/workflow-first.d.ts +216 -0
  270. package/dist/runner/workflow-first.js +303 -0
  271. package/dist/runner/workflow-host.d.ts +6 -1
  272. package/dist/runner/workflow-host.js +1 -1
  273. package/dist/runner/workflow-loop.d.ts +1 -1
  274. package/dist/runner/workflow-loop.js +17 -10
  275. package/dist/runner/workflow-spec.d.ts +15 -2
  276. package/dist/runner/workflow-spec.js +63 -23
  277. package/dist/runs-over-store.d.ts +17 -3
  278. package/dist/runs-over-store.js +59 -20
  279. package/dist/seal-key.js +3 -3
  280. package/dist/sealed-settings-store.d.ts +5 -2
  281. package/dist/sealed-settings-store.js +10 -4
  282. package/dist/secret-writes.d.ts +5 -4
  283. package/dist/secret-writes.js +5 -4
  284. package/dist/server-secrets-store.d.ts +4 -3
  285. package/dist/server-secrets-store.js +15 -9
  286. package/dist/server-secrets.js +3 -2
  287. package/dist/server.d.ts +119 -18
  288. package/dist/server.js +841 -202
  289. package/dist/settings-wake.d.ts +23 -0
  290. package/dist/settings-wake.js +65 -0
  291. package/dist/standard-webhooks.d.ts +4 -1
  292. package/dist/standard-webhooks.js +8 -4
  293. package/dist/store/agent-body.d.ts +14 -3
  294. package/dist/store/agent-body.js +14 -10
  295. package/dist/store/command-wake.d.ts +13 -0
  296. package/dist/store/command-wake.js +37 -0
  297. package/dist/store/dialect.d.ts +6 -0
  298. package/dist/store/dialect.js +5 -0
  299. package/dist/store/index.d.ts +1 -1
  300. package/dist/store/journal/storage.d.ts +3 -2
  301. package/dist/store/journal/storage.js +13 -5
  302. package/dist/store/postgres/connection.js +3 -1
  303. package/dist/store/postgres/dialect.js +4 -0
  304. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  305. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  306. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  307. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  308. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  309. package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
  310. package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
  311. package/dist/store/schema.d.ts +10 -1
  312. package/dist/store/schema.js +104 -15
  313. package/dist/store/sqlite/connection.d.ts +2 -2
  314. package/dist/store/sqlite/connection.js +2 -2
  315. package/dist/store/sqlite/run-patch.d.ts +7 -5
  316. package/dist/store/sqlite/run-patch.js +45 -18
  317. package/dist/store/sqlite/store.js +331 -72
  318. package/dist/store/store.d.ts +312 -21
  319. package/dist/store/store.js +12 -1
  320. package/dist/store-reads/cap.d.ts +1 -1
  321. package/dist/store-reads/cap.js +8 -1
  322. package/dist/store-reads/decisions.d.ts +2 -2
  323. package/dist/store-reads/decisions.js +1 -1
  324. package/dist/store-reads/import-summary.d.ts +1 -1
  325. package/dist/store-reads/journal.d.ts +30 -5
  326. package/dist/store-reads/journal.js +128 -56
  327. package/dist/store-reads/learning.d.ts +114 -12
  328. package/dist/store-reads/learning.js +238 -48
  329. package/dist/store-reads/loop.d.ts +61 -0
  330. package/dist/store-reads/loop.js +111 -0
  331. package/dist/store-reads/runs.d.ts +1 -1
  332. package/dist/store-reads/workflow.d.ts +1 -1
  333. package/dist/store-view.d.ts +6 -0
  334. package/dist/store-view.js +59 -26
  335. package/dist/template-eval.d.ts +18 -9
  336. package/dist/template-eval.js +95 -68
  337. package/dist/template-github-permissions.d.ts +24 -10
  338. package/dist/template-github-permissions.js +36 -15
  339. package/dist/template-import.d.ts +31 -0
  340. package/dist/template-import.js +121 -0
  341. package/dist/template-source.d.ts +51 -0
  342. package/dist/template-source.js +371 -0
  343. package/dist/templates.d.ts +218 -46
  344. package/dist/templates.js +493 -181
  345. package/dist/timeline/computer.d.ts +48 -0
  346. package/dist/timeline/computer.js +169 -0
  347. package/dist/timeline/index.d.ts +4 -3
  348. package/dist/timeline/index.js +4 -3
  349. package/dist/timeline/labels.d.ts +6 -2
  350. package/dist/timeline/labels.js +93 -2
  351. package/dist/timeline/origin.d.ts +19 -5
  352. package/dist/timeline/origin.js +11 -4
  353. package/dist/timeline/timeline.d.ts +22 -1
  354. package/dist/timeline/timeline.js +34 -18
  355. package/dist/timeline/util.d.ts +4 -0
  356. package/dist/timeline/util.js +14 -0
  357. package/dist/tool-gate.d.ts +84 -50
  358. package/dist/tool-gate.js +179 -101
  359. package/dist/tool-keys.d.ts +4 -1
  360. package/dist/tool-keys.js +8 -3
  361. package/dist/tool-list.d.ts +26 -0
  362. package/dist/tool-list.js +43 -0
  363. package/dist/tool-names.d.ts +71 -0
  364. package/dist/tool-names.js +99 -0
  365. package/dist/tool-plane.d.ts +33 -27
  366. package/dist/tool-plane.js +72 -39
  367. package/dist/tools.d.ts +32 -7
  368. package/dist/tools.js +37 -24
  369. package/dist/trigger-adapter.d.ts +4 -0
  370. package/dist/trigger-secrets-shown.d.ts +2 -2
  371. package/dist/trigger-secrets-shown.js +1 -1
  372. package/dist/trigger-signatures.d.ts +25 -6
  373. package/dist/trigger-signatures.js +41 -7
  374. package/dist/trigger-targets.d.ts +2 -0
  375. package/dist/trigger-targets.js +1 -0
  376. package/dist/trigger-webhook.js +5 -2
  377. package/dist/triggers.d.ts +7 -3
  378. package/dist/triggers.js +35 -5
  379. package/dist/turns.js +16 -1
  380. package/dist/validate.d.ts +15 -7
  381. package/dist/validate.js +102 -45
  382. package/dist/web-fetch.d.ts +2 -8
  383. package/dist/web-fetch.js +2 -22
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +145 -102
  387. package/dist/webhooks.js +559 -322
  388. package/dist/workflow/decisions.d.ts +1 -1
  389. package/dist/workflow/node-runner.d.ts +2 -1
  390. package/dist/workflow/node.d.ts +2 -1
  391. package/dist/workflow/node.js +3 -1
  392. package/dist/workflow/pi-versions.d.ts +23 -0
  393. package/dist/workflow/pi-versions.js +57 -0
  394. package/dist/workflow/record-tool.d.ts +2 -1
  395. package/dist/workflow/store.d.ts +1 -1
  396. package/dist/workflow/task.js +3 -2
  397. package/dist/workflow-run.d.ts +1 -1
  398. package/dist/workspace/attached-computers.d.ts +41 -0
  399. package/dist/workspace/attached-computers.js +114 -0
  400. package/dist/workspace/computer-deps.d.ts +19 -9
  401. package/dist/workspace/computer-deps.js +24 -9
  402. package/dist/workspace/computer-for-claim.d.ts +23 -8
  403. package/dist/workspace/computer-for-claim.js +92 -33
  404. package/dist/workspace/computer-hold.d.ts +11 -27
  405. package/dist/workspace/computer-hold.js +41 -55
  406. package/dist/workspace/computer-ledger.d.ts +3 -1
  407. package/dist/workspace/computer-ledger.js +4 -0
  408. package/dist/workspace/computer-mcp.d.ts +25 -0
  409. package/dist/workspace/computer-mcp.js +41 -0
  410. package/dist/workspace/computer-ports.d.ts +4 -13
  411. package/dist/workspace/computer-ports.js +4 -107
  412. package/dist/workspace/computer-script.d.ts +53 -0
  413. package/dist/workspace/computer-script.js +172 -0
  414. package/dist/workspace/executors.d.ts +1 -1
  415. package/dist/workspace/index.d.ts +4 -2
  416. package/dist/workspace/index.js +3 -1
  417. package/dist/workspace/kind-skills/desktop/SKILL.md +132 -84
  418. package/dist/workspace/kind-skills/phone/SKILL.md +104 -85
  419. package/dist/workspace/local.js +2 -2
  420. package/dist/workspace/resolve-computer.d.ts +24 -1
  421. package/dist/workspace/resolve-computer.js +40 -16
  422. package/dist/workspace/run-tools.d.ts +56 -21
  423. package/dist/workspace/run-tools.js +55 -34
  424. package/dist/wrap-up.d.ts +21 -0
  425. package/dist/wrap-up.js +21 -0
  426. package/launcher/agentrun-serve +4 -2
  427. package/package.json +19 -16
  428. package/templates/README.md +111 -45
  429. package/templates/code-review/agent.md +30 -14
  430. package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
  431. package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
  432. package/templates/code-review/evals/injection/case.yaml +2 -1
  433. package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
  434. package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
  435. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
  436. package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
  437. package/templates/code-review/evals/never-flag/case.yaml +2 -1
  438. package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
  439. package/templates/code-review/evals/null-name/case.yaml +2 -1
  440. package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
  441. package/templates/code-review/evals/off-by-one/case.yaml +2 -1
  442. package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
  443. package/templates/code-review/evals/other-repo/case.yaml +16 -0
  444. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
  445. package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
  446. package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
  447. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
  448. package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
  449. package/templates/code-review/evals/other-repo/prompt.md +10 -0
  450. package/templates/code-review/evals/re-review/case.yaml +2 -1
  451. package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
  452. package/templates/code-review/evals/re-review-open/case.yaml +2 -1
  453. package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
  454. package/templates/code-review/evals/repo-rule/case.yaml +2 -1
  455. package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
  456. package/templates/code-review/evals/two-defects/case.yaml +2 -1
  457. package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
  458. package/templates/code-review/rules/CODEREVIEW.md +1 -1
  459. package/templates/code-review/skills/review/DEEP.md +3 -2
  460. package/templates/code-review/skills/review/REVIEWER.md +3 -2
  461. package/templates/code-review/skills/review/SKILL.md +4 -3
  462. package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
  463. package/templates/inbound-lead/agent.md +26 -16
  464. package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
  465. package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
  466. package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
  467. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
  468. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
  469. package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
  470. package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
  471. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
  472. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
  473. package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
  474. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
  475. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
  476. package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
  477. package/templates/kyb/agent.md +15 -5
  478. package/templates/kyb/evals/adverse-media/prompt.md +2 -7
  479. package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
  480. package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
  481. package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
  482. package/templates/kyb/evals/name-collision/prompt.md +2 -6
  483. package/templates/kyb/evals/no-invention/prompt.md +2 -6
  484. package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
  485. package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
  486. package/templates/kyb/kyb.schema.json +8 -7
  487. package/templates/kyb/skills/kyb/SKILL.md +9 -6
  488. package/templates/market-monitor/agent.md +19 -12
  489. package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
  490. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
  491. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
  492. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
  493. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  494. package/templates/release-notes/agent.md +32 -10
  495. package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
  496. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
  497. package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
  498. package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
  499. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
  500. package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
  501. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
  502. package/templates/release-notes/evals/learned-style/case.yaml +2 -1
  503. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
  504. package/templates/release-notes/evals/other-repo/case.yaml +24 -0
  505. package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
  506. package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
  507. package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
  508. package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
  509. package/templates/release-notes/evals/other-repo/prompt.md +32 -0
  510. package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
  511. package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
  512. package/templates/release-notes/notes.schema.json +1 -1
  513. package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
  514. package/dist/console/assets/index-BI4Byidu.js +0 -550
  515. package/dist/console/assets/index-C19gUF2n.css +0 -1
  516. package/dist/run-db.d.ts +0 -53
  517. package/dist/run-db.js +0 -116
  518. package/dist/tool-blurbs.d.ts +0 -4
  519. package/dist/tool-blurbs.js +0 -28
  520. package/dist/tool-budget.d.ts +0 -26
  521. package/dist/tool-budget.js +0 -56
  522. package/dist/workflow/readers.d.ts +0 -36
  523. package/dist/workflow/readers.js +0 -145
  524. package/dist/workflow/wal.d.ts +0 -11
  525. package/dist/workflow/wal.js +0 -106
  526. package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
  527. package/templates/code-review/evals/injection/graders/schema.md +0 -5
  528. package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
  529. package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
  530. package/templates/code-review/evals/null-name/graders/schema.md +0 -5
  531. package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
  532. package/templates/code-review/evals/re-review/graders/schema.md +0 -5
  533. package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
  534. package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
  535. package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
  536. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
  537. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
  538. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
  539. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
  540. package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
  541. package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
  542. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
  543. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
  544. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
  545. package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
  546. package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
  547. package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
  548. package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
  549. package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
  550. package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
  551. package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
  552. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
  553. package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
  554. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
  555. package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
  556. package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
  557. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
  558. package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
  559. package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
  560. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
  561. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
  562. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
  563. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
  564. package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
  565. package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
  566. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
  567. package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
  568. package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
@@ -1,15 +1,18 @@
1
1
  // An agent's cost per run, run after run (GET /agents/{id}/learning/cost): what each run of its cost, what learning added
2
2
  // for it, and the path it took, so a person sees the cost fall once a learned workflow does the job, and by how much.
3
3
  // Aggregates only: no run's input, answer or tool text. The store's reader (store-reads/learning.ts agentCostOverStore)
4
- // gives each run's figures and its path (runner/learning-end.ts runPathOf); this module sums its learning and says what the
4
+ // gives each run's figures and its path (its run record's metrics.path, store-reads/learning.ts runPathOverStore); this module sums its learning and says what the
5
5
  // series shows (costSummary), the rule the console, the CLI and the CSV all read. It imports only the errors, so the API
6
6
  // document reads its words.
7
7
  import { ApiError } from "./errors.js";
8
- /** The path a run took: `workflow`, a learned workflow finished it alone (its job's only tool calls were learned_workflow
9
- * calls, each answering, and nothing was said after its first message: the runner's own rule for a run with nothing new
10
- * to look back on, runner/learning-end.ts onlyLearnedWorkflows); `handed_back`, a learned workflow ran and the agent
11
- * went on (it failed, escalated, or the agent did more work after it); `agent`, no learned workflow ran. */
12
- export const RUN_PATHS = ["agent", "handed_back", "workflow"];
8
+ /** The path a run took: `workflow`, a learned workflow finished it alone (served first and answered, or its job's only
9
+ * tool calls were learned_workflow calls, each answering, and nothing was said after its first message: the runner's own
10
+ * rule for a run with nothing new to look back on, runner/learning-end.ts onlyLearnedWorkflows); `handed_back`, a
11
+ * learned workflow ran and the agent went on (it handed back, failed, escalated, or the agent did more work after it);
12
+ * `agent`, no learned workflow ran; `replay`, a replay run deciding whether a learned workflow's new revision serves
13
+ * (runner/promotion.ts: the workflow alone on a graded run's input, at workflow cost). One classifier (store-reads/learning.ts runPathOverStore) writes it on the run's
14
+ * record at its end (metrics.path). */
15
+ export const RUN_PATHS = ["agent", "handed_back", "workflow", "replay"];
13
16
  const usd = (value) => Math.round(value * 1e6) / 1e6;
14
17
  /** A run's own cost and what learning added for it, from its row's cost (`rowUsd`: the job, its look-back and any turn a
15
18
  * person asked of it after), what it kept as it answered (`looked`, none for a run that did not look back) and what its
@@ -32,6 +35,9 @@ export function runCostOf(rowUsd, looked, gradeUsd = 0) {
32
35
  }
33
36
  /** The fewest runs after the takeover a "times cheaper" figure needs: fewer say too little. */
34
37
  export const CHEAPER_AFTER_RUNS = 20;
38
+ /** How many of a learned workflow's newest runs served first at one version the money rule reads
39
+ * (runner/workflow-first.ts costLineOf); under that many, it serves. */
40
+ export const COST_WINDOW = 10;
35
41
  /** The latest runs the route answers by default, and at most. */
36
42
  export const COST_RUNS_DEFAULT = 1000;
37
43
  export const COST_RUNS_MAX = 10_000;
@@ -41,7 +47,9 @@ export function costSummary(runs) {
41
47
  const before = mean((first < 0 ? runs : runs.slice(0, first)).flatMap((run) => (run.path === "agent" && run.cost_usd !== null ? [run.cost_usd] : [])));
42
48
  const after = first < 0 ? null : mean(runs.slice(first).flatMap((run) => (run.total_usd === null ? [] : [run.total_usd])));
43
49
  const times = before && after && after.runs >= CHEAPER_AFTER_RUNS && after.mean_usd > 0 ? Math.round((before.mean_usd / after.mean_usd) * 10) / 10 : null;
44
- return { takeover: first < 0 ? null : { n: runs[first].n, run_id: runs[first].run_id }, before, after, times_cheaper: times };
50
+ const ranFirst = first < 0 ? [] : runs.slice(first).filter((run) => run.path === "workflow" || run.path === "handed_back");
51
+ const handBacks = first < 0 ? null : { ran: ranFirst.length, back: ranFirst.filter((run) => run.path === "handed_back").length };
52
+ return { takeover: first < 0 ? null : { n: runs[first].n, run_id: runs[first].run_id }, before, after, times_cheaper: times, hand_backs: handBacks };
45
53
  }
46
54
  /** The series as CSV (RFC 4180, a header line, `\r\n` line ends): one row a run, an unknown figure empty. A text cell that
47
55
  * a spreadsheet would read as a formula (one starting with =, +, -, @, a tab or a carriage return) starts with a `'`, so
@@ -0,0 +1,33 @@
1
+ import type { Store } from "./store/store.js";
2
+ /** How many records an agent keeps, newest first. */
3
+ export declare const EVALS_KEPT = 20;
4
+ /** The most jobs one test may count. */
5
+ export declare const EVAL_JOBS_MAX = 10000000;
6
+ /** The longest `name` and `label_source`. */
7
+ export declare const EVAL_TEXT_MAX = 200;
8
+ /** One record: what was posted (`name`, `label_source`, the counts, each side's cost a task, the learned revision), the
9
+ * server's `accuracy` (correct / n) and `ci` (its 95% Wilson interval), each to four places, and when it was recorded. */
10
+ export type LearningEval = {
11
+ id: string;
12
+ name: string;
13
+ label_source: string | null;
14
+ n: number;
15
+ correct: number;
16
+ accuracy: number;
17
+ ci: [number, number];
18
+ cost_per_task_usd: number | null;
19
+ baseline_cost_per_task_usd: number | null;
20
+ learned_revision: string | null;
21
+ recorded_at: string;
22
+ };
23
+ /** The 95% Wilson score interval of `correct` right of `n`, [low, high], each from 0 to 1, to four places: unlike the
24
+ * normal approximation it holds at 0 and at n right and with few jobs. */
25
+ export declare function wilsonOf(n: number, correct: number): [number, number];
26
+ /** A posted record, checked for its shape only: each field that is missing or wrong is 422 input_invalid by field, and
27
+ * nothing is kept. */
28
+ export declare function evalOf(body: unknown, now: Date): LearningEval;
29
+ /** Agent `agentId`'s records, newest recorded first. */
30
+ export declare function evalsOf(store: Store, agentId: string): Promise<LearningEval[]>;
31
+ /** Appends `record` first in agent `agentId`'s records, the latest EVALS_KEPT kept: a compare-and-set, so of two posts at
32
+ * once neither is lost. */
33
+ export declare function recordEval(store: Store, agentId: string, record: LearningEval): Promise<void>;
@@ -0,0 +1,98 @@
1
+ // An agent's eval records (POST and GET /agents/{id}/learning/evals): the counts of a held-out test of what the agent
2
+ // learned, posted by whoever ran it (a bench, a script, a person): `n` jobs it never learned from, `correct` of them right,
3
+ // the cost a task with learning and by hand, where the labels came from and the learned revision it tested. The server
4
+ // computes the accuracy and its 95% Wilson interval from the counts (a caller never sends either), so the console's
5
+ // Learning tab can say how accurate and how cheap the learned agent is, with how many jobs and how sure. A record is only
6
+ // ever what was posted: the server never computes one from the agent's own runs (the jobs it learned from, never held
7
+ // out). Append-only, the latest first and the one shown, the latest EVALS_KEPT kept in the store's settings under the
8
+ // agent's key. Aggregates only: no rows, no inputs.
9
+ import { randomUUID } from "node:crypto";
10
+ import { invalid } from "./errors.js";
11
+ /** How many records an agent keeps, newest first. */
12
+ export const EVALS_KEPT = 20;
13
+ /** The most jobs one test may count. */
14
+ export const EVAL_JOBS_MAX = 10_000_000;
15
+ /** The longest `name` and `label_source`. */
16
+ export const EVAL_TEXT_MAX = 200;
17
+ const FIELDS = ["name", "label_source", "n", "correct", "cost_per_task_usd", "baseline_cost_per_task_usd", "learned_revision"];
18
+ /** z for a two-sided 95% interval. */
19
+ const Z95 = 1.959963984540054;
20
+ const places = (value) => Math.round(value * 1e4) / 1e4;
21
+ /** The 95% Wilson score interval of `correct` right of `n`, [low, high], each from 0 to 1, to four places: unlike the
22
+ * normal approximation it holds at 0 and at n right and with few jobs. */
23
+ export function wilsonOf(n, correct) {
24
+ const p = correct / n;
25
+ const z2 = Z95 * Z95;
26
+ const over = 1 + z2 / n;
27
+ const centre = (p + z2 / (2 * n)) / over;
28
+ const half = (Z95 * Math.sqrt((p * (1 - p)) / n + z2 / (4 * n * n))) / over;
29
+ return [places(Math.max(0, centre - half)), places(Math.min(1, centre + half))];
30
+ }
31
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
32
+ const oneLine = (value) => typeof value === "string" && !!value.trim() && value.length <= EVAL_TEXT_MAX && !/[\u0000-\u001f\u007f]/.test(value);
33
+ const whole = (value, least, most) => Number.isInteger(value) && value >= least && value <= most;
34
+ const dollars = (value) => value === null || (typeof value === "number" && Number.isFinite(value) && value >= 0);
35
+ /** A posted record, checked for its shape only: each field that is missing or wrong is 422 input_invalid by field, and
36
+ * nothing is kept. */
37
+ export function evalOf(body, now) {
38
+ if (!isObject(body))
39
+ throw invalid([{ field: "body", reason: "invalid", message: "the body is a JSON object" }]);
40
+ const issues = [];
41
+ for (const key of Object.keys(body)) {
42
+ const why = key === "accuracy" || key === "ci" ? "the server computes accuracy and ci from n and correct" : `the body takes ${FIELDS.join(", ")}`;
43
+ if (!FIELDS.includes(key))
44
+ issues.push({ field: key, reason: "unknown", message: why });
45
+ }
46
+ const { name, label_source: source = null, n, correct, cost_per_task_usd: cost = null, baseline_cost_per_task_usd: baseline = null, learned_revision: revision = null } = body;
47
+ if (!oneLine(name))
48
+ issues.push({ field: "name", reason: "invalid", message: `name says what ran the test, in one line of at most ${EVAL_TEXT_MAX} characters`, example: "invoice bench, sealed test" });
49
+ if (!(source === null || oneLine(source)))
50
+ issues.push({ field: "label_source", reason: "invalid", message: `label_source says where the right answers came from, in one line of at most ${EVAL_TEXT_MAX} characters, or null`, example: "teacher labels, 87% strict vs people" });
51
+ const jobs = whole(n, 1, EVAL_JOBS_MAX);
52
+ if (!jobs)
53
+ issues.push({ field: "n", reason: "invalid", message: `n is the held-out jobs counted, a whole number from 1 to ${EVAL_JOBS_MAX}`, example: 200 });
54
+ if (!whole(correct, 0, jobs ? n : EVAL_JOBS_MAX))
55
+ issues.push({ field: "correct", reason: "invalid", message: "correct is how many of the n jobs it got right, a whole number from 0 to n", example: 188 });
56
+ if (!dollars(cost))
57
+ issues.push({ field: "cost_per_task_usd", reason: "invalid", message: "cost_per_task_usd is the mean cost a task with learning, in dollars, 0 or more, or null" });
58
+ if (!dollars(baseline))
59
+ issues.push({ field: "baseline_cost_per_task_usd", reason: "invalid", message: "baseline_cost_per_task_usd is the mean cost a task by hand, in dollars, 0 or more, or null" });
60
+ if (!(revision === null || (typeof revision === "string" && /^[0-9a-f]{7,64}$/.test(revision))))
61
+ issues.push({ field: "learned_revision", reason: "invalid", message: "learned_revision is the learning folder's commit it tested (7 to 64 hex characters), or null" });
62
+ if (issues.length)
63
+ throw invalid(issues);
64
+ const [jobsN, right] = [n, correct];
65
+ return {
66
+ id: `eval_${randomUUID()}`,
67
+ name: name.trim(),
68
+ label_source: source === null ? null : source.trim(),
69
+ n: jobsN,
70
+ correct: right,
71
+ accuracy: places(right / jobsN),
72
+ ci: wilsonOf(jobsN, right),
73
+ cost_per_task_usd: cost,
74
+ baseline_cost_per_task_usd: baseline,
75
+ learned_revision: revision,
76
+ recorded_at: now.toISOString(),
77
+ };
78
+ }
79
+ const keyOf = (agentId) => `learning.evals.${agentId}`;
80
+ const listOf = (value) => (Array.isArray(value) ? value : []);
81
+ /** Agent `agentId`'s records, newest recorded first. */
82
+ export async function evalsOf(store, agentId) {
83
+ return listOf(await store.settings.get(keyOf(agentId)));
84
+ }
85
+ /** Appends `record` first in agent `agentId`'s records, the latest EVALS_KEPT kept: a compare-and-set, so of two posts at
86
+ * once neither is lost. */
87
+ export async function recordEval(store, agentId, record) {
88
+ const key = keyOf(agentId);
89
+ for (;;) {
90
+ const was = await store.settings.get(key);
91
+ const next = [record, ...listOf(was)].slice(0, EVALS_KEPT);
92
+ // putIfAbsent answers what the key holds after: ours, or ours under a post that raced in between (Postgres inserts and reads
93
+ // back in separate calls), so ours is kept when its id is in the list, never when the list merely differs from ours.
94
+ const kept = was === undefined ? listOf(await store.settings.putIfAbsent(key, next)).some((e) => e.id === record.id) : await store.settings.replaceIf(key, was, next);
95
+ if (kept)
96
+ return;
97
+ }
98
+ }
@@ -1,5 +1,6 @@
1
1
  import type { DraftAsk } from "./learn/skills.js";
2
2
  import type { IncomingMessage, ServerResponse } from "node:http";
3
+ import type { DraftDecisions } from "./learn/skills.js";
3
4
  import { type ItemStatus, type Learning, type NoteRuns, type Shown } from "./learning.js";
4
5
  import type { Impact } from "./learning-run.js";
5
6
  import { type LearnedUse } from "./store-reads/learning.js";
@@ -112,6 +113,27 @@ export declare function agentLearning(data: string, agentId: string, shown: Show
112
113
  export declare function learningNotes(data: string, agentId: string, query: URLSearchParams, shown: Shown, runs?: NoteRuns): Promise<Page<NoteView>>;
113
114
  /** GET /agents/{id}/learning/log?cursor=&limit=: a page of the changes on main, newest first. */
114
115
  export declare function learningLog(data: string, agentId: string, query: URLSearchParams, shown: Shown): Promise<Page<Change>>;
116
+ /** One revision of a learned workflow: a commit on main that changed its workflow.json, with that commit's text (null
117
+ * when the commit holds no such file: it was deleted there), cut of the host's secrets. */
118
+ type WorkflowRevision = {
119
+ commit: string;
120
+ at: string;
121
+ by: Change["by"];
122
+ reason: string;
123
+ text: string | null;
124
+ digest: string | null;
125
+ };
126
+ /** GET /agents/{id}/learning/workflows/{name}/revisions?limit=: the latest revisions of learned workflow `name` (the
127
+ * commits on main's log that changed `workflows/<name>/workflow.json`), oldest first, each with the workflow's text at
128
+ * that commit, so a person can step through how it changed. One read-only exec per revision (textsAt), at most `limit`
129
+ * of them. `total` counts every such commit the log holds, `truncated` says the log itself is cut (it keeps the latest
130
+ * LOG_KEEP changes). A workflow no commit of the log changed is not_found. */
131
+ export declare function workflowRevisions(data: string, agentId: string, name: string, query: URLSearchParams, shown: Shown): Promise<{
132
+ name: string;
133
+ revisions: WorkflowRevision[];
134
+ total: number;
135
+ truncated: boolean;
136
+ }>;
115
137
  /** GET /agents/{id}/learning/files/{file}: the file on main as text, its ETag, and its type (a draft's workflow.json is
116
138
  * JSON). */
117
139
  export declare function readNote(data: string, agentId: string, raw: string, shown: Shown): Promise<{
@@ -151,6 +173,7 @@ export declare function writeNote(data: string, agentId: string, raw: string, in
151
173
  gated: Record<string, string>;
152
174
  deniedBy?: Record<string, "agent" | "server" | "default">;
153
175
  ask?: DraftAsk;
176
+ decisions?: DraftDecisions;
154
177
  }>;
155
178
  }): Promise<{
156
179
  status: 200 | 201;
@@ -180,6 +203,7 @@ export declare function promotable(data: string, agentId: string, raw: string, i
180
203
  tools: string[];
181
204
  gated: Record<string, string>;
182
205
  deniedBy?: Record<string, "agent" | "server" | "default">;
206
+ decisions?: DraftDecisions;
183
207
  }>;
184
208
  }): Promise<Promotable>;
185
209
  /** GET /runs/{id}/learning's body, from the run's learning as it reads now, the seed it started from and whether it
@@ -215,6 +239,17 @@ export declare function runLearningBody(input: {
215
239
  path?: string | undefined;
216
240
  rule: import("./learn/check.js").Rule;
217
241
  }[];
242
+ compiled: {
243
+ workflow: string;
244
+ from_notes: string[];
245
+ attempts: {
246
+ ok: boolean;
247
+ errors: string[];
248
+ }[];
249
+ digest: string | null;
250
+ promoted: boolean | null;
251
+ } | null;
252
+ draft_errors: string[];
218
253
  cost_usd: {
219
254
  grade: number | null;
220
255
  };
@@ -238,8 +273,8 @@ export declare function runLearningBody(input: {
238
273
  skills?: import("./learning.js").LearnedFile[];
239
274
  workflows?: import("./learning.js").LearnedFile[];
240
275
  run: string;
241
- state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
242
- reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
276
+ state: "proposed" | "dropped" | "merged" | "seeded" | "reflecting";
277
+ reason: "cancelled" | "no_budget" | "empty" | "unparsed" | "use" | "seed_failed" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
243
278
  detail: string | null;
244
279
  at: string;
245
280
  };
@@ -1,5 +1,7 @@
1
+ import { noteBytes } from "./learn/check.js";
2
+ import { createHash } from "node:crypto";
1
3
  import { approve, buildIndex, CAPS, checkNote, draftProblems, frontKeys, INDEX_FILE, INDEX_LINES, isHeld, LEARNED_KEYS, learnedName, learnedPlace, learnedStatus, NOTE_FILE, NOTE_STATUSES, parseNoteFile, printable, released, retire, retiredLearned, skillProblems, SKILLS_DIR, supersede, UNCLEAR_FRONT, unstorable, WORKFLOWS_DIR, unclearFront, restorable, restore, restoredLearned } from "./learn/index.js";
2
- import { blobOid, FolderBusy, FolderRefused, FolderTooLarge, FolderUnreadable, heldOnMain, isBodyMismatch, readLearning, PATCH_CAP, readRunDiff, readSnapshot, snapshotNotes, writeLearning } from "./learn/folder.js";
4
+ import { blobOid, FolderBusy, FolderRefused, FolderTooLarge, FolderUnreadable, heldOnMain, isBodyMismatch, readLearning, PATCH_CAP, readRunDiff, readSnapshot, runDiffKey, snapshotNotes, textsAt, writeLearning } from "./learn/folder.js";
3
5
  import { ApiError, invalid } from "./errors.js";
4
6
  import { detailShown, learningFolderOf, notesView, reasonShown, secretsShown, withAgentRepo } from "./learning.js";
5
7
  import { isObject } from "./validate.js";
@@ -209,6 +211,41 @@ export async function learningLog(data, agentId, query, shown) {
209
211
  return logPage(page.snapshot, page.offset, limit, shown);
210
212
  }, () => EMPTY);
211
213
  }
214
+ /** The most revisions a workflow's history answers, and its default. */
215
+ const REVISIONS_MAX = 50;
216
+ const REVISIONS_DEFAULT = 20;
217
+ /** GET /agents/{id}/learning/workflows/{name}/revisions?limit=: the latest revisions of learned workflow `name` (the
218
+ * commits on main's log that changed `workflows/<name>/workflow.json`), oldest first, each with the workflow's text at
219
+ * that commit, so a person can step through how it changed. One read-only exec per revision (textsAt), at most `limit`
220
+ * of them. `total` counts every such commit the log holds, `truncated` says the log itself is cut (it keeps the latest
221
+ * LOG_KEEP changes). A workflow no commit of the log changed is not_found. */
222
+ export async function workflowRevisions(data, agentId, name, query, shown) {
223
+ if (!learnedName("workflow", name))
224
+ throw new ApiError("bad_request", "A workflow's folder is named with lowercase letters, digits, dashes and underscores.");
225
+ const given = query.get("limit");
226
+ const limit = given === null ? REVISIONS_DEFAULT : Number(given);
227
+ if ((given !== null && !/^\d+$/.test(given)) || limit < 1 || limit > REVISIONS_MAX)
228
+ throw new ApiError("bad_request", `limit is an integer from 1 to ${REVISIONS_MAX}`);
229
+ const path = `${WORKFLOWS_DIR}/${name}/workflow.json`;
230
+ if (shown.name(path) !== path)
231
+ throw new ApiError("not_found", "the agent's learning folder has no such workflow");
232
+ const found = await reading(data, agentId, async ({ ws, snapshot }) => {
233
+ const touched = snapshot.log.filter((change) => change.files.includes(path));
234
+ const latest = touched.slice(0, limit).reverse();
235
+ const revisions = [];
236
+ for (const change of latest) {
237
+ const texts = await textsAt(ws, change.commit, [path]).catch((error) => { throw routeFailure(error); });
238
+ const raw = texts?.[path];
239
+ // Its digest, read from the text as it is (workflow-first.ts workflowDigest's): the one a run's metrics and the
240
+ // promotion records name, so a revision's runs, guards and promotion are found by it.
241
+ revisions.push({ commit: change.commit, at: change.at, by: change.by, reason: shown.text(change.reason), text: raw === undefined ? null : shown.text(raw), digest: raw === undefined ? null : createHash("sha256").update(raw).digest("hex").slice(0, 16) });
242
+ }
243
+ return { revisions, total: touched.length, truncated: snapshot.log_more };
244
+ }, () => undefined);
245
+ if (!found || !found.total)
246
+ throw new ApiError("not_found", "the agent's learning folder has no such workflow");
247
+ return { name, ...found };
248
+ }
212
249
  /** The blob of `file` on the snapshot's main, as a route names it: the index, a note, a skill's SKILL.md, a draft's
213
250
  * README.md or workflow.json; undefined when main holds no such file the snapshot names. */
214
251
  function blobIn(snapshot, file) {
@@ -423,9 +460,9 @@ export async function writeNote(data, agentId, raw, input) {
423
460
  // a restore never brings back a draft no run could run.
424
461
  const draft = changes.find(({ path }) => path === `${folder}workflow.json`);
425
462
  if (learned.kind !== "skill" && draft && input.draftTools) {
426
- const { tools, gated, deniedBy, ask } = await input.draftTools();
463
+ const { tools, gated, deniedBy, ask, decisions } = await input.draftTools();
427
464
  const dsl = await import("@parcha/agentrun-dsl");
428
- for (const { rule, detail } of draftProblems(dsl, draft.bytes.toString("utf8"), tools, gated, deniedBy ?? {}, ask))
465
+ for (const { rule, detail } of draftProblems(dsl, draft.bytes.toString("utf8"), tools, gated, deniedBy ?? {}, ask, decisions))
429
466
  problems.push(printable({ rule, path: draft.path, detail }, input.refuse));
430
467
  }
431
468
  if (problems.length)
@@ -485,9 +522,9 @@ export async function writeNote(data, agentId, raw, input) {
485
522
  const retired = parseNoteFile(file, text);
486
523
  if (Array.isArray(retired))
487
524
  throw refused(retired.map((detail) => printable({ rule: "note", path: file, detail }, input.refuse)));
488
- const size = Buffer.byteLength(text);
525
+ const size = noteBytes(text);
489
526
  if (size > CAPS.note + RETIRED_LINE)
490
- throw refused([printable({ rule: "too_large", path: file, detail: `${size} bytes as retired; the cap is ${CAPS.note}, and the status lines a retire adds` }, input.refuse)]);
527
+ throw refused([printable({ rule: "too_large", path: file, detail: `${size} bytes as retired; the cap is ${CAPS.note}, and the status lines a retire adds (a compiled_into line on top)` }, input.refuse)]);
491
528
  }
492
529
  if (current && text === current.text)
493
530
  return { result: { status: 200, file, text, etag: etagOf(current.oid) } };
@@ -559,8 +596,9 @@ export async function promotable(data, agentId, raw, input) {
559
596
  problems.push(printable({ rule: "workflow", path: file, detail: "the workflow's folder holds no workflow.json" }, input.refuse));
560
597
  const dsl = await import("@parcha/agentrun-dsl");
561
598
  if (json && !problems.length) {
562
- const { tools, gated, deniedBy } = await input.draftTools();
563
- for (const { rule, detail } of draftProblems(dsl, json.text, tools, gated, deniedBy ?? {}))
599
+ // A learned workflow's decision nodes (LS-07) are checked on this server's decision providers, as a restore checks them.
600
+ const { tools, gated, deniedBy, decisions } = await input.draftTools();
601
+ for (const { rule, detail } of draftProblems(dsl, json.text, tools, gated, deniedBy ?? {}, undefined, decisions))
564
602
  problems.push(printable({ rule, path: file, detail }, input.refuse));
565
603
  }
566
604
  if (problems.length)
@@ -587,6 +625,12 @@ export function runLearningBody(input, shown, secrets) {
587
625
  verdict: verdict ? { merge: verdict.merge, reason: shown.text(verdict.reason), items: (verdict.items ?? []).map(({ file, keep, pending: waits, origin, question, why }) => ({ file: shown.name(file), keep, ...(waits ? { pending: true } : {}), ...(origin ? { origin: shown.text(origin) } : {}), ...(question ? { question: shown.text(question) } : {}), why: shown.text(why) })) } : null,
588
626
  // Each cut of the host's secrets (printable), then as every served text is (`shown`: no loopback address).
589
627
  problems: (problems ?? []).map((problem) => printable(problem, secrets)).map(({ rule, path, detail }) => ({ rule: shown.text(rule), ...(path === undefined ? {} : { path: shown.text(path) }), detail: shown.text(detail) })),
628
+ // The compile turn's record (learn/compile.ts): the workflow it wrote, the notes it absorbed and each attempt with
629
+ // what the checks refused, its kept draft's digest and whether that serves (its promotion: true, held false, null
630
+ // while undecided); null when the run compiled nothing. A draft that never passed is never silent: its
631
+ // errors are `draft_errors`. Each text cut of the host's secrets.
632
+ compiled: learning.compiled ? { workflow: shown.name(learning.compiled.workflow), from_notes: learning.compiled.from_notes.map(shown.name), attempts: learning.compiled.attempts.map(({ ok, errors }) => ({ ok, errors: errors.map((error) => shown.text(printable({ rule: "workflow", detail: error }, secrets).detail)) })), digest: learning.compiled.digest ?? null, promoted: learning.compiled.promoted ?? null } : null,
633
+ draft_errors: (learning.draft_errors ?? []).map((error) => shown.text(printable({ rule: "workflow", detail: error }, secrets).detail)),
590
634
  // The grade's alone: the end-of-run turn's cost is in the run's own totals.
591
635
  cost_usd: { grade: cost_usd?.grade ?? null },
592
636
  tokens: { grade: tokens?.grade ?? null },
@@ -630,7 +674,7 @@ export async function runDiffOverStore(data, store, runId, shown) {
630
674
  };
631
675
  if (end?.merged) {
632
676
  const folder = learningFolderOf(data, row.agentId);
633
- const diff = await readRunDiff(folder.workspace, runId).catch((error) => Promise.reject(routeFailure(error))).finally(() => folder.end());
677
+ const diff = await readRunDiff(folder.workspace, runDiffKey(runId, kept?.round)).catch((error) => Promise.reject(routeFailure(error))).finally(() => folder.end());
634
678
  if (!diff || diff.merge !== end.merged)
635
679
  throw new ApiError("not_found", "the run's merge is not in its agent's learning folder");
636
680
  return { base: diff.parent, head: diff.merge, files: diff.files.map((entry) => ("patch" in entry ? file(entry.path, entry.status, entry.patch) : { path: shown.name(entry.path), status: entry.status, withheld: entry.withheld })) };
@@ -36,6 +36,10 @@ export declare const said: {
36
36
  /** The end-of-run turn asked again because a workflow draft failed its dry run (learn/reflect.ts reflectDryRun), as a
37
37
  * person reads it in the timeline: never the ask, which holds the check's words. */
38
38
  askedDryRun: string;
39
+ /** The compile turn's ask (learn/compile.ts askedForCompile): the job written as a workflow, or a revision of one, or
40
+ * an attempt the checks sent back. */
41
+ askedCompile: string;
42
+ askedCompileAgain: string;
39
43
  proposed: (notes: number, skills?: number, workflows?: number) => string;
40
44
  /** What it learned, by name, and how many older notes they replace, and its skill and workflow by name; then what
41
45
  * waits for the owner's OK, by name; then, when the grader dropped an item and kept others (a verdict per item), its
@@ -52,6 +56,8 @@ export declare const said: {
52
56
  /** A run whose only work was its learned workflows, each answering, with nothing said after its first message: it was
53
57
  * not asked to look back (runner/learning-end.ts onlyLearnedWorkflows). */
54
58
  onlyWorkflow: string;
59
+ /** A run started with `learning: "use"`: it read what its agent learned and kept nothing, as asked. */
60
+ use: string;
55
61
  /** A merge whose every item the owner has since retired: nothing it learned is kept now. */
56
62
  retiredSince: string;
57
63
  /** The run's answer gave its notes, but not in the format asked for, so none was read. */
@@ -66,7 +72,14 @@ export declare const said: {
66
72
  * either way: said in one sentence true of both. */
67
73
  stale: (problems: readonly Pick<Problem, "rule">[]) => string;
68
74
  noBudget: string;
75
+ /** The run's grade did not fit what its cap left (its learning run's cap): not run, so nothing it learned is kept. */
76
+ noRoomToGrade: string;
77
+ /** A grade under a cap whose cost can't be kept within it (its spend or the grade model's price unknown). */
78
+ gradeUncapped: string;
69
79
  unknownCost: string;
80
+ /** A capped run whose spend under its cap is unknown once it looked back: its grade is not run (none could be kept
81
+ * within the cap), so nothing it learned is kept. */
82
+ gradeUnknownSpend: string;
70
83
  stopped: (cause: string) => string;
71
84
  };
72
85
  /** Why a verdict kept nothing, in a person's words: the grader's word on the first note it did not keep, since its
@@ -102,6 +102,10 @@ export const said = {
102
102
  /** The end-of-run turn asked again because a workflow draft failed its dry run (learn/reflect.ts reflectDryRun), as a
103
103
  * person reads it in the timeline: never the ask, which holds the check's words. */
104
104
  askedDryRun: "Looking back again: a workflow draft did not pass its dry run.",
105
+ /** The compile turn's ask (learn/compile.ts askedForCompile): the job written as a workflow, or a revision of one, or
106
+ * an attempt the checks sent back. */
107
+ askedCompile: "Writing this job as a learned workflow.",
108
+ askedCompileAgain: "Writing the workflow again: the checks sent back what they refused.",
105
109
  proposed: (notes, skills = 0, workflows = 0) => `Checking ${listed([...(notes || !(skills || workflows) ? [count(notes, "new note")] : []), ...(skills ? [count(skills, "skill")] : []), ...(workflows ? [count(workflows, "workflow")] : [])])}…`,
106
110
  /** What it learned, by name, and how many older notes they replace, and its skill and workflow by name; then what
107
111
  * waits for the owner's OK, by name; then, when the grader dropped an item and kept others (a verdict per item), its
@@ -126,6 +130,8 @@ export const said = {
126
130
  /** A run whose only work was its learned workflows, each answering, with nothing said after its first message: it was
127
131
  * not asked to look back (runner/learning-end.ts onlyLearnedWorkflows). */
128
132
  onlyWorkflow: "Nothing new: the run only ran a learned workflow.",
133
+ /** A run started with `learning: "use"`: it read what its agent learned and kept nothing, as asked. */
134
+ use: "Used what its agent learned; this run keeps nothing.",
129
135
  /** A merge whose every item the owner has since retired: nothing it learned is kept now. */
130
136
  retiredSince: "What it learned was retired since.",
131
137
  /** The run's answer gave its notes, but not in the format asked for, so none was read. */
@@ -144,7 +150,14 @@ export const said = {
144
150
  ? "Not kept: a note it would replace is gone or was changed since."
145
151
  : `Not kept: the agent's notes changed while this run ran (${rulesIn(problems)}).`,
146
152
  noBudget: "Skipped: no budget left in this run to look back.",
153
+ /** The run's grade did not fit what its cap left (its learning run's cap): not run, so nothing it learned is kept. */
154
+ noRoomToGrade: "Not graded: no room under the cap.",
155
+ /** A grade under a cap whose cost can't be kept within it (its spend or the grade model's price unknown). */
156
+ gradeUncapped: "Not graded: the grade's cost can't be kept under the cap.",
147
157
  unknownCost: "Skipped: this run's spend is unknown, so its budget can't cover looking back.",
158
+ /** A capped run whose spend under its cap is unknown once it looked back: its grade is not run (none could be kept
159
+ * within the cap), so nothing it learned is kept. */
160
+ gradeUnknownSpend: "Not graded: this run's spend is unknown, so its budget can't cover the grade.",
148
161
  stopped: (cause) => `Not kept: learning stopped (${cause}).`,
149
162
  };
150
163
  /** The reasons learn/grade.ts' parseVerdict gives of its own, never the grader's: an answer it could not read, and one
@@ -12,7 +12,8 @@ export declare const LEARNING_ENV = "AGENTRUN_SERVE_LEARNING";
12
12
  /** The switch: `given`, else AGENTRUN_SERVE_LEARNING, else on. Any other value is an error, and the server does not start. */
13
13
  export declare function learningOf(env: NodeJS.ProcessEnv, given?: string): LearningMode;
14
14
  /** How much of what a run learned its instructions hold under `# Learned` by default, in UTF-8 bytes (learnedParts): its
15
- * notes whole while they fit, else the index and the notes changed last, whole, while they fit. */
15
+ * notes whole while they fit, else the notes that bear most on the run whole while they fit, then a line for each of
16
+ * the next while they fit; the rest are left out, and the run's log names them. */
16
17
  export declare const LEARNING_BUDGET = 8000;
17
18
  export declare const LEARNING_BUDGET_ENV = "AGENTRUN_SERVE_LEARNING_BUDGET";
18
19
  /** The learning budget: `given` (`--learning-budget`), else AGENTRUN_SERVE_LEARNING_BUDGET, else LEARNING_BUDGET. Any
@@ -23,7 +24,11 @@ export declare function learningBudgetOf(env: NodeJS.ProcessEnv, given?: number)
23
24
  * checks and is kept (propose.ts), `merged` once it is on main (runner/learning-loop.ts), or `dropped` with a
24
25
  * reason from the closed list. A learning fault never refuses a run: it starts with nothing learned, `seed_failed`. */
25
26
  export declare const LEARNING_STATES: readonly ["seeded", "reflecting", "proposed", "merged", "dropped"];
26
- export declare const LEARNING_REASONS: readonly ["seed_failed", "no_budget", "unknown_cost", "cancelled", "crashed", "reflect_timeout", "reflect_failed", "empty", "unparsed", "propose_failed", "checker", "grader", "grade_failed"];
27
+ export declare const LEARNING_REASONS: readonly ["seed_failed", "no_budget", "unknown_cost", "cancelled", "crashed", "reflect_timeout", "reflect_failed", "empty", "unparsed", "propose_failed", "checker", "grader", "grade_failed", "use"];
28
+ /** A run's own `learning` on its start (POST /agents/{agent_id}/runs): it starts from what its agent learned, as a run that
29
+ * learns does, and keeps nothing (no end-of-run turn, no proposal, no grade, no merge, at any end), so runs of one agent
30
+ * read one learned state however many run at once. Its learning ends `dropped`, reason `use`. */
31
+ export declare const RUN_LEARNING_USE = "use";
27
32
  export type LearningState = (typeof LEARNING_STATES)[number];
28
33
  export type LearningReason = (typeof LEARNING_REASONS)[number];
29
34
  /** Tokens by the platform's names, as a run's metrics and /v2/stats count them: `input` is the input neither read from
@@ -102,6 +107,23 @@ export type Learning = {
102
107
  /** A grader's drop on two answers the host could not read: the last, cut of secrets and in size (UNREAD_MAX), kept on the
103
108
  * run's file to diagnose it by, and served by no read. */
104
109
  unread?: string;
110
+ /** The compile turn's record, when the run's end-of-run turn wrote the agent's job as a learned workflow
111
+ * (learn/compile.ts): the workflow, the notes it absorbed, and each attempt with what the checks refused. */
112
+ compiled?: LearningCompiled;
113
+ /** What the checks refused of a compiled draft that never passed: never silent, on the run's learning and its API. */
114
+ draft_errors?: string[];
115
+ };
116
+ /** A compile turn's record (learn/compile.ts CompiledRecord): `digest`, the kept draft's; `promoted`, read from the agent's
117
+ * promotion records when the run's learning is read, absent while undecided. */
118
+ export type LearningCompiled = {
119
+ workflow: string;
120
+ from_notes: string[];
121
+ attempts: {
122
+ ok: boolean;
123
+ errors: string[];
124
+ }[];
125
+ digest?: string;
126
+ promoted?: boolean;
105
127
  };
106
128
  /** A skill or a workflow draft a merge added or changed. */
107
129
  export type LearnedFile = {
@@ -163,8 +185,8 @@ export declare const learningView: (learning: Learning, shown: Shown, settled: b
163
185
  pending?: NoteUsed[];
164
186
  skills?: LearnedFile[];
165
187
  workflows?: LearnedFile[];
166
- state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
167
- reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
188
+ state: "proposed" | "dropped" | "merged" | "seeded" | "reflecting";
189
+ reason: "cancelled" | "no_budget" | "empty" | "unparsed" | "use" | "seed_failed" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
168
190
  detail: string | null;
169
191
  at: string;
170
192
  };
@@ -178,10 +200,10 @@ export declare function shortOf<T extends {
178
200
  detail: string | null;
179
201
  at: string;
180
202
  }>({ state, reason, detail, at: _, ...notes }: T): {
181
- state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
182
- reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
203
+ state: "proposed" | "dropped" | "merged" | "seeded" | "reflecting";
204
+ reason: "cancelled" | "no_budget" | "empty" | "unparsed" | "use" | "seed_failed" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
183
205
  detail: string | null;
184
- } & Omit<T, "at" | "reason" | "detail" | "state">;
206
+ } & Omit<T, "at" | "reason" | "state" | "detail">;
185
207
  /** The label of the end-of-run turn's timeline rows, and the kind and label of a run's learning row. */
186
208
  export declare const LEARNING_LABEL = "learning";
187
209
  /** A run's proposal, in its directory (propose.ts): the seed it was checked against, each new note's file and text, its
@@ -191,9 +213,12 @@ export declare const LEARNING_LABEL = "learning";
191
213
  export declare const PROPOSAL = "learning-proposal.json";
192
214
  /** A run's proposal: its notes, skill and drafts, each draft's dry run by its workflow.json's path (learn/skills.ts
193
215
  * draftDryRun: passed, or not run and why), the skill of each draft's name as the folder holds it at the seed
194
- * (`drafted`, its SKILL.md: shown to the grader beside the draft, never graded or merged), and what was said in the run. */
216
+ * (`drafted`, its SKILL.md: shown to the grader beside the draft, never graded or merged), and what was said in the run.
217
+ * `bases`: a file whose conflict base is not the seed, by its path: a revised workflow's, the commit of main its compile
218
+ * ask read it at. */
195
219
  export type Proposal = {
196
220
  seed: string;
221
+ bases?: Record<string, string>;
197
222
  notes: {
198
223
  file: string;
199
224
  text: string;
@@ -394,6 +419,9 @@ export type NoteCandidates = {
394
419
  readonly indexBytes: number;
395
420
  readonly indexComplete: boolean;
396
421
  readonly budget: number;
422
+ /** Whether the run has the read tool, so the section past the budget names `.learning/` (READ_LINE) and its room is kept
423
+ * for that line. Absent: kept, as for a run that has it. */
424
+ readonly read?: boolean;
397
425
  };
398
426
  /** A selector's choice: the notes the run reads whole, in the order it reads them (a subset of the candidates), and
399
427
  * whether it reads the index first. Without the index, the notes are all it is given; or, with `lines`, the notes it
@@ -408,14 +436,16 @@ export type NoteSelection = {
408
436
  * index when it serves it, fit `budget`, past which only the index may go (as loadedIndex bounds it). */
409
437
  export type NoteSelector = (candidates: NoteCandidates, run: RunInput) => NoteSelection;
410
438
  /** The selector by recency: every note whole while all fit the budget and the index names no note main does not hold
411
- * whole; else the index, then the newest notes that fit what it leaves, each whole. */
439
+ * whole; notes that fit with an index that names one it lacks, the index, then the newest notes that fit what it
440
+ * leaves, each whole; past the budget, the newest notes whole while they fit, then a line for each of the next while
441
+ * they fit (withinBudget). */
412
442
  export declare const byRecency: NoteSelector;
413
443
  /** The default selector, by relevance, past the budget: while the notes fit it, recency's choice (byRecency). Else each
414
444
  * note is scored against the run's input (learn/relevance.ts: BM25 over its name, description and body, a code
415
445
  * review's changed paths' words weighed PATH_WEIGHT; no model call), and the run reads the notes that bear on it most
416
- * whole, in score order, while they fit, then one rule line for each of the rest, best first, in place of the index; the lines count toward the
417
- * budget before the whole notes, as the index did, and no more of them than a run reads of the index (loadedIndex). An
418
- * input with no word any note holds reads by recency. */
446
+ * whole, best first, while they fit the budget, then one rule line for each of the next while they fit what is left
447
+ * (withinBudget), a note that bears on it in no word a line at most; the rest are left out. An input with no word any
448
+ * note holds reads by recency. */
419
449
  export declare const byRelevance: NoteSelector;
420
450
  /** What a run of `seed` reads under `# Learned` (`section`, the same for every harness, undefined when it learned
421
451
  * nothing) and the notes that names (`given`), from one choice of the selector, so the section and the given notes never
@@ -423,11 +453,14 @@ export declare const byRelevance: NoteSelector;
423
453
  * the index, nor counted toward the budget (readSeed reads active notes alone, and servedIndex drops their lines). Its
424
454
  * active notes, newest first (`seed.recent`, else by name), each whole while all fit `budget`; past it, the selector's
425
455
  * choice (byRelevance by default). An agent with the read tool is told the rest are in `.learning/`, one without is not.
456
+ * Notes past a budget that holds none of them (0 among them) are said to be there (NONE_FIT), never "Nothing learned yet.".
426
457
  * Every text is cut of the host's secrets. A run "was given" `given`; of them, it "read" those whose file it opened
427
- * (store-reads/learning.ts notesReadOf). Whether it applied one given whole is not measured. */
458
+ * (store-reads/learning.ts notesReadOf). Whether it applied one given whole is not measured. `left`: the active notes
459
+ * the section names in no way, over the budget, which the run's log names (runner/learning-seed.ts). */
428
460
  export declare function learnedParts(seed: Seed, options: LearnedOptions): {
429
461
  section: string | undefined;
430
462
  given: LearnedNote[];
463
+ left: LearnedNote[];
431
464
  };
432
465
  /** Lays each of `skills` in the run's `.agents/skills/<name>/` through its Workspace, a folder made new for it (one
433
466
  * already there throws EXISTS); a link on the way is ESCAPE, and nothing is written through it. Each name goes in
@@ -446,6 +479,11 @@ export declare function chooseSkills(work: Workspace, seed: Seed, own: readonly
446
479
  taken: LearnedSkill[];
447
480
  left: string[];
448
481
  }>;
482
+ /** Whether `text` holds a host secret (`shown`): as written, or, read as JSON, in any string it decodes to (its escapes
483
+ * decoded), or nested past the bound. The one check a learned workflow's text passes at a run's start (chooseWorkflows)
484
+ * and every text its compile turn is told (runner/learning-end.ts compileAskOf); a text that is not JSON is read as
485
+ * written. */
486
+ export declare const holdsSecret: (text: string, shown: Shown) => boolean;
449
487
  /** Which of `seed`'s learned workflows a run may run (its `learned_workflow` tool), in the seed's order: each while its
450
488
  * line (workflowLine) fits what is left of the tool's description budget (LEARNED_WORKFLOWS_BUDGET). One that does not,
451
489
  * or holds a host secret (`shown`), is left out and named in `left`, but for one whose name is itself a secret, never
@@ -475,10 +513,10 @@ export declare function readPin(runDir: string): Promise<Pin | undefined>;
475
513
  /** The heading of what a run learned, in its instructions. */
476
514
  export declare const LEARNED_HEADING = "# Learned";
477
515
  /** A run's instructions with its # Learned section laid in main's position: the revision's instructions, then the heading,
478
- * LEARNS, and the section text — "Nothing learned yet." when the run learns but its section is empty (no notes yet, or a
479
- * seed that could not be read). Shared so the runner (laying launch.learning.section, read with no folder) and app.ts
480
- * (withLearned) lay the same bytes. */
481
- export declare const laidLearned: (instructions: string, section: string | undefined) => string;
516
+ * LEARNS (USES for a run that only `use`s what its agent learned), and the section text — "Nothing learned yet." when the
517
+ * run learns but its section is empty (no notes yet, or a seed that could not be read). Shared so the runner (laying
518
+ * launch.learning.section, read with no folder) and app.ts (withLearned) lay the same bytes. */
519
+ export declare const laidLearned: (instructions: string, section: string | undefined, use?: boolean) => string;
482
520
  /** A run's instructions, with `# Learned` after them when its pin in `runDir` says it learns: that it learns, then what
483
521
  * the pin says it learned, or that it has learned nothing yet. A run with no pin (its agent does not learn, its seed
484
522
  * failed, a workflow's run) is never asked what to keep, so it is told nothing. And its skill files: the revision's