@parcha/agentrun-serve 0.1.0-beta.61 → 0.1.0-beta.62

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 (131) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +102 -13
  3. package/dist/api-only.d.ts +4 -0
  4. package/dist/api-only.js +5 -1
  5. package/dist/archil-settings.d.ts +9 -0
  6. package/dist/archil-settings.js +8 -1
  7. package/dist/bash-read-only.d.ts +3 -0
  8. package/dist/bash-read-only.js +6 -3
  9. package/dist/chatgpt-plan.d.ts +26 -8
  10. package/dist/chatgpt-plan.js +89 -21
  11. package/dist/claude-login.d.ts +12 -5
  12. package/dist/claude-login.js +28 -3
  13. package/dist/cli.js +19 -8
  14. package/dist/composio-triggers.d.ts +9 -3
  15. package/dist/computers.d.ts +3 -0
  16. package/dist/computers.js +2 -1
  17. package/dist/console/assets/{backend-C9ffXUR5.js → backend-DEgVn5lC.js} +1 -1
  18. package/dist/console/assets/index-CG5tELph.js +639 -0
  19. package/dist/console/assets/share-CIeFK2Oe.js +6 -0
  20. package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
  21. package/dist/console/index.html +3 -3
  22. package/dist/console/share.html +3 -3
  23. package/dist/cut-pool.d.ts +14 -0
  24. package/dist/cut-pool.js +98 -0
  25. package/dist/cut-worker.d.ts +14 -0
  26. package/dist/cut-worker.js +16 -0
  27. package/dist/decisions.d.ts +4 -0
  28. package/dist/decisions.js +9 -1
  29. package/dist/env-switch.d.ts +3 -0
  30. package/dist/env-switch.js +3 -0
  31. package/dist/harness-table.d.ts +7 -0
  32. package/dist/harness-table.js +6 -3
  33. package/dist/import.d.ts +8 -1
  34. package/dist/import.js +36 -5
  35. package/dist/key-check.js +22 -8
  36. package/dist/learned-nodes.d.ts +2 -1
  37. package/dist/learned-nodes.js +2 -1
  38. package/dist/mcp-gateway.d.ts +24 -0
  39. package/dist/mcp-gateway.js +97 -8
  40. package/dist/mcp-servers-store.d.ts +7 -10
  41. package/dist/mcp-servers-store.js +15 -9
  42. package/dist/native/cli.js +5 -1
  43. package/dist/ollama-provider.d.ts +10 -3
  44. package/dist/ollama-provider.js +17 -7
  45. package/dist/openapi.js +29 -12
  46. package/dist/otel/tracer.d.ts +6 -3
  47. package/dist/otel/tracer.js +24 -6
  48. package/dist/page.d.ts +7 -0
  49. package/dist/page.js +17 -4
  50. package/dist/place.d.ts +25 -9
  51. package/dist/place.js +37 -11
  52. package/dist/print.d.ts +3 -2
  53. package/dist/print.js +8 -6
  54. package/dist/run-launch.js +16 -3
  55. package/dist/run-model-key.d.ts +2 -1
  56. package/dist/run-model-key.js +2 -1
  57. package/dist/run-reads-over-store.d.ts +7 -0
  58. package/dist/run-reads-over-store.js +32 -4
  59. package/dist/runnable.d.ts +6 -3
  60. package/dist/runnable.js +16 -6
  61. package/dist/runner/adapter-loop.js +64 -25
  62. package/dist/runner/adapter-run-spec.d.ts +6 -1
  63. package/dist/runner/adapter-run-spec.js +14 -11
  64. package/dist/runner/adapters/index.d.ts +4 -0
  65. package/dist/runner/adapters/index.js +2 -1
  66. package/dist/runner/claim-secrets.d.ts +3 -1
  67. package/dist/runner/claim-secrets.js +18 -7
  68. package/dist/runner/cli-run-spec.js +12 -8
  69. package/dist/runner/dispatch.js +2 -0
  70. package/dist/runner/harness-loops.d.ts +5 -0
  71. package/dist/runner/harness-loops.js +4 -1
  72. package/dist/runner/live-ticker.js +3 -1
  73. package/dist/runner/loop-contract.d.ts +4 -1
  74. package/dist/runner/mcp-run.d.ts +5 -0
  75. package/dist/runner/mcp-run.js +18 -0
  76. package/dist/runner/meta-tools.js +4 -4
  77. package/dist/runner/metrics.d.ts +4 -2
  78. package/dist/runner/metrics.js +5 -3
  79. package/dist/runner/native-loop.js +2 -2
  80. package/dist/runner/run-child-host.d.ts +10 -6
  81. package/dist/runner/run-child-host.js +44 -29
  82. package/dist/runner/run-child.js +1 -0
  83. package/dist/runner/runner.js +2 -0
  84. package/dist/runner/workflow-calls.d.ts +4 -3
  85. package/dist/runner/workflow-calls.js +41 -12
  86. package/dist/runner/workflow-spec.js +1 -1
  87. package/dist/secret-rules.d.ts +0 -1
  88. package/dist/secret-rules.js +25 -5
  89. package/dist/server.d.ts +10 -1
  90. package/dist/server.js +114 -38
  91. package/dist/share-host.d.ts +111 -0
  92. package/dist/share-host.js +666 -0
  93. package/dist/store-reads/analytics.d.ts +15 -0
  94. package/dist/store-reads/analytics.js +17 -0
  95. package/dist/suggestions.js +32 -3
  96. package/dist/templates.d.ts +3 -1
  97. package/dist/templates.js +7 -3
  98. package/dist/tool-gate.d.ts +25 -9
  99. package/dist/tool-gate.js +58 -19
  100. package/dist/tool-plane.d.ts +1 -0
  101. package/dist/tool-plane.js +6 -2
  102. package/dist/trigger-composio.js +1 -1
  103. package/dist/webhooks.d.ts +3 -0
  104. package/dist/webhooks.js +5 -0
  105. package/dist/workspace/archil-claim.d.ts +7 -3
  106. package/dist/workspace/archil-claim.js +13 -5
  107. package/dist/workspace/archil-mount-credential.d.ts +6 -0
  108. package/dist/workspace/archil-mount-credential.js +11 -0
  109. package/dist/workspace/computer-deps.d.ts +5 -3
  110. package/dist/workspace/computer-deps.js +11 -9
  111. package/dist/workspace/computer-for-claim.d.ts +6 -2
  112. package/dist/workspace/computer-for-claim.js +43 -12
  113. package/dist/workspace/computer-janitor.d.ts +7 -4
  114. package/dist/workspace/computer-janitor.js +7 -4
  115. package/dist/workspace/computer-kept.d.ts +7 -1
  116. package/dist/workspace/computer-kept.js +7 -1
  117. package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
  118. package/dist/workspace/mount-revoke-left.d.ts +16 -4
  119. package/dist/workspace/mount-revoke-left.js +42 -22
  120. package/dist/workspace/resolve-computer.d.ts +11 -5
  121. package/dist/workspace/resolve-computer.js +22 -13
  122. package/dist/workspace/run-end-computers.js +1 -1
  123. package/dist/workspace/run-tools.d.ts +10 -3
  124. package/dist/workspace/run-tools.js +5 -4
  125. package/dist/wrapped.d.ts +29 -2
  126. package/dist/wrapped.js +20 -3
  127. package/launcher/agentrun-serve +1 -1
  128. package/package.json +12 -12
  129. package/dist/console/assets/index-BnZV3lvW.js +0 -639
  130. package/dist/console/assets/share-B1o5mJ56.js +0 -6
  131. /package/dist/console/assets/{styles-D_znYrHR.js → styles-BGZxYkky.js} +0 -0
@@ -829,10 +829,11 @@ export class McpServersOverStore {
829
829
  const open = openMcpRow(this.sealKey, row);
830
830
  return "credential" in open && open.credential.type === "oauth" ? open.credential.set : undefined;
831
831
  }
832
- /** A saved Composio preset server's key (its sealed x-api-key), the Composio user its address names (`user_id`, the
833
- * preset's default when none), its toolkit and the auth config its save recorded (composio-made.ts; none for a server
834
- * saved before that was recorded): what its Composio triggers are made with (composio-triggers.ts). Refused
835
- * when `name` is no such server: on the trigger's `source.server` at its create (`field`), as a 404 on the server's own
832
+ /** A saved Composio preset server's key (its sealed x-api-key), its toolkit and the auth config its save recorded
833
+ * (composio-made.ts; none for a server saved before that was recorded), and for a trigger's own steps (`field`) the
834
+ * Composio user its address names (`user_id`, the preset's default when none): what its Composio triggers are made with
835
+ * (composio-triggers.ts). The server's own routes (`route`) are answered no user: none of them sends one. Refused when
836
+ * `name` is no such server: on the trigger's `source.server` at its create (`field`), as a 404 on the server's own
836
837
  * routes (`route`). The key goes only to Composio. */
837
838
  async composioOf(name, refusal) {
838
839
  const refuse = (message) => (refusal === "route" ? new ApiError("not_found", message) : invalid([{ field: "source.server", reason: "not_an_option", message }]));
@@ -853,15 +854,20 @@ export class McpServersOverStore {
853
854
  if (!key)
854
855
  throw refuse(`${name}'s saved credential holds no Composio key: save it again with its key.`);
855
856
  const config = recordedMade(recorded, row.createdAt)?.auth_config?.id;
857
+ const made = { key, toolkit, ...(config ? { auth_config: config } : {}) };
858
+ // A route sends Composio no user: its events, its triggers and the project's subscription are read by the key, and a
859
+ // delete or a save takes the project's turn by it, so it is answered none, and a server with a blank user keeps its
860
+ // routes and that turn.
861
+ if (refusal === "route")
862
+ return made;
856
863
  // Only an address with no user_id at all is the default user's: an empty one is a blank user, refused below.
857
864
  const user = new URL(row.url).searchParams.get("user_id") ?? COMPOSIO_USER;
858
865
  // A user that is no Composio user id (a blank one Composio may read as every user) is refused for a trigger's own steps
859
- // (`field`) before Composio is asked anything: a create sends the user (its account read, its connect link, its
860
- // instance's upsert). A route sends none: its events, its triggers and the project's subscription are read by the key,
861
- // and a delete or a save takes the project's turn by it, so a server with a blank user keeps its routes and that turn.
862
- if (refusal === "field" && !COMPOSIO_USER_ID.test(user))
866
+ // before Composio is asked anything: a create sends the user (its account read, its connect link, its instance's
867
+ // upsert).
868
+ if (!COMPOSIO_USER_ID.test(user))
863
869
  throw refuse(`${name}'s saved Composio user ${JSON.stringify(user)} is no Composio user id: save the server again with its user.`);
864
- return { key, user, toolkit, ...(config ? { auth_config: config } : {}) };
870
+ return { ...made, user };
865
871
  }
866
872
  /** What the saved server `row` is, for a template's apply to match (mcp-sources.ts sourceOf): github on the GitHub App's
867
873
  * tokens, else its record, else url with none. */
@@ -1,4 +1,5 @@
1
1
  import { parseArgs } from 'node:util';
2
+ import { keyBase } from '@parcha/agentrun-computer';
2
3
  import { readFile } from 'node:fs/promises';
3
4
  import { join } from 'node:path';
4
5
  import { defaultData } from '../server-fs.js';
@@ -33,7 +34,10 @@ export async function nativeMain(argv, usage) {
33
34
  recorded = record.base_url;
34
35
  }
35
36
  catch { /* explicit/default URL below */ }
36
- const url = new URL(values.url ?? process.env.AGENTRUN_BASE_URL ?? process.env.AGENTRUN_URL ?? recorded ?? 'http://127.0.0.1:7340');
37
+ const named = [['--url', values.url], ['AGENTRUN_BASE_URL', process.env.AGENTRUN_BASE_URL], ['AGENTRUN_URL', process.env.AGENTRUN_URL], ["the server's recorded base_url", recorded]];
38
+ const [setting, given] = named.find((entry) => entry[1] !== undefined) ?? ['the default URL', 'http://127.0.0.1:7340'];
39
+ // The token goes to it, and fetch's errors print the whole URL: the rule of a URL a key goes to (keyBase), over loopback's http or https.
40
+ const url = new URL(keyBase(given, setting, ['http:', 'https:']));
37
41
  if (!['localhost', '127.0.0.1', '[::1]'].includes(url.hostname))
38
42
  throw new Error('Run AgentRun on this source machine and connect to its loopback URL; hosted native pairing is not available yet.');
39
43
  const token = secret('AGENTRUN_API_KEY') || secret('AGENTRUN_TOKEN') || (await readFile(join(data, '.token'), 'utf8')).trim();
@@ -110,18 +110,25 @@ export type OllamaPullLine = {
110
110
  /** How long a pull may go with no byte from Ollama before it stops (ollamaPull): a registry that stalls, or an Ollama
111
111
  * that wedges, frees the one pull here instead of holding it at `pulling` until the server restarts. */
112
112
  export declare const PULL_STALL_MS = 120000;
113
- /** The longest progress line a pull takes: Ollama's are a few hundred bytes, so a stream that sends no newline ends. */
113
+ /** How long a pull may go with no byte from Ollama once it says `verifying sha256 digest`: it then hashes every blob of the
114
+ * model with no further line, and on a slow disk a model of gigabytes takes minutes. An Ollama that wedges there still
115
+ * frees the pull. */
116
+ export declare const PULL_VERIFY_STALL_MS: number;
117
+ /** The longest progress line a pull takes, in characters: Ollama's are a few hundred, so a stream that sends no newline
118
+ * ends. */
114
119
  export declare const PULL_LINE_MAX: number;
115
120
  /**
116
121
  * Pulls `tag` through the Ollama `env` names (POST /api/pull, streamed as NDJSON), each line of progress to `onLine` as it
117
122
  * comes. Resolves once Ollama says `success`; throws, in Ollama's words, on an `error` line, a refusal, a stream that ends
118
123
  * before `success`, or `signal`; in its own, on `stallMs` with no byte from Ollama (the answer's head or a chunk of the
119
- * stream) or a line past PULL_LINE_MAX. No deadline on the whole: a model is gigabytes, and a pull that moves is let run.
124
+ * stream), `verifyStallMs` once Ollama says it is verifying the digest, or a line past PULL_LINE_MAX. No deadline on the
125
+ * whole: a model is gigabytes, and a pull that moves is let run.
120
126
  */
121
- export declare function ollamaPull(env: NodeJS.ProcessEnv, tag: string, onLine: (line: OllamaPullLine) => void, { fetch: send, signal, stallMs }?: {
127
+ export declare function ollamaPull(env: NodeJS.ProcessEnv, tag: string, onLine: (line: OllamaPullLine) => void, { fetch: send, signal, stallMs, verifyStallMs }?: {
122
128
  fetch?: typeof fetch;
123
129
  signal?: AbortSignal;
124
130
  stallMs?: number;
131
+ verifyStallMs?: number;
125
132
  }): Promise<void>;
126
133
  /** `env`'s Ollama listing as last kept (ollamaKept), in one string: each model's tag, capabilities and trained context.
127
134
  * A server compares it to see a model pulled, removed or an Ollama started since it made its offers (server.ts). */
@@ -299,23 +299,31 @@ export async function ollamaVersion(env, { fetch: send = globalThis.fetch, timeo
299
299
  /** How long a pull may go with no byte from Ollama before it stops (ollamaPull): a registry that stalls, or an Ollama
300
300
  * that wedges, frees the one pull here instead of holding it at `pulling` until the server restarts. */
301
301
  export const PULL_STALL_MS = 120_000;
302
- /** The longest progress line a pull takes: Ollama's are a few hundred bytes, so a stream that sends no newline ends. */
302
+ /** How long a pull may go with no byte from Ollama once it says `verifying sha256 digest`: it then hashes every blob of the
303
+ * model with no further line, and on a slow disk a model of gigabytes takes minutes. An Ollama that wedges there still
304
+ * frees the pull. */
305
+ export const PULL_VERIFY_STALL_MS = 15 * 60_000;
306
+ /** The longest progress line a pull takes, in characters: Ollama's are a few hundred, so a stream that sends no newline
307
+ * ends. */
303
308
  export const PULL_LINE_MAX = 64 * 1024;
304
309
  /**
305
310
  * Pulls `tag` through the Ollama `env` names (POST /api/pull, streamed as NDJSON), each line of progress to `onLine` as it
306
311
  * comes. Resolves once Ollama says `success`; throws, in Ollama's words, on an `error` line, a refusal, a stream that ends
307
312
  * before `success`, or `signal`; in its own, on `stallMs` with no byte from Ollama (the answer's head or a chunk of the
308
- * stream) or a line past PULL_LINE_MAX. No deadline on the whole: a model is gigabytes, and a pull that moves is let run.
313
+ * stream), `verifyStallMs` once Ollama says it is verifying the digest, or a line past PULL_LINE_MAX. No deadline on the
314
+ * whole: a model is gigabytes, and a pull that moves is let run.
309
315
  */
310
- export async function ollamaPull(env, tag, onLine, { fetch: send = globalThis.fetch, signal, stallMs = PULL_STALL_MS } = {}) {
316
+ export async function ollamaPull(env, tag, onLine, { fetch: send = globalThis.fetch, signal, stallMs = PULL_STALL_MS, verifyStallMs = PULL_VERIFY_STALL_MS } = {}) {
311
317
  const base = baseOf(env);
312
318
  if (base === undefined)
313
319
  throw new Error("no Ollama is asked here");
314
320
  const stall = new AbortController();
315
321
  let timer;
322
+ // The silence let pass now: the stall deadline, until Ollama says it is verifying the digest.
323
+ let quietMs = stallMs;
316
324
  const moved = () => {
317
325
  clearTimeout(timer);
318
- timer = setTimeout(() => stall.abort(), stallMs);
326
+ timer = setTimeout(() => stall.abort(), quietMs);
319
327
  };
320
328
  const stopped = signal ? AbortSignal.any([signal, stall.signal]) : stall.signal;
321
329
  moved();
@@ -338,10 +346,10 @@ export async function ollamaPull(env, tag, onLine, { fetch: send = globalThis.fe
338
346
  return;
339
347
  if (line.status === "success")
340
348
  succeeded = true;
349
+ quietMs = line.status.startsWith("verifying") ? Math.max(stallMs, verifyStallMs) : stallMs;
341
350
  onLine({ status: line.status, ...(typeof line.digest === "string" ? { digest: line.digest } : {}), ...(line.total !== undefined ? { total: count(line.total) } : {}), ...(line.completed !== undefined ? { completed: count(line.completed) } : {}) });
342
351
  };
343
352
  for await (const chunk of response.body) {
344
- moved();
345
353
  rest += decoder.decode(chunk, { stream: true });
346
354
  let cut;
347
355
  while ((cut = rest.indexOf("\n")) >= 0) {
@@ -350,8 +358,10 @@ export async function ollamaPull(env, tag, onLine, { fetch: send = globalThis.fe
350
358
  if (text)
351
359
  take(text);
352
360
  }
361
+ // Armed after the chunk's lines are read, so a `verifying` line sets the silence that follows it.
362
+ moved();
353
363
  if (rest.length > PULL_LINE_MAX)
354
- throw new Error(`Ollama sent a progress line longer than ${PULL_LINE_MAX} bytes, so the pull stopped. Press Pull again.`);
364
+ throw new Error(`Ollama sent a progress line longer than ${PULL_LINE_MAX} characters, so the pull stopped. Press Pull again.`);
355
365
  }
356
366
  if (rest.trim())
357
367
  take(rest.trim());
@@ -360,7 +370,7 @@ export async function ollamaPull(env, tag, onLine, { fetch: send = globalThis.fe
360
370
  }
361
371
  catch (error) {
362
372
  if (stall.signal.aborted && !signal?.aborted)
363
- throw new Error(`Ollama sent nothing for ${Math.round(stallMs / 1000)} s, so the pull stopped. Press Pull again.`);
373
+ throw new Error(`Ollama sent nothing for ${Math.round(quietMs / 1000)} s, so the pull stopped. Press Pull again.`);
364
374
  throw error;
365
375
  }
366
376
  finally {
package/dist/openapi.js CHANGED
@@ -173,6 +173,8 @@ const closed = (properties, description) => ({ type: "object", additionalPropert
173
173
  const USD = { type: ["number", "null"], minimum: 0, description: "The sum of the known costs, rounded to 1e-6; null when no run's cost is known, never 0 for unknown." };
174
174
  /** wrapped/1: GET /wrapped's answer (wrapped.ts). */
175
175
  const WRAPPED_TOKENS = closed({ input: COUNT, output: COUNT, cache_read: COUNT, cache_write: COUNT });
176
+ /** One figure per cache cause (the import package's CACHE_CAUSES), each always there. */
177
+ const CACHE_BY_CAUSE = (value) => closed(Object.fromEntries(["model", "idle", "compaction", "edited", "sidechain", "unknown"].map((cause) => [cause, value])));
176
178
  const WRAPPED = closed({
177
179
  year: { type: "integer", minimum: 1000, maximum: 9999 },
178
180
  sessions: { ...COUNT, description: "Sessions whose first request falls in the year." },
@@ -190,6 +192,19 @@ const WRAPPED = closed({
190
192
  sources: { type: "array", items: closed({ source: { type: "string" }, sessions: COUNT, requests: COUNT }), description: "By the tool the sessions were read from." },
191
193
  imported: { type: "array", items: closed({ source: { type: "string" }, runs: COUNT }), description: "The runs imported here in the year, by source (never `live`)." },
192
194
  unread_files: { ...COUNT, description: "Session files that could not be read (gone since listed, or not openable by this user), so the numbers are short by them. A count only: no path." },
195
+ cache: {
196
+ oneOf: [
197
+ closed({
198
+ runs: { ...COUNT, description: "The year's imported Claude Code, Codex and pi runs whose cache the import analyzed. A session left out of the import, or imported before it analyzed caches, is not among them." },
199
+ hit_rate: { type: ["number", "null"], minimum: 0, maximum: 1, description: "Cache read over the whole prompt (input, cache read and cache write) of those runs' requests and their subagents'; null when they sent none." },
200
+ breaks: { ...CACHE_BY_CAUSE(COUNT), description: "Cache breaks by cause: a turn whose cache read dropped more than 80% against the turn before it." },
201
+ extra_cost_usd: { ...CACHE_BY_CAUSE({ type: "number", minimum: 0 }), description: "By cause, what the breaks' re-sent tokens cost above a cache read, at list prices (USD); unpriced breaks are not in it." },
202
+ unpriced_breaks: { ...COUNT, description: "Breaks on a model with no list price: in `breaks`, not in `extra_cost_usd`." },
203
+ }),
204
+ { type: "null" },
205
+ ],
206
+ description: "The cache of the runs imported here in the year, from what the import kept of each (numbers only); null when none was analyzed.",
207
+ },
193
208
  }, "A year of the work under this machine's home, bucketed by each request's time in the server's local zone.");
194
209
  /** Runs counted together (AgentStoreReader.analytics's AnalyticsGroup). */
195
210
  const GROUP = {
@@ -369,7 +384,7 @@ const RUN_USAGE_LINE = {
369
384
  not_metered_calls: { type: "integer", minimum: 1, description: "On `tools`: calls with no price set (an MCP tool its owner set none for), as GET /usage counts them. They ran outside the run's cost and its cap, so they are in neither `quantity` nor `usd`: a line of such calls alone has `quantity` 0 and `usd` 0." },
370
385
  resource: { enum: ["vcpu", "memory", "gpu", "disk"], description: "On `compute_time`: the resource the line counts." },
371
386
  gpu_type: { type: ["string", "null"], description: "On `compute_time` for `gpu`: the provider's own name for the GPU type. Null on the other resources." },
372
- unheld_quantity: { type: ["number", "null"], minimum: 0, description: "On `compute_time`: the part of `quantity` no claim of the run held, so no cap held and nothing booked: a computer kept past its claim for a follow-up, one deleted after its run ended, one whose delete failed, one still open. Its cost is in neither `usd` nor `total`. 0 for a provider that bills nothing (Docker): its time costs nothing, held or not. Null when `quantity` is." },
387
+ unheld_quantity: { type: ["number", "null"], minimum: 0, description: "On `compute_time`: the part of `quantity` no claim of the run held, so no cap held and nothing booked: a computer kept past its claim for a follow-up, one deleted after its run ended, one whose delete failed, one still open. Its cost is in neither `usd` nor `total`. Null when `quantity` is, on a provider that bills; 0 on one that bills nothing (Docker), its `quantity` known or not: its time costs nothing, held or not." },
373
388
  open_computers: { type: "integer", minimum: 0, description: "On `compute_time`: how many of the line's computers no delete has ended yet (still running, or their delete failed), counted up to `measured_to`." },
374
389
  measured_to: { type: "string", format: "date-time", description: "On `compute_time` with an open computer: the moment its time is counted to, this read's." },
375
390
  },
@@ -418,7 +433,7 @@ const COMPUTER_INTERVAL = {
418
433
  started_at: { type: "string", format: "date-time", description: "When the provider's create answered with the computer, on this server's clock." },
419
434
  ended_at: { type: ["string", "null"], format: "date-time", description: "When the provider's delete of the computer answered ok, on this server's clock. Null while none did: the computer may still be running (a run that ended with one open left it behind), or its delete failed or its answer is unknown. Never a guessed end." },
420
435
  kept: { type: "boolean", description: "The run's park kept the computer past its claim, for the person's answer (it is deleted once its keep's time passes, or at the run's end)." },
421
- booked_seconds: { type: "number", minimum: 0, description: "How much of the computer's time a claim of the run held and booked on the run's ledger. The rest of its life is time no claim held (`unheld_quantity` on its `compute_time` lines). 0 for one whose provider has no price set, or that bills nothing.", "x-agentrun-serve": "runusage/4" },
436
+ booked_seconds: { type: "number", minimum: 0, description: "How much of the computer's time a claim of the run held and booked on the run's ledger. On a provider that bills, the rest of its life is time no claim held (`unheld_quantity` on its `compute_time` lines); on one that bills nothing (Docker) both are 0. 0 for one whose provider has no price set.", "x-agentrun-serve": "runusage/4" },
422
437
  ...ATTEMPT_FIELDS,
423
438
  },
424
439
  };
@@ -897,11 +912,11 @@ const MCP_PIN = {
897
912
  * resolves to on the agent's harness and model; a tool of bash's family its computer leaves out, unavailable. */
898
913
  const AGENT_TOOLS = {
899
914
  type: "array",
900
- description: "Each tool the agent's current revision grants, in capabilities.tools' order, with its permission (permission, where it came from as permission_from, default_permission, permissions). A tool with a provider choice (web_search, web_fetch, browser) carries the provider in force (provider), where it came from (provider_from: agent, its own tool_settings; server, the server's settings; default, the built-in default), the one that applies when the agent sets none (default_provider, the server's), and what it resolves to on the agent's harness and model (resolved). A tool of bash's family (bash and the background tools) carries resolved only where the agent's computer gives a run of it no such tool, `unavailable: ` and why: with no computer that mounts the run's folder the background tools are not there, and bash neither unless the server keeps its folders on Archil, whose exec runs it. Only GET /agents/{agent_id} answers it.",
915
+ description: "Each tool the agent's current revision grants, in capabilities.tools' order, with its permission (permission, where it came from as permission_from, default_permission, permissions). A tool with a provider choice (web_search, web_fetch, browser) carries the provider picked (provider), where it came from (provider_from: agent, its own tool_settings; server, the server's settings; default, the built-in default), the one that applies when the agent sets none (default_provider, the server's), and what it resolves to on the agent's harness and model (resolved), which is what a run uses. Where the server's setting for web_fetch (`kernel`) or web_search (`native`, `off`) is a ceiling over the agent's own pick (a keyless service or Parallel, named or resolved to, or a native search under `off`), `ceiling` names that setting and `resolved` is the server's, not the pick's. A tool of bash's family (bash and the background tools) carries resolved only where the agent's computer gives a run of it no such tool, `unavailable: ` and why: with no computer that mounts the run's folder the background tools are not there, and bash neither unless the server keeps its folders on Archil, whose exec runs it. Only GET /agents/{agent_id} answers it.",
901
916
  items: {
902
917
  type: "object", additionalProperties: false, required: ["name", "permission", "permission_from", "default_permission", "permissions"],
903
918
  properties: {
904
- name: { type: "string" }, blurb: { type: "string", description: "One short line for people (the editor's Tools grid); the model never sees it. Absent for an MCP server's tool.", "x-agentrun-serve": "tool-blurb/1" }, provider: { type: "string" }, provider_from: { enum: ["agent", "server", "default"] }, default_provider: { type: "string" }, resolved: RESOLUTION,
919
+ name: { type: "string" }, blurb: { type: "string", description: "One short line for people (the editor's Tools grid); the model never sees it. Absent for an MCP server's tool.", "x-agentrun-serve": "tool-blurb/1" }, provider: { type: "string" }, provider_from: { enum: ["agent", "server", "default"] }, default_provider: { type: "string" }, resolved: RESOLUTION, ceiling: { type: "string", description: "The server's setting that is a ceiling over the agent's own pick here (`kernel` for web_fetch; `native` or `off` for web_search), present only where it holds the pick down: a run gets `resolved`, the server's, never the pick.", "x-agentrun-serve": "web-ceiling/1" },
905
920
  permission: { ...PERMISSION, description: "The permission in force: a deny set on this server, which is absolute (no setting of the agent's reaches past it); else the agent's own (tool_settings), else the server's, else the owner's default.", "x-agentrun-serve": "approvals/1" },
906
921
  permission_from: { enum: ["agent", "server", "default", "unattended"], description: "Where the permission came from: agent, its own tool_settings (the tool's key, or its MCP server's wildcard); server, the server's settings (always, for a deny set on the server, which is absolute); default, the owner's default; unattended, an ask its definition's approvals `never` allowed (permission is then allow).", "x-agentrun-serve": "approvals/1" },
907
922
  default_permission: { enum: [...PERMISSIONS], description: "The one that applies when the agent sets none: the server's, else the owner's default.", "x-agentrun-serve": "approvals/1" },
@@ -1150,11 +1165,11 @@ const MODEL_GATEWAY_TEST = {
1150
1165
  /** computer/1: an agent's computer kind, as Settings → Computers and the run read name it (computer-setting.ts). */
1151
1166
  const COMPUTER_KIND = { enum: ["none", "sandbox", "desktop", "phone", "browser"] };
1152
1167
  /** A computer choice's shell (computers.ts ShellChoice): where its runs have their shell, in this server's folder mode. */
1153
- const CHOICE_SHELL = { enum: ["computer", "local", "none"], description: "Where a run of this choice has its shell, in this server's folder mode: `computer`, in the computer, which mounts the run's folder (bash and the background tools); `local`, no computer mounts it and the folder is on the owner's disk, so bash runs in a fresh container there (bash only); `none`, no computer mounts it and the folder is on this server's own disk, so the run has no shell (the file tools only)." };
1168
+ const CHOICE_SHELL = { enum: ["computer", "local", "none"], description: "Where a run of this choice has its shell, in this server's folder mode: `computer`, in the computer, which mounts the run's folder (bash and the background tools); `local`, no computer mounts it and the folder is on the owner's disk, so bash runs in a fresh container there (bash only); `none`, no computer mounts it and the run has no shell (the file tools only): the folder is on this server's own disk, or on Archil in a region with no serverless exec." };
1154
1169
  /** The host tools a choice gives, by name: the kernel registry's list for its shell. */
1155
1170
  const CHOICE_HOST_TOOLS = { type: "array", items: { type: "string" }, description: "Exactly the host tools a run of this choice gets, by name: the file tools always, bash with a shell (`computer` or `local`), the five background tools on a computer." };
1156
1171
  /** What a choice leaves out of the shell, in words. */
1157
- const CHOICE_SHELL_NOTE = { type: "string", description: "What this choice leaves out of the shell, in plain words; absent when its shell is `computer`. A save that names a tool it leaves out is refused in the same words." };
1172
+ const CHOICE_SHELL_NOTE = { type: "string", description: "What this choice leaves out of the shell, in plain words; absent when its shell is `computer`. A save that names a tool it leaves out is refused, in words that give the same reason and how to get the tool." };
1158
1173
  /** A sandbox's GPUs on an agent's computer setting (computer-setting.ts GpuSetting). */
1159
1174
  const COMPUTER_GPU = {
1160
1175
  type: "object", additionalProperties: false, required: ["type", "count"],
@@ -2571,7 +2586,7 @@ const EXTENSIONS = {
2571
2586
  "/runs/{run_id}/export": {
2572
2587
  get: {
2573
2588
  operationId: "getRunExport", tags: ["runs"], summary: "An ended run as a share bundle, every string cut",
2574
- description: "The run as one `agentrun.share/1` document, the one a share page renders: its view's allowlisted fields, its Timeline rows, a workflow's graph, its UTF-8 text files within the caps, what is left out (`omitted`), and its sha256. Every string in it from the run is cut by the scrubber, with the values this server holds and the sign-ins the run was handed as its held values: a known key format, a held value and a dump (env output, a .env file, ~/.ssh) are cut for good; a value beside a label (`PGPASSWORD=`, `Authorization:`, `--password`) and a personal detail (a home path's user, an email, a private address) are cut and may be restored. Each cut is a record in `cuts`: where it is, its rule and kind, whether it may be restored, and its shape, never its value. The document is the same bytes on every export of the run, and is read back before it is answered: a value the cut left, or a scrub that failed, answers `500` with an empty body. `restore` re-exports with those cuts' values in place, each record moved to `restored`; an id of a cut that may not be restored, or of no cut, is `400`, and nothing is restored. `409 run_not_final` until the run has ended; `403 forbidden` while this server can't read the browser sign-in the run was handed; `413 export_too_large` over 8 MiB, never cut short.",
2589
+ description: "The run as one `agentrun.share/1` document, the one a share page renders: its view's allowlisted fields, its Timeline rows, a workflow's graph, its UTF-8 text files within the caps, what is left out (`omitted`), and its sha256. Every string in it from the run is cut by the scrubber, with the values this server holds and the sign-ins the run was handed as its held values: a known key format, a held value and a dump (env output, a .env file, ~/.ssh) are cut for good; a value beside a label (`PGPASSWORD=`, `Authorization:`, `--password`) and a personal detail (a home path's user, an email, a private address) are cut and may be restored. Each cut is a record in `cuts`: where it is, its rule and kind, whether it may be restored, and its shape, never its value. The document is the same bytes on every export of the run, and is read back before it is answered: a value the cut left, or a scrub that failed, answers `500` with an empty body. `restore` re-exports with those cuts' values in place, each record moved to `restored`; an id of a cut that may not be restored, or of no cut, is `400`, and nothing is restored. `409 run_not_final` until the run has ended; `403 forbidden` while this server can't read the browser sign-in the run was handed; `413 export_too_large` over 8 MiB, never cut short. Served in the API-only profile (`AGENTRUN_API_ONLY=1`) too, with the token: the share page that renders it is the console's, which that profile refuses.",
2575
2590
  parameters: [ref("parameters/RunId"), { name: "restore", in: "query", required: false, description: "Cut ids to restore, comma-separated (the parameter may repeat): each a label, personal or jev cut of this run's bundle.", schema: { type: "string" } }],
2576
2591
  responses: { "200": json(SHARE_BUNDLE, "The run's share bundle."), "500": { description: "The export failed closed: a scrub failed, or the bundle read back held a value. No body." }, ...errors(400, 401, 403, 404, 409, 413, 429) },
2577
2592
  "x-agentrun-serve": "share/1",
@@ -3100,11 +3115,11 @@ const EXTENSIONS = {
3100
3115
  "/settings/claude-login/sign-out": {
3101
3116
  post: {
3102
3117
  operationId: "signOutClaudeLogin", tags: ["local"], summary: "Sign out of Claude Code's login on this machine: AgentRun's own login removed, the mode off",
3103
- description: "For a person to sign in fresh, or as another account: a turn-off leaves the login as the CLI keeps it, so the next turn-on reads it again. Ends a sign-in that waits, turns the mode off, runs the pinned CLI's own `claude auth logout` on AgentRun's own login folder (`<data>/claude-login`), which removes its credentials file and, on macOS, its Keychain item for that folder, then removes the folder (credentials, account, profiles, refresh locks), the login's signed-in note and the runner's token reader, whatever the CLI said. The next turn-on finds no login (`signed_out`) and the sign-in starts as before. Runs already going on the login are left as a turn-off leaves them: each keeps the token its CLI holds, and fails saying the login is signed out at its next read of it. `confirmed` false: signed out here and the mode off, and `message` says what may remain: the CLI didn't confirm its own sign-out, or its step failed, named (on macOS its Keychain item may remain); a removal failed, each named with its path (the others still happen); or the folder had become a link, which alone is removed, with no CLI run through it and nothing it leads to touched. 403 forbidden, with nothing touched, when the login is this machine's own (`place` `machine`: the person's `~/.claude` or CLAUDE_CONFIG_DIR): AgentRun never signs it out, and the words say to run `claude auth logout` in a terminal there. 404 not_found, naming the operation, when AGENTRUN_CLAUDE_CODE_LOGIN is `off`. A secret write: the owner's signed-in session alone (ownerSession).",
3118
+ description: "For a person to sign in fresh, or as another account: a turn-off leaves the login as the CLI keeps it, so the next turn-on reads it again. Ends a sign-in that waits, turns the mode off, runs the pinned CLI's own `claude auth logout` on AgentRun's own login folder (`<data>/claude-login`), which removes its credentials file and, on macOS, its Keychain item for that folder, then removes the folder (credentials, account, profiles, refresh locks), the login's signed-in note and the runner's token reader, whatever the CLI said. The next turn-on finds no login (`signed_out`) and the sign-in starts as before. Runs already going on the login are left as a turn-off leaves them: each keeps the token its CLI holds, and fails saying the login is signed out at its next read of it. `confirmed` false: signed out here and the mode off, and `message` says what may remain: the CLI didn't confirm its own sign-out, or its step failed, named (on macOS its Keychain item may remain); a removal failed, each named with its path (the others still happen); on macOS, an older Keychain item a sign-in left under the account `unknown`, which holds a refresh token and which the sign-out deletes too, could not be removed, which makes `confirmed` false even where the CLI confirmed its own sign-out, with how to delete that item alone: its exact service, `Claude Code-credentials-` and 8 hex of AgentRun's folder, to search in Keychain Access, or the one `security delete-generic-password -a unknown -s \"<that service>\"` command; or the folder had become a link, which alone is removed, with no CLI run through it and nothing it leads to touched. 403 forbidden, with nothing touched, when the login is this machine's own (`place` `machine`: the person's `~/.claude` or CLAUDE_CONFIG_DIR): AgentRun never signs it out, and the words say to run `claude auth logout` in a terminal there. 404 not_found, naming the operation, when AGENTRUN_CLAUDE_CODE_LOGIN is `off`. A secret write: the owner's signed-in session alone (ownerSession).",
3104
3119
  "x-agentrun-secret": true,
3105
3120
  security: [{ ownerSession: [] }],
3106
3121
  responses: {
3107
- "200": json({ type: "object", additionalProperties: false, required: ["confirmed", "login"], properties: { confirmed: { type: "boolean", description: "Whether all of the login is gone: the CLI confirmed its own sign-out and every removal landed. The CLI's sign-out runs where the folder is already gone too, so a retry after an unconfirmed sign-out is true only where the CLI confirms." }, message: { type: "string", description: "With `confirmed` false: what may remain, in words (the CLI's step unconfirmed or failed, a removal that failed, a link left in place of the folder)." }, login: CLAUDE_LOGIN } }, "Signed out here."),
3122
+ "200": json({ type: "object", additionalProperties: false, required: ["confirmed", "login"], properties: { confirmed: { type: "boolean", description: "Whether all of the login is gone: the CLI confirmed its own sign-out, every removal landed, and on macOS no older Keychain item a sign-in left under the account `unknown` may remain. So it is false where the CLI confirmed its sign-out but that item could not be removed. The CLI's sign-out runs where the folder is already gone too, so a retry after an unconfirmed sign-out is true only where the CLI confirms." }, message: { type: "string", description: "With `confirmed` false: what may remain, in words (the CLI's step unconfirmed or failed, a removal that failed, on macOS an older Keychain item under the account `unknown` that could not be removed, with its exact service and how to delete that item alone, a link left in place of the folder)." }, login: CLAUDE_LOGIN } }, "Signed out here."),
3108
3123
  ...errors(401, 403, 404, 429, 500),
3109
3124
  },
3110
3125
  "x-agentrun-serve": "claudelogin/1",
@@ -3477,7 +3492,7 @@ const EXTENSIONS = {
3477
3492
  "/settings/tools": {
3478
3493
  get: {
3479
3494
  operationId: "getToolSettings", tags: ["capabilities"], summary: "The server's tool settings",
3480
- description: "Each capability that has a choice, and its provider, and each tool's permission that is set (an MCP server's wildcard mcp:<server>/* among them): web_search auto (Parallel where the server holds its key, which bills it, else Firecrawl's keyless search with Exa's behind it, on every harness), native (the harness's own search, claude-agent's or codex's, or on pi the model provider's hosted one: that alone), firecrawl-keyless (Firecrawl's, Exa's behind it), exa-keyless (that alone) or parallel; web_fetch auto (Parallel's extract where the server holds a Parallel key, which bills it, with the guarded direct fetch behind it, else Firecrawl's keyless fetch, which is sent each URL read, never a private or local one, with the guarded direct fetch behind it), firecrawl-keyless (that, whatever the key), kernel (the guarded direct fetch alone) or parallel; browser auto (Browserbase where the server holds its keys, else Kernel where it holds Kernel's), browserbase, kernel (each that alone) or chrome (a Chrome on the server's host, not set up on any server yet: unavailable). An agent's definition.tool_settings is over these, except a permission set to deny here: a server deny is absolute and refuses the tool on this server whatever the agent sets; and web_fetch kernel, or web_search native or off, a ceiling: an agent's firecrawl-keyless, exa-keyless, auto or parallel resolves as the setting does, and under off so does its native. Every other provider set here is a default an agent's pick replaces. A setting applies at a run's next claim; a claim keeps the plane it began with to its end. capabilities.tools say what each resolves to on each harness, and GET /agents/{agent_id} for that agent. An MCP tool's own key may carry its pin, the arguments its calls must carry.",
3495
+ description: "Each capability that has a choice, and its provider, and each tool's permission that is set (an MCP server's wildcard mcp:<server>/* among them): web_search auto (Parallel where the server holds its key, which bills it, else Firecrawl's keyless search with Exa's behind it, on every harness), native (the harness's own search, claude-agent's or codex's, or on pi the model provider's hosted one: that alone), firecrawl-keyless (Firecrawl's, Exa's behind it), exa-keyless (that alone) or parallel; web_fetch auto (Parallel's extract where the server holds a Parallel key, which bills it, with the guarded direct fetch behind it, else Firecrawl's keyless fetch, which is sent each URL read, never a private or local one, with the guarded direct fetch behind it), firecrawl-keyless (that, whatever the key), kernel (the guarded direct fetch alone) or parallel; browser auto (Browserbase where the server holds its keys, else Kernel where it holds Kernel's), browserbase, kernel (each that alone) or chrome (a Chrome on the server's host, not set up on any server yet: unavailable). An agent's definition.tool_settings is over these, except a permission set to deny here: a server deny is absolute and refuses the tool on this server whatever the agent sets; and web_fetch kernel, or web_search native or off, a ceiling: an agent's firecrawl-keyless, exa-keyless, auto or parallel resolves as the setting does, and under off so does its native. Every other provider set here is a default an agent's pick replaces. A setting applies at a run's next claim; a claim keeps the plane it began with to its end, and deny, read at each call, is what stops a claim already running. The ceiling covers web_search and web_fetch alone: browser, bash, MCP and catalog tools, Jev's ranking, a workflow's parallel decision provider and a native job's own CLI reach the web outside it. capabilities.tools say what each resolves to on each harness, and GET /agents/{agent_id} for that agent. An MCP tool's own key may carry its pin, the arguments its calls must carry.",
3481
3496
  responses: { "200": json(TOOL_SETTINGS_ANSWER, "Each capability's provider."), ...errors(401, 429, 500) },
3482
3497
  "x-agentrun-serve": "providers/1",
3483
3498
  },
@@ -4640,10 +4655,10 @@ const FIELD_EXTENSIONS = {
4640
4655
  { type: "object", additionalProperties: false, required: ["mode", "box"], properties: { mode: { const: "sandbox" }, box: { enum: [...BOX_IDS] } } },
4641
4656
  { type: "null" },
4642
4657
  ],
4643
- description: "The place a NEW agentic agent that names none and has a shell is saved with, written on its revision at its create, and where an agentic revision saved with no place and a shell tool runs, resolved at each run. In Mode 2, where the runner's shell is Archil's serverless exec, the runner (`{\"mode\": \"runner\"}`), docker or not (Docker's box can't mount Archil's workspaces), and such a create saves with no place. In Mode 1, where the runner has no shell: the Docker box (`{\"mode\": \"sandbox\", \"box\": \"docker\"}`) where this server has docker, with tools [\"bash\", \"bash_background\", \"bash_output\", \"bash_input\", \"bash_signal\", \"bash_list\"] when the definition names no tools; where it has no docker, null, meaning no default: a new agent names a box or the runner, `default_reason` gives the words, and a create that names no place and no tools, or a tool that runs only in a box, is refused `422 input_invalid` at field `definition.place`, reason `missing`, in those words, no other box picked for it. A client tells the cases apart by `default_place` being null, never by reading `default_reason`. One whose named tools need no shell is saved with no place and runs on the runner, as do a workflow and a revision that names a tool a box refuses. (It replaces `places.default`, which said `runner`.)",
4658
+ description: "The place a NEW agentic agent that names none and has a shell is saved with, written on its revision at its create, and where an agentic revision saved with no place and a shell tool runs, resolved at each run. In Mode 2, where the runner's shell is Archil's serverless exec, the runner (`{\"mode\": \"runner\"}`), docker or not (Docker's box can't mount Archil's workspaces), and such a create saves with no place. In Mode 2 on an Archil region with no serverless exec (gcp-us-central1), the runner has no shell, so null, docker or not: a create that names no place, no computer and a tool that runs only in a box is refused `422 input_invalid` at field `definition.computer`, reason `missing`, in `default_reason`'s words, naming a sandbox computer; one that names no tools is saved on the runner with none. In Mode 1, where the runner has no shell: the Docker box (`{\"mode\": \"sandbox\", \"box\": \"docker\"}`) where this server has docker, with tools [\"bash\", \"bash_background\", \"bash_output\", \"bash_input\", \"bash_signal\", \"bash_list\"] when the definition names no tools; where it has no docker, null, meaning no default: a new agent names a box or the runner, `default_reason` gives the words, and a create that names no place and no tools, or a tool that runs only in a box, is refused `422 input_invalid` at field `definition.place`, reason `missing`, in those words, no other box picked for it. A client tells the cases apart by `default_place` being null, never by reading `default_reason`. One whose named tools need no shell is saved with no place and runs on the runner, as do a workflow and a revision that names a tool a box refuses. (It replaces `places.default`, which said `runner`.)",
4644
4659
  "x-agentrun-serve": "place/5",
4645
4660
  },
4646
- default_reason: { type: "string", description: "There exactly when `default_place` is null (Mode 1 with no Docker box): the words a create that names no place and would get the box is refused in, `name a box: this server has no Docker box for a new agent. Set place to {mode: sandbox, box: <one of: …>}, or to {mode: runner} to run without a shell.`, listing the boxes this server has, or `<none is set up>`. Docker's own reason is on its entry in `boxes`.", "x-agentrun-serve": "place/5" },
4661
+ default_reason: { type: "string", description: "There exactly when `default_place` is null. In Mode 1 with no Docker box, the words a create that names no place and would get the box is refused in, `name a box: this server has no Docker box for a new agent. Set place to {mode: sandbox, box: <one of: …>}, or to {mode: runner} to run without a shell.`, listing the boxes this server has, or `<none is set up>`. In Mode 2 on an Archil region with no serverless exec, the words a create that names no place, no computer and a shell tool is refused in, `name a sandbox computer: this server's Archil region <region> has no serverless exec, …`. Docker's own reason is on its entry in `boxes`.", "x-agentrun-serve": "place/5" },
4647
4662
  allow: { type: "array", items: { type: "string" }, description: "The hosts a box whose `network` is `allowlist` may reach: AGENTRUN_BOX_ALLOW's, else the package registries and GitHub; empty when it is `none`.", "x-agentrun-serve": "place/2" },
4648
4663
  },
4649
4664
  "Capabilities/workflows": {
@@ -5086,6 +5101,8 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
5086
5101
  ];
5087
5102
  readFileOp.responses["413"] = ref("responses/PayloadTooLarge");
5088
5103
  readFileOp.responses["415"] = ref("responses/UnsupportedMediaType");
5104
+ // Its cut is made in a worker under a deadline (cut-pool.ts): past it, or when the worker fails, 503, never uncut.
5105
+ readFileOp.responses["503"] = ref("responses/Unavailable");
5089
5106
  readFile["x-agentrun-serve-changed"] = { ...readFile["x-agentrun-serve-changed"], parameters: "filecut/1" };
5090
5107
  // filecut/2: `?cut=run` on the listing names each file under the run's cut (RunFile.name), so a grader is told of every
5091
5108
  // file a run left, media included, without a path that holds a held value.
@@ -10,7 +10,10 @@ export declare const FLUSH_MS = 3000;
10
10
  * never ends them can't grow its runner's memory without bound. */
11
11
  export declare const OPEN_MAX = 512;
12
12
  /** The OTLP exporter's settings from `env`, as the spec reads them: the traces endpoint as given, else the endpoint's
13
- * /v1/traces; the headers (the traces' over the general ones); the timeout. */
13
+ * /v1/traces; the headers (the traces' over the general ones); the timeout. The headers go to the endpoint, so it takes
14
+ * the rule of a URL a key goes to (keyBase) over http or https, since OTLP allows both and a collector is often a plain
15
+ * http one beside the server: one with a user, a password, a query or a fragment throws in those words, which name the
16
+ * variable and the origin alone, and tracing is off for it (made). */
14
17
  export declare function exporterConfig(env: NodeJS.ProcessEnv): {
15
18
  url: string;
16
19
  headers: Record<string, string>;
@@ -74,8 +77,8 @@ export interface TracingTest {
74
77
  readonly log?: (line: string) => void;
75
78
  readonly now?: () => number;
76
79
  }
77
- /** This process's tracing, or undefined while `env` leaves it off: then no @opentelemetry module is ever loaded. Made
78
- * once per process; a test's (`test`) is its own. */
80
+ /** This process's tracing, or undefined while `env` leaves it off or its endpoint is refused (made): then no
81
+ * @opentelemetry module is ever loaded. Made once per process; a test's (`test`) is its own. */
79
82
  export declare function genAiTracing(env?: NodeJS.ProcessEnv, test?: TracingTest): Promise<GenAiTracing | undefined>;
80
83
  /** This process's closing flush (GenAiTracing.flush) of its tracing, when it was made; at once when it never was (off:
81
84
  * nothing of OpenTelemetry is loaded for it). Never throws. */
@@ -21,6 +21,7 @@
21
21
  // most FLUSH_MS.
22
22
  import { createHash, randomBytes } from "node:crypto";
23
23
  import { readFileSync } from "node:fs";
24
+ import { keyBase } from "@parcha/agentrun-computer";
24
25
  import { runnerSecrets, secretRedactor } from "../runner/redact.js";
25
26
  import { keyValues, otlpHeaderCut } from "../secrets.js";
26
27
  import { agentAttributes, chatAttributes, spanName, toolAttributes, tracedAgent, written } from "./genai.js";
@@ -33,10 +34,18 @@ export const FLUSH_MS = 3_000;
33
34
  * never ends them can't grow its runner's memory without bound. */
34
35
  export const OPEN_MAX = 512;
35
36
  /** The OTLP exporter's settings from `env`, as the spec reads them: the traces endpoint as given, else the endpoint's
36
- * /v1/traces; the headers (the traces' over the general ones); the timeout. */
37
+ * /v1/traces; the headers (the traces' over the general ones); the timeout. The headers go to the endpoint, so it takes
38
+ * the rule of a URL a key goes to (keyBase) over http or https, since OTLP allows both and a collector is often a plain
39
+ * http one beside the server: one with a user, a password, a query or a fragment throws in those words, which name the
40
+ * variable and the origin alone, and tracing is off for it (made). */
37
41
  export function exporterConfig(env) {
38
42
  const traces = env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT?.trim();
39
- const url = traces || `${(env.OTEL_EXPORTER_OTLP_ENDPOINT ?? "").trim().replace(/\/+$/, "")}/v1/traces`;
43
+ const endpoint = (env.OTEL_EXPORTER_OTLP_ENDPOINT ?? "").trim();
44
+ // A traces endpoint, once checked, is used as given, as the spec says: a collector may tell /ingest/ from /ingest. The
45
+ // general endpoint's /v1/traces is added to the rule's normalized return, never the raw string: a bare ? or # passes
46
+ // the rule, and would put the path in a query.
47
+ const checked = keyBase(traces || endpoint, traces ? "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" : "OTEL_EXPORTER_OTLP_ENDPOINT", ["http:", "https:"]);
48
+ const url = traces || `${checked}/v1/traces`;
40
49
  const timeout = Number(env.OTEL_EXPORTER_OTLP_TRACES_TIMEOUT ?? env.OTEL_EXPORTER_OTLP_TIMEOUT);
41
50
  return { url, headers: { ...keyValues(env.OTEL_EXPORTER_OTLP_HEADERS), ...keyValues(env.OTEL_EXPORTER_OTLP_TRACES_HEADERS) }, ...(Number.isFinite(timeout) && timeout > 0 ? { timeoutMillis: timeout } : {}) };
42
51
  }
@@ -204,8 +213,8 @@ export function tracePosts(tracing, runId, redact, agent) {
204
213
  };
205
214
  }
206
215
  let shared;
207
- /** This process's tracing, or undefined while `env` leaves it off: then no @opentelemetry module is ever loaded. Made
208
- * once per process; a test's (`test`) is its own. */
216
+ /** This process's tracing, or undefined while `env` leaves it off or its endpoint is refused (made): then no
217
+ * @opentelemetry module is ever loaded. Made once per process; a test's (`test`) is its own. */
209
218
  export function genAiTracing(env = process.env, test) {
210
219
  if (!otelOn(env))
211
220
  return Promise.resolve(undefined);
@@ -237,9 +246,18 @@ function saidOf(env, given) {
237
246
  return (line) => log(headers(cut(line)));
238
247
  }
239
248
  async function made(env, test) {
240
- const [api, sdk, resources] = await Promise.all([import("@opentelemetry/api"), import("@opentelemetry/sdk-trace"), import("@opentelemetry/resources")]);
241
249
  const log = saidOf(env, test?.log);
242
- const config = exporterConfig(env);
250
+ let config;
251
+ try {
252
+ config = exporterConfig(env);
253
+ }
254
+ catch (error) {
255
+ // The endpoint the rule of a URL a key goes to refuses: no exporter is built on it and nothing is sent, never a
256
+ // thrown start or run. Said once (genAiTracing makes this once per process), in keyBase's words.
257
+ log(`[otel] tracing is off: ${error.message}`);
258
+ return undefined;
259
+ }
260
+ const [api, sdk, resources] = await Promise.all([import("@opentelemetry/api"), import("@opentelemetry/sdk-trace"), import("@opentelemetry/resources")]);
243
261
  const where = shownEndpoint(config.url);
244
262
  const exporter = safeExporter(test?.exporter ?? new (await import("@opentelemetry/exporter-trace-otlp-http")).OTLPTraceExporter(config), log, where, test?.now ?? Date.now);
245
263
  // The next root span's trace id (the run's), taken by the one startSpan that asks for it: startSpan is synchronous.
package/dist/page.d.ts CHANGED
@@ -69,6 +69,13 @@ type PageServer = {
69
69
  takesBytes?: (method: string | undefined, path: string) => boolean;
70
70
  publicUrl?: string;
71
71
  };
72
+ /** A share host's pages' CSP (share-host.ts): the local preview's, so a public page, as the owner's preview of it, makes no
73
+ * outbound fetch (a graph's image URL among them). */
74
+ export declare const SHARE_HOST_CSP = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'";
75
+ /** A share host's page for a share (the console's share.html), its asset URLs under /r/_assets/, under SHARE_HOST_CSP. */
76
+ export declare const sendHostedSharePage: (req: IncomingMessage, res: ServerResponse, dir: string | undefined) => Promise<void>;
77
+ /** A share host's asset at /r/_assets/`rel`: the console's assets/`rel`, the same rules as /assets/. */
78
+ export declare const sendHostedAsset: (req: IncomingMessage, res: ServerResponse, raw: string, dir: string | undefined, rel: string) => void | Promise<void>;
72
79
  /** Whether `req` came from the owner's page under their password session (answerPage). A token, whoever holds it, never
73
80
  * did. */
74
81
  export declare const byOwnerSession: (req: IncomingMessage) => boolean;
package/dist/page.js CHANGED
@@ -130,8 +130,9 @@ export const sendMovedPage = (req, res, to) => send(req, res, 403, HTML, movedPa
130
130
  const refuse = (req, res, error) => send(req, res, error.status, "application/json", JSON.stringify(error.body(String(res.getHeader("x-request-id") ?? ""))), error.headers);
131
131
  const redirect = (res, location, headers = {}) => (res.writeHead(303, { ...SECURITY, location, "content-length": 0, ...headers }), void res.end());
132
132
  /** A file of the console: a known type inside `dir`, read through no link that leaves it. Vite's hashed assets are cached
133
- * for a year; index.html is no-store. */
134
- async function file(req, res, raw, dir, rel, status = 200, headers = {}) {
133
+ * for a year; index.html is no-store. `hosted`: answer headers of its own (a CSP), and for a share host the page's text
134
+ * rewritten. */
135
+ async function file(req, res, raw, dir, rel, status = 200, hosted) {
135
136
  const missing = () => refuse(req, res, new ApiError("not_found", `no file ${raw} in the console`));
136
137
  const type = CONSOLE_TYPES[extname(rel).toLowerCase()];
137
138
  if (!type || !rel.split("/").every((segment) => CONSOLE_SEGMENT.test(segment)))
@@ -143,8 +144,20 @@ async function file(req, res, raw, dir, rel, status = 200, headers = {}) {
143
144
  }
144
145
  if (!real.startsWith(root + sep) || !(await stat(real)).isFile())
145
146
  return missing();
146
- send(req, res, status, type, await readFile(real), { "cache-control": rel.startsWith("assets/") ? "public, max-age=31536000, immutable" : "no-store", ...headers });
147
+ const bytes = await readFile(real);
148
+ send(req, res, status, type, hosted?.rewrite ? hosted.rewrite(bytes.toString("utf8")) : bytes, { "cache-control": rel.startsWith("assets/") ? "public, max-age=31536000, immutable" : "no-store", ...hosted?.headers });
147
149
  }
150
+ /** A share host's pages' CSP (share-host.ts): the local preview's, so a public page, as the owner's preview of it, makes no
151
+ * outbound fetch (a graph's image URL among them). */
152
+ export const SHARE_HOST_CSP = SHARE_PAGE_CSP;
153
+ const HOSTED = { "content-security-policy": SHARE_HOST_CSP, "x-robots-tag": "noindex" };
154
+ /** The page's asset URLs as Vite writes them with base "./" (`./assets/x`), moved under the share host's /r/_assets/: the
155
+ * page answers at /r/<id> and /r/<id>/, where a relative URL would land elsewhere. */
156
+ const hostedAssets = (text) => text.replace(/(\s(?:src|href)=["'])\.\/assets\//g, "$1/r/_assets/");
157
+ /** A share host's page for a share (the console's share.html), its asset URLs under /r/_assets/, under SHARE_HOST_CSP. */
158
+ export const sendHostedSharePage = (req, res, dir) => file(req, res, "/r/<id>", dir ?? CONSOLE_DIR, "share.html", 200, { headers: HOSTED, rewrite: hostedAssets });
159
+ /** A share host's asset at /r/_assets/`rel`: the console's assets/`rel`, the same rules as /assets/. */
160
+ export const sendHostedAsset = (req, res, raw, dir, rel) => rel.endsWith(".html") ? refuse(req, res, new ApiError("not_found", `no file ${raw} in the console`)) : file(req, res, raw, dir ?? CONSOLE_DIR, `assets/${rel}`, 200, { headers: HOSTED });
148
161
  async function answer(req, res, raw, server, held) {
149
162
  if (req.method !== "GET" && req.method !== "HEAD")
150
163
  return refuse(req, res, new ApiError("method_not_allowed", `the console answers GET and HEAD; ${req.method} is not one`, {}, { allow: "GET, HEAD" }));
@@ -204,7 +217,7 @@ async function share(req, res, raw, dir, server, held) {
204
217
  server.authFailed?.("/share", "no_session");
205
218
  return send(req, res, 401, HTML, SIGN_IN_FIRST);
206
219
  }
207
- return file(req, res, raw, dir, "share.html", 200, { "content-security-policy": SHARE_PAGE_CSP });
220
+ return file(req, res, raw, dir, "share.html", 200, { headers: { "content-security-policy": SHARE_PAGE_CSP } });
208
221
  }
209
222
  /** The requests the owner's password session sends from the page (a write only from this server's own origin, with a
210
223
  * JSON body), never under an accounts-off console session. */
package/dist/place.d.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import { type BoxOffer } from "./place-offers.js";
2
2
  import { type InputIssue } from "./errors.js";
3
+ /** Where a revision that names no place has a shell, besides a box it names (server.ts runnerShellNow): `true`, on the
4
+ * runner, Archil's serverless exec (Mode 2); `false`, in Docker's box where this server has it (Mode 1); `{ noExec }`,
5
+ * nowhere: Mode 2 on Archil region `noExec`, which has no serverless exec (archil-settings.ts noExecRegionOf), where a
6
+ * run with no computer has no shell and Docker's box can't mount Archil. */
7
+ export type RunnerShell = boolean | {
8
+ readonly noExec: string;
9
+ };
10
+ /** The refusal of a new agent with a shell tool and no computer, at its save or deploy, on a Mode 2 server whose Archil
11
+ * region `region` has no serverless exec (RunnerShell `noExec`): it names a sandbox computer, never Docker's box. */
12
+ export declare const noExecIssue: (region: string) => InputIssue;
3
13
  export declare const PLACE_MODES: readonly ["runner", "sandbox"];
4
14
  export type PlaceMode = (typeof PLACE_MODES)[number];
5
15
  export type Place = {
@@ -29,9 +39,10 @@ export declare function newAgentPlace(registry: readonly BoxOffer[]): {
29
39
  * (newAgentPlace) for an agentic revision with a tool that runs only in a box (`flags`, tools.ts: bash and the
30
40
  * background tools); the runner for a workflow, which is never given a box, for one whose tools need no shell (none, or
31
41
  * only read and write: a container would only hold up its start), and for one that names a tool the box refuses (the
32
- * browser, runner-only for now). Where the runner has a shell (`runnerShell`: Mode 2's Archil exec), the runner for
33
- * every revision: Docker's box can't mount the folder Mode 2 keeps on Archil. */
34
- export declare function defaultPlaceOf(kind: "agentic" | "workflow", tools: readonly unknown[], registry: readonly BoxOffer[], flags: ToolFlags, runnerShell: boolean): Place;
42
+ * browser, runner-only for now). In Mode 2 (`runnerShell` not false), the runner for every revision: Docker's box can't
43
+ * mount the folder Mode 2 keeps on Archil. Where the runner has no shell there either (`noExec`), a shell tool's agent
44
+ * is refused at its save (noBoxRefusal) and its run (runnable.ts), never given Docker's box. */
45
+ export declare function defaultPlaceOf(kind: "agentic" | "workflow", tools: readonly unknown[], registry: readonly BoxOffer[], flags: ToolFlags, runnerShell: RunnerShell): Place;
35
46
  type ToolFlags = (tool: string) => {
36
47
  readonly sandboxOnly?: true;
37
48
  readonly runnerOnly?: true;
@@ -40,8 +51,11 @@ type ToolFlags = (tool: string) => {
40
51
  * save it, where it would be given the default box (it names no tools, `tools` undefined, so it would get a shell, or a
41
52
  * tool that runs only in a box) and this server does not have Docker's box, and where the runner has no shell
42
53
  * (`runnerShell` false: Mode 1). On Mode 2 the runner's exec is a shell, and such a definition saves for the runner as
43
- * it always did, its tools checked there (runnable.ts). Undefined for one that saves. */
44
- export declare function noBoxRefusal(tools: readonly unknown[] | undefined, registry: readonly BoxOffer[], flags: ToolFlags, runnerShell: boolean): InputIssue | undefined;
54
+ * it always did, its tools checked there (runnable.ts); on a Mode 2 region with no exec (`noExec`) there is no shell
55
+ * for a shell tool it names, Docker answering or not: it names a sandbox computer (noExecIssue). One that names no tools
56
+ * is saved on Mode 2's runner with none (server.ts defaultToolsAt), so it has no shell tool to refuse. Undefined for one
57
+ * that saves. */
58
+ export declare function noBoxRefusal(tools: readonly unknown[] | undefined, registry: readonly BoxOffer[], flags: ToolFlags, runnerShell: RunnerShell): InputIssue | undefined;
45
59
  /** The refusal of a revision that names no place where Docker's box is not here, at definition.place: its words, and
46
60
  * what to set as its fix, so no example of a place is picked for it. */
47
61
  export declare const noPlaceIssue: (registry: readonly BoxOffer[]) => InputIssue;
@@ -57,15 +71,17 @@ export declare function noBoxReason(registry: readonly BoxOffer[], listed: Reado
57
71
  * AGENTRUN_BOXES lists (`listed`), and, when none is ready, the boxes it does not list, with what to do.
58
72
  * `byDefault`, with AGENTRUN_BOXES not set at all: short, the local box alone, said to be on by default, or why it is
59
73
  * not, and where a new agent with no place goes then: it names its place, or, where the runner has a shell
60
- * (`runnerShell`: Mode 2), it runs on the runner (placesOf). */
61
- export declare function boxesLine(registry: readonly BoxOffer[], listed: ReadonlySet<string>, allow?: readonly string[] | "none", byDefault?: boolean, runnerShell?: boolean): string;
74
+ * (`runnerShell`: Mode 2), it runs on the runner (placesOf). On a Mode 2 region with no exec (`noExec`), every form says
75
+ * a new agent with bash names a sandbox computer, and why. */
76
+ export declare function boxesLine(registry: readonly BoxOffer[], listed: ReadonlySet<string>, allow?: readonly string[] | "none", byDefault?: boolean, runnerShell?: RunnerShell): string;
62
77
  /** `places` in capabilities: the modes a revision may name, the place a new agent is saved with and a revision that
63
78
  * names none runs in (`default_place`), each box, and the hosts a box whose `network` is `allowlist` reaches (`allow`,
64
79
  * box-settings.ts boxAllowOf; empty for `none`). `default_place` is the runner where it has a shell (`runnerShell`:
65
80
  * Mode 2's Archil exec), Docker answering or not (defaultPlaceOf); else Docker's box where this server has it; else
66
81
  * null, no default: a new agent names its place, and `default_reason` is the words a no-place create is refused in
67
- * (noBoxRefusal). `default_reason` is there exactly when `default_place` is null. */
68
- export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly string[] | "none", runnerShell?: boolean) => {
82
+ * (noBoxRefusal). On a Mode 2 region with no exec (`noExec`) it is null, Docker answering or not, and `default_reason`
83
+ * says to name a sandbox computer (noExecIssue). `default_reason` is there exactly when `default_place` is null. */
84
+ export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly string[] | "none", runnerShell?: RunnerShell) => {
69
85
  boxes: BoxOffer[];
70
86
  allow: string[];
71
87
  default_place: Place;