@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
package/dist/validate.js CHANGED
@@ -4,9 +4,10 @@ import { HARNESSES } from "./harness.js";
4
4
  import { THINKING_LEVELS } from "./model.js";
5
5
  import { placeIssues } from "./place.js";
6
6
  import { computerIssues, settingConflict } from "./computer-setting.js";
7
- import { AGENT_LAYER_PINS, AGENT_PIN_LATER, settingsIssues } from "./tool-plane.js";
7
+ import { settingsIssues } from "./tool-plane.js";
8
8
  import { CAP_MODES } from "./cap.js";
9
9
  import { APPROVALS } from "./approvals.js";
10
+ import { schemaCheck } from "./answer-json.js";
10
11
  export const ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
11
12
  /** An inline agent's source or kind in its external reference (POST /runs): no colon, which the reference's key splits on. */
12
13
  export const EXTERNAL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
@@ -16,12 +17,13 @@ export const isObject = (value) => typeof value === "object" && value !== null &
16
17
  /** How long an Idempotency-Key answers with its first answer (capabilities' limits.idempotency_ttl_s). */
17
18
  export const IDEMPOTENCY_TTL_S = 86_400;
18
19
  export const stable = (value) => Array.isArray(value) ? `[${value.map(stable).join(",")}]` : isObject(value) ? `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stable(value[k])}`).join(",")}}` : JSON.stringify(value);
19
- export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "cap_mode"];
20
+ export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "cap_mode", "output_schema"];
20
21
  /** Why a field a definition may have elsewhere has no place in an agent store's revision. */
21
22
  export const NOT_KEPT = {
22
23
  input_schema: "The agent store keeps no input_schema: an agentic run takes {content}, and a workflow checks its input against its own schema.",
23
- output_schema: "The agent store keeps no output_schema: a workflow run's output is its workflow's.",
24
24
  };
25
+ /** The most bytes an agent's output_schema takes, as JSON. */
26
+ export const MAX_OUTPUT_SCHEMA_BYTES = 64 * 1024;
25
27
  /** `provider/model-id`. */
26
28
  export const MODEL_REF = /^[^/\s]+\/\S+$/;
27
29
  const SKILL_FILE = "/SKILL.md";
@@ -93,22 +95,29 @@ export function definitionIssues(definition, { at = "definition", creating = tru
93
95
  else if (typeof d.learning !== "boolean")
94
96
  out.push(issue(`${at}.learning`, "wrong_type", `${at}.learning is true or false`));
95
97
  }
98
+ // An agentic revision's structured answer: the JSON Schema its final answer's last fenced json block meets, read into a
99
+ // completed run's result.output (answer-json.ts structuredAnswer). A workflow's output is its workflow's own.
100
+ if (d.output_schema !== undefined) {
101
+ if (d.workflow !== undefined)
102
+ out.push(issue(`${at}.output_schema`, "not_allowed", "A workflow revision keeps no output_schema: its run's output is its workflow's.", `Remove ${at}.output_schema.`));
103
+ else if (!isObject(d.output_schema))
104
+ out.push(issue(`${at}.output_schema`, "wrong_type", `${at}.output_schema is a JSON Schema object`));
105
+ else if (Buffer.byteLength(JSON.stringify(d.output_schema)) > MAX_OUTPUT_SCHEMA_BYTES)
106
+ out.push(issue(`${at}.output_schema`, "too_long", `${at}.output_schema is over ${MAX_OUTPUT_SCHEMA_BYTES} bytes as JSON`));
107
+ else {
108
+ const compiled = schemaCheck(d.output_schema);
109
+ if ("why" in compiled)
110
+ out.push(issue(`${at}.output_schema`, "bad_format", `${at}.output_schema ${compiled.why}`));
111
+ }
112
+ }
96
113
  if (d.skills !== undefined)
97
114
  names(d.skills, `${at}.skills`, out);
98
115
  if (d.tools !== undefined)
99
116
  names(d.tools, `${at}.tools`, out);
100
117
  // The agent's own tool settings, over the server's (tool-plane.ts); an edit that leaves them out keeps none.
101
118
  if (d.tool_settings !== undefined) {
102
- const settings = settingsIssues(d.tool_settings, `${at}.tool_settings`, "agent");
103
- out.push(...settings);
104
- // An agent's own pin, once its store keeps one (AGENT_LAYER_PINS); until then a pin that is one is the server's to set.
105
- if (!AGENT_LAYER_PINS && isObject(d.tool_settings)) {
106
- for (const [name, setting] of Object.entries(d.tool_settings)) {
107
- const field = `${at}.tool_settings.${name}.pin`;
108
- if (isObject(setting) && setting.pin !== undefined && !settings.some((one) => one.field === field || one.field.startsWith(`${field}.`)))
109
- out.push(issue(field, "not_set_up_here", AGENT_PIN_LATER));
110
- }
111
- }
119
+ // An agent's own pin among them, kept as given (the gate holds its runs to it).
120
+ out.push(...settingsIssues(d.tool_settings, `${at}.tool_settings`, "agent"));
112
121
  }
113
122
  // Whether the agent's runs ask a person (the gate as its settings say) or run unattended, an ask allowed: never over a
114
123
  // deny. An edit that leaves it out asks, as one that leaves out tool_settings keeps none: no edit makes an agent
@@ -116,7 +125,7 @@ export function definitionIssues(definition, { at = "definition", creating = tru
116
125
  if (d.approvals !== undefined && !APPROVALS.includes(d.approvals))
117
126
  out.push(issue(`${at}.approvals`, "not_an_option", `${at}.approvals is one of ${APPROVALS.join(", ")}: ask, the default, waits for a person where a tool is set to ask; never runs the agent unattended, each such tool allowed, while a deny still refuses`));
118
127
  // The agent's default cap of each run started without one of its own: above 0 sets it, 0 clears it (no default), and
119
- // an edit that leaves it out keeps the agent's (agents.ts), so leaving a field out never removes a spend limit.
128
+ // an edit that leaves it out keeps the agent's (agents-store.ts), so leaving a field out never removes a spend limit.
120
129
  if (d.max_cost_usd !== undefined) {
121
130
  if (!(typeof d.max_cost_usd === "number" && Number.isFinite(d.max_cost_usd) && d.max_cost_usd >= 0))
122
131
  out.push(issue(`${at}.max_cost_usd`, "wrong_type", `${at}.max_cost_usd is a number of at least 0, in US dollars: above 0 sets the agent's default cap, 0 clears it`));
@@ -1,3 +1,5 @@
1
+ import { type SealedSettingsOverStore, type SettingsSpec } from "./sealed-settings-store.js";
2
+ import type { Settings } from "./store/index.js";
1
3
  import type { TriggerFailed } from "./triggers.js";
2
4
  /** A run's two notices, which runs.ts tells. */
3
5
  export declare const RUN_EVENTS: readonly ["run.needs_input", "run.ended"];
@@ -6,14 +8,22 @@ export declare const WEBHOOK_EVENTS: readonly ["run.needs_input", "run.ended", "
6
8
  /** The message types: a run's two notices, and the test send's. */
7
9
  export declare const MESSAGE_TYPES: readonly ["run.needs_input", "run.ended", "trigger.failed", "webhook.test"];
8
10
  type MessageType = (typeof MESSAGE_TYPES)[number];
9
- export declare const WEBHOOK_FILE = "webhook.json";
10
- export declare const OUTBOX_FILE = "webhook-outbox.json";
11
+ /** The store setting the webhook is kept in: its URL, when its secret was made, and why it is off, if it is. */
12
+ export declare const WEBHOOK_SETTING = "webhook";
13
+ /** The store setting the outbox is kept in: the messages, the last attempts and the ledger, written whole. */
14
+ export declare const OUTBOX_SETTING = "webhook_outbox";
15
+ /** The webhook's signing secret among the server's sealed settings (sealed-settings-store.ts): minted at the first PUT,
16
+ * kept sealed in the store, retired (still cut from what runs say) when it goes. Not a trigger source: its own adapter id. */
17
+ export declare const OUTBOUND_WEBHOOK: {
18
+ readonly id: string;
19
+ readonly settings: SettingsSpec;
20
+ };
11
21
  /** The waits before each try again, after the first at once: the Standard Webhooks schedule, cut at about a day. */
12
22
  export declare const RETRY_MS: readonly number[];
13
23
  /** How many attempts the log keeps, and with them the messages they tried, for a redelivery. */
14
24
  export declare const ATTEMPTS_KEPT = 50;
15
25
  /** What a notice says of its run: never its tools' arguments, its output or its input, which a receiver reads through the API. */
16
- /** What `emit` did with a notice: `queued`, in the outbox on disk (or already there, or counted as sent); `unsaved`,
26
+ /** What `emit` did with a notice: `queued`, in the outbox in the store (or already there, or counted as sent); `unsaved`,
17
27
  * held here only, its outbox write failed; `off`, no webhook set, or one a 410 turned off, so nothing is to be sent;
18
28
  * `closed`, the server is stopping. */
19
29
  export type Emitted = "queued" | "unsaved" | "off" | "closed";
@@ -26,17 +36,6 @@ export type RunNotice = {
26
36
  kind: "question" | "approval" | "stopped" | "budget" | "browser";
27
37
  };
28
38
  };
29
- /** `secret_at`: when the secret was made, its own time (a URL change keeps it); absent in a file from before it was kept. */
30
- type Config = {
31
- url: string;
32
- secret: string;
33
- secret_at?: string;
34
- updated_at: string;
35
- disabled?: {
36
- at: string;
37
- reason: string;
38
- };
39
- };
40
39
  export type Attempt = {
41
40
  webhook_id: string;
42
41
  type: MessageType;
@@ -47,29 +46,45 @@ export type Attempt = {
47
46
  retry_at: string | null;
48
47
  redelivery: boolean;
49
48
  };
50
- /** Whether the secret signs here: sealed, or not, for no seal key now or one it does not open under. */
51
- type Signing = "sealed" | "seal_key_missing" | "unreadable";
52
- export { signatureOf } from "./standard-webhooks.js";
53
- /** Its secret, opened under `key`, or why it is not. */
54
- declare function opened(key: Buffer | undefined, config: Config): {
55
- secret: string;
56
- } | {
57
- signing: Exclude<Signing, "sealed">;
49
+ /** Whether the secret signs here: sealed, or not, for a seal key it does not open under (or damaged). */
50
+ type Signing = "sealed" | "unreadable";
51
+ /** The store slice the webhook reads and writes: its two settings, and the durable commit after each write. */
52
+ export type WebhookStore = {
53
+ readonly settings: Pick<Settings, "get" | "put" | "remove">;
54
+ flush(): Promise<void>;
58
55
  };
59
- /** The signing secret of the webhook data directory `data` keeps, opened with the seal key of `env`, or why it does not
60
- * open (no seal key, or one it was not sealed under); undefined when it keeps none. Read for an import, which cuts it
61
- * out of what it keeps. */
62
- export declare function webhookSecretIn(data: string, env: NodeJS.ProcessEnv): ReturnType<typeof opened> | undefined;
56
+ /** The webhook's secret, among the server's sealed settings (OUTBOUND_WEBHOOK), loaded before the webhook is. */
57
+ export type WebhookSecret = Pick<SealedSettingsOverStore, "get" | "mint" | "remove">;
58
+ export { signatureOf } from "./standard-webhooks.js";
59
+ /** The mark of the wait a run stands at, its webhook-id's marker: one per ask, however often or whenever the run is read,
60
+ * so every read of the same ask makes the same webhook-id. A question's is its waiting row (run-view.ts withAsks: the
61
+ * asked call's result, `:waiting`); an approval's, the call it holds; a budget pause's, its time; a hand-over's, when it
62
+ * was asked; a stop, which waits on no ask, the last row that shows (not usage, a phase or learning's). Never the last
63
+ * row for an ask: a run read between the person's answer and its runner's take of it shows the answer last, and a
64
+ * marker from that row would tell the same ask twice, under two ids. Undefined when there is none. */
65
+ export declare function waitMarkerOf(rows: readonly {
66
+ id: string;
67
+ kind: string;
68
+ agent_label?: string | null;
69
+ }[], pending: {
70
+ kind?: unknown;
71
+ id?: unknown;
72
+ at?: unknown;
73
+ asked_at?: unknown;
74
+ } | null | undefined, waiting: boolean, learningLabel: string): string | undefined;
63
75
  export declare class Webhooks {
76
+ private readonly store;
77
+ private readonly secret;
64
78
  private readonly say;
65
79
  private readonly retryMs;
66
- private readonly file;
67
- private readonly outbox;
68
- private readonly key;
69
80
  private messages;
70
81
  private attempts;
71
82
  /** The ledger, by run: written with the messages, in the same write. */
72
83
  private notices;
84
+ /** The webhook as the store holds it: read at load, then kept with every write (this server is the store's one writer).
85
+ * A write that failed (a 410 that turned it off, on a store that refused the write) leaves it held here as it now is, and
86
+ * the next PUT writes it whole. */
87
+ private current?;
73
88
  /** The runs told of since this server started: their ledger entries are this server's news, which a start's catch-up
74
89
  * never drops. */
75
90
  private readonly told;
@@ -79,29 +94,27 @@ export declare class Webhooks {
79
94
  private readonly trying;
80
95
  private readonly stop;
81
96
  private closed;
82
- /** The outbox as held here is not on disk: its last write failed. Written again soon, and at the close. */
97
+ /** The outbox as held here is not in the store: its last write failed. Written again soon, and at the close. */
83
98
  private unsaved;
84
99
  private saving?;
85
- /** The webhook as held here when its write failed (a 410 that turned it off, on a full disk): read in place of the
86
- * file until a write lands, as the next PUT's does. */
87
- private held?;
100
+ /** The outbox's writes, one after another: each writes the outbox as it stands when its turn comes. */
101
+ private writing;
102
+ /** What reads the webhook and then writes it (a PUT, a DELETE, a try's 410 that turns it off), one after another: each
103
+ * reads it as the last one left it, so a 410 never turns off a webhook a PUT set again meanwhile. */
104
+ private changing;
105
+ /** A DELETE under way: no notice is queued meanwhile, so none slips past its drop of the pending messages. */
106
+ private removing;
88
107
  /** The messages with a try in flight, by id, and how many: kept in the outbox until each lands, so one whose earlier
89
108
  * attempts left the log meanwhile can still be redelivered. */
90
109
  private readonly sending;
91
- /** `env` is the server's own (withSecrets); `say` takes a log line's fields; `retryMs` the waits between tries. */
92
- constructor(data: string, env: NodeJS.ProcessEnv, say: (fields: Record<string, string | number>) => void, retryMs?: readonly number[]);
110
+ /** `store` keeps the webhook and its outbox, `secret` its signing secret (the server's sealed settings for
111
+ * OUTBOUND_WEBHOOK, loaded); `say` takes a log line's fields; `retryMs` the waits between tries. load() before use. */
112
+ constructor(store: WebhookStore, secret: WebhookSecret, say: (fields: Record<string, string | number>) => void, retryMs?: readonly number[]);
113
+ /** Reads the webhook and the outbox as the last server left them, and goes on with the messages it left pending, each at
114
+ * its next try's time; a test send is tried once, so one left in flight failed. Awaited once, before anything else. */
115
+ load(): Promise<void>;
93
116
  /** Where the page is, for each notice's link to its run. */
94
117
  attach(base: string): void;
95
- /** The secret, opened here, and each one this server held before it since it started (removed by a DELETE, or
96
- * replaced), for the server's list of its own secrets (server-secrets.ts): a run that echoes an old one is cut all the
97
- * same. None that is not there, or does not open. */
98
- signingSecrets(): string[];
99
- /** The secrets this webhook signed with before, in memory alone, for this process's life. */
100
- private readonly retired;
101
- /** The secret, opened here; undefined when there is none, or it does not open. */
102
- private signingSecret;
103
- /** signingSecret's last reading: read again after any write of the webhook's file, which only this server makes. */
104
- private signing?;
105
118
  /** GET: the URL, whether the secret signs here, and why the webhook is off, if it is; its secret's metadata (secret-writes.ts
106
119
  * SecretMeta), never the secret. */
107
120
  view(): {
@@ -122,34 +135,36 @@ export declare class Webhooks {
122
135
  } | null;
123
136
  updated_at: string;
124
137
  };
125
- /** PUT: the URL, and the webhook on again. The first makes the secret and answers it, once; a later one keeps it. */
126
- save(body: Record<string, unknown>): {
138
+ /** PUT: the URL, and the webhook on again. The first makes the secret and answers it, once; a later one keeps it, or
139
+ * makes a new one (answered once) when the one kept does not open under this server's seal key. */
140
+ save(body: Record<string, unknown>): Promise<{
127
141
  created: boolean;
128
142
  view: ReturnType<Webhooks["view"]>;
129
143
  secret?: string;
130
- };
131
- /** DELETE: the webhook gone, and its pending messages with it; the log of attempts stays. */
132
- remove(): void;
144
+ }>;
145
+ /** DELETE: the webhook gone, its secret with it (retired: still cut from what a run says), and its pending messages; the
146
+ * log of attempts stays. */
147
+ remove(): Promise<void>;
133
148
  /** GET .../deliveries: the last attempts, newest first. */
134
149
  attemptsView(): {
135
150
  attempts: Attempt[];
136
151
  };
137
- /** A run's moment, told by runs.ts each time it sees it (a wait reached, an end the agent store has): queued once, when
138
- * a webhook is set and on, and kept in the ledger in the same write. `marker` makes its webhook-id: the same moment,
139
- * seen again after a restart, has the same id, which is a receiver's idempotency key. An end before the webhook was
140
- * set, or past the outbox's day, counts as sent. */
141
- emit(type: (typeof RUN_EVENTS)[number], run: RunNotice, marker: string): Emitted;
152
+ /** A run's moment, told by the server each time it sees it (a wait reached, an end the store has): queued once, when a
153
+ * webhook is set and on, and kept in the ledger in the same write. `marker` makes its webhook-id: the same moment, seen
154
+ * again after a restart, has the same id, which is a receiver's idempotency key. An end before the webhook was set, or
155
+ * past the outbox's day, counts as sent. */
156
+ emit(type: (typeof RUN_EVENTS)[number], run: RunNotice, marker: string): Promise<Emitted>;
142
157
  /** A trigger's failed firing (triggers.ts), queued once: its webhook-id is made from the firing's key, so the same
143
158
  * failure told again, by a later server too, is the same message. Its trigger keeps whether it was queued. */
144
- emitTrigger(failed: TriggerFailed, firingKey: string): Emitted;
145
- /** A start's catch-up, once its runs are read (`rows`, the agent store's: a row with no state is an ended one). First,
146
- * before anything is awaited, the ledger as the store now stands: a run the store no longer has goes, and a wait of a
147
- * run it holds as ended goes (an end the webhook was off for never moved it past). Then each end the store holds that
148
- * the ledger does not, and that is still due, is queued under the store's end time, so under the same webhook-id: its
149
- * server was killed between the store's end and the outbox write, or that write never reached the disk. `current`
150
- * reads the run as the store holds it right before its end is queued, with its notice (null: no such run now). The
151
- * server takes requests meanwhile, so a run continued since the rows were read has moved past that end, which was
152
- * queued before it could be continued: its end is not queued again. */
159
+ emitTrigger(failed: TriggerFailed, firingKey: string): Promise<Emitted>;
160
+ /** A start's catch-up, once its runs are read (`rows`, the store's: a row with no state is an ended one). First, before
161
+ * anything is awaited, the ledger as the store now stands: a run the store no longer has goes, and a wait of a run it
162
+ * holds as ended goes (an end the webhook was off for never moved it past). Then each end the store holds that the
163
+ * ledger does not, and that is still due, is queued under the store's end time, so under the same webhook-id: its
164
+ * server was killed between the run's end and the outbox write, or that write never landed. `current` reads the run as
165
+ * the store holds it right before its end is queued, with its notice (null: no such run now). The server takes
166
+ * requests meanwhile, so a run continued since the rows were read has moved past that end, which was queued before it
167
+ * could be continued: its end is not queued again. */
153
168
  catchUp(rows: Iterable<{
154
169
  id: string;
155
170
  state?: string;
@@ -163,28 +178,39 @@ export declare class Webhooks {
163
178
  test(): Promise<Attempt>;
164
179
  /** POST .../deliveries/{webhook_id}/redeliver: the message sent again once now, under its own webhook-id and body. */
165
180
  redeliver(id: string): Promise<Attempt>;
166
- /** Stops: no try starts, those in flight are cut and waited for, and nothing more is written. A message cut here is
167
- * still pending on disk, for the next server (its receiver may get it twice, under the same webhook-id). */
181
+ /** Stops: no try starts, those in flight are cut and waited for, and nothing more is written but what a failed write left
182
+ * only here. A message cut here is still pending in the store, for the next server (its receiver may get it twice,
183
+ * under the same webhook-id). Before the store closes. */
168
184
  close(): Promise<void>;
169
185
  private config;
170
- /** Throws when the write fails: what was held stays held. */
186
+ /** Whether what is held here is in the store: once every outbox write asked for so far has settled (each writes it
187
+ * whole), `queued` when the last one landed, else `unsaved`. A moment told again while its first write is still in
188
+ * flight waits for it, never answering `queued` before it lands. */
189
+ private landed;
190
+ /** `work`, once every change of the webhook asked for before it has settled, failed or not. */
191
+ private change;
192
+ /** The signing secret, opened here; undefined when there is none, or it does not open under this server's seal key. */
193
+ private signingSecret;
194
+ /** Throws when the write fails: the webhook as held here stays as it was. */
171
195
  private write;
172
- /** The outbox as the last server left it. A file of another version is not read, and the log says which it was. */
173
- private readOutbox;
196
+ /** The outbox as the last server left it. One of another version is not read, and the log says which it was. */
197
+ private outboxOf;
174
198
  /** Whether an end's run.ended is still to be queued: at or after the webhook was set and the outbox's day began (a
175
199
  * marker that names no time is not judged by one). The catch-up and the ledger's pruning read the same line, so the
176
200
  * ledger never forgets an end a start would look for. */
177
201
  private due;
178
- /** The ledger without what no start looks for: a run whose end is no longer due goes, with the wait it ended past. A
179
- * wait with no end after it stays while the run stands at it, however long: never pruned by age, so the same question
202
+ /** The ledger without what no start looks for: a run whose end is no longer due goes, with the waits it ended past.
203
+ * Waits with no end after them stay while the run stands at it, however long: never pruned by age, so the same question
180
204
  * is never asked again. */
181
205
  private prune;
206
+ /** The outbox written, after every write asked for before it; whether it landed. One that failed is kept here and
207
+ * written again until a write lands (or the close writes it). Closed, nothing is written: the store may be the next
208
+ * server's already. */
182
209
  private writeOutbox;
183
- /** The outbox written whole: the last attempts, and the messages pending or tried by one of those (a redelivery sends
184
- * one again). False when the write failed, which the log says once until one lands. */
185
- private store;
186
- /** The secret, opened, or why it is not. */
187
- private secret;
210
+ /** The outbox written whole, in one durable commit: the last attempts, and the messages pending or tried by one of
211
+ * those (a redelivery sends one again). False when the write failed, which the log says once until one lands. */
212
+ private persist;
213
+ /** A new pending message, and its outbox write (whether it landed). */
188
214
  private enqueue;
189
215
  private schedule;
190
216
  private attempt;