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

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 (312) hide show
  1. package/CHANGELOG.md +281 -0
  2. package/README.md +246 -66
  3. package/dist/acp-package.d.ts +2 -0
  4. package/dist/adapters.d.ts +15 -3
  5. package/dist/adapters.js +17 -6
  6. package/dist/agent-package.d.ts +3 -3
  7. package/dist/agent-package.js +17 -8
  8. package/dist/api-keys.d.ts +76 -0
  9. package/dist/api-keys.js +217 -0
  10. package/dist/api-only.d.ts +15 -5
  11. package/dist/api-only.js +32 -8
  12. package/dist/box-paths.d.ts +4 -3
  13. package/dist/box-paths.js +7 -4
  14. package/dist/browser-hold.d.ts +23 -0
  15. package/dist/browser-hold.js +48 -0
  16. package/dist/browser-person.d.ts +3 -0
  17. package/dist/browser-person.js +4 -1
  18. package/dist/chatgpt-plan.d.ts +18 -8
  19. package/dist/chatgpt-plan.js +91 -34
  20. package/dist/claude-login-token.d.ts +117 -0
  21. package/dist/claude-login-token.js +737 -0
  22. package/dist/claude-login.d.ts +120 -22
  23. package/dist/claude-login.js +347 -63
  24. package/dist/claude-sign-in.d.ts +17 -6
  25. package/dist/claude-sign-in.js +42 -39
  26. package/dist/cli.js +33 -10
  27. package/dist/composio-made.d.ts +4 -0
  28. package/dist/composio-made.js +4 -0
  29. package/dist/composio-preset.d.ts +43 -2
  30. package/dist/composio-preset.js +92 -4
  31. package/dist/computer-attach.d.ts +35 -17
  32. package/dist/computer-attach.js +301 -49
  33. package/dist/computer-held-routes.d.ts +5 -4
  34. package/dist/computer-held-routes.js +29 -8
  35. package/dist/computer-held.d.ts +6 -1
  36. package/dist/computer-held.js +14 -0
  37. package/dist/computer-record.js +4 -2
  38. package/dist/computer-viewer.js +4 -1
  39. package/dist/computers.d.ts +10 -10
  40. package/dist/computers.js +5 -5
  41. package/dist/console/assets/{backend-Boh7tC4i.js → backend-CSAWUqtZ.js} +19 -19
  42. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  43. package/dist/console/assets/index-DPh29cyz.js +747 -0
  44. package/dist/console/index.html +2 -2
  45. package/dist/decisions.d.ts +1 -1
  46. package/dist/decisions.js +1 -1
  47. package/dist/dial-relay.d.ts +25 -4
  48. package/dist/dial-relay.js +129 -1
  49. package/dist/docker-host-addresses.d.ts +22 -11
  50. package/dist/docker-host-addresses.js +38 -26
  51. package/dist/env-switch.d.ts +8 -0
  52. package/dist/env-switch.js +31 -2
  53. package/dist/errors.d.ts +1 -0
  54. package/dist/errors.js +2 -0
  55. package/dist/fal-price.d.ts +56 -20
  56. package/dist/fal-price.js +400 -90
  57. package/dist/handed-values.d.ts +43 -1
  58. package/dist/handed-values.js +119 -2
  59. package/dist/harness-archive.d.ts +13 -10
  60. package/dist/harness-archive.js +60 -34
  61. package/dist/harness-check.d.ts +3 -1
  62. package/dist/harness-check.js +25 -46
  63. package/dist/harness-keys.d.ts +73 -27
  64. package/dist/harness-keys.js +194 -61
  65. package/dist/harness-recipe-entry.d.ts +8 -7
  66. package/dist/harness-recipe-entry.js +21 -32
  67. package/dist/harness-recipe.d.ts +38 -25
  68. package/dist/harness-recipe.js +49 -36
  69. package/dist/harness-sign-in.js +12 -23
  70. package/dist/harness-table.d.ts +10 -3
  71. package/dist/harness-table.js +26 -21
  72. package/dist/harness.d.ts +1 -0
  73. package/dist/harness.js +17 -5
  74. package/dist/hosted-search.d.ts +1 -1
  75. package/dist/hosted-search.js +1 -2
  76. package/dist/import-worker.d.ts +4 -2
  77. package/dist/import-worker.js +9 -2
  78. package/dist/in-flight.d.ts +26 -0
  79. package/dist/in-flight.js +52 -0
  80. package/dist/key-refusal.d.ts +9 -4
  81. package/dist/key-refusal.js +107 -25
  82. package/dist/learn/ledger.d.ts +170 -0
  83. package/dist/learn/ledger.js +218 -0
  84. package/dist/learn/promote.d.ts +3 -3
  85. package/dist/learn/promote.js +1 -1
  86. package/dist/learn/secrets.d.ts +13 -3
  87. package/dist/learn/secrets.js +118 -17
  88. package/dist/learning-cost.d.ts +28 -23
  89. package/dist/learning-cost.js +19 -23
  90. package/dist/link-check.js +1 -1
  91. package/dist/live-reach.d.ts +2 -0
  92. package/dist/live-reach.js +2 -0
  93. package/dist/llms.txt +1 -1
  94. package/dist/marketplace.d.ts +77 -0
  95. package/dist/marketplace.js +224 -0
  96. package/dist/mcp-api-only-origins.d.ts +35 -0
  97. package/dist/mcp-api-only-origins.js +57 -0
  98. package/dist/mcp-gateway.d.ts +7 -5
  99. package/dist/mcp-gateway.js +9 -12
  100. package/dist/mcp-secret-writes.js +5 -3
  101. package/dist/mcp-servers-store.d.ts +28 -6
  102. package/dist/mcp-servers-store.js +53 -4
  103. package/dist/media-duration.d.ts +3 -0
  104. package/dist/media-duration.js +90 -9
  105. package/dist/micro.d.ts +2 -0
  106. package/dist/micro.js +2 -0
  107. package/dist/model-form.d.ts +5 -4
  108. package/dist/model-form.js +11 -7
  109. package/dist/model.d.ts +10 -6
  110. package/dist/model.js +16 -11
  111. package/dist/monid.d.ts +14 -1
  112. package/dist/monid.js +103 -26
  113. package/dist/ollama-provider.d.ts +7 -1
  114. package/dist/ollama-provider.js +14 -2
  115. package/dist/openapi.js +210 -37
  116. package/dist/otel/genai.d.ts +65 -0
  117. package/dist/otel/genai.js +116 -0
  118. package/dist/otel/tracer.d.ts +55 -0
  119. package/dist/otel/tracer.js +308 -0
  120. package/dist/page.d.ts +2 -0
  121. package/dist/page.js +3 -1
  122. package/dist/paid-calls.d.ts +1 -32
  123. package/dist/paid-calls.js +4 -39
  124. package/dist/place-offers.d.ts +4 -0
  125. package/dist/place-offers.js +7 -4
  126. package/dist/provider.d.ts +11 -2
  127. package/dist/provider.js +59 -8
  128. package/dist/redact/match.d.ts +30 -3
  129. package/dist/redact/match.js +422 -41
  130. package/dist/refusal-words.d.ts +11 -0
  131. package/dist/refusal-words.js +11 -0
  132. package/dist/run-census.d.ts +67 -0
  133. package/dist/run-census.js +240 -0
  134. package/dist/run-computer.d.ts +6 -3
  135. package/dist/run-computer.js +4 -1
  136. package/dist/run-cut.d.ts +15 -6
  137. package/dist/run-cut.js +30 -9
  138. package/dist/run-files.d.ts +3 -0
  139. package/dist/run-files.js +3 -0
  140. package/dist/run-launch.d.ts +12 -1
  141. package/dist/run-launch.js +9 -10
  142. package/dist/run-learning-served.d.ts +4 -2
  143. package/dist/run-model-key.d.ts +8 -0
  144. package/dist/run-model-key.js +31 -1
  145. package/dist/run-reads-over-store.d.ts +24 -6
  146. package/dist/run-reads-over-store.js +67 -23
  147. package/dist/run-recordings.d.ts +5 -1
  148. package/dist/run-recordings.js +39 -14
  149. package/dist/run-timeline-served.d.ts +2 -0
  150. package/dist/run-timeline-served.js +2 -2
  151. package/dist/run-usage.d.ts +1 -0
  152. package/dist/run-view.d.ts +1 -2
  153. package/dist/run-view.js +2 -1
  154. package/dist/runnable.d.ts +10 -1
  155. package/dist/runnable.js +20 -8
  156. package/dist/runner/adapter-loop.d.ts +11 -0
  157. package/dist/runner/adapter-loop.js +58 -26
  158. package/dist/runner/adapter-run-spec.d.ts +55 -11
  159. package/dist/runner/adapter-run-spec.js +183 -52
  160. package/dist/runner/adapters/pi.js +25 -3
  161. package/dist/runner/beside.d.ts +9 -2
  162. package/dist/runner/beside.js +27 -9
  163. package/dist/runner/big-writes.js +1 -10
  164. package/dist/runner/claim-secrets.d.ts +27 -10
  165. package/dist/runner/claim-secrets.js +49 -22
  166. package/dist/runner/cli-run-spec.d.ts +6 -0
  167. package/dist/runner/cli-run-spec.js +97 -38
  168. package/dist/runner/computer-journal.d.ts +9 -1
  169. package/dist/runner/computer-journal.js +26 -0
  170. package/dist/runner/conformance/harness.js +1 -1
  171. package/dist/runner/feedback-round.js +3 -0
  172. package/dist/runner/harness-loops.d.ts +6 -5
  173. package/dist/runner/harness-loops.js +7 -7
  174. package/dist/runner/held.d.ts +24 -6
  175. package/dist/runner/journal-kinds.d.ts +5 -0
  176. package/dist/runner/journal-kinds.js +5 -0
  177. package/dist/runner/main.d.ts +11 -6
  178. package/dist/runner/main.js +19 -9
  179. package/dist/runner/mcp-claim.js +31 -3
  180. package/dist/runner/mcp-run.d.ts +9 -0
  181. package/dist/runner/mcp-run.js +11 -5
  182. package/dist/runner/model-route.d.ts +17 -0
  183. package/dist/runner/model-route.js +120 -2
  184. package/dist/runner/presence.d.ts +11 -1
  185. package/dist/runner/presence.js +7 -0
  186. package/dist/runner/reflect-hook.js +1 -1
  187. package/dist/runner/run-child-host.d.ts +22 -8
  188. package/dist/runner/run-child-host.js +128 -41
  189. package/dist/runner/run-child.js +5 -2
  190. package/dist/runner/runner.d.ts +17 -3
  191. package/dist/runner/runner.js +130 -34
  192. package/dist/runner/save-slots.js +2 -1
  193. package/dist/runner/store-port.d.ts +1 -1
  194. package/dist/runner/store-secrets.d.ts +6 -0
  195. package/dist/runner/store-secrets.js +49 -7
  196. package/dist/runner/subagent.d.ts +11 -0
  197. package/dist/runner/subagent.js +16 -38
  198. package/dist/runner/workflow-first.d.ts +35 -15
  199. package/dist/runner/workflow-first.js +38 -25
  200. package/dist/runner/workflow-spec.js +4 -3
  201. package/dist/runs-over-store.d.ts +15 -6
  202. package/dist/runs-over-store.js +33 -21
  203. package/dist/scrub-command.d.ts +73 -0
  204. package/dist/scrub-command.js +307 -0
  205. package/dist/secret-cut.d.ts +73 -0
  206. package/dist/secret-cut.js +291 -4
  207. package/dist/secret-rules.d.ts +143 -0
  208. package/dist/secret-rules.js +2564 -0
  209. package/dist/secrets.d.ts +7 -0
  210. package/dist/secrets.js +20 -0
  211. package/dist/server-keys.d.ts +20 -0
  212. package/dist/server-keys.js +25 -6
  213. package/dist/server.d.ts +65 -13
  214. package/dist/server.js +470 -157
  215. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  216. package/dist/slots.d.ts +9 -0
  217. package/dist/slots.js +45 -0
  218. package/dist/store/index.d.ts +1 -1
  219. package/dist/store/index.js +1 -1
  220. package/dist/store/journal/storage.js +1 -1
  221. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  222. package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
  223. package/dist/store/schema.d.ts +23 -0
  224. package/dist/store/schema.js +58 -2
  225. package/dist/store/seal.d.ts +6 -1
  226. package/dist/store/seal.js +5 -3
  227. package/dist/store/sqlite/run-launch.d.ts +9 -1
  228. package/dist/store/sqlite/run-launch.js +24 -13
  229. package/dist/store/sqlite/run-patch.d.ts +12 -2
  230. package/dist/store/sqlite/run-patch.js +42 -5
  231. package/dist/store/sqlite/store.js +105 -12
  232. package/dist/store/store.d.ts +57 -2
  233. package/dist/store/store.js +20 -0
  234. package/dist/store-reads/learning.d.ts +84 -124
  235. package/dist/store-reads/learning.js +210 -274
  236. package/dist/store-view.d.ts +3 -0
  237. package/dist/store-view.js +3 -3
  238. package/dist/suggestions.js +3 -2
  239. package/dist/template-eval.d.ts +39 -9
  240. package/dist/template-eval.js +191 -60
  241. package/dist/template-import.js +6 -2
  242. package/dist/templates.d.ts +10 -2
  243. package/dist/templates.js +28 -8
  244. package/dist/timeline/labels.d.ts +6 -4
  245. package/dist/timeline/labels.js +18 -6
  246. package/dist/timeline/timeline.d.ts +5 -0
  247. package/dist/timeline/timeline.js +14 -8
  248. package/dist/timeline/util.js +1 -1
  249. package/dist/timeline/web-calls.d.ts +22 -7
  250. package/dist/timeline/web-calls.js +106 -35
  251. package/dist/tool-gate.d.ts +42 -3
  252. package/dist/tool-gate.js +66 -5
  253. package/dist/tool-keys-store.d.ts +2 -4
  254. package/dist/tool-keys-store.js +5 -21
  255. package/dist/tool-keys.d.ts +2 -2
  256. package/dist/tool-keys.js +2 -2
  257. package/dist/tool-list.js +1 -1
  258. package/dist/tool-plane.d.ts +2 -2
  259. package/dist/tool-plane.js +35 -33
  260. package/dist/tools.js +13 -7
  261. package/dist/trigger-targets.d.ts +4 -0
  262. package/dist/trigger-targets.js +9 -2
  263. package/dist/triggers.d.ts +67 -4
  264. package/dist/triggers.js +171 -22
  265. package/dist/until.d.ts +3 -0
  266. package/dist/until.js +11 -0
  267. package/dist/web-fake.d.ts +1 -3
  268. package/dist/web-fake.js +7 -18
  269. package/dist/web-fetch.d.ts +6 -72
  270. package/dist/web-fetch.js +11 -265
  271. package/dist/web-run.d.ts +31 -0
  272. package/dist/web-run.js +90 -0
  273. package/dist/web-save.d.ts +10 -13
  274. package/dist/web-save.js +13 -55
  275. package/dist/web-search.d.ts +9 -127
  276. package/dist/web-search.js +23 -259
  277. package/dist/wires.d.ts +13 -0
  278. package/dist/wires.js +11 -0
  279. package/dist/workflow-run.d.ts +5 -4
  280. package/dist/workflow-run.js +5 -4
  281. package/dist/workspace/attached-computers.d.ts +32 -9
  282. package/dist/workspace/attached-computers.js +77 -13
  283. package/dist/workspace/computer-deps.d.ts +8 -2
  284. package/dist/workspace/computer-deps.js +10 -3
  285. package/dist/workspace/computer-for-claim.d.ts +12 -1
  286. package/dist/workspace/computer-for-claim.js +83 -11
  287. package/dist/workspace/computer-kept.d.ts +3 -0
  288. package/dist/workspace/computer-kept.js +11 -2
  289. package/dist/workspace/index.d.ts +1 -1
  290. package/dist/workspace/index.js +1 -1
  291. package/dist/workspace/kind-skills.d.ts +4 -0
  292. package/dist/workspace/kind-skills.js +9 -0
  293. package/dist/workspace/paired-route.d.ts +91 -0
  294. package/dist/workspace/paired-route.js +153 -0
  295. package/dist/workspace/synced-folder.js +3 -4
  296. package/dist/wrapped.d.ts +20 -6
  297. package/dist/wrapped.js +66 -25
  298. package/package.json +17 -11
  299. package/skills/agentrun-serve/SKILL.md +4 -0
  300. package/templates/README.md +32 -10
  301. package/dist/console/assets/index-CQ3cJRzI.js +0 -746
  302. package/dist/console/assets/index-DKkaS3a0.css +0 -1
  303. package/dist/exa-keyless.d.ts +0 -34
  304. package/dist/exa-keyless.js +0 -118
  305. package/dist/firecrawl-keyless.d.ts +0 -41
  306. package/dist/firecrawl-keyless.js +0 -152
  307. package/dist/keyless-mcp.d.ts +0 -36
  308. package/dist/keyless-mcp.js +0 -127
  309. package/dist/text-urls.d.ts +0 -38
  310. package/dist/text-urls.js +0 -170
  311. package/dist/web-fetch-direct.d.ts +0 -119
  312. package/dist/web-fetch-direct.js +0 -190
@@ -233,6 +233,14 @@ export declare function folderFiles(dir: string): PackageFiles;
233
233
  /** A package held in memory, by path (template-source.ts keeps regular files alone): its folders are those its files'
234
234
  * paths name. */
235
235
  export declare function memoryFiles(name: string, where: string, files: ReadonlyMap<string, Buffer>): PackageFiles;
236
+ /** Each of a package's triggers (POST /v2/triggers bodies, as its manifest or an export writes them) with no spend cap of
237
+ * its own (target.max_cost_usd, read by isCap here, not left to the trigger's schema), by its index and name. A package
238
+ * with triggers and no budget.per_run_usd is taken only when this is empty, so every run a trigger starts is capped by
239
+ * the budget or by its trigger. readPackage refuses by it, and an export blocks by it (agent-package.ts). */
240
+ export declare function uncappedTriggers(triggers: readonly unknown[]): {
241
+ index: number;
242
+ name: string;
243
+ }[];
236
244
  /** Reads the package at `from` (its folder, or its files: PackageFiles) checked whole: a valid package, or PackageError
237
245
  * with every problem found. */
238
246
  export declare function readPackage(from: string | PackageFiles, { evalFixtures }?: {
@@ -260,7 +268,7 @@ export declare function packageView(p: Package): {
260
268
  license: string | null;
261
269
  author: Json | null;
262
270
  repository: string | null;
263
- category: "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" | "personal" | null;
271
+ category: "personal" | "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" | null;
264
272
  tags: string[];
265
273
  output: {
266
274
  schema: string;
@@ -334,7 +342,7 @@ export declare function packageDetail<Pick>(p: Package, computerHere: (p: Packag
334
342
  license: string | null;
335
343
  author: Json | null;
336
344
  repository: string | null;
337
- category: "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" | "personal" | null;
345
+ category: "personal" | "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" | null;
338
346
  tags: string[];
339
347
  output: {
340
348
  schema: string;
package/dist/templates.js CHANGED
@@ -508,6 +508,20 @@ function fieldsSchema(value, of, bad) {
508
508
  }
509
509
  return { type: "object", additionalProperties: false, ...(required.length ? { required } : {}), properties };
510
510
  }
511
+ /** A spend cap a run can hold: a number above 0 and finite (0, a negative, NaN and Infinity are none). */
512
+ const isCap = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
513
+ /** Each of a package's triggers (POST /v2/triggers bodies, as its manifest or an export writes them) with no spend cap of
514
+ * its own (target.max_cost_usd, read by isCap here, not left to the trigger's schema), by its index and name. A package
515
+ * with triggers and no budget.per_run_usd is taken only when this is empty, so every run a trigger starts is capped by
516
+ * the budget or by its trigger. readPackage refuses by it, and an export blocks by it (agent-package.ts). */
517
+ export function uncappedTriggers(triggers) {
518
+ return triggers.flatMap((trigger, index) => {
519
+ const target = isObject(trigger) ? trigger.target : undefined;
520
+ if (isObject(target) && isCap(target.max_cost_usd))
521
+ return [];
522
+ return [{ index, name: isObject(trigger) && typeof trigger.name === "string" ? trigger.name.trim() : "" }];
523
+ });
524
+ }
511
525
  /** Reads the package at `from` (its folder, or its files: PackageFiles) checked whole: a valid package, or PackageError
512
526
  * with every problem found. */
513
527
  export function readPackage(from, { evalFixtures = true } = {}) {
@@ -554,8 +568,10 @@ export function readPackage(from, { evalFixtures = true } = {}) {
554
568
  bad(MANIFEST, `${field} names one item twice`);
555
569
  return value;
556
570
  };
557
- /** `path` is a regular file inside the package. */
558
- const inside = (path) => typeof path === "string" && !path.startsWith("/") && !path.split("/").some((part) => part === ".." || part === "." || part === "") && kind(path) === "file";
571
+ /** `path`, named in agent.md, passes through a hidden file or folder: one the package leaves out (entries), so never read. */
572
+ const hidden = (path) => typeof path === "string" && path.split("/").some((part) => part.startsWith("."));
573
+ /** `path` is a regular file inside the package, none of its parts hidden (".", ".." and ".env" alike) or empty. */
574
+ const inside = (path) => typeof path === "string" && !path.startsWith("/") && !hidden(path) && !path.split("/").includes("") && kind(path) === "file";
559
575
  const name = src.name;
560
576
  if (src.kind("") !== "dir")
561
577
  throw new PackageError(dir, ["it is not a folder: a package is one"]);
@@ -604,7 +620,7 @@ export function readPackage(from, { evalFixtures = true } = {}) {
604
620
  bad(MANIFEST, "repository is an http(s) URL");
605
621
  // Display only: what a marketplace page and the console's list file it under, and its tags.
606
622
  if (f.category !== undefined && !CATEGORIES.includes(f.category))
607
- bad(MANIFEST, `category is one of ${CATEGORIES.join(", ")}`);
623
+ bad(MANIFEST, `category is one of ${CATEGORIES.join(", ")}, not ${JSON.stringify(f.category)}`);
608
624
  const tags = f.tags === undefined ? [] : Array.isArray(f.tags) && f.tags.length <= MAX_TAGS && f.tags.every((tag) => typeof tag === "string" && TAG.test(tag)) && new Set(f.tags).size === f.tags.length ? f.tags : (bad(MANIFEST, `tags is a list of at most ${MAX_TAGS} tags, each once, each lowercase letters, digits and dashes (${TAG.source})`), []);
609
625
  const harness = f.harness === undefined ? undefined : list(f.harness, "harness", (id) => HARNESSES.includes(id));
610
626
  if (harness && !harness.length)
@@ -703,9 +719,8 @@ export function readPackage(from, { evalFixtures = true } = {}) {
703
719
  bad(MANIFEST, `secrets names ${secret}, a key this server cannot hold: a package needs the keys Settings saves and a run is handed (${PACKAGE_SECRETS.join(", ")})`);
704
720
  // Each run's limits: its spend cap (per_run_usd, the agent's max_cost_usd), required once a budget is given, and the most
705
721
  // requests on free models it makes (max_requests, the agent's max_requests), which a dollar cap cannot bound.
706
- const perRun = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
707
722
  const requests = (value) => value === undefined || (typeof value === "number" && Number.isSafeInteger(value) && value >= 1);
708
- if (f.budget !== undefined && !(isObject(f.budget) && !unknownFields(f.budget, ["per_run_usd", "max_requests"]).length && perRun(f.budget.per_run_usd) && requests(f.budget.max_requests)))
723
+ if (f.budget !== undefined && !(isObject(f.budget) && !unknownFields(f.budget, ["per_run_usd", "max_requests"]).length && isCap(f.budget.per_run_usd) && requests(f.budget.max_requests)))
709
724
  bad(MANIFEST, "budget is {per_run_usd: a number above 0, max_requests: a whole number of free-model requests above 0, when given}");
710
725
  const learningIssue = f.learning === undefined ? undefined : learningSettingIssue(f.learning, "learning");
711
726
  if (learningIssue)
@@ -743,13 +758,18 @@ export function readPackage(from, { evalFixtures = true } = {}) {
743
758
  bad(MANIFEST, `triggers[${i}].source.server ${need.toolkit}: the trigger's server is the mcp need of the toolkit ${need.toolkit}, so that need is required: true. An optional one may have no saved server here, and the trigger would have none`);
744
759
  }
745
760
  });
746
- if (triggers.length && !(isObject(f.budget) && f.budget.per_run_usd !== undefined))
747
- bad(MANIFEST, "budget is required when the package has triggers: {per_run_usd}, each run's cap");
761
+ // Every run a trigger starts is capped: by the package's budget, else by each trigger's own max_cost_usd.
762
+ if (triggers.length && !(isObject(f.budget) && f.budget.per_run_usd !== undefined)) {
763
+ for (const { index, name } of uncappedTriggers(triggers))
764
+ bad(MANIFEST, `triggers[${index}]${name ? ` (${name})` : ""} has no max_cost_usd of its own, and the package has no budget: every run a trigger starts is capped, so give the trigger's target a max_cost_usd above 0, or the package a budget: {per_run_usd}, each run's cap`);
765
+ }
748
766
  let outputSchema;
749
767
  if (f.output !== undefined) {
750
768
  const at = isObject(f.output) ? f.output.schema : undefined;
751
769
  const evalSize = typeof at === "string" && at.startsWith("evals/") && inside(at) ? src.size(at) : 0;
752
- if (!isObject(f.output) || unknownFields(f.output, ["schema"]).length || !inside(at))
770
+ if (isObject(f.output) && typeof at === "string" && hidden(at) && !at.split("/").some((part) => part === "." || part === ".."))
771
+ bad(MANIFEST, `output.schema ${at} is a hidden file: a hidden file or folder is no part of a package, so it is never read. Name a file with no part of its path starting with "."`);
772
+ else if (!isObject(f.output) || unknownFields(f.output, ["schema"]).length || !inside(at))
753
773
  bad(MANIFEST, "output is {schema: a JSON Schema file in the package}");
754
774
  else if (evalSize > MAX_FILE_BYTES || agentBytes + evalSize > MAX_PACKAGE_BYTES) {
755
775
  bad(at, evalSize > MAX_FILE_BYTES ? `is over ${MAX_FILE_BYTES} bytes, a package file's limit: the answer's schema is given to the agent, so it keeps an agent file's limits, under evals/ too` : `takes the agent's files over ${MAX_PACKAGE_BYTES} bytes together, POST /v2/agents' own limit: the answer's schema is given to the agent, so it counts as an agent file, under evals/ too`);
@@ -15,13 +15,15 @@ export type FoldSpec = {
15
15
  };
16
16
  /** Registers the label of one tool, in the past tense, and with `name` what the tool is called where calls are counted
17
17
  * (a run's analytics). `saysFailure`: the label of a call that errored says so itself ("Could not take a screenshot"),
18
- * so its row adds only why. A host adds its own tools here. */
18
+ * so its row adds only why; `true` for every error, or a test of the errored result for the errors whose label says so.
19
+ * A host adds its own tools here. */
19
20
  export declare function registerLabel(tool: string, label: LabelFn, fold?: FoldSpec, { name, saysFailure }?: {
20
21
  name?: string;
21
- saysFailure?: true;
22
+ saysFailure?: true | ((result: ToolResultView) => boolean);
22
23
  }): void;
23
- /** Whether `tool`'s label says a call that errored failed (registerLabel's saysFailure). */
24
- export declare const saysFailure: (tool: string) => boolean;
24
+ /** Whether `tool`'s label says that its errored call `result` failed (registerLabel's saysFailure). `result` is the one
25
+ * the label was given, so the two read the same text. */
26
+ export declare const saysFailure: (tool: string, result: ToolResultView) => boolean;
25
27
  /** What a tool is called where its calls are counted, in plain words: its registered name, else the name it was called by. */
26
28
  export declare const nameOf: (tool: string) => string;
27
29
  /** A finished call's outcome, when its own result says more than that the call returned: a tool that answers a refusal
@@ -3,10 +3,11 @@ import { cut, firstLine, json, list, obj, scrubUrls, str, where } from "./util.j
3
3
  const labels = new Map();
4
4
  const folds = new Map();
5
5
  const names = new Map();
6
- const saying = new Set();
6
+ const saying = new Map();
7
7
  /** Registers the label of one tool, in the past tense, and with `name` what the tool is called where calls are counted
8
8
  * (a run's analytics). `saysFailure`: the label of a call that errored says so itself ("Could not take a screenshot"),
9
- * so its row adds only why. A host adds its own tools here. */
9
+ * so its row adds only why; `true` for every error, or a test of the errored result for the errors whose label says so.
10
+ * A host adds its own tools here. */
10
11
  export function registerLabel(tool, label, fold, { name, saysFailure } = {}) {
11
12
  labels.set(tool, label);
12
13
  if (fold)
@@ -14,10 +15,11 @@ export function registerLabel(tool, label, fold, { name, saysFailure } = {}) {
14
15
  if (name)
15
16
  names.set(tool, name);
16
17
  if (saysFailure)
17
- saying.add(tool);
18
+ saying.set(tool, saysFailure === true ? () => true : saysFailure);
18
19
  }
19
- /** Whether `tool`'s label says a call that errored failed (registerLabel's saysFailure). */
20
- export const saysFailure = (tool) => saying.has(tool);
20
+ /** Whether `tool`'s label says that its errored call `result` failed (registerLabel's saysFailure). `result` is the one
21
+ * the label was given, so the two read the same text. */
22
+ export const saysFailure = (tool, result) => saying.get(tool)?.(result) === true;
21
23
  /** A remote MCP server's tool, read `<server> · <tool>`: by its catalog name, `mcp:<server>/<tool>`, or by the name the
22
24
  * harnesses call it, `mcp__<server>__<tool>` (a server's name has no `_`; `hands` is a harness's own tools'). A tool whose
23
25
  * `mcp__<server>__<tool>` is too long is called by a hashed name (the server's catalog.ts wireName), which reads as no
@@ -162,8 +164,18 @@ registerLabel("browser_read", (_a, result) => {
162
164
  }, { many: (n) => `Read ${n} pages`, subject: (_input, output) => { const url = output && /^url: (\S+)/m.exec(output)?.[1]; return url ? where(url) : undefined; } }, { name: "Read the browser's page" });
163
165
  registerLabel("snapshot", () => "Looked at the page structure", { many: (n) => `Looked at the page structure ${n} times` }, { name: "Look at the page structure" });
164
166
  registerLabel("screenshot", () => "Took a screenshot", { many: (n) => `Took ${n} screenshots` }, { name: "Take screenshots" });
167
+ /** Whether a browser call errored as the browser's refusal before it ran: pi-browser's typed failure, `code: "refused"`
168
+ * with `effect: "none"` (code sent to a browser that takes only actions, an op it does not take), read by those fields,
169
+ * never by its words. A refusal after some of its actions ran (`effect: "partial"`, a take-over mid-batch) is not one. */
170
+ const browserRefused = (result) => {
171
+ const failure = result?.isError === true ? obj(json(result.text)) : undefined;
172
+ return str(failure?.code) === "refused" && str(failure?.effect) === "none";
173
+ };
165
174
  registerLabel("run", (a, result) => {
166
175
  const goto = GOTO.exec(str(a.code) ?? "")?.[1];
176
+ // Refused before it ran: the row says what the browser refused, never that a page failed to open.
177
+ if (browserRefused(result))
178
+ return str(a.code) === undefined ? "The browser refused the action" : goto ? `The browser refused the code to open ${where(goto)}` : "The browser refused the agent's code";
167
179
  if (goto)
168
180
  return `Opened ${where(goto)}`;
169
181
  const sent = obj(result?.details)?.sent;
@@ -171,7 +183,7 @@ registerLabel("run", (a, result) => {
171
183
  ? sent.flatMap((request) => { const r = obj(request); const [method, url] = [str(r?.method), str(r?.url)]; return method && url ? `${method} ${where(url)}` : []; })
172
184
  : [];
173
185
  return requests.length ? `Acted on the page (${requests.length} request${requests.length === 1 ? "" : "s"} sent: ${list(requests)})` : "Acted on the page";
174
- }, { many: (n) => `Acted on the page ${n} times` }, { name: "Open or act on a page in the browser" });
186
+ }, { many: (n) => `Acted on the page ${n} times` }, { name: "Open or act on a page in the browser", saysFailure: browserRefused });
175
187
  registerLabel("browser_downloads", (_a, result) => {
176
188
  const fetched = result && json(result.text)?.fetched;
177
189
  const names = Array.isArray(fetched) ? fetched.flatMap((file) => str(obj(file)?.name) ?? []) : [];
@@ -293,6 +293,11 @@ export type TimelineOptions = {
293
293
  redact?: (text: string) => string;
294
294
  held?: (value: number | bigint) => boolean;
295
295
  };
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;
296
301
  };
297
302
  /** A tool's calls in a run, and how many failed. */
298
303
  export type ToolMetrics = {
@@ -1,7 +1,7 @@
1
1
  import { BROWSER_OPENERS, BROWSER_STEPS, callFailed, endsTurn, failedWith, inputPreview, labelOf, outcomeOf, refusedLabel, savedPaths, saysFailure } from "./labels.js";
2
2
  import { cut, firstLine, firstSentence, json, obj, saidSummary, scrubUrls, str, utf8Bytes } from "./util.js";
3
3
  import { BESIDE_SUFFIX, NOTE_SUFFIX, originMatcher, TRIGGER_LABELS } from "./origin.js";
4
- import { webShownOf, webWithin } from "./web-calls.js";
4
+ import { webHeld, webShownOf, webWithin } from "./web-calls.js";
5
5
  /** The call a nested call (the kernel's NestedCalls: a script's, tools_call's) was made in, read off its id
6
6
  * (`<callId>/<key>`); undefined for a call the model made itself. */
7
7
  export const nestingCallOf = (callId) => {
@@ -683,9 +683,13 @@ function createProjector(options) {
683
683
  const verdict = /^(\w+): /.exec(text);
684
684
  return verdict ? `${verdict[1]}: ${scrubUrls(firstLine(redactText(text.slice(verdict[0].length))))}` : scrubUrls(firstLine(redactText(text)));
685
685
  };
686
- /** A result as its rows show it: its whole output redacted once, which its label, summary and preview are all taken
687
- * from (resultRow); its details and error flag as they came. */
688
- const shownOf = (view) => options.redact ? { ...view, text: view.text ? options.redact(view.text) : view.text, details: redactValue(view.details) } : view;
686
+ /** A result as its rows show it: its whole output redacted once, or "[redacted]" when it is withheld whole (`withheld`),
687
+ * which its label, summary and preview are all taken from (resultRow); its details and error flag as they came. */
688
+ const shownOf = (tool, view) => withheld(tool, view.text) ? { ...view, text: "[redacted]", details: redactValue(view.details) }
689
+ : 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). */
692
+ const withheld = (tool, text) => (options.holds && text ? webHeld(tool, text, options.holds) : false);
689
693
  const failure = (text) => scrubUrls(firstLine(str(json(text)?.message) ?? diagnosticOf(text) ?? text)) || "no detail";
690
694
  /** Whether a result is a call's refusal before it ran: an error its host marked so in its details (CALL_REFUSED),
691
695
  * read by that field, never by its words. */
@@ -711,6 +715,8 @@ function createProjector(options) {
711
715
  const resultText = (tool, text) => {
712
716
  if (!text)
713
717
  return null;
718
+ if (withheld(tool, text))
719
+ return "[redacted]";
714
720
  const web = webShownOf(tool, text, callShown);
715
721
  return web ? webWithin(web, options.calls.result) : cut(callShown(text), options.calls.result);
716
722
  };
@@ -730,8 +736,8 @@ function createProjector(options) {
730
736
  // ok, and never the detail as it came.
731
737
  const worded = shown.text === view.text ? outcome : outcomeOf(tool.name, { ...view, text: shown.text });
732
738
  // A call refused before it ran is named refused already (refusedLabel), and a computer step's label says it could not
733
- // (saysFailure): its row says why, never that it failed.
734
- const failedSummary = refused(view) || saysFailure(tool.name) ? `${named}: ${failure(shown.text)}` : `${named} failed: ${failure(shown.text)}`;
739
+ // (saysFailure, asked of an error alone, with the text its label read): its row says why, never that it failed.
740
+ const failedSummary = refused(view) || (view.isError && saysFailure(tool.name, { text: shown.text, details: view.details, isError: true })) ? `${named}: ${failure(shown.text)}` : `${named} failed: ${failure(shown.text)}`;
735
741
  // One the run's end closed has no outcome: interrupted, as a call cut off reads (interrupt), with no status.
736
742
  const unended = endedWithRun(view);
737
743
  return make("tool_result", conv, rowId, {
@@ -930,7 +936,7 @@ function createProjector(options) {
930
936
  const call = calls.get(`${conv}:${id}`);
931
937
  const name = call?.name ?? str(message.toolName) ?? "tool";
932
938
  const view = viewOf(message);
933
- const shown = shownOf(view);
939
+ const shown = shownOf(name, view);
934
940
  // A call that failed ended nothing: the agent goes on after it, so a message then is still a steer.
935
941
  ended.set(conv, (previous.get(conv) !== "pi.tool-result" || ended.get(conv) === true) && endsTurn(name) && !view.isError);
936
942
  // One an abort cut did end the turn. A round's results come in as its calls end, so one that ended before the abort
@@ -1078,7 +1084,7 @@ function createProjector(options) {
1078
1084
  const text = typeof output === "string" ? output : output !== undefined ? JSON.stringify(output) : (diagnostic ?? "");
1079
1085
  const failed = result.isError === true;
1080
1086
  const view = { text, details: result.details, isError: failed };
1081
- const shown = shownOf(view);
1087
+ const shown = shownOf(call.name, view);
1082
1088
  const named = nameFor(call.name, call.args, view, shown);
1083
1089
  call.done = true;
1084
1090
  call.use.summary = clean(named, caps.summary);
@@ -1,4 +1,4 @@
1
- import { SCRUBBED_URL, trimmed } from "../text-urls.js";
1
+ import { SCRUBBED_URL, trimmed } from "@parcha/agentrun-web/text-urls";
2
2
  export const obj = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
3
3
  export const str = (value) => (typeof value === "string" ? value : undefined);
4
4
  export const cut = (text, max) => (text.length > max ? `${text.slice(0, max - 3)}...` : text);
@@ -1,12 +1,27 @@
1
+ /** The names eachString has tried for a property, counted so a test can bound the work, not time it. */
2
+ export declare const namesTried: {
3
+ count: number;
4
+ };
1
5
  /** A web call's output with each text that gives way cut to `keep` characters (a cut one ending "…"), the rest whole. */
2
6
  export type WebShown = (keep: number) => string;
3
- /** `text`, a call of `tool`'s output, with `cut` (the run's redactor) applied to each string of its JSON by itself and to
4
- * the lines after it, never to its JSON line whole: the redactor reads a run of more than 8,192 characters with no
5
- * whitespace as "[redacted]" (key-refusal.ts redactedAnswer), and a JSON line, whose newlines are escapes, is one such
6
- * run from its text's last space through its links, so cut whole it loses its links and no longer parses. Undefined for
7
- * a tool other than web_search and web_fetch, or an output whose first line is not a JSON object: that one is cut as
8
- * any other tool's. */
9
- export declare function webCut(tool: string, text: string, cut: (text: string) => string): string | undefined;
7
+ /** Whether a text holds a held value no cut in place takes (key-refusal.ts withheldWhole): `joined` is `parts` joined
8
+ * by line breaks, for a reader that reads each part by itself too (adapter-run-spec.ts answersCut). */
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. */
16
+ export declare function webHeld(tool: string, text: string, holds: WebHolds): boolean;
17
+ /** `text`, a call of `tool`'s output, with `cut` (the run's redactor) applied to each string of its JSON by itself, its
18
+ * property names too, and to the lines after it, never to its JSON line whole: the redactor reads a run of more than
19
+ * 8,192 characters with no whitespace as "[redacted]" (key-refusal.ts redactedAnswer), and a JSON line, whose newlines
20
+ * are escapes, is one such run from its text's last space through its links, so cut whole it loses its links and no
21
+ * longer parses. "[redacted]" when `holds` finds a held value split across its strings (webHeld). Undefined for a tool
22
+ * other than web_search and web_fetch, or an output whose first line is not a JSON object: that one is cut as any other
23
+ * tool's. */
24
+ export declare function webCut(tool: string, text: string, cut: (text: string) => string, holds?: WebHolds): string | undefined;
10
25
  /** `text`, a call of `tool`'s output, as a grader reads it (WebShown), each of its strings through `each` first (the
11
26
  * run's redaction, its URLs' query values elided), so a cut never falls inside what that takes out. Undefined for a
12
27
  * tool other than web_search and web_fetch, or an output that is not its JSON. A page's links past a cut are counted
@@ -1,5 +1,7 @@
1
1
  const WEB_SEARCH = "web_search";
2
2
  const WEB_FETCH = "web_fetch";
3
+ /** The names eachString has tried for a property, counted so a test can bound the work, not time it. */
4
+ export const namesTried = { count: 0 };
3
5
  const isObj = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4
6
  /** `text` cut to `keep` characters and marked, never splitting a surrogate pair. */
5
7
  function clip(text, keep) {
@@ -8,33 +10,62 @@ function clip(text, keep) {
8
10
  const code = keep > 0 ? text.charCodeAt(keep - 1) : 0;
9
11
  return `${text.slice(0, code >= 0xd800 && code <= 0xdbff ? keep - 1 : keep)}…`;
10
12
  }
11
- /** Every string in `value`, property names aside, through `each`. */
13
+ /** Every string in `value` through `each`, property names too (a tool may write a value as one): two names `each` makes
14
+ * one are both kept, the later ones numbered, as the runner's cutDeep keeps them (runner/redact.ts). */
12
15
  function eachString(value, each) {
13
16
  if (typeof value === "string")
14
17
  return each(value);
15
18
  if (Array.isArray(value))
16
19
  return value.map((item) => eachString(item, each));
17
- if (isObj(value))
18
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, eachString(item, each)]));
19
- return value;
20
- }
21
- /** How many of `links`, in order, fit in `keep` characters of JSON. */
22
- function linksWithin(links, keep) {
23
- let used = 0;
24
- for (const [i, link] of links.entries()) {
25
- used += JSON.stringify(link).length + 1;
26
- if (used > keep)
27
- return i;
20
+ if (!isObj(value))
21
+ return value;
22
+ const out = {};
23
+ let next;
24
+ for (const [key, item] of Object.entries(value)) {
25
+ const once = each(key);
26
+ let name = once;
27
+ // Each name's count goes on from its last free number: no name is taken back, so every number below it is still taken.
28
+ for (let n = next?.get(once) ?? 2; (namesTried.count++, Object.hasOwn(out, name)); n++) {
29
+ name = `${once} (${n})`;
30
+ (next ??= new Map()).set(once, n + 1);
31
+ }
32
+ Object.defineProperty(out, name, { value: eachString(item, each), enumerable: true, writable: true, configurable: true });
28
33
  }
29
- return links.length;
34
+ return out;
30
35
  }
31
- /** `text`, a call of `tool`'s output, with `cut` (the run's redactor) applied to each string of its JSON by itself and to
32
- * the lines after it, never to its JSON line whole: the redactor reads a run of more than 8,192 characters with no
33
- * whitespace as "[redacted]" (key-refusal.ts redactedAnswer), and a JSON line, whose newlines are escapes, is one such
34
- * run from its text's last space through its links, so cut whole it loses its links and no longer parses. Undefined for
35
- * a tool other than web_search and web_fetch, or an output whose first line is not a JSON object: that one is cut as
36
- * any other tool's. */
37
- export function webCut(tool, text, cut) {
36
+ /** Every string in `value` in the order its object reads (Object.entries: integer-like names first, a name written twice
37
+ * once, with its last value): the order JSON.stringify writes it back in (webCut, webShownOf). With `names`, each
38
+ * property name before its value. */
39
+ function stringsOf(value, names, out = []) {
40
+ if (typeof value === "string")
41
+ out.push(value);
42
+ else if (Array.isArray(value))
43
+ for (const item of value)
44
+ stringsOf(item, names, out);
45
+ else if (isObj(value))
46
+ for (const [key, item] of Object.entries(value)) {
47
+ if (names)
48
+ out.push(key);
49
+ stringsOf(item, names, out);
50
+ }
51
+ return out;
52
+ }
53
+ /** A JSON string as written, and the colon after it when it is a property name. */
54
+ const JSON_STRING = /("(?:[^"\\]|\\.)*")(\s*:)?/g;
55
+ /** Every string in `line`, a JSON text that parses, in the order it is written, each value of a name written twice too;
56
+ * with `names`, each property name as well, before its value. In JSON that parses, a quote outside a string only
57
+ * ever opens one, so the strings are read by JSON_STRING alone. */
58
+ function writtenStrings(line, names) {
59
+ const out = [];
60
+ for (const [, quoted, colon] of line.matchAll(JSON_STRING))
61
+ if (names || !colon)
62
+ out.push(JSON.parse(quoted));
63
+ return out;
64
+ }
65
+ /** `text`, a call of `tool`'s output, read as its tool writes it: the JSON object on its first line, and where that line
66
+ * ends (-1 when it is the whole text). Undefined for a tool other than web_search and web_fetch, or an output whose
67
+ * first line is not a JSON object. */
68
+ function webRead(tool, text) {
38
69
  if (tool !== WEB_SEARCH && tool !== WEB_FETCH)
39
70
  return undefined;
40
71
  const end = text.indexOf("\n");
@@ -45,29 +76,69 @@ export function webCut(tool, text, cut) {
45
76
  catch {
46
77
  return undefined;
47
78
  }
48
- if (!isObj(read))
79
+ return isObj(read) ? { read, end } : undefined;
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. */
87
+ export function webHeld(tool, text, holds) {
88
+ const web = webRead(tool, text);
89
+ return web ? heldIn(web, text, holds) : false;
90
+ }
91
+ /** webHeld of an output already read (webRead). */
92
+ function heldIn(web, text, holds) {
93
+ const after = web.end < 0 ? [] : [text.slice(web.end + 1)];
94
+ const line = web.end < 0 ? text : text.slice(0, web.end);
95
+ const asked = (strings) => {
96
+ const parts = [...strings, ...after];
97
+ return holds(parts.join("\n"), parts);
98
+ };
99
+ return [false, true].some((names) => {
100
+ const back = stringsOf(web.read, names);
101
+ const written = writtenStrings(line, names);
102
+ return asked(back) || (!sameStrings(back, written) && asked(written));
103
+ });
104
+ }
105
+ /** Whether two lists hold the same strings in the same order. */
106
+ const sameStrings = (a, b) => a.length === b.length && a.every((one, i) => one === b[i]);
107
+ /** How many of `links`, in order, fit in `keep` characters of JSON. */
108
+ function linksWithin(links, keep) {
109
+ let used = 0;
110
+ for (const [i, link] of links.entries()) {
111
+ used += JSON.stringify(link).length + 1;
112
+ if (used > keep)
113
+ return i;
114
+ }
115
+ return links.length;
116
+ }
117
+ /** `text`, a call of `tool`'s output, with `cut` (the run's redactor) applied to each string of its JSON by itself, its
118
+ * property names too, and to the lines after it, never to its JSON line whole: the redactor reads a run of more than
119
+ * 8,192 characters with no whitespace as "[redacted]" (key-refusal.ts redactedAnswer), and a JSON line, whose newlines
120
+ * are escapes, is one such run from its text's last space through its links, so cut whole it loses its links and no
121
+ * longer parses. "[redacted]" when `holds` finds a held value split across its strings (webHeld). Undefined for a tool
122
+ * other than web_search and web_fetch, or an output whose first line is not a JSON object: that one is cut as any other
123
+ * tool's. */
124
+ export function webCut(tool, text, cut, holds) {
125
+ const web = webRead(tool, text);
126
+ if (!web)
49
127
  return undefined;
50
- return `${JSON.stringify(eachString(read, cut))}${end < 0 ? "" : cut(text.slice(end))}`;
128
+ if (holds && heldIn(web, text, holds))
129
+ return "[redacted]";
130
+ return `${JSON.stringify(eachString(web.read, cut))}${web.end < 0 ? "" : cut(text.slice(web.end))}`;
51
131
  }
52
132
  /** `text`, a call of `tool`'s output, as a grader reads it (WebShown), each of its strings through `each` first (the
53
133
  * run's redaction, its URLs' query values elided), so a cut never falls inside what that takes out. Undefined for a
54
134
  * tool other than web_search and web_fetch, or an output that is not its JSON. A page's links past a cut are counted
55
135
  * in `links_cut`. */
56
136
  export function webShownOf(tool, text, each = (part) => part) {
57
- if (tool !== WEB_SEARCH && tool !== WEB_FETCH)
58
- return undefined;
59
- const end = text.indexOf("\n");
60
- let read;
61
- try {
62
- read = JSON.parse(end < 0 ? text : text.slice(0, end));
63
- }
64
- catch {
65
- return undefined;
66
- }
67
- const shown = eachString(read, each);
68
- if (!isObj(shown))
137
+ const web = webRead(tool, text);
138
+ if (!web)
69
139
  return undefined;
70
- const after = end < 0 ? "" : each(text.slice(end));
140
+ const shown = eachString(web.read, each);
141
+ const after = web.end < 0 ? "" : each(text.slice(web.end));
71
142
  if (tool === WEB_SEARCH) {
72
143
  const results = shown.results;
73
144
  if (!Array.isArray(results) || !results.every(isObj))
@@ -1,4 +1,4 @@
1
- import { SHELL_FAMILY, SHELL_WATCHERS, shellToolOf } from "@parcha/agentrun-kernel/kernel";
1
+ import { SHELL_FAMILY, SHELL_WATCHERS, type ShellPlace, shellToolOf } from "@parcha/agentrun-kernel/kernel";
2
2
  import { type AdapterFacts } from "@parcha/agentrun-kernel";
3
3
  import type { Workspace } from "./workspace/workspace.js";
4
4
  import { type ToolSettingsRead } from "./tool-plane.js";
@@ -130,8 +130,8 @@ export declare const SETTINGS_UNREAD: unique symbol;
130
130
  export declare const permissionOf: (name: string, server: PermissionSettings, agent?: PermissionSettings, approvals?: Approvals, effect?: ToolEffect) => Permission;
131
131
  /** An approval's price for the person who answers it: USD where the tool declares one (booked through the spend cap's
132
132
  * paidCall), else "not metered" (an unpriced MCP call, the owner's ruling of 11-04), or "priced by usage" for a monid
133
- * endpoint priced by usage: monid estimates its cost only when the call runs, after the person's allow, and its charge
134
- * can pass that estimate (runner/monid-run.ts). */
133
+ * endpoint priced by usage or a fal job: each is priced only when the call runs, after the person's allow, and its
134
+ * charge can pass that estimate (runner/monid-run.ts, fal-price.ts). */
135
135
  export type ApprovalPrice = number | "not metered" | "priced by usage";
136
136
  /** One pending approval, as the run's view shows it (`pending`) and the console's approval card reads it. */
137
137
  export type PendingApproval = {
@@ -197,6 +197,25 @@ export declare function runGate(where: {
197
197
  place?: unknown;
198
198
  };
199
199
  }, serverSettings: () => ToolSettingsRead, approvers: boolean): RunGate;
200
+ /** The tools a run's computer of `kind` serves, by the names its gate decides them by: a desktop's or a phone's own
201
+ * (COMPUTER_TOOLS, held to its kind's key), a browser's (its key), and, where the run's shell is on the computer
202
+ * (`shell` "computer": a sandbox, a desktop that mounts the run's folder), each host tool the agent grants. */
203
+ export declare function computerToolsOf(kind: string, granted: readonly string[], shell: ShellPlace): readonly string[];
204
+ /** The kind of the agent's computer when every tool it serves (computerToolsOf) is set to deny for `revision` under the
205
+ * server's `server` settings, as its run's gate reads them: a run of it never starts that computer. Undefined for an agent
206
+ * with no computer, one whose computer serves none of its tools, or one any of them is allowed or asked of. `shell`: where
207
+ * a run of it has its shell (resolve-computer.ts runShellOf). Settings that do not read deny nothing (the gate asks). */
208
+ export declare function computerDenied(revision: {
209
+ kind: string;
210
+ body: {
211
+ tools?: readonly string[];
212
+ toolSettings?: unknown;
213
+ harness?: string;
214
+ approvals?: Approvals;
215
+ computer?: unknown;
216
+ place?: unknown;
217
+ };
218
+ }, shell: ShellPlace, server: ToolSettingsRead): string | undefined;
200
219
  /** The top-level arguments the listing of the MCP tool `name` (`mcp:<server>/<tool>`) in the run's pin declares under
201
220
  * its inputSchema's `properties`, the snapshot the run offers the model, never a live listing; undefined for a listing
202
221
  * with no `properties` object (nothing to close a pinned call to) and for any other tool. */
@@ -244,6 +263,26 @@ export declare class RunGate {
244
263
  }): Promise<"allow" | "ask" | {
245
264
  deny: string;
246
265
  }>;
266
+ /** The refusal of a call of the run's computer's own tools (computerOwns) once that computer is off for the rest of the
267
+ * run (computerOff): short, decided with no setting read and nothing sent to it, a setting changed since included.
268
+ * Undefined for any other call, or while the computer is on. */
269
+ offRefusal(name: string, options?: {
270
+ readonly replayed?: boolean;
271
+ }): {
272
+ deny: string;
273
+ } | undefined;
274
+ /** The run's computer's kind once it is off for the rest of the run: by the first deny of a call of its own tools
275
+ * (decide, whose refusal says so once), or from a claim's start (turnOff). Undefined while it is on. */
276
+ get computerOff(): string | undefined;
277
+ /** The run's computer off from this claim's start: an earlier claim's deny turned it off for the run
278
+ * (computer-journal.ts computerTurnedOff), so each call of its tools is refused short, never said off again. */
279
+ turnOff(): void;
280
+ /** Set by the first deny of a call of the run's computer's own tools (computerOwns), or by turnOff. */
281
+ private off;
282
+ /** The run's computer kind (where.kind) when `name` is one of that computer's own tools: a desktop's or a phone's
283
+ * (KIND_TOOLS), a browser's (held to the browser key). Undefined for any other call, a shell or file tool the computer
284
+ * runs included: a deny of one of those leaves the computer's own tools as they are. */
285
+ private computerOwns;
247
286
  /** The settings key a call of `name` is held to, the one its refusal and its ask name: a computer tool's is the kind
248
287
  * whose setting decides it (kindSetting), any other's its session's name map. */
249
288
  private keyOf;