@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.35

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 (466) hide show
  1. package/CHANGELOG.md +368 -0
  2. package/README.md +341 -208
  3. package/dist/adapters.d.ts +3 -4
  4. package/dist/adapters.js +18 -15
  5. package/dist/agent-rows.d.ts +99 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +75 -25
  9. package/dist/agents.d.ts +9 -125
  10. package/dist/agents.js +15 -305
  11. package/dist/answer-json.d.ts +23 -0
  12. package/dist/answer-json.js +58 -0
  13. package/dist/api-only.d.ts +1 -1
  14. package/dist/api-only.js +2 -2
  15. package/dist/archil-settings.d.ts +11 -1
  16. package/dist/archil-settings.js +10 -0
  17. package/dist/bash-read-only.d.ts +35 -0
  18. package/dist/bash-read-only.js +778 -0
  19. package/dist/box-settings.d.ts +3 -23
  20. package/dist/box-settings.js +7 -51
  21. package/dist/boxes.d.ts +17 -0
  22. package/dist/boxes.js +27 -20
  23. package/dist/browser-commands.d.ts +5 -2
  24. package/dist/browser-commands.js +4 -4
  25. package/dist/browser-computer.d.ts +5 -0
  26. package/dist/browser-computer.js +21 -0
  27. package/dist/browser-cost.d.ts +9 -6
  28. package/dist/browser-cost.js +95 -51
  29. package/dist/browser-live.d.ts +7 -20
  30. package/dist/browser-live.js +15 -93
  31. package/dist/browser-person.d.ts +18 -51
  32. package/dist/browser-person.js +94 -277
  33. package/dist/budget.d.ts +0 -5
  34. package/dist/budget.js +0 -5
  35. package/dist/cap.d.ts +14 -8
  36. package/dist/cap.js +19 -9
  37. package/dist/cli.js +71 -18
  38. package/dist/closed-pipes.d.ts +2 -0
  39. package/dist/closed-pipes.js +13 -0
  40. package/dist/computer-commands.d.ts +2 -0
  41. package/dist/computer-commands.js +2 -0
  42. package/dist/computer-keys.d.ts +20 -10
  43. package/dist/computer-keys.js +36 -54
  44. package/dist/computer-setting.d.ts +20 -3
  45. package/dist/computer-setting.js +58 -10
  46. package/dist/computers.d.ts +35 -2
  47. package/dist/computers.js +72 -11
  48. package/dist/confine.d.ts +120 -0
  49. package/dist/confine.js +436 -0
  50. package/dist/console/assets/index-B7NKTU8E.css +1 -0
  51. package/dist/console/assets/index-CXZMgJE7.js +550 -0
  52. package/dist/console/index.html +2 -2
  53. package/dist/content-filter.d.ts +7 -0
  54. package/dist/content-filter.js +23 -0
  55. package/dist/decision-cap.d.ts +7 -29
  56. package/dist/decision-cap.js +3 -94
  57. package/dist/decision-rows.d.ts +1 -1
  58. package/dist/decision-rows.js +1 -1
  59. package/dist/docker-daemon.d.ts +31 -0
  60. package/dist/docker-daemon.js +56 -0
  61. package/dist/effort-guidance.js +4 -3
  62. package/dist/environment.d.ts +0 -3
  63. package/dist/environment.js +3 -5
  64. package/dist/errors.d.ts +1 -2
  65. package/dist/errors.js +9 -9
  66. package/dist/explain.js +3 -1
  67. package/dist/filed-answer.d.ts +32 -0
  68. package/dist/filed-answer.js +160 -0
  69. package/dist/files.d.ts +1 -3
  70. package/dist/files.js +2 -4
  71. package/dist/github-connection.d.ts +1 -1
  72. package/dist/github-connection.js +25 -7
  73. package/dist/github-faux.d.ts +26 -0
  74. package/dist/github-faux.js +76 -0
  75. package/dist/github.d.ts +6 -2
  76. package/dist/github.js +5 -3
  77. package/dist/graph-served.d.ts +5 -3
  78. package/dist/graph-served.js +14 -6
  79. package/dist/graph-view.d.ts +3 -5
  80. package/dist/graph-view.js +9 -16
  81. package/dist/handed-values.d.ts +9 -0
  82. package/dist/handed-values.js +26 -0
  83. package/dist/harness-install.d.ts +1 -7
  84. package/dist/harness-install.js +1 -18
  85. package/dist/harness-opencode/adapter.d.ts +7 -0
  86. package/dist/harness-opencode/adapter.js +23 -6
  87. package/dist/harness-opencode/harness.js +0 -1
  88. package/dist/harness-opencode/host/policy.js +2 -2
  89. package/dist/harness-opencode/index.d.ts +1 -1
  90. package/dist/harness-opencode/index.js +1 -1
  91. package/dist/harness-opencode/verify.d.ts +17 -0
  92. package/dist/harness-opencode/verify.js +30 -10
  93. package/dist/harness-table.js +6 -1
  94. package/dist/heard.js +1 -1
  95. package/dist/held-fd.d.ts +5 -0
  96. package/dist/held-fd.js +14 -0
  97. package/dist/host-calls.d.ts +20 -0
  98. package/dist/host-calls.js +12 -0
  99. package/dist/host-tools.d.ts +4 -21
  100. package/dist/host-tools.js +4 -61
  101. package/dist/host.d.ts +2 -4
  102. package/dist/host.js +2 -7
  103. package/dist/import-summary.d.ts +1 -5
  104. package/dist/import-summary.js +0 -21
  105. package/dist/import.d.ts +6 -6
  106. package/dist/import.js +14 -15
  107. package/dist/index.d.ts +1 -0
  108. package/dist/index.js +1 -0
  109. package/dist/key-refusal.d.ts +5 -1
  110. package/dist/key-refusal.js +19 -4
  111. package/dist/learn/check.d.ts +8 -2
  112. package/dist/learn/check.js +85 -31
  113. package/dist/learn/folder.d.ts +11 -4
  114. package/dist/learn/folder.js +17 -19
  115. package/dist/learn/grade.d.ts +18 -1
  116. package/dist/learn/grade.js +108 -14
  117. package/dist/learn/index.d.ts +5 -5
  118. package/dist/learn/index.js +5 -5
  119. package/dist/learn/learning.sh +1 -14
  120. package/dist/learn/notes.d.ts +14 -3
  121. package/dist/learn/notes.js +16 -6
  122. package/dist/learn/reflect.d.ts +31 -2
  123. package/dist/learn/reflect.js +83 -6
  124. package/dist/learn/relevance.d.ts +24 -0
  125. package/dist/learn/relevance.js +91 -0
  126. package/dist/learn/secrets.d.ts +7 -1
  127. package/dist/learn/secrets.js +86 -19
  128. package/dist/learn/skills.d.ts +159 -18
  129. package/dist/learn/skills.js +644 -64
  130. package/dist/learned-nodes.d.ts +14 -0
  131. package/dist/learned-nodes.js +8 -0
  132. package/dist/learned-workflow.d.ts +41 -6
  133. package/dist/learned-workflow.js +153 -18
  134. package/dist/learning-routes.d.ts +49 -4
  135. package/dist/learning-routes.js +113 -31
  136. package/dist/learning-run.d.ts +16 -31
  137. package/dist/learning-run.js +31 -38
  138. package/dist/learning-words.d.ts +12 -5
  139. package/dist/learning-words.js +18 -9
  140. package/dist/learning.d.ts +91 -97
  141. package/dist/learning.js +176 -320
  142. package/dist/live/stream.js +1 -1
  143. package/dist/live/translate.js +12 -2
  144. package/dist/llm.d.ts +4 -1
  145. package/dist/llm.js +4 -2
  146. package/dist/local-models.d.ts +11 -5
  147. package/dist/local-models.js +13 -8
  148. package/dist/mcp-gateway.d.ts +17 -49
  149. package/dist/mcp-gateway.js +55 -136
  150. package/dist/mcp-oauth.d.ts +10 -14
  151. package/dist/mcp-oauth.js +14 -32
  152. package/dist/mcp-probe.d.ts +0 -7
  153. package/dist/mcp-probe.js +4 -10
  154. package/dist/mcp-servers-store.d.ts +18 -18
  155. package/dist/mcp-servers-store.js +12 -14
  156. package/dist/mcp-store.js +3 -4
  157. package/dist/mcp.js +4 -3
  158. package/dist/model.d.ts +9 -7
  159. package/dist/model.js +51 -27
  160. package/dist/monid.d.ts +0 -2
  161. package/dist/monid.js +3 -6
  162. package/dist/openapi.d.ts +8 -1
  163. package/dist/openapi.js +156 -58
  164. package/dist/page.d.ts +1 -3
  165. package/dist/page.js +6 -18
  166. package/dist/paid-calls.d.ts +21 -27
  167. package/dist/paid-calls.js +26 -61
  168. package/dist/pause.d.ts +2 -19
  169. package/dist/pause.js +5 -74
  170. package/dist/port-models.d.ts +10 -3
  171. package/dist/port-models.js +26 -6
  172. package/dist/propose.d.ts +2 -0
  173. package/dist/propose.js +80 -45
  174. package/dist/push-handler.d.ts +1 -1
  175. package/dist/reflect-range.d.ts +25 -0
  176. package/dist/reflect-range.js +30 -0
  177. package/dist/refusal-words.d.ts +5 -1
  178. package/dist/refusal-words.js +5 -1
  179. package/dist/rows.d.ts +1 -1
  180. package/dist/run-cut.d.ts +0 -6
  181. package/dist/run-cut.js +0 -6
  182. package/dist/run-db.d.ts +2 -11
  183. package/dist/run-db.js +2 -37
  184. package/dist/run-launch.d.ts +21 -2
  185. package/dist/run-launch.js +14 -5
  186. package/dist/run-learning-served.d.ts +21 -4
  187. package/dist/run-learning-served.js +23 -13
  188. package/dist/run-reads-over-store.d.ts +5 -3
  189. package/dist/run-reads-over-store.js +25 -14
  190. package/dist/run-secrets.d.ts +1 -1
  191. package/dist/run-timeline-served.d.ts +5 -1
  192. package/dist/run-timeline-served.js +27 -6
  193. package/dist/run-view.d.ts +37 -22
  194. package/dist/run-view.js +85 -38
  195. package/dist/runnable.d.ts +21 -10
  196. package/dist/runnable.js +35 -12
  197. package/dist/runner/adapter-loop.d.ts +36 -5
  198. package/dist/runner/adapter-loop.js +663 -69
  199. package/dist/runner/adapter-run-spec.d.ts +42 -8
  200. package/dist/runner/adapter-run-spec.js +186 -52
  201. package/dist/runner/adapters/index.js +11 -1
  202. package/dist/runner/adapters/pi.d.ts +40 -2
  203. package/dist/runner/adapters/pi.js +110 -27
  204. package/dist/runner/beside.d.ts +38 -3
  205. package/dist/runner/beside.js +54 -5
  206. package/dist/runner/claim-secrets.d.ts +16 -1
  207. package/dist/runner/claim-secrets.js +62 -14
  208. package/dist/runner/cli-run-spec.d.ts +5 -0
  209. package/dist/runner/cli-run-spec.js +159 -41
  210. package/dist/runner/commands.js +1 -1
  211. package/dist/runner/computer-journal.d.ts +15 -2
  212. package/dist/runner/computer-journal.js +41 -5
  213. package/dist/runner/conformance/harness.d.ts +1 -0
  214. package/dist/runner/conformance/harness.js +123 -13
  215. package/dist/runner/conformance/subject.d.ts +4 -1
  216. package/dist/runner/dispatch.d.ts +8 -1
  217. package/dist/runner/dispatch.js +81 -7
  218. package/dist/runner/end-of-run.d.ts +8 -2
  219. package/dist/runner/end-of-run.js +10 -4
  220. package/dist/runner/github-app.d.ts +7 -2
  221. package/dist/runner/github-app.js +47 -16
  222. package/dist/runner/harness-loops.d.ts +15 -2
  223. package/dist/runner/harness-loops.js +38 -2
  224. package/dist/runner/journal-kinds.d.ts +60 -6
  225. package/dist/runner/journal-kinds.js +43 -5
  226. package/dist/runner/journal-reader.d.ts +1 -1
  227. package/dist/runner/journal-reader.js +2 -2
  228. package/dist/runner/learning-ask.d.ts +4 -0
  229. package/dist/runner/learning-ask.js +15 -1
  230. package/dist/runner/learning-end.d.ts +18 -3
  231. package/dist/runner/learning-end.js +194 -20
  232. package/dist/runner/learning-loop.d.ts +7 -0
  233. package/dist/runner/learning-loop.js +36 -8
  234. package/dist/runner/learning-seed.d.ts +6 -0
  235. package/dist/runner/learning-seed.js +6 -0
  236. package/dist/runner/loop-contract.d.ts +4 -0
  237. package/dist/runner/main.d.ts +61 -9
  238. package/dist/runner/main.js +144 -20
  239. package/dist/runner/mcp-claim.d.ts +3 -0
  240. package/dist/runner/mcp-claim.js +7 -3
  241. package/dist/runner/mcp-github.d.ts +11 -2
  242. package/dist/runner/mcp-github.js +55 -4
  243. package/dist/runner/mcp-run.d.ts +2 -0
  244. package/dist/runner/mcp-run.js +16 -5
  245. package/dist/runner/memory-claim.d.ts +9 -0
  246. package/dist/runner/memory-claim.js +25 -0
  247. package/dist/runner/metrics.d.ts +46 -1
  248. package/dist/runner/metrics.js +156 -1
  249. package/dist/runner/model-route.d.ts +16 -0
  250. package/dist/runner/model-route.js +134 -10
  251. package/dist/runner/reflect-hook.d.ts +12 -1
  252. package/dist/runner/reflect-hook.js +33 -3
  253. package/dist/runner/runner.d.ts +20 -0
  254. package/dist/runner/runner.js +146 -18
  255. package/dist/runner/spec-holds.d.ts +7 -2
  256. package/dist/runner/spec-holds.js +4 -3
  257. package/dist/runner/store-port.d.ts +1 -1
  258. package/dist/runner/store-secrets.d.ts +3 -3
  259. package/dist/runner/store-secrets.js +8 -12
  260. package/dist/runner/text-tools.d.ts +44 -0
  261. package/dist/runner/text-tools.js +237 -0
  262. package/dist/runner/workflow-host.d.ts +7 -2
  263. package/dist/runner/workflow-host.js +3 -1
  264. package/dist/runner/workflow-loop.d.ts +10 -1
  265. package/dist/runner/workflow-loop.js +14 -6
  266. package/dist/runner/workflow-spec.d.ts +21 -0
  267. package/dist/runner/workflow-spec.js +217 -93
  268. package/dist/runs-over-store.d.ts +14 -3
  269. package/dist/runs-over-store.js +100 -23
  270. package/dist/seal-key.d.ts +0 -2
  271. package/dist/seal-key.js +5 -45
  272. package/dist/sealed-settings-store.d.ts +19 -4
  273. package/dist/sealed-settings-store.js +9 -9
  274. package/dist/sealing.d.ts +4 -0
  275. package/dist/sealing.js +20 -0
  276. package/dist/secret-cut.d.ts +1 -1
  277. package/dist/secret-cut.js +1 -1
  278. package/dist/secret-name.d.ts +9 -0
  279. package/dist/secret-name.js +15 -0
  280. package/dist/secret-writes.d.ts +0 -1
  281. package/dist/secret-writes.js +0 -1
  282. package/dist/server-fs.d.ts +4 -0
  283. package/dist/server-fs.js +8 -2
  284. package/dist/server-lock.d.ts +0 -24
  285. package/dist/server-lock.js +5 -85
  286. package/dist/server-secrets-store.d.ts +4 -4
  287. package/dist/server-secrets-store.js +9 -31
  288. package/dist/server-secrets.d.ts +4 -9
  289. package/dist/server-secrets.js +12 -36
  290. package/dist/server.d.ts +37 -56
  291. package/dist/server.js +322 -134
  292. package/dist/sign-ins-store.d.ts +34 -36
  293. package/dist/sign-ins-store.js +27 -38
  294. package/dist/sign-ins.d.ts +2 -119
  295. package/dist/sign-ins.js +5 -311
  296. package/dist/standard-webhooks.d.ts +1 -1
  297. package/dist/standard-webhooks.js +1 -1
  298. package/dist/stats.d.ts +3 -2
  299. package/dist/stats.js +1 -1
  300. package/dist/stop-signals.d.ts +4 -2
  301. package/dist/stop-signals.js +5 -3
  302. package/dist/store/agent-body.d.ts +12 -2
  303. package/dist/store/agent-body.js +22 -4
  304. package/dist/store/deadline.d.ts +18 -0
  305. package/dist/store/deadline.js +45 -0
  306. package/dist/store/index.d.ts +2 -2
  307. package/dist/store/index.js +2 -2
  308. package/dist/store/open.d.ts +6 -3
  309. package/dist/store/open.js +2 -2
  310. package/dist/store/postgres/connection.d.ts +22 -2
  311. package/dist/store/postgres/connection.js +211 -41
  312. package/dist/store/postgres/migrate.d.ts +4 -0
  313. package/dist/store/postgres/migrate.js +9 -2
  314. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  315. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  316. package/dist/store/postgres/store.d.ts +9 -2
  317. package/dist/store/postgres/store.js +9 -0
  318. package/dist/store/schema.js +1 -1
  319. package/dist/store/seal.js +2 -2
  320. package/dist/store/sqlite/connection.js +14 -5
  321. package/dist/store/sqlite/run-patch.d.ts +3 -0
  322. package/dist/store/sqlite/run-patch.js +3 -0
  323. package/dist/store/sqlite/store.js +41 -12
  324. package/dist/store/store.d.ts +35 -6
  325. package/dist/store/store.js +12 -2
  326. package/dist/store-reads/cap.d.ts +1 -1
  327. package/dist/store-reads/cap.js +22 -4
  328. package/dist/store-reads/journal.d.ts +9 -6
  329. package/dist/store-reads/journal.js +129 -18
  330. package/dist/store-reads/learning.d.ts +82 -8
  331. package/dist/store-reads/learning.js +184 -11
  332. package/dist/store-reads/workflow.d.ts +1 -1
  333. package/dist/store-reads/workflow.js +1 -1
  334. package/dist/store-view.d.ts +19 -1
  335. package/dist/store-view.js +95 -27
  336. package/dist/template-eval.d.ts +60 -4
  337. package/dist/template-eval.js +120 -54
  338. package/dist/templates.d.ts +33 -14
  339. package/dist/templates.js +82 -46
  340. package/dist/timeline/group.d.ts +33 -0
  341. package/dist/timeline/group.js +77 -0
  342. package/dist/timeline/index.d.ts +7 -0
  343. package/dist/timeline/index.js +7 -0
  344. package/dist/timeline/labels.d.ts +79 -0
  345. package/dist/timeline/labels.js +150 -0
  346. package/dist/timeline/origin.d.ts +56 -0
  347. package/dist/timeline/origin.js +92 -0
  348. package/dist/timeline/render-text.d.ts +11 -0
  349. package/dist/timeline/render-text.js +62 -0
  350. package/dist/timeline/timeline.d.ts +282 -0
  351. package/dist/timeline/timeline.js +1308 -0
  352. package/dist/timeline/util.d.ts +17 -0
  353. package/dist/timeline/util.js +49 -0
  354. package/dist/tool-budget.d.ts +18 -0
  355. package/dist/tool-budget.js +50 -0
  356. package/dist/tool-gate.d.ts +47 -218
  357. package/dist/tool-gate.js +87 -545
  358. package/dist/tool-keys-store.d.ts +11 -12
  359. package/dist/tool-keys-store.js +24 -31
  360. package/dist/tool-keys.d.ts +5 -101
  361. package/dist/tool-keys.js +8 -267
  362. package/dist/tool-plane.d.ts +23 -52
  363. package/dist/tool-plane.js +23 -81
  364. package/dist/tool-settings-store.d.ts +1 -2
  365. package/dist/tool-settings-store.js +5 -8
  366. package/dist/tools.d.ts +67 -25
  367. package/dist/tools.js +170 -119
  368. package/dist/trigger-adapter.d.ts +2 -2
  369. package/dist/trigger-targets.d.ts +13 -1
  370. package/dist/trigger-targets.js +31 -1
  371. package/dist/triggers.d.ts +2 -2
  372. package/dist/triggers.js +3 -3
  373. package/dist/turn-end.d.ts +1 -1
  374. package/dist/turn-end.js +1 -1
  375. package/dist/turns.d.ts +0 -6
  376. package/dist/turns.js +0 -19
  377. package/dist/uploads.d.ts +28 -5
  378. package/dist/uploads.js +83 -10
  379. package/dist/usage.d.ts +1 -49
  380. package/dist/usage.js +3 -84
  381. package/dist/validate.d.ts +4 -0
  382. package/dist/validate.js +33 -14
  383. package/dist/webhooks.d.ts +102 -76
  384. package/dist/webhooks.js +266 -233
  385. package/dist/workflow-run.d.ts +114 -0
  386. package/dist/workflow-run.js +144 -0
  387. package/dist/workspace/archil-claim.d.ts +2 -2
  388. package/dist/workspace/archil-claim.js +4 -3
  389. package/dist/workspace/archil-disk.d.ts +10 -1
  390. package/dist/workspace/archil-disk.js +4 -0
  391. package/dist/workspace/archil-exec.d.ts +12 -2
  392. package/dist/workspace/archil-exec.js +16 -0
  393. package/dist/workspace/archil.d.ts +2 -2
  394. package/dist/workspace/archil.js +25 -5
  395. package/dist/workspace/attach.js +2 -0
  396. package/dist/workspace/beneath.d.ts +19 -0
  397. package/dist/workspace/beneath.js +106 -0
  398. package/dist/workspace/computer-deps.d.ts +26 -9
  399. package/dist/workspace/computer-deps.js +144 -43
  400. package/dist/workspace/computer-for-claim.d.ts +17 -14
  401. package/dist/workspace/computer-for-claim.js +99 -26
  402. package/dist/workspace/computer-hold.d.ts +6 -1
  403. package/dist/workspace/computer-hold.js +6 -1
  404. package/dist/workspace/computer-janitor.d.ts +47 -0
  405. package/dist/workspace/computer-janitor.js +182 -0
  406. package/dist/workspace/computer-ledger.d.ts +1 -8
  407. package/dist/workspace/computer-ledger.js +0 -3
  408. package/dist/workspace/computer-providers.d.ts +5 -3
  409. package/dist/workspace/computer-providers.js +11 -9
  410. package/dist/workspace/grep-worker.d.ts +5 -0
  411. package/dist/workspace/grep-worker.js +9 -6
  412. package/dist/workspace/hands.d.ts +5 -2
  413. package/dist/workspace/hands.js +4 -3
  414. package/dist/workspace/index.d.ts +6 -5
  415. package/dist/workspace/index.js +4 -4
  416. package/dist/workspace/local.d.ts +14 -2
  417. package/dist/workspace/local.js +170 -43
  418. package/dist/workspace/paths.js +3 -2
  419. package/dist/workspace/pi-env.d.ts +4 -0
  420. package/dist/workspace/pi-env.js +3 -2
  421. package/dist/workspace/resolve-computer.d.ts +55 -10
  422. package/dist/workspace/resolve-computer.js +66 -14
  423. package/dist/workspace/run-tools.d.ts +15 -31
  424. package/dist/workspace/run-tools.js +19 -30
  425. package/dist/workspace/workspace.d.ts +5 -0
  426. package/dist/workspace-paths.d.ts +0 -17
  427. package/dist/workspace-paths.js +1 -41
  428. package/dist/workspace.d.ts +0 -17
  429. package/dist/workspace.js +4 -110
  430. package/package.json +14 -14
  431. package/skills/agentrun-serve/SKILL.md +1 -1
  432. package/templates/README.md +11 -5
  433. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  434. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  435. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  436. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  437. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  438. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  439. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  440. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  441. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  442. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  443. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  444. package/templates/market-monitor/agent.md +2 -2
  445. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  446. package/templates/release-notes/agent.md +11 -0
  447. package/dist/bound-files.d.ts +0 -4
  448. package/dist/bound-files.js +0 -164
  449. package/dist/coding-tools.d.ts +0 -47
  450. package/dist/coding-tools.js +0 -189
  451. package/dist/computer-adb.d.ts +0 -12
  452. package/dist/computer-adb.js +0 -14
  453. package/dist/console/assets/index-Dn0ngwG9.js +0 -535
  454. package/dist/console/assets/index-DvW6Aled.css +0 -1
  455. package/dist/grade.d.ts +0 -63
  456. package/dist/grade.js +0 -150
  457. package/dist/mcp-servers.d.ts +0 -269
  458. package/dist/mcp-servers.js +0 -456
  459. package/dist/packs.d.ts +0 -71
  460. package/dist/packs.js +0 -180
  461. package/dist/sealed-settings.d.ts +0 -60
  462. package/dist/sealed-settings.js +0 -171
  463. package/dist/sessions.d.ts +0 -6
  464. package/dist/sessions.js +0 -109
  465. package/dist/workspace/computer-serves.d.ts +0 -12
  466. package/dist/workspace/computer-serves.js +0 -15
@@ -1,7 +1,7 @@
1
- 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, unstorable, WORKFLOWS_DIR } from "./learn/index.js";
2
- import { beforeRetire, blobOid, FolderBusy, FolderRefused, FolderTooLarge, FolderUnreadable, heldOnMain, isBodyMismatch, readLearning, PATCH_CAP, readRunDiff, readSnapshot, snapshotNotes, writeLearning } from "./learn/folder.js";
1
+ 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, 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";
3
3
  import { ApiError, invalid } from "./errors.js";
4
- import { detailShown, learningFolderOf, notesView, secretsShown, withAgentRepo } from "./learning.js";
4
+ import { detailShown, learningFolderOf, notesView, reasonShown, secretsShown, withAgentRepo } from "./learning.js";
5
5
  import { isObject } from "./validate.js";
6
6
  import { launchOf } from "./handed-values.js";
7
7
  import { learningStartOf } from "./run-launch.js";
@@ -11,7 +11,8 @@ const NOTES_PAGE = 50;
11
11
  const LOG_PAGE = 20;
12
12
  const PAGE_MAX = 200;
13
13
  /** What a retire adds to a note, on top of the note cap a retired note may fill (learn/notes.ts retire). */
14
- const RETIRED_LINE = Buffer.byteLength("status: retired\n");
14
+ /** What a retire adds to a note: its status line and the status it took it from (the longer of the two). */
15
+ const RETIRED_LINE = Buffer.byteLength("status: retired\nretired_from: pending\n");
15
16
  export { secretsShown } from "./learning.js";
16
17
  /** The few values last kept, by key, oldest dropped first: at most `entries` of them. */
17
18
  class Recent {
@@ -70,14 +71,16 @@ async function reading(data, agentId, read, none) {
70
71
  }
71
72
  /** A retired item's `retired`: its newest retire by a person; else, one a person made retired another way (an edit to
72
73
  * status: retired, or created so), their newest change; else (retired by none of theirs) its newest change's time. */
73
- const retiredOf = (history) => (history.retire ? { at: history.retire.at, by: "person" } : history.person ? { at: history.person.at, by: "person" } : { at: history.at, by: "run" });
74
+ /** `from`: the status its restore gives back (its retire recorded it, retired_from; none recorded reads pending, as its
75
+ * restore gives it: only an approval makes an item active). */
76
+ const retiredOf = (history, from) => ({ ...(history.retire ? { at: history.retire.at, by: "person" } : history.person ? { at: history.person.at, by: "person" } : { at: history.at, by: "run" }), from: from ?? "pending" });
74
77
  /** A note as the view shows it, cut of the host's secrets: its name and the one that superseded it whole; with its
75
78
  * ETag, the one its file's GET answers, so an edit or a retire from the card names the version it shows; its last
76
79
  * change, and when and by whom it was retired on a retired one. */
77
80
  const noteView = (note, text, shown, runs) => ({
78
81
  file: shown.name(note.file), name: shown.text(note.name), description: shown.text(note.description), type: note.type, status: note.status, origin: note.origin, superseded_by: note.superseded_by === null ? null : shown.name(note.superseded_by), text: shown.text(text), etag: etagOf(note.oid), runs: { ...(runs.get(note.file) ?? { given: 0, read: 0 }) },
79
82
  ...(note.history.last ? { last_change: note.history.last } : {}),
80
- ...(note.status === "retired" ? { retired: retiredOf(note.history) } : {}),
83
+ ...(note.status === "retired" ? { retired: retiredOf(note.history, note.retired_from) } : {}),
81
84
  });
82
85
  function learnedView(item, kind, shown) {
83
86
  const file = kind === "skill" ? item.file : `${WORKFLOWS_DIR}/${item.name}/workflow.json`;
@@ -85,7 +88,7 @@ function learnedView(item, kind, shown) {
85
88
  return {
86
89
  name: shown.name(item.name), file: shown.name(file), ...(kind === "workflow" ? { readme: shown.name(item.file) } : {}), description: shown.text(item.description), status: item.status, run: item.run, bytes, etag: etagOf(item.oid),
87
90
  ...(item.history.last ? { last_change: item.history.last } : {}),
88
- ...(item.status === "retired" ? { retired: retiredOf(item.history) } : {}),
91
+ ...(item.status === "retired" ? { retired: retiredOf(item.history, item.retired_from) } : {}),
89
92
  };
90
93
  }
91
94
  /** A change on main as the log shows it, cut of the host's secrets. */
@@ -354,18 +357,29 @@ export async function writeNote(data, agentId, raw, input) {
354
357
  throw new ApiError("precondition_failed", "The folder has a note by this name: read it, then edit it with If-Match.");
355
358
  // A note whose text holds one of the host's secrets as they are now (a value made secret after it was written) is
356
359
  // read cut of it, under its own ETag: an edit of what was shown would write the cut over the hidden text. Only a
357
- // retire reaches it.
360
+ // retire reaches it. So is one holding a loopback address, read as "a local address" (secretsShown).
358
361
  if (given !== undefined && current && secretsShown(input.refuse).holds(current.text)) {
359
362
  throw refused([{ rule: "secret_value", path: file, detail: "This note holds a value the server now keeps secret, so its text was shown with that value hidden, and saving would replace the hidden text. Retire it and write a new note instead." }]);
360
363
  }
364
+ if (given !== undefined && current && secretsShown(input.refuse).text(current.text) !== current.text) {
365
+ throw refused([{ rule: "note", path: file, detail: "This note holds a local address, so its text was shown with it hidden, and saving would replace it. Retire it and write a new note instead." }]);
366
+ }
361
367
  let text = given;
362
368
  // A note that waits for its owner's OK is made active by an approval alone: an edit keeps it waiting, so one that
363
- // drops or changes its status is refused, whoever sends it.
369
+ // drops or changes its status is refused, whoever sends it. A retired note comes back by its restore alone, to the
370
+ // status its retire recorded: an edit keeps it retired and keeps that record (retired_from) as it is.
364
371
  if (given !== undefined && current) {
365
372
  const was = parseNoteFile(file, current.text);
366
373
  const now = parseNoteFile(file, given);
367
374
  if (!Array.isArray(was) && was.status === "pending" && !Array.isArray(now) && now.status !== "pending")
368
375
  throw refused([printable({ rule: "status", path: file, detail: "it waits for its owner's OK: an edit keeps status: pending, only an approval makes it active, and a retire takes it out" }, input.refuse)]);
376
+ if (!Array.isArray(was) && was.status === "retired" && !Array.isArray(now)) {
377
+ const kept = was.retired_from ?? "pending";
378
+ if (now.status !== "retired" || (now.keys.includes("retired_from") && now.retired_from !== kept))
379
+ throw refused([printable({ rule: "status", path: file, detail: `it is retired: an edit keeps status: retired and retired_from: ${kept}, and only its restore brings it back, as it was before its retire` }, input.refuse)]);
380
+ // What its retire recorded is the host's: the edit carries it, written or not.
381
+ text = retire(given, kept);
382
+ }
369
383
  }
370
384
  // Beside the note itself: what an approve marks of the notes the approved one supersedes.
371
385
  const also = new Map();
@@ -376,20 +390,24 @@ export async function writeNote(data, agentId, raw, input) {
376
390
  if (notes.get(old)?.status === "active")
377
391
  also.set(old, supersede(await body(old, noteOid(old)), file));
378
392
  };
379
- let heldBefore = false;
380
393
  if (input.restore) {
381
- // Restored, a retired note, skill or draft is active again: given to every later run. It is checked again as a
382
- // new one is (secrets' shapes, the host's values, hidden characters, its format, every file of a skill's or a
383
- // draft's folder): a retire takes a leaking one out of every run unchecked, and a restore never brings it back.
384
- // One that waited for its owner's OK before its retire is recorded as their approval too (Approved-Via).
385
- const before = await beforeRetire(ws, main, file);
386
- heldBefore = before !== undefined && (learned ? learnedStatus(before) === "pending" : ((note) => !Array.isArray(note) && note.status === "pending")(parseNoteFile(file, before)));
394
+ // Restored, a retired note, skill or draft goes back to the status its retire recorded (retired_from): active, so
395
+ // given to every later run, or waiting for its owner's OK again, so a retire and a restore never skip that OK
396
+ // (a retire that recorded none restores it waiting). It is checked again as a new one is (secrets' shapes, the
397
+ // host's values, hidden characters, its format, every file of a skill's or a draft's folder): a retire takes a
398
+ // leaking one out of every run unchecked, and a restore never brings it back. A restore is never an approval.
387
399
  if (learned) {
388
400
  const status = learnedStatus(current.text);
389
401
  const kind = learned.kind === "skill" ? "skill" : "workflow";
390
402
  if (status !== "retired")
391
403
  throw new ApiError("bad_request", `The ${kind} is not retired: it is ${status}.`);
392
- text = released(current.text);
404
+ // Read as retired since its front matter reads no way, or its status (or the retired_from its retire recorded) is
405
+ // set on more than one line, which no writer edits (learnedStatus, restorable): refused until it is written so.
406
+ if (!restorable(current.text))
407
+ throw refused([printable({ rule: kind, path: file, detail: UNCLEAR_FRONT }, input.refuse)]);
408
+ // Back to the status its retire recorded (restoredLearned: retired_from, read by the one reader), never active
409
+ // unless it was active: a held skill or draft waits for its owner's OK again.
410
+ text = restoredLearned(current.text);
393
411
  const problems = skillProblems(text, learned.name).map((detail) => printable({ rule: kind, path: file, detail }, input.refuse));
394
412
  const extra = (frontKeys(text) ?? []).filter((key) => !LEARNED_KEYS.includes(key) && key !== "status");
395
413
  if (extra.length)
@@ -402,9 +420,9 @@ export async function writeNote(data, agentId, raw, input) {
402
420
  // a restore never brings back a draft no run could run.
403
421
  const draft = changes.find(({ path }) => path === `${folder}workflow.json`);
404
422
  if (learned.kind !== "skill" && draft && input.draftTools) {
405
- const { tools, gated } = await input.draftTools();
423
+ const { tools, gated, deniedBy, ask } = await input.draftTools();
406
424
  const dsl = await import("@parcha/agentrun-dsl");
407
- for (const { rule, detail } of draftProblems(dsl, draft.bytes.toString("utf8"), tools, gated))
425
+ for (const { rule, detail } of draftProblems(dsl, draft.bytes.toString("utf8"), tools, gated, deniedBy ?? {}, ask))
408
426
  problems.push(printable({ rule, path: draft.path, detail }, input.refuse));
409
427
  }
410
428
  if (problems.length)
@@ -416,12 +434,14 @@ export async function writeNote(data, agentId, raw, input) {
416
434
  throw refused(note.map((detail) => printable({ rule: "note", path: file, detail }, input.refuse)));
417
435
  if (note.status !== "retired")
418
436
  throw new ApiError("bad_request", `The note is not retired: it is ${note.status}.`);
419
- text = approve(current.text);
437
+ text = restore(current.text, note);
420
438
  const { problems } = checkNote(file, Buffer.from(text, "utf8"), input.refuse);
421
439
  if (problems.length)
422
440
  throw refused(problems);
423
- // What it supersedes, and is active still, is superseded now, as an approval marks it.
424
- await mark(note.supersedes);
441
+ // Back active, what it supersedes, and is active still, is superseded now, as an approval marks it; back
442
+ // waiting, it supersedes nothing until it is approved.
443
+ if (note.retired_from === "active")
444
+ await mark(note.supersedes);
425
445
  }
426
446
  }
427
447
  else if (text === undefined && learned && !input.approve) {
@@ -458,13 +478,13 @@ export async function writeNote(data, agentId, raw, input) {
458
478
  // A retire is how a person takes a note out of every later run's prompt, a leaking one above all, so it always
459
479
  // can: only the note's format is checked as retired (its front matter parses, and it fits the note cap with the
460
480
  // status line added), never a secret in its name or text. Every answer cuts those as any read does.
461
- text = retire(current.text);
481
+ text = retire(current.text, note.status === "pending" ? "pending" : "active");
462
482
  const retired = parseNoteFile(file, text);
463
483
  if (Array.isArray(retired))
464
484
  throw refused(retired.map((detail) => printable({ rule: "note", path: file, detail }, input.refuse)));
465
485
  const size = Buffer.byteLength(text);
466
486
  if (size > CAPS.note + RETIRED_LINE)
467
- throw refused([printable({ rule: "too_large", path: file, detail: `${size} bytes as retired; the cap is ${CAPS.note}, and the status line a retire adds` }, input.refuse)]);
487
+ 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)]);
468
488
  }
469
489
  if (current && text === current.text)
470
490
  return { result: { status: 200, file, text, etag: etagOf(current.oid) } };
@@ -475,7 +495,7 @@ export async function writeNote(data, agentId, raw, input) {
475
495
  const kind = input.approve ? "approved" : input.restore ? "restored" : given === undefined ? "retired" : current ? "edited" : "created";
476
496
  const change = {
477
497
  // Who approved, and how, in the trailers; the commit's own date is when. Never the note's text.
478
- by: { person: kind, file, approved: Boolean(input.approve || heldBefore) },
498
+ by: { person: kind, file, approved: Boolean(input.approve) },
479
499
  writes: [{ path: file, text: text }, { path: INDEX_FILE, text: buildIndex(after) }, ...[...also].map(([path, marked]) => ({ path, text: marked }))],
480
500
  // A create takes a name main holds nothing by, as git holds it: a file the notes leave out included.
481
501
  ...(current ? {} : { absent: [file] }),
@@ -496,6 +516,55 @@ export async function writeNote(data, agentId, raw, input) {
496
516
  }
497
517
  });
498
518
  }
519
+ /** POST /agents/{id}/learning/workflows/{name}/promote's read of the learned workflow `raw` (percent-encoded) on agent
520
+ * `agentId`'s main: an active one alone, as every later run is given it. One that waits for its owner's OK, or that a
521
+ * person retired, is 409 learned_not_active: a promotion never runs what the owner has not let every run use. Each of
522
+ * its files is checked again as a restore checks it (unstorable: a secret's shape, the host's values as they are now,
523
+ * a hidden character), and its workflow.json as the learning checker checks a run's draft against the agent's tools and
524
+ * its gate (draftProblems: the DSL's validation with no code run, no code node, no shell or executor call, no call node
525
+ * on a tool the agent does not have or the gate holds to ask or deny). Any of those is 400 with `problems`, printable.
526
+ * Reads only: the folder is never written. */
527
+ export async function promotable(data, agentId, raw, input) {
528
+ let name;
529
+ try {
530
+ name = decodeURIComponent(raw);
531
+ }
532
+ catch {
533
+ throw new ApiError("bad_request", "the workflow's name is not percent-encoded right");
534
+ }
535
+ if (!learnedName("workflow", name))
536
+ throw new ApiError("bad_request", "A learned workflow's folder is named with lowercase letters, digits, dashes and underscores.");
537
+ const found = await reading(data, agentId, async ({ snapshot, body }) => {
538
+ const item = snapshot.workflows.find((one) => one.name === name);
539
+ if (!item)
540
+ return undefined;
541
+ if (item.status !== "active")
542
+ return { item, files: [] };
543
+ return { item, files: await Promise.all(item.files.map(async ({ path, oid }) => ({ path, text: await body(path, oid) }))) };
544
+ }, () => undefined);
545
+ if (!found)
546
+ throw new ApiError("not_found", "the agent's learning folder has no such workflow on main");
547
+ const { item, files } = found;
548
+ if (item.status === "pending")
549
+ throw new ApiError("learned_not_active", "This workflow waits for your OK: approve it first. Making it an agent never skips your OK.");
550
+ if (item.status !== "active")
551
+ throw new ApiError("learned_not_active", "This workflow is retired: restore it first to make it an agent.");
552
+ const file = `${WORKFLOWS_DIR}/${name}/workflow.json`;
553
+ const json = files.find(({ path }) => path === file);
554
+ const problems = unstorable(files.map(({ path, text }) => ({ path, status: "modified", bytes: Buffer.from(text, "utf8") })), input.refuse);
555
+ if (!json)
556
+ problems.push(printable({ rule: "workflow", path: file, detail: "the workflow's folder holds no workflow.json" }, input.refuse));
557
+ const dsl = await import("@parcha/agentrun-dsl");
558
+ if (json && !problems.length) {
559
+ const { tools, gated, deniedBy } = await input.draftTools();
560
+ for (const { rule, detail } of draftProblems(dsl, json.text, tools, gated, deniedBy ?? {}))
561
+ problems.push(printable({ rule, path: file, detail }, input.refuse));
562
+ }
563
+ if (problems.length)
564
+ throw new ApiError("bad_request", `The workflow does not pass the checks: ${[...new Set(problems.map((problem) => problem.rule))].join(", ")}.`, { problems });
565
+ const workflow = JSON.parse(json.text);
566
+ return { name, description: item.description, workflow, calls: dsl.inspectWorkflow(workflow).requires.tools };
567
+ }
499
568
  /** GET /runs/{id}/learning's body, from the run's learning as it reads now, the seed it started from and whether it
500
569
  * settled: the one shape, read from the one store (store-reads/learning.ts
501
570
  * runLearningOverStore). */
@@ -503,7 +572,7 @@ export function runLearningBody(input, shown, secrets) {
503
572
  const { learning } = input;
504
573
  const { state, reason, at, verdict, problems, merged, cost_usd, tokens, pending } = learning;
505
574
  return {
506
- run: input.id, state, reason, detail: detailShown(learning, shown), at,
575
+ run: input.id, state, reason: reasonShown(reason, shown), detail: detailShown(learning, shown), at,
507
576
  // Once it settled (a run that runs again for a follow-up is still reading).
508
577
  ...notesView(learning, shown, input.settled),
509
578
  seed: input.seed,
@@ -511,12 +580,19 @@ export function runLearningBody(input, shown, secrets) {
511
580
  // The merge's notes that wait for a person's OK: on main as `status: pending`, read by no run until approved.
512
581
  pending: (pending ?? []).map(({ file, name }) => ({ file: shown.name(file), name: shown.text(name) })),
513
582
  // The grader's, with its item for each new note: a name holding one of the host's secrets reads [redacted], and
514
- // each text is cut of them.
515
- 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 } : {}), ...(question ? { question: shown.text(question) } : {}), why: shown.text(why) })) } : null,
516
- problems: (problems ?? []).map((problem) => printable(problem, secrets)),
583
+ // each text is cut of them, its origin too (a kept row read back is untrusted).
584
+ 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,
585
+ // Each cut of the host's secrets (printable), then as every served text is (`shown`: no loopback address).
586
+ 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) })),
517
587
  // The grade's alone: the end-of-run turn's cost is in the run's own totals.
518
588
  cost_usd: { grade: cost_usd?.grade ?? null },
519
589
  tokens: { grade: tokens?.grade ?? null },
590
+ // What the job did with the learned skills and workflows it was offered (store-reads/learning.ts learnedUseOf), apart
591
+ // from the skills and workflows it learned (notesView's), each name cut of the host's secrets as a note's is.
592
+ used: {
593
+ skills: (input.used?.skills ?? []).map(({ name, read }) => ({ name: shown.name(name), read })),
594
+ workflows: (input.used?.workflows ?? []).map(({ name, calls, failed }) => ({ name: shown.name(name), calls, failed })),
595
+ },
520
596
  };
521
597
  }
522
598
  /** `text`, an added file, as git's unified diff writes it, hunks only. */
@@ -533,7 +609,8 @@ function addedPatch(text) {
533
609
  * its agent's learning folder); before, its kept proposal (new notes only, from its learning_proposals row) against its
534
610
  * seed; a run that proposed nothing, no file, against the seed its launch's learning start names. A run that does not
535
611
  * learn (no learning start and no learning end) is not_found. A file's patch is withheld when too large (as the script
536
- * wrote it), or when it holds one of the host's secrets now (`shown`). */
612
+ * wrote it), or when it holds one of the host's secrets now (`shown`); any other is served as every learning text is
613
+ * (`shown.text`: a loopback address reads "a local address"). */
537
614
  export async function runDiffOverStore(data, store, runId, shown) {
538
615
  const [end, kept, launch, row] = await Promise.all([runLearningEnd(store, runId), store.learning.proposal(runId), launchOf(store, runId), store.runs.get(runId)]);
539
616
  const start = launch ? learningStartOf(launch) : undefined;
@@ -541,7 +618,12 @@ export async function runDiffOverStore(data, store, runId, shown) {
541
618
  throw new ApiError("not_found", "the run does not learn, so it proposed nothing");
542
619
  const file = (name, status, patch) => {
543
620
  const path = shown.name(name);
544
- return Buffer.byteLength(patch) > PATCH_CAP ? { path, status, withheld: "too_large" } : shown.holds(patch) ? { path, status, withheld: "secret" } : { path, status, patch };
621
+ if (Buffer.byteLength(patch) > PATCH_CAP)
622
+ return { path, status, withheld: "too_large" };
623
+ if (shown.holds(patch))
624
+ return { path, status, withheld: "secret" };
625
+ const served = shown.text(patch);
626
+ return Buffer.byteLength(served) > PATCH_CAP ? { path, status, withheld: "too_large" } : { path, status, patch: served };
545
627
  };
546
628
  if (end?.merged) {
547
629
  const folder = learningFolderOf(data, row.agentId);
@@ -1,29 +1,9 @@
1
- import { type AnalyticsFilter, type RunRow } from "@parcha/pi-durable-agent";
2
- import type { TimelineEvent } from "@parcha/pi-durable-agent/timeline";
3
- import { type NoteRuns } from "./learning.js";
4
- import type { Status } from "./run-view.js";
1
+ import type { RunRow } from "./agent-rows.js";
2
+ import type { AnalyticsFilter } from "./store-reads/analytics.js";
3
+ import type { TimelineEvent } from "./timeline/index.js";
4
+ import { type Learning, type NoteRuns, type Shown } from "./learning.js";
5
+ import { type Reflect } from "./reflect-range.js";
5
6
  import type { NoteFiles } from "./usage.js";
6
- /** A run's end-of-run turn: the job's outcome, the newest store entry before the turn and, once the run ended, the newest
7
- * after it (its rows are those between), its deadline, and how it ended. */
8
- export type Reflect = {
9
- outcome: Status;
10
- after: number;
11
- until?: number;
12
- deadline: string;
13
- ended?: true;
14
- timedOut?: true;
15
- };
16
- /** Who sent the end-of-run turn: the server, never a person, and no request field sets it. The one value it is sent
17
- * with, at its one call (reflectTurn); the tool gate reads it there and refuses that turn's writes under work/.learning/ (tool-gate.ts NOTE_ONLY_TEXT). */
18
- declare const REFLECT_ORIGIN = "reflect";
19
- export type TurnOrigin = typeof REFLECT_ORIGIN;
20
- /** Whether entry `id` (a number), or the row `id`, is the end-of-run turn's. Before the run has ended every later entry
21
- * is, and so is a live row. */
22
- export declare function reflects(reflect: Reflect | undefined, id: string | number): boolean;
23
- /** `rows` with the end-of-run turn's labelled: never the run's answer (meaningful skips the label), its answer shown as
24
- * a text row, and its message as the host's, in a person's words (learning-words.ts): what the model is asked stays in
25
- * the run's store, and no row shows it. */
26
- export declare function labelled(reflect: Reflect | undefined, rows: TimelineEvent[]): TimelineEvent[];
27
7
  /** The files of the run's copy of the folder its job read, in the order it first read them, each once: every `read`
28
8
  * call whose result came back a success, matched to its call by id (claude-agent's rows can hold the result above the
29
9
  * call), on any harness: pi's, claude-agent's (the host's `read`, served to its CLI as `mcp__hands__read`) and codex's
@@ -31,6 +11,10 @@ export declare function labelled(reflect: Reflect | undefined, rows: TimelineEve
31
11
  * end-of-run turn's reads are its own, not the job's, and are left out; so is a read that failed or never ended, and
32
12
  * MEMORY.md, which is no note. Which of these files are notes the run started from is for its seed to say (noteUsed). */
33
13
  export declare function notesRead(reflect: Reflect | undefined, rows: readonly TimelineEvent[]): string[];
14
+ /** The run's learning row, once its learning was proposed, merged or dropped (`seed_failed` included): its state, reason
15
+ * and detail, its summary the detail itself as the run's view says it (learning.ts detailShown: cut of the host's
16
+ * secrets now, `shown`, then cut short). One row, which says where the learning ended. */
17
+ export declare function withLearning(rows: readonly TimelineEvent[], learning: Learning | undefined, shown: Shown): TimelineEvent[];
34
18
  /** How the runs that tried to learn fared, over the runs the analytics' `from`, `to` and `agent` pick (by when they
35
19
  * started, unarchived): `runs` with a learning block, `merged`, `dropped` by reason, and `in_progress` (seeded,
36
20
  * reflecting or proposed: a run this server holds). A run with learning off, a workflow's or an imported one, has
@@ -59,8 +43,7 @@ export type Impact = {
59
43
  after: ImpactSide;
60
44
  } | null;
61
45
  /** Each note's count of runs that were given it and that read it, by its file, over runs' note files (usage.ts
62
- * notesOf, lineNotesOf): a held run's from its learning, an ended one's from its ledger line. A run counts a note
63
- * once each way. */
46
+ * notesOf). A run counts a note once each way. */
64
47
  export declare function noteRuns(runs: readonly (NoteFiles | null | undefined)[]): NoteRuns;
65
48
  /** What a run's learning tells its impact (learning-run.ts ofAgent), from memory or from its ledger line: how it
66
49
  * ended and when, how many notes it started from, when its answer was final and its costs; `grade_usd` once it ended
@@ -70,17 +53,19 @@ export type ImpactLearning = {
70
53
  reason: string | null;
71
54
  at: string;
72
55
  seed_notes?: number;
56
+ seed_skills?: number;
57
+ seed_workflows?: number;
73
58
  answered_at?: string;
74
59
  job_cost_usd?: number | null;
75
60
  look_back_usd?: number | null;
76
61
  grade_usd?: number | null;
77
62
  };
78
63
  /** What learning changed for an agent, from its run rows (`rows`) and what its runs' learning says (`learningOf`),
79
- * never a run's files. `after`: its completed agentic runs that started from at least one active note. `before`: its
80
- * completed agentic runs that started before its first note, the earlier of its first merge's end and the start of its
81
- * first run that started from a note (a person's note comes first that way); none of them could have. Each side's
64
+ * never a run's files. `after`: its completed agentic runs that started from at least one learned item: an active note,
65
+ * a learned skill it was offered or a learned workflow its learned_workflow tool could run (seededItems). `before`: its
66
+ * completed agentic runs that started before its first item, the earlier of its first merge's end and the start of its
67
+ * first run that started from one (a person's note comes first that way); none of them could have. Each side's
82
68
  * figures (sideOf, figuresOf): its time to the answer in seconds to a tenth, its job's own cost, what learning cost.
83
69
  * An imported or archived run is on neither side, nor is a later one with learning off or seeded with no note (every
84
70
  * note retired), nor one whose learning predates these figures. Null unless both sides hold 2 runs or more. */
85
71
  export declare function learningImpact(rows: readonly RunRow[], learningOf: (row: RunRow) => ImpactLearning | null | undefined): Impact;
86
- export {};
@@ -1,37 +1,11 @@
1
- // A run's learning, as the server reads it from a run's rows and the runs' rows: which rows its end-of-run turn made
2
- // (reflects, labelled), the notes it read (notesRead), how the runs that tried to learn fared (learningStats), and an
3
- // agent's impact (noteRuns, learningImpact). The runner runs the end-of-run turn itself (runner/reflect-hook.ts).
1
+ // A run's learning, as the server reads it from a run's rows and the runs' rows: the notes it read (notesRead), its
2
+ // learning row once its learning ended (withLearning), how the runs that tried to learn fared (learningStats), and an
3
+ // agent's impact (noteRuns, learningImpact). Which rows its end-of-run turn made is reflect-range.ts's (reflects,
4
+ // labelled). The runner runs the end-of-run turn itself (runner/reflect-hook.ts).
4
5
  import { posix } from "node:path";
5
6
  import { INDEX_FILE } from "./learn/index.js";
6
- import { LEARNED_DIR, LEARNING_LABEL, LEARNING_REASONS } from "./learning.js";
7
- import { said } from "./learning-words.js";
8
- /** Who sent the end-of-run turn: the server, never a person, and no request field sets it. The one value it is sent
9
- * with, at its one call (reflectTurn); the tool gate reads it there and refuses that turn's writes under work/.learning/ (tool-gate.ts NOTE_ONLY_TEXT). */
10
- const REFLECT_ORIGIN = "reflect";
11
- /** A row's store entry, from its id (`<conversation>:<entry>[:...]`); NaN for a row no entry made (a live one, usage). */
12
- const entryOf = (id) => Number(id.split(":")[1]);
13
- /** Whether entry `id` (a number), or the row `id`, is the end-of-run turn's. Before the run has ended every later entry
14
- * is, and so is a live row. */
15
- export function reflects(reflect, id) {
16
- if (!reflect)
17
- return false;
18
- const entry = typeof id === "number" ? id : entryOf(id);
19
- if (Number.isInteger(entry))
20
- return entry > reflect.after && (reflect.until === undefined || entry <= reflect.until);
21
- return reflect.until === undefined && typeof id === "string" && id.includes(":live:");
22
- }
23
- /** `rows` with the end-of-run turn's labelled: never the run's answer (meaningful skips the label), its answer shown as
24
- * a text row, and its message as the host's, in a person's words (learning-words.ts): what the model is asked stays in
25
- * the run's store, and no row shows it. */
26
- export function labelled(reflect, rows) {
27
- if (!reflect)
28
- return rows;
29
- return rows.map((row) => (!reflects(reflect, row.id) ? row : {
30
- ...row, agent_label: LEARNING_LABEL,
31
- ...(row.kind === "final_answer" ? { kind: "text_block" } : {}),
32
- ...(row.kind === "user_message" ? { summary: said.asked, text: said.asked } : {}),
33
- }));
34
- }
7
+ import { detailShown, LEARNED_DIR, LEARNING_LABEL, LEARNING_REASONS } from "./learning.js";
8
+ import { reflects } from "./reflect-range.js";
35
9
  /** A path that names a file at the top of a run's copy of the folder: `.learning/<file>` relative to its work, as a
36
10
  * harness's file tools take it, or the same at the end of an absolute path (claude-agent's CLI joins its working
37
11
  * directory; a box names its own). */
@@ -54,6 +28,22 @@ export function notesRead(reflect, rows) {
54
28
  }
55
29
  return [...read];
56
30
  }
31
+ /** The run's learning row, once its learning was proposed, merged or dropped (`seed_failed` included): its state, reason
32
+ * and detail, its summary the detail itself as the run's view says it (learning.ts detailShown: cut of the host's
33
+ * secrets now, `shown`, then cut short). One row, which says where the learning ended. */
34
+ export function withLearning(rows, learning, shown) {
35
+ if (!learning || learning.state === "seeded" || learning.state === "reflecting")
36
+ return [...rows];
37
+ const detail = detailShown(learning, shown);
38
+ const row = {
39
+ id: LEARNING_LABEL, timestamp: learning.at, created_at: learning.at, kind: "learning", summary: detail ?? `Learning ${learning.state}`, agent_label: LEARNING_LABEL,
40
+ tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null, text: detail,
41
+ learning: { state: learning.state, reason: learning.reason, detail },
42
+ };
43
+ // No store entry makes it: the served view adds it at each read, and learning that starts over (seeded, reflecting)
44
+ // has none.
45
+ return [...rows, row];
46
+ }
57
47
  /** How the runs that tried to learn fared, over the runs the analytics' `from`, `to` and `agent` pick (by when they
58
48
  * started, unarchived): `runs` with a learning block, `merged`, `dropped` by reason, and `in_progress` (seeded,
59
49
  * reflecting or proposed: a run this server holds). A run with learning off, a workflow's or an imported one, has
@@ -81,8 +71,7 @@ export function learningStats(rows, filter, learningOf) {
81
71
  return out;
82
72
  }
83
73
  /** Each note's count of runs that were given it and that read it, by its file, over runs' note files (usage.ts
84
- * notesOf, lineNotesOf): a held run's from its learning, an ended one's from its ledger line. A run counts a note
85
- * once each way. */
74
+ * notesOf). A run counts a note once each way. */
86
75
  export function noteRuns(runs) {
87
76
  const out = new Map();
88
77
  for (const files of runs) {
@@ -98,6 +87,9 @@ export function noteRuns(runs) {
98
87
  }
99
88
  return out;
100
89
  }
90
+ /** How many learned items a run started from: its notes, the learned skills it was offered and the learned workflows its
91
+ * learned_workflow tool could run. */
92
+ const seededItems = (learning) => (learning?.seed_notes ?? 0) + (learning?.seed_skills ?? 0) + (learning?.seed_workflows ?? 0);
101
93
  /** The middle of `values` (the mean of the two middle ones when there is an even count); undefined for none. */
102
94
  const median = (values) => {
103
95
  if (!values.length)
@@ -133,15 +125,16 @@ function figuresOf(row, learning) {
133
125
  return { seconds: (answered - Date.parse(row.startedAt)) / 1000, cost, learning: typeof back === "number" && typeof grade === "number" ? back + grade : null };
134
126
  }
135
127
  /** What learning changed for an agent, from its run rows (`rows`) and what its runs' learning says (`learningOf`),
136
- * never a run's files. `after`: its completed agentic runs that started from at least one active note. `before`: its
137
- * completed agentic runs that started before its first note, the earlier of its first merge's end and the start of its
138
- * first run that started from a note (a person's note comes first that way); none of them could have. Each side's
128
+ * never a run's files. `after`: its completed agentic runs that started from at least one learned item: an active note,
129
+ * a learned skill it was offered or a learned workflow its learned_workflow tool could run (seededItems). `before`: its
130
+ * completed agentic runs that started before its first item, the earlier of its first merge's end and the start of its
131
+ * first run that started from one (a person's note comes first that way); none of them could have. Each side's
139
132
  * figures (sideOf, figuresOf): its time to the answer in seconds to a tenth, its job's own cost, what learning cost.
140
133
  * An imported or archived run is on neither side, nor is a later one with learning off or seeded with no note (every
141
134
  * note retired), nor one whose learning predates these figures. Null unless both sides hold 2 runs or more. */
142
135
  export function learningImpact(rows, learningOf) {
143
136
  const done = rows.filter((row) => row.kind === "agentic" && !row.importedFrom && !row.archivedAt && row.state === "completed" && row.endedAt);
144
- const after = done.filter((row) => (learningOf(row)?.seed_notes ?? 0) > 0);
137
+ const after = done.filter((row) => seededItems(learningOf(row)) > 0);
145
138
  const merges = rows.flatMap((row) => {
146
139
  const learning = learningOf(row);
147
140
  return learning?.state === "merged" ? [Date.parse(learning.at)] : [];
@@ -13,19 +13,19 @@ export declare function firstSentence(text: string): string;
13
13
  export declare const STOPPED: {
14
14
  readonly unreadable: "the agent's notes could not be read, so the run started without them";
15
15
  readonly notCopied: "the agent's notes could not be copied into the run, so the run started without them";
16
+ readonly noSeed: "the run started without the agent's notes";
16
17
  readonly serverStopped: "the server stopped while it set up the run's notes, so the run started without them";
17
18
  readonly cancelled: "the run was cancelled";
18
19
  readonly cancelledLooking: "the run was cancelled while it looked back";
19
20
  readonly crashed: "the run's process ended before it could look back";
20
- readonly crashedLooking: "the run's process ended while it looked back";
21
21
  readonly timedOut: "looking back took too long";
22
- readonly notAsked: "looking back could not start";
23
22
  readonly failed: "looking back ended on an error";
24
- readonly notSetAside: "the new notes could not be set aside to be checked";
25
23
  readonly notChecked: "the new notes could not be checked";
26
24
  readonly refuseUnread: "what the run must never learn (its agent's browser sign-in, the server's secrets) could not be read back, so nothing it learned is kept";
27
25
  readonly noReview: "the review of the new notes gave no answer";
28
26
  readonly unread: "the review of the new notes gave an answer that could not be read";
27
+ readonly contradicted: "the review of the new notes contradicted itself: it kept them and said not to";
28
+ readonly contradictedTwice: "the review of the new notes contradicted itself twice: it kept them and said not to";
29
29
  };
30
30
  /** A run's learning, in words, by where it stands. */
31
31
  export declare const said: {
@@ -33,6 +33,9 @@ export declare const said: {
33
33
  reflecting: string;
34
34
  /** The end-of-run turn's message, as a person reads it in the timeline: never the prompt the model is sent. */
35
35
  asked: string;
36
+ /** The end-of-run turn asked again because a workflow draft failed its dry run (learn/reflect.ts reflectDryRun), as a
37
+ * person reads it in the timeline: never the ask, which holds the check's words. */
38
+ askedDryRun: string;
36
39
  proposed: (notes: number, skills?: number, workflows?: number) => string;
37
40
  /** What it learned, by name, and how many older notes they replace, and its skill and workflow by name; then what
38
41
  * waits for the owner's OK, by name; then, when the grader dropped an item and kept others (a verdict per item), its
@@ -46,6 +49,9 @@ export declare const said: {
46
49
  why: string;
47
50
  }[], checked?: readonly Pick<Problem, "rule" | "path">[]) => string;
48
51
  empty: string;
52
+ /** A run whose only work was its learned workflows, each answering, with nothing said after its first message: it was
53
+ * not asked to look back (runner/learning-end.ts onlyLearnedWorkflows). */
54
+ onlyWorkflow: string;
49
55
  /** A merge whose every item the owner has since retired: nothing it learned is kept now. */
50
56
  retiredSince: string;
51
57
  /** The run's answer gave its notes, but not in the format asked for, so none was read. */
@@ -73,6 +79,7 @@ export declare const said: {
73
79
  export declare function notKept(verdict: Pick<Verdict, "reason" | "items">, lost?: readonly Pick<LearnedFile, "file">[]): string;
74
80
  /** A run's learning in words as a read says them, whole: what it learned and what waits for the owner's OK, or why the
75
81
  * grader kept nothing, said again from its parts (`learned`, `pending`, `verdict`) each cut by `cut` first (the host's
76
- * secrets as they are now); any other detail, the server's own sentence, cut as well. The caller cuts the words short
77
- * after. */
82
+ * secrets as they are now), and the whole line cut again, as notKept's is: a skill's or a workflow's file names it in
83
+ * the words, uncut until then; any other detail, the server's own sentence, cut as well. The caller cuts the words
84
+ * short after. */
78
85
  export declare function wordsOf(learning: Pick<Learning, "state" | "reason" | "detail" | "learned" | "pending" | "verdict" | "skills" | "workflows" | "problems" | "lost">, cut: (text: string) => string): string | null;