@parcha/agentrun-serve 0.1.0-beta.61 → 0.1.0-beta.63
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.
- package/CHANGELOG.md +113 -0
- package/README.md +128 -20
- package/dist/adapters.js +4 -2
- package/dist/agent-delete.d.ts +3 -3
- package/dist/agent-delete.js +50 -4
- package/dist/api-only.d.ts +4 -0
- package/dist/api-only.js +5 -1
- package/dist/archil-settings.d.ts +9 -0
- package/dist/archil-settings.js +8 -1
- package/dist/bash-read-only.d.ts +3 -0
- package/dist/bash-read-only.js +6 -3
- package/dist/chatgpt-plan.d.ts +33 -8
- package/dist/chatgpt-plan.js +141 -24
- package/dist/claude-login.d.ts +12 -5
- package/dist/claude-login.js +28 -3
- package/dist/cli.js +19 -8
- package/dist/composio-triggers.d.ts +9 -3
- package/dist/computers.d.ts +3 -0
- package/dist/computers.js +2 -1
- package/dist/console/assets/{backend-C9ffXUR5.js → backend-BxQ2G1M0.js} +2 -2
- package/dist/console/assets/index-C8Y5Zl8x.js +639 -0
- package/dist/console/assets/share-CjBJ_rxP.js +6 -0
- package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/cut-pool.d.ts +14 -0
- package/dist/cut-pool.js +98 -0
- package/dist/cut-worker.d.ts +14 -0
- package/dist/cut-worker.js +16 -0
- package/dist/decisions.d.ts +4 -0
- package/dist/decisions.js +9 -1
- package/dist/env-switch.d.ts +3 -0
- package/dist/env-switch.js +3 -0
- package/dist/harness-opencode/adapter.d.ts +3 -1
- package/dist/harness-opencode/adapter.js +6 -2
- package/dist/harness-opencode/harness.d.ts +4 -0
- package/dist/harness-opencode/harness.js +6 -1
- package/dist/harness-table.d.ts +7 -0
- package/dist/harness-table.js +6 -3
- package/dist/host-tools.d.ts +18 -3
- package/dist/host-tools.js +27 -4
- package/dist/import.d.ts +8 -1
- package/dist/import.js +36 -5
- package/dist/key-check.js +22 -8
- package/dist/learn/ledger.d.ts +37 -16
- package/dist/learn/ledger.js +56 -24
- package/dist/learn/promote.d.ts +4 -1
- package/dist/learned-nodes.d.ts +2 -1
- package/dist/learned-nodes.js +2 -1
- package/dist/learning-cost.d.ts +5 -3
- package/dist/learning-model.js +7 -5
- package/dist/learning-work.d.ts +69 -0
- package/dist/learning-work.js +148 -0
- package/dist/mcp-gateway.d.ts +24 -0
- package/dist/mcp-gateway.js +97 -8
- package/dist/mcp-servers-store.d.ts +7 -10
- package/dist/mcp-servers-store.js +15 -9
- package/dist/native/cli.js +5 -1
- package/dist/ollama-provider.d.ts +10 -3
- package/dist/ollama-provider.js +17 -7
- package/dist/openapi.js +51 -20
- package/dist/otel/tracer.d.ts +6 -3
- package/dist/otel/tracer.js +24 -6
- package/dist/page.d.ts +7 -0
- package/dist/page.js +17 -4
- package/dist/place.d.ts +25 -9
- package/dist/place.js +37 -11
- package/dist/print.d.ts +3 -2
- package/dist/print.js +8 -6
- package/dist/run-export.js +7 -4
- package/dist/run-launch.d.ts +6 -1
- package/dist/run-launch.js +26 -6
- package/dist/run-model-key.d.ts +2 -1
- package/dist/run-model-key.js +2 -1
- package/dist/run-reads-over-store.d.ts +7 -0
- package/dist/run-reads-over-store.js +32 -4
- package/dist/run-view.js +9 -3
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +21 -11
- package/dist/runner/adapter-loop.js +95 -28
- package/dist/runner/adapter-run-spec.d.ts +20 -4
- package/dist/runner/adapter-run-spec.js +64 -30
- package/dist/runner/adapters/index.d.ts +6 -0
- package/dist/runner/adapters/index.js +5 -1
- package/dist/runner/adapters/pi.d.ts +42 -3
- package/dist/runner/adapters/pi.js +114 -13
- package/dist/runner/audit.d.ts +8 -2
- package/dist/runner/audit.js +34 -18
- package/dist/runner/book-cut.d.ts +6 -0
- package/dist/runner/book-cut.js +38 -0
- package/dist/runner/claim-secrets.d.ts +12 -5
- package/dist/runner/claim-secrets.js +28 -12
- package/dist/runner/cli-run-spec.d.ts +0 -2
- package/dist/runner/cli-run-spec.js +54 -25
- package/dist/runner/dispatch.js +2 -0
- package/dist/runner/harness-loops.d.ts +5 -0
- package/dist/runner/harness-loops.js +4 -1
- package/dist/runner/held.d.ts +6 -3
- package/dist/runner/learned-first.d.ts +5 -0
- package/dist/runner/learned-first.js +1 -1
- package/dist/runner/learning-end.d.ts +15 -8
- package/dist/runner/learning-end.js +23 -7
- package/dist/runner/live-ticker.js +3 -1
- package/dist/runner/loop-contract.d.ts +8 -1
- package/dist/runner/main.js +2 -0
- package/dist/runner/mcp-run.d.ts +5 -0
- package/dist/runner/mcp-run.js +18 -0
- package/dist/runner/meta-tools.js +4 -4
- package/dist/runner/metrics.d.ts +4 -2
- package/dist/runner/metrics.js +5 -3
- package/dist/runner/model-route.d.ts +4 -0
- package/dist/runner/model-route.js +1 -1
- package/dist/runner/native-loop.js +2 -2
- package/dist/runner/pr-checkout.d.ts +12 -0
- package/dist/runner/pr-checkout.js +21 -2
- package/dist/runner/promotion.d.ts +9 -2
- package/dist/runner/promotion.js +79 -28
- package/dist/runner/reflect-hook.d.ts +7 -0
- package/dist/runner/reflect-hook.js +2 -1
- package/dist/runner/run-child-host.d.ts +10 -6
- package/dist/runner/run-child-host.js +65 -41
- package/dist/runner/run-child.js +2 -0
- package/dist/runner/runner.d.ts +9 -0
- package/dist/runner/runner.js +158 -25
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/workflow-calls.d.ts +4 -3
- package/dist/runner/workflow-calls.js +41 -12
- package/dist/runner/workflow-first.js +4 -3
- package/dist/runner/workflow-loop.js +13 -1
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/secret-cut.d.ts +4 -0
- package/dist/secret-cut.js +1 -1
- package/dist/secret-rules.d.ts +2 -1
- package/dist/secret-rules.js +88 -24
- package/dist/server.d.ts +10 -1
- package/dist/server.js +131 -44
- package/dist/share-host.d.ts +111 -0
- package/dist/share-host.js +669 -0
- package/dist/store/schema.d.ts +4 -3
- package/dist/store/schema.js +4 -3
- package/dist/store/seal.d.ts +8 -2
- package/dist/store/seal.js +13 -2
- package/dist/store/sqlite/learning-rows.js +2 -1
- package/dist/store/sqlite/run-patch.js +4 -4
- package/dist/store/sqlite/store.js +28 -4
- package/dist/store/store.d.ts +5 -0
- package/dist/store-reads/analytics.d.ts +15 -0
- package/dist/store-reads/analytics.js +17 -0
- package/dist/store-reads/journal.d.ts +2 -0
- package/dist/store-reads/journal.js +1 -1
- package/dist/store-reads/learning.d.ts +4 -3
- package/dist/store-reads/learning.js +62 -18
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +18 -1
- package/dist/suggestions.js +32 -3
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +7 -3
- package/dist/tool-gate.d.ts +25 -9
- package/dist/tool-gate.js +58 -19
- package/dist/tool-list.d.ts +4 -0
- package/dist/tool-list.js +4 -0
- package/dist/tool-plane.d.ts +1 -0
- package/dist/tool-plane.js +6 -2
- package/dist/tools.js +2 -2
- package/dist/trigger-composio.js +1 -1
- package/dist/webhooks.d.ts +3 -0
- package/dist/webhooks.js +5 -0
- package/dist/workspace/archil-claim.d.ts +7 -3
- package/dist/workspace/archil-claim.js +13 -5
- package/dist/workspace/archil-mount-credential.d.ts +6 -0
- package/dist/workspace/archil-mount-credential.js +11 -0
- package/dist/workspace/attach.js +22 -5
- package/dist/workspace/computer-deps.d.ts +5 -3
- package/dist/workspace/computer-deps.js +11 -9
- package/dist/workspace/computer-for-claim.d.ts +6 -2
- package/dist/workspace/computer-for-claim.js +43 -12
- package/dist/workspace/computer-janitor.d.ts +7 -4
- package/dist/workspace/computer-janitor.js +7 -4
- package/dist/workspace/computer-kept.d.ts +7 -1
- package/dist/workspace/computer-kept.js +7 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +17 -4
- package/dist/workspace/mount-revoke-left.d.ts +16 -4
- package/dist/workspace/mount-revoke-left.js +42 -22
- package/dist/workspace/resolve-computer.d.ts +11 -5
- package/dist/workspace/resolve-computer.js +22 -13
- package/dist/workspace/run-end-computers.js +1 -1
- package/dist/workspace/run-tools.d.ts +10 -3
- package/dist/workspace/run-tools.js +5 -4
- package/dist/wrapped.d.ts +29 -2
- package/dist/wrapped.js +20 -3
- package/launcher/agentrun-serve +1 -1
- package/package.json +12 -12
- package/templates/kyb/agent.md +7 -1
- package/templates/kyb/evals/list-file-fuzzy-alias/case.yaml +10 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/graders/finds-the-transliteration.md +17 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-fuzzy-alias/prompt.md +7 -0
- package/templates/kyb/evals/list-file-hit/case.yaml +10 -0
- package/templates/kyb/evals/list-file-hit/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-hit/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-hit/graders/hits-by-company-number.md +18 -0
- package/templates/kyb/evals/list-file-hit/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-hit/prompt.md +7 -0
- package/templates/kyb/evals/list-file-no-hit/case.yaml +10 -0
- package/templates/kyb/evals/list-file-no-hit/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-no-hit/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-no-hit/graders/no-hit-by-whole-file.md +12 -0
- package/templates/kyb/evals/list-file-no-hit/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-no-hit/prompt.md +7 -0
- package/templates/kyb/evals/list-file-short-name/case.yaml +9 -0
- package/templates/kyb/evals/list-file-short-name/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-short-name/graders/finds-the-short-name.md +19 -0
- package/templates/kyb/evals/list-file-short-name/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-short-name/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-short-name/prompt.md +7 -0
- package/templates/kyb/evals/list-file-split-name/case.yaml +11 -0
- package/templates/kyb/evals/list-file-split-name/fixtures/web.json +58 -0
- package/templates/kyb/evals/list-file-split-name/graders/finds-the-director.md +18 -0
- package/templates/kyb/evals/list-file-split-name/graders/greps-the-files.md +11 -0
- package/templates/kyb/evals/list-file-split-name/graders/saves-the-uk-file.md +8 -0
- package/templates/kyb/evals/list-file-split-name/prompt.md +7 -0
- package/templates/kyb/kyb.schema.json +2 -2
- package/templates/kyb/rules/SANCTIONS.md +82 -13
- package/dist/console/assets/index-BnZV3lvW.js +0 -639
- package/dist/console/assets/share-B1o5mJ56.js +0 -6
- /package/dist/console/assets/{styles-D_znYrHR.js → styles-BGZxYkky.js} +0 -0
package/dist/openapi.js
CHANGED
|
@@ -83,6 +83,8 @@ import "./computers.js";
|
|
|
83
83
|
import { ARCHIL_KEY_NAMES } from "./archil-routes.js";
|
|
84
84
|
import { ARCHIL_S3_URLS } from "./archil-settings.js";
|
|
85
85
|
import { RUN_FILE_CUT_MAX } from "./run-files.js";
|
|
86
|
+
import { COMPILE_TIMEOUT_MS } from "./learn/compile.js";
|
|
87
|
+
import { LEARNING_CHILD_MS } from "./learning-work.js";
|
|
86
88
|
import { ATTACH_HEARTBEAT_MS, ATTACH_IDLE_MS, ATTACH_SUBPROTOCOL, MAX_LINE_BYTES, PAIRING_CODE_PATTERN, PAIRING_CODE_TTL_MS, PROTOCOL_VERSION } from "@parcha/agentrun-computer";
|
|
87
89
|
import { DAEMON_FETCHES_PER_MINUTE, PAIR_TRIES_PER_MINUTE, PAIRED_NAME_MAX } from "./computer-attach.js";
|
|
88
90
|
/** runlabels/1: a run's labels, given at its start and served on every read of it (run-labels.ts). */
|
|
@@ -173,6 +175,8 @@ const closed = (properties, description) => ({ type: "object", additionalPropert
|
|
|
173
175
|
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
176
|
/** wrapped/1: GET /wrapped's answer (wrapped.ts). */
|
|
175
177
|
const WRAPPED_TOKENS = closed({ input: COUNT, output: COUNT, cache_read: COUNT, cache_write: COUNT });
|
|
178
|
+
/** One figure per cache cause (the import package's CACHE_CAUSES), each always there. */
|
|
179
|
+
const CACHE_BY_CAUSE = (value) => closed(Object.fromEntries(["model", "idle", "compaction", "edited", "sidechain", "unknown"].map((cause) => [cause, value])));
|
|
176
180
|
const WRAPPED = closed({
|
|
177
181
|
year: { type: "integer", minimum: 1000, maximum: 9999 },
|
|
178
182
|
sessions: { ...COUNT, description: "Sessions whose first request falls in the year." },
|
|
@@ -190,6 +194,19 @@ const WRAPPED = closed({
|
|
|
190
194
|
sources: { type: "array", items: closed({ source: { type: "string" }, sessions: COUNT, requests: COUNT }), description: "By the tool the sessions were read from." },
|
|
191
195
|
imported: { type: "array", items: closed({ source: { type: "string" }, runs: COUNT }), description: "The runs imported here in the year, by source (never `live`)." },
|
|
192
196
|
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." },
|
|
197
|
+
cache: {
|
|
198
|
+
oneOf: [
|
|
199
|
+
closed({
|
|
200
|
+
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." },
|
|
201
|
+
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." },
|
|
202
|
+
breaks: { ...CACHE_BY_CAUSE(COUNT), description: "Cache breaks by cause: a turn whose cache read dropped more than 80% against the turn before it." },
|
|
203
|
+
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." },
|
|
204
|
+
unpriced_breaks: { ...COUNT, description: "Breaks on a model with no list price: in `breaks`, not in `extra_cost_usd`." },
|
|
205
|
+
}),
|
|
206
|
+
{ type: "null" },
|
|
207
|
+
],
|
|
208
|
+
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.",
|
|
209
|
+
},
|
|
193
210
|
}, "A year of the work under this machine's home, bucketed by each request's time in the server's local zone.");
|
|
194
211
|
/** Runs counted together (AgentStoreReader.analytics's AnalyticsGroup). */
|
|
195
212
|
const GROUP = {
|
|
@@ -369,7 +386,7 @@ const RUN_USAGE_LINE = {
|
|
|
369
386
|
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
387
|
resource: { enum: ["vcpu", "memory", "gpu", "disk"], description: "On `compute_time`: the resource the line counts." },
|
|
371
388
|
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`.
|
|
389
|
+
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
390
|
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
391
|
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
392
|
},
|
|
@@ -418,7 +435,7 @@ const COMPUTER_INTERVAL = {
|
|
|
418
435
|
started_at: { type: "string", format: "date-time", description: "When the provider's create answered with the computer, on this server's clock." },
|
|
419
436
|
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
437
|
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.
|
|
438
|
+
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
439
|
...ATTEMPT_FIELDS,
|
|
423
440
|
},
|
|
424
441
|
};
|
|
@@ -897,11 +914,11 @@ const MCP_PIN = {
|
|
|
897
914
|
* resolves to on the agent's harness and model; a tool of bash's family its computer leaves out, unavailable. */
|
|
898
915
|
const AGENT_TOOLS = {
|
|
899
916
|
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
|
|
917
|
+
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
918
|
items: {
|
|
902
919
|
type: "object", additionalProperties: false, required: ["name", "permission", "permission_from", "default_permission", "permissions"],
|
|
903
920
|
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,
|
|
921
|
+
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
922
|
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
923
|
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
924
|
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 +1167,11 @@ const MODEL_GATEWAY_TEST = {
|
|
|
1150
1167
|
/** computer/1: an agent's computer kind, as Settings → Computers and the run read name it (computer-setting.ts). */
|
|
1151
1168
|
const COMPUTER_KIND = { enum: ["none", "sandbox", "desktop", "phone", "browser"] };
|
|
1152
1169
|
/** 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,
|
|
1170
|
+
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
1171
|
/** The host tools a choice gives, by name: the kernel registry's list for its shell. */
|
|
1155
1172
|
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
1173
|
/** 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
|
|
1174
|
+
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
1175
|
/** A sandbox's GPUs on an agent's computer setting (computer-setting.ts GpuSetting). */
|
|
1159
1176
|
const COMPUTER_GPU = {
|
|
1160
1177
|
type: "object", additionalProperties: false, required: ["type", "count"],
|
|
@@ -1829,18 +1846,19 @@ const COST_RUN = closedWith({
|
|
|
1829
1846
|
audited: { type: "boolean", description: "An audit's shadow run was started for it (the agent definition's `learning.audit_every`): the shadow's cost is in `learning_usd`, and its verdict is a row of GET /agents/{agent_id}/learning/audits once scored, at a later run's start." },
|
|
1830
1847
|
cost_usd: COST_USD("The job's own cost: what the run had cost when its answer was final, before its compile turn; for a run that was asked none, its whole cost."),
|
|
1831
1848
|
cost_upper_bound: { type: "boolean", description: "The run's stored cost is only a bound (its row's `costAtMostUsd`: a model request cut at its cap hold): `cost_usd` and `total_usd` are null, never a known cost. `summary` counts such a run as `at_most`, not `unknown`." },
|
|
1832
|
-
learning_usd: COST_USD("What learning cost for the run: its compile turn. 0 for a run that does not learn or was not asked one. An audit's shadow run of it is its learning too: null while that shadow is queued or running, never $0."),
|
|
1849
|
+
learning_usd: COST_USD("What learning cost for the run: its compile turn. 0 for a run that does not learn or was not asked one. An audit's shadow run of it is its learning too, and so are the replays of a check it started on its own model key (`check_usd`): null while that shadow is queued or running, never $0."),
|
|
1833
1850
|
total_usd: COST_USD("The run's all-in cost, `cost_usd` and `learning_usd` together; null when either is."),
|
|
1834
1851
|
}, {
|
|
1835
1852
|
compile_usd: COST_USD("The compile turns the run's own session asked: its revision's spend, never its own (`bill.revisions`), or no run's when it kept no draft (`bill.unattributed_usd`). GET /runs/{id} `cost.compile_usd` is the same figure. 0 for a run asked none."),
|
|
1836
1853
|
followup_usd: COST_USD("What the run's learning spent after its job answered besides its compile turns (a follow-up round's turns): a part of its GET /runs/{id} `cost.learning_usd`, the same figure there."),
|
|
1837
1854
|
shadow_usd: COST_USD("Its audit shadow's cost (0 when none ran): a part of its GET /runs/{id} `cost.learning_usd`, the same figure there. Null while the shadow is queued or running."),
|
|
1855
|
+
check_usd: COST_USD("What the replay runs of a check it started on its own model key (`model_key`) cost (0 when none ran): its own learning, as its shadow is, in its `learning_usd` and its GET /runs/{id} `cost.learning_usd`, the same figure there, and never in `bill.revisions`."),
|
|
1838
1856
|
share_usd: COST_USD("Its share of the learning spend of the revision that served it (`bill.revisions`): a part of its GET /runs/{id} `cost.learning_usd`, the same figure there. 0 for a run no revision served."),
|
|
1839
1857
|
not_served: { enum: ["cost_stop", "cut", null], description: "Why a learned workflow did not serve the run alone, when one was there to: `cost_stop`, the money rule stopped it (its served runs cost as much as the agent by hand); `cut`, a restart cut the workflow's call and the run was handed back (`handed_back` at agent cost, counted in the summary's `hand_backs.cut`, never `back`). Null otherwise." },
|
|
1840
1858
|
});
|
|
1841
1859
|
const LEARNING_COST = closed({
|
|
1842
1860
|
agent: { type: "string" },
|
|
1843
|
-
runs: { type: "array", items: COST_RUN, description: "The agent's agentic runs that ended (completed, stopped or failed), oldest first: the last `limit` of them, each keeping its number (a replay has none). A run still at work, an imported or archived run, a workflow revision's run and a run whose path is not known (`unknown_path_runs`) are left out; a run's grade is no run here, and its cost is that run's `learning_usd`." },
|
|
1861
|
+
runs: { type: "array", items: COST_RUN, description: "The agent's agentic runs that ended (completed, stopped or failed), oldest first: the last `limit` of them, each keeping its number (a replay has none). A run still at work, an imported or archived run, a workflow revision's run and a run whose path is not known (`unknown_path_runs`) are left out; a run's grade is no run here, and its cost is that run's `learning_usd`. A replay a run started on its own model key (`model_key`) is no run here either: its cost is that run's `check_usd`, counted once." },
|
|
1844
1862
|
total_runs: { ...COUNT, description: "How many runs the series counts in all, `limit` aside." },
|
|
1845
1863
|
unknown_cost_runs: { ...COUNT, description: "How many of them have no known all-in cost (`total_usd` null)." },
|
|
1846
1864
|
unknown_path_runs: { ...COUNT, description: "How many runs that learn ended with no path on their record (their end could not read their cost and path in time, or no runner wrote their end): left out of `runs`, `total_runs` and `summary`, never counted as `agent` runs at $0." },
|
|
@@ -1887,7 +1905,7 @@ const LEARNING_COST = closed({
|
|
|
1887
1905
|
workflow: { type: "string", description: "The learned workflow, by name." },
|
|
1888
1906
|
digest: { type: "string", description: "The revision: the first 16 hex characters of its workflow.json's sha256." },
|
|
1889
1907
|
compile_usd: COST_USD("What the compile turns that drafted it cost: each ran at the end of a run, in its session, and is that run's learning spend no more, but this revision's. A recompile's turn is its recompiled revision's. 0 when none on record drafted it."),
|
|
1890
|
-
check_usd: COST_USD("What its check cost: its replay runs (the first draft's check or the one recompile's, each revision its own)."),
|
|
1908
|
+
check_usd: COST_USD("What its check cost: its replay runs (the first draft's check or the one recompile's, each revision its own). A replay on a run's own model key (`model_key`) is that run's learning instead (its `runs[].check_usd`), never here."),
|
|
1891
1909
|
spend_usd: COST_USD("Its learning spend: `compile_usd` and `check_usd` together."),
|
|
1892
1910
|
k: { type: "integer", minimum: 1, description: "The served runs its spend is spread over: its check's `compile_after`." },
|
|
1893
1911
|
served: { ...COUNT, description: "How many runs it has served (`workflow` or `handed_back` at this digest), every one: its first `k` carry its spend." },
|
|
@@ -2571,7 +2589,7 @@ const EXTENSIONS = {
|
|
|
2571
2589
|
"/runs/{run_id}/export": {
|
|
2572
2590
|
get: {
|
|
2573
2591
|
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.",
|
|
2592
|
+
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
2593
|
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
2594
|
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
2595
|
"x-agentrun-serve": "share/1",
|
|
@@ -3100,11 +3118,11 @@ const EXTENSIONS = {
|
|
|
3100
3118
|
"/settings/claude-login/sign-out": {
|
|
3101
3119
|
post: {
|
|
3102
3120
|
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).",
|
|
3121
|
+
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
3122
|
"x-agentrun-secret": true,
|
|
3105
3123
|
security: [{ ownerSession: [] }],
|
|
3106
3124
|
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
|
|
3125
|
+
"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
3126
|
...errors(401, 403, 404, 429, 500),
|
|
3109
3127
|
},
|
|
3110
3128
|
"x-agentrun-serve": "claudelogin/1",
|
|
@@ -3477,7 +3495,7 @@ const EXTENSIONS = {
|
|
|
3477
3495
|
"/settings/tools": {
|
|
3478
3496
|
get: {
|
|
3479
3497
|
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.",
|
|
3498
|
+
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
3499
|
responses: { "200": json(TOOL_SETTINGS_ANSWER, "Each capability's provider."), ...errors(401, 429, 500) },
|
|
3482
3500
|
"x-agentrun-serve": "providers/1",
|
|
3483
3501
|
},
|
|
@@ -4075,7 +4093,7 @@ const MCP_RUN_AUTH = {
|
|
|
4075
4093
|
const RUN_MODEL_KEY = {
|
|
4076
4094
|
type: "string", minLength: MIN_SECRET, maxLength: MAX_MODEL_KEY_CHARS, pattern: HANDED_SECRET.source,
|
|
4077
4095
|
// Not x-agentrun-secret, as mcp_auth: a key for this run alone, handed by whoever may start it, never kept for others.
|
|
4078
|
-
description: `The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased from the store by the write that ends the run's turn;
|
|
4096
|
+
description: `The run's own model key: a key for the model gateway at AGENT_MODEL_BASE_URL, such as a LiteLLM virtual key minted for this run, which every model request tied to the run carries in place of the server's own key (its turns, its subagents, its learned workflows' nodes, a workflow's model nodes, its end-of-run compile turn, and the learning work it starts: a learned workflow's check replay runs and an audit's shadow run). AgentRun never mints, lists or revokes it. Sealed into the run's launch bound to the gateway's origin, read at each claim (a reclaim after a crash among them), erased from the store by the write that ends the run's turn. A replay or shadow run the run starts while its claim holds the key takes a copy sealed for that run alone, erased by the write that ends that run (or its purge): such a run starts at the run's end, capped at its share of what the run's cap leaves then (none left: it is dropped, nothing spent), and it is listed in the run's \`learning_work\` until it ends; revoke the key once the run is terminal and \`learning_work.state\` is not \`running\`. Never in its saved body, its timeline, its view, a log or an Idempotency-Key's fingerprint (a retry with a new key answers the first request's run, its first key kept). The harness, its tools and its sandbox never see it. 422 \`invalid\` at \`model_key\` for a key under ${MIN_SECRET} characters (no cut could hold it) or one with a character that is not visible ASCII (a space, a control character, anything past ASCII); 422 at \`model_key\` when the run's model never goes to that gateway (no AGENT_MODEL_BASE_URL here, a native run, or a model routed elsewhere). Absent, the run spends on the server's key for its route; where the server holds none (no AGENT_MODEL_API_KEY, none saved in Settings), a start without it is 422 \`model_key_required\`, never a failure at its first model call.`,
|
|
4079
4097
|
"x-agentrun-serve": "runmodelkey/1",
|
|
4080
4098
|
};
|
|
4081
4099
|
/** runkeys/1: the run's own tool keys (run-keys.ts), by name. */
|
|
@@ -4115,13 +4133,14 @@ const FIELD_EXTENSIONS = {
|
|
|
4115
4133
|
description: "The run's model requests' tokens, as their provider or gateway reported them in each answer's usage (OpenAI's Responses `usage.input_tokens`/`output_tokens`, Anthropic's Messages `usage` with its cache reads and writes). Absent while the run has booked no model request and stored none (a run still starting, a workflow with no model node), and on a native or SDK run, which reports its whole task's tokens at its end with no request count, while any count is unknown.",
|
|
4116
4134
|
"x-agentrun-serve": "costbasis/1",
|
|
4117
4135
|
},
|
|
4118
|
-
learning_usd: { type: ["number", "null"], minimum: 0, description: "On the run read (GET /v2/runs/{run_id}) alone, where `usd` is the run's own spend, the job's: what learning spent for it, on the agent's own model route. Its audit shadow's cost (the agent on its input with learning off) and its share of its workflow revision's learning spend: the compile turn that drafted that revision and its check's replay runs, spread over the first `compile_after` runs the revision serves (GET /agents/{agent_id}/learning/cost `bill.revisions`). A compile turn is never in the `usd` or `learning_usd` of the run whose session asked it: it is its revision's (a recompile's, its recompiled revision's), or, when it kept no draft (every draft failed its checks, or the cap stopped it), on no run (`bill.unattributed_usd`). 0 for a replay or shadow run, whose spend is on the runs it serves. As booked (float noise rounded off at 1e-12, as `usd` is); null while the run
|
|
4136
|
+
learning_usd: { type: ["number", "null"], minimum: 0, description: "On the run read (GET /v2/runs/{run_id}) alone, where `usd` is the run's own spend, the job's: what learning spent for it, on the agent's own model route. Its audit shadow's cost (the agent on its input with learning off), what the replays of a check it started on its own model key cost (`check_usd`), and its share of its workflow revision's learning spend: the compile turn that drafted that revision and its check's replay runs, spread over the first `compile_after` runs the revision serves (GET /agents/{agent_id}/learning/cost `bill.revisions`). A compile turn is never in the `usd` or `learning_usd` of the run whose session asked it: it is its revision's (a recompile's, its recompiled revision's), or, when it kept no draft (every draft failed its checks, or the cap stopped it), on no run (`bill.unattributed_usd`). 0 for a replay or shadow run, whose spend is on the runs it serves. As booked (float noise rounded off at 1e-12, as `usd` is); null while the run, its shadow or an own-key check's replay is at work, or a part is unknown: never $0 for unknown.", "x-agentrun-serve": "allin/1" },
|
|
4119
4137
|
tools_usd: { type: ["number", "null"], minimum: 0, description: "On the run read (GET /v2/runs/{run_id}) alone: the part of `usd` that went to the run's paid tool calls (a monid endpoint's charge, an MCP tool's saved price, Parallel's behind `web_search` and `web_fetch`, the browser's session time, and a workflow decision Parallel answered on its own API on this server's PARALLEL_API_KEY, at Parallel's list price), as the run's ledger booked them, joined and rounded as `usd` is, so `usd` less this is its model requests and its other decisions (Jev's, an OpenRouter model's, Parallel's model reached through OpenRouter). Inside `usd`, never added to it. A paid call in the run's end-of-run turn is learning's, in `learning_usd` and never here. 0 when the run made no paid call. An MCP tool with no price is in neither (`not_metered` on its trace span). Null while a paid call's charge is unknown (one charged an unknown amount, cut, or still running), or counted at its hold; while the run is at work (until it ended, stopped or failed); for a run a follow-up opened again (a round past its first), whose job is what it had cost when its first round answered; and for an imported, native or SDK run, whose `usd` is its import's or its harness's own figure and whose tool calls the server never books: never $0 for unknown.", "x-agentrun-serve": "toolsusd/2" },
|
|
4120
4138
|
all_in_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone: `usd` and `learning_usd` together, what the run cost its owner all in. 0 for a replay or shadow run. Over every run of an agent, these and the cost route's `bill.unattributed_usd` add up to its `bill.booked_usd`. Null when either is, or `usd` is only a bound (`upper_bound`).", "x-agentrun-serve": "allin/1" },
|
|
4121
4139
|
compile_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone: the compile turns the run's own session asked, as booked. Never in its `usd` or `learning_usd`: each is its revision's (its share is in the `learning_usd` of the runs that revision serves, `share_usd`), or no run's when it kept no draft (the cost route's `bill.unattributed_usd`). 0 for a run asked none; null while the run is at work or the turn's cost is unknown. The cost route's `runs[].compile_usd` is the same figure.", "x-agentrun-serve": "ledger/1" },
|
|
4122
4140
|
followup_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone, a part of `learning_usd`: what the run's learning spent after its job answered besides its compile turns (a follow-up round's turns, feedback the run was given). 0 for none; null while the run is at work or unknown.", "x-agentrun-serve": "ledger/1" },
|
|
4123
4141
|
shadow_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone, a part of `learning_usd`: its audit shadow's cost (0 when none ran). Null while the shadow is queued or running, or its cost is unknown: never $0.", "x-agentrun-serve": "ledger/1" },
|
|
4124
|
-
|
|
4142
|
+
check_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone, a part of `learning_usd`: what the replay runs of its learned workflow's check cost when it started them on its own model key (`model_key`; `learning_work` lists them), 0 when none ran. They spent on the run's key, so they are its learning, as its shadow is, and never their revision's (`bill.revisions`). Null while one is queued or running, or a cost is unknown: never $0.", "x-agentrun-serve": "ledger/1" },
|
|
4143
|
+
share_usd: { type: ["number", "null"], minimum: 0, description: "On the run read alone, a part of `learning_usd`: its share of the learning spend of the workflow revision that served it (that revision's compile turns and check replays, spread over the first `compile_after` runs it serves, the cost route's `bill.revisions`). 0 for a run no revision served; null while unknown. `followup_usd`, `shadow_usd`, `check_usd` and this add up to `learning_usd`.", "x-agentrun-serve": "ledger/1" },
|
|
4125
4144
|
plan: {
|
|
4126
4145
|
type: "object", additionalProperties: false, required: ["requests", "tokens", "on"],
|
|
4127
4146
|
properties: {
|
|
@@ -4247,6 +4266,15 @@ const FIELD_EXTENSIONS = {
|
|
|
4247
4266
|
},
|
|
4248
4267
|
trigger: RUN_TRIGGER,
|
|
4249
4268
|
audit_of: { ...NULL_STRING, description: "On the run read: a shadow run's served run. A run a promoted learned workflow answered alone (path `workflow`; a run it handed back is never drawn) may be audited (the agent definition's `learning.audit_every`): its shadow, the same agent on the same input with learning off, started at the served run's end and capped at what the served run's cap left, is no row of any run list and sends no webhook, and its cost is in the served run's `cost.learning_usd` and `cost.all_in_usd` (null while the shadow is queued or running: never $0), never in its `cost.usd`, and in the agent's learning cost (GET /agents/{agent_id}/learning/audits). Null for any other run.", "x-agentrun-serve": "promotion/1" },
|
|
4269
|
+
learning_work: {
|
|
4270
|
+
...closed({
|
|
4271
|
+
state: { enum: ["none", "running", "ended"], description: "`none`: the run started no learning work (it does not learn, its learning was off, or nothing of it began), and never will once the run is terminal. `running`: learning work it started is still going: its end-of-run compile turn (inside the run's own claim, while the run already reads `completed`), a learned workflow's check replay runs, or its audit's shadow run. `ended`: every piece it started finished or was dropped: a child run that failed, was cancelled or lost, or one dropped before it started because the run's cap left too little for it (`no_budget`: nothing spent). Once the run is terminal it only moves forward: none or running, then ended; it never reads `running` again after `none` or `ended` (a message that opens the run again starts a new turn, whose learning starts afresh)." },
|
|
4272
|
+
runs: { type: "array", items: { type: "string" }, description: "The id of each child run this run started that has not ended (a check's replay runs, an audit's shadow run), oldest first; `[]` while only the compile turn runs, and in `none` and `ended`." },
|
|
4273
|
+
ended_at: { ...DATE_TIME, type: ["string", "null"], description: "When the last piece of its learning work finished or dropped; null unless `state` is `ended`." },
|
|
4274
|
+
deadline_at: { ...DATE_TIME, type: ["string", "null"], description: `The latest instant any learning work this run started may still spend on its key: the later of its compile turn's start + its timeout (${COMPILE_TIMEOUT_MS / 60_000} min) and each started child's start + its bound (${LEARNING_CHILD_MS / 60_000} min). The server cancels a child still at work at its bound, as a person's cancel is, and it then counts as ended. It only moves later while \`state\` is \`running\`; null unless \`state\` is \`running\`. A key-expiry backstop for a caller that missed \`state\`: \`state\` stays the signal to revoke on.` },
|
|
4275
|
+
}, "The learning work this run started beside its turn, what a caller that handed the run its own model key (`model_key`) revokes it on: once the run is terminal (`completed`, `failed`, `stopped`, `cancelled`) and `state` is not `running`, nothing of the run or of a child it started sends that key again. A child spends on a copy of the run's key sealed for it alone, erased by the write that ends it, within its share of what the run's cap left at the run's end. Always on a run's view (GET /runs/{run_id}, and each answer that returns the run), never on run lists or webhooks."),
|
|
4276
|
+
"x-agentrun-serve": "learningwork/1",
|
|
4277
|
+
},
|
|
4250
4278
|
...RUN_PATH,
|
|
4251
4279
|
},
|
|
4252
4280
|
InputIssue: {
|
|
@@ -4640,10 +4668,10 @@ const FIELD_EXTENSIONS = {
|
|
|
4640
4668
|
{ type: "object", additionalProperties: false, required: ["mode", "box"], properties: { mode: { const: "sandbox" }, box: { enum: [...BOX_IDS] } } },
|
|
4641
4669
|
{ type: "null" },
|
|
4642
4670
|
],
|
|
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`.)",
|
|
4671
|
+
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`. Null has two causes: Mode 1 with no Docker, where such a create is refused at `definition.place`, and Mode 2 on an Archil region with no serverless exec, where it is refused at `definition.computer`; the refusal's field says which. 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
4672
|
"x-agentrun-serve": "place/5",
|
|
4645
4673
|
},
|
|
4646
|
-
default_reason: { type: "string", description: "There exactly when `default_place` is null
|
|
4674
|
+
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
4675
|
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
4676
|
},
|
|
4649
4677
|
"Capabilities/workflows": {
|
|
@@ -4949,9 +4977,10 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
|
|
|
4949
4977
|
const schema = schemas[name];
|
|
4950
4978
|
schema.required = [...schema.required, ...RUN_FIELDS_SENT];
|
|
4951
4979
|
}
|
|
4952
|
-
// A run's place, which its view always sends (store-view.ts viewOverStore: the launch's, else the runner)
|
|
4980
|
+
// A run's place, which its view always sends (store-view.ts viewOverStore: the launch's, else the runner), and its
|
|
4981
|
+
// learning_work, which a caller's revoke reads on every run (learning-work.ts): never missing, `none` at the least.
|
|
4953
4982
|
const runSchema = schemas.Run;
|
|
4954
|
-
runSchema.required = [...runSchema.required, "place"];
|
|
4983
|
+
runSchema.required = [...runSchema.required, "place", "learning_work"];
|
|
4955
4984
|
// An agent's own fields this server always sends (agents-store.ts agentView), on a read, a list and a write's answer.
|
|
4956
4985
|
const agentSchema = schemas.Agent;
|
|
4957
4986
|
agentSchema.required = [...agentSchema.required, ...AGENT_FIELDS_SENT];
|
|
@@ -5086,6 +5115,8 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
|
|
|
5086
5115
|
];
|
|
5087
5116
|
readFileOp.responses["413"] = ref("responses/PayloadTooLarge");
|
|
5088
5117
|
readFileOp.responses["415"] = ref("responses/UnsupportedMediaType");
|
|
5118
|
+
// Its cut is made in a worker under a deadline (cut-pool.ts): past it, or when the worker fails, 503, never uncut.
|
|
5119
|
+
readFileOp.responses["503"] = ref("responses/Unavailable");
|
|
5089
5120
|
readFile["x-agentrun-serve-changed"] = { ...readFile["x-agentrun-serve-changed"], parameters: "filecut/1" };
|
|
5090
5121
|
// 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
5122
|
// file a run left, media included, without a path that holds a held value.
|
package/dist/otel/tracer.d.ts
CHANGED
|
@@ -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
|
|
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. */
|
package/dist/otel/tracer.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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).
|
|
33
|
-
*
|
|
34
|
-
|
|
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)
|
|
44
|
-
|
|
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
|
-
|
|
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).
|
|
68
|
-
|
|
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;
|