@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
@@ -2,6 +2,7 @@ import type { InputIssue } from "./errors.js";
2
2
  import type { Settings } from "./store/index.js";
3
3
  import { type HarnessId } from "./harness.js";
4
4
  import { type Permission, type Pin } from "./tool-gate.js";
5
+ import { type BashPolicy } from "./bash-read-only.js";
5
6
  /**
6
7
  * The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
7
8
  * table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
@@ -53,19 +54,13 @@ export declare const KIND_KEYS: readonly string[];
53
54
  export type ToolSetting = {
54
55
  provider?: string;
55
56
  permission?: Permission;
56
- pin?: Pin; /** Read as a stand-in for a value not offered (readToolSettings); never shown or written. */
57
+ pin?: Pin; /** bash's policy, an agent's own only (bash-read-only.ts). */
58
+ policy?: BashPolicy; /** Read as a stand-in for a value not offered (checkToolSettings); never shown or written. */
57
59
  fallback?: true; /** The stand-in's value as written in the file, which a save that keeps the stand-in writes back (ToolSettings.put). Never shown. */
58
60
  raw?: unknown; /** A pin in the file that does not read (readToolSettings): the gate refuses every call of the tool, and a save keeps it (ToolSettings.put) until the owner sets a valid pin or removes the tool's setting. Served as `pin_broken: true`. */
59
61
  brokenPin?: true; /** The broken pin as written in the file, which a save that keeps it writes back. Never shown. */
60
62
  rawPin?: unknown;
61
63
  };
62
- /** Whether an agent's own settings (definition.tool_settings) keep a pin. Not yet: the agent store this server writes
63
- * today keeps a setting's values as names only, and refuses a pin; the store of the rewrite (store/, module A) keeps it
64
- * as given, and this is true from its cutover on. Until then a pin is set on the server (PUT /v2/settings/tools), which
65
- * the gate holds every run to; the gate reads an agent's pin wherever a revision carries one. */
66
- export declare const AGENT_LAYER_PINS: boolean;
67
- /** Why an agent's own pin is refused while AGENT_LAYER_PINS is false. */
68
- export declare const AGENT_PIN_LATER = "An agent's own pin is kept once this server's agent store takes it (the store cutover). Until then set the pin on this server, PUT /v2/settings/tools (Settings \u2192 Tools), which the tool gate holds every run to.";
69
64
  /** The longest pinned string. */
70
65
  export declare const MAX_PIN_TEXT = 1024;
71
66
  /** The one check of a pin, every place that takes one calls it (the server's settings, an agent's, a template's mcp
@@ -215,7 +210,7 @@ export declare const handsParallel: (plane: Plane) => boolean;
215
210
  * table, a catalog tool, an MCP server's wildcard) to `{provider?, permission?}`, a provider only for a capability that
216
211
  * has a choice and one offered for it, a permission one offered for the tool. */
217
212
  export declare function settingsIssues(value: unknown, at?: string, layer?: "server" | "agent"): InputIssue[];
218
- /** `map` as a revision body keeps it: each tool's provider, permission and pin as written (never a stand-in's internal
213
+ /** `map` as a revision body keeps it: each tool's provider, permission, pin and policy as written (never a stand-in's internal
219
214
  * marks), tools, fields and a pin's arguments sorted, and a tool with none of them gone. The one form, so two
220
215
  * revisions whose settings say the same (a pin's arguments in another order) are the same text, and so one revision
221
216
  * where its id is the body's digest (the store keeps the body as given: store/sqlite/store.ts). */
@@ -225,12 +220,9 @@ export declare const withDefaults: (map: ToolSettingsMap) => ToolSettingsMap & R
225
220
  provider: string;
226
221
  permission?: Permission;
227
222
  }>;
228
- /** The tool settings in `dir` as the server and the tool gate read them, failing closed: each entry that reads is kept;
229
- * one that does not is dropped, but a known tool keeps what of it reads, and its permission, when not one offered,
230
- * reads ask (deny where ask is not offered), never its allow default. `problems`: one line for each entry dropped or
231
- * changed, naming the file and the field, never a value. `unreadable`: the file as a whole does not read (none, a
232
- * missing file is every default). */
233
- export declare function readToolSettings(dir: string): {
223
+ /** The server's tool settings as read (checkToolSettings, loadToolSettings): the map, a line for each problem, and whether
224
+ * the stored value as a whole does not read. */
225
+ export type ToolSettingsRead = {
234
226
  settings: ToolSettingsMap;
235
227
  problems: string[];
236
228
  unreadable?: true;
@@ -246,18 +238,14 @@ export declare function checkToolSettings(read: unknown, where: string): {
246
238
  };
247
239
  /** The key the server's tool settings live under in the one store (store.settings). */
248
240
  export declare const TOOL_SETTINGS_KEY = "tool-settings";
249
- /** The server's tool settings read from the one store (store.settings), failing closed as readToolSettings does: no row
250
- * is every default. The store-backed replacement for `new ToolSettings(dir)` + get(); the cut wires it. */
241
+ /** The server's tool settings read from the one store (store.settings), failing closed (checkToolSettings): no row is
242
+ * every default. */
251
243
  export declare function loadToolSettings(store: {
252
244
  settings: Pick<Settings, "get">;
253
- }): Promise<{
254
- settings: ToolSettingsMap;
255
- problems: string[];
256
- unreadable?: true;
257
- }>;
245
+ }): Promise<ToolSettingsRead>;
258
246
  /** A save of the server's tool settings: `map` (a tool it leaves out takes its defaults) over the settings read before it
259
247
  * (`current`), as kept (the marks within) and as written (the raw values, which a read turns back into those marks).
260
- * The one rule both writers keep (ToolSettings.put to the file, saveToolSettings to the store), so they cannot drift:
248
+ * The rule saveToolSettings keeps:
261
249
  * - a pin is kept as given, as a pin is a gate fence (tool-gate.ts pinRefusal);
262
250
  * - a broken pin (one that did not read) is kept by every save that keeps the tool's key and sets no pin of its own (a
263
251
  * console's whole map sends the key back, marked pin_broken): only a valid pin, or the key left out, clears it, so an
@@ -269,28 +257,12 @@ export declare function keptSettings(map: ToolSettingsMap, current: ToolSettings
269
257
  kept: ToolSettingsMap;
270
258
  written: Record<string, Record<string, unknown>>;
271
259
  };
272
- /** Replaces the server's tool settings in the one store, as ToolSettings.put does to the file, by the same rule
273
- * (keptSettings): a tool `map` leaves out takes its defaults, a pin is kept, a broken pin is kept until a valid one or the
274
- * key left out clears it, and a stand-in sent back unchanged stays a stand-in. Answers the settings as served (the marks
275
- * within). The store-backed replacement for ToolSettings.put; the cut wires it. */
260
+ /** Replaces the server's tool settings in the one store, by keptSettings's rule: a tool `map` leaves out takes its
261
+ * defaults, a pin is kept, a broken pin is kept until a valid one or the key left out clears it, and a stand-in sent
262
+ * back unchanged stays a stand-in. Answers the settings as served (the marks within). */
276
263
  export declare function saveToolSettings(store: {
277
264
  settings: Pick<Settings, "get" | "put">;
278
265
  }, map: ToolSettingsMap): Promise<ToolSettingsMap>;
279
- export declare class ToolSettings {
280
- private readonly dir;
281
- static readonly FILE = "tool-settings.json";
282
- private current;
283
- /** The file was present but did not read at the start: every tool takes its defaults until a PUT replaces it. */
284
- private unread;
285
- constructor(dir: string, warn?: (line: string) => void);
286
- /** The settings now. While the file does not read, the map carries SETTINGS_UNREAD (tool-gate.ts), so wherever it goes
287
- * (the gate's permission, the plane's providers, an agent's tools, a save's blockers) approvals "never" lifts no ask
288
- * over a deny the file may hold, as the gate itself fails closed. */
289
- get(): ToolSettingsMap;
290
- /** Replaces the settings: a tool `map` leaves out takes its defaults; pins, broken pins and stand-ins by the one rule
291
- * the store's save keeps too (keptSettings). Durable before it returns. */
292
- put(map: ToolSettingsMap): ToolSettingsMap;
293
- }
294
266
  /** GET /v2/agents/{id}'s `tools`: each tool its current revision grants, in `order` (capabilities.tools'), with its
295
267
  * permission in force and where it came from (the agent's own settings, the server's, or the default), the one that
296
268
  * applies when the agent sets none (the server's, else the default) and those it may be set to; and for one with a
@@ -20,18 +20,15 @@
20
20
  // told a deny: its Plane resolves a denied capability as under ask, and the gate, which reads the permission at each
21
21
  // call, is the one place that refuses it, so a deny lifted mid-run is lifted at the next call.
22
22
  import { blurbOf } from "./tool-blurbs.js";
23
- import { readFileSync } from "node:fs";
24
- import { isToolSettingsKey } from "@parcha/pi-durable-agent";
25
- import { join } from "node:path";
26
23
  import { decisionKeysOf, PARALLEL_KEY_ENV } from "./decisions.js";
27
24
  import { keyNeeded } from "./key-words.js";
28
- import { writeDurableSync } from "./server-fs.js";
29
25
  import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
30
26
  import { builtinHarness, harnessOf } from "./harness-table.js";
31
27
  import { viaOpenRouter, WIRES } from "./provider.js";
32
28
  import { savedIn } from "./secrets.js";
33
29
  import { hostModel } from "./model.js";
34
30
  import { canonicalPin, defaultPermission, isCatalogTool, isMcpTool, MAX_PIN_ARGS, MAX_PIN_CHOICES, PERMISSIONS, permissionFrom, permissionOf, SETTINGS_UNREAD, SHELL_FAMILY } from "./tool-gate.js";
31
+ import { BASH_POLICIES } from "./bash-read-only.js";
35
32
  /**
36
33
  * The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
37
34
  * table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
@@ -71,14 +68,11 @@ export const KIND_KEYS = ["desktop", "phone"];
71
68
  /** A settings key: a tool of the table, one of the run's own tools (SERVE_OWN_TOOLS), a computer kind's (KIND_KEYS), a
72
69
  * catalog tool (`monid.<tool>`, `mcp:<server>/<tool>`), or an MCP server's wildcard (`mcp:<server>/*`), which sets each
73
70
  * of its tools. */
71
+ /** A tool's name in an agent's or the server's tool settings: a plain name, a catalog's tool (`monid.discover`), an MCP
72
+ * server's tool (`mcp:<server>/<tool>`) or its wildcard (`mcp:<server>/*`). */
73
+ const TOOL_KEY = /^(?:[a-z][a-z0-9_-]{0,63}(?:\.[A-Za-z0-9_-]{1,64})?|mcp:[A-Za-z0-9_.-]{1,64}\/(?:\*|[A-Za-z0-9_.-]{1,128}))$/;
74
+ const isToolSettingsKey = (name) => TOOL_KEY.test(name);
74
75
  const isSettingsKey = (name) => isToolSettingsKey(name) && (TABLE_TOOLS.includes(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || isCatalogTool(name) || /^mcp:[^/]+\/\*$/.test(name));
75
- /** Whether an agent's own settings (definition.tool_settings) keep a pin. Not yet: the agent store this server writes
76
- * today keeps a setting's values as names only, and refuses a pin; the store of the rewrite (store/, module A) keeps it
77
- * as given, and this is true from its cutover on. Until then a pin is set on the server (PUT /v2/settings/tools), which
78
- * the gate holds every run to; the gate reads an agent's pin wherever a revision carries one. */
79
- export const AGENT_LAYER_PINS = true;
80
- /** Why an agent's own pin is refused while AGENT_LAYER_PINS is false. */
81
- export const AGENT_PIN_LATER = "An agent's own pin is kept once this server's agent store takes it (the store cutover). Until then set the pin on this server, PUT /v2/settings/tools (Settings → Tools), which the tool gate holds every run to.";
82
76
  /** The longest pinned string. */
83
77
  export const MAX_PIN_TEXT = 1024;
84
78
  /** A pinned argument's name: a top-level argument of the tool, as MCP tools name theirs. */
@@ -357,10 +351,16 @@ export function settingsIssues(value, at = "", layer = "server") {
357
351
  if (!isSettingsKey(name))
358
352
  return [{ field: field(name), reason: "not_allowed", message: `Tool settings are kept for this server's tools (${[...TABLE_TOOLS, ...SERVE_OWN_TOOLS, ...KIND_KEYS].join(", ")}), catalog tools (monid.<tool>, mcp:<server>/<tool>) and an MCP server's tools (mcp:<server>/*); ${name} is none of them.` }];
359
353
  if (!isPlain(setting))
360
- return [{ field: field(name), reason: "wrong_type", message: `${field(name)} is an object, {${pickable ? "provider, " : ""}permission${isMcpTool(name) ? ", pin" : ""}}` }];
354
+ return [{ field: field(name), reason: "wrong_type", message: `${field(name)} is an object, {${pickable ? "provider, " : ""}permission${isMcpTool(name) ? ", pin" : ""}${layer === "agent" && name === "bash" ? ", policy" : ""}}` }];
361
355
  return Object.entries(setting).flatMap(([key, given]) => {
362
356
  if (key === "pin")
363
357
  return pinIssues(given, field(name, key), name);
358
+ // bash's policy (bash-read-only.ts): an agent's own, on bash's key only, as what its commands may do is the agent's.
359
+ if (key === "policy") {
360
+ if (layer !== "agent" || name !== "bash")
361
+ return [{ field: field(name, key), reason: "not_allowed", message: `A policy is set on bash in an agent's own tool settings (definition.tool_settings.bash.policy), never ${layer === "agent" ? `on ${name}` : "in the server's"}.` }];
362
+ return BASH_POLICIES.includes(given) ? [] : [{ field: field(name, key), reason: "not_an_option", message: `${field(name, key)} is one of ${BASH_POLICIES.join(", ")}: read-only refuses, before it runs, any command that could write, run code or read outside the run's folder` }];
363
+ }
364
364
  // The server's own mark of a pin in its file that does not read (withDefaults serves it), which a whole-map save
365
365
  // sends back: it keeps the broken pin, and nothing else. Never an agent's.
366
366
  if (key === "pin_broken") {
@@ -380,7 +380,7 @@ export function settingsIssues(value, at = "", layer = "server") {
380
380
  });
381
381
  });
382
382
  }
383
- /** `map` as a revision body keeps it: each tool's provider, permission and pin as written (never a stand-in's internal
383
+ /** `map` as a revision body keeps it: each tool's provider, permission, pin and policy as written (never a stand-in's internal
384
384
  * marks), tools, fields and a pin's arguments sorted, and a tool with none of them gone. The one form, so two
385
385
  * revisions whose settings say the same (a pin's arguments in another order) are the same text, and so one revision
386
386
  * where its id is the body's digest (the store keeps the body as given: store/sqlite/store.ts). */
@@ -389,7 +389,7 @@ export function canonicalToolSettings(map) {
389
389
  return sorted(Object.fromEntries(Object.entries(map).flatMap(([name, setting]) => {
390
390
  if (!setting)
391
391
  return [];
392
- const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
392
+ const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.policy ? { policy: setting.policy } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
393
393
  return Object.keys(kept).length ? [[name, kept]] : [];
394
394
  })));
395
395
  }
@@ -399,31 +399,9 @@ export const withDefaults = (map) => ({
399
399
  ...Object.fromEntries(Object.entries(map).map(([name, setting]) => [name, setting && { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: setting.pin } : {}), ...(setting.brokenPin ? { pin_broken: true } : {}) }])),
400
400
  ...Object.fromEntries(PICKABLE.map((name) => [name, { provider: map[name]?.provider ?? PROVIDERS[name][0], ...(map[name]?.permission ? { permission: map[name].permission } : {}) }])),
401
401
  });
402
- /** The server's tool settings, beside the agent store in its data directory: not a secret, and not in store.sqlite,
403
- * which runs hold open. Read once at the start, written whole and durably (0600) at each PUT; a missing file is every
404
- * default, and so is one it cannot read, which it says in one line. */
405
- /** An empty settings map marked as standing for a file that does not read (SETTINGS_UNREAD, tool-gate.ts): every caller of
406
- * readToolSettings inherits the mark, a direct read too (learning's draft check, the learned-draft tools), so none lifts an
407
- * ask over a file whose deny it cannot see. */
402
+ /** An empty settings map marked as standing for settings that do not read (SETTINGS_UNREAD, tool-gate.ts): every reader
403
+ * inherits the mark, so none lifts an ask over settings whose deny it cannot see. */
408
404
  const unreadMap = () => Object.assign({}, { [SETTINGS_UNREAD]: true });
409
- /** The tool settings in `dir` as the server and the tool gate read them, failing closed: each entry that reads is kept;
410
- * one that does not is dropped, but a known tool keeps what of it reads, and its permission, when not one offered,
411
- * reads ask (deny where ask is not offered), never its allow default. `problems`: one line for each entry dropped or
412
- * changed, naming the file and the field, never a value. `unreadable`: the file as a whole does not read (none, a
413
- * missing file is every default). */
414
- export function readToolSettings(dir) {
415
- const file = join(dir, ToolSettings.FILE);
416
- let read;
417
- try {
418
- read = JSON.parse(readFileSync(file, "utf8"));
419
- }
420
- catch (error) {
421
- if (error.code === "ENOENT")
422
- return { settings: {}, problems: [] };
423
- return { settings: unreadMap(), problems: [`${file} does not read as JSON`], unreadable: true };
424
- }
425
- return checkToolSettings(read, file);
426
- }
427
405
  /** A parsed tool-settings object (from the file, or the store), checked and failed closed: each entry that reads is kept;
428
406
  * one that does not is dropped, but a known tool keeps what of it reads, and its permission, when not one offered, reads
429
407
  * ask (deny where ask is not offered), never its allow default. `where` names the source in each problem line (the file's
@@ -472,15 +450,14 @@ export function checkToolSettings(read, where) {
472
450
  }
473
451
  /** The key the server's tool settings live under in the one store (store.settings). */
474
452
  export const TOOL_SETTINGS_KEY = "tool-settings";
475
- /** The server's tool settings read from the one store (store.settings), failing closed as readToolSettings does: no row
476
- * is every default. The store-backed replacement for `new ToolSettings(dir)` + get(); the cut wires it. */
453
+ /** The server's tool settings read from the one store (store.settings), failing closed (checkToolSettings): no row is
454
+ * every default. */
477
455
  export async function loadToolSettings(store) {
478
456
  const read = await store.settings.get(TOOL_SETTINGS_KEY);
479
457
  if (read === undefined)
480
458
  return { settings: {}, problems: [] };
481
459
  const checked = checkToolSettings(read, "the stored tool settings");
482
- // A stored row that does not read carries SETTINGS_UNREAD (tool-gate.ts), as ToolSettings.get does for the file: wherever
483
- // these settings go (the plane's providers, an agent's tools, a save's blockers) approvals "never" lifts no ask over a
460
+ // A stored row that does not read carries SETTINGS_UNREAD (tool-gate.ts): wherever these settings go (the plane's providers, an agent's tools, a save's blockers) approvals "never" lifts no ask over a
484
461
  // deny the row may hold. A save over it (saveToolSettings) writes a row that reads.
485
462
  if (checked.unreadable)
486
463
  checked.settings[SETTINGS_UNREAD] = true;
@@ -488,7 +465,7 @@ export async function loadToolSettings(store) {
488
465
  }
489
466
  /** A save of the server's tool settings: `map` (a tool it leaves out takes its defaults) over the settings read before it
490
467
  * (`current`), as kept (the marks within) and as written (the raw values, which a read turns back into those marks).
491
- * The one rule both writers keep (ToolSettings.put to the file, saveToolSettings to the store), so they cannot drift:
468
+ * The rule saveToolSettings keeps:
492
469
  * - a pin is kept as given, as a pin is a gate fence (tool-gate.ts pinRefusal);
493
470
  * - a broken pin (one that did not read) is kept by every save that keeps the tool's key and sets no pin of its own (a
494
471
  * console's whole map sends the key back, marked pin_broken): only a valid pin, or the key left out, clears it, so an
@@ -509,50 +486,15 @@ export function keptSettings(map, current) {
509
486
  const written = Object.fromEntries(Object.entries(kept).map(([name, setting]) => [name, { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.fallback ? { permission: setting.raw } : setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: setting.pin } : setting.brokenPin ? { pin: setting.rawPin } : {}) }]));
510
487
  return { kept, written };
511
488
  }
512
- /** Replaces the server's tool settings in the one store, as ToolSettings.put does to the file, by the same rule
513
- * (keptSettings): a tool `map` leaves out takes its defaults, a pin is kept, a broken pin is kept until a valid one or the
514
- * key left out clears it, and a stand-in sent back unchanged stays a stand-in. Answers the settings as served (the marks
515
- * within). The store-backed replacement for ToolSettings.put; the cut wires it. */
489
+ /** Replaces the server's tool settings in the one store, by keptSettings's rule: a tool `map` leaves out takes its
490
+ * defaults, a pin is kept, a broken pin is kept until a valid one or the key left out clears it, and a stand-in sent
491
+ * back unchanged stays a stand-in. Answers the settings as served (the marks within). */
516
492
  export async function saveToolSettings(store, map) {
517
493
  const { settings: current } = await loadToolSettings(store);
518
494
  const { kept, written } = keptSettings(map, current);
519
495
  await store.settings.put(TOOL_SETTINGS_KEY, written);
520
496
  return structuredClone(kept);
521
497
  }
522
- export class ToolSettings {
523
- dir;
524
- static FILE = "tool-settings.json";
525
- current;
526
- /** The file was present but did not read at the start: every tool takes its defaults until a PUT replaces it. */
527
- unread;
528
- constructor(dir, warn = (line) => void process.stderr.write(`${line}\n`)) {
529
- this.dir = dir;
530
- const { settings, problems, unreadable } = readToolSettings(dir);
531
- for (const line of problems)
532
- warn(`agentrun-serve: ${line}; ${unreadable ? "every tool takes its defaults" : "that entry is dropped (a permission that is not offered reads ask)"} until a PUT /v2/settings/tools`);
533
- this.current = settings;
534
- this.unread = unreadable === true;
535
- }
536
- /** The settings now. While the file does not read, the map carries SETTINGS_UNREAD (tool-gate.ts), so wherever it goes
537
- * (the gate's permission, the plane's providers, an agent's tools, a save's blockers) approvals "never" lifts no ask
538
- * over a deny the file may hold, as the gate itself fails closed. */
539
- get() {
540
- const map = structuredClone(this.current);
541
- if (this.unread)
542
- map[SETTINGS_UNREAD] = true;
543
- return map;
544
- }
545
- /** Replaces the settings: a tool `map` leaves out takes its defaults; pins, broken pins and stand-ins by the one rule
546
- * the store's save keeps too (keptSettings). Durable before it returns. */
547
- put(map) {
548
- const { kept, written } = keptSettings(map, this.current);
549
- writeDurableSync(join(this.dir, ToolSettings.FILE), `${JSON.stringify(written)}\n`);
550
- this.current = kept;
551
- // The file is the one just written: it reads.
552
- this.unread = false;
553
- return this.get();
554
- }
555
- }
556
498
  /** GET /v2/agents/{id}'s `tools`: each tool its current revision grants, in `order` (capabilities.tools'), with its
557
499
  * permission in force and where it came from (the agent's own settings, the server's, or the default), the one that
558
500
  * applies when the agent sets none (the server's, else the default) and those it may be set to; and for one with a
@@ -25,6 +25,5 @@ declare class ToolSettingsOverStore {
25
25
  put(map: ToolSettingsMap): Promise<ToolSettingsMap>;
26
26
  }
27
27
  export type { ToolSettingsOverStore };
28
- /** The ToolSettings surface over the one store: the switch swaps `new ToolSettings(dir)` for this, then awaits load() once
29
- * at start before the first get(). */
28
+ /** The server's tool settings over the one store: the server awaits load() once at start, before the first get(). */
30
29
  export declare function toolSettingsOverStore(store: ToolSettingsStore, warn?: (line: string) => void): ToolSettingsOverStore;
@@ -1,9 +1,7 @@
1
- // The server's tool settings over the one store (store.settings), the store-backed replacement for the ToolSettings class
2
- // (tool-plane.ts) that read and wrote tool-settings.json. It keeps the same surface the server calls: a synchronous get()
3
- // off an in-memory snapshot the server (the one writer of this row) loads once at start and keeps in step with every
4
- // put(), and a put() that returns the settings as served. put() returns a promise the handler awaits (durable before the
5
- // 204, as writeDurableSync was). The read and write go through loadToolSettings / saveToolSettings; this layer is
6
- // only the snapshot and the sync surface the switch swaps `new ToolSettings(dir)` for.
1
+ // The server's tool settings over the one store (store.settings): a synchronous get() off an in-memory snapshot the server
2
+ // (the one writer of this row) loads once at start and keeps in step with every put(), and a put() that returns the
3
+ // settings as served, durable before the handler's answer. The read and write go through loadToolSettings /
4
+ // saveToolSettings; this layer is only the snapshot and the sync surface.
7
5
  import { SETTINGS_UNREAD } from "./tool-gate.js";
8
6
  import { loadToolSettings, saveToolSettings } from "./tool-plane.js";
9
7
  class ToolSettingsOverStore {
@@ -46,8 +44,7 @@ class ToolSettingsOverStore {
46
44
  return this.get();
47
45
  }
48
46
  }
49
- /** The ToolSettings surface over the one store: the switch swaps `new ToolSettings(dir)` for this, then awaits load() once
50
- * at start before the first get(). */
47
+ /** The server's tool settings over the one store: the server awaits load() once at start, before the first get(). */
51
48
  export function toolSettingsOverStore(store, warn = (line) => void process.stderr.write(`${line}\n`)) {
52
49
  return new ToolSettingsOverStore(store, warn);
53
50
  }
package/dist/tools.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { TSchema } from "typebox";
2
2
  import { type Extension, type Harness, type ToolRegistration, type Tx } from "@earendil-works/pi-durable";
3
- import type { AppContext } from "@parcha/pi-durable-disk";
4
- import type { Revision } from "@parcha/pi-durable-agent";
5
- import type { CodingSource } from "./coding-tools.js";
3
+ import type { Revision } from "./agent-rows.js";
6
4
  import { type Workspace } from "./workspace/index.js";
5
+ import type { ClaimBrowser } from "./workspace/resolve-computer.js";
7
6
  import { type Complete } from "./llm.js";
8
7
  import { type Ledger, type PaidBooking } from "./paid-calls.js";
9
8
  import type { Refusal } from "@parcha/agentrun-kernel";
9
+ import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
10
10
  import { type Plane, type Tooling, type ToolSettingsMap } from "./tool-plane.js";
11
11
  import type { DenyFrom, SettingFrom } from "./tool-gate.js";
12
12
  import type { LiveHandover, LiveViewerStore } from "./browser-live.js";
@@ -23,13 +23,19 @@ export declare const FAUX_VENDOR_API_ENV = "AGENTRUN_SERVE_FAUX_VENDOR_API";
23
23
  /** What the result of `ask_person` says; the person's page shows the question as a waiting row. */
24
24
  export declare const asked: (question: string) => string;
25
25
  export declare const askPerson: ToolRegistration<TSchema, import("@earendil-works/chord").JsonValue>;
26
+ /** Where a run's tools are bound: the run, by its id, its folder and the folder its tools work in. */
27
+ export type RunWhere = {
28
+ readonly ref: {
29
+ readonly id: string;
30
+ };
31
+ readonly root: string;
32
+ readonly work: string;
33
+ };
26
34
  /** What a tool's binding gets from the run's process. */
27
35
  export type ToolHost = {
28
- where: AppContext;
36
+ where: RunWhere;
29
37
  /** The run's environment: the server's, without the server's token. */
30
38
  env: NodeJS.ProcessEnv;
31
- /** The run's coding tools, by its place (coding-tools.ts codingSource). */
32
- coding: CodingSource;
33
39
  /** Installs an extension in the run's registry, before the run opens. */
34
40
  install(extension: Extension): void;
35
41
  /** Runs in the commit that creates each of the run's conversations. */
@@ -52,16 +58,12 @@ export type ToolHost = {
52
58
  * takes (adapter-loop AdapterRun.rowSummaryOn): a hand-over's wait sets the row's waiting summary in its waiting
53
59
  * entry's commit, and its answer's commit clears it, so the server tells run.needs_input for a run held in its claim. */
54
60
  rowSummaryOn?(kind: string, test: (data: Record<string, unknown>) => boolean, summary: string | null): void;
55
- /** The run is on the runner: its browser hand-over's answers are entries of its journal (a browser_hand_back row the
56
- * runner applies, the live view's hand-back, the ask's expiry), read and written there, never as answer files
57
- * (browser-person.ts personHands `answered`). */
58
- handoverInJournal?: boolean;
59
61
  /** The run is on the runner: its live viewers are handed over through the store, not through files in its directory
60
62
  * (browser-live.ts putLiveViewer/dropLiveViewer). The browser tool's live-viewer writers hang off this: `put` hands a
61
63
  * session's viewer over (its token sealed under the run's `sealKey`), `drop` takes one (or all of the run's) back. The
62
64
  * three fields below are what builds these (the one store, the claim the row is written under, the seal key); a tool's
63
- * binding reads `liveViewers`, never them directly. Absent on the server path, where the viewer lives in the run's
64
- * directory (browser-live.ts sessionHandovers: writeHandover/dropHandover). */
65
+ * binding reads `liveViewers`, never them directly. Absent, no viewer is handed over (browser-live.ts
66
+ * sessionHandovers), and nothing is written in the run's folder. */
65
67
  liveViewers?: {
66
68
  put(handover: LiveHandover): Promise<boolean>;
67
69
  drop(tag?: string): Promise<void>;
@@ -77,11 +79,13 @@ export type ToolHost = {
77
79
  /** The run's ledger, as the adapter loop hands it (spendcap-1's AdapterRun.ledger): `paid`, the claim's one-ledger
78
80
  * booking (the kernel cap's paidCalls, paid-calls.ts PaidBooking), and `pause`, how a refusal at the cap parks the run.
79
81
  * The browser passes `paid` to browserSpend, so its calls are held and settled there and a session's release is booked
80
- * there, never on this process's own spend. The runner installs the browser only with `paid` and the grant, on pi's
81
- * native route (adapter-run-spec.ts browserListed). */
82
+ * there, never on this process's own spend; `flush`, the runner's store flush, puts a session's open record on disk
83
+ * before the vendor is asked. The runner installs the browser only with `paid` and the grant, on pi's native route
84
+ * (adapter-run-spec.ts browserListed). */
82
85
  ledger?: {
83
86
  paid: PaidBooking;
84
87
  pause?: (refusal: Refusal) => Promise<void>;
88
+ flush: () => Promise<void>;
85
89
  };
86
90
  /** The run's one redactor (the runner's: every secret value the runner and the claim hold, in every form): what the
87
91
  * browser's answers pass through before pi stores them or the model reads them. Absent on the old per-run process. */
@@ -90,6 +94,9 @@ export type ToolHost = {
90
94
  * where a tool files what the run's read finds later (monid's whole answer past the model's cut). Absent, the local
91
95
  * folder at `where.work`. */
92
96
  workspace?: Workspace;
97
+ /** The agent's computer, where it is a browser (computer-for-claim.ts): the browser tool opens its sessions through the
98
+ * claim's provider and drives each over its CDP URL with pi-browser's raw-CDP driver, in place of the plane's vendor. */
99
+ browserComputer?: ClaimBrowser;
93
100
  };
94
101
  /** What a name stands for in the run: the pi tools it offers, and the extensions a conversation selects for them. */
95
102
  export type ToolBinding = {
@@ -187,7 +194,7 @@ export declare const savedOnRelease: (row: {
187
194
  /** On the runner, the per-session hook that verifies the run's saved sign-in: a session that saved to it (savedOnRelease,
188
195
  * in a run handed it to save) verifies it under the run's claim, at the session's own end (its time, else now), as the
189
196
  * saved mark main reads at the lease's end. Answers whether it verified (sign-ins-store.ts verifyRunSignIn). */
190
- export declare const runSignInSaved: (store: Pick<Store, "runs" | "signIns">, sealKey: Buffer | undefined, claim: Claim, kept: RunSignIn) => (row: {
197
+ export declare const runSignInSaved: (store: Pick<Store, "runs" | "signIns">, sealKey: Buffer, claim: Claim, kept: RunSignIn) => (row: {
191
198
  session: {
192
199
  resourceId: string | null;
193
200
  releaseReason: string | null;
@@ -229,6 +236,10 @@ export declare function grantedTools(revision: {
229
236
  }): Promise<string[]>;
230
237
  /** The table's entry for `name`, or undefined for a name it does not hold. */
231
238
  export declare const toolOf: (name: string) => ToolEntry | undefined;
239
+ /** The sandbox-only tools a run whose shell is `shell` has (resolve-computer.ts shellPlaceOf): every one in a computer
240
+ * that mounts its folder, bash alone on Mode 2's Archil exec ("local"), none with no shell. The kernel registry's
241
+ * hostToolDefs says which, the one list the run's tools are bound from. The save check asks it for "local" alone. */
242
+ export declare const shellTools: (shell: ShellPlace) => ReadonlySet<string>;
232
243
  /** What a stored revision's tools resolve from (tool-plane.ts): the tools it grants, its harness, model and settings. */
233
244
  export declare function toolingOf(revision: Revision): Promise<Tooling>;
234
245
  /** The variables `entry` needs that `env` does not set, by name. */
@@ -246,11 +257,12 @@ export declare function toolRefusal(names: readonly string[], env: NodeJS.Proces
246
257
  * sets none), the default, and what it resolves to on each harness under the server's `settings`: available where any
247
258
  * is not unavailable, and missing PARALLEL_API_KEY where Parallel is picked without it. An unavailable tool says why
248
259
  * (`reason`). `noBox`: why no box can run a sandbox-only tool here (place.ts noBoxReason), which leaves it
249
- * unavailable with that reason; undefined, a box can. `refused`: the variables of the keys this server was started with
250
- * that their provider refused at the start (ToolKeys.refused), each with why: a tool that needs one is unavailable,
260
+ * unavailable with that reason; undefined, a box can. `runnerShell`: the sandbox-only tools a run on the runner has a
261
+ * shell for here (shellTools: bash on Archil's exec in Mode 2), which need no box. `refused`: the variables of the keys this server was started with
262
+ * that their provider refused at the start (tool-keys-store.ts refused), each with why: a tool that needs one is unavailable,
251
263
  * saying that. Each tool also gives its permission under the server's settings (tool-gate.ts), the owner's default
252
264
  * and the permissions it may be set to. */
253
- export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettingsMap, noBox?: string, refused?: Readonly<Record<string, string>>) => {
265
+ export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettingsMap, noBox?: string, refused?: Readonly<Record<string, string>>, runnerShell?: ReadonlySet<string>) => {
254
266
  providers?: ("auto" | "native" | "parallel" | "browserbase" | "kernel" | "off" | "exa-keyless" | "chrome")[] | undefined;
255
267
  provider?: string | undefined;
256
268
  default_provider?: "auto" | "kernel" | undefined;