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

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 (444) hide show
  1. package/CHANGELOG.md +270 -0
  2. package/README.md +343 -246
  3. package/dist/adapters.d.ts +0 -7
  4. package/dist/adapters.js +11 -22
  5. package/dist/agent-rows.d.ts +98 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +60 -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 +14 -0
  14. package/dist/api-only.js +33 -0
  15. package/dist/archil-routes.d.ts +1 -1
  16. package/dist/bash-read-only.d.ts +22 -0
  17. package/dist/bash-read-only.js +701 -0
  18. package/dist/box-egress-vm.d.ts +0 -8
  19. package/dist/box-egress-vm.js +0 -10
  20. package/dist/box-egress.d.ts +0 -4
  21. package/dist/box-egress.js +1 -16
  22. package/dist/box-paths.d.ts +25 -2
  23. package/dist/box-paths.js +79 -11
  24. package/dist/box-relay.d.ts +0 -11
  25. package/dist/box-relay.js +0 -20
  26. package/dist/box-settings.d.ts +26 -0
  27. package/dist/box-settings.js +63 -0
  28. package/dist/boxes.d.ts +21 -1
  29. package/dist/boxes.js +27 -20
  30. package/dist/browser-commands.d.ts +5 -2
  31. package/dist/browser-commands.js +4 -4
  32. package/dist/browser-computer.d.ts +5 -0
  33. package/dist/browser-computer.js +21 -0
  34. package/dist/browser-cost.d.ts +9 -6
  35. package/dist/browser-cost.js +94 -51
  36. package/dist/browser-live.d.ts +7 -20
  37. package/dist/browser-live.js +15 -93
  38. package/dist/browser-person.d.ts +18 -53
  39. package/dist/browser-person.js +94 -279
  40. package/dist/budget.d.ts +0 -4
  41. package/dist/budget.js +0 -7
  42. package/dist/cap.d.ts +8 -12
  43. package/dist/cap.js +12 -27
  44. package/dist/cli.js +61 -20
  45. package/dist/closed-pipes.d.ts +2 -0
  46. package/dist/closed-pipes.js +13 -0
  47. package/dist/computer-commands.d.ts +2 -0
  48. package/dist/computer-commands.js +2 -0
  49. package/dist/computer-keys.js +5 -2
  50. package/dist/computer-setting.d.ts +20 -4
  51. package/dist/computer-setting.js +25 -5
  52. package/dist/computers.d.ts +31 -3
  53. package/dist/computers.js +70 -11
  54. package/dist/confine.d.ts +120 -0
  55. package/dist/confine.js +436 -0
  56. package/dist/console/assets/index-RPHGlXmM.js +540 -0
  57. package/dist/console/assets/index-opTN5Naq.css +1 -0
  58. package/dist/console/index.html +2 -2
  59. package/dist/daytona-api.d.ts +0 -11
  60. package/dist/daytona-api.js +1 -82
  61. package/dist/decision-rows.d.ts +1 -1
  62. package/dist/decision-rows.js +1 -1
  63. package/dist/docker-daemon.d.ts +31 -0
  64. package/dist/docker-daemon.js +56 -0
  65. package/dist/docker-host-addresses.d.ts +37 -0
  66. package/dist/docker-host-addresses.js +110 -0
  67. package/dist/effort-guidance.js +4 -3
  68. package/dist/environment.d.ts +0 -3
  69. package/dist/environment.js +3 -5
  70. package/dist/errors.d.ts +0 -2
  71. package/dist/errors.js +6 -9
  72. package/dist/filed-answer.d.ts +32 -0
  73. package/dist/filed-answer.js +160 -0
  74. package/dist/files.d.ts +1 -11
  75. package/dist/files.js +2 -21
  76. package/dist/github-connection.d.ts +2 -2
  77. package/dist/github-connection.js +1 -1
  78. package/dist/graph-view.d.ts +3 -5
  79. package/dist/graph-view.js +4 -14
  80. package/dist/handed-values.d.ts +9 -0
  81. package/dist/handed-values.js +26 -0
  82. package/dist/harness-install.d.ts +22 -5
  83. package/dist/harness-install.js +98 -20
  84. package/dist/harness-opencode/adapter.d.ts +7 -0
  85. package/dist/harness-opencode/adapter.js +23 -6
  86. package/dist/harness-opencode/index.d.ts +1 -1
  87. package/dist/harness-opencode/index.js +1 -1
  88. package/dist/harness-opencode/verify.d.ts +17 -0
  89. package/dist/harness-opencode/verify.js +30 -10
  90. package/dist/harness-table.js +6 -1
  91. package/dist/harness.d.ts +4 -3
  92. package/dist/harness.js +16 -1
  93. package/dist/heard.js +1 -1
  94. package/dist/held-fd.d.ts +5 -0
  95. package/dist/held-fd.js +14 -0
  96. package/dist/host-calls.d.ts +20 -0
  97. package/dist/host-calls.js +12 -0
  98. package/dist/host-tools.d.ts +4 -21
  99. package/dist/host-tools.js +4 -61
  100. package/dist/host.d.ts +2 -4
  101. package/dist/host.js +2 -7
  102. package/dist/import-summary.d.ts +1 -5
  103. package/dist/import-summary.js +0 -21
  104. package/dist/import.d.ts +6 -6
  105. package/dist/import.js +62 -24
  106. package/dist/key-refusal.d.ts +5 -1
  107. package/dist/key-refusal.js +19 -4
  108. package/dist/learn/check.d.ts +6 -2
  109. package/dist/learn/check.js +83 -29
  110. package/dist/learn/folder.d.ts +5 -1
  111. package/dist/learn/folder.js +10 -3
  112. package/dist/learn/grade.d.ts +14 -0
  113. package/dist/learn/grade.js +68 -12
  114. package/dist/learn/index.d.ts +4 -4
  115. package/dist/learn/index.js +4 -4
  116. package/dist/learn/reflect.d.ts +31 -2
  117. package/dist/learn/reflect.js +79 -4
  118. package/dist/learn/relevance.d.ts +24 -0
  119. package/dist/learn/relevance.js +91 -0
  120. package/dist/learn/secrets.d.ts +8 -1
  121. package/dist/learn/secrets.js +95 -15
  122. package/dist/learn/skills.d.ts +112 -14
  123. package/dist/learn/skills.js +556 -52
  124. package/dist/learned-workflow.d.ts +37 -5
  125. package/dist/learned-workflow.js +106 -12
  126. package/dist/learning-routes.d.ts +16 -49
  127. package/dist/learning-routes.js +46 -36
  128. package/dist/learning-run.d.ts +6 -250
  129. package/dist/learning-run.js +11 -665
  130. package/dist/learning-words.d.ts +12 -5
  131. package/dist/learning-words.js +18 -9
  132. package/dist/learning.d.ts +93 -77
  133. package/dist/learning.js +176 -304
  134. package/dist/live/stream.js +1 -1
  135. package/dist/live/translate.js +13 -3
  136. package/dist/local-models.d.ts +11 -5
  137. package/dist/local-models.js +13 -8
  138. package/dist/mcp-gateway.d.ts +11 -52
  139. package/dist/mcp-gateway.js +44 -148
  140. package/dist/mcp-oauth.d.ts +10 -14
  141. package/dist/mcp-oauth.js +14 -32
  142. package/dist/mcp-probe.d.ts +0 -7
  143. package/dist/mcp-probe.js +4 -10
  144. package/dist/mcp-servers-store.d.ts +6 -6
  145. package/dist/mcp-servers-store.js +13 -15
  146. package/dist/mcp-store.js +3 -4
  147. package/dist/mcp.js +4 -3
  148. package/dist/model.d.ts +6 -7
  149. package/dist/model.js +43 -27
  150. package/dist/monid.d.ts +0 -2
  151. package/dist/monid.js +3 -6
  152. package/dist/openapi.d.ts +8 -1
  153. package/dist/openapi.js +124 -50
  154. package/dist/page.d.ts +1 -3
  155. package/dist/page.js +9 -19
  156. package/dist/paid-calls.d.ts +21 -27
  157. package/dist/paid-calls.js +28 -62
  158. package/dist/pause.d.ts +0 -2
  159. package/dist/pause.js +1 -8
  160. package/dist/place.d.ts +0 -5
  161. package/dist/place.js +0 -10
  162. package/dist/print.d.ts +2 -1
  163. package/dist/print.js +4 -2
  164. package/dist/propose.js +83 -39
  165. package/dist/push-handler.d.ts +1 -1
  166. package/dist/reflect-range.d.ts +25 -0
  167. package/dist/reflect-range.js +30 -0
  168. package/dist/refusal-words.d.ts +5 -1
  169. package/dist/refusal-words.js +5 -1
  170. package/dist/rows.d.ts +1 -1
  171. package/dist/run-cut.d.ts +0 -6
  172. package/dist/run-cut.js +0 -6
  173. package/dist/run-db.d.ts +2 -13
  174. package/dist/run-db.js +2 -41
  175. package/dist/run-launch.d.ts +19 -2
  176. package/dist/run-launch.js +13 -5
  177. package/dist/run-learning-served.d.ts +46 -2
  178. package/dist/run-learning-served.js +26 -7
  179. package/dist/run-reads-over-store.d.ts +1 -1
  180. package/dist/run-reads-over-store.js +15 -6
  181. package/dist/run-secrets.d.ts +33 -0
  182. package/dist/run-secrets.js +53 -0
  183. package/dist/run-timeline-served.d.ts +5 -1
  184. package/dist/run-timeline-served.js +19 -5
  185. package/dist/run-view.d.ts +12 -17
  186. package/dist/run-view.js +29 -28
  187. package/dist/runnable.d.ts +18 -10
  188. package/dist/runnable.js +21 -10
  189. package/dist/runner/adapter-loop.d.ts +14 -3
  190. package/dist/runner/adapter-loop.js +464 -62
  191. package/dist/runner/adapter-run-spec.d.ts +29 -8
  192. package/dist/runner/adapter-run-spec.js +96 -37
  193. package/dist/runner/adapters/index.js +11 -1
  194. package/dist/runner/adapters/pi.d.ts +15 -1
  195. package/dist/runner/adapters/pi.js +19 -5
  196. package/dist/runner/beside.d.ts +30 -3
  197. package/dist/runner/beside.js +54 -12
  198. package/dist/runner/claim-secrets.d.ts +10 -1
  199. package/dist/runner/claim-secrets.js +49 -15
  200. package/dist/runner/cli-run-spec.d.ts +2 -0
  201. package/dist/runner/cli-run-spec.js +60 -17
  202. package/dist/runner/commands.js +1 -1
  203. package/dist/runner/computer-journal.d.ts +15 -2
  204. package/dist/runner/computer-journal.js +41 -5
  205. package/dist/runner/conformance/harness.js +118 -8
  206. package/dist/runner/conformance/subject.d.ts +4 -1
  207. package/dist/runner/dispatch.d.ts +8 -1
  208. package/dist/runner/dispatch.js +81 -7
  209. package/dist/runner/end-of-run.d.ts +8 -2
  210. package/dist/runner/end-of-run.js +10 -4
  211. package/dist/runner/github-app.js +1 -1
  212. package/dist/runner/harness-loops.d.ts +9 -1
  213. package/dist/runner/harness-loops.js +15 -2
  214. package/dist/runner/journal-kinds.d.ts +30 -6
  215. package/dist/runner/journal-kinds.js +20 -5
  216. package/dist/runner/journal-reader.d.ts +1 -1
  217. package/dist/runner/journal-reader.js +2 -2
  218. package/dist/runner/learning-ask.d.ts +4 -0
  219. package/dist/runner/learning-ask.js +15 -1
  220. package/dist/runner/learning-end.d.ts +18 -3
  221. package/dist/runner/learning-end.js +113 -11
  222. package/dist/runner/learning-loop.d.ts +5 -0
  223. package/dist/runner/learning-loop.js +26 -6
  224. package/dist/runner/live-ticker.d.ts +1 -1
  225. package/dist/runner/live-ticker.js +28 -4
  226. package/dist/runner/loop-contract.d.ts +3 -2
  227. package/dist/runner/main.d.ts +64 -10
  228. package/dist/runner/main.js +165 -27
  229. package/dist/runner/mcp-claim.d.ts +1 -1
  230. package/dist/runner/mcp-claim.js +2 -3
  231. package/dist/runner/mcp-run.d.ts +2 -0
  232. package/dist/runner/mcp-run.js +15 -5
  233. package/dist/runner/memory-claim.d.ts +9 -0
  234. package/dist/runner/memory-claim.js +25 -0
  235. package/dist/runner/metrics.d.ts +33 -1
  236. package/dist/runner/metrics.js +85 -1
  237. package/dist/runner/model-route.d.ts +13 -0
  238. package/dist/runner/model-route.js +154 -11
  239. package/dist/runner/redact.d.ts +8 -2
  240. package/dist/runner/redact.js +11 -2
  241. package/dist/runner/reflect-hook.d.ts +12 -1
  242. package/dist/runner/reflect-hook.js +33 -3
  243. package/dist/runner/runner.d.ts +20 -0
  244. package/dist/runner/runner.js +56 -10
  245. package/dist/runner/store-port.d.ts +1 -1
  246. package/dist/runner/store-secrets.d.ts +3 -3
  247. package/dist/runner/store-secrets.js +8 -12
  248. package/dist/runner/text-tools.d.ts +44 -0
  249. package/dist/runner/text-tools.js +237 -0
  250. package/dist/runner/workflow-loop.d.ts +6 -0
  251. package/dist/runner/workflow-loop.js +6 -4
  252. package/dist/runner/workflow-spec.d.ts +18 -0
  253. package/dist/runner/workflow-spec.js +68 -26
  254. package/dist/runs-over-store.d.ts +8 -3
  255. package/dist/runs-over-store.js +76 -19
  256. package/dist/seal-key.d.ts +54 -15
  257. package/dist/seal-key.js +232 -82
  258. package/dist/sealed-settings-store.d.ts +19 -4
  259. package/dist/sealed-settings-store.js +9 -9
  260. package/dist/sealing.d.ts +4 -0
  261. package/dist/sealing.js +20 -0
  262. package/dist/secret-cut.d.ts +1 -1
  263. package/dist/secret-cut.js +1 -1
  264. package/dist/secret-name.d.ts +9 -0
  265. package/dist/secret-name.js +15 -0
  266. package/dist/secret-writes.d.ts +0 -1
  267. package/dist/secret-writes.js +0 -1
  268. package/dist/secrets.d.ts +2 -10
  269. package/dist/secrets.js +21 -17
  270. package/dist/server-fs.d.ts +4 -0
  271. package/dist/server-fs.js +8 -2
  272. package/dist/server-lock.d.ts +0 -24
  273. package/dist/server-lock.js +1 -80
  274. package/dist/server-secrets-store.d.ts +4 -4
  275. package/dist/server-secrets-store.js +10 -32
  276. package/dist/server-secrets.d.ts +4 -9
  277. package/dist/server-secrets.js +12 -33
  278. package/dist/server.d.ts +26 -44
  279. package/dist/server.js +229 -142
  280. package/dist/sign-ins-store.d.ts +34 -36
  281. package/dist/sign-ins-store.js +27 -38
  282. package/dist/sign-ins.d.ts +2 -119
  283. package/dist/sign-ins.js +5 -311
  284. package/dist/standard-webhooks.d.ts +1 -1
  285. package/dist/standard-webhooks.js +1 -1
  286. package/dist/stats.d.ts +3 -2
  287. package/dist/stats.js +1 -1
  288. package/dist/store/agent-body.d.ts +8 -2
  289. package/dist/store/agent-body.js +16 -4
  290. package/dist/store/index.d.ts +3 -3
  291. package/dist/store/index.js +3 -3
  292. package/dist/store/open.d.ts +18 -5
  293. package/dist/store/open.js +23 -3
  294. package/dist/store/postgres/connection.d.ts +18 -2
  295. package/dist/store/postgres/connection.js +156 -32
  296. package/dist/store/postgres/migrate.d.ts +4 -0
  297. package/dist/store/postgres/migrate.js +27 -3
  298. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  299. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  300. package/dist/store/postgres/store.d.ts +9 -2
  301. package/dist/store/postgres/store.js +9 -0
  302. package/dist/store/schema.js +1 -1
  303. package/dist/store/seal.js +2 -2
  304. package/dist/store/sqlite/connection.js +49 -5
  305. package/dist/store/sqlite/run-patch.d.ts +3 -0
  306. package/dist/store/sqlite/run-patch.js +3 -0
  307. package/dist/store/sqlite/store.js +64 -20
  308. package/dist/store/store.d.ts +38 -6
  309. package/dist/store/store.js +12 -2
  310. package/dist/store-reads/cap.d.ts +1 -1
  311. package/dist/store-reads/cap.js +22 -4
  312. package/dist/store-reads/journal.d.ts +25 -6
  313. package/dist/store-reads/journal.js +173 -21
  314. package/dist/store-reads/learning.d.ts +26 -8
  315. package/dist/store-reads/learning.js +12 -4
  316. package/dist/store-reads/workflow.d.ts +1 -1
  317. package/dist/store-reads/workflow.js +1 -1
  318. package/dist/store-view.d.ts +5 -1
  319. package/dist/store-view.js +91 -23
  320. package/dist/template-eval.d.ts +60 -4
  321. package/dist/template-eval.js +120 -54
  322. package/dist/templates.d.ts +24 -10
  323. package/dist/templates.js +69 -38
  324. package/dist/timeline/group.d.ts +33 -0
  325. package/dist/timeline/group.js +77 -0
  326. package/dist/timeline/index.d.ts +7 -0
  327. package/dist/timeline/index.js +7 -0
  328. package/dist/timeline/labels.d.ts +79 -0
  329. package/dist/timeline/labels.js +150 -0
  330. package/dist/timeline/origin.d.ts +56 -0
  331. package/dist/timeline/origin.js +92 -0
  332. package/dist/timeline/render-text.d.ts +11 -0
  333. package/dist/timeline/render-text.js +62 -0
  334. package/dist/timeline/timeline.d.ts +274 -0
  335. package/dist/timeline/timeline.js +1308 -0
  336. package/dist/timeline/util.d.ts +17 -0
  337. package/dist/timeline/util.js +49 -0
  338. package/dist/tool-gate.d.ts +41 -216
  339. package/dist/tool-gate.js +79 -540
  340. package/dist/tool-keys-store.d.ts +11 -12
  341. package/dist/tool-keys-store.js +24 -31
  342. package/dist/tool-keys.d.ts +9 -104
  343. package/dist/tool-keys.js +15 -271
  344. package/dist/tool-plane.d.ts +14 -42
  345. package/dist/tool-plane.js +23 -81
  346. package/dist/tool-settings-store.d.ts +1 -2
  347. package/dist/tool-settings-store.js +5 -8
  348. package/dist/tools.d.ts +31 -19
  349. package/dist/tools.js +101 -108
  350. package/dist/trigger-adapter.d.ts +2 -2
  351. package/dist/trigger-schedule.js +2 -1
  352. package/dist/trigger-secrets-shown.js +5 -1
  353. package/dist/trigger-targets.d.ts +13 -1
  354. package/dist/trigger-targets.js +31 -1
  355. package/dist/triggers.d.ts +2 -2
  356. package/dist/triggers.js +3 -3
  357. package/dist/turn-end.d.ts +1 -1
  358. package/dist/turn-end.js +1 -1
  359. package/dist/turns.d.ts +0 -6
  360. package/dist/turns.js +0 -19
  361. package/dist/uploads.js +1 -1
  362. package/dist/usage.d.ts +0 -2
  363. package/dist/usage.js +0 -2
  364. package/dist/validate.d.ts +2 -0
  365. package/dist/validate.js +23 -14
  366. package/dist/webhooks.d.ts +102 -76
  367. package/dist/webhooks.js +266 -233
  368. package/dist/workflow-run.d.ts +114 -0
  369. package/dist/workflow-run.js +144 -0
  370. package/dist/workspace/beneath.d.ts +19 -0
  371. package/dist/workspace/beneath.js +106 -0
  372. package/dist/workspace/computer-deps.d.ts +52 -5
  373. package/dist/workspace/computer-deps.js +154 -19
  374. package/dist/workspace/computer-for-claim.d.ts +19 -14
  375. package/dist/workspace/computer-for-claim.js +77 -16
  376. package/dist/workspace/computer-hold.d.ts +6 -1
  377. package/dist/workspace/computer-hold.js +6 -1
  378. package/dist/workspace/computer-janitor.d.ts +47 -0
  379. package/dist/workspace/computer-janitor.js +182 -0
  380. package/dist/workspace/computer-providers.d.ts +6 -2
  381. package/dist/workspace/computer-providers.js +1 -1
  382. package/dist/workspace/grep-worker.d.ts +5 -0
  383. package/dist/workspace/grep-worker.js +9 -6
  384. package/dist/workspace/index.d.ts +4 -3
  385. package/dist/workspace/index.js +4 -4
  386. package/dist/workspace/local.d.ts +11 -2
  387. package/dist/workspace/local.js +161 -43
  388. package/dist/workspace/resolve-computer.d.ts +50 -10
  389. package/dist/workspace/resolve-computer.js +46 -11
  390. package/dist/workspace/run-tools.d.ts +13 -31
  391. package/dist/workspace/run-tools.js +10 -27
  392. package/dist/workspace-paths.d.ts +0 -17
  393. package/dist/workspace-paths.js +1 -41
  394. package/dist/workspace.d.ts +0 -17
  395. package/dist/workspace.js +3 -99
  396. package/launcher/agentrun-serve +6 -33
  397. package/package.json +14 -14
  398. package/templates/README.md +9 -3
  399. package/templates/inbound-lead/agent.md +1 -1
  400. package/templates/kyb/agent.md +1 -1
  401. package/templates/market-monitor/agent.md +2 -2
  402. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  403. package/dist/app.d.ts +0 -5
  404. package/dist/app.js +0 -514
  405. package/dist/bound-files.d.ts +0 -4
  406. package/dist/bound-files.js +0 -164
  407. package/dist/bounds.d.ts +0 -26
  408. package/dist/bounds.js +0 -137
  409. package/dist/coding-tools.d.ts +0 -47
  410. package/dist/coding-tools.js +0 -189
  411. package/dist/computer-adb.d.ts +0 -12
  412. package/dist/computer-adb.js +0 -14
  413. package/dist/console/assets/index-35-7aeIZ.js +0 -519
  414. package/dist/console/assets/index-Cejbov-Y.css +0 -1
  415. package/dist/content-filter.d.ts +0 -7
  416. package/dist/content-filter.js +0 -23
  417. package/dist/disk.d.ts +0 -33
  418. package/dist/disk.js +0 -85
  419. package/dist/door-line.d.ts +0 -23
  420. package/dist/door-line.js +0 -83
  421. package/dist/grade.d.ts +0 -63
  422. package/dist/grade.js +0 -150
  423. package/dist/harness-app.d.ts +0 -69
  424. package/dist/harness-app.js +0 -1162
  425. package/dist/mcp-servers.d.ts +0 -269
  426. package/dist/mcp-servers.js +0 -456
  427. package/dist/packs.d.ts +0 -71
  428. package/dist/packs.js +0 -180
  429. package/dist/request-start.d.ts +0 -27
  430. package/dist/request-start.js +0 -381
  431. package/dist/run-box.d.ts +0 -205
  432. package/dist/run-box.js +0 -661
  433. package/dist/run-holder.d.ts +0 -52
  434. package/dist/run-holder.js +0 -139
  435. package/dist/runs.d.ts +0 -1200
  436. package/dist/runs.js +0 -4103
  437. package/dist/sealed-settings.d.ts +0 -60
  438. package/dist/sealed-settings.js +0 -178
  439. package/dist/served-only.d.ts +0 -5
  440. package/dist/served-only.js +0 -12
  441. package/dist/sessions.d.ts +0 -6
  442. package/dist/sessions.js +0 -109
  443. package/dist/workspace/computer-serves.d.ts +0 -12
  444. package/dist/workspace/computer-serves.js +0 -15
package/dist/host.d.ts CHANGED
@@ -22,10 +22,8 @@ export declare function runsThatFit(harness: string, memory: number): number;
22
22
  export declare const defaultMaxRuns: (memory: number) => number;
23
23
  /** Why no run of `harness` can ever start on a host of `memory` bytes, in words; undefined when one fits. */
24
24
  export declare function neverFits(harness: string, memory: number): string | undefined;
25
- /** Why a run of `harness` cannot start now, with `heldMib` of the memory for runs held: the memory runs hold, in words. */
26
- export declare function memoryFull(harness: string, memory: number, heldMib: number): string;
27
- /** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. The
28
- * memory each run reserves is checked beside it (runs.ts): both apply. */
25
+ /** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. A runner
26
+ * holds at most this many; a run past it waits queued, never refused for a place. */
29
27
  export declare function maxRunsOf(env: NodeJS.ProcessEnv, given?: number): number;
30
28
  export type Health = {
31
29
  status: "ok" | "failing";
package/dist/host.js CHANGED
@@ -47,13 +47,8 @@ export function neverFits(harness, memory) {
47
47
  const fit = HARNESSES.filter((id) => runsThatFit(id, memory) > 0);
48
48
  return `This server has ${sizeOf(memory / MiB)} of memory and keeps ${sizeOf(SERVER_MIB)} for itself; ${aRun(harness)} needs about ${sizeOf(runMibOf(harness))} more, so it can't start here. ${listed(fit)} runs fit.`;
49
49
  }
50
- /** Why a run of `harness` cannot start now, with `heldMib` of the memory for runs held: the memory runs hold, in words. */
51
- export function memoryFull(harness, memory, heldMib) {
52
- const free = Math.max(0, runsMemoryMib(memory) - heldMib);
53
- return `This server's memory is held by the runs it has going: ${aRun(harness)} needs about ${sizeOf(runMibOf(harness))}, and ${sizeOf(free)} of the ${sizeOf(runsMemoryMib(memory))} it has for runs is free; start this one when another ends.`;
54
- }
55
- /** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. The
56
- * memory each run reserves is checked beside it (runs.ts): both apply. */
50
+ /** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. A runner
51
+ * holds at most this many; a run past it waits queued, never refused for a place. */
57
52
  export function maxRunsOf(env, given) {
58
53
  const value = given ?? (env.AGENTRUN_MAX_RUNS ? Number(env.AGENTRUN_MAX_RUNS) : defaultMaxRuns(hostMemory()));
59
54
  if (!Number.isSafeInteger(value) || value < 1)
@@ -1,5 +1,4 @@
1
- import type { AgentStoreReader } from "@parcha/pi-durable-agent";
2
- import type { RunMetrics } from "@parcha/pi-durable-agent/timeline";
1
+ import type { RunMetrics } from "./timeline/index.js";
3
2
  import { type Source } from "./import-sources.js";
4
3
  /** A session an import found: its source and agent; what it used (undefined: unknown), with its time at work; and its
5
4
  * model requests by local hour of the day (undefined: their times are unknown). `untied`: a subagent's session whose
@@ -15,9 +14,6 @@ export type Found = {
15
14
  };
16
15
  /** Requests by local hour of the day, from their times (ms). */
17
16
  export declare function hoursOf(times: Iterable<number>): number[];
18
- /** An imported run of `store`, as found: its metrics as the store keeps them, and its requests' times from its transcript,
19
- * read by SQLite's JSON functions (no record is parsed here). Undefined for a run the store does not hold as imported. */
20
- export declare function foundIn(store: AgentStoreReader, runId: string): Promise<Found | undefined>;
21
17
  /** The summary's lines for `found`, ending with where to open the server (`open`, its address). `dryRun`: what an import
22
18
  * would take, nothing taken yet. */
23
19
  export declare function summaryLines(everything: readonly Found[], open: string, { dryRun }?: {
@@ -1,8 +1,4 @@
1
- // The lines an import ends with: how many sessions it found and from where, how many agents they make, and what they
2
- // used, from every session found, those imported before included. A number with no data behind it reads unknown.
3
- import { existsSync } from "node:fs";
4
1
  import { SOURCES } from "./import-sources.js";
5
- import { readRunDbSync } from "./run-db.js";
6
2
  const NAMES = { "claude-code": "Claude Code", codex: "Codex", pi: "pi" };
7
3
  /** Requests by local hour of the day, from their times (ms). */
8
4
  export function hoursOf(times) {
@@ -12,23 +8,6 @@ export function hoursOf(times) {
12
8
  hours[new Date(at).getHours()] += 1;
13
9
  return hours;
14
10
  }
15
- /** An imported run of `store`, as found: its metrics as the store keeps them, and its requests' times from its transcript,
16
- * read by SQLite's JSON functions (no record is parsed here). Undefined for a run the store does not hold as imported. */
17
- export async function foundIn(store, runId) {
18
- const run = store.readRun(runId);
19
- if (!run?.importedFrom)
20
- return undefined;
21
- const metrics = store.runMetrics(runId);
22
- const file = store.runStorePath(runId);
23
- let hours;
24
- if (existsSync(file)) {
25
- hours = readRunDbSync(file, false, (db) => {
26
- const rows = db.prepare("SELECT json_extract(record, '$.model[0].timestamp') AS at FROM entries WHERE json_extract(record, '$.kind') = 'pi.assistant'").all();
27
- return hoursOf(rows.map((row) => Number(row.at)));
28
- });
29
- }
30
- return { source: run.importedFrom.source, agent: run.agent, ...(metrics ? { metrics } : {}), ...(hours ? { hours } : {}) };
31
- }
32
11
  const count = (n) => n.toLocaleString("en-US");
33
12
  const compact = new Intl.NumberFormat("en-US", { notation: "compact", maximumFractionDigits: 1 });
34
13
  const plural = (n, one) => `${count(n)} ${one}${n === 1 ? "" : "s"}`;
package/dist/import.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type StorageWrite } from "@earendil-works/pi-durable";
2
- import { type EntryLike } from "@parcha/pi-durable-agent/timeline";
2
+ import { type EntryLike } from "./timeline/index.js";
3
3
  import { type Session, type Source } from "./import-sources.js";
4
4
  import { type Found } from "./import-summary.js";
5
5
  import { type Store } from "./store/index.js";
@@ -130,11 +130,11 @@ export declare function transcriptOf(session: Session, cut: (value: unknown) =>
130
130
  entries: EntryLike[];
131
131
  };
132
132
  /** The secrets this server made and keeps, by value: its API token and its sign-in sessions' secret (still files beside the
133
- * store), its webhook's signing secret (`whsec_...`; webhooks.ts) and every value a trigger source keeps sealed, which the
134
- * switch keeps as store rows (server-secrets-store.ts), opened with the seal key of `env`, so left out when that key is not
135
- * there; each signing secret's key in every spelling too. One pasted into a session is this server's own, so an import cuts
136
- * it wherever it is, as it cuts the environment's keys. Not among them: a key-shaped value this server did not make (a
137
- * `whsec_` from elsewhere). The per-run door token is gone (the runner cutover deleted it). A webhook secret that does not
133
+ * store), and its webhook's signing secret (`whsec_...`; webhooks.ts) and every value a trigger source keeps sealed, as
134
+ * store rows (server-secrets-store.ts), opened with the seal key of `env`, which the caller has (a dry run over a store that
135
+ * keeps no secret has none, and does not ask); each signing secret's key in every spelling too. One pasted into a
136
+ * session is this server's own, so an import cuts it wherever it is, as it cuts the environment's keys. Not among them: a key-shaped value this server did not make (a
137
+ * `whsec_` from elsewhere). The per-run door token is gone (the runner cutover deleted it). A sealed value that does not
138
138
  * open is said to `say`: the import goes on, and does not cut it. */
139
139
  export declare function ownSecrets(store: {
140
140
  triggerSettings: Pick<Store["triggerSettings"], "get" | "put" | "removeScope">;
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";
@@ -21,12 +21,11 @@ import { logLine } from "./print.js";
21
21
  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
- import { SECRET_NAMES, withSecrets } from "./secrets.js";
25
- import { SEAL_KEY_ENV } from "./tool-keys.js";
26
- import { bootSealKey } from "./seal-key.js";
24
+ import { handedSecret, SECRET_NAMES, withSecrets } from "./secrets.js";
25
+ import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
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,16 +981,15 @@ 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: boot it the
987
- // one way the server and runner do (seal-key.ts bootSealKey), before the environment is read, so the environment carries
988
- // it; without it the store's server-secret reads refuse to open. The key handed over wins, else the one under the config
989
- // home, as the server reads it. A caller's own environment (a test's) is given the key too, so it reads the same store.
990
- const seal = bootSealKey();
984
+ // The server's own secrets, kept sealed in the store, open only under the server's seal key: it is
985
+ // booted the one way the server and runner boot it (seal-key.ts bootSealKey) once the store is open (keyed below), and
986
+ // checked against it. The key handed over wins (this process's, else a caller's own environment's: a test's), else the
987
+ // one in the data directory, as the server reads it.
988
+ const handedKey = handedSecret(SEAL_KEY_ENV) ?? env?.[SEAL_KEY_ENV];
989
+ const ownEnv = env === undefined;
991
990
  // The server's own keys, which its start moved out of process.env (secrets.ts), read back in: the import cuts them out of
992
991
  // what it keeps, as it cuts every other key in the environment.
993
992
  env ??= withSecrets(process.env);
994
- if (env[SEAL_KEY_ENV] === undefined)
995
- Object.defineProperty(env, SEAL_KEY_ENV, { value: seal.text, enumerable: false, configurable: true });
996
993
  // What it prints goes through the cut what it keeps does, with the keys secretlint finds in the lines themselves: a
997
994
  // file or project named after a key is printed cut. The lines are held until the end, then scanned and printed.
998
995
  const printed = secretCut(env, SECRET_NAMES);
@@ -1010,6 +1007,27 @@ temp = tmpdir(), env, out = console.log, } = {}) {
1010
1007
  for (const line of lines.splice(0))
1011
1008
  print(printed.text(line));
1012
1009
  };
1010
+ let dir;
1011
+ /** The store's seal key, booted against `store` (seal-key.ts), and the environment the import reads given it, so the
1012
+ * store's sealed reads open under it. A dry run (`write` false) makes, moves and records nothing, and a store that holds
1013
+ * no secret and has no key is read with none. The key is cut from what is printed, as every key is. */
1014
+ let releaseKey = () => undefined;
1015
+ const keyed = async (store, write) => {
1016
+ const seal = await bootSealKey(store, dir, { given: handedKey, role: "import", write, say: (line) => void warnings.push(line.trimEnd()) });
1017
+ if (!seal)
1018
+ return;
1019
+ releaseKey = seal.release;
1020
+ printed.add([seal.text]);
1021
+ // The environment the import reads, this process's own or a caller's, with the key the boot checked as its seal key.
1022
+ env = withSealKey(ownEnv ? withSecrets(process.env) : env, seal.text);
1023
+ };
1024
+ /** A start the seal key refuses (seal-key.ts): said, in its words, and the import does not go on. */
1025
+ const sealRefused = (error) => {
1026
+ if (!(error instanceof SealKeyRefused))
1027
+ return false;
1028
+ warnings.push(`agentrun-serve import: ${error.message}`);
1029
+ return true;
1030
+ };
1013
1031
  try {
1014
1032
  let values;
1015
1033
  try {
@@ -1042,13 +1060,17 @@ temp = tmpdir(), env, out = console.log, } = {}) {
1042
1060
  console.error(`--from takes ${SOURCES.join(", ")}: not ${unknown.join(", ")}\n\n${usage}`);
1043
1061
  return 2;
1044
1062
  }
1045
- const dir = values.data ?? defaultData({ ...env, HOME: home });
1063
+ dir = values.data ?? defaultData({ ...env, HOME: home });
1046
1064
  // The import's options, built from the open store: the tool keys the server keeps as sealed rows (tool-keys-store.ts),
1047
1065
  // opened here with the seal key this process was handed, and this server's own secrets (server-secrets-store.ts). One
1048
1066
  // that does not open is not known here, so not cut: said, as the server says it at its start. A dry run on a data
1049
1067
  // directory with no store yet reads neither (none is there).
1050
1068
  const optionsFrom = async (store) => {
1051
- const keys = store ? toolKeysOverStore(store, env, say("tool_keys")) : undefined;
1069
+ // The environment as it is now: once the store's key is booted (keyed), it carries it.
1070
+ const keyEnv = env;
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;
1052
1074
  if (keys) {
1053
1075
  await keys.load();
1054
1076
  keys.view();
@@ -1059,9 +1081,9 @@ temp = tmpdir(), env, out = console.log, } = {}) {
1059
1081
  all: values.all === true,
1060
1082
  deleted: values["include-deleted"] === true,
1061
1083
  temp,
1062
- env,
1084
+ env: keyEnv,
1063
1085
  stored: keys ? keys.values() : {},
1064
- own: store ? await ownSecrets(store, dir, env, say("webhook_secret")) : [],
1086
+ own: keyed ? await ownSecrets(store, dir, keyEnv, say("sealed_settings")) : [],
1065
1087
  };
1066
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
1067
1089
  // keeps is.
@@ -1082,12 +1104,19 @@ temp = tmpdir(), env, out = console.log, } = {}) {
1082
1104
  let plan;
1083
1105
  let found;
1084
1106
  try {
1107
+ if (reader)
1108
+ await keyed(reader, false);
1085
1109
  const options = await optionsFrom(reader);
1086
1110
  plan = await planImport({ ...options, measure: true }, reader);
1087
1111
  for (const line of await describePlan(plan, reader, { verbose: values.verbose === true }))
1088
1112
  out(line);
1089
1113
  found = [...plan.found, ...(reader ? await foundAll(reader, plan.held) : []), ...(await untiedFound(plan))];
1090
1114
  }
1115
+ catch (error) {
1116
+ if (sealRefused(error))
1117
+ return 1;
1118
+ throw error;
1119
+ }
1091
1120
  finally {
1092
1121
  await reader?.close();
1093
1122
  }
@@ -1117,6 +1146,14 @@ temp = tmpdir(), env, out = console.log, } = {}) {
1117
1146
  throw error;
1118
1147
  }
1119
1148
  try {
1149
+ try {
1150
+ await keyed(store, true);
1151
+ }
1152
+ catch (error) {
1153
+ if (sealRefused(error))
1154
+ return 1;
1155
+ throw error;
1156
+ }
1120
1157
  const options = await optionsFrom(store);
1121
1158
  const plan = await planImport(options, store);
1122
1159
  const report = await runImport(store, plan, options);
@@ -1143,6 +1180,7 @@ temp = tmpdir(), env, out = console.log, } = {}) {
1143
1180
  }
1144
1181
  }
1145
1182
  finally {
1183
+ releaseKey();
1146
1184
  await flush();
1147
1185
  }
1148
1186
  }
@@ -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 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. */
@@ -69,6 +69,9 @@ export type CheckInput = {
69
69
  readonly deniedBy?: Readonly<Record<string, "agent" | "server" | "default">>;
70
70
  /** The workflow DSL a draft is read with; a proposal that holds a draft is checked with it, never without. */
71
71
  readonly dsl?: DraftReader;
72
+ /** Each draft's dry run (skills.ts draftDryRun), by its workflow.json's path: one that failed is refused, rule
73
+ * `workflow`, when the draft has no other problem. A draft with none given is checked without one. */
74
+ readonly dryRuns?: Readonly<Record<string, DraftDryRun>>;
72
75
  /** 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
76
  * owner's OK): a run never changes those. A draft's is its README.md. */
74
77
  readonly kept?: readonly string[];
@@ -79,7 +82,8 @@ export type ProposalCheck = {
79
82
  readonly problems: Problem[];
80
83
  readonly notes: ProposedNote[];
81
84
  };
82
- /** `problem` as it may be printed: its path and detail cut of `values` and of secret shapes, whole when over PRINT_MAX. */
85
+ /** `problem` as it may be printed: its path and detail cut of `values` and of every shape learning refuses, a bank's
86
+ * numbers too (redactLearned: a name refused for one never prints it), whole when over PRINT_MAX. */
83
87
  export declare const printable: (problem: Problem, values: readonly string[]) => Problem;
84
88
  /** 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
89
  * 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);
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")
@@ -217,12 +262,12 @@ export function checkProposal(input) {
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)
@@ -102,7 +102,7 @@ export type RunDiff = {
102
102
  };
103
103
  /** Git's blob id of `bytes`: the sha1 of "blob <length>\0" and the bytes. */
104
104
  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. */
105
+ /** A commit as the snapshot reads it: its time (git's %cI, as commitTime keeps it), subject, body and trailers. */
106
106
  type CommitInfo = {
107
107
  at: string;
108
108
  subject: string;
@@ -119,6 +119,10 @@ type TreeEntry = {
119
119
  path: string;
120
120
  };
121
121
  /** What the script's `read` printed: main, its tree, its log and its blobs. Undefined main for a folder with none. */
122
+ /** 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
123
+ * committer's zone), in the one form a snapshot keeps: UTC in whole seconds, ending "Z", as nextSnapshot writes it, so
124
+ * a snapshot rebuilt from git and one built incrementally agree. Text that is no time is kept as it is. */
125
+ export declare function commitTime(text: string): string;
122
126
  export declare function parseRead(out: Uint8Array): {
123
127
  main: string | undefined;
124
128
  tree: TreeEntry[];