@parcha/agentrun-serve 0.1.0-beta.58 → 0.1.0-beta.59

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 (375) hide show
  1. package/CHANGELOG.md +325 -1
  2. package/README.md +332 -88
  3. package/dist/acp-package.d.ts +5 -1
  4. package/dist/acp-package.js +19 -2
  5. package/dist/adapters.d.ts +23 -2
  6. package/dist/adapters.js +106 -33
  7. package/dist/agents-store.js +1 -1
  8. package/dist/answer-text.d.ts +3 -0
  9. package/dist/answer-text.js +22 -0
  10. package/dist/attach-conformance.js +5 -4
  11. package/dist/box-paths.d.ts +3 -2
  12. package/dist/box-paths.js +5 -4
  13. package/dist/browser-computer.d.ts +3 -8
  14. package/dist/browser-computer.js +12 -35
  15. package/dist/browser-cost.js +94 -20
  16. package/dist/capacity.d.ts +1 -1
  17. package/dist/capacity.js +3 -3
  18. package/dist/chatgpt-plan.d.ts +5 -0
  19. package/dist/chatgpt-plan.js +25 -11
  20. package/dist/claude-login-token.d.ts +15 -11
  21. package/dist/claude-login-token.js +167 -107
  22. package/dist/claude-login.d.ts +76 -31
  23. package/dist/claude-login.js +426 -79
  24. package/dist/claude-sign-in.d.ts +3 -0
  25. package/dist/claude-sign-in.js +10 -1
  26. package/dist/cli.js +323 -292
  27. package/dist/composio-made.d.ts +1 -6
  28. package/dist/composio-made.js +1 -6
  29. package/dist/composio-owners.d.ts +26 -0
  30. package/dist/composio-owners.js +36 -0
  31. package/dist/composio-preset.d.ts +56 -23
  32. package/dist/composio-preset.js +173 -77
  33. package/dist/composio-triggers.d.ts +4 -4
  34. package/dist/composio-triggers.js +6 -7
  35. package/dist/compute-cost.js +11 -2
  36. package/dist/computer-attach.d.ts +6 -3
  37. package/dist/computer-attach.js +41 -29
  38. package/dist/computer-held-routes.d.ts +1 -1
  39. package/dist/computer-held-routes.js +9 -4
  40. package/dist/computer-keys.d.ts +11 -1
  41. package/dist/computer-keys.js +26 -1
  42. package/dist/computer-record.js +3 -1
  43. package/dist/computer-view.d.ts +5 -3
  44. package/dist/computer-view.js +10 -6
  45. package/dist/computer-viewer.js +36 -7
  46. package/dist/computers.d.ts +2 -1
  47. package/dist/computers.js +6 -3
  48. package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
  49. package/dist/console/assets/backend-BztxEAvb.js +166 -0
  50. package/dist/console/assets/index-LwNL4L9q.js +619 -0
  51. package/dist/console/assets/share-L84tlUDW.js +6 -0
  52. package/dist/console/assets/styles-CaRKlHke.js +291 -0
  53. package/dist/console/assets/styles-DQo8rzY-.css +1 -0
  54. package/dist/console/index.html +4 -3
  55. package/dist/console/share.html +17 -0
  56. package/dist/decisions.d.ts +17 -7
  57. package/dist/decisions.js +41 -15
  58. package/dist/dial-relay.js +10 -4
  59. package/dist/docker-daemon.js +4 -5
  60. package/dist/docker-host-addresses.js +29 -11
  61. package/dist/email/account.d.ts +6 -0
  62. package/dist/email/account.js +6 -0
  63. package/dist/email/authentication.d.ts +21 -0
  64. package/dist/email/authentication.js +106 -0
  65. package/dist/email/email-faux.d.ts +11 -2
  66. package/dist/email/email-faux.js +21 -5
  67. package/dist/email/mail.d.ts +25 -0
  68. package/dist/email/mail.js +58 -2
  69. package/dist/email/names.js +2 -2
  70. package/dist/email/tools.d.ts +9 -4
  71. package/dist/email/tools.js +95 -13
  72. package/dist/env-switch.d.ts +12 -2
  73. package/dist/env-switch.js +23 -3
  74. package/dist/errors.d.ts +1 -0
  75. package/dist/errors.js +2 -0
  76. package/dist/fal-price.d.ts +11 -1
  77. package/dist/fal-price.js +33 -0
  78. package/dist/faux-computers.js +1 -1
  79. package/dist/filed-answer.d.ts +2 -2
  80. package/dist/filed-answer.js +2 -2
  81. package/dist/graph-served.d.ts +10 -5
  82. package/dist/graph-served.js +40 -10
  83. package/dist/handed-values.js +1 -2
  84. package/dist/harness-check.d.ts +2 -1
  85. package/dist/harness-check.js +45 -12
  86. package/dist/harness-keys.js +9 -6
  87. package/dist/harness-opencode/facts.js +2 -0
  88. package/dist/harness-recipe-entry.d.ts +9 -3
  89. package/dist/harness-recipe-entry.js +18 -9
  90. package/dist/harness-recipe.d.ts +21 -0
  91. package/dist/harness-recipe.js +25 -3
  92. package/dist/harness-table.d.ts +8 -0
  93. package/dist/harness-table.js +17 -6
  94. package/dist/helper-env.d.ts +4 -1
  95. package/dist/helper-env.js +4 -1
  96. package/dist/host-check.d.ts +2 -3
  97. package/dist/host-check.js +13 -7
  98. package/dist/hosted-search.js +1 -1
  99. package/dist/import.d.ts +11 -8
  100. package/dist/import.js +437 -186
  101. package/dist/key-refusal.d.ts +9 -2
  102. package/dist/key-refusal.js +86 -32
  103. package/dist/learn/audit.d.ts +8 -5
  104. package/dist/learn/audit.js +15 -7
  105. package/dist/learn/compile.d.ts +5 -2
  106. package/dist/learn/compile.js +45 -21
  107. package/dist/learn/field-check.d.ts +111 -0
  108. package/dist/learn/field-check.js +174 -0
  109. package/dist/learn/ledger.d.ts +32 -29
  110. package/dist/learn/ledger.js +26 -19
  111. package/dist/learn/promote.d.ts +79 -36
  112. package/dist/learn/promote.js +60 -65
  113. package/dist/learn/secrets.d.ts +4 -0
  114. package/dist/learn/secrets.js +12 -0
  115. package/dist/learned-nodes.d.ts +8 -5
  116. package/dist/learned-nodes.js +8 -5
  117. package/dist/learned-workflow.d.ts +2 -1
  118. package/dist/learned-workflow.js +13 -10
  119. package/dist/learning-cost.d.ts +25 -8
  120. package/dist/learning-cost.js +23 -8
  121. package/dist/learning-setting.d.ts +6 -0
  122. package/dist/learning-setting.js +11 -1
  123. package/dist/listen-first.d.ts +5 -4
  124. package/dist/listen-first.js +4 -5
  125. package/dist/live-reach.d.ts +7 -0
  126. package/dist/live-reach.js +7 -0
  127. package/dist/mcp-api-only-origins.d.ts +15 -0
  128. package/dist/mcp-api-only-origins.js +40 -0
  129. package/dist/mcp-gateway.d.ts +16 -2
  130. package/dist/mcp-gateway.js +41 -3
  131. package/dist/mcp-oauth.d.ts +1 -1
  132. package/dist/mcp-oauth.js +3 -2
  133. package/dist/mcp-probe.d.ts +3 -0
  134. package/dist/mcp-probe.js +3 -0
  135. package/dist/mcp-secret-writes.d.ts +24 -2
  136. package/dist/mcp-secret-writes.js +30 -2
  137. package/dist/mcp-servers-store.d.ts +52 -14
  138. package/dist/mcp-servers-store.js +165 -61
  139. package/dist/mcp-sources.d.ts +1 -2
  140. package/dist/mcp-sources.js +1 -2
  141. package/dist/mcp-store.d.ts +5 -5
  142. package/dist/mcp-store.js +3 -3
  143. package/dist/mcp.js +1 -1
  144. package/dist/model-gateway.d.ts +1 -1
  145. package/dist/model-gateway.js +20 -36
  146. package/dist/ollama-provider.d.ts +23 -9
  147. package/dist/ollama-provider.js +49 -20
  148. package/dist/openapi.js +202 -51
  149. package/dist/otel/genai.d.ts +83 -7
  150. package/dist/otel/genai.js +69 -9
  151. package/dist/otel/tracer.d.ts +42 -13
  152. package/dist/otel/tracer.js +241 -56
  153. package/dist/page.d.ts +7 -1
  154. package/dist/page.js +76 -22
  155. package/dist/paid-calls.d.ts +6 -4
  156. package/dist/paid-calls.js +15 -7
  157. package/dist/place-offers.d.ts +55 -34
  158. package/dist/place-offers.js +93 -54
  159. package/dist/place.d.ts +13 -14
  160. package/dist/place.js +56 -41
  161. package/dist/print.js +1 -1
  162. package/dist/provider.d.ts +3 -2
  163. package/dist/provider.js +17 -8
  164. package/dist/redact/match.d.ts +27 -9
  165. package/dist/redact/match.js +266 -57
  166. package/dist/run-census.d.ts +1 -1
  167. package/dist/run-census.js +4 -5
  168. package/dist/run-cut.js +4 -5
  169. package/dist/run-export-store.d.ts +15 -0
  170. package/dist/run-export-store.js +30 -0
  171. package/dist/run-export.d.ts +139 -0
  172. package/dist/run-export.js +379 -0
  173. package/dist/run-file-cut.d.ts +5 -0
  174. package/dist/run-file-cut.js +13 -0
  175. package/dist/run-launch.js +16 -3
  176. package/dist/run-model-key.d.ts +15 -6
  177. package/dist/run-model-key.js +30 -31
  178. package/dist/run-reads-over-store.js +4 -4
  179. package/dist/run-secrets.js +3 -5
  180. package/dist/run-timeline-served.js +3 -1
  181. package/dist/runnable.js +2 -2
  182. package/dist/runner/adapter-loop.d.ts +35 -18
  183. package/dist/runner/adapter-loop.js +94 -47
  184. package/dist/runner/adapter-run-spec.d.ts +14 -1
  185. package/dist/runner/adapter-run-spec.js +64 -28
  186. package/dist/runner/adapters/pi.js +4 -2
  187. package/dist/runner/audit.d.ts +8 -5
  188. package/dist/runner/audit.js +37 -17
  189. package/dist/runner/beside.js +5 -6
  190. package/dist/runner/claim-secrets.d.ts +10 -3
  191. package/dist/runner/claim-secrets.js +29 -13
  192. package/dist/runner/cli-run-spec.d.ts +18 -0
  193. package/dist/runner/cli-run-spec.js +81 -46
  194. package/dist/runner/compare-end.d.ts +2 -1
  195. package/dist/runner/compare-end.js +25 -10
  196. package/dist/runner/conformance/harness.js +2 -3
  197. package/dist/runner/conformance/subject.d.ts +4 -1
  198. package/dist/runner/harness-loops.js +3 -3
  199. package/dist/runner/held.d.ts +5 -2
  200. package/dist/runner/journal-kinds.d.ts +4 -1
  201. package/dist/runner/journal-kinds.js +22 -4
  202. package/dist/runner/learned-first.js +20 -4
  203. package/dist/runner/learning-end.d.ts +2 -8
  204. package/dist/runner/learning-end.js +11 -19
  205. package/dist/runner/live-ticker.js +7 -5
  206. package/dist/runner/loop-contract.d.ts +0 -2
  207. package/dist/runner/loop.d.ts +7 -0
  208. package/dist/runner/loop.js +1 -0
  209. package/dist/runner/main.js +12 -11
  210. package/dist/runner/mcp-claim.js +21 -5
  211. package/dist/runner/meta-tools.js +3 -2
  212. package/dist/runner/metrics.d.ts +7 -0
  213. package/dist/runner/metrics.js +19 -0
  214. package/dist/runner/model-route.d.ts +10 -7
  215. package/dist/runner/model-route.js +79 -15
  216. package/dist/runner/native-loop.js +10 -8
  217. package/dist/runner/presence.d.ts +1 -4
  218. package/dist/runner/presence.js +6 -8
  219. package/dist/runner/promotion.d.ts +25 -13
  220. package/dist/runner/promotion.js +125 -50
  221. package/dist/runner/redact.d.ts +3 -1
  222. package/dist/runner/redact.js +5 -3
  223. package/dist/runner/responses-fetch.d.ts +36 -0
  224. package/dist/runner/responses-fetch.js +511 -0
  225. package/dist/runner/run-child-host.d.ts +20 -5
  226. package/dist/runner/run-child-host.js +179 -77
  227. package/dist/runner/run-child.js +11 -4
  228. package/dist/runner/runner-check.js +5 -1
  229. package/dist/runner/runner.d.ts +2 -3
  230. package/dist/runner/runner.js +13 -9
  231. package/dist/runner/sdk-loop.js +8 -8
  232. package/dist/runner/spec-holds.d.ts +8 -1
  233. package/dist/runner/spec-holds.js +9 -4
  234. package/dist/runner/workflow-calls.d.ts +9 -0
  235. package/dist/runner/workflow-calls.js +150 -0
  236. package/dist/runner/workflow-first.d.ts +120 -32
  237. package/dist/runner/workflow-first.js +218 -94
  238. package/dist/runner/workflow-spec.js +1 -1
  239. package/dist/runs-over-store.js +8 -7
  240. package/dist/save-once.d.ts +14 -0
  241. package/dist/save-once.js +31 -0
  242. package/dist/scrub-command.d.ts +34 -31
  243. package/dist/scrub-command.js +116 -147
  244. package/dist/sdk/runs.d.ts +6 -0
  245. package/dist/sdk/runs.js +89 -10
  246. package/dist/seal-key.js +4 -4
  247. package/dist/secret-cut.d.ts +3 -0
  248. package/dist/secret-cut.js +7 -1
  249. package/dist/secret-rules.d.ts +8 -1
  250. package/dist/secret-rules.js +482 -53
  251. package/dist/secrets.d.ts +51 -9
  252. package/dist/secrets.js +311 -21
  253. package/dist/server-keys.d.ts +4 -3
  254. package/dist/server-keys.js +4 -3
  255. package/dist/server-secrets-store.js +2 -4
  256. package/dist/server.d.ts +15 -3
  257. package/dist/server.js +312 -80
  258. package/dist/share-context.d.ts +22 -0
  259. package/dist/share-context.js +76 -0
  260. package/dist/shell-lex.d.ts +105 -0
  261. package/dist/shell-lex.js +646 -0
  262. package/dist/sign-ins-store.d.ts +5 -7
  263. package/dist/sign-ins-store.js +12 -16
  264. package/dist/sign-ins.d.ts +7 -11
  265. package/dist/sign-ins.js +40 -41
  266. package/dist/skills/agentrun-serve/SKILL.md +5 -2
  267. package/dist/start-switches.d.ts +6 -5
  268. package/dist/start-switches.js +8 -4
  269. package/dist/stats.d.ts +5 -1
  270. package/dist/stats.js +1 -1
  271. package/dist/store/agent-body.js +2 -2
  272. package/dist/store/dialect.d.ts +4 -0
  273. package/dist/store/dialect.js +1 -0
  274. package/dist/store/index.d.ts +2 -2
  275. package/dist/store/index.js +1 -1
  276. package/dist/store/mcp-record-keys.d.ts +10 -0
  277. package/dist/store/mcp-record-keys.js +13 -0
  278. package/dist/store/postgres/dialect.js +2 -0
  279. package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
  280. package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
  281. package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
  282. package/dist/store/postgres/store.js +4 -0
  283. package/dist/store/schema.d.ts +33 -10
  284. package/dist/store/schema.js +70 -16
  285. package/dist/store/seal.d.ts +4 -1
  286. package/dist/store/sqlite/run-launch.d.ts +3 -10
  287. package/dist/store/sqlite/run-launch.js +12 -23
  288. package/dist/store/sqlite/run-patch.d.ts +17 -10
  289. package/dist/store/sqlite/run-patch.js +50 -13
  290. package/dist/store/sqlite/store.d.ts +3 -0
  291. package/dist/store/sqlite/store.js +116 -34
  292. package/dist/store/store-schema.js +3 -4
  293. package/dist/store/store.d.ts +67 -32
  294. package/dist/store/store.js +14 -11
  295. package/dist/store-reads/analytics.d.ts +2 -1
  296. package/dist/store-reads/analytics.js +7 -5
  297. package/dist/store-reads/learning.d.ts +35 -26
  298. package/dist/store-reads/learning.js +120 -92
  299. package/dist/store-reads/stats.d.ts +2 -2
  300. package/dist/store-reads/stats.js +13 -7
  301. package/dist/store-view.js +10 -7
  302. package/dist/suggestions.d.ts +1 -1
  303. package/dist/suggestions.js +29 -13
  304. package/dist/template-eval.d.ts +72 -9
  305. package/dist/template-eval.js +358 -64
  306. package/dist/timeline/labels.d.ts +1 -1
  307. package/dist/timeline/labels.js +4 -3
  308. package/dist/timeline/timeline.d.ts +23 -11
  309. package/dist/timeline/timeline.js +115 -31
  310. package/dist/timeline/web-calls.d.ts +8 -6
  311. package/dist/timeline/web-calls.js +10 -6
  312. package/dist/tool-gate.d.ts +13 -1
  313. package/dist/tool-gate.js +43 -3
  314. package/dist/tool-keys-store.js +2 -4
  315. package/dist/tool-keys.d.ts +11 -0
  316. package/dist/tool-keys.js +16 -0
  317. package/dist/tool-plane.d.ts +50 -11
  318. package/dist/tool-plane.js +94 -30
  319. package/dist/tools.d.ts +5 -1
  320. package/dist/tools.js +7 -7
  321. package/dist/trigger-email.js +12 -6
  322. package/dist/triggers.d.ts +15 -34
  323. package/dist/triggers.js +119 -126
  324. package/dist/validate.d.ts +8 -1
  325. package/dist/validate.js +163 -23
  326. package/dist/web-fake.d.ts +2 -1
  327. package/dist/web-fake.js +8 -6
  328. package/dist/web-fetch.d.ts +8 -6
  329. package/dist/web-fetch.js +13 -11
  330. package/dist/web-holds.d.ts +32 -0
  331. package/dist/web-holds.js +86 -0
  332. package/dist/web-run.d.ts +32 -5
  333. package/dist/web-run.js +75 -28
  334. package/dist/web-save.js +23 -12
  335. package/dist/web-search.js +14 -25
  336. package/dist/wires.d.ts +4 -3
  337. package/dist/wires.js +5 -4
  338. package/dist/workspace/archil-claim.d.ts +12 -5
  339. package/dist/workspace/archil-claim.js +45 -5
  340. package/dist/workspace/attach.js +52 -19
  341. package/dist/workspace/attached-computers.d.ts +6 -2
  342. package/dist/workspace/attached-computers.js +5 -4
  343. package/dist/workspace/computer-deps.d.ts +23 -6
  344. package/dist/workspace/computer-deps.js +35 -17
  345. package/dist/workspace/computer-for-claim.d.ts +21 -4
  346. package/dist/workspace/computer-for-claim.js +160 -54
  347. package/dist/workspace/computer-intervals.d.ts +2 -0
  348. package/dist/workspace/computer-intervals.js +1 -1
  349. package/dist/workspace/computer-janitor.d.ts +48 -14
  350. package/dist/workspace/computer-janitor.js +153 -44
  351. package/dist/workspace/computer-kept.d.ts +158 -32
  352. package/dist/workspace/computer-kept.js +288 -63
  353. package/dist/workspace/computer-providers.d.ts +8 -3
  354. package/dist/workspace/computer-providers.js +12 -5
  355. package/dist/workspace/index.d.ts +1 -1
  356. package/dist/workspace/index.js +1 -1
  357. package/dist/workspace/local.js +41 -1
  358. package/dist/workspace/mount-revoke-left.d.ts +31 -0
  359. package/dist/workspace/mount-revoke-left.js +72 -0
  360. package/dist/workspace/paired-route.js +4 -5
  361. package/dist/workspace/resolve-computer.d.ts +5 -2
  362. package/dist/workspace/resolve-computer.js +9 -3
  363. package/dist/workspace/run-end-computers.d.ts +11 -5
  364. package/dist/workspace/run-end-computers.js +153 -28
  365. package/dist/workspace/run-tools.d.ts +22 -3
  366. package/dist/workspace/run-tools.js +17 -5
  367. package/dist/workspace/run-workspace.d.ts +14 -1
  368. package/dist/workspace/run-workspace.js +34 -1
  369. package/dist/workspace/workspace.d.ts +6 -0
  370. package/package.json +12 -13
  371. package/skills/agentrun-serve/SKILL.md +5 -2
  372. package/templates/README.md +22 -6
  373. package/dist/console/assets/backend-CSAWUqtZ.js +0 -166
  374. package/dist/console/assets/index-Bwn1oTem.css +0 -1
  375. package/dist/console/assets/index-DPh29cyz.js +0 -747
@@ -71,7 +71,7 @@ export declare function foldLabel(tool: string, calls: readonly {
71
71
  path?: (path: string) => string;
72
72
  }): string;
73
73
  /** The input worth showing: the base keys first, then the browser and file ones, and last the app a computer's look or act
74
- * names (never what an act types: its steps; nor a codemode script, which can hold it). */
74
+ * names (never what an act types: its steps; nor a codemode script, which can hold it), then a search's objective. */
75
75
  export declare function inputPreview(args: Obj, max: number): string | null;
76
76
  /** Files a finished call put in the workspace. */
77
77
  export declare function savedPaths(tool: string, args: Obj, result: ToolResultView): string[];
@@ -68,9 +68,9 @@ export function foldLabel(tool, calls, options = {}) {
68
68
  return subjects.length ? `${head}: ${list(subjects)}` : head;
69
69
  }
70
70
  /** The input worth showing: the base keys first, then the browser and file ones, and last the app a computer's look or act
71
- * names (never what an act types: its steps; nor a codemode script, which can hold it). */
71
+ * names (never what an act types: its steps; nor a codemode script, which can hold it), then a search's objective. */
72
72
  export function inputPreview(args, max) {
73
- for (const key of ["description", "command", "query", "file_path", "url", "path", "code", "app"]) {
73
+ for (const key of ["description", "command", "query", "file_path", "url", "path", "code", "app", "objective"]) {
74
74
  const value = str(args[key]);
75
75
  if (value)
76
76
  return cut(scrubUrls(value), max);
@@ -150,7 +150,8 @@ const fromHost = (a) => {
150
150
  registerLabel("web_save", (a, result) => `${unfetched(result) ? "Tried to save" : "Saved"} ${savedAt(a, result)}${fromHost(a)}`, { many: (n) => `Saved ${n} files from the web`, subject: (input) => input ?? undefined }, { name: "Save files from the web" });
151
151
  registerOutcome("web_save", fetchOutcome);
152
152
  registerLabel("web_search", (a) => {
153
- const query = str(a.query);
153
+ // Its first keyword query, else its objective, else the deprecated query alone.
154
+ const query = (Array.isArray(a.queries) ? a.queries.map(str).find(Boolean) : undefined) ?? str(a.objective) ?? str(a.query);
154
155
  return query ? `Searched the web for "${cut(scrubUrls(query), 60)}"` : "Searched the web";
155
156
  }, { many: (n) => `Searched the web ${n} times`, subject: (input) => (input ? `"${cut(input, 40)}"` : undefined) }, { name: "Search the web" });
156
157
  // web_search answers its results and a line asking for citations, or `{error}` when the search gave no answer: failed.
@@ -53,7 +53,8 @@ export type TimelineEvent = {
53
53
  paused?: true;
54
54
  /** `true` on the `tool_result` row of a call refused before it ran (its host's mark, CALL_REFUSED: a gate's deny, a
55
55
  * person's, a call held for an approval the run ended or stopped without): it never ran, so it never failed, though
56
- * `tool_status` stays `failed` (it did not do its work). A client shows it apart from a call that ran and failed. */
56
+ * `tool_status` stays `failed` (it did not do its work). A client shows it apart from a call that ran and failed. Also
57
+ * on a script's (codemode) or a tools_call's row that stopped at such a call (its host tool answered `refused`). */
57
58
  refused?: true;
58
59
  /** On the usage row, the run's cost. On a paid tool's charge row (a `phase` naming the tool), that charge alone. On a
59
60
  * browser call's `tool_use` row, every browser charge booked under that call (BROWSER_CHARGE): its session's time
@@ -92,8 +93,10 @@ export type TimelineEvent = {
92
93
  * counts the calls past the record's bound. This projector writes none (store-reads/journal.ts withComputerCalls). */
93
94
  computer_calls?: readonly ComputerCallRow[];
94
95
  computer_calls_dropped?: number;
95
- /** On a `tool_use` row of a timeline read with `calls` (TimelineOptions): the call's arguments, each string as `redact`
96
- * makes it where the call is first seen, cut at CAPS.text. */
96
+ /** On a `tool_use` row of a timeline read with `calls` (TimelineOptions): the call's arguments, each string as
97
+ * `calls.input` makes it of the arguments as the call came (else as the rows show them), its names and values
98
+ * together cut at `calls.result` characters (inputShown), the bound its output has (a grader reads a long write whole: an issue body, a note, a
99
+ * posted digest). Absent when `holds` withholds them whole. */
97
100
  tool_input?: Obj;
98
101
  /** On a `tool_result` row of a timeline read with `calls`: the call's output whole to `calls.result` characters (its
99
102
  * head past that), as `calls.redact` makes it, its URLs' query values elided as the preview's are; a web call's every
@@ -133,7 +136,8 @@ export declare const CAPS: {
133
136
  * web_search's every result keeps its url, title and published date, and a web_fetch its url and title, their snippets
134
137
  * and page text cut to fit (web-calls.ts), past this only when its urls alone pass it. */
135
138
  export declare const CALL_RESULT_CHARS = 120000;
136
- /** The most rows a `calls=whole` timeline page holds, and its default: each row's result may be CALL_RESULT_CHARS long. */
139
+ /** The most rows a `calls=whole` timeline page holds, and its default: each row's result, or the names, values and
140
+ * brackets of its call's arguments together (tool_input, inputShown), may be CALL_RESULT_CHARS long. */
137
141
  export declare const CALLS_PAGE_ROWS = 100;
138
142
  /** A host's marks of a model request: as it leaves (written before it does), and as its stream ends aborted. A request
139
143
  * that answered or failed has a `pi.assistant` entry; one aborted before its first content has none; a start with no
@@ -282,22 +286,30 @@ export type TimelineOptions = {
282
286
  * this for the full protection: a key a stream wraps with only part of its tail streamed is covered by a held-back
283
287
  * tail as long as a key, not by the word holdback. */
284
288
  redactLive?: (text: string) => string;
289
+ /** Whether a text holds a held value no cut in place takes (key-refusal.ts withheldWhole, whose join view reads a
290
+ * JSON text's strings joined, property names among them). Read in every read, with `calls` or without, before any
291
+ * row shows what it reads: a call's arguments, each string of which `redact` reads on its own, are read with it as
292
+ * their JSON (argsOf), and a web call's output as it came (web-calls.ts webHeld). A value split across two of their
293
+ * strings, or across a property name and its value, which `redact` and `calls.redact` never read side by side,
294
+ * withholds them whole: the call's rows read it as one with no arguments, or its output's preview, summary and a
295
+ * `calls` read's text read "[redacted]". Default: none withheld. */
296
+ holds?: (text: string) => boolean;
285
297
  /** For a reader that grades the run (a template eval): each `tool_use` row carries its call's arguments whole
286
298
  * (`tool_input`), and each `tool_result` row the head of its output to `result` characters (`tool_result_text`; a
287
299
  * web call's every url, each of its strings redacted on its own), made safe by `redact`, a redactor that reads that
288
300
  * far (the rows' own `redact` stops at the head a row shows).
289
- * Without `redact`, the rows' own. `held`: whether a number in the arguments shows a held value (a key that is all
290
- * digits); such a number is shown as "[redacted]". */
301
+ * Without `redact`, the rows' own. `input`: each string of a call's arguments as `tool_input` shows it, read from the
302
+ * arguments as the call came, its head of `shown` characters made safe (the caller cuts it there). The rows' own
303
+ * `redact` stops at the head a row shows, so without `input`, `tool_input` reads the arguments as the rows show them,
304
+ * each string no longer than that head. Arguments `holds` withholds whole have no `tool_input` either way: it reads
305
+ * them as the call came. `held`: whether a number in the arguments shows a held value (a key that is all digits);
306
+ * such a number is shown as "[redacted]". */
291
307
  calls?: {
292
308
  result: number;
293
309
  redact?: (text: string) => string;
310
+ input?: (text: string, shown: number) => string;
294
311
  held?: (value: number | bigint) => boolean;
295
312
  };
296
- /** Whether a text holds a held value no cut in place takes (key-refusal.ts withheldWhole). A web call's output is read
297
- * through it joined, its JSON's strings as they came (web-calls.ts webHeld), before any of its rows shows any of it: a
298
- * value split across two of its strings, which `redact` and `calls.redact` never read side by side, withholds the
299
- * output, so its preview, its summary and a `calls` read's text read "[redacted]". Default: none withheld. */
300
- holds?: (text: string) => boolean;
301
313
  };
302
314
  /** A tool's calls in a run, and how many failed. */
303
315
  export type ToolMetrics = {
@@ -18,7 +18,8 @@ export const CAPS = { summary: 500, preview: 500, text: 2000, thinking: 100 };
18
18
  * web_search's every result keeps its url, title and published date, and a web_fetch its url and title, their snippets
19
19
  * and page text cut to fit (web-calls.ts), past this only when its urls alone pass it. */
20
20
  export const CALL_RESULT_CHARS = 120_000;
21
- /** The most rows a `calls=whole` timeline page holds, and its default: each row's result may be CALL_RESULT_CHARS long. */
21
+ /** The most rows a `calls=whole` timeline page holds, and its default: each row's result, or the names, values and
22
+ * brackets of its call's arguments together (tool_input, inputShown), may be CALL_RESULT_CHARS long. */
22
23
  export const CALLS_PAGE_ROWS = 100;
23
24
  /** A host's marks of a model request: as it leaves (written before it does), and as its stream ends aborted. A request
24
25
  * that answered or failed has a `pi.assistant` entry; one aborted before its first content has none; a start with no
@@ -193,13 +194,14 @@ const tokenCount = (value) => (typeof value === "number" && Number.isSafeInteger
193
194
  /** A usage's tokens: undefined unless it has an input and an output count (a cache count it omits is 0), and unless it
194
195
  * has some input. A request that reached a model always sent some, so a usage with none is a writer's zeros for a
195
196
  * request it did not measure (an imported transcript's, a harness answer's written with no booking): unknown, never 0.
196
- * `failed`: a failed request's counts are taken as they are, as its cost is. */
197
+ * `failed`: a failed request's counts are taken as they are, as its cost is; so are a `folded` usage's (an imported
198
+ * request whose tokens its source counted in a later request of the session). */
197
199
  function tokensOf(usage, failed = false) {
198
200
  const u = obj(usage);
199
201
  const [input, output, cacheRead, cacheWrite] = [tokenCount(u?.input), tokenCount(u?.output), u?.cacheRead === undefined ? 0 : tokenCount(u.cacheRead), u?.cacheWrite === undefined ? 0 : tokenCount(u.cacheWrite)];
200
202
  if (input === undefined || output === undefined || cacheRead === undefined || cacheWrite === undefined)
201
203
  return undefined;
202
- return failed || input + cacheRead + cacheWrite > 0 ? { input, cacheRead, cacheWrite, output } : undefined;
204
+ return failed || u?.folded === true || input + cacheRead + cacheWrite > 0 ? { input, cacheRead, cacheWrite, output } : undefined;
203
205
  }
204
206
  /** A run's model requests as its entries mark them: how many, what they cost and the tokens they used. The usage row
205
207
  * and runMetricsOf count through it. `push` says what an entry was: an answer (a `pi.assistant` that is a request), a
@@ -285,8 +287,9 @@ function createMeter() {
285
287
  const message = entry.model?.[0];
286
288
  const data = obj(entry.data);
287
289
  const summaryAnswered = compactionAnswers(entry, sideSummaries);
288
- if (entry.kind === "pi.assistant" && entry.recordedCall && message) {
290
+ if (entry.kind === "pi.assistant" && (entry.recordedCall || data?.mirrors !== undefined) && message) {
289
291
  // A call the loop's record kept (a CLI's, or one a tool of pi's nested): shown as an answer's call, never a request.
292
+ // So is an imported answer whose request another run counts (`mirrors`: an OpenCode request Claude Code also wrote).
290
293
  return "call";
291
294
  }
292
295
  else if (entry.kind === REQUEST_REFUSED) {
@@ -506,21 +509,70 @@ const blocksOf = (message) => {
506
509
  const textOf = (message, type = "text", field = "text") => blocksOf(message).filter((block) => block.type === type).map((block) => str(block[field]) ?? "").join("\n").trim();
507
510
  /** Every string a row shows goes through here: a URL keeps its origin, path and query keys, then the text is cut. */
508
511
  const clean = (text, max) => cut(scrubUrls(text), max);
509
- /** A call's arguments as `tool_input` carries them, their values already redacted (argsOf): each string cut at `max`, and
510
- * each property name through `redact` too, as only this field shows them, and each number `held` names as
511
- * "[redacted]". An object two of whose names come out the same is withheld whole, as "[redacted]", never one value
512
- * merged over the other. */
513
- const inputShown = (value, max, redact = (text) => text, held = () => false) => {
514
- if (typeof value === "string")
515
- return cut(value, max);
516
- if (typeof value === "number" || typeof value === "bigint")
517
- return held(value) ? "[redacted]" : value;
518
- if (Array.isArray(value))
519
- return value.map((item) => inputShown(item, max, redact, held));
520
- if (!value || typeof value !== "object")
521
- return value;
522
- const entries = Object.entries(value).map(([key, item]) => [redact(key), inputShown(item, max, redact, held)]);
523
- return new Set(entries.map(([key]) => key)).size === entries.length ? Object.fromEntries(entries) : "[redacted]";
512
+ /** A call's arguments as `tool_input` carries them, at most `budget` characters a row, taken in order: each property
513
+ * name as `redact` makes it, as only this field shows them, each string as `read` makes it of the head it is given,
514
+ * each number, boolean or null as its text (a number `held` names as "[redacted]"), and each array or object its two
515
+ * brackets. Every name and value costs at least one character. The name or string that reaches the budget is cut
516
+ * there, and a number, boolean or null that would pass it shows as "..."; an array or object then ends with one "..."
517
+ * (an item, or a "..." name), and a value reached past it shows as "...", unread, however much it holds. So a row's
518
+ * names, values and brackets come to at most `budget` characters, past which only a "..." for the value it stopped in
519
+ * and one for each array or object still open, whatever its call holds. An object two of whose names come out the
520
+ * same is withheld whole, as "[redacted]", never one value merged over the other. */
521
+ const inputShown = (args, budget, read, redact = (text) => text, held = () => false) => {
522
+ let left = budget;
523
+ const spend = (size) => (left -= Math.max(1, size));
524
+ // A number, boolean or null shows whole or as "...": a cut one would read as another value.
525
+ const scalar = (out) => {
526
+ const text = String(out);
527
+ if (text.length > left) {
528
+ left = 0;
529
+ return "...";
530
+ }
531
+ spend(text.length);
532
+ return out;
533
+ };
534
+ const shown = (value) => {
535
+ if (left <= 3)
536
+ return "...";
537
+ if (typeof value === "string") {
538
+ const text = cut(read(value, left), left);
539
+ spend(text.length);
540
+ return text;
541
+ }
542
+ if (typeof value === "number" || typeof value === "bigint")
543
+ return scalar(held(value) ? "[redacted]" : value);
544
+ if (Array.isArray(value)) {
545
+ spend(2);
546
+ const out = [];
547
+ for (const item of value) {
548
+ if (left <= 3)
549
+ return [...out, "..."];
550
+ out.push(shown(item));
551
+ }
552
+ return out;
553
+ }
554
+ if (!value || typeof value !== "object")
555
+ return scalar(value);
556
+ spend(2);
557
+ const entries = [];
558
+ let ended = false;
559
+ for (const [key, item] of Object.entries(value)) {
560
+ if (left <= 3) {
561
+ ended = true;
562
+ break;
563
+ }
564
+ const name = cut(redact(key), left);
565
+ spend(name.length);
566
+ entries.push([name, shown(item)]);
567
+ }
568
+ if (new Set(entries.map(([key]) => key)).size !== entries.length)
569
+ return "[redacted]";
570
+ const out = Object.fromEntries(entries);
571
+ if (ended && !Object.hasOwn(out, "..."))
572
+ out["..."] = "...";
573
+ return out;
574
+ };
575
+ return shown(args);
524
576
  };
525
577
  /** The rows that show words as a person or the agent wrote them: cut, never scrubbed. */
526
578
  const WHOLE = new Set(["user_message", "text_block", "final_answer"]);
@@ -675,8 +727,32 @@ function createProjector(options) {
675
727
  return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactValue(item)]));
676
728
  return value;
677
729
  };
678
- /** A call's arguments as its rows may show them: redacted once, where the call is first seen (redactValue). */
679
- const argsOf = (args) => (options.redact ? redactValue(args) : args);
730
+ /** The arguments of calls a read withholds whole (argsOf). */
731
+ const withheldArgs = new WeakSet();
732
+ /** A call's arguments as its rows may show them: redacted once, where the call is first seen (redactValue). Arguments
733
+ * whose JSON holds a held value no cut in place takes (`holds`: split across two of their
734
+ * strings, or across a property name and its value, which redactValue reads one at a time) are withheld whole, in a
735
+ * read with calls or without: the call's rows read it as one with no arguments, its preview is "[redacted]" and its
736
+ * `tool_input` is left out. */
737
+ const argsOf = (args) => {
738
+ if (argsHeld(args)) {
739
+ const none = {};
740
+ withheldArgs.add(none);
741
+ return none;
742
+ }
743
+ return options.redact ? redactValue(args) : args;
744
+ };
745
+ /** Whether the read withholds `args` whole (argsOf); arguments that cannot be read as JSON are. */
746
+ const argsHeld = (args) => {
747
+ if (!options.holds)
748
+ return false;
749
+ try {
750
+ return options.holds(JSON.stringify(args));
751
+ }
752
+ catch {
753
+ return true;
754
+ }
755
+ };
680
756
  /** An outcome's words as the summary shows them: its verdict (`failed:`, `refused:`) as read, and only what follows it
681
757
  * redacted, so a redaction that takes the whole detail still leaves the verdict, as the row's status says. */
682
758
  const saidOf = (text) => {
@@ -687,8 +763,8 @@ function createProjector(options) {
687
763
  * which its label, summary and preview are all taken from (resultRow); its details and error flag as they came. */
688
764
  const shownOf = (tool, view) => withheld(tool, view.text) ? { ...view, text: "[redacted]", details: redactValue(view.details) }
689
765
  : options.redact ? { ...view, text: view.text ? options.redact(view.text) : view.text, details: redactValue(view.details) } : view;
690
- /** Whether a call of `tool`'s output is withheld whole before any row shows it: a web call's strings, read joined
691
- * (TimelineOptions.holds). */
766
+ /** Whether a call of `tool`'s output is withheld whole before any row shows it: a web call's output, read as it came
767
+ * through `holds` (TimelineOptions.holds, web-calls.ts webHeld). */
692
768
  const withheld = (tool, text) => (options.holds && text ? webHeld(tool, text, options.holds) : false);
693
769
  const failure = (text) => scrubUrls(firstLine(str(json(text)?.message) ?? diagnosticOf(text) ?? text)) || "no detail";
694
770
  /** Whether a result is a call's refusal before it ran: an error its host marked so in its details (CALL_REFUSED),
@@ -698,11 +774,18 @@ function createProjector(options) {
698
774
  const endedWithRun = (view) => view.isError && obj(view.details)?.[CALL_ENDED_WITH_RUN] === true;
699
775
  /** A call's name on its rows: a refused one's in plain words (refusedLabel), else its label. */
700
776
  const nameFor = (tool, args, view, result) => (refused(view) ? refusedLabel(labelled(tool), shown(args)) : label(tool, args, result));
701
- /** The `tool_use` row of a call; `fields` is what differs between a stored call and a nested one. */
702
- const useRow = (conv, rowId, callId, name, args, fields) => make("tool_use", conv, rowId, { summary: label(name, args), tool_name: name, tool_use_id: callId, tool_input_preview: inputPreview(args, caps.preview), ...inputOf(args), ...fields });
703
- /** A `calls` read's `tool_input` (inputShown); none when the arguments themselves are withheld. */
704
- const inputOf = (args) => {
705
- const shown = options.calls ? obj(inputShown(args, caps.text, options.redact, options.calls.held)) : undefined;
777
+ /** The `tool_use` row of a call: its summary and preview from `args`, as its rows show them (argsOf), and a `calls`
778
+ * read's `tool_input` from `raw`, the arguments as the call came; `fields` is what differs between a stored call and
779
+ * a nested one. Arguments argsOf withholds whole preview as "[redacted]". */
780
+ const useRow = (conv, rowId, callId, name, args, raw, fields) => make("tool_use", conv, rowId, { summary: label(name, args), tool_name: name, tool_use_id: callId, tool_input_preview: withheldArgs.has(args) ? "[redacted]" : inputPreview(args, caps.preview), ...inputOf(args, raw), ...fields });
781
+ /** A `calls` read's `tool_input` (inputShown), at most `calls.result` characters of names and values a row: the raw arguments
782
+ * through `calls.input`, else the arguments as the rows show them. None when the arguments themselves are withheld:
783
+ * argsOf reads `raw` whole through `holds`, so a value split across two of the raw strings withholds both. */
784
+ const inputOf = (args, raw) => {
785
+ if (!options.calls || withheldArgs.has(args))
786
+ return {};
787
+ const { result, input, held } = options.calls;
788
+ const shown = obj(input ? inputShown(raw, result, input, options.redact, held) : inputShown(args, result, (text) => text, options.redact, held));
706
789
  return shown ? { tool_input: shown } : {};
707
790
  };
708
791
  /** A call's output as a `calls` read shows it (tool_result_text): redacted by its redactor, else the rows' own, then its
@@ -901,7 +984,8 @@ function createProjector(options) {
901
984
  const [id, name] = [str(block.id), str(block.name)];
902
985
  if (block.type !== "toolCall" || !id || !name)
903
986
  return;
904
- const args = argsOf(obj(block.arguments) ?? {});
987
+ const raw = obj(block.arguments) ?? {};
988
+ const args = argsOf(raw);
905
989
  if (BROWSER_OPENERS.has(name) && !browsers.has(conv)) {
906
990
  browsers.add(conv);
907
991
  add(make("phase", conv, `${base}:${index}:session`, { summary: "A live browser session started" }));
@@ -910,7 +994,7 @@ function createProjector(options) {
910
994
  // made inside a call of the harness's own (Codex's `exec`) under that call, which its record names. SDK calls keep
911
995
  // their validated explicit parent.
912
996
  const nesting = (entry.recordedCall ? (entry.parentCall ?? nestingCallOf(id)) : undefined) ?? str(obj(entry.data)?.parentCallId);
913
- const use = useRow(conv, `${base}:${index}`, id, name, args, { round, ...(nesting ? { parent_tool_use_id: nesting } : {}) });
997
+ const use = useRow(conv, `${base}:${index}`, id, name, args, raw, { round, ...(nesting ? { parent_tool_use_id: nesting } : {}) });
914
998
  const before = early.get(`${conv}:${id}`);
915
999
  const opened = { conv, name, args, round, use, done: before !== undefined };
916
1000
  calls.set(`${conv}:${id}`, opened);
@@ -1070,7 +1154,7 @@ function createProjector(options) {
1070
1154
  function nested(conv, id, parent, name, raw) {
1071
1155
  const args = argsOf(raw);
1072
1156
  const round = calls.get(`${conv}:${parent}`)?.round;
1073
- const use = useRow(conv, `${conv}:n:${id}`, id, name, args, { round, parent_tool_use_id: parent });
1157
+ const use = useRow(conv, `${conv}:n:${id}`, id, name, args, raw, { round, parent_tool_use_id: parent });
1074
1158
  calls.set(`${conv}:${id}`, { conv, name, args, round, use, done: false });
1075
1159
  rows.push(use);
1076
1160
  return use;
@@ -7,12 +7,14 @@ export type WebShown = (keep: number) => string;
7
7
  /** Whether a text holds a held value no cut in place takes (key-refusal.ts withheldWhole): `joined` is `parts` joined
8
8
  * by line breaks, for a reader that reads each part by itself too (adapter-run-spec.ts answersCut). */
9
9
  export type WebHolds = (joined: string, parts: readonly string[]) => boolean;
10
- /** Whether `text`, a web call's output, is withheld whole: `holds` (key-refusal.ts withheldWhole) finds a held value in
11
- * its JSON's strings joined by line breaks (false for an output that is not a web call's JSON). They are read in the
12
- * order the output is written back in (stringsOf) and, where that differs, in the order it was written (writtenStrings).
13
- * Every reader asks this first: the runner before it stores the answer (answersCut), a timeline before its row shows.
14
- * Each string is cut on its own wherever the output is shown, and no view joins across the JSON's punctuation between
15
- * two strings, so a held value split across two of them is found only here. */
10
+ /** Whether `text`, a web call's output, is withheld whole: `holds` (key-refusal.ts withheldWhole) reads the output as it
11
+ * came, through the matcher's join view (redact/match.ts joinOf: a JSON text's strings joined), then its JSON's strings
12
+ * joined by line breaks with the lines after the JSON, once its values alone and once with each property name before its
13
+ * value. They are read in the order the output is written back in (stringsOf) and, where that differs, in the order it
14
+ * was written (writtenStrings). Every reader asks this first: the runner before it stores the answer (answersCut), a
15
+ * timeline before its row shows. Each string is cut on its own wherever the output is shown, so a held value split across
16
+ * two of them, or across a property name and its value, is found only here. False for an output that is not a web
17
+ * call's JSON. */
16
18
  export declare function webHeld(tool: string, text: string, holds: WebHolds): boolean;
17
19
  /** `text`, a call of `tool`'s output, with `cut` (the run's redactor) applied to each string of its JSON by itself, its
18
20
  * property names too, and to the lines after it, never to its JSON line whole: the redactor reads a run of more than
@@ -78,18 +78,22 @@ function webRead(tool, text) {
78
78
  }
79
79
  return isObj(read) ? { read, end } : undefined;
80
80
  }
81
- /** Whether `text`, a web call's output, is withheld whole: `holds` (key-refusal.ts withheldWhole) finds a held value in
82
- * its JSON's strings joined by line breaks (false for an output that is not a web call's JSON). They are read in the
83
- * order the output is written back in (stringsOf) and, where that differs, in the order it was written (writtenStrings).
84
- * Every reader asks this first: the runner before it stores the answer (answersCut), a timeline before its row shows.
85
- * Each string is cut on its own wherever the output is shown, and no view joins across the JSON's punctuation between
86
- * two strings, so a held value split across two of them is found only here. */
81
+ /** Whether `text`, a web call's output, is withheld whole: `holds` (key-refusal.ts withheldWhole) reads the output as it
82
+ * came, through the matcher's join view (redact/match.ts joinOf: a JSON text's strings joined), then its JSON's strings
83
+ * joined by line breaks with the lines after the JSON, once its values alone and once with each property name before its
84
+ * value. They are read in the order the output is written back in (stringsOf) and, where that differs, in the order it
85
+ * was written (writtenStrings). Every reader asks this first: the runner before it stores the answer (answersCut), a
86
+ * timeline before its row shows. Each string is cut on its own wherever the output is shown, so a held value split across
87
+ * two of them, or across a property name and its value, is found only here. False for an output that is not a web
88
+ * call's JSON. */
87
89
  export function webHeld(tool, text, holds) {
88
90
  const web = webRead(tool, text);
89
91
  return web ? heldIn(web, text, holds) : false;
90
92
  }
91
93
  /** webHeld of an output already read (webRead). */
92
94
  function heldIn(web, text, holds) {
95
+ if (holds(text, [text]))
96
+ return true;
93
97
  const after = web.end < 0 ? [] : [text.slice(web.end + 1)];
94
98
  const line = web.end < 0 ? text : text.slice(0, web.end);
95
99
  const asked = (strings) => {
@@ -31,6 +31,12 @@ export declare function heldAs(name: string, args: unknown): {
31
31
  readonly tool: string;
32
32
  readonly args: unknown;
33
33
  } | undefined;
34
+ /** Why a run can't write a file (a screenshot's save_as, a script's op held as write), or undefined where it can: "not
35
+ * given", write is not among the agent's `tools` (none given, none: leaving write out is how its owner keeps it from
36
+ * writing, whatever write's setting says); "denied", write's `permission` is deny; "no approver", it asks and no one can
37
+ * approve (`approvers` false). The one answer the run's gate refuses by and its files note and bound tools offer by. */
38
+ export type WriteBar = "not given" | "denied" | "no approver";
39
+ export declare const writeBar: (tools: readonly string[] | undefined, permission: Permission, approvers: boolean) => WriteBar | undefined;
34
40
  /** A session's `{name -> settings key}` map (nameMapOf). */
35
41
  export type NameMap = ReadonlyMap<string, string>;
36
42
  /** Every name a session on `harness` gives its tools, to the settings key each is held to: the shell family (bash's),
@@ -190,6 +196,7 @@ export declare function runGate(where: {
190
196
  }, runId: string, revision: {
191
197
  kind: string;
192
198
  body: {
199
+ tools?: readonly string[];
193
200
  toolSettings?: unknown;
194
201
  harness?: string;
195
202
  approvals?: Approvals;
@@ -241,7 +248,8 @@ export declare class RunGate {
241
248
  runId: string;
242
249
  harness?: string;
243
250
  computer?: boolean; /** The run's computer kind (its revision's setting): the key a computer tool's refusal and ask name on a tie (kindSetting). */
244
- kind?: string;
251
+ kind?: string; /** The tools the agent is given (its revision's `tools`): a screenshot's save_as and a script's op held as write are refused unless write is among them; none given, none (writeBar). */
252
+ tools?: readonly string[];
245
253
  effectOf?: (name: string) => ToolEffect | undefined; /** The arguments each MCP tool's listing in the run's pin declares (ClaimMcp.argumentsOf), for a pinned tool's closure (pinRefusal). */
246
254
  argumentsOf?: ArgumentsOf; /** The harness's adapter facts on the owner's table (its native tools' names, nameMapOf); undefined for one with none. */
247
255
  facts: AdapterFacts | undefined;
@@ -250,6 +258,10 @@ export declare class RunGate {
250
258
  /** A tool's permission now (permissionOf): the revision's own over the server's setting, read at each call, so a change
251
259
  * reaches a live run at its next call; under approvals "never", an ask is an allow. */
252
260
  readonly policy: (tool: string) => Permission;
261
+ /** Why this run can't write a file now (writeBar over its agent's tools, write's permission and whether anyone can
262
+ * approve), or undefined where it can: what decide refuses a save_as or a script's write by, and what the run's files
263
+ * note and computer_screenshot's save_as are offered by. */
264
+ readonly writeBar: () => WriteBar | undefined;
253
265
  /** The gate's answer for one call before its intent, for a loop that parks and answers asks itself (the runner's adapter
254
266
  * loops, pi's and the CLI harnesses'): run it, ask a person, or refuse it with the words the model reads. The order:
255
267
  * the deny (with where it was set, and that nothing was sent or charged), a pin, bash's policy (policyRefusal), then
package/dist/tool-gate.js CHANGED
@@ -77,7 +77,8 @@ const KIND_TOOLS = (() => {
77
77
  })();
78
78
  /** A script's computer op (computer_op's `op`) that runs on the computer what one of the run's own tools runs, held to
79
79
  * that tool's setting: the shell is bash's, a program started to run on (processes.start) bash_background's (bash's
80
- * setting, and a read-only bash policy refuses it), a file's write is write's, a file's read, listing or stat is
80
+ * setting, and a read-only bash policy refuses it), a file's write is write's (and needs write among the agent's tools,
81
+ * writeBar), a file's read, listing or stat is
81
82
  * read's. The other ops (apps, raw input) are the computer kind's, computer_op's own key (KIND_TOOLS). */
82
83
  const OP_HELD_AS = Object.freeze({ "shell.run": "bash", "processes.start": "bash_background", "files.write": "write", "files.read": "read", "files.list": "read", "files.stat": "read" });
83
84
  /** The ops whose command runs in the computer's shell. */
@@ -95,6 +96,22 @@ export function heldAs(name, args) {
95
96
  const fields = (given !== null && typeof given === "object" ? given : {});
96
97
  return { tool, args: SHELL_OPS.has(op) ? { command: fields.command, ...(fields.cwd !== undefined ? { cwd: fields.cwd } : {}) } : { path: fields.path } };
97
98
  }
99
+ /** The path a computer_screenshot call saves the screen to in the run's folder (its `save_as`), held to write's setting
100
+ * as a file the write tool writes is; undefined for any other call, a screenshot with no save_as included. */
101
+ function savedAs(name, args) {
102
+ if (name !== "computer_screenshot" || args === null || typeof args !== "object")
103
+ return undefined;
104
+ const path = args.save_as;
105
+ return path === undefined ? undefined : { path };
106
+ }
107
+ /** What a screenshot's refusal for write's setting adds to write's own words: why write's setting holds it. */
108
+ const SAVED_AS_WORDS = "computer_screenshot with save_as writes a file into the run's files, so write's setting holds it; a screenshot without save_as is not held to it.";
109
+ export const writeBar = (tools, permission, approvers) => !tools?.includes("write") ? "not given" : permission === "deny" ? "denied" : permission === "ask" && !approvers ? "no approver" : undefined;
110
+ /** The refusal of a call that writes a file (`writes`: what it does, in words; `instead`: what to do, or "") for an agent
111
+ * whose tools leave write out (writeBar's "not given"). */
112
+ const notGivenWriteText = (writes, instead, ran) => `${DENIED_OPENING}${writes}, and this agent is not given write, so it can't write one.${instead ? ` ${instead}` : ""} ${ran === "no" ? NOT_RUN : RAN_UNKNOWN}`;
113
+ /** What a screenshot's save_as does, and what to do instead, in a not-given refusal. */
114
+ const SAVED_AS_WRITES = ["computer_screenshot with save_as writes a file into the run's files", "Take the screenshot without save_as."];
98
115
  const STRICTNESS = { allow: 0, ask: 1, deny: 2 };
99
116
  /** Every name a session on `harness` gives its tools, to the settings key each is held to: the shell family (bash's),
100
117
  * table, own and decision tools, read_skill_file (`read`), the kinds' tools (a shared one by its first kind), nativeTools,
@@ -351,7 +368,7 @@ export function previewOf(text) {
351
368
  export function runGate(where, runId, revision, serverSettings, approvers) {
352
369
  // The run's computer kind, from its revision's setting (as the claim starts it): a computer tool's words name it.
353
370
  const kind = settingOfDefinition(revision.body)?.computer.kind;
354
- return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(kind !== undefined ? { kind } : {}), ...(where.effectOf ? { effectOf: where.effectOf } : {}), ...(where.argumentsOf ? { argumentsOf: where.argumentsOf } : {}), facts: where.facts }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
371
+ return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, tools: revision.body.tools ?? [], ...(where.computer === undefined ? {} : { computer: where.computer }), ...(kind !== undefined ? { kind } : {}), ...(where.effectOf ? { effectOf: where.effectOf } : {}), ...(where.argumentsOf ? { argumentsOf: where.argumentsOf } : {}), facts: where.facts }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
355
372
  }
356
373
  /** The host tools that run on a computer that holds the run's shell (the kernel registry's, for shell "computer"). */
357
374
  const ON_COMPUTER = new Set(hostToolDefs({ maxExecS: 600, shell: "computer" }).map((def) => def.name));
@@ -397,6 +414,10 @@ export class RunGate {
397
414
  /** A tool's permission now (permissionOf): the revision's own over the server's setting, read at each call, so a change
398
415
  * reaches a live run at its next call; under approvals "never", an ask is an allow. */
399
416
  policy = (tool) => this.setting(tool).permission;
417
+ /** Why this run can't write a file now (writeBar over its agent's tools, write's permission and whether anyone can
418
+ * approve), or undefined where it can: what decide refuses a save_as or a script's write by, and what the run's files
419
+ * note and computer_screenshot's save_as are offered by. */
420
+ writeBar = () => writeBar(this.where.tools, this.policy("write"), this.approvers);
400
421
  /** The gate's answer for one call before its intent, for a loop that parks and answers asks itself (the runner's adapter
401
422
  * loops, pi's and the CLI harnesses'): run it, ask a person, or refuse it with the words the model reads. The order:
402
423
  * the deny (with where it was set, and that nothing was sent or charged), a pin, bash's policy (policyRefusal), then
@@ -426,8 +447,13 @@ export class RunGate {
426
447
  return off;
427
448
  const own = this.computerOwns(name);
428
449
  const held = heldAs(name, args);
429
- if (held && this.policy(name) !== "deny")
450
+ if (held && this.policy(name) !== "deny") {
451
+ // An op held as write (files.write) writes a file, into the run's files on a desktop that mounts them, as save_as
452
+ // does: an agent not given write is refused it first, whatever write's setting says (writeBar).
453
+ if (held.tool === "write" && this.writeBar() === "not given")
454
+ return { deny: notGivenWriteText(`computer_op ${args.op} writes a file`, "", ran) };
430
455
  return this.onComputer().decide(held.tool, held.args, options);
456
+ }
431
457
  const key = this.keyOf(name) ?? name;
432
458
  const tool = this.askedAs(name);
433
459
  const verdict = this.policy(name);
@@ -445,6 +471,20 @@ export class RunGate {
445
471
  const policed = this.policyRefusal(key, name, args);
446
472
  if (policed)
447
473
  return { deny: policed };
474
+ // A screenshot saved into the run's files (save_as) is a file written as write writes one: write's setting holds it
475
+ // too, after the kind's deny, and the stricter decides (write's deny refuses it before the computer is asked, write's
476
+ // ask puts it to a person, as the kind's does). An agent whose tools leave write out is refused it first: no setting
477
+ // offers a tool the agent was not given (write's default is allow).
478
+ const saved = savedAs(name, args);
479
+ if (saved) {
480
+ if (this.writeBar() === "not given")
481
+ return { deny: notGivenWriteText(...SAVED_AS_WRITES, ran) };
482
+ const write = await this.decide("write", saved, options);
483
+ if (typeof write === "object")
484
+ return { deny: `${write.deny} ${SAVED_AS_WORDS}` };
485
+ if (write === "ask")
486
+ return "ask";
487
+ }
448
488
  if (verdict === "allow")
449
489
  return "allow";
450
490
  return this.approvers ? "ask" : { deny: noApproverText(tool, ran) };
@@ -11,7 +11,7 @@ import { decisionsOf } from "./decisions.js";
11
11
  import { ApiError, invalid } from "./errors.js";
12
12
  import { checkKey } from "./key-check.js";
13
13
  import { openSealed, putSealedKey, removeSealedKey, sealFingerprint, UNREADABLE } from "./server-keys.js";
14
- import { rowSecrets, rowUnlocks, SEAL_KEY_ENV, sealKeyOf, TOOL_KEYS } from "./tool-keys.js";
14
+ import { rowSecrets, rowUnlocks, SEAL_KEY_ENV, sealKeyIn, TOOL_KEYS } from "./tool-keys.js";
15
15
  import { toolsView } from "./tools.js";
16
16
  import { sealColumn, sealedAt } from "./store/index.js";
17
17
  import { isObject, unknownFields } from "./validate.js";
@@ -50,9 +50,7 @@ class ToolKeysOverStore {
50
50
  this.env = env;
51
51
  this.say = say;
52
52
  // There is always a seal key (seal-key.ts bootSealKey): no tool key is ever kept, or read, without one.
53
- const key = sealKeyOf(env[SEAL_KEY_ENV]);
54
- if (!key)
55
- throw new Error(`tool keys are kept under the server's seal key (${SEAL_KEY_ENV}), and none was handed over: the server does not start without one`);
53
+ const key = sealKeyIn(env[SEAL_KEY_ENV], "tool keys");
56
54
  this.key = key;
57
55
  this.sealCheck = sealFingerprint(key);
58
56
  }
@@ -109,3 +109,14 @@ export declare function rowSecrets(row: {
109
109
  }[], changedAt: (name: string) => string | null): SecretMeta[];
110
110
  /** The seal key `text` gives: 32 bytes in base64 (or base64url), else none. */
111
111
  export declare function sealKeyOf(text: string | undefined): Buffer | undefined;
112
+ /** Why `text`, handed as a seal key, is none (sealKeyOf), by its length alone: never its value, a secret. A host whose
113
+ * generator counts bytes where characters were meant hands 60 characters, and the refusal that stops a start says so. */
114
+ export declare function notASealKey(text: string): string;
115
+ /** The seal key `handed` (SEAL_KEY_ENV's value) gives, for a reader of `what` kept under it; else one refusal, every
116
+ * reader's: the one handed by its length (notASealKey), never its value, or that none was. In production the start boots
117
+ * the key first (seal-key.ts bootSealKey), which refuses a malformed one itself; this is each reader's own guard.
118
+ * `Refused`: the error a caller's own refusals are (a runner's RunnerRefused); `none`: what to do when none was handed. */
119
+ export declare function sealKeyIn(handed: string | undefined, what: string, { Refused, none }?: {
120
+ Refused?: new (message: string) => Error;
121
+ none?: string;
122
+ }): Buffer;
package/dist/tool-keys.js CHANGED
@@ -83,3 +83,19 @@ export function sealKeyOf(text) {
83
83
  const trimmed = text?.trim() ?? "";
84
84
  return /^[A-Za-z0-9+/_-]{43}=?$/.test(trimmed) ? Buffer.from(trimmed, "base64") : undefined;
85
85
  }
86
+ /** Why `text`, handed as a seal key, is none (sealKeyOf), by its length alone: never its value, a secret. A host whose
87
+ * generator counts bytes where characters were meant hands 60 characters, and the refusal that stops a start says so. */
88
+ export function notASealKey(text) {
89
+ const length = text.trim().length;
90
+ return `is not 32 bytes in base64 (43 characters, or 44 ending in =; it has ${length}${length === 43 || length === 44 ? ", but not in that form" : ""})`;
91
+ }
92
+ /** The seal key `handed` (SEAL_KEY_ENV's value) gives, for a reader of `what` kept under it; else one refusal, every
93
+ * reader's: the one handed by its length (notASealKey), never its value, or that none was. In production the start boots
94
+ * the key first (seal-key.ts bootSealKey), which refuses a malformed one itself; this is each reader's own guard.
95
+ * `Refused`: the error a caller's own refusals are (a runner's RunnerRefused); `none`: what to do when none was handed. */
96
+ export function sealKeyIn(handed, what, { Refused = Error, none = "start the server, which makes or opens it" } = {}) {
97
+ const key = sealKeyOf(handed);
98
+ if (key)
99
+ return key;
100
+ throw new Refused(`${what} are kept under the server's seal key (${SEAL_KEY_ENV}), and ${handed?.trim() ? `the one handed ${notASealKey(handed)}` : `none was handed: ${none}`}`);
101
+ }