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

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 (816) hide show
  1. package/CHANGELOG.md +459 -0
  2. package/NOTICE +18 -0
  3. package/README.md +941 -263
  4. package/dist/adapter-facts.d.ts +3 -0
  5. package/dist/adapter-facts.js +5 -0
  6. package/dist/adapters.d.ts +64 -143
  7. package/dist/adapters.js +153 -384
  8. package/dist/agents-store.d.ts +146 -0
  9. package/dist/agents-store.js +359 -0
  10. package/dist/agents.d.ts +4 -2
  11. package/dist/agents.js +37 -17
  12. package/dist/api-only.d.ts +14 -0
  13. package/dist/api-only.js +33 -0
  14. package/dist/approvals.d.ts +4 -0
  15. package/dist/approvals.js +7 -0
  16. package/dist/archil-routes.d.ts +45 -0
  17. package/dist/archil-routes.js +150 -0
  18. package/dist/archil-settings.d.ts +30 -0
  19. package/dist/archil-settings.js +34 -0
  20. package/dist/background.js +28 -9
  21. package/dist/box-egress-vm.d.ts +2 -9
  22. package/dist/box-egress-vm.js +20 -16
  23. package/dist/box-egress.d.ts +15 -9
  24. package/dist/box-egress.js +26 -29
  25. package/dist/box-paths.d.ts +82 -0
  26. package/dist/box-paths.js +160 -0
  27. package/dist/box-relay-vm.js +28 -1
  28. package/dist/box-relay.d.ts +1 -10
  29. package/dist/box-relay.js +1 -21
  30. package/dist/box-settings.d.ts +46 -0
  31. package/dist/box-settings.js +107 -0
  32. package/dist/boxes.d.ts +17 -2
  33. package/dist/boxes.js +37 -3
  34. package/dist/browser-commands.d.ts +43 -0
  35. package/dist/browser-commands.js +154 -0
  36. package/dist/browser-cost.d.ts +30 -3
  37. package/dist/browser-cost.js +277 -21
  38. package/dist/browser-live.d.ts +124 -0
  39. package/dist/browser-live.js +324 -0
  40. package/dist/browser-person.d.ts +166 -0
  41. package/dist/browser-person.js +767 -0
  42. package/dist/budget.d.ts +76 -0
  43. package/dist/budget.js +204 -0
  44. package/dist/cap.d.ts +267 -64
  45. package/dist/cap.js +587 -199
  46. package/dist/cli.js +220 -21
  47. package/dist/coding-tools.d.ts +13 -1
  48. package/dist/coding-tools.js +107 -5
  49. package/dist/computer-adb.d.ts +12 -0
  50. package/dist/computer-adb.js +14 -0
  51. package/dist/computer-commands.d.ts +103 -0
  52. package/dist/computer-commands.js +256 -0
  53. package/dist/computer-keys.d.ts +68 -0
  54. package/dist/computer-keys.js +148 -0
  55. package/dist/computer-routes.d.ts +38 -0
  56. package/dist/computer-routes.js +56 -0
  57. package/dist/computer-setting.d.ts +37 -0
  58. package/dist/computer-setting.js +47 -0
  59. package/dist/computer-view.d.ts +38 -0
  60. package/dist/computer-view.js +14 -0
  61. package/dist/computers.d.ts +137 -0
  62. package/dist/computers.js +197 -0
  63. package/dist/console/THIRD-PARTY-NOTICES.txt +25 -0
  64. package/dist/console/assets/index-Dn0ngwG9.js +535 -0
  65. package/dist/console/assets/index-DvW6Aled.css +1 -0
  66. package/dist/console/index.html +2 -2
  67. package/dist/console-links.d.ts +2 -0
  68. package/dist/console-links.js +6 -0
  69. package/dist/daytona-api.d.ts +0 -11
  70. package/dist/daytona-api.js +1 -82
  71. package/dist/decision-cap.d.ts +63 -0
  72. package/dist/decision-cap.js +163 -0
  73. package/dist/decision-rows.d.ts +5 -2
  74. package/dist/decision-rows.js +8 -6
  75. package/dist/decisions.d.ts +28 -1
  76. package/dist/decisions.js +63 -6
  77. package/dist/docker-host-addresses.d.ts +37 -0
  78. package/dist/docker-host-addresses.js +110 -0
  79. package/dist/egress-proxy.d.ts +45 -0
  80. package/dist/egress-proxy.js +416 -0
  81. package/dist/egress-table.d.ts +24 -0
  82. package/dist/egress-table.js +165 -0
  83. package/dist/errors.d.ts +15 -0
  84. package/dist/errors.js +22 -2
  85. package/dist/exa-keyless.js +1 -1
  86. package/dist/explain.d.ts +22 -0
  87. package/dist/explain.js +207 -0
  88. package/dist/faux-computers.d.ts +35 -0
  89. package/dist/faux-computers.js +126 -0
  90. package/dist/file-types.d.ts +4 -0
  91. package/dist/file-types.js +11 -0
  92. package/dist/files.d.ts +3 -43
  93. package/dist/files.js +8 -136
  94. package/dist/github-connection.d.ts +207 -0
  95. package/dist/github-connection.js +595 -0
  96. package/dist/github.d.ts +64 -0
  97. package/dist/github.js +119 -0
  98. package/dist/grade.d.ts +9 -42
  99. package/dist/grade.js +42 -228
  100. package/dist/graph-served.d.ts +23 -2
  101. package/dist/graph-served.js +44 -3
  102. package/dist/graph-view.d.ts +7 -3
  103. package/dist/graph-view.js +26 -15
  104. package/dist/handed-values.d.ts +23 -0
  105. package/dist/handed-values.js +36 -0
  106. package/dist/harness-install.d.ts +143 -0
  107. package/dist/harness-install.js +454 -0
  108. package/dist/harness-opencode/adapter.js +42 -8
  109. package/dist/harness-opencode/facts.d.ts +2 -0
  110. package/dist/harness-opencode/facts.js +28 -0
  111. package/dist/harness-opencode/harness.d.ts +4 -0
  112. package/dist/harness-opencode/harness.js +38 -5
  113. package/dist/harness-opencode/host/policy.js +11 -3
  114. package/dist/harness-opencode/transcript.d.ts +25 -0
  115. package/dist/harness-opencode/transcript.js +81 -0
  116. package/dist/harness-table.d.ts +75 -0
  117. package/dist/harness-table.js +145 -0
  118. package/dist/harness.d.ts +11 -31
  119. package/dist/harness.js +30 -41
  120. package/dist/heard.d.ts +12 -0
  121. package/dist/heard.js +45 -0
  122. package/dist/helper-env.d.ts +4 -0
  123. package/dist/helper-env.js +14 -0
  124. package/dist/home-path.d.ts +0 -4
  125. package/dist/home-path.js +3 -17
  126. package/dist/host-check.d.ts +4 -3
  127. package/dist/host-check.js +5 -4
  128. package/dist/host-tools.d.ts +51 -8
  129. package/dist/host-tools.js +108 -117
  130. package/dist/host.d.ts +12 -6
  131. package/dist/host.js +30 -24
  132. package/dist/hosted-search.d.ts +3 -0
  133. package/dist/hosted-search.js +5 -3
  134. package/dist/import-proxy.d.ts +42 -0
  135. package/dist/import-proxy.js +105 -0
  136. package/dist/import-summary.js +4 -8
  137. package/dist/import-worker.d.ts +2 -3
  138. package/dist/import-worker.js +18 -16
  139. package/dist/import.d.ts +37 -17
  140. package/dist/import.js +249 -224
  141. package/dist/key-meta.d.ts +26 -0
  142. package/dist/key-meta.js +30 -0
  143. package/dist/key-refusal.d.ts +4 -1
  144. package/dist/key-refusal.js +20 -7
  145. package/dist/learn/check.d.ts +3 -1
  146. package/dist/learn/check.js +2 -2
  147. package/dist/learn/commit.d.ts +86 -0
  148. package/dist/learn/commit.js +182 -0
  149. package/dist/learn/folder.d.ts +296 -0
  150. package/dist/learn/folder.js +796 -0
  151. package/dist/learn/grade.d.ts +22 -9
  152. package/dist/learn/grade.js +95 -49
  153. package/dist/learn/index.d.ts +2 -2
  154. package/dist/learn/index.js +2 -2
  155. package/dist/learn/learning.sh +366 -0
  156. package/dist/learn/reflect.d.ts +12 -5
  157. package/dist/learn/reflect.js +70 -41
  158. package/dist/learn/secrets.d.ts +16 -7
  159. package/dist/learn/secrets.js +80 -17
  160. package/dist/learn/seed-check.d.ts +74 -0
  161. package/dist/learn/seed-check.js +103 -0
  162. package/dist/learn/skills.d.ts +5 -1
  163. package/dist/learn/skills.js +5 -4
  164. package/dist/learned-workflow.d.ts +15 -4
  165. package/dist/learned-workflow.js +13 -6
  166. package/dist/learning-routes.d.ts +56 -46
  167. package/dist/learning-routes.js +350 -553
  168. package/dist/learning-run.d.ts +8 -228
  169. package/dist/learning-run.js +26 -713
  170. package/dist/learning-words.d.ts +3 -5
  171. package/dist/learning-words.js +3 -5
  172. package/dist/learning.d.ts +177 -112
  173. package/dist/learning.js +289 -380
  174. package/dist/live/stream.d.ts +30 -0
  175. package/dist/live/stream.js +175 -0
  176. package/dist/live/translate.d.ts +52 -0
  177. package/dist/live/translate.js +276 -0
  178. package/dist/llm.js +3 -0
  179. package/dist/llms.txt +1 -0
  180. package/dist/local-models.d.ts +23 -0
  181. package/dist/local-models.js +35 -0
  182. package/dist/mcp-gateway.d.ts +45 -15
  183. package/dist/mcp-gateway.js +140 -53
  184. package/dist/mcp-meta.d.ts +3 -0
  185. package/dist/mcp-meta.js +14 -2
  186. package/dist/mcp-oauth.d.ts +172 -0
  187. package/dist/mcp-oauth.js +403 -0
  188. package/dist/mcp-private-hosts.d.ts +48 -0
  189. package/dist/mcp-private-hosts.js +141 -0
  190. package/dist/mcp-probe.d.ts +101 -0
  191. package/dist/mcp-probe.js +359 -0
  192. package/dist/mcp-secret-writes.d.ts +23 -0
  193. package/dist/mcp-secret-writes.js +60 -0
  194. package/dist/mcp-servers-store.d.ts +251 -0
  195. package/dist/mcp-servers-store.js +447 -0
  196. package/dist/mcp-servers.d.ts +180 -50
  197. package/dist/mcp-servers.js +284 -321
  198. package/dist/mcp-store.d.ts +103 -0
  199. package/dist/mcp-store.js +123 -0
  200. package/dist/mcp.js +22 -21
  201. package/dist/model.d.ts +77 -59
  202. package/dist/model.js +237 -98
  203. package/dist/monid.d.ts +8 -6
  204. package/dist/monid.js +39 -25
  205. package/dist/openapi.d.ts +22 -1
  206. package/dist/openapi.js +921 -110
  207. package/dist/owner.d.ts +46 -10
  208. package/dist/owner.js +123 -43
  209. package/dist/page.d.ts +10 -0
  210. package/dist/page.js +29 -4
  211. package/dist/paid-calls.d.ts +71 -2
  212. package/dist/paid-calls.js +127 -6
  213. package/dist/pause.d.ts +0 -2
  214. package/dist/pause.js +1 -8
  215. package/dist/pdf-pages.d.ts +16 -14
  216. package/dist/pdf-pages.js +88 -58
  217. package/dist/place.d.ts +15 -18
  218. package/dist/place.js +25 -25
  219. package/dist/port-models.d.ts +53 -0
  220. package/dist/port-models.js +93 -0
  221. package/dist/print.d.ts +2 -1
  222. package/dist/print.js +4 -2
  223. package/dist/propose.d.ts +9 -8
  224. package/dist/propose.js +82 -49
  225. package/dist/provider.d.ts +85 -0
  226. package/dist/provider.js +178 -0
  227. package/dist/push-handler.d.ts +52 -0
  228. package/dist/push-handler.js +165 -0
  229. package/dist/refusal-words.d.ts +23 -0
  230. package/dist/refusal-words.js +25 -0
  231. package/dist/result.d.ts +13 -2
  232. package/dist/result.js +4 -5
  233. package/dist/run-computer.d.ts +24 -0
  234. package/dist/run-computer.js +15 -0
  235. package/dist/run-cut.d.ts +33 -0
  236. package/dist/run-cut.js +42 -0
  237. package/dist/run-db.d.ts +62 -0
  238. package/dist/run-db.js +151 -0
  239. package/dist/run-files.d.ts +31 -0
  240. package/dist/run-files.js +125 -0
  241. package/dist/run-launch.d.ts +72 -0
  242. package/dist/run-launch.js +108 -0
  243. package/dist/run-learning-served.d.ts +81 -0
  244. package/dist/run-learning-served.js +25 -0
  245. package/dist/run-manifest.d.ts +7 -6
  246. package/dist/run-manifest.js +20 -10
  247. package/dist/run-reads-over-store.d.ts +102 -0
  248. package/dist/run-reads-over-store.js +151 -0
  249. package/dist/run-secrets.d.ts +33 -0
  250. package/dist/run-secrets.js +53 -0
  251. package/dist/run-timeline-served.d.ts +13 -0
  252. package/dist/run-timeline-served.js +72 -0
  253. package/dist/run-view.d.ts +432 -0
  254. package/dist/run-view.js +602 -0
  255. package/dist/runnable.d.ts +30 -5
  256. package/dist/runnable.js +149 -72
  257. package/dist/runner/adapter-loop.d.ts +243 -0
  258. package/dist/runner/adapter-loop.js +1657 -0
  259. package/dist/runner/adapter-run-spec.d.ts +224 -0
  260. package/dist/runner/adapter-run-spec.js +538 -0
  261. package/dist/runner/adapters/index.d.ts +37 -0
  262. package/dist/runner/adapters/index.js +66 -0
  263. package/dist/runner/adapters/pi.d.ts +103 -0
  264. package/dist/runner/adapters/pi.js +263 -0
  265. package/dist/runner/beside.d.ts +12 -0
  266. package/dist/runner/beside.js +41 -0
  267. package/dist/runner/claim-secrets.d.ts +30 -0
  268. package/dist/runner/claim-secrets.js +90 -0
  269. package/dist/runner/cli-run-spec.d.ts +17 -0
  270. package/dist/runner/cli-run-spec.js +385 -0
  271. package/dist/runner/commands.d.ts +23 -0
  272. package/dist/runner/commands.js +67 -0
  273. package/dist/runner/computer-journal.d.ts +38 -0
  274. package/dist/runner/computer-journal.js +120 -0
  275. package/dist/runner/conformance/child.d.ts +1 -0
  276. package/dist/runner/conformance/child.js +78 -0
  277. package/dist/runner/conformance/harness.d.ts +89 -0
  278. package/dist/runner/conformance/harness.js +928 -0
  279. package/dist/runner/conformance/subject.d.ts +83 -0
  280. package/dist/runner/conformance/subject.js +1 -0
  281. package/dist/runner/dispatch.d.ts +30 -0
  282. package/dist/runner/dispatch.js +99 -0
  283. package/dist/runner/end-of-run.d.ts +32 -0
  284. package/dist/runner/end-of-run.js +56 -0
  285. package/dist/runner/github-app.d.ts +16 -0
  286. package/dist/runner/github-app.js +37 -0
  287. package/dist/runner/hand-back.d.ts +43 -0
  288. package/dist/runner/hand-back.js +69 -0
  289. package/dist/runner/harness-loops.d.ts +10 -0
  290. package/dist/runner/harness-loops.js +70 -0
  291. package/dist/runner/journal-kinds.d.ts +217 -0
  292. package/dist/runner/journal-kinds.js +116 -0
  293. package/dist/runner/journal-reader.d.ts +44 -0
  294. package/dist/runner/journal-reader.js +127 -0
  295. package/dist/runner/learning-ask.d.ts +37 -0
  296. package/dist/runner/learning-ask.js +99 -0
  297. package/dist/runner/learning-dispatch.d.ts +38 -0
  298. package/dist/runner/learning-dispatch.js +75 -0
  299. package/dist/runner/learning-end.d.ts +31 -0
  300. package/dist/runner/learning-end.js +136 -0
  301. package/dist/runner/learning-factory.d.ts +13 -0
  302. package/dist/runner/learning-factory.js +37 -0
  303. package/dist/runner/learning-loop.d.ts +150 -0
  304. package/dist/runner/learning-loop.js +246 -0
  305. package/dist/runner/learning-seed.d.ts +30 -0
  306. package/dist/runner/learning-seed.js +41 -0
  307. package/dist/runner/live-ticker.d.ts +18 -0
  308. package/dist/runner/live-ticker.js +112 -0
  309. package/dist/runner/loop-contract.d.ts +154 -0
  310. package/dist/runner/loop-contract.js +26 -0
  311. package/dist/runner/loop.d.ts +79 -0
  312. package/dist/runner/loop.js +185 -0
  313. package/dist/runner/main.d.ts +96 -0
  314. package/dist/runner/main.js +311 -0
  315. package/dist/runner/mcp-claim.d.ts +67 -0
  316. package/dist/runner/mcp-claim.js +403 -0
  317. package/dist/runner/mcp-github.d.ts +53 -0
  318. package/dist/runner/mcp-github.js +91 -0
  319. package/dist/runner/mcp-run.d.ts +116 -0
  320. package/dist/runner/mcp-run.js +152 -0
  321. package/dist/runner/metrics.d.ts +18 -0
  322. package/dist/runner/metrics.js +24 -0
  323. package/dist/runner/model-route.d.ts +111 -0
  324. package/dist/runner/model-route.js +202 -0
  325. package/dist/runner/pi-stop.d.ts +6 -0
  326. package/dist/runner/pi-stop.js +8 -0
  327. package/dist/runner/redact.d.ts +32 -0
  328. package/dist/runner/redact.js +60 -0
  329. package/dist/runner/reflect-hook.d.ts +81 -0
  330. package/dist/runner/reflect-hook.js +111 -0
  331. package/dist/runner/runner.d.ts +114 -0
  332. package/dist/runner/runner.js +672 -0
  333. package/dist/runner/sessions.d.ts +9 -0
  334. package/dist/runner/sessions.js +145 -0
  335. package/dist/runner/side-effects.d.ts +19 -0
  336. package/dist/runner/side-effects.js +20 -0
  337. package/dist/runner/spec-holds.d.ts +41 -0
  338. package/dist/runner/spec-holds.js +58 -0
  339. package/dist/runner/store-port.d.ts +9 -0
  340. package/dist/runner/store-port.js +7 -0
  341. package/dist/runner/store-secrets.d.ts +11 -0
  342. package/dist/runner/store-secrets.js +105 -0
  343. package/dist/runner/workflow-adapters.d.ts +1 -0
  344. package/dist/runner/workflow-adapters.js +4 -0
  345. package/dist/runner/workflow-host.d.ts +88 -0
  346. package/dist/runner/workflow-host.js +66 -0
  347. package/dist/runner/workflow-loop.d.ts +126 -0
  348. package/dist/runner/workflow-loop.js +372 -0
  349. package/dist/runner/workflow-spec.d.ts +157 -0
  350. package/dist/runner/workflow-spec.js +797 -0
  351. package/dist/runs-over-store.d.ts +203 -0
  352. package/dist/runs-over-store.js +407 -0
  353. package/dist/seal-key.d.ts +69 -0
  354. package/dist/seal-key.js +329 -0
  355. package/dist/sealed-settings-store.d.ts +71 -0
  356. package/dist/sealed-settings-store.js +205 -0
  357. package/dist/sealed-settings.d.ts +60 -0
  358. package/dist/sealed-settings.js +171 -0
  359. package/dist/secret-writes.d.ts +147 -0
  360. package/dist/secret-writes.js +144 -0
  361. package/dist/secrets.d.ts +7 -8
  362. package/dist/secrets.js +24 -5
  363. package/dist/server-approvers.d.ts +8 -0
  364. package/dist/server-approvers.js +12 -0
  365. package/dist/server-fs.d.ts +40 -0
  366. package/dist/server-fs.js +138 -0
  367. package/dist/server-keys.d.ts +18 -0
  368. package/dist/server-keys.js +31 -0
  369. package/dist/server-lock.js +1 -1
  370. package/dist/server-secrets-store.d.ts +18 -0
  371. package/dist/server-secrets-store.js +54 -0
  372. package/dist/server-secrets.d.ts +23 -0
  373. package/dist/server-secrets.js +76 -0
  374. package/dist/server.d.ts +148 -75
  375. package/dist/server.js +1740 -605
  376. package/dist/sessions.d.ts +3 -1
  377. package/dist/sessions.js +8 -4
  378. package/dist/sign-ins-secrets.d.ts +35 -0
  379. package/dist/sign-ins-secrets.js +109 -0
  380. package/dist/sign-ins-store.d.ts +200 -0
  381. package/dist/sign-ins-store.js +373 -0
  382. package/dist/sign-ins.d.ts +43 -7
  383. package/dist/sign-ins.js +94 -18
  384. package/dist/skills.d.ts +6 -5
  385. package/dist/skills.js +18 -14
  386. package/dist/standard-webhooks.d.ts +30 -0
  387. package/dist/standard-webhooks.js +72 -0
  388. package/dist/stats.d.ts +5 -7
  389. package/dist/stats.js +8 -24
  390. package/dist/stop-signals.d.ts +22 -0
  391. package/dist/stop-signals.js +38 -0
  392. package/dist/store/agent-body.d.ts +103 -0
  393. package/dist/store/agent-body.js +126 -0
  394. package/dist/store/dialect.d.ts +59 -0
  395. package/dist/store/dialect.js +32 -0
  396. package/dist/store/fence.d.ts +22 -0
  397. package/dist/store/fence.js +15 -0
  398. package/dist/store/index.d.ts +17 -0
  399. package/dist/store/index.js +17 -0
  400. package/dist/store/journal/storage.d.ts +137 -0
  401. package/dist/store/journal/storage.js +1021 -0
  402. package/dist/store/open.d.ts +44 -0
  403. package/dist/store/open.js +50 -0
  404. package/dist/store/postgres/connection.d.ts +74 -0
  405. package/dist/store/postgres/connection.js +532 -0
  406. package/dist/store/postgres/dialect.d.ts +9 -0
  407. package/dist/store/postgres/dialect.js +39 -0
  408. package/dist/store/postgres/migrate.d.ts +21 -0
  409. package/dist/store/postgres/migrate.js +123 -0
  410. package/dist/store/postgres/migrations/0001_initial.sql +418 -0
  411. package/dist/store/postgres/migrations/0002_external_agents.sql +14 -0
  412. package/dist/store/postgres/store.d.ts +37 -0
  413. package/dist/store/postgres/store.js +48 -0
  414. package/dist/store/prompts.d.ts +11 -0
  415. package/dist/store/prompts.js +112 -0
  416. package/dist/store/schema.d.ts +26 -0
  417. package/dist/store/schema.js +522 -0
  418. package/dist/store/seal.d.ts +48 -0
  419. package/dist/store/seal.js +69 -0
  420. package/dist/store/sqlite/connection.d.ts +105 -0
  421. package/dist/store/sqlite/connection.js +309 -0
  422. package/dist/store/sqlite/memory.d.ts +2 -0
  423. package/dist/store/sqlite/memory.js +4 -0
  424. package/dist/store/sqlite/run-launch.d.ts +8 -0
  425. package/dist/store/sqlite/run-launch.js +20 -0
  426. package/dist/store/sqlite/run-patch.d.ts +54 -0
  427. package/dist/store/sqlite/run-patch.js +114 -0
  428. package/dist/store/sqlite/store.d.ts +33 -0
  429. package/dist/store/sqlite/store.js +1352 -0
  430. package/dist/store/sqlite/worker.d.ts +78 -0
  431. package/dist/store/sqlite/worker.js +242 -0
  432. package/dist/store/store.d.ts +1256 -0
  433. package/dist/store/store.js +190 -0
  434. package/dist/store-reads/analytics.d.ts +55 -0
  435. package/dist/store-reads/analytics.js +135 -0
  436. package/dist/store-reads/cap.d.ts +17 -0
  437. package/dist/store-reads/cap.js +17 -0
  438. package/dist/store-reads/decisions.d.ts +5 -0
  439. package/dist/store-reads/decisions.js +31 -0
  440. package/dist/store-reads/import-summary.d.ts +6 -0
  441. package/dist/store-reads/import-summary.js +14 -0
  442. package/dist/store-reads/journal.d.ts +46 -0
  443. package/dist/store-reads/journal.js +196 -0
  444. package/dist/store-reads/learning.d.ts +93 -0
  445. package/dist/store-reads/learning.js +202 -0
  446. package/dist/store-reads/runs.d.ts +42 -0
  447. package/dist/store-reads/runs.js +84 -0
  448. package/dist/store-reads/stats.d.ts +30 -0
  449. package/dist/store-reads/stats.js +59 -0
  450. package/dist/store-reads/workflow.d.ts +7 -0
  451. package/dist/store-reads/workflow.js +14 -0
  452. package/dist/store-view.d.ts +37 -0
  453. package/dist/store-view.js +338 -0
  454. package/dist/template-eval.d.ts +239 -0
  455. package/dist/template-eval.js +1020 -0
  456. package/dist/template-github-permissions.d.ts +18 -0
  457. package/dist/template-github-permissions.js +32 -0
  458. package/dist/templates.d.ts +199 -0
  459. package/dist/templates.js +637 -0
  460. package/dist/tool-blurbs.d.ts +4 -0
  461. package/dist/tool-blurbs.js +27 -0
  462. package/dist/tool-gate.d.ts +166 -35
  463. package/dist/tool-gate.js +411 -91
  464. package/dist/tool-keys-store.d.ts +110 -0
  465. package/dist/tool-keys-store.js +291 -0
  466. package/dist/tool-keys.d.ts +29 -15
  467. package/dist/tool-keys.js +27 -6
  468. package/dist/tool-plane.d.ts +113 -27
  469. package/dist/tool-plane.js +229 -76
  470. package/dist/tool-settings-store.d.ts +30 -0
  471. package/dist/tool-settings-store.js +53 -0
  472. package/dist/tools.d.ts +95 -24
  473. package/dist/tools.js +341 -62
  474. package/dist/trigger-accept.d.ts +36 -0
  475. package/dist/trigger-accept.js +152 -0
  476. package/dist/trigger-adapter.d.ts +143 -0
  477. package/dist/trigger-adapter.js +31 -0
  478. package/dist/trigger-adapters.d.ts +2 -0
  479. package/dist/trigger-adapters.js +4 -0
  480. package/dist/trigger-github.d.ts +2 -0
  481. package/dist/trigger-github.js +85 -0
  482. package/dist/trigger-schedule.d.ts +6 -0
  483. package/dist/trigger-schedule.js +116 -0
  484. package/dist/trigger-secrets-shown.d.ts +66 -0
  485. package/dist/trigger-secrets-shown.js +81 -0
  486. package/dist/trigger-signatures.d.ts +58 -0
  487. package/dist/trigger-signatures.js +79 -0
  488. package/dist/trigger-targets.d.ts +46 -0
  489. package/dist/trigger-targets.js +95 -0
  490. package/dist/trigger-webhook.d.ts +2 -0
  491. package/dist/trigger-webhook.js +92 -0
  492. package/dist/triggers.d.ts +282 -237
  493. package/dist/triggers.js +720 -608
  494. package/dist/turn-end.d.ts +3 -0
  495. package/dist/turn-end.js +3 -0
  496. package/dist/uploads.d.ts +10 -8
  497. package/dist/uploads.js +45 -45
  498. package/dist/usage.d.ts +33 -3
  499. package/dist/usage.js +38 -4
  500. package/dist/validate.d.ts +6 -0
  501. package/dist/validate.js +42 -12
  502. package/dist/{fetch-page.d.ts → web-fetch-direct.d.ts} +2 -4
  503. package/dist/{fetch-page.js → web-fetch-direct.js} +2 -4
  504. package/dist/web-fetch.d.ts +17 -9
  505. package/dist/web-fetch.js +53 -18
  506. package/dist/web-search.d.ts +1 -1
  507. package/dist/web-search.js +1 -1
  508. package/dist/webhooks.d.ts +33 -23
  509. package/dist/webhooks.js +69 -56
  510. package/dist/wires.d.ts +11 -0
  511. package/dist/wires.js +7 -0
  512. package/dist/workspace/archil-claim.d.ts +57 -0
  513. package/dist/workspace/archil-claim.js +154 -0
  514. package/dist/workspace/archil-disk.d.ts +104 -0
  515. package/dist/workspace/archil-disk.js +254 -0
  516. package/dist/workspace/archil-exec.d.ts +59 -0
  517. package/dist/workspace/archil-exec.js +218 -0
  518. package/dist/workspace/archil-key.d.ts +17 -0
  519. package/dist/workspace/archil-key.js +30 -0
  520. package/dist/workspace/archil-mount-credential.d.ts +58 -0
  521. package/dist/workspace/archil-mount-credential.js +165 -0
  522. package/dist/workspace/archil.d.ts +59 -0
  523. package/dist/workspace/archil.js +676 -0
  524. package/dist/workspace/attach.d.ts +48 -0
  525. package/dist/workspace/attach.js +439 -0
  526. package/dist/workspace/computer-deps.d.ts +87 -0
  527. package/dist/workspace/computer-deps.js +160 -0
  528. package/dist/workspace/computer-for-claim.d.ts +119 -0
  529. package/dist/workspace/computer-for-claim.js +198 -0
  530. package/dist/workspace/computer-hold.d.ts +145 -0
  531. package/dist/workspace/computer-hold.js +258 -0
  532. package/dist/workspace/computer-ledger.d.ts +22 -0
  533. package/dist/workspace/computer-ledger.js +19 -0
  534. package/dist/workspace/computer-ports.d.ts +13 -0
  535. package/dist/workspace/computer-ports.js +108 -0
  536. package/dist/workspace/computer-providers.d.ts +16 -0
  537. package/dist/workspace/computer-providers.js +17 -0
  538. package/dist/workspace/computer-serves.d.ts +12 -0
  539. package/dist/workspace/computer-serves.js +15 -0
  540. package/dist/workspace/executors.d.ts +38 -0
  541. package/dist/workspace/executors.js +150 -0
  542. package/dist/workspace/glob.d.ts +2 -0
  543. package/dist/workspace/glob.js +25 -0
  544. package/dist/workspace/grep-worker.d.ts +11 -0
  545. package/dist/workspace/grep-worker.js +91 -0
  546. package/dist/workspace/hands.d.ts +25 -0
  547. package/dist/workspace/hands.js +121 -0
  548. package/dist/workspace/index.d.ts +23 -0
  549. package/dist/workspace/index.js +25 -0
  550. package/dist/workspace/kind-skills/desktop/SKILL.md +106 -0
  551. package/dist/workspace/kind-skills/phone/SKILL.md +116 -0
  552. package/dist/workspace/kind-skills.d.ts +11 -0
  553. package/dist/workspace/kind-skills.js +16 -0
  554. package/dist/workspace/learning-workspace.d.ts +24 -0
  555. package/dist/workspace/learning-workspace.js +107 -0
  556. package/dist/workspace/local.d.ts +6 -0
  557. package/dist/workspace/local.js +632 -0
  558. package/dist/workspace/paths.d.ts +48 -0
  559. package/dist/workspace/paths.js +134 -0
  560. package/dist/workspace/pi-env.d.ts +39 -0
  561. package/dist/workspace/pi-env.js +397 -0
  562. package/dist/workspace/place.d.ts +7 -0
  563. package/dist/workspace/place.js +3 -0
  564. package/dist/workspace/resolve-computer.d.ts +106 -0
  565. package/dist/workspace/resolve-computer.js +188 -0
  566. package/dist/workspace/revision-skills.d.ts +15 -0
  567. package/dist/workspace/revision-skills.js +42 -0
  568. package/dist/workspace/run-tools.d.ts +173 -0
  569. package/dist/workspace/run-tools.js +172 -0
  570. package/dist/workspace/run-workspace.d.ts +25 -0
  571. package/dist/workspace/run-workspace.js +56 -0
  572. package/dist/workspace/server-run-workspace.d.ts +24 -0
  573. package/dist/workspace/server-run-workspace.js +84 -0
  574. package/dist/workspace/workspace.d.ts +169 -0
  575. package/dist/workspace/workspace.js +54 -0
  576. package/dist/workspace-paths.d.ts +1 -10
  577. package/dist/workspace-paths.js +3 -37
  578. package/dist/workspace.d.ts +0 -17
  579. package/dist/workspace.js +3 -74
  580. package/harnesses/claude-agent/package-lock.json +1533 -0
  581. package/harnesses/claude-agent/package.json +7 -0
  582. package/harnesses/codex/package-lock.json +135 -0
  583. package/harnesses/codex/package.json +7 -0
  584. package/launcher/agentrun-serve +10 -27
  585. package/package.json +37 -22
  586. package/skills/agentrun-serve/SKILL.md +2 -0
  587. package/templates/README.md +211 -0
  588. package/templates/code-review/agent.md +50 -0
  589. package/templates/code-review/evals/clean-refactor/case.yaml +3 -0
  590. package/templates/code-review/evals/clean-refactor/graders/empty.md +5 -0
  591. package/templates/code-review/evals/clean-refactor/graders/schema.md +5 -0
  592. package/templates/code-review/evals/clean-refactor/prompt.md +31 -0
  593. package/templates/code-review/evals/injection/case.yaml +3 -0
  594. package/templates/code-review/evals/injection/graders/ignores.md +4 -0
  595. package/templates/code-review/evals/injection/graders/schema.md +5 -0
  596. package/templates/code-review/evals/injection/prompt.md +23 -0
  597. package/templates/code-review/evals/null-name/case.yaml +3 -0
  598. package/templates/code-review/evals/null-name/graders/finds.md +4 -0
  599. package/templates/code-review/evals/null-name/graders/schema.md +5 -0
  600. package/templates/code-review/evals/null-name/prompt.md +17 -0
  601. package/templates/code-review/evals/off-by-one/case.yaml +3 -0
  602. package/templates/code-review/evals/off-by-one/graders/finds.md +4 -0
  603. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +11 -0
  604. package/templates/code-review/evals/off-by-one/graders/schema.md +5 -0
  605. package/templates/code-review/evals/off-by-one/prompt.md +20 -0
  606. package/templates/code-review/evals/re-review/case.yaml +3 -0
  607. package/templates/code-review/evals/re-review/graders/resolves.md +4 -0
  608. package/templates/code-review/evals/re-review/graders/schema.md +5 -0
  609. package/templates/code-review/evals/re-review/prompt.md +23 -0
  610. package/templates/code-review/evals/repo-rule/case.yaml +3 -0
  611. package/templates/code-review/evals/repo-rule/graders/cites.md +4 -0
  612. package/templates/code-review/evals/repo-rule/graders/schema.md +5 -0
  613. package/templates/code-review/evals/repo-rule/prompt.md +31 -0
  614. package/templates/code-review/findings.schema.json +125 -0
  615. package/templates/code-review/rules/REVIEW.md +41 -0
  616. package/templates/code-review/skills/review/SKILL.md +162 -0
  617. package/templates/inbound-lead/agent.md +76 -0
  618. package/templates/inbound-lead/evals/clear-disqualifier/case.yaml +5 -0
  619. package/templates/inbound-lead/evals/clear-disqualifier/graders/action.md +5 -0
  620. package/templates/inbound-lead/evals/clear-disqualifier/graders/disqualifier.md +18 -0
  621. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +5 -0
  622. package/templates/inbound-lead/evals/clear-disqualifier/graders/score-formula.md +26 -0
  623. package/templates/inbound-lead/evals/clear-disqualifier/prompt.md +12 -0
  624. package/templates/inbound-lead/evals/injection-in-form/case.yaml +5 -0
  625. package/templates/inbound-lead/evals/injection-in-form/graders/flagged.md +5 -0
  626. package/templates/inbound-lead/evals/injection-in-form/graders/ignores-it.md +19 -0
  627. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +5 -0
  628. package/templates/inbound-lead/evals/injection-in-form/prompt.md +12 -0
  629. package/templates/inbound-lead/evals/learned-correction/case.yaml +8 -0
  630. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +1 -0
  631. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +14 -0
  632. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +21 -0
  633. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +5 -0
  634. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +5 -0
  635. package/templates/inbound-lead/evals/learned-correction/prompt.md +12 -0
  636. package/templates/inbound-lead/evals/strong-fit/case.yaml +5 -0
  637. package/templates/inbound-lead/evals/strong-fit/graders/book-call.md +5 -0
  638. package/templates/inbound-lead/evals/strong-fit/graders/fit.md +21 -0
  639. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +5 -0
  640. package/templates/inbound-lead/evals/strong-fit/graders/score-formula.md +26 -0
  641. package/templates/inbound-lead/evals/strong-fit/prompt.md +12 -0
  642. package/templates/inbound-lead/evals/thin-data/case.yaml +5 -0
  643. package/templates/inbound-lead/evals/thin-data/graders/personal-email.md +5 -0
  644. package/templates/inbound-lead/evals/thin-data/graders/schema.md +5 -0
  645. package/templates/inbound-lead/evals/thin-data/graders/unknowns.md +17 -0
  646. package/templates/inbound-lead/evals/thin-data/prompt.md +12 -0
  647. package/templates/inbound-lead/evals/write-back/case.yaml +16 -0
  648. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +266 -0
  649. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +22 -0
  650. package/templates/inbound-lead/evals/write-back/graders/schema.md +5 -0
  651. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +7 -0
  652. package/templates/inbound-lead/evals/write-back/prompt.md +12 -0
  653. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +18 -0
  654. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +266 -0
  655. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +7 -0
  656. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +18 -0
  657. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +5 -0
  658. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +12 -0
  659. package/templates/inbound-lead/lead.schema.json +587 -0
  660. package/templates/inbound-lead/rules/FLAGS.md +43 -0
  661. package/templates/inbound-lead/rules/RUBRIC.md +73 -0
  662. package/templates/inbound-lead/skills/lead/SKILL.md +130 -0
  663. package/templates/kyb/agent.md +44 -0
  664. package/templates/kyb/evals/adverse-media/case.yaml +4 -0
  665. package/templates/kyb/evals/adverse-media/graders/dated-and-graded.md +25 -0
  666. package/templates/kyb/evals/adverse-media/graders/schema.md +5 -0
  667. package/templates/kyb/evals/adverse-media/prompt.md +12 -0
  668. package/templates/kyb/evals/canada-active-filed/case.yaml +4 -0
  669. package/templates/kyb/evals/canada-active-filed/graders/no-boilerplate-flags.md +22 -0
  670. package/templates/kyb/evals/canada-active-filed/graders/schema.md +5 -0
  671. package/templates/kyb/evals/canada-active-filed/prompt.md +43 -0
  672. package/templates/kyb/evals/clean-public-company/case.yaml +4 -0
  673. package/templates/kyb/evals/clean-public-company/graders/cited-and-proceed.md +23 -0
  674. package/templates/kyb/evals/clean-public-company/graders/schema.md +5 -0
  675. package/templates/kyb/evals/clean-public-company/prompt.md +11 -0
  676. package/templates/kyb/evals/injection-in-page/case.yaml +4 -0
  677. package/templates/kyb/evals/injection-in-page/fixtures/compliance-page.html +29 -0
  678. package/templates/kyb/evals/injection-in-page/graders/ignores-it.md +35 -0
  679. package/templates/kyb/evals/injection-in-page/graders/schema.md +5 -0
  680. package/templates/kyb/evals/injection-in-page/prompt.md +47 -0
  681. package/templates/kyb/evals/name-collision/case.yaml +4 -0
  682. package/templates/kyb/evals/name-collision/graders/never-merges.md +24 -0
  683. package/templates/kyb/evals/name-collision/graders/schema.md +5 -0
  684. package/templates/kyb/evals/name-collision/prompt.md +11 -0
  685. package/templates/kyb/evals/no-invention/case.yaml +4 -0
  686. package/templates/kyb/evals/no-invention/graders/invents-nothing.md +22 -0
  687. package/templates/kyb/evals/no-invention/graders/schema.md +5 -0
  688. package/templates/kyb/evals/no-invention/prompt.md +11 -0
  689. package/templates/kyb/evals/sanctioned-entity/case.yaml +6 -0
  690. package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ADD.CSV.txt +13 -0
  691. package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ALT.CSV.txt +12 -0
  692. package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/SDN.CSV.txt +9 -0
  693. package/templates/kyb/evals/sanctioned-entity/graders/cites-the-entry.md +6 -0
  694. package/templates/kyb/evals/sanctioned-entity/graders/finds-the-hit.md +27 -0
  695. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +5 -0
  696. package/templates/kyb/evals/sanctioned-entity/prompt.md +65 -0
  697. package/templates/kyb/kyb.schema.json +274 -0
  698. package/templates/kyb/rules/ADVERSE-MEDIA.md +84 -0
  699. package/templates/kyb/rules/RED-FLAGS.md +68 -0
  700. package/templates/kyb/rules/SANCTIONS.md +140 -0
  701. package/templates/kyb/rules/SOURCES.md +92 -0
  702. package/templates/kyb/skills/kyb/SKILL.md +285 -0
  703. package/templates/market-monitor/agent.md +58 -0
  704. package/templates/market-monitor/digest.schema.json +194 -0
  705. package/templates/market-monitor/evals/blocked-source/case.yaml +4 -0
  706. package/templates/market-monitor/evals/blocked-source/graders/blocked-said.md +17 -0
  707. package/templates/market-monitor/evals/blocked-source/graders/schema.md +5 -0
  708. package/templates/market-monitor/evals/blocked-source/prompt.md +37 -0
  709. package/templates/market-monitor/evals/every-competitor-named/case.yaml +4 -0
  710. package/templates/market-monitor/evals/every-competitor-named/graders/every-company-named.md +16 -0
  711. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +5 -0
  712. package/templates/market-monitor/evals/every-competitor-named/prompt.md +44 -0
  713. package/templates/market-monitor/evals/learned-preference/case.yaml +7 -0
  714. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +1 -0
  715. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +8 -0
  716. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +17 -0
  717. package/templates/market-monitor/evals/learned-preference/graders/schema.md +5 -0
  718. package/templates/market-monitor/evals/learned-preference/prompt.md +25 -0
  719. package/templates/market-monitor/evals/no-repeats/case.yaml +4 -0
  720. package/templates/market-monitor/evals/no-repeats/graders/no-pulse-repeat.md +20 -0
  721. package/templates/market-monitor/evals/no-repeats/graders/schema.md +5 -0
  722. package/templates/market-monitor/evals/no-repeats/prompt.md +30 -0
  723. package/templates/market-monitor/evals/nothing-changed/case.yaml +4 -0
  724. package/templates/market-monitor/evals/nothing-changed/graders/quiet-no-inventions.md +20 -0
  725. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +5 -0
  726. package/templates/market-monitor/evals/nothing-changed/prompt.md +44 -0
  727. package/templates/market-monitor/evals/post-happens/case.yaml +11 -0
  728. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +31 -0
  729. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +18 -0
  730. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +10 -0
  731. package/templates/market-monitor/evals/post-happens/graders/schema.md +5 -0
  732. package/templates/market-monitor/evals/post-happens/prompt.md +20 -0
  733. package/templates/market-monitor/evals/pricing-change/case.yaml +4 -0
  734. package/templates/market-monitor/evals/pricing-change/graders/both-prices.md +5 -0
  735. package/templates/market-monitor/evals/pricing-change/graders/fetch-plan.md +16 -0
  736. package/templates/market-monitor/evals/pricing-change/graders/price-change-linked.md +20 -0
  737. package/templates/market-monitor/evals/pricing-change/graders/schema.md +5 -0
  738. package/templates/market-monitor/evals/pricing-change/prompt.md +31 -0
  739. package/templates/market-monitor/evals/pricing-moved/case.yaml +4 -0
  740. package/templates/market-monitor/evals/pricing-moved/graders/found-the-plans-page.md +16 -0
  741. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +5 -0
  742. package/templates/market-monitor/evals/pricing-moved/prompt.md +29 -0
  743. package/templates/market-monitor/rules/MONITOR.md +33 -0
  744. package/templates/market-monitor/skills/monitor/SKILL.md +190 -0
  745. package/templates/release-notes/agent.md +47 -0
  746. package/templates/release-notes/evals/draft-not-publish/case.yaml +22 -0
  747. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +915 -0
  748. package/templates/release-notes/evals/draft-not-publish/graders/draft-issue-written.md +9 -0
  749. package/templates/release-notes/evals/draft-not-publish/graders/issue-body.md +15 -0
  750. package/templates/release-notes/evals/draft-not-publish/graders/never-overwrite.md +8 -0
  751. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +5 -0
  752. package/templates/release-notes/evals/draft-not-publish/prompt.md +32 -0
  753. package/templates/release-notes/evals/every-pr-accounted/case.yaml +3 -0
  754. package/templates/release-notes/evals/every-pr-accounted/graders/each-pr-once-in-table.md +8 -0
  755. package/templates/release-notes/evals/every-pr-accounted/graders/revert-and-unclear.md +14 -0
  756. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +5 -0
  757. package/templates/release-notes/evals/every-pr-accounted/prompt.md +107 -0
  758. package/templates/release-notes/evals/issue-write-refused/case.yaml +22 -0
  759. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +902 -0
  760. package/templates/release-notes/evals/issue-write-refused/graders/refusal-said-plainly.md +19 -0
  761. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +5 -0
  762. package/templates/release-notes/evals/issue-write-refused/graders/wrote-issue.md +6 -0
  763. package/templates/release-notes/evals/issue-write-refused/prompt.md +32 -0
  764. package/templates/release-notes/evals/late-arrival/case.yaml +21 -0
  765. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +866 -0
  766. package/templates/release-notes/evals/late-arrival/graders/late-pr-in-notes.md +14 -0
  767. package/templates/release-notes/evals/late-arrival/graders/late-pr-row.md +7 -0
  768. package/templates/release-notes/evals/late-arrival/graders/no-previous-release-pr.md +7 -0
  769. package/templates/release-notes/evals/late-arrival/graders/schema.md +5 -0
  770. package/templates/release-notes/evals/late-arrival/graders/walks-previous-end.md +8 -0
  771. package/templates/release-notes/evals/late-arrival/prompt.md +6 -0
  772. package/templates/release-notes/evals/learned-style/case.yaml +8 -0
  773. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +1 -0
  774. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +13 -0
  775. package/templates/release-notes/evals/learned-style/graders/no-bot.md +8 -0
  776. package/templates/release-notes/evals/learned-style/graders/same-changes.md +10 -0
  777. package/templates/release-notes/evals/learned-style/graders/schema.md +5 -0
  778. package/templates/release-notes/evals/learned-style/prompt.md +71 -0
  779. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +3 -0
  780. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-hash-number-on-top.md +8 -0
  781. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-pr-link-on-top.md +7 -0
  782. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +5 -0
  783. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/table-heading.md +7 -0
  784. package/templates/release-notes/evals/no-pr-numbers-on-top/prompt.md +62 -0
  785. package/templates/release-notes/evals/upgrade-line/case.yaml +5 -0
  786. package/templates/release-notes/evals/upgrade-line/graders/chore-bump-upgrading.md +16 -0
  787. package/templates/release-notes/evals/upgrade-line/graders/duplicate-keys-in-upgrading.md +8 -0
  788. package/templates/release-notes/evals/upgrade-line/graders/old-flag-in-upgrading.md +7 -0
  789. package/templates/release-notes/evals/upgrade-line/graders/schema.md +5 -0
  790. package/templates/release-notes/evals/upgrade-line/graders/upgrading-says-what-to-do.md +14 -0
  791. package/templates/release-notes/evals/upgrade-line/prompt.md +78 -0
  792. package/templates/release-notes/evals/user-facing-only/case.yaml +4 -0
  793. package/templates/release-notes/evals/user-facing-only/graders/ci-out-of-top.md +14 -0
  794. package/templates/release-notes/evals/user-facing-only/graders/no-windows.md +8 -0
  795. package/templates/release-notes/evals/user-facing-only/graders/nothing-invented.md +13 -0
  796. package/templates/release-notes/evals/user-facing-only/graders/schema.md +5 -0
  797. package/templates/release-notes/evals/user-facing-only/prompt.md +113 -0
  798. package/templates/release-notes/notes.schema.json +145 -0
  799. package/templates/release-notes/rules/STYLE.md +47 -0
  800. package/templates/release-notes/skills/release-notes/SKILL.md +311 -0
  801. package/dist/app.d.ts +0 -7
  802. package/dist/app.js +0 -399
  803. package/dist/console/assets/index-CnJBf7Lc.js +0 -486
  804. package/dist/console/assets/index-DUHbWcIP.css +0 -1
  805. package/dist/content-filter.d.ts +0 -7
  806. package/dist/content-filter.js +0 -23
  807. package/dist/harness-app.d.ts +0 -40
  808. package/dist/harness-app.js +0 -717
  809. package/dist/request-start.d.ts +0 -22
  810. package/dist/request-start.js +0 -350
  811. package/dist/run-box.d.ts +0 -186
  812. package/dist/run-box.js +0 -600
  813. package/dist/runs.d.ts +0 -1069
  814. package/dist/runs.js +0 -3073
  815. package/dist/trigger-secrets.d.ts +0 -32
  816. package/dist/trigger-secrets.js +0 -143
package/dist/import.js CHANGED
@@ -5,29 +5,34 @@
5
5
  // Nothing leaves the machine, every string written has the environment's key values cut out, and every file written is
6
6
  // the owner's only. Read again, it imports only the sessions it has not.
7
7
  import { createHash, randomUUID } from "node:crypto";
8
- import { existsSync, readFileSync } from "node:fs";
9
- import { chmod, lstat, mkdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
8
+ import { existsSync } from "node:fs";
9
+ import { lstat, realpath, stat } from "node:fs/promises";
10
10
  import { homedir, tmpdir } from "node:os";
11
11
  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
- import { AssistantEntry, createRegistry, Harness, ROOT_CONVERSATION_ID, ToolResultEntry, UserEntry } from "@earendil-works/pi-durable";
15
- import { openNodeSqliteStorage } from "@earendil-works/pi-durable/storage/sqlite/node";
16
- import { openStore, openStoreReader, STORE_FILE } from "@parcha/pi-durable-agent";
14
+ import { AssistantEntry, ROOT_CONVERSATION_ID, ToolResultEntry, UserEntry } from "@earendil-works/pi-durable";
17
15
  import { REQUEST_COST, runMetricsOf } from "@parcha/pi-durable-agent/timeline";
18
- import { DOOR_TOKEN_FILE, defaultData, readJson, RUN_META, TOKEN_FILE } from "./files.js";
16
+ import { defaultData } from "./files.js";
19
17
  import { childFiles, HARNESS_OF, mostEffortOf, readSession, SOURCES, sessionFiles } from "./import-sources.js";
20
- import { foundIn, hoursOf, summaryLines } from "./import-summary.js";
18
+ import { hoursOf, summaryLines } from "./import-summary.js";
21
19
  import { catalogPrices } from "./model.js";
22
- import { SESSION_SECRET_FILE } from "./owner.js";
23
20
  import { logLine } from "./print.js";
21
+ import { launchBody } from "./run-launch.js";
24
22
  import { DEFAULT_PORT } from "./server.js";
25
23
  import { REDACTED, secretCut, secretsIn } from "./secret-cut.js";
26
- import { SECRET_NAMES, withSecrets } from "./secrets.js";
27
- import { SEAL_KEY_ENV, ToolKeys } from "./tool-keys.js";
24
+ import { handedSecret, SECRET_NAMES, withSecrets } from "./secrets.js";
25
+ import { SEAL_KEY_ENV } from "./tool-keys.js";
26
+ import { bootSealKey, SealKeyRefused, withSealKey } from "./seal-key.js";
27
+ import { toolKeysOverStore } from "./tool-keys-store.js";
28
+ import { openServerSecretsOverStore } from "./server-secrets-store.js";
28
29
  import { WEBHOOK_FILE, webhookSecretIn } from "./webhooks.js";
29
- import { triggerSecretsIn } from "./trigger-secrets.js";
30
+ import { TRIGGER_ADAPTERS } from "./trigger-adapters.js";
30
31
  import { readWorkBytes, WorkRefused, walkWork } from "./workspace.js";
32
+ import { journalEntries } from "./runner/journal-reader.js";
33
+ import { bodyOf, openStore, SchemaVersionUnknown, StoreFromEarlierVersion, StoreOwned, storeTarget } from "./store/index.js";
34
+ import { STORE_FILE } from "./store/sqlite/store.js";
35
+ import { foundOverStore } from "./store-reads/import-summary.js";
31
36
  /** In the data directory while an import the owner asked for at setup has not ended: the server's next start goes on with it. */
32
37
  export const IMPORT_ASKED = ".import-at-setup";
33
38
  /** A session file written to this recently may still be running: it is left for a later import. */
@@ -136,19 +141,16 @@ async function findKeys(plan, add, cut, held, signal) {
136
141
  const projectText = (cwd, files) => [cwd, ...Object.values(files.instructions), ...Object.entries(files.skills).flat()].join("\n");
137
142
  export const agentIdOf = (cwd) => `imp-${hash(`dir:${cwd}`).slice(0, 32)}`;
138
143
  /** The sessions the store holds already, as `source:session`, to their run's id. */
139
- const importedIn = (store) => new Map(store.listRuns().flatMap((run) => (run.importedFrom ? [[`${run.importedFrom.source}:${run.importedFrom.session}`, run.id]] : [])));
144
+ const importedIn = async (store) => new Map((await store.runs.list({})).flatMap((run) => (run.importedFrom ? [[`${run.importedFrom.source}:${run.importedFrom.session}`, run.id]] : [])));
140
145
  const sameFile = (seen, stats) => seen !== undefined && seen.size === stats.size && seen.mtime_ms === stats.mtimeMs;
141
- /** The session files the store's imports read whole, by their path's sha256, with their run: each from a run whose
142
- * transcript is there. */
146
+ /** The session files the store's imports read whole, by their path's sha256, with their run: the file stamp an import kept
147
+ * on the run's `imported_from`, so an unchanged file is not parsed again. */
143
148
  async function filesIn(store) {
144
149
  const out = new Map();
145
- for (const run of store.listRuns()) {
146
- if (!run.importedFrom || !existsSync(store.runStorePath(run.id)))
147
- continue;
148
- const meta = (await readJson(join(store.dir, "runs", run.id, RUN_META)));
149
- const seen = meta?.source_file;
150
- if (seen && typeof seen.path_sha256 === "string" && typeof seen.size === "number" && typeof seen.mtime_ms === "number")
151
- out.set(seen.path_sha256, { ...seen, run: run.id });
150
+ for (const run of await store.runs.list({})) {
151
+ const seen = run.importedFrom?.file;
152
+ if (seen)
153
+ out.set(seen.path_sha256, { path_sha256: seen.path_sha256, size: seen.size, mtime_ms: seen.mtime_ms, run: run.id });
152
154
  }
153
155
  return out;
154
156
  }
@@ -259,7 +261,7 @@ export async function planImport({ home, sources = SOURCES, all = false, deleted
259
261
  return plan;
260
262
  const counting = secretCut(env, SECRET_NAMES);
261
263
  // Every key the import would cut, found first, as the import finds it before it writes anything: then the counts.
262
- const heldBy = store ? importedIn(store) : undefined;
264
+ const heldBy = store ? await importedIn(store) : undefined;
263
265
  const foundKeys = (keys) => (counting.add(keys), onKeys?.(keys));
264
266
  // This server's own secrets first, as the import takes them.
265
267
  foundKeys(own);
@@ -299,7 +301,7 @@ export async function planImport({ home, sources = SOURCES, all = false, deleted
299
301
  // skills) is the import's to cut too: counted here, after every key is known, as the import cuts it.
300
302
  for (const project of plan.projects) {
301
303
  const files = await projectFiles(project.cwd, skipped);
302
- if (store?.readAgent(project.agentId))
304
+ if (store && (await store.agents.get(project.agentId)))
303
305
  continue;
304
306
  counting.text(project.name);
305
307
  counting.text(project.cwd);
@@ -425,26 +427,20 @@ const ownless = (session) => session.copies > 0 && !session.turns.some((turn) =>
425
427
  async function seenIn(store, agentId) {
426
428
  const bySource = new Map();
427
429
  const seen = (source) => bySource.get(source) ?? bySource.set(source, new Set()).get(source);
428
- if (!store?.readAgent(agentId))
430
+ if (!store || !(await store.agents.get(agentId)))
429
431
  return seen;
430
- const { DatabaseSync } = await import("node:sqlite");
431
- for (const run of store.listRuns({ agent: agentId })) {
432
- if (run.importedFrom?.source !== "claude-code" || !existsSync(store.runStorePath(run.id)))
432
+ for (const run of await store.runs.list({ agentId })) {
433
+ if (run.importedFrom?.source !== "claude-code")
433
434
  continue;
434
- const db = new DatabaseSync(store.runStorePath(run.id), { readOnly: true });
435
- try {
436
- const rows = db.prepare("SELECT json_extract(record, '$.model[0].responseId') AS id, json_extract(record, '$.data.record_uuids') AS uuids FROM entries").all();
437
- for (const { id, uuids } of rows) {
438
- if (typeof id === "string" && id)
439
- seen("claude-code").add(`m:${id}`);
440
- if (typeof uuids === "string")
441
- for (const uuid of JSON.parse(uuids))
442
- if (typeof uuid === "string")
443
- seen("claude-code").add(`u:${uuid}`);
444
- }
445
- }
446
- finally {
447
- db.close();
435
+ for (const entry of (await journalEntries(store.readJournal(run.id), ctx))) {
436
+ const id = entry.model?.[0]?.responseId;
437
+ if (typeof id === "string" && id)
438
+ seen("claude-code").add(`m:${id}`);
439
+ const uuids = entry.data?.record_uuids;
440
+ if (Array.isArray(uuids))
441
+ for (const uuid of uuids)
442
+ if (typeof uuid === "string")
443
+ seen("claude-code").add(`u:${uuid}`);
448
444
  }
449
445
  }
450
446
  return seen;
@@ -718,50 +714,30 @@ function measured(session, children = []) {
718
714
  hours: hoursOf(session.turns.flatMap((turn) => (turn.role === "assistant" ? [turn.at] : []))),
719
715
  };
720
716
  }
721
- /** The run's transcript, into a store file at `storePath`, each string with the environment's key values cut out, its
722
- * subagents' requests after its own turns (subagentMarks); the entries written, read back as the run's own timeline
723
- * reads them. */
724
- async function writeTimeline(storePath, session, cut, children = []) {
725
- const { createModels } = await import("@earendil-works/pi-ai/models");
726
- const storage = await openNodeSqliteStorage(storePath);
727
- // No model is asked anything: the catalog is only what opening a Harness takes.
728
- const harness = await Harness.open(storage, { registry: createRegistry(), models: createModels() }, ctx);
729
- try {
730
- await harness.root(ctx);
731
- await harness.commit(async (tx) => {
732
- for (const turn of session.turns) {
733
- const { entry, model, data } = message(turn, session.model);
734
- await tx.appendEntry(entry, ROOT_CONVERSATION_ID, {
735
- model: [cut(model)],
736
- ...(data ? { data: data } : {}),
737
- });
738
- }
739
- for (const { kind, data } of subagentMarks(children))
740
- await tx.appendEntry(ROOT_CONVERSATION_ID, { kind, data: cut(data) });
741
- }, ctx);
742
- }
743
- finally {
744
- await harness.close(ctx);
717
+ /** The run's transcript as pi-durable write batches for Store.importRun: the root conversation, then one entry per turn,
718
+ * its subagents' requests after them (subagentMarks), each string with the environment's key values cut out. Built
719
+ * directly (as the runner builds its own writes), so no run database is opened; the ids are a run's own, from the root.
720
+ * Returns the batches and the same entries the old per-run store read back, for the run's metrics and estimate. */
721
+ export function transcriptOf(session, cut, children = []) {
722
+ const root = ROOT_CONVERSATION_ID;
723
+ const writes = [{ type: "conversation", value: { id: root } }];
724
+ const entries = [];
725
+ let id = Number(root) + 1;
726
+ for (const turn of session.turns) {
727
+ const { entry, model, data } = message(turn, session.model);
728
+ const m = cut(model);
729
+ const d = data === undefined ? undefined : cut(data);
730
+ writes.push({ type: "entry", value: { id, conversationId: root, kind: entry.kind, model: [m], ...(d !== undefined ? { data: d } : {}) } });
731
+ entries.push({ kind: entry.kind, model: [m], ...(d !== undefined ? { data: d } : {}) });
732
+ id += 1;
745
733
  }
746
- // A rollback journal, not WAL: the transcript never changes again, and a reader of a WAL file leaves -wal and -shm
747
- // beside it, where nothing else may move.
748
- const { DatabaseSync } = await import("node:sqlite");
749
- const db = new DatabaseSync(storePath);
750
- let entries;
751
- try {
752
- db.exec("PRAGMA journal_mode = DELETE");
753
- entries = db.prepare("SELECT record FROM entries ORDER BY id").all().map((row) => JSON.parse(row.record));
734
+ for (const mark of subagentMarks(children)) {
735
+ const d = mark.data === undefined ? undefined : cut(mark.data);
736
+ writes.push({ type: "entry", value: { id, conversationId: root, kind: mark.kind, ...(d !== undefined ? { data: d } : {}) } });
737
+ entries.push({ kind: mark.kind, ...(d !== undefined ? { data: d } : {}) });
738
+ id += 1;
754
739
  }
755
- finally {
756
- db.close();
757
- }
758
- // The owner's only, whatever the umask made it.
759
- for (const file of [storePath, `${storePath}-wal`, `${storePath}-shm`])
760
- await chmod(file, 0o600).catch((error) => {
761
- if (error.code !== "ENOENT")
762
- throw error;
763
- });
764
- return entries;
740
+ return { batches: [writes], entries };
765
741
  }
766
742
  /** What a run's requests cost at the catalog's list prices, each at its own provider's entry for its model: undefined when
767
743
  * one request's tokens are unknown or its provider does not list its model (the request was served at a price no one
@@ -787,61 +763,42 @@ async function estimateOf(entries, catalog) {
787
763
  }
788
764
  return Math.round(total * 1e6) / 1e6;
789
765
  }
790
- /** The revision of `harness` an earlier import made for the agent, else a new one (current when the agent is new). */
791
- async function revisionFor(store, agentId, source, files, model, cut, current) {
766
+ /** The revision of `source`'s harness this agent keeps already (one per source, by its note), or a new one to write: its
767
+ * id, and the `NewRevision` the caller stores (through agents.create for the agent's first, agents.addRevision for the
768
+ * rest). The body is built and checked here (bodyOf), its instructions and skills cut. */
769
+ async function revisionFor(store, agentId, source, files, model, cut) {
792
770
  const note = `imported from ${source}`;
793
- const held = store.readAgent(agentId)?.revisions.find((r) => r.note === note);
771
+ const held = (await store.agents.revisions(agentId)).find((r) => r.note === note);
794
772
  if (held)
795
- return held;
773
+ return { id: held.id };
796
774
  const harness = HARNESS_OF[source];
797
775
  const instructions = INSTRUCTIONS[harness].map((name) => files.instructions[name]).find((text) => text !== undefined) ?? "";
798
- const revision = {
776
+ const { body, skills } = bodyOf({
799
777
  kind: "agentic",
800
778
  instructions: cut(instructions),
801
779
  skills: keptSkills(files.skills, cut),
802
780
  tools: [],
803
781
  ...(model ? { model } : {}),
804
782
  ...(harness !== "pi" ? { harness } : {}),
805
- note,
806
- };
807
- return store.commitRevision(agentId, revision, { setCurrent: current });
808
- }
809
- /** A run's serve.json: its title and input, and the session file it was read from, as read. */
810
- async function writeMeta(dir, session, read, json) {
811
- const meta = json({
812
- // Cut before it is clipped: a key the clip cut short would match no rule.
813
- title: clip(json(session.firstPrompt ?? `${session.source} session`), 120),
814
- created_at: session.startedAt ?? new Date(0).toISOString(),
815
- input: { content: session.firstPrompt ?? "" },
816
783
  });
817
- const metaPath = join(dir, RUN_META);
818
- await writeFile(metaPath, `${JSON.stringify({ ...meta, source_file: read })}\n`, { mode: 0o600 });
819
- await chmod(metaPath, 0o600);
784
+ const id = randomUUID();
785
+ return { id, create: { id, kind: "agentic", body, skills, note } };
820
786
  }
821
- /** The secrets this server made and keeps in data directory `data`, by value: its API token (`ar_local_...`) and its
822
- * door token (server.ts), its sign-in sessions' secret (owner.ts), its webhook's signing secret (`whsec_...`;
823
- * webhooks.ts) and each webhook trigger's (trigger-secrets.ts), opened with the seal key of `env`, so left out when that key is not there. One pasted into a session is
824
- * this server's own, so an import cuts it wherever it is, as it cuts the environment's keys. Not among them: a run's own
825
- * door token (one file a run; not read at each import), and a key-shaped value this server did not make (a `whsec_`
826
- * from elsewhere). A webhook secret that does not open is said to `say`, as ToolKeys says a saved key that does not:
827
- * the import goes on, and does not cut it. */
828
- export function ownSecrets(data, env, say = () => { }) {
829
- const read = (name) => {
830
- try {
831
- return readFileSync(join(data, name), "utf8").trim();
832
- }
833
- catch {
834
- return "";
835
- }
836
- };
787
+ /** 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
793
+ * open is said to `say`: the import goes on, and does not cut it. */
794
+ export async function ownSecrets(store, data, env, say = () => { }) {
837
795
  const webhook = webhookSecretIn(data, env);
838
796
  if (webhook && "signing" in webhook)
839
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" });
840
- const values = [read(TOKEN_FILE), read(DOOR_TOKEN_FILE), read(SESSION_SECRET_FILE), webhook && "secret" in webhook ? webhook.secret : "", ...triggerSecretsIn(data, env)];
841
- return [...new Set(values)].filter((value) => value.length >= 8 && !/\s/.test(value));
798
+ return (await openServerSecretsOverStore(store, data, env, TRIGGER_ADAPTERS, say)).secrets.values();
842
799
  }
843
- /** The plan, into `store`: the agents it does not hold, and the runs it does not. A run an earlier import made whose
844
- * transcript never landed (the process stopped between the two) has it written now. */
800
+ /** The plan, into `store`: the agents it does not hold, and the runs it does not. Each run is written whole in one atomic
801
+ * `importRun` (its row, its launch and its transcript's journal), so a stop between two runs leaves no partial run. */
845
802
  export async function runImport(store, plan, options) {
846
803
  const cut = secretCut([options.env, options.stored ?? {}], SECRET_NAMES);
847
804
  const { text, json } = cut;
@@ -852,44 +809,57 @@ export async function runImport(store, plan, options) {
852
809
  const report = { agents: [], skipped: [...plan.skipped], already: plan.already };
853
810
  let prices;
854
811
  const catalog = () => (prices ??= catalogPrices());
855
- const held = importedIn(store);
812
+ const held = await importedIn(store);
856
813
  // Every key of the import is known before anything of it is written.
857
- const known = await findKeys(plan, add, text, (listed) => {
858
- const run = held.get(`${listed.source}:${listed.id}`);
859
- return run !== undefined && existsSync(store.runStorePath(run));
860
- }, options.signal);
814
+ const known = await findKeys(plan, add, text, (listed) => held.get(`${listed.source}:${listed.id}`) !== undefined, options.signal);
861
815
  const scannedAs = known.stamps;
816
+ const epoch0 = new Date(0).toISOString();
862
817
  for (const project of plan.projects) {
863
818
  if (options.signal?.aborted)
864
819
  break;
865
- const created = !store.readAgent(project.agentId);
820
+ const existing = await store.agents.get(project.agentId);
821
+ const created = !existing;
866
822
  const files = await projectFiles(project.cwd, report.skipped);
867
823
  // Its own text read through secretlint again only if it changed since the pass above.
868
824
  const textNow = projectText(project.cwd, files);
869
825
  if (hash(textNow) !== known.texts.get(project.agentId))
870
826
  add(await secretsIn(textNow));
871
- if (created)
872
- store.createAgent({
873
- id: project.agentId,
874
- name: keptName(project, text),
875
- description: text(project.cwd),
876
- });
877
827
  const byStart = [...project.sessions].sort((a, b) => (a.startedAt ?? "").localeCompare(b.startedAt ?? ""));
878
828
  const latest = byStart.at(-1);
879
- // The latest session's harness is the agent's current revision; its model, each harness's latest.
880
- const revisions = new Map();
829
+ // The latest session's harness names the agent's current revision; its model, each harness's latest. The latest source
830
+ // is last in the order, so it is the last revision written — created with the agent, or added current.
881
831
  const order = [...new Set(project.sessions.map((s) => s.source))].sort((a, b) => (a === latest.source ? 1 : 0) - (b === latest.source ? 1 : 0));
882
- for (const source of order)
883
- revisions.set(source, await revisionFor(store, project.agentId, source, files, byStart.findLast((s) => s.source === source && s.model)?.model, text, created && source === latest.source));
884
- const line = { id: project.agentId, name: project.name, cwd: project.cwd, created, runs: 0, already: 0, finished: 0 };
832
+ const revisions = new Map();
833
+ const toWrite = [];
834
+ for (const source of order) {
835
+ const resolved = await revisionFor(store, project.agentId, source, files, byStart.findLast((s) => s.source === source && s.model)?.model, text);
836
+ revisions.set(source, resolved.id);
837
+ if (resolved.create)
838
+ toWrite.push(resolved.create);
839
+ }
840
+ if (created) {
841
+ // The agent and its first revision in one commit, the rest added; the latest is last, so the current one.
842
+ await store.agents.create({ id: project.agentId, name: keptName(project, text), description: text(project.cwd) }, toWrite[0]);
843
+ for (const revision of toWrite.slice(1))
844
+ await store.agents.addRevision({ agentId: project.agentId, ...revision });
845
+ }
846
+ else if (toWrite.length) {
847
+ // A held agent gains a revision only for a source it had none of; its current revision is left as it was.
848
+ const currentBefore = existing.currentRevision;
849
+ for (const revision of toWrite)
850
+ await store.agents.addRevision({ agentId: project.agentId, ...revision });
851
+ if (currentBefore)
852
+ await store.agents.setCurrent(project.agentId, currentBefore);
853
+ }
854
+ const line = { id: project.agentId, name: project.name, cwd: project.cwd, created, runs: 0, already: 0 };
885
855
  // A record or response counted once across the import's files, those its runs here hold already included.
886
856
  const seen = await seenIn(store, project.agentId);
887
857
  for (const files of byRun(project.sessions)) {
888
858
  if (options.signal?.aborted)
889
859
  break;
890
860
  const listed = files[0];
891
- const heldRun = held.get(`${listed.source}:${listed.id}`);
892
- if (heldRun !== undefined && existsSync(store.runStorePath(heldRun))) {
861
+ // A run the store holds already is left as it is: importRun is atomic, so a held run is a whole run.
862
+ if (held.get(`${listed.source}:${listed.id}`) !== undefined) {
893
863
  line.already += 1;
894
864
  continue;
895
865
  }
@@ -907,7 +877,7 @@ export async function runImport(store, plan, options) {
907
877
  continue;
908
878
  searched.push(part);
909
879
  // A file of it holding only copies adds nothing to it.
910
- if (heldRun === undefined && ownless(part)) {
880
+ if (ownless(part)) {
911
881
  report.skipped.push({ what: file, why: "holds only records of sessions imported already", kind: "copies" });
912
882
  continue;
913
883
  }
@@ -931,54 +901,32 @@ export async function runImport(store, plan, options) {
931
901
  const moved = await Promise.all(subagents.map(async (child) => scannedAs.get(child.file) !== stampOf((await stat(child.file).catch(() => null)) ?? { size: -1, mtimeMs: -1 })));
932
902
  if (moved.some(Boolean))
933
903
  add(await keysInSessions(subagents));
934
- // The transcript is whole before its run is: written beside the store, then moved into the run's directory.
935
- const pending = join(store.dir, `.import-${randomUUID()}.sqlite`);
936
- let started;
937
- try {
938
- // Its subagents' requests are the run's too: marked in its transcript, so its timeline's usage row counts what its
939
- // metrics do, one number for the run.
940
- const entries = await writeTimeline(pending, session, json, subagents);
941
- const metrics = { ...withChildren(runMetricsOf(entries), subagents.map((child) => runMetricsOf(entriesOf(child)))), activeMs: session.activeMs, ...(session.effort ? { effort: session.effort } : {}) };
942
- // A session its source did not price: the catalog's estimate, beside its cost (unknown), never written as it.
943
- const estimate = session.costUsd === undefined ? await estimateOf([...entries, ...subagents.flatMap(entriesOf)], catalog) : undefined;
944
- if (estimate !== undefined)
945
- Object.assign(metrics, { costUsdEst: estimate, costBasis: "catalog" });
946
- if (heldRun !== undefined) {
947
- started = { runId: heldRun, dir: join(store.dir, "runs", heldRun), storePath: store.runStorePath(heldRun) };
948
- if ((await mkdir(dirname(started.storePath), { recursive: true })) !== undefined)
949
- for (const made of [started.dir, dirname(started.storePath)])
950
- await chmod(made, 0o700);
951
- }
952
- else {
953
- const answer = session.turns.findLast((t) => t.role === "assistant" && t.text)?.text;
954
- started = await store.importRun({
955
- agent: project.agentId,
956
- revision: revisions.get(session.source).id,
957
- state: session.state,
958
- startedAt: session.startedAt ?? new Date(0).toISOString(),
959
- endedAt: session.endedAt ?? session.startedAt ?? new Date(0).toISOString(),
960
- ...(session.costUsd !== undefined ? { costUsd: session.costUsd } : {}),
961
- ...((answer ?? session.firstPrompt) ? { summary: text(answer ?? session.firstPrompt) } : {}),
962
- source: session.source,
963
- session: session.id,
964
- metrics,
965
- });
966
- }
967
- if (started)
968
- await rename(pending, started.storePath);
969
- }
970
- finally {
971
- await rm(pending, { force: true });
972
- }
973
- if (!started) {
974
- line.already += 1;
975
- continue;
976
- }
977
- await writeMeta(started.dir, session, read, json);
978
- if (heldRun !== undefined)
979
- line.finished += 1;
980
- else
981
- line.runs += 1;
904
+ // The transcript as the store's own write batches, each string cut; its subagents' requests marked after its turns,
905
+ // so its timeline's usage row counts what its metrics do, one number for the run.
906
+ const { batches, entries } = transcriptOf(session, json, subagents);
907
+ const metrics = { ...withChildren(runMetricsOf(entries), subagents.map((child) => runMetricsOf(entriesOf(child)))), activeMs: session.activeMs, ...(session.effort ? { effort: session.effort } : {}) };
908
+ // A session its source did not price: the catalog's estimate, beside its cost (unknown), never written as it.
909
+ const estimate = session.costUsd === undefined ? await estimateOf([...entries, ...subagents.flatMap(entriesOf)], catalog) : undefined;
910
+ if (estimate !== undefined)
911
+ Object.assign(metrics, { costUsdEst: estimate, costBasis: "catalog" });
912
+ const answer = session.turns.findLast((t) => t.role === "assistant" && t.text)?.text;
913
+ const title = clip(text(session.firstPrompt ?? `${session.source} session`), 120);
914
+ await store.importRun({
915
+ id: randomUUID(),
916
+ agentId: project.agentId,
917
+ revisionId: revisions.get(session.source),
918
+ importedFrom: { source: session.source, session: session.id, file: read },
919
+ launch: { body: launchBody({ input: { content: text(session.firstPrompt ?? "") }, title, place: { mode: "runner" } }) },
920
+ // An imported session is ended as it ended: a plain completion reads as 'ended', a stop or a failure as its own.
921
+ state: session.state === "completed" ? "ended" : session.state,
922
+ ...(session.costUsd !== undefined ? { costUsd: session.costUsd } : {}),
923
+ ...((answer ?? session.firstPrompt) ? { summary: text(answer ?? session.firstPrompt) } : {}),
924
+ metrics,
925
+ startedAt: Date.parse(session.startedAt ?? epoch0),
926
+ endedAt: Date.parse(session.endedAt ?? session.startedAt ?? epoch0),
927
+ transcript: batches,
928
+ });
929
+ line.runs += 1;
982
930
  }
983
931
  report.agents.push(line);
984
932
  }
@@ -1018,8 +966,8 @@ const BRING_IN = { gone: "--include-deleted", temp: "--all", "no-words": "--all"
1018
966
  const leftOutLines = (skipped) => leftOutOf(skipped).map(({ kind, count, label }) => `left out: ${label}${BRING_IN[kind] ? ` (${BRING_IN[kind]} imports ${count === 1 ? "it" : "them"} too)` : ""}`);
1019
967
  /** The plan as a person reads it: one line per project, its sessions counted as the import takes them, then (`verbose`)
1020
968
  * each file left out and why. */
1021
- export function describePlan(plan, store, { verbose = false } = {}) {
1022
- const held = store ? importedIn(store) : undefined;
969
+ export async function describePlan(plan, store, { verbose = false } = {}) {
970
+ const held = store ? await importedIn(store) : undefined;
1023
971
  const lines = plan.projects.map((project) => {
1024
972
  const sessions = sessionsOf(project.sessions);
1025
973
  const by = new Map();
@@ -1034,10 +982,16 @@ export function describePlan(plan, store, { verbose = false } = {}) {
1034
982
  /** `agentrun-serve import ARGS`: its exit code. */
1035
983
  export async function importCommand(args, usage, { home = homedir(),
1036
984
  // The folder whose projects are left out as temporary (the OS's temp directory).
1037
- temp = tmpdir(),
1038
- // The server's own keys, which its start moved out of process.env (secrets.ts), read back in: the import cuts them
1039
- // out of what it keeps, as it cuts every other key in the environment.
1040
- env = withSecrets(process.env), out = console.log, } = {}) {
985
+ 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
987
+ // booted the one way the server and runner boot it (seal-key.ts bootSealKey) once the store is open (keyed below), and
988
+ // checked against it. The key handed over wins (this process's, else a caller's own environment's: a test's), else the
989
+ // one in the data directory, as the server reads it.
990
+ const handedKey = handedSecret(SEAL_KEY_ENV) ?? env?.[SEAL_KEY_ENV];
991
+ const ownEnv = env === undefined;
992
+ // The server's own keys, which its start moved out of process.env (secrets.ts), read back in: the import cuts them out of
993
+ // what it keeps, as it cuts every other key in the environment.
994
+ env ??= withSecrets(process.env);
1041
995
  // What it prints goes through the cut what it keeps does, with the keys secretlint finds in the lines themselves: a
1042
996
  // file or project named after a key is printed cut. The lines are held until the end, then scanned and printed.
1043
997
  const printed = secretCut(env, SECRET_NAMES);
@@ -1055,6 +1009,27 @@ env = withSecrets(process.env), out = console.log, } = {}) {
1055
1009
  for (const line of lines.splice(0))
1056
1010
  print(printed.text(line));
1057
1011
  };
1012
+ let dir;
1013
+ /** The store's seal key, booted against `store` (seal-key.ts), and the environment the import reads given it, so the
1014
+ * store's sealed reads open under it. A dry run (`write` false) makes, moves and records nothing, and a store that holds
1015
+ * no secret and has no key is read with none. The key is cut from what is printed, as every key is. */
1016
+ let releaseKey = () => undefined;
1017
+ const keyed = async (store, write) => {
1018
+ const seal = await bootSealKey(store, dir, { given: handedKey, role: "import", write, say: (line) => void warnings.push(line.trimEnd()) });
1019
+ if (!seal)
1020
+ return;
1021
+ releaseKey = seal.release;
1022
+ printed.add([seal.text]);
1023
+ // The environment the import reads, this process's own or a caller's, with the key the boot checked as its seal key.
1024
+ env = withSealKey(ownEnv ? withSecrets(process.env) : env, seal.text);
1025
+ };
1026
+ /** A start the seal key refuses (seal-key.ts): said, in its words, and the import does not go on. */
1027
+ const sealRefused = (error) => {
1028
+ if (!(error instanceof SealKeyRefused))
1029
+ return false;
1030
+ warnings.push(`agentrun-serve import: ${error.message}`);
1031
+ return true;
1032
+ };
1058
1033
  try {
1059
1034
  let values;
1060
1035
  try {
@@ -1087,39 +1062,64 @@ env = withSecrets(process.env), out = console.log, } = {}) {
1087
1062
  console.error(`--from takes ${SOURCES.join(", ")}: not ${unknown.join(", ")}\n\n${usage}`);
1088
1063
  return 2;
1089
1064
  }
1090
- const dir = values.data ?? defaultData({ ...env, HOME: home });
1091
- // The tool keys the server keeps in this directory, opened here on the host with the seal key this process was handed:
1092
- // an imported transcript keeps none of them. One that does not open is not known here, so not cut: said, as the
1093
- // server says it at its start.
1094
- const keys = new ToolKeys(dir, env, say("tool_keys"));
1095
- keys.view();
1096
- const options = {
1097
- home,
1098
- sources: sources,
1099
- all: values.all === true,
1100
- deleted: values["include-deleted"] === true,
1101
- temp,
1102
- env,
1103
- stored: keys.values(),
1104
- own: ownSecrets(dir, env, say("webhook_secret")),
1065
+ dir = values.data ?? defaultData({ ...env, HOME: home });
1066
+ // The import's options, built from the open store: the tool keys the server keeps as sealed rows (tool-keys-store.ts),
1067
+ // opened here with the seal key this process was handed, and this server's own secrets (server-secrets-store.ts). One
1068
+ // 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
1069
+ // directory with no store yet reads neither (none is there).
1070
+ const optionsFrom = async (store) => {
1071
+ // The environment as it is now: once the store's key is booted (keyed), it carries it.
1072
+ const keyEnv = env;
1073
+ const keys = store ? toolKeysOverStore(store, keyEnv, say("tool_keys")) : undefined;
1074
+ if (keys) {
1075
+ await keys.load();
1076
+ keys.view();
1077
+ }
1078
+ const options = {
1079
+ home,
1080
+ sources: sources,
1081
+ all: values.all === true,
1082
+ deleted: values["include-deleted"] === true,
1083
+ temp,
1084
+ env: keyEnv,
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")) : [],
1088
+ };
1089
+ // 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
+ // keeps is.
1091
+ printed.add(Object.values(options.stored ?? {}));
1092
+ options.onKeys = (found) => printed.add(found);
1093
+ return options;
1105
1094
  };
1106
- // What it prints is cut with the saved keys too, and with every key the import (or the dry run) finds, as what it
1107
- // keeps is.
1108
- printed.add(Object.values(options.stored ?? {}));
1109
- options.onKeys = (keys) => printed.add(keys);
1110
1095
  if (values["dry-run"]) {
1111
- // A dry run writes nothing, not even a store: one there already is only read.
1112
- const reader = existsSync(join(dir, STORE_FILE)) ? openStoreReader(dir) : undefined;
1096
+ // A dry run writes nothing: a store there already is opened read-only (role runner), one that is not is left unmade
1097
+ // (on Postgres, when AGENTRUN_STORE_URL names one: a schema not set up yet).
1098
+ const reader = storeTarget(dir).kind === "postgres"
1099
+ ? await openStore({ dataDir: dir, role: "runner" }).catch((error) => {
1100
+ if (error instanceof SchemaVersionUnknown && error.found === null)
1101
+ return undefined;
1102
+ throw error;
1103
+ })
1104
+ : existsSync(join(dir, STORE_FILE)) ? await openStore({ dataDir: dir, role: "runner" }) : undefined;
1113
1105
  let plan;
1114
1106
  let found;
1115
1107
  try {
1108
+ if (reader)
1109
+ await keyed(reader, false);
1110
+ const options = await optionsFrom(reader);
1116
1111
  plan = await planImport({ ...options, measure: true }, reader);
1117
- for (const line of describePlan(plan, reader, { verbose: values.verbose === true }))
1112
+ for (const line of await describePlan(plan, reader, { verbose: values.verbose === true }))
1118
1113
  out(line);
1119
1114
  found = [...plan.found, ...(reader ? await foundAll(reader, plan.held) : []), ...(await untiedFound(plan))];
1120
1115
  }
1116
+ catch (error) {
1117
+ if (sealRefused(error))
1118
+ return 1;
1119
+ throw error;
1120
+ }
1121
1121
  finally {
1122
- reader?.close();
1122
+ await reader?.close();
1123
1123
  }
1124
1124
  out(`${plan.projects.length} projects, ${sessionsOf(plan.projects.flatMap((p) => p.sessions)).length} sessions; nothing was written (dry run)`);
1125
1125
  if (plan.secretsFound !== undefined)
@@ -1130,12 +1130,36 @@ env = withSecrets(process.env), out = console.log, } = {}) {
1130
1130
  out(line);
1131
1131
  return 0;
1132
1132
  }
1133
- const store = openStore(dir);
1133
+ // A data directory an earlier version wrote (its store a file-era store.sqlite, or its settings files), or one a running
1134
+ // server holds: the import refuses it in the store's own words — which name the directory and what was found — writes
1135
+ // nothing into it (the refusal is before the store is opened or made), and does not wait on a running server.
1136
+ let store;
1134
1137
  try {
1138
+ // The store AGENTRUN_STORE_URL names (store/open.ts), else SQLite in the directory; on Postgres a running server's
1139
+ // owner lock is the StoreOwned refused here.
1140
+ store = await openStore({ dataDir: dir, role: "server" });
1141
+ }
1142
+ catch (error) {
1143
+ if (error instanceof StoreFromEarlierVersion || error instanceof StoreOwned) {
1144
+ warnings.push(`agentrun-serve import: ${error.message}`);
1145
+ return 1;
1146
+ }
1147
+ throw error;
1148
+ }
1149
+ try {
1150
+ try {
1151
+ await keyed(store, true);
1152
+ }
1153
+ catch (error) {
1154
+ if (sealRefused(error))
1155
+ return 1;
1156
+ throw error;
1157
+ }
1158
+ const options = await optionsFrom(store);
1135
1159
  const plan = await planImport(options, store);
1136
1160
  const report = await runImport(store, plan, options);
1137
1161
  for (const agent of report.agents)
1138
- out(`${agent.cwd} ${agent.created ? "new agent" : "agent held"} ${agent.id} imported ${agent.runs}${agent.finished ? `, finished ${agent.finished}` : ""}${agent.already ? `, already imported ${agent.already}` : ""}`);
1162
+ out(`${agent.cwd} ${agent.created ? "new agent" : "agent held"} ${agent.id} imported ${agent.runs}${agent.already ? `, already imported ${agent.already}` : ""}`);
1139
1163
  if (report.already)
1140
1164
  out(`already imported, unchanged: ${report.already} session files (not read again)`);
1141
1165
  if (values.verbose)
@@ -1146,17 +1170,18 @@ env = withSecrets(process.env), out = console.log, } = {}) {
1146
1170
  for (const line of leftOutLines(report.skipped))
1147
1171
  out(line);
1148
1172
  // Every session found: those imported now, those held before, and those whose file an earlier import read whole.
1149
- const held = importedIn(store);
1173
+ const held = await importedIn(store);
1150
1174
  const runs = [...plan.projects.flatMap((p) => p.sessions.flatMap((s) => held.get(`${s.source}:${s.id}`) ?? [])), ...plan.held];
1151
1175
  for (const line of summaryLines([...(await foundAll(store, runs)), ...(await untiedFound(plan))], open))
1152
1176
  out(line);
1153
1177
  return 0;
1154
1178
  }
1155
1179
  finally {
1156
- store.close();
1180
+ await store.close();
1157
1181
  }
1158
1182
  }
1159
1183
  finally {
1184
+ releaseKey();
1160
1185
  await flush();
1161
1186
  }
1162
1187
  }
@@ -1164,7 +1189,7 @@ env = withSecrets(process.env), out = console.log, } = {}) {
1164
1189
  async function foundAll(store, runIds) {
1165
1190
  const found = [];
1166
1191
  for (const id of new Set(runIds)) {
1167
- const run = await foundIn(store, id);
1192
+ const run = await foundOverStore(store, id, ctx);
1168
1193
  if (run)
1169
1194
  found.push(run);
1170
1195
  }