@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
package/dist/import.js CHANGED
@@ -12,7 +12,7 @@ import { basename, dirname, join, sep } from "node:path";
12
12
  import { parseArgs } from "node:util";
13
13
  import { BACKGROUND_CONTEXT as ctx } from "@earendil-works/chord/context";
14
14
  import { AssistantEntry, ROOT_CONVERSATION_ID, ToolResultEntry, UserEntry } from "@earendil-works/pi-durable";
15
- import { REQUEST_COST, runMetricsOf } from "@parcha/pi-durable-agent/timeline";
15
+ import { REQUEST_COST, runMetricsOf } from "./timeline/index.js";
16
16
  import { defaultData } from "./files.js";
17
17
  import { childFiles, HARNESS_OF, mostEffortOf, readSession, SOURCES, sessionFiles } from "./import-sources.js";
18
18
  import { hoursOf, summaryLines } from "./import-summary.js";
@@ -22,11 +22,10 @@ import { launchBody } from "./run-launch.js";
22
22
  import { DEFAULT_PORT } from "./server.js";
23
23
  import { REDACTED, secretCut, secretsIn } from "./secret-cut.js";
24
24
  import { handedSecret, SECRET_NAMES, withSecrets } from "./secrets.js";
25
- import { SEAL_KEY_ENV } from "./tool-keys.js";
25
+ import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
26
26
  import { bootSealKey, SealKeyRefused, withSealKey } from "./seal-key.js";
27
27
  import { toolKeysOverStore } from "./tool-keys-store.js";
28
28
  import { openServerSecretsOverStore } from "./server-secrets-store.js";
29
- import { WEBHOOK_FILE, webhookSecretIn } from "./webhooks.js";
30
29
  import { TRIGGER_ADAPTERS } from "./trigger-adapters.js";
31
30
  import { readWorkBytes, WorkRefused, walkWork } from "./workspace.js";
32
31
  import { journalEntries } from "./runner/journal-reader.js";
@@ -785,16 +784,15 @@ async function revisionFor(store, agentId, source, files, model, cut) {
785
784
  return { id, create: { id, kind: "agentic", body, skills, note } };
786
785
  }
787
786
  /** The secrets this server made and keeps, by value: its API token and its sign-in sessions' secret (still files beside the
788
- * store), its webhook's signing secret (`whsec_...`; webhooks.ts) and every value a trigger source keeps sealed, which the
789
- * switch keeps as store rows (server-secrets-store.ts), opened with the seal key of `env`, so left out when that key is not
790
- * there; each signing secret's key in every spelling too. One pasted into a session is this server's own, so an import cuts
791
- * it wherever it is, as it cuts the environment's keys. Not among them: a key-shaped value this server did not make (a
792
- * `whsec_` from elsewhere). The per-run door token is gone (the runner cutover deleted it). A webhook secret that does not
787
+ * store), and its webhook's signing secret (`whsec_...`; webhooks.ts) and every value a trigger source keeps sealed, as
788
+ * store rows (server-secrets-store.ts), opened with the seal key of `env`, which the caller has (a dry run over a store that
789
+ * keeps no secret has none, and does not ask); each signing secret's key in every spelling too. One pasted into a
790
+ * session is this server's own, so an import cuts it wherever it is, as it cuts the environment's keys. Not among them: a key-shaped value this server did not make (a
791
+ * `whsec_` from elsewhere). The per-run door token is gone (the runner cutover deleted it). A sealed value that does not
793
792
  * open is said to `say`: the import goes on, and does not cut it. */
794
793
  export async function ownSecrets(store, data, env, say = () => { }) {
795
- const webhook = webhookSecretIn(data, env);
796
- if (webhook && "signing" in webhook)
797
- say({ condition: webhook.signing, name: SEAL_KEY_ENV, file: join(data, WEBHOOK_FILE), effect: "this server's webhook secret cannot be read, so the import does not cut it" });
794
+ if (!sealKeyOf(env[SEAL_KEY_ENV]))
795
+ throw new Error(`the server's own secrets open only under its seal key (${SEAL_KEY_ENV}), and none was handed`);
798
796
  return (await openServerSecretsOverStore(store, data, env, TRIGGER_ADAPTERS, say)).secrets.values();
799
797
  }
800
798
  /** The plan, into `store`: the agents it does not hold, and the runs it does not. Each run is written whole in one atomic
@@ -983,7 +981,7 @@ export async function describePlan(plan, store, { verbose = false } = {}) {
983
981
  export async function importCommand(args, usage, { home = homedir(),
984
982
  // The folder whose projects are left out as temporary (the OS's temp directory).
985
983
  temp = tmpdir(), env, out = console.log, } = {}) {
986
- // The server's own secrets, which the switch keeps sealed in the store, open only under the server's seal key: it is
984
+ // The server's own secrets, kept sealed in the store, open only under the server's seal key: it is
987
985
  // booted the one way the server and runner boot it (seal-key.ts bootSealKey) once the store is open (keyed below), and
988
986
  // checked against it. The key handed over wins (this process's, else a caller's own environment's: a test's), else the
989
987
  // one in the data directory, as the server reads it.
@@ -1070,7 +1068,9 @@ temp = tmpdir(), env, out = console.log, } = {}) {
1070
1068
  const optionsFrom = async (store) => {
1071
1069
  // The environment as it is now: once the store's key is booted (keyed), it carries it.
1072
1070
  const keyEnv = env;
1073
- const keys = store ? toolKeysOverStore(store, keyEnv, say("tool_keys")) : undefined;
1071
+ // With no key (a dry run over a store that keeps no secret: seal-key.ts) there is nothing of the server's to open.
1072
+ const keyed = store !== undefined && keyEnv[SEAL_KEY_ENV] !== undefined;
1073
+ const keys = keyed ? toolKeysOverStore(store, keyEnv, say("tool_keys")) : undefined;
1074
1074
  if (keys) {
1075
1075
  await keys.load();
1076
1076
  keys.view();
@@ -1083,8 +1083,7 @@ temp = tmpdir(), env, out = console.log, } = {}) {
1083
1083
  temp,
1084
1084
  env: keyEnv,
1085
1085
  stored: keys ? keys.values() : {},
1086
- // With no key (a dry run over a store that keeps no secret: seal-key.ts) there is nothing of the server's to open.
1087
- own: store && keyEnv[SEAL_KEY_ENV] !== undefined ? await ownSecrets(store, dir, keyEnv, say("webhook_secret")) : [],
1086
+ own: keyed ? await ownSecrets(store, dir, keyEnv, say("sealed_settings")) : [],
1088
1087
  };
1089
1088
  // What it prints is cut with the saved keys too, and with every key the import (or the dry run) finds, as what it
1090
1089
  // keeps is.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { capabilities, CONTRACT, DEFAULT_PORT, type Serve, type ServeOptions, startServe } from "./server.js";
2
+ export { serveWithRunner } from "./runner/beside.js";
2
3
  export { SERVER_LOCK, type ServerLock, ServerLockHeldError, takeServerLock } from "./server-lock.js";
3
4
  export { ApiError, ERROR_STATUS, type ErrorCode } from "./errors.js";
4
5
  export { defaultMaxRuns, type Health } from "./host.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { capabilities, CONTRACT, DEFAULT_PORT, startServe } from "./server.js";
2
+ export { serveWithRunner } from "./runner/beside.js";
2
3
  export { SERVER_LOCK, ServerLockHeldError, takeServerLock } from "./server-lock.js";
3
4
  export { ApiError, ERROR_STATUS } from "./errors.js";
4
5
  export { defaultMaxRuns } from "./host.js";
@@ -46,8 +46,12 @@ export declare function redactedLive(text: string, secrets: readonly string[]):
46
46
  /** `text`, a run's error, in a person's words when it is a provider's 401 for `key` (REFUSED), with no value of
47
47
  * `secrets` in it; undefined when it is not one. */
48
48
  export declare function keyRefusal(text: string | undefined, key: RunKey | undefined, secrets?: readonly string[]): string | undefined;
49
+ /** `text` with each loopback address in it, with a scheme or bare with its port, its path with it, as "a local address",
50
+ * and nothing else of it changed: a sentence's full stop, a label before it, its line's end and a JSON string's quotes
51
+ * stay. What a learning text is served through (learning.ts secretsShown), and what withoutLoopback ends with. */
52
+ export declare function withoutLoopbackAddresses(text: string): string;
49
53
  /** `text`, a run's error, with no loopback address in it: Codex's `url:` tail goes (tried at the last "url:" only), and
50
- * any other, with a scheme or bare with its port, becomes "a local address". */
54
+ * any other address alone becomes "a local address" (withoutLoopbackAddresses). */
51
55
  export declare function withoutLoopback(text: string): string;
52
56
  /** `value` with each string in it, however deep, through `cut`: what a run error's details hold is served and kept as its
53
57
  * message is (runs.ts). */
@@ -175,10 +175,25 @@ export function keyRefusal(text, key, secrets = []) {
175
175
  * address. Every pattern is tried at one place or advances past what it read, so a rewrite takes time in proportion to
176
176
  * the text. */
177
177
  const LOOPBACK_TAIL = /^url:\s*https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\])(?![\w.-])(:\d+)?\S*\s*$/i; // key-gate: loopback-rule strips the loopback proxy address codex prints
178
- const LOOPBACK = /https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\])(?![\w.-])(:\d+)?[^\s,;:)\x22\x27\]]*/gi; // key-gate: loopback-rule replaces any loopback address in a run error
179
- const LOOPBACK_BARE = /(?<![\w.\/-])(?:127\.0\.0\.1|localhost|\[::1\])(:\d+)(?![\w.-])/gi; // key-gate: loopback-rule replaces a bare loopback address with its port, a refused connection to the proxy
178
+ /** A loopback host, by any of its names. */
179
+ const LOOPBACK_HOST = String.raw `(?:127\.0\.0\.1|localhost|\[::1\])`; // key-gate: loopback-rule the loopback host names every address pattern below shares
180
+ /** What ends an address's path: a space, a quote, a backslash (a JSON string's escape), a closing mark, the text's end, or
181
+ * a full stop followed by one of those (a sentence's, which stays). */
182
+ const STOP = String.raw `[\s,;:)\x22\x27\]\\]`;
183
+ const PATH = String.raw `[^\s,;:)\x22\x27\]\\]*?(?=${STOP}|\.(?:${STOP}|$)|$)`;
184
+ /** One with a scheme, its port and its path. */
185
+ const LOOPBACK = new RegExp(String.raw `https?:\/\/${LOOPBACK_HOST}(?![\w.-])(?::\d+)?${PATH}`, "gi"); // key-gate: loopback-rule replaces any loopback address with a scheme
186
+ /** A bare one: its port, then its path when one follows. A port followed by a letter, a digit, a dash or a full stop
187
+ * that ends no sentence names no address of the host's, so it is kept. */
188
+ const LOOPBACK_BARE = new RegExp(String.raw `(?<![\w.\/-])${LOOPBACK_HOST}:\d+(?:\/${PATH})?(?![\w-])(?!\.(?!${STOP}|$))`, "gi"); // key-gate: loopback-rule replaces a bare loopback address with its port, a refused connection to the proxy
189
+ /** `text` with each loopback address in it, with a scheme or bare with its port, its path with it, as "a local address",
190
+ * and nothing else of it changed: a sentence's full stop, a label before it, its line's end and a JSON string's quotes
191
+ * stay. What a learning text is served through (learning.ts secretsShown), and what withoutLoopback ends with. */
192
+ export function withoutLoopbackAddresses(text) {
193
+ return text.replace(LOOPBACK, "a local address").replace(LOOPBACK_BARE, "a local address");
194
+ }
180
195
  /** `text`, a run's error, with no loopback address in it: Codex's `url:` tail goes (tried at the last "url:" only), and
181
- * any other, with a scheme or bare with its port, becomes "a local address". */
196
+ * any other address alone becomes "a local address" (withoutLoopbackAddresses). */
182
197
  export function withoutLoopback(text) {
183
198
  let at = -1;
184
199
  for (const found of text.matchAll(/url:/gi))
@@ -189,7 +204,7 @@ export function withoutLoopback(text) {
189
204
  if (out.endsWith(","))
190
205
  out = out.slice(0, -1);
191
206
  }
192
- return out.replace(LOOPBACK, "a local address").replace(LOOPBACK_BARE, "a local address");
207
+ return withoutLoopbackAddresses(out);
193
208
  }
194
209
  /** `value` with each string in it, however deep, through `cut`: what a run error's details hold is served and kept as its
195
210
  * message is (runs.ts). */
@@ -1,5 +1,5 @@
1
1
  import { type LearnedNote } from "./notes.js";
2
- import { type DraftReader } from "./skills.js";
2
+ import { type DraftAsk, type DraftDryRun, type DraftReader } from "./skills.js";
3
3
  /** Byte caps (UTF-8) and counts. Over a cap is refused, never cut. */
4
4
  export declare const CAPS: Readonly<{
5
5
  /** One note's file. */
@@ -65,10 +65,15 @@ export type CheckInput = {
65
65
  /** The agent's granted tools the gate does not allow, with what each is set to (tools.ts learnedDraftTools): a draft
66
66
  * whose call node calls one is refused, in the words a workflow revision's is (learn/skills.ts gatedNodes). */
67
67
  readonly gated?: Readonly<Record<string, string>>;
68
+ /** The MCP tools set to ask a learned call would ask about, and the gate's card rule (skills.ts DraftAsk, #2424). */
69
+ readonly ask?: DraftAsk;
68
70
  /** Where each of `gated`'s denies was set (this agent's settings or this server's), for the refusal's words. */
69
71
  readonly deniedBy?: Readonly<Record<string, "agent" | "server" | "default">>;
70
72
  /** The workflow DSL a draft is read with; a proposal that holds a draft is checked with it, never without. */
71
73
  readonly dsl?: DraftReader;
74
+ /** Each draft's dry run (skills.ts draftDryRun), by its workflow.json's path: one that failed is refused, rule
75
+ * `workflow`, when the draft has no other problem. A draft with none given is checked without one. */
76
+ readonly dryRuns?: Readonly<Record<string, DraftDryRun>>;
72
77
  /** The skills' and drafts' files whose text in the run's seed has a status (a person retired it, or it waits for its
73
78
  * owner's OK): a run never changes those. A draft's is its README.md. */
74
79
  readonly kept?: readonly string[];
@@ -79,7 +84,8 @@ export type ProposalCheck = {
79
84
  readonly problems: Problem[];
80
85
  readonly notes: ProposedNote[];
81
86
  };
82
- /** `problem` as it may be printed: its path and detail cut of `values` and of secret shapes, whole when over PRINT_MAX. */
87
+ /** `problem` as it may be printed: its path and detail cut of `values` and of every shape learning refuses, a bank's
88
+ * numbers too (redactLearned: a name refused for one never prints it), whole when over PRINT_MAX. */
83
89
  export declare const printable: (problem: Problem, values: readonly string[]) => Problem;
84
90
  /** The checks one note's file passes by itself (SPEC.md), as a person writes it through the host: its name, the note cap,
85
91
  * UTF-8, hidden characters, secret shapes and the host's values in its name and text, and its front matter. A person
@@ -5,8 +5,8 @@
5
5
  // path and detail are cut of the host's secrets and of text shaped like one, and a field over PRINT_MAX is redacted whole.
6
6
  import { hiddenCharacter } from "./invisible.js";
7
7
  import { INDEX_FILE, INDEX_LINES, NOTE_FILE, parseNoteFile } from "./notes.js";
8
- import { redactSecrets, secretShapes, valueMatcher } from "./secrets.js";
9
- import { draftProblems, frontKeys, LEARNED_KEYS, learnedName, learnedPlace, setsStatus, skillProblems, WORKFLOWS_DIR } from "./skills.js";
8
+ import { learnedSecretShapes, redactLearned, valueMatcher } from "./secrets.js";
9
+ import { draftProblems, decodedStrings, DECODED_DEPTH, DRY_RUN_FAILED, frontKeys, frontValues, LEARNED_KEYS, learnedName, learnedPlace, setsStatus, skillProblems, WORKFLOWS_DIR } from "./skills.js";
10
10
  /** The most the host adds to a run's note as it merges it: `origin: you` and `status: pending`, a front matter line
11
11
  * each (notes.ts mergedNote). */
12
12
  const HOST_LINES = Buffer.byteLength("origin: you\nstatus: pending\n");
@@ -36,16 +36,18 @@ export const CAPS = Object.freeze({
36
36
  const MODES = { "120000": "a link: never followed", "040000": "a folder: nothing in it was read" };
37
37
  /** Why a run's path is none of what it may propose. */
38
38
  const OUTSIDE = "a run proposes notes at the folder's top, skills/<name>/SKILL.md, and workflows/<name>/ with its workflow.json and README.md";
39
- /** `problem` as it may be printed: its path and detail cut of `values` and of secret shapes, whole when over PRINT_MAX. */
39
+ /** `problem` as it may be printed: its path and detail cut of `values` and of every shape learning refuses, a bank's
40
+ * numbers too (redactLearned: a name refused for one never prints it), whole when over PRINT_MAX. */
40
41
  export const printable = (problem, values) => ({
41
- rule: problem.rule,
42
- ...(problem.path === undefined ? {} : { path: redactSecrets(problem.path, values) }),
43
- detail: redactSecrets(problem.detail, values),
42
+ // A rule is one of Rule's words as the checks write it; a kept row read back is untrusted, so it is cut too.
43
+ rule: redactLearned(problem.rule, values),
44
+ ...(problem.path === undefined ? {} : { path: redactLearned(problem.path, values) }),
45
+ detail: redactLearned(problem.detail, values),
44
46
  });
45
47
  /** No secret's shape or the host's values in a file's name: a writer picks its files' names, and they reach main, the
46
48
  * index and the logs. */
47
49
  function nameScanned(path, refused, add) {
48
- for (const kind of secretShapes(path))
50
+ for (const kind of learnedSecretShapes(path))
49
51
  add("secret_shape", `its name holds text shaped like a secret (${kind})`, path);
50
52
  if (refused(path))
51
53
  add("secret_value", "its name holds a value the host named as secret", path);
@@ -90,12 +92,40 @@ function textOf(path, bytes, refused, add) {
90
92
  const hidden = hiddenCharacter(text);
91
93
  if (hidden)
92
94
  found = (add("invisible_unicode", `it holds U+${hidden.code.toString(16).toUpperCase().padStart(4, "0")}, a character a reader does not see, at character ${hidden.at}`, path), true);
93
- for (const kind of secretShapes(text))
95
+ for (const kind of learnedSecretShapes(text))
94
96
  found = (add("secret_shape", `it holds text shaped like a secret (${kind})`, path), true);
95
97
  if (refused(text))
96
98
  found = (add("secret_value", "it holds a value the host named as secret", path), true);
97
99
  return found ? undefined : text;
98
100
  }
101
+ /** A learned file at `path` as it is read later, its escapes decoded: a skill's SKILL.md or a draft's README.md, its front
102
+ * matter read as YAML reads it (skills.ts frontValues, the value a harness is served); a draft's workflow.json, every
103
+ * string it decodes to, keys too, as JSON.parse reads it (skills.ts decodedStrings, what draftProblems and a learned
104
+ * call's run read). A hidden character, a secret's shape or the host's value there is refused as one in its text is,
105
+ * though the text as stored spells it in escapes. True when it found one. */
106
+ function decodedScanned(path, text, refused, add, deep = true) {
107
+ const place = learnedPlace(path);
108
+ if (!place)
109
+ return false;
110
+ const decoded = place.kind === "workflow" ? decodedStrings(text) : frontValues(text);
111
+ // Nested past the bound: refused on its own where its item is checked (`deep`), unread where the whole answer is
112
+ // scanned (unstorable), which a draft so deep never reaches storage past.
113
+ if (decoded === "too_deep")
114
+ return deep ? (add("workflow", `its workflow.json nests deeper than ${DECODED_DEPTH}`, path), true) : false;
115
+ const [values, read] = [decoded, place.kind === "workflow" ? "its JSON, read as JSON reads it," : "its front matter, read as YAML reads it,"];
116
+ let found = false;
117
+ for (const value of values) {
118
+ const hidden = hiddenCharacter(value);
119
+ if (hidden)
120
+ found = (add("invisible_unicode", `${read} holds U+${hidden.code.toString(16).toUpperCase().padStart(4, "0")}, a character a reader does not see`, path), true);
121
+ // Learning's shapes, a bank's numbers beside their words too (learnedSecretShapes), as the text's own scan reads them.
122
+ for (const kind of learnedSecretShapes(value))
123
+ found = (add("secret_shape", `${read} holds text shaped like a secret (${kind})`, path), true);
124
+ if (refused(value))
125
+ found = (add("secret_value", `${read} holds a value the host named as secret`, path), true);
126
+ }
127
+ return found;
128
+ }
99
129
  /** What a run may write of a skill or a workflow draft (`place`), by itself: a good folder name, never a deletion, a
100
130
  * regular file within CAPS.file (a README within CAPS.readme), its text as textOf takes it, and in shape: a skill's
101
131
  * front matter (skillProblems), with no `status`, which is the host's; a draft the DSL validates against `tools` with
@@ -118,13 +148,18 @@ function learnedChecked(change, place, refused, input, add) {
118
148
  if (input.kept?.includes(path) || (place.kind === "workflow" && input.kept?.includes(readmeOf)))
119
149
  return add("skill_status", "a person retired it, or it waits for its owner's OK: a run never changes it", path);
120
150
  const text = textOf(path, change.bytes, refused, add);
121
- if (text === undefined)
151
+ if (text === undefined || decodedScanned(path, text, refused, add))
122
152
  return;
123
153
  if (place.kind === "workflow") {
124
154
  if (!input.dsl)
125
155
  throw new TypeError(`${path}: a workflow draft is read with the workflow DSL, which was not given`);
126
- for (const { rule, detail } of draftProblems(input.dsl, text, input.tools, input.gated, input.deniedBy))
156
+ const problems = draftProblems(input.dsl, text, input.tools, input.gated, input.deniedBy, input.ask);
157
+ for (const { rule, detail } of problems)
127
158
  add(rule, detail, path);
159
+ // A draft the checks pass whose dry run failed: its wiring breaks at run time, before any node is paid for.
160
+ const dry = input.dryRuns?.[path];
161
+ if (!problems.length && dry?.status === "failed")
162
+ add("workflow", dry.detail ?? DRY_RUN_FAILED, path);
128
163
  return;
129
164
  }
130
165
  for (const reason of skillProblems(text, place.name))
@@ -163,8 +198,9 @@ export function unstorable(changes, refuseValues = []) {
163
198
  if (change.path === INDEX_FILE)
164
199
  continue;
165
200
  nameScanned(change.path, refused, add);
166
- if (change.bytes)
167
- textOf(change.path, change.bytes, refused, add);
201
+ const text = change.bytes ? textOf(change.path, change.bytes, refused, add) : undefined;
202
+ if (text !== undefined)
203
+ decodedScanned(change.path, text, refused, add, false);
168
204
  }
169
205
  return problems;
170
206
  }
@@ -172,17 +208,26 @@ export function checkProposal(input) {
172
208
  const values = input.refuseValues ?? [];
173
209
  const problems = [];
174
210
  const add = (rule, detail, path) => void problems.push(printable(path === undefined ? { rule, detail } : { rule, path, detail }, values));
175
- const changes = input.changes.filter((change) => change.path !== INDEX_FILE);
176
- if (changes.length > CAPS.changes) {
177
- add("too_many_files", `${changes.length} changed paths; the cap is ${CAPS.changes} a run, and nothing else was read`);
178
- return { ok: false, problems, notes: [] };
179
- }
211
+ const given = input.changes.filter((change) => change.path !== INDEX_FILE);
180
212
  const refused = valueMatcher(values);
213
+ // Each count cap names the items past it, in the order the answer gave them, so they alone are left out (propose.ts)
214
+ // and the rest is kept. The changed paths past CAPS.changes are named unread; but what refuses the whole answer by its
215
+ // path alone (a path outside what a run may write, a deletion, a name holding a secret) is read on every path first,
216
+ // past the cap too, so the cap never turns a whole refusal into one item left out.
217
+ for (const change of given.slice(CAPS.changes)) {
218
+ nameScanned(change.path, refused, add);
219
+ if (!learnedPlace(change.path) && (change.path.includes("/") || !change.path.endsWith(".md")))
220
+ add("outside", OUTSIDE, change.path);
221
+ else if (change.status === "deleted")
222
+ add("deleted", "a run never deletes a note, a skill or a workflow", change.path);
223
+ add("too_many_files", `${given.length} changed paths; the cap is ${CAPS.changes} a run, and this one, past it, was not read`, change.path);
224
+ }
225
+ const changes = given.slice(0, CAPS.changes);
181
226
  const base = new Set(input.base.files);
182
227
  const notes = [];
183
228
  const skills = [];
184
229
  const workflows = new Set();
185
- let added = 0;
230
+ const added = [];
186
231
  const one = (change) => {
187
232
  const { path } = change;
188
233
  const place = learnedPlace(path);
@@ -197,7 +242,7 @@ export function checkProposal(input) {
197
242
  return learnedChecked(change, place, refused, input, add);
198
243
  }
199
244
  if (change.status === "added")
200
- added += 1;
245
+ added.push(path);
201
246
  if (!nameChecked(path, refused, add, OUTSIDE))
202
247
  return;
203
248
  if (change.status === "deleted")
@@ -211,18 +256,18 @@ export function checkProposal(input) {
211
256
  const note = textChecked(path, change.size ?? change.bytes?.length ?? 0, change.bytes, refused, add, true);
212
257
  if (!note)
213
258
  return;
214
- if (note.keys.includes("status") || note.keys.includes("superseded_by") || note.keys.includes("origin"))
215
- return add("status", "a run never sets status, superseded_by or origin: the host does, when it merges the note or a later one supersedes it", path);
259
+ if (["status", "superseded_by", "retired_from", "origin"].some((key) => note.keys.includes(key)))
260
+ return add("status", "a run never sets status, superseded_by, retired_from or origin: the host does, when it merges the note, a later one supersedes it or a person retires it", path);
216
261
  notes.push(note);
217
262
  };
218
263
  for (const change of changes)
219
264
  one(change);
220
- if (added > CAPS.newNotes)
221
- add("too_many_notes", `${added} new notes; the cap is ${CAPS.newNotes} a run`);
222
- if (skills.length > CAPS.skills)
223
- add("too_many_skills", `${skills.length} skills added or changed; a run adds or changes at most ${CAPS.skills}`);
224
- if (workflows.size > CAPS.workflows)
225
- add("too_many_workflows", `${workflows.size} workflow drafts added or changed; a run adds or changes at most ${CAPS.workflows}`);
265
+ for (const path of added.slice(CAPS.newNotes))
266
+ add("too_many_notes", `${added.length} new notes; the cap is ${CAPS.newNotes} a run, and this one is past it`, path);
267
+ for (const path of skills.slice(CAPS.skills))
268
+ add("too_many_skills", `${skills.length} skills added or changed; a run adds or changes at most ${CAPS.skills}, and this one is past it`, path);
269
+ for (const name of [...workflows].slice(CAPS.workflows))
270
+ add("too_many_workflows", `${workflows.size} workflow drafts added or changed; a run adds or changes at most ${CAPS.workflows}, and this one is past it`, `${WORKFLOWS_DIR}/${name}/workflow.json`);
226
271
  // A skill is what every later run reads as how to do the job: only a run that did it writes one.
227
272
  if (input.outcome !== "completed")
228
273
  for (const path of skills)
@@ -255,20 +300,29 @@ export function mergeProblems(base, notes, refuseValues = []) {
255
300
  const active = new Set(base.active.map((note) => note.file));
256
301
  const out = [];
257
302
  const replaced = new Set();
303
+ // The grader reads each note superseded in full (grade.ts): their count is capped, as the new notes' is. Counted in
304
+ // the order the notes come: a note that would take the count past the cap is named (and left out), and what it
305
+ // supersedes is neither counted nor held as superseded for the notes after it, so a later one that fits is kept.
306
+ const counted = new Set();
258
307
  for (const note of notes) {
259
308
  if (files.has(note.file))
260
309
  out.push({ rule: "exists", path: note.file, detail: "the folder has a note by this name" });
310
+ const would = new Set([...counted, ...note.supersedes]);
311
+ const over = would.size > CAPS.supersedes;
261
312
  for (const old of note.supersedes) {
262
313
  if (!active.has(old))
263
314
  out.push({ rule: "supersedes", path: note.file, detail: `it supersedes ${old}, which is not an active note` });
264
315
  else if (replaced.has(old))
265
316
  out.push({ rule: "supersedes", path: note.file, detail: `${old} is superseded by another new note too` });
266
- replaced.add(old);
317
+ if (!over)
318
+ replaced.add(old);
267
319
  }
320
+ if (over)
321
+ out.push({ rule: "supersedes", path: note.file, detail: `with it the new notes supersede ${would.size} notes; the cap is ${CAPS.supersedes} a run` });
322
+ else
323
+ for (const old of note.supersedes)
324
+ counted.add(old);
268
325
  }
269
- // The grader reads each note superseded in full (grade.ts): their count is capped, as the new notes' is.
270
- if (replaced.size > CAPS.supersedes)
271
- out.push({ rule: "supersedes", detail: `the new notes supersede ${replaced.size} notes; the cap is ${CAPS.supersedes} a run` });
272
326
  const gone = supersededBy(notes);
273
327
  const lines = [...active].filter((file) => !gone.has(file)).length + notes.filter((note) => note.status === "active").length;
274
328
  if (lines > INDEX_LINES)
@@ -34,6 +34,9 @@ export type SnapNote = {
34
34
  origin: "you" | "run";
35
35
  supersedes: string[];
36
36
  superseded_by: string | null;
37
+ /** Past SNAPSHOT.md v1, additive, on a retired note alone: the status its restore gives back (notes.ts LearnedNote
38
+ * retired_from). */
39
+ retired_from?: "active" | "pending";
37
40
  order: number;
38
41
  history: SnapHistory;
39
42
  };
@@ -47,6 +50,9 @@ export type SnapLearned = {
47
50
  file: string;
48
51
  description: string;
49
52
  status: "active" | "pending" | "retired";
53
+ /** Past SNAPSHOT.md v1, additive, on a retired skill or draft alone: the status its restore gives back (skills.ts
54
+ * retiredFrom). */
55
+ retired_from?: "active" | "pending";
50
56
  run: string | null;
51
57
  files: SnapFile[];
52
58
  oid: string;
@@ -102,7 +108,7 @@ export type RunDiff = {
102
108
  };
103
109
  /** Git's blob id of `bytes`: the sha1 of "blob <length>\0" and the bytes. */
104
110
  export declare const blobOid: (bytes: Uint8Array | string) => string;
105
- /** A commit as the snapshot reads it: its time (git's %cI), subject, body and trailers. */
111
+ /** A commit as the snapshot reads it: its time (git's %cI, as commitTime keeps it), subject, body and trailers. */
106
112
  type CommitInfo = {
107
113
  at: string;
108
114
  subject: string;
@@ -119,6 +125,10 @@ type TreeEntry = {
119
125
  path: string;
120
126
  };
121
127
  /** What the script's `read` printed: main, its tree, its log and its blobs. Undefined main for a folder with none. */
128
+ /** A commit's time as git's %cI gives it (its own offset, "+00:00", "+02:00" or "Z", by git's version and the
129
+ * committer's zone), in the one form a snapshot keeps: UTC in whole seconds, ending "Z", as nextSnapshot writes it, so
130
+ * a snapshot rebuilt from git and one built incrementally agree. Text that is no time is kept as it is. */
131
+ export declare function commitTime(text: string): string;
122
132
  export declare function parseRead(out: Uint8Array): {
123
133
  main: string | undefined;
124
134
  tree: TreeEntry[];
@@ -259,9 +269,6 @@ export declare function folderAt(ws: Workspace, commit: string): Promise<{
259
269
  blobs: ReadonlyMap<string, Buffer>;
260
270
  } | undefined>;
261
271
  export declare function learningRepair(ws: Workspace): Promise<Snapshot | undefined>;
262
- /** Main's text of `path` just before the newest person's retire of it on `main`'s line, or undefined (never retired by
263
- * a person). A read through the script: git's history is not in the snapshot. */
264
- export declare function beforeRetire(ws: Workspace, main: string, path: string): Promise<string | undefined>;
265
272
  /** Whether `main` holds anything at `path`, as git stores it (any mode, any type): what the snapshot leaves out (a file
266
273
  * that is no note) included. A read through the script. */
267
274
  export declare function heldOnMain(ws: Workspace, main: string, path: string): Promise<boolean>;
@@ -21,7 +21,7 @@ import { createHash, randomBytes } from "node:crypto";
21
21
  import { readFileSync } from "node:fs";
22
22
  import { isWorkspaceError, learningWorkspace as oneLearningWorkspace, } from "../workspace/index.js";
23
23
  import { INDEX_FILE, NOTE_FILE, parseNoteFile } from "./notes.js";
24
- import { learnedFront, learnedName, learnedStatus, SKILLS_DIR, WORKFLOWS_DIR } from "./skills.js";
24
+ import { learnedFront, learnedName, learnedStatus, retiredFrom, SKILLS_DIR, WORKFLOWS_DIR } from "./skills.js";
25
25
  /** The host's folder inside the learning folder: the snapshot, the diffs and the script. Never a note's, never seeded. */
26
26
  export const HOST_DIR = ".agentrun";
27
27
  export const SNAPSHOT_FILE = `${HOST_DIR}/snapshot.json`;
@@ -117,7 +117,7 @@ function noteEntry(file, text, oid, bytes, order, history) {
117
117
  const note = parseNoteFile(file, text);
118
118
  if (Array.isArray(note))
119
119
  return undefined;
120
- return { file, oid, bytes, name: note.name, description: note.description, type: note.type, status: note.status, origin: note.origin, supersedes: [...note.supersedes], superseded_by: note.superseded_by, order, history };
120
+ return { file, oid, bytes, name: note.name, description: note.description, type: note.type, status: note.status, origin: note.origin, supersedes: [...note.supersedes], superseded_by: note.superseded_by, ...(note.retired_from ? { retired_from: note.retired_from } : {}), order, history };
121
121
  }
122
122
  // ---------------------------------------------------------------------------------------------------------------------
123
123
  // A snapshot from main whole (the script's `read`): a folder whose snapshot is not main's.
@@ -138,6 +138,13 @@ const recordsOf = (out) => out.split("\x1e").slice(1).map((record) => {
138
138
  return { head: record.slice(0, end < 0 ? undefined : end), files: end < 0 ? [] : record.slice(end + 1).split("\0").map((file) => file.replace(/^\n/, "")).filter(Boolean) };
139
139
  });
140
140
  /** What the script's `read` printed: main, its tree, its log and its blobs. Undefined main for a folder with none. */
141
+ /** A commit's time as git's %cI gives it (its own offset, "+00:00", "+02:00" or "Z", by git's version and the
142
+ * committer's zone), in the one form a snapshot keeps: UTC in whole seconds, ending "Z", as nextSnapshot writes it, so
143
+ * a snapshot rebuilt from git and one built incrementally agree. Text that is no time is kept as it is. */
144
+ export function commitTime(text) {
145
+ const ms = Date.parse(text);
146
+ return Number.isNaN(ms) ? text : new Date(ms).toISOString().replace(/\.\d{3}Z$/, "Z");
147
+ }
141
148
  export function parseRead(out) {
142
149
  const buf = Buffer.from(out);
143
150
  const end = buf.indexOf(10);
@@ -160,7 +167,7 @@ export function parseRead(out) {
160
167
  });
161
168
  const records = recordsOf(part(logLen).toString("utf8")).map(({ head: line, files }) => {
162
169
  const [sha = "", cI = "", subject = "", body = "", runId = "", changedBy = "", approvedVia = ""] = line.split("\x1f");
163
- return { sha, files, commit: { at: cI, subject, body, runId, changedBy, approvedVia } };
170
+ return { sha, files, commit: { at: commitTime(cI), subject, body, runId, changedBy, approvedVia } };
164
171
  });
165
172
  const blobs = new Map();
166
173
  const raw = part(blobLen);
@@ -269,9 +276,10 @@ function learnedItem(kind, name, files, links, text, at, said) {
269
276
  const body = text(key.path);
270
277
  if (body === undefined)
271
278
  return undefined;
272
- fields = { description: learnedFront(body)?.description ?? "", status: learnedStatus(body) };
279
+ const status = learnedStatus(body);
280
+ fields = { description: learnedFront(body)?.description ?? "", status, ...(status === "retired" ? { retired_from: retiredFrom(body) } : {}) };
273
281
  }
274
- return { name, file: key.path, description: fields.description, status: fields.status, run: at.run, files: [...files].sort((a, b) => byBytes(a.path, b.path)), oid: key.oid, bytes: key.bytes, order: at.order, history: at.history, ...(links.length ? { links: [...links].sort(byBytes) } : {}) };
282
+ return { name, file: key.path, description: fields.description, status: fields.status, ...(fields.retired_from ? { retired_from: fields.retired_from } : {}), run: at.run, files: [...files].sort((a, b) => byBytes(a.path, b.path)), oid: key.oid, bytes: key.bytes, order: at.order, history: at.history, ...(links.length ? { links: [...links].sort(byBytes) } : {}) };
275
283
  }
276
284
  /** A commit's message and trailers, as git keeps them: a person's names their action and the file, with Changed-By (and
277
285
  * Approved-Via on an approval); a run's merge names the run, then the grader's reason, then its Run-Id. */
@@ -290,8 +298,8 @@ function messageOf(by) {
290
298
  const body = paragraphs([by.approved ? "Changed-By: user\nApproved-Via: console" : "Changed-By: user"]);
291
299
  return { message: `${subject}\n\n${body}`, subject, body, runId: "", changedBy: "user", approvedVia: by.approved ? "console" : "" };
292
300
  }
293
- /** Git's %cI of a time in whole seconds, as a commit made at +0000 shows it. */
294
- const isoSeconds = (seconds) => new Date(seconds * 1000).toISOString().replace(/\.\d{3}Z$/, "+00:00");
301
+ /** A time in whole seconds as every snapshot says a commit's time: UTC, ending "Z" (commitTime's form). */
302
+ const isoSeconds = (seconds) => new Date(seconds * 1000).toISOString().replace(/\.\d{3}Z$/, "Z");
295
303
  /** Every path `snapshot` names a blob for: the index, each note, each learned folder's files. */
296
304
  function oidsOf(snapshot) {
297
305
  const out = new Map();
@@ -350,7 +358,7 @@ export function nextSnapshot(before, change, seconds) {
350
358
  order: 0,
351
359
  history: touched.has(key) ? foldNewer(old?.history, commit, key) : (old?.history ?? { at: commit.at }),
352
360
  run: runId && touched.has(viewFile(kind, name)) ? runId : (old?.run ?? null),
353
- }, keyText === undefined && old ? { description: old.description, status: old.status } : undefined);
361
+ }, keyText === undefined && old ? { description: old.description, status: old.status, ...(old.retired_from ? { retired_from: old.retired_from } : {}) } : undefined);
354
362
  if (item)
355
363
  out.push(item);
356
364
  }
@@ -510,7 +518,7 @@ export async function readRunDiff(ws, run) {
510
518
  return diff;
511
519
  }
512
520
  /** The notes of a snapshot as the learning modules take them (buildIndex, mergeProblems): their front matter, no body. */
513
- export const snapshotNotes = (snapshot) => (snapshot?.notes ?? []).map((note) => ({ file: note.file, name: note.name, description: note.description, type: note.type, status: note.status, origin: note.origin, superseded_by: note.superseded_by, supersedes: [...note.supersedes], keys: [], body: "" }));
521
+ export const snapshotNotes = (snapshot) => (snapshot?.notes ?? []).map((note) => ({ file: note.file, name: note.name, description: note.description, type: note.type, status: note.status, origin: note.origin, superseded_by: note.superseded_by, supersedes: [...note.supersedes], retired_from: note.status === "retired" ? (note.retired_from ?? "pending") : null, keys: [], body: "" }));
514
522
  /** Every name at main's top a snapshot knows: the index, the notes, and the learned folders' tops. */
515
523
  export const topOf = (snapshot) => (snapshot ? [INDEX_FILE, ...snapshot.notes.map((note) => note.file), ...(snapshot.skills.length ? [SKILLS_DIR] : []), ...(snapshot.workflows.length ? [WORKFLOWS_DIR] : [])] : []);
516
524
  // ---------------------------------------------------------------------------------------------------------------------
@@ -697,16 +705,6 @@ export async function learningRepair(ws) {
697
705
  }
698
706
  throw new Error("the learning folder's main kept moving while its snapshot was rebuilt");
699
707
  }
700
- /** Main's text of `path` just before the newest person's retire of it on `main`'s line, or undefined (never retired by
701
- * a person). A read through the script: git's history is not in the snapshot. */
702
- export async function beforeRetire(ws, main, path) {
703
- const result = await runScript(ws, ["before-retire", main, checkPath(path)]);
704
- if (result.code === 1)
705
- return undefined;
706
- if (result.code !== 0)
707
- throw failed("before-retire", result);
708
- return textOf(result.stdout);
709
- }
710
708
  /** Whether `main` holds anything at `path`, as git stores it (any mode, any type): what the snapshot leaves out (a file
711
709
  * that is no note) included. A read through the script. */
712
710
  export async function heldOnMain(ws, main, path) {
@@ -24,6 +24,12 @@ export type GradeInput = {
24
24
  /** The skill and workflow draft the run proposes beside them, each checked, by path in the folder: a skill's
25
25
  * `skills/<name>/SKILL.md`, a draft's `workflows/<name>/workflow.json` with its `README.md`. */
26
26
  readonly files?: readonly NoteText[];
27
+ /** Each draft's dry run, by its workflow.json's path (skills.ts draftDryRun): passed, or not run and why. The prompt
28
+ * says it under the draft, each detail cut to DRY_RUN_DETAIL with unseen characters taken out. */
29
+ readonly dryRuns?: Readonly<Record<string, {
30
+ readonly status: string;
31
+ readonly detail?: string;
32
+ }>>;
27
33
  /** What the user said in the run, in order: the messages the run was sent, never the host's end-of-run turn. The
28
34
  * prompt holds every one, each cut to GRADE_CAPS.askedMessage, with unseen characters taken out, while together
29
35
  * they fit GRADE_CAPS.askedTotal (askedOf). The host cuts them of its secrets first. */
@@ -35,6 +41,9 @@ export type GradeInput = {
35
41
  readonly source: string;
36
42
  readonly text: string;
37
43
  }[];
44
+ /** Why each draft (by its workflow.json's path) waits for its owner's OK whatever the grade (skills.ts unpricedLine:
45
+ * a step calling an MCP tool with no declared price). Said under the draft; parseVerdict holds it. */
46
+ readonly held?: Readonly<Record<string, readonly string[]>>;
38
47
  };
39
48
  /** What bounds the grader's prompt, in UTF-16 units, as a completion counts them. `prompt` is the most it ever is:
40
49
  * the fixed text, the instructions cut to `instructions`, INDEX_LINES + CAPS.supersedes index lines cut to
@@ -72,6 +81,14 @@ export type Verdict = {
72
81
  /** The verdict when the grader's answer cannot be read: never a merge. */
73
82
  /** Why a verdict is no merge when the grader's answer could not be read at all: the host asks once more on it. */
74
83
  export declare const UNREADABLE_REASON = "the grader's verdict could not be read";
84
+ /** Why a verdict is no merge when the grader kept every item and still said no merge: its answer contradicts itself, so
85
+ * the host asks once more on it, the contradiction named (CONTRADICTION_ASK), as it does on an answer it cannot read. */
86
+ export declare const CONTRADICTED_REASON = "the grader's verdict contradicted itself: it kept every item and said not to merge";
87
+ /** Why a verdict is no merge when the grade, asked again because it contradicted itself, contradicted itself again: the
88
+ * learning run sets it (runner/learning-loop.ts), never parseVerdict, which reads one answer. */
89
+ export declare const CONTRADICTED_TWICE_REASON = "the grader's verdict contradicted itself twice: it kept every item and said not to merge, asked again";
90
+ /** What the grade is told when it is asked again after an answer that kept every item and said no merge. */
91
+ export declare const CONTRADICTION_ASK = "Your last answer said \"merge\": false while it kept every item (each one keep or pending). Both cannot hold: merge is true when any item is kept or pending. Answer again in the same format: keep or hold each item that may be kept, and drop each one that may not, with its question.";
75
92
  /** The files the grader gives one item for, in order: the new notes', then each skill and draft's (gradedFiles). */
76
93
  export declare const gradedFiles: (proposed: readonly NoteText[], files?: readonly NoteText[]) => string[];
77
94
  /** The items the grader judges, with their texts, in gradedFiles' order: what parseVerdict reads, a note's text for the
@@ -93,4 +110,4 @@ export declare function gradePrompt(input: GradeInput): string;
93
110
  * file it was not asked to judge, or a merge with an item not kept, is no merge. `proposed` are the new notes the
94
111
  * prompt was built from, or the files it asked an item for (gradedFiles: a note's file, a skill's SKILL.md, a draft's
95
112
  * workflow.json). Throws only when `proposed` is not a list a checked proposal could hold, never on the answer. */
96
- export declare function parseVerdict(text: unknown, proposed: readonly NoteText[] | readonly string[]): Verdict;
113
+ export declare function parseVerdict(text: unknown, proposed: readonly NoteText[] | readonly string[], held?: Readonly<Record<string, readonly string[]>>): Verdict;