@parcha/agentrun-serve 0.1.0-beta.33 → 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 (381) hide show
  1. package/CHANGELOG.md +233 -0
  2. package/README.md +266 -201
  3. package/dist/adapters.d.ts +0 -4
  4. package/dist/adapters.js +11 -15
  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 +1 -1
  14. package/dist/api-only.js +2 -2
  15. package/dist/bash-read-only.d.ts +22 -0
  16. package/dist/bash-read-only.js +701 -0
  17. package/dist/box-settings.d.ts +3 -23
  18. package/dist/box-settings.js +7 -51
  19. package/dist/boxes.d.ts +17 -0
  20. package/dist/boxes.js +27 -20
  21. package/dist/browser-commands.d.ts +5 -2
  22. package/dist/browser-commands.js +4 -4
  23. package/dist/browser-computer.d.ts +5 -0
  24. package/dist/browser-computer.js +21 -0
  25. package/dist/browser-cost.d.ts +9 -6
  26. package/dist/browser-cost.js +92 -50
  27. package/dist/browser-live.d.ts +7 -20
  28. package/dist/browser-live.js +15 -93
  29. package/dist/browser-person.d.ts +18 -51
  30. package/dist/browser-person.js +94 -277
  31. package/dist/cap.d.ts +8 -5
  32. package/dist/cap.js +12 -5
  33. package/dist/cli.js +39 -13
  34. package/dist/closed-pipes.d.ts +2 -0
  35. package/dist/closed-pipes.js +13 -0
  36. package/dist/computer-commands.d.ts +2 -0
  37. package/dist/computer-commands.js +2 -0
  38. package/dist/computer-keys.js +5 -2
  39. package/dist/computer-setting.d.ts +20 -4
  40. package/dist/computer-setting.js +25 -5
  41. package/dist/computers.d.ts +30 -2
  42. package/dist/computers.js +70 -11
  43. package/dist/confine.d.ts +120 -0
  44. package/dist/confine.js +436 -0
  45. package/dist/console/assets/index-RPHGlXmM.js +540 -0
  46. package/dist/console/assets/index-opTN5Naq.css +1 -0
  47. package/dist/console/index.html +2 -2
  48. package/dist/decision-rows.d.ts +1 -1
  49. package/dist/decision-rows.js +1 -1
  50. package/dist/docker-daemon.d.ts +31 -0
  51. package/dist/docker-daemon.js +56 -0
  52. package/dist/effort-guidance.js +4 -3
  53. package/dist/environment.d.ts +0 -3
  54. package/dist/environment.js +3 -5
  55. package/dist/errors.d.ts +0 -2
  56. package/dist/errors.js +6 -9
  57. package/dist/filed-answer.d.ts +32 -0
  58. package/dist/filed-answer.js +160 -0
  59. package/dist/files.d.ts +1 -3
  60. package/dist/files.js +2 -4
  61. package/dist/github-connection.d.ts +1 -1
  62. package/dist/graph-view.d.ts +3 -5
  63. package/dist/graph-view.js +4 -14
  64. package/dist/handed-values.d.ts +9 -0
  65. package/dist/handed-values.js +26 -0
  66. package/dist/harness-install.d.ts +1 -7
  67. package/dist/harness-install.js +1 -18
  68. package/dist/harness-opencode/adapter.d.ts +7 -0
  69. package/dist/harness-opencode/adapter.js +23 -6
  70. package/dist/harness-opencode/index.d.ts +1 -1
  71. package/dist/harness-opencode/index.js +1 -1
  72. package/dist/harness-opencode/verify.d.ts +17 -0
  73. package/dist/harness-opencode/verify.js +30 -10
  74. package/dist/harness-table.js +6 -1
  75. package/dist/heard.js +1 -1
  76. package/dist/held-fd.d.ts +5 -0
  77. package/dist/held-fd.js +14 -0
  78. package/dist/host-calls.d.ts +20 -0
  79. package/dist/host-calls.js +12 -0
  80. package/dist/host-tools.d.ts +4 -21
  81. package/dist/host-tools.js +4 -61
  82. package/dist/host.d.ts +2 -4
  83. package/dist/host.js +2 -7
  84. package/dist/import-summary.d.ts +1 -5
  85. package/dist/import-summary.js +0 -21
  86. package/dist/import.d.ts +6 -6
  87. package/dist/import.js +14 -15
  88. package/dist/key-refusal.d.ts +5 -1
  89. package/dist/key-refusal.js +19 -4
  90. package/dist/learn/check.d.ts +6 -2
  91. package/dist/learn/check.js +83 -29
  92. package/dist/learn/folder.d.ts +5 -1
  93. package/dist/learn/folder.js +10 -3
  94. package/dist/learn/grade.d.ts +14 -0
  95. package/dist/learn/grade.js +68 -12
  96. package/dist/learn/index.d.ts +4 -4
  97. package/dist/learn/index.js +4 -4
  98. package/dist/learn/reflect.d.ts +31 -2
  99. package/dist/learn/reflect.js +79 -4
  100. package/dist/learn/relevance.d.ts +24 -0
  101. package/dist/learn/relevance.js +91 -0
  102. package/dist/learn/secrets.d.ts +7 -1
  103. package/dist/learn/secrets.js +86 -19
  104. package/dist/learn/skills.d.ts +112 -14
  105. package/dist/learn/skills.js +556 -52
  106. package/dist/learned-workflow.d.ts +32 -1
  107. package/dist/learned-workflow.js +100 -9
  108. package/dist/learning-routes.d.ts +8 -4
  109. package/dist/learning-routes.js +23 -9
  110. package/dist/learning-run.d.ts +9 -26
  111. package/dist/learning-run.js +22 -32
  112. package/dist/learning-words.d.ts +12 -5
  113. package/dist/learning-words.js +18 -9
  114. package/dist/learning.d.ts +93 -77
  115. package/dist/learning.js +176 -304
  116. package/dist/live/stream.js +1 -1
  117. package/dist/live/translate.js +12 -2
  118. package/dist/local-models.d.ts +11 -5
  119. package/dist/local-models.js +13 -8
  120. package/dist/mcp-gateway.d.ts +11 -49
  121. package/dist/mcp-gateway.js +44 -135
  122. package/dist/mcp-oauth.d.ts +10 -14
  123. package/dist/mcp-oauth.js +14 -32
  124. package/dist/mcp-probe.d.ts +0 -7
  125. package/dist/mcp-probe.js +4 -10
  126. package/dist/mcp-servers-store.d.ts +6 -6
  127. package/dist/mcp-servers-store.js +12 -14
  128. package/dist/mcp-store.js +3 -4
  129. package/dist/mcp.js +4 -3
  130. package/dist/model.d.ts +6 -7
  131. package/dist/model.js +43 -27
  132. package/dist/monid.d.ts +0 -2
  133. package/dist/monid.js +3 -6
  134. package/dist/openapi.d.ts +8 -1
  135. package/dist/openapi.js +121 -47
  136. package/dist/page.d.ts +1 -3
  137. package/dist/page.js +6 -18
  138. package/dist/paid-calls.d.ts +21 -27
  139. package/dist/paid-calls.js +25 -60
  140. package/dist/propose.js +83 -39
  141. package/dist/push-handler.d.ts +1 -1
  142. package/dist/reflect-range.d.ts +25 -0
  143. package/dist/reflect-range.js +30 -0
  144. package/dist/refusal-words.d.ts +5 -1
  145. package/dist/refusal-words.js +5 -1
  146. package/dist/rows.d.ts +1 -1
  147. package/dist/run-cut.d.ts +0 -6
  148. package/dist/run-cut.js +0 -6
  149. package/dist/run-db.d.ts +2 -11
  150. package/dist/run-db.js +2 -37
  151. package/dist/run-launch.d.ts +19 -2
  152. package/dist/run-launch.js +13 -5
  153. package/dist/run-learning-served.d.ts +10 -4
  154. package/dist/run-learning-served.js +23 -13
  155. package/dist/run-reads-over-store.d.ts +1 -1
  156. package/dist/run-reads-over-store.js +15 -6
  157. package/dist/run-secrets.d.ts +1 -1
  158. package/dist/run-timeline-served.d.ts +5 -1
  159. package/dist/run-timeline-served.js +15 -4
  160. package/dist/run-view.d.ts +7 -8
  161. package/dist/run-view.js +26 -7
  162. package/dist/runnable.d.ts +18 -10
  163. package/dist/runnable.js +21 -10
  164. package/dist/runner/adapter-loop.d.ts +6 -1
  165. package/dist/runner/adapter-loop.js +423 -53
  166. package/dist/runner/adapter-run-spec.d.ts +21 -8
  167. package/dist/runner/adapter-run-spec.js +90 -32
  168. package/dist/runner/adapters/index.js +11 -1
  169. package/dist/runner/adapters/pi.d.ts +12 -2
  170. package/dist/runner/adapters/pi.js +16 -5
  171. package/dist/runner/beside.d.ts +30 -3
  172. package/dist/runner/beside.js +36 -5
  173. package/dist/runner/claim-secrets.d.ts +10 -1
  174. package/dist/runner/claim-secrets.js +48 -14
  175. package/dist/runner/cli-run-spec.d.ts +2 -0
  176. package/dist/runner/cli-run-spec.js +45 -16
  177. package/dist/runner/commands.js +1 -1
  178. package/dist/runner/computer-journal.d.ts +15 -2
  179. package/dist/runner/computer-journal.js +41 -5
  180. package/dist/runner/conformance/harness.js +118 -8
  181. package/dist/runner/conformance/subject.d.ts +4 -1
  182. package/dist/runner/dispatch.d.ts +8 -1
  183. package/dist/runner/dispatch.js +81 -7
  184. package/dist/runner/end-of-run.d.ts +8 -2
  185. package/dist/runner/end-of-run.js +10 -4
  186. package/dist/runner/github-app.js +1 -1
  187. package/dist/runner/harness-loops.d.ts +9 -1
  188. package/dist/runner/harness-loops.js +15 -2
  189. package/dist/runner/journal-kinds.d.ts +24 -6
  190. package/dist/runner/journal-kinds.js +20 -5
  191. package/dist/runner/journal-reader.d.ts +1 -1
  192. package/dist/runner/journal-reader.js +2 -2
  193. package/dist/runner/learning-ask.d.ts +4 -0
  194. package/dist/runner/learning-ask.js +15 -1
  195. package/dist/runner/learning-end.d.ts +18 -3
  196. package/dist/runner/learning-end.js +113 -11
  197. package/dist/runner/learning-loop.d.ts +5 -0
  198. package/dist/runner/learning-loop.js +26 -6
  199. package/dist/runner/main.d.ts +56 -9
  200. package/dist/runner/main.js +127 -18
  201. package/dist/runner/mcp-claim.js +1 -2
  202. package/dist/runner/mcp-run.d.ts +2 -0
  203. package/dist/runner/mcp-run.js +15 -5
  204. package/dist/runner/memory-claim.d.ts +9 -0
  205. package/dist/runner/memory-claim.js +25 -0
  206. package/dist/runner/metrics.d.ts +33 -1
  207. package/dist/runner/metrics.js +85 -1
  208. package/dist/runner/model-route.d.ts +13 -0
  209. package/dist/runner/model-route.js +133 -9
  210. package/dist/runner/reflect-hook.d.ts +12 -1
  211. package/dist/runner/reflect-hook.js +33 -3
  212. package/dist/runner/runner.d.ts +20 -0
  213. package/dist/runner/runner.js +56 -10
  214. package/dist/runner/store-port.d.ts +1 -1
  215. package/dist/runner/store-secrets.d.ts +3 -3
  216. package/dist/runner/store-secrets.js +8 -12
  217. package/dist/runner/text-tools.d.ts +44 -0
  218. package/dist/runner/text-tools.js +237 -0
  219. package/dist/runner/workflow-loop.d.ts +6 -0
  220. package/dist/runner/workflow-loop.js +6 -4
  221. package/dist/runner/workflow-spec.d.ts +18 -0
  222. package/dist/runner/workflow-spec.js +63 -17
  223. package/dist/runs-over-store.d.ts +7 -2
  224. package/dist/runs-over-store.js +60 -14
  225. package/dist/seal-key.js +5 -43
  226. package/dist/sealed-settings-store.d.ts +19 -4
  227. package/dist/sealed-settings-store.js +9 -9
  228. package/dist/sealing.d.ts +4 -0
  229. package/dist/sealing.js +20 -0
  230. package/dist/secret-cut.d.ts +1 -1
  231. package/dist/secret-cut.js +1 -1
  232. package/dist/secret-name.d.ts +9 -0
  233. package/dist/secret-name.js +15 -0
  234. package/dist/secret-writes.d.ts +0 -1
  235. package/dist/secret-writes.js +0 -1
  236. package/dist/server-fs.d.ts +4 -0
  237. package/dist/server-fs.js +8 -2
  238. package/dist/server-lock.d.ts +0 -24
  239. package/dist/server-lock.js +1 -80
  240. package/dist/server-secrets-store.d.ts +4 -4
  241. package/dist/server-secrets-store.js +9 -31
  242. package/dist/server-secrets.d.ts +4 -9
  243. package/dist/server-secrets.js +12 -36
  244. package/dist/server.d.ts +16 -38
  245. package/dist/server.js +145 -106
  246. package/dist/sign-ins-store.d.ts +34 -36
  247. package/dist/sign-ins-store.js +27 -38
  248. package/dist/sign-ins.d.ts +2 -119
  249. package/dist/sign-ins.js +5 -311
  250. package/dist/standard-webhooks.d.ts +1 -1
  251. package/dist/standard-webhooks.js +1 -1
  252. package/dist/stats.d.ts +3 -2
  253. package/dist/stats.js +1 -1
  254. package/dist/store/agent-body.d.ts +8 -2
  255. package/dist/store/agent-body.js +16 -4
  256. package/dist/store/index.d.ts +2 -2
  257. package/dist/store/index.js +2 -2
  258. package/dist/store/open.d.ts +6 -3
  259. package/dist/store/open.js +2 -2
  260. package/dist/store/postgres/connection.d.ts +18 -2
  261. package/dist/store/postgres/connection.js +156 -32
  262. package/dist/store/postgres/migrate.d.ts +4 -0
  263. package/dist/store/postgres/migrate.js +9 -2
  264. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  265. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  266. package/dist/store/postgres/store.d.ts +9 -2
  267. package/dist/store/postgres/store.js +9 -0
  268. package/dist/store/schema.js +1 -1
  269. package/dist/store/seal.js +2 -2
  270. package/dist/store/sqlite/connection.js +49 -5
  271. package/dist/store/sqlite/run-patch.d.ts +3 -0
  272. package/dist/store/sqlite/run-patch.js +3 -0
  273. package/dist/store/sqlite/store.js +41 -12
  274. package/dist/store/store.d.ts +35 -6
  275. package/dist/store/store.js +12 -2
  276. package/dist/store-reads/cap.d.ts +1 -1
  277. package/dist/store-reads/cap.js +22 -4
  278. package/dist/store-reads/journal.d.ts +9 -6
  279. package/dist/store-reads/journal.js +93 -17
  280. package/dist/store-reads/learning.d.ts +26 -8
  281. package/dist/store-reads/learning.js +12 -4
  282. package/dist/store-reads/workflow.d.ts +1 -1
  283. package/dist/store-reads/workflow.js +1 -1
  284. package/dist/store-view.d.ts +5 -1
  285. package/dist/store-view.js +53 -18
  286. package/dist/template-eval.d.ts +60 -4
  287. package/dist/template-eval.js +120 -54
  288. package/dist/templates.d.ts +24 -10
  289. package/dist/templates.js +69 -38
  290. package/dist/timeline/group.d.ts +33 -0
  291. package/dist/timeline/group.js +77 -0
  292. package/dist/timeline/index.d.ts +7 -0
  293. package/dist/timeline/index.js +7 -0
  294. package/dist/timeline/labels.d.ts +79 -0
  295. package/dist/timeline/labels.js +150 -0
  296. package/dist/timeline/origin.d.ts +56 -0
  297. package/dist/timeline/origin.js +92 -0
  298. package/dist/timeline/render-text.d.ts +11 -0
  299. package/dist/timeline/render-text.js +62 -0
  300. package/dist/timeline/timeline.d.ts +274 -0
  301. package/dist/timeline/timeline.js +1308 -0
  302. package/dist/timeline/util.d.ts +17 -0
  303. package/dist/timeline/util.js +49 -0
  304. package/dist/tool-gate.d.ts +41 -216
  305. package/dist/tool-gate.js +79 -540
  306. package/dist/tool-keys-store.d.ts +11 -12
  307. package/dist/tool-keys-store.js +24 -31
  308. package/dist/tool-keys.d.ts +5 -101
  309. package/dist/tool-keys.js +8 -267
  310. package/dist/tool-plane.d.ts +14 -42
  311. package/dist/tool-plane.js +23 -81
  312. package/dist/tool-settings-store.d.ts +1 -2
  313. package/dist/tool-settings-store.js +5 -8
  314. package/dist/tools.d.ts +30 -18
  315. package/dist/tools.js +97 -107
  316. package/dist/trigger-adapter.d.ts +2 -2
  317. package/dist/trigger-targets.d.ts +13 -1
  318. package/dist/trigger-targets.js +31 -1
  319. package/dist/triggers.d.ts +2 -2
  320. package/dist/triggers.js +3 -3
  321. package/dist/turn-end.d.ts +1 -1
  322. package/dist/turn-end.js +1 -1
  323. package/dist/turns.d.ts +0 -6
  324. package/dist/turns.js +0 -19
  325. package/dist/uploads.js +1 -1
  326. package/dist/usage.d.ts +0 -2
  327. package/dist/usage.js +0 -2
  328. package/dist/validate.d.ts +2 -0
  329. package/dist/validate.js +23 -14
  330. package/dist/webhooks.d.ts +102 -76
  331. package/dist/webhooks.js +266 -233
  332. package/dist/workflow-run.d.ts +114 -0
  333. package/dist/workflow-run.js +144 -0
  334. package/dist/workspace/beneath.d.ts +19 -0
  335. package/dist/workspace/beneath.js +106 -0
  336. package/dist/workspace/computer-deps.d.ts +24 -6
  337. package/dist/workspace/computer-deps.js +108 -20
  338. package/dist/workspace/computer-for-claim.d.ts +12 -11
  339. package/dist/workspace/computer-for-claim.js +76 -15
  340. package/dist/workspace/computer-hold.d.ts +6 -1
  341. package/dist/workspace/computer-hold.js +6 -1
  342. package/dist/workspace/computer-janitor.d.ts +47 -0
  343. package/dist/workspace/computer-janitor.js +182 -0
  344. package/dist/workspace/grep-worker.d.ts +5 -0
  345. package/dist/workspace/grep-worker.js +9 -6
  346. package/dist/workspace/index.d.ts +3 -2
  347. package/dist/workspace/index.js +3 -3
  348. package/dist/workspace/local.d.ts +11 -2
  349. package/dist/workspace/local.js +161 -43
  350. package/dist/workspace/resolve-computer.d.ts +50 -10
  351. package/dist/workspace/resolve-computer.js +46 -11
  352. package/dist/workspace/run-tools.d.ts +13 -31
  353. package/dist/workspace/run-tools.js +10 -27
  354. package/dist/workspace-paths.d.ts +0 -17
  355. package/dist/workspace-paths.js +1 -41
  356. package/dist/workspace.d.ts +0 -14
  357. package/dist/workspace.js +3 -96
  358. package/package.json +13 -13
  359. package/templates/README.md +9 -3
  360. package/templates/market-monitor/agent.md +2 -2
  361. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  362. package/dist/bound-files.d.ts +0 -4
  363. package/dist/bound-files.js +0 -164
  364. package/dist/coding-tools.d.ts +0 -47
  365. package/dist/coding-tools.js +0 -189
  366. package/dist/computer-adb.d.ts +0 -12
  367. package/dist/computer-adb.js +0 -14
  368. package/dist/console/assets/index-Dn0ngwG9.js +0 -535
  369. package/dist/console/assets/index-DvW6Aled.css +0 -1
  370. package/dist/grade.d.ts +0 -63
  371. package/dist/grade.js +0 -150
  372. package/dist/mcp-servers.d.ts +0 -269
  373. package/dist/mcp-servers.js +0 -456
  374. package/dist/packs.d.ts +0 -71
  375. package/dist/packs.js +0 -180
  376. package/dist/sealed-settings.d.ts +0 -60
  377. package/dist/sealed-settings.js +0 -171
  378. package/dist/sessions.d.ts +0 -6
  379. package/dist/sessions.js +0 -109
  380. package/dist/workspace/computer-serves.d.ts +0 -12
  381. package/dist/workspace/computer-serves.js +0 -15
@@ -1,46 +1,24 @@
1
- // The server's own secrets as one redaction list, over the one store, the store-backed replacement for openServerSecrets
2
- // (server-secrets.ts). What changes from the file version: each trigger source's sealed settings are store rows
3
- // (sealed-settings-store.ts, store.triggerSettings), not per-adapter files; the deleted per-run door token (.door-token) is
4
- // no longer a source. What stays a file: the owner's API token (.token, the CLI reads it) and the sign-in session secret,
5
- // which the cutover keeps beside the store; and the outbound webhook's signing secret, read as before. The list is still
1
+ // The server's own secrets as one redaction list, over the one store: each trigger source's sealed settings and the
2
+ // outbound webhook's signing secret are store rows (sealed-settings-store.ts, store.triggerSettings); the owner's API
3
+ // token (.token, the CLI reads it) and the sign-in session secret stay beside the store (server-secrets.ts besideTheStore). The list is
6
4
  // the one the server never shows (server.ts serverSecrets): what a run shows, what learning keeps and what the server
7
5
  // answers are cut of it.
8
- import { readFileSync } from "node:fs";
9
- import { join } from "node:path";
10
- import { TOKEN_FILE } from "./files.js";
11
- import { SESSION_SECRET_FILE } from "./owner.js";
12
6
  import { sealedSettingsOverStore } from "./sealed-settings-store.js";
13
- import { ServerSecrets } from "./server-secrets.js";
7
+ import { besideTheStore } from "./server-secrets.js";
14
8
  import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
15
- import { webhookSecretIn } from "./webhooks.js";
16
- /** The file `name` in `data`, trimmed; empty when it is not there. */
17
- const fileIn = (data, name) => {
18
- try {
19
- return readFileSync(join(data, name), "utf8").trim();
20
- }
21
- catch {
22
- return "";
23
- }
24
- };
25
- /** The server's own secrets over the store: the owner's token and the session secret (still files beside the store), the
26
- * outbound webhook's secret, and every adapter's sealed settings (now store rows), which are returned too, by adapter id,
9
+ import { OUTBOUND_WEBHOOK } from "./webhooks.js";
10
+ /** The server's own secrets over the store: what it keeps beside the store (besideTheStore), every adapter's sealed
11
+ * settings and the outbound webhook's (OUTBOUND_WEBHOOK, its signing secret), store rows, which are returned too, by id,
27
12
  * for the server to keep using. Loads each adapter's settings before it answers (awaited once at start), so the redaction
28
13
  * list is whole from the first use. A value that does not open is said to `say`. */
29
14
  export async function openServerSecretsOverStore(store, data, env, adapters, say = () => { }) {
30
- const secrets = new ServerSecrets();
31
- // Each read until it is there, then kept: they are made once, and a redaction reads the list often.
32
- const read = new Map();
33
- const kept = (name) => read.get(name) || (read.set(name, fileIn(data, name)), read.get(name));
34
- // The owner's API token and the sign-in session secret stay files beside the store; the per-run door token is gone.
35
- secrets.add("files", () => [kept(TOKEN_FILE), kept(SESSION_SECRET_FILE)]);
36
- const webhook = webhookSecretIn(data, env);
37
- secrets.add("webhook", () => (webhook && "secret" in webhook ? [webhook.secret] : []));
38
15
  // The server always has its seal key (seal-key.ts bootSealKey, at its start): no setting is ever kept in the clear.
39
16
  const key = sealKeyOf(env[SEAL_KEY_ENV]);
40
17
  if (!key)
41
18
  throw new Error(`the server starts with its seal key (${SEAL_KEY_ENV}), made at the first start when none is handed over`);
19
+ const secrets = besideTheStore(data);
42
20
  const settings = new Map();
43
- for (const adapter of adapters) {
21
+ for (const adapter of [...adapters, OUTBOUND_WEBHOOK]) {
44
22
  if (!adapter.settings)
45
23
  continue;
46
24
  const adapterSettings = sealedSettingsOverStore(store, adapter.id, adapter.settings, key, say);
@@ -1,5 +1,3 @@
1
- import { SealedSettings } from "./sealed-settings.js";
2
- import type { TriggerAdapter } from "./trigger-adapter.js";
3
1
  export declare class ServerSecrets {
4
2
  private readonly sources;
5
3
  /** Sources whose every value is listed as it is, of any length and whitespace and all: a PEM key's lines and whole. */
@@ -14,10 +12,7 @@ export declare class ServerSecrets {
14
12
  * in every spelling of it (standard-webhooks.ts secretForms). */
15
13
  values(): string[];
16
14
  }
17
- /** The server's own secrets data directory `data` keeps, each store opened with the seal key of `env`: the tokens' and
18
- * the session secret's files, the outbound webhook's secret, and every adapter's sealed settings (a value that does not
19
- * open is said to `say`), which are returned too, by adapter id, for the server to keep using. */
20
- export declare function openServerSecrets(data: string, env: NodeJS.ProcessEnv, adapters: readonly TriggerAdapter[], say?: (fields: Record<string, string>) => void): {
21
- secrets: ServerSecrets;
22
- settings: Map<string, SealedSettings>;
23
- };
15
+ /** The server's own secrets data directory `data` keeps beside the store: the owner's API token and the sign-in session
16
+ * secret (files the CLI and the console's sign-in read). Each file is read until it is there, then kept: they are made
17
+ * once, and a redaction reads the list often. */
18
+ export declare function besideTheStore(data: string): ServerSecrets;
@@ -1,17 +1,14 @@
1
- // The server's own secrets, as one list: its API token, its door token, its sign-in sessions' secret, its outbound
2
- // webhook's signing secret, and every value a trigger source keeps sealed (sealed-settings.ts). Each store adds itself
3
- // when it opens, as a reader, so a secret made or rotated since is in the list at once. With the host's, they are the one
4
- // list a server never shows (server.ts serverSecrets): what a run shows (runs.ts), what learning keeps (learning-run.ts),
5
- // what the server answers and the VM relay's errors are cut of it, and what an import writes (import.ts) of these; none
6
- // of them assembles its own.
7
- import { existsSync, readFileSync } from "node:fs";
1
+ // The server's own secrets, as one list: its API token, its sign-in sessions' secret, and every value the server keeps
2
+ // sealed among its settings (sealed-settings-store.ts): each trigger source's, and the outbound webhook's signing secret. Each source is added as a reader, so a
3
+ // secret made or rotated since is in the list at once. With the host's, they are the one list a server never shows
4
+ // (server.ts serverSecrets): what a run shows, what learning keeps, what the server answers and what an import writes are
5
+ // cut of it; none of them assembles its own. The trigger settings are store rows (server-secrets-store.ts); what stays
6
+ // beside the store in the data directory is read here (besideTheStore), by the server and by a runner that shares it.
7
+ import { readFileSync } from "node:fs";
8
8
  import { join } from "node:path";
9
9
  import { TOKEN_FILE } from "./files.js";
10
10
  import { SESSION_SECRET_FILE } from "./owner.js";
11
- import { SealedSettings } from "./sealed-settings.js";
12
11
  import { secretForms } from "./standard-webhooks.js";
13
- import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
14
- import { webhookSecretIn } from "./webhooks.js";
15
12
  export class ServerSecrets {
16
13
  sources = new Map();
17
14
  /** Sources whose every value is listed as it is, of any length and whitespace and all: a PEM key's lines and whole. */
@@ -43,34 +40,13 @@ const fileIn = (data, name) => {
43
40
  return "";
44
41
  }
45
42
  };
46
- /** The server's own secrets data directory `data` keeps, each store opened with the seal key of `env`: the tokens' and
47
- * the session secret's files, the outbound webhook's secret, and every adapter's sealed settings (a value that does not
48
- * open is said to `say`), which are returned too, by adapter id, for the server to keep using. */
49
- export function openServerSecrets(data, env, adapters, say = () => { }) {
43
+ /** The server's own secrets data directory `data` keeps beside the store: the owner's API token and the sign-in session
44
+ * secret (files the CLI and the console's sign-in read). Each file is read until it is there, then kept: they are made
45
+ * once, and a redaction reads the list often. */
46
+ export function besideTheStore(data) {
50
47
  const secrets = new ServerSecrets();
51
- // Each read until it is there, then kept: they are made once, and a redaction reads the list often.
52
48
  const read = new Map();
53
49
  const kept = (name) => read.get(name) || (read.set(name, fileIn(data, name)), read.get(name));
54
50
  secrets.add("files", () => [kept(TOKEN_FILE), kept(SESSION_SECRET_FILE)]);
55
- const webhook = webhookSecretIn(data, env);
56
- secrets.add("webhook", () => (webhook && "secret" in webhook ? [webhook.secret] : []));
57
- // Where a webhook trigger's secret was kept before its source's sealed settings were: no longer read.
58
- const leftover = join(data, "trigger-secrets.json");
59
- if (existsSync(leftover))
60
- say({ condition: "trigger_secrets_left_over", file: leftover, effect: "not read: give each webhook trigger made before a new secret with POST /v2/triggers/{id}/secret, or make it again" });
61
- // There is always a seal key (seal-key.ts): every caller hands this one.
62
- const key = sealKeyOf(env[SEAL_KEY_ENV]);
63
- if (!key)
64
- throw new Error(`the server's own secrets open only under its seal key (${SEAL_KEY_ENV}), and none was handed`);
65
- const settings = new Map();
66
- for (const adapter of adapters) {
67
- if (!adapter.settings)
68
- continue;
69
- const store = new SealedSettings(data, adapter.id, adapter.settings, key, say);
70
- settings.set(adapter.id, store);
71
- secrets.add(`trigger-settings:${adapter.id}`, () => store.values());
72
- // A PEM key's lines, its short last one too, and the key whole: listed with no floor.
73
- secrets.add(`trigger-settings-pem:${adapter.id}`, () => store.pemValues(), { whole: true });
74
- }
75
- return { secrets, settings };
51
+ return secrets;
76
52
  }
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type ModelNeeds } from "./model.js";
2
2
  import { type HarnessCapability } from "./harness.js";
3
- import type { MessageOrigin } from "@parcha/pi-durable-agent/timeline";
3
+ import type { MessageOrigin } from "./timeline/index.js";
4
4
  import { type LearningMode } from "./learning.js";
5
5
  import { type Place } from "./place.js";
6
6
  import { type Store } from "./store/index.js";
@@ -16,6 +16,9 @@ export declare const DEFAULT_PORT = 7340;
16
16
  export type ServeOptions = {
17
17
  /** The data directory: the agent store (`store.sqlite`) and its runs (`runs/<id>/`). */
18
18
  data: string;
19
+ /** On Postgres: told when this server's owner lock is lost for good (another server took the schema, or the lock could
20
+ * not be taken back): every store call is refused from then. The CLI exits 1 on it, so the platform restarts the server. */
21
+ onStoreLost?: (error: Error) => void;
19
22
  /** The owner, signed in with a password (owner.ts): the page asks for it, and the token stays for scripts and the CLI. */
20
23
  accounts?: boolean;
21
24
  /** With accounts: the first visit sets the password with no setup code (a server with no public address). Honored only
@@ -130,8 +133,6 @@ export type ServeOptions = {
130
133
  maxRuns?: number;
131
134
  /** Free disk under the data directory below which GET /v2/health fails (default 64 MiB, or AGENTRUN_MIN_FREE_MB). */
132
135
  minFreeBytes?: number;
133
- /** How often a carry back the store refused is tried again while the server lives (default 30 s). */
134
- settleRetryMs?: number;
135
136
  /** Where the log lines go (print.ts); none without it. AGENTRUN_LOG=quiet leaves out the request lines. */
136
137
  log?: (line: string) => void;
137
138
  /** Told the Docker box image's state at the start, when this server has a Docker box, then each change (box-image.ts):
@@ -141,41 +142,18 @@ export type ServeOptions = {
141
142
  * left to finish their turn, and this start's, when it waits for a server that is stopping (server-lock.ts). Default:
142
143
  * standard error, after `agentrun-serve: `. */
143
144
  notice?: (line: string) => void;
144
- /** The waits between carry backs that found the store held by another writer (default 0.5, 1, 2, 4 and 8 s), and a
145
- * hook called at each such refusal. */
146
- /** A test hook the per-run process used for carry-back; the runner owns carry-back now (unused by the server cut). */
147
- carryBackRetry?: unknown;
148
145
  /** A test's seam: awaited by a stop between its mark and its abort, so a test can hold a stop in flight there. */
149
146
  beforeAbort?: (runId: string) => Promise<void> | void;
150
147
  /** A test's seam: awaited by a completed run's reopen for a follow-up, after the run reads open again and before its
151
148
  * process is launched, so a test can hold a reopen there. */
152
149
  beforeReopenLaunch?: (runId: string) => Promise<void> | void;
153
- /** A test's seam: awaited where a raise that opens a let-go workflow pins what its launch needs, after its place is
154
- * taken (runs.ts finishRaise); one that throws stands for a pin that fails there. */
155
- beforeRaiseLaunch?: (runId: string) => Promise<void> | void;
156
150
  /** A test's seam: the host's memory, in bytes, that the runs' limit reads (host.ts), in place of this host's. */
157
151
  hostMemory?: number;
158
- /** A test's seam: told each stat and each read of a workflow run's pause by its watch (runs.ts watchPause). */
159
- onPauseCheck?: (runId: string, what: "stat" | "read") => void;
160
- /** A test's seam: awaited by a message before it goes to the run's door, so a test can act while it is in flight. */
161
- beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
162
152
  /** A test's seam: told each run read in from its store (runs.ts onRunLoad). */
163
153
  onRunLoad?: (runId: string) => void;
164
- /** A test's seam: awaited before a run's serve.json is written (runs.ts beforeMetaSave). */
165
- beforeMetaSave?: (runId: string, meta: Readonly<Record<string, unknown>>) => Promise<void> | void;
166
154
  /** A test's seam: who wrote a message sent to a run through its messages route (`origin`, as a raised cap's follow-up
167
155
  * carries it), so a test sends a server-written message down the path a person's message takes. */
168
156
  messageOrigin?: (runId: string, content: string) => MessageOrigin | undefined;
169
- /** How long a request waits for a run's door, its process coming up or a settle in progress (default 45 s). */
170
- readyTimeoutMs?: number;
171
- /** How long a launched run's process has to open its run before it is stopped and the run opened again (default 45 s,
172
- * READY_TIMEOUT_MS: the wait of a run's first message). */
173
- openTimeoutMs?: number;
174
- /** With `faux` only: the door nonce each run's process is handed in place of its launch's own, so its door answers the
175
- * launch's proof wrongly (a test of a door that fails its proof). */
176
- fauxHandedNonce?: string;
177
- /** How long a run's end-of-run turn may take before it is aborted and the run finishes without it (default 5 min). */
178
- reflectTimeoutMs?: number;
179
157
  /** The model the grader runs on (`--grade-model`; default AGENTRUN_SERVE_GRADE_MODEL, else the strong tier,
180
158
  * AGENT_MODEL_STRONG, else each run's agent's own model). */
181
159
  gradeModel?: string;
@@ -184,8 +162,8 @@ export type ServeOptions = {
184
162
  * its agent's definition says, and its `learning` is null. */
185
163
  learning?: LearningMode;
186
164
  /** How much of what a run learned its instructions hold under `# Learned`, in UTF-8 bytes (`--learning-budget`;
187
- * default AGENTRUN_SERVE_LEARNING_BUDGET, else 8000): every note whole while they fit, else the index and the notes
188
- * changed last, whole, while they fit (learning.ts learnedOf). */
165
+ * default AGENTRUN_SERVE_LEARNING_BUDGET, else 8000): every note whole while they fit, else the notes that bear on
166
+ * the run's input whole and a line for each of the rest (learning.ts learnedParts, its note selector). */
189
167
  learningBudget?: number;
190
168
  /** A test's seam: the triggers' clock and timer (triggers.ts), in place of Date.now and setTimeout. */
191
169
  triggerClock?: TriggerClock;
@@ -460,13 +438,13 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
460
438
  take_over: boolean;
461
439
  ask: boolean;
462
440
  };
463
- /** An agent's browser stays signed in between its runs (sign-ins.ts): with a seal key to keep each pointer under, and a
464
- * browser vendor here (Browserbase's or Kernel's; local Chrome keeps none). */
441
+ /** An agent's browser stays signed in between its runs (sign-ins-store.ts), each pointer sealed under the server's seal
442
+ * key: with a browser vendor here (Browserbase's or Kernel's; local Chrome keeps none). */
465
443
  sign_ins: boolean;
466
444
  vault: boolean;
467
445
  query: boolean;
468
- /** GET, PUT and DELETE /settings/tool-keys: a tool's key saved by name, kept sealed under the launcher's seal key
469
- * (tool-keys.ts); with none handed over, nothing is kept, never in the clear. */
446
+ /** GET, PUT and DELETE /settings/tool-keys: a tool's key saved by name, kept sealed under the server's seal key
447
+ * (tool-keys-store.ts), never in the clear. */
470
448
  tool_keys: {
471
449
  routes: boolean;
472
450
  at_rest: string;
@@ -482,7 +460,7 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
482
460
  /** This server's learning switch (`--learning`): on, a run learns when its agent says `learning: true`; off, none does. */
483
461
  learning: "on" | "off";
484
462
  /** /settings/webhook: one URL POSTed, signed by the Standard Webhooks spec, when a run needs its person and when it
485
- * ends (webhooks.ts); its secret kept sealed under the same seal key, so with none no webhook is set. */
463
+ * ends (webhooks.ts); its secret kept sealed under the same seal key. */
486
464
  webhooks: {
487
465
  routes: boolean;
488
466
  events: ("run.needs_input" | "run.ended" | "trigger.failed")[];
@@ -718,13 +696,13 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
718
696
  take_over: boolean;
719
697
  ask: boolean;
720
698
  };
721
- /** An agent's browser stays signed in between its runs (sign-ins.ts): with a seal key to keep each pointer under, and a
722
- * browser vendor here (Browserbase's or Kernel's; local Chrome keeps none). */
699
+ /** An agent's browser stays signed in between its runs (sign-ins-store.ts), each pointer sealed under the server's seal
700
+ * key: with a browser vendor here (Browserbase's or Kernel's; local Chrome keeps none). */
723
701
  sign_ins: boolean;
724
702
  vault: boolean;
725
703
  query: boolean;
726
- /** GET, PUT and DELETE /settings/tool-keys: a tool's key saved by name, kept sealed under the launcher's seal key
727
- * (tool-keys.ts); with none handed over, nothing is kept, never in the clear. */
704
+ /** GET, PUT and DELETE /settings/tool-keys: a tool's key saved by name, kept sealed under the server's seal key
705
+ * (tool-keys-store.ts), never in the clear. */
728
706
  tool_keys: {
729
707
  routes: boolean;
730
708
  at_rest: string;
@@ -740,7 +718,7 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
740
718
  /** This server's learning switch (`--learning`): on, a run learns when its agent says `learning: true`; off, none does. */
741
719
  learning: "on" | "off";
742
720
  /** /settings/webhook: one URL POSTed, signed by the Standard Webhooks spec, when a run needs its person and when it
743
- * ends (webhooks.ts); its secret kept sealed under the same seal key, so with none no webhook is set. */
721
+ * ends (webhooks.ts); its secret kept sealed under the same seal key. */
744
722
  webhooks: {
745
723
  routes: boolean;
746
724
  events: ("run.needs_input" | "run.ended" | "trigger.failed")[];