@parcha/agentrun-serve 0.1.0-beta.62 → 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 +47 -0
- package/README.md +32 -13
- package/dist/adapters.js +4 -2
- package/dist/agent-delete.d.ts +3 -3
- package/dist/agent-delete.js +50 -4
- package/dist/chatgpt-plan.d.ts +8 -1
- package/dist/chatgpt-plan.js +55 -6
- package/dist/console/assets/{backend-DEgVn5lC.js → backend-BxQ2G1M0.js} +2 -2
- package/dist/console/assets/{index-CG5tELph.js → index-C8Y5Zl8x.js} +2 -2
- package/dist/console/assets/share-CjBJ_rxP.js +6 -0
- package/dist/console/index.html +1 -1
- package/dist/console/share.html +1 -1
- 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/host-tools.d.ts +18 -3
- package/dist/host-tools.js +27 -4
- 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/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/openapi.js +23 -9
- package/dist/run-export.js +7 -4
- package/dist/run-launch.d.ts +6 -1
- package/dist/run-launch.js +10 -3
- package/dist/run-view.js +9 -3
- package/dist/runnable.js +5 -5
- package/dist/runner/adapter-loop.js +31 -3
- package/dist/runner/adapter-run-spec.d.ts +14 -3
- package/dist/runner/adapter-run-spec.js +50 -19
- package/dist/runner/adapters/index.d.ts +2 -0
- package/dist/runner/adapters/index.js +3 -0
- 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 +9 -4
- package/dist/runner/claim-secrets.js +10 -5
- package/dist/runner/cli-run-spec.d.ts +0 -2
- package/dist/runner/cli-run-spec.js +44 -19
- 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/loop-contract.d.ts +4 -0
- package/dist/runner/main.js +2 -0
- package/dist/runner/model-route.d.ts +4 -0
- package/dist/runner/model-route.js +1 -1
- 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.js +21 -12
- package/dist/runner/run-child.js +1 -0
- package/dist/runner/runner.d.ts +9 -0
- package/dist/runner/runner.js +156 -25
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/workflow-first.js +4 -3
- package/dist/runner/workflow-loop.js +13 -1
- package/dist/secret-cut.d.ts +4 -0
- package/dist/secret-cut.js +1 -1
- package/dist/secret-rules.d.ts +2 -0
- package/dist/secret-rules.js +63 -19
- package/dist/server.js +20 -9
- package/dist/share-host.js +6 -3
- 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/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/tool-list.d.ts +4 -0
- package/dist/tool-list.js +4 -0
- package/dist/tools.js +2 -2
- package/dist/workspace/attach.js +22 -5
- package/dist/workspace/kind-skills/desktop/SKILL.md +7 -3
- 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/share-CIeFK2Oe.js +0 -6
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). */
|
|
@@ -1844,18 +1846,19 @@ const COST_RUN = closedWith({
|
|
|
1844
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." },
|
|
1845
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."),
|
|
1846
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`." },
|
|
1847
|
-
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."),
|
|
1848
1850
|
total_usd: COST_USD("The run's all-in cost, `cost_usd` and `learning_usd` together; null when either is."),
|
|
1849
1851
|
}, {
|
|
1850
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."),
|
|
1851
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."),
|
|
1852
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`."),
|
|
1853
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."),
|
|
1854
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." },
|
|
1855
1858
|
});
|
|
1856
1859
|
const LEARNING_COST = closed({
|
|
1857
1860
|
agent: { type: "string" },
|
|
1858
|
-
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." },
|
|
1859
1862
|
total_runs: { ...COUNT, description: "How many runs the series counts in all, `limit` aside." },
|
|
1860
1863
|
unknown_cost_runs: { ...COUNT, description: "How many of them have no known all-in cost (`total_usd` null)." },
|
|
1861
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." },
|
|
@@ -1902,7 +1905,7 @@ const LEARNING_COST = closed({
|
|
|
1902
1905
|
workflow: { type: "string", description: "The learned workflow, by name." },
|
|
1903
1906
|
digest: { type: "string", description: "The revision: the first 16 hex characters of its workflow.json's sha256." },
|
|
1904
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."),
|
|
1905
|
-
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."),
|
|
1906
1909
|
spend_usd: COST_USD("Its learning spend: `compile_usd` and `check_usd` together."),
|
|
1907
1910
|
k: { type: "integer", minimum: 1, description: "The served runs its spend is spread over: its check's `compile_after`." },
|
|
1908
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." },
|
|
@@ -4090,7 +4093,7 @@ const MCP_RUN_AUTH = {
|
|
|
4090
4093
|
const RUN_MODEL_KEY = {
|
|
4091
4094
|
type: "string", minLength: MIN_SECRET, maxLength: MAX_MODEL_KEY_CHARS, pattern: HANDED_SECRET.source,
|
|
4092
4095
|
// Not x-agentrun-secret, as mcp_auth: a key for this run alone, handed by whoever may start it, never kept for others.
|
|
4093
|
-
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.`,
|
|
4094
4097
|
"x-agentrun-serve": "runmodelkey/1",
|
|
4095
4098
|
};
|
|
4096
4099
|
/** runkeys/1: the run's own tool keys (run-keys.ts), by name. */
|
|
@@ -4130,13 +4133,14 @@ const FIELD_EXTENSIONS = {
|
|
|
4130
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.",
|
|
4131
4134
|
"x-agentrun-serve": "costbasis/1",
|
|
4132
4135
|
},
|
|
4133
|
-
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" },
|
|
4134
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" },
|
|
4135
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" },
|
|
4136
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" },
|
|
4137
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" },
|
|
4138
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" },
|
|
4139
|
-
|
|
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" },
|
|
4140
4144
|
plan: {
|
|
4141
4145
|
type: "object", additionalProperties: false, required: ["requests", "tokens", "on"],
|
|
4142
4146
|
properties: {
|
|
@@ -4262,6 +4266,15 @@ const FIELD_EXTENSIONS = {
|
|
|
4262
4266
|
},
|
|
4263
4267
|
trigger: RUN_TRIGGER,
|
|
4264
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
|
+
},
|
|
4265
4278
|
...RUN_PATH,
|
|
4266
4279
|
},
|
|
4267
4280
|
InputIssue: {
|
|
@@ -4655,7 +4668,7 @@ const FIELD_EXTENSIONS = {
|
|
|
4655
4668
|
{ type: "object", additionalProperties: false, required: ["mode", "box"], properties: { mode: { const: "sandbox" }, box: { enum: [...BOX_IDS] } } },
|
|
4656
4669
|
{ type: "null" },
|
|
4657
4670
|
],
|
|
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`.)",
|
|
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`.)",
|
|
4659
4672
|
"x-agentrun-serve": "place/5",
|
|
4660
4673
|
},
|
|
4661
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" },
|
|
@@ -4964,9 +4977,10 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
|
|
|
4964
4977
|
const schema = schemas[name];
|
|
4965
4978
|
schema.required = [...schema.required, ...RUN_FIELDS_SENT];
|
|
4966
4979
|
}
|
|
4967
|
-
// 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.
|
|
4968
4982
|
const runSchema = schemas.Run;
|
|
4969
|
-
runSchema.required = [...runSchema.required, "place"];
|
|
4983
|
+
runSchema.required = [...runSchema.required, "place", "learning_work"];
|
|
4970
4984
|
// An agent's own fields this server always sends (agents-store.ts agentView), on a read, a list and a write's answer.
|
|
4971
4985
|
const agentSchema = schemas.Agent;
|
|
4972
4986
|
agentSchema.required = [...agentSchema.required, ...AGENT_FIELDS_SENT];
|
package/dist/run-export.js
CHANGED
|
@@ -176,7 +176,7 @@ export async function exportBundle(input) {
|
|
|
176
176
|
};
|
|
177
177
|
let result;
|
|
178
178
|
try {
|
|
179
|
-
result = await cutPass(text, { mode: "cut", held: input.held, keep, ...(context?.path !== undefined ? { path: context.path } : {}), ...(context?.command !== undefined ? { command: context.command } : {}) });
|
|
179
|
+
result = await cutPass(text, { mode: "cut", held: input.held, keep, ...(context?.path !== undefined ? { path: context.path } : {}), ...(context?.command !== undefined ? { command: context.command } : {}), ...(context?.flattened ? { flattened: true } : {}) });
|
|
180
180
|
}
|
|
181
181
|
catch {
|
|
182
182
|
throw new ExportFailed("a scrub threw");
|
|
@@ -232,9 +232,12 @@ export async function exportBundle(input) {
|
|
|
232
232
|
const context = effectContext(effect);
|
|
233
233
|
return context === undefined ? walk(effect, at) : each(effect, at, (item, here, key) => walk(item, here, key === "output" ? context : undefined));
|
|
234
234
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
// The run's title is its first message flattened onto one line (runs-over-store.ts prepareLaunch): it is cut as such,
|
|
236
|
+
// so a transcript's env command and its output, one line there, is still a dump (secret-cut.ts ScrubOptions.flattened).
|
|
237
|
+
const walkPart = (key, value, at) => key === "run" ? each(value, at, (item, here, field) => (field === "title" && typeof item === "string" ? cutString(item, here, { flattened: true }) : walk(item, here)))
|
|
238
|
+
: key === "rows" ? each(value, at, walkRow)
|
|
239
|
+
: key === "graph" ? each(value, at, (item, here, field) => (field === "effects" ? each(item, here, walkEffect) : walk(item, here)))
|
|
240
|
+
: walk(value, at);
|
|
238
241
|
// A file's content is cut knowing its path (a .env* file or one under ~/.ssh is dropped whole); then its bytes and digest
|
|
239
242
|
// are the carried text's. The caps hold for those bytes, as a share host checks them: a cut can make a file longer than it
|
|
240
243
|
// was read (a marker longer than the value), so one whose cut text is over the file cap, or the files' total, is left out
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -136,11 +136,16 @@ export interface SourceProjectLaunch {
|
|
|
136
136
|
readonly inputs?: readonly string[];
|
|
137
137
|
}
|
|
138
138
|
export declare function sourceProjectOf(value: unknown): SourceProjectLaunch | undefined;
|
|
139
|
-
/** What a replay run replays: the graded run, and the learned workflow at the digest it decides.
|
|
139
|
+
/** What a replay run replays: the graded run, and the learned workflow at the digest it decides. `paidBy`: a replay
|
|
140
|
+
* that spends on run `paidBy`'s own model key (a keyed check, runner/promotion.ts), whose learning its cost is
|
|
141
|
+
* (learn/ledger.ts record), never its revision's. `deadlineAt` (ms): a learning child's deadline, its start +
|
|
142
|
+
* learning-work.ts LEARNING_CHILD_MS; the runner holding it cancels it there (runner.ts). */
|
|
140
143
|
export interface Replay {
|
|
141
144
|
readonly of: string;
|
|
142
145
|
readonly workflow: string;
|
|
143
146
|
readonly digest: string;
|
|
147
|
+
readonly paidBy?: string;
|
|
148
|
+
readonly deadlineAt?: number;
|
|
144
149
|
}
|
|
145
150
|
/** The disk a launch record names, and whose it is. */
|
|
146
151
|
export interface LaunchDisk {
|
package/dist/run-launch.js
CHANGED
|
@@ -38,7 +38,14 @@ export function sourceProjectOf(value) {
|
|
|
38
38
|
/** The disk a launch body names, as read back, or undefined. */
|
|
39
39
|
const readDisk = (value) => isObject(value) && typeof value.disk_id === "string" && (value.kind === "launch" || value.kind === "agent") ? { diskId: value.disk_id, kind: value.kind } : undefined;
|
|
40
40
|
/** The replay a launch body names, as read back, or undefined. */
|
|
41
|
-
const readReplay = (value) =>
|
|
41
|
+
const readReplay = (value) => {
|
|
42
|
+
if (!(isObject(value) && typeof value.of === "string" && typeof value.workflow === "string" && typeof value.digest === "string"))
|
|
43
|
+
return undefined;
|
|
44
|
+
const deadline = typeof value.deadline_at === "string" ? Date.parse(value.deadline_at) : Number.NaN;
|
|
45
|
+
return { of: value.of, workflow: value.workflow, digest: value.digest, ...(typeof value.paid_by === "string" ? { paidBy: value.paid_by } : {}), ...(Number.isFinite(deadline) ? { deadlineAt: deadline } : {}) };
|
|
46
|
+
};
|
|
47
|
+
/** A replay or an audit as a launch body keeps it. */
|
|
48
|
+
const replayBody = (replay) => ({ of: replay.of, workflow: replay.workflow, digest: replay.digest, ...(replay.paidBy ? { paid_by: replay.paidBy } : {}), ...(replay.deadlineAt !== undefined ? { deadline_at: new Date(replay.deadlineAt).toISOString() } : {}) });
|
|
42
49
|
/** The trigger a launch body names, as read back: `{ id, firing_key }` and its firing's `attrs` (each a string) when it
|
|
43
50
|
* kept them, or null (triggerOf of the old serve.json). */
|
|
44
51
|
function readTrigger(value) {
|
|
@@ -98,8 +105,8 @@ export function launchBody(launch) {
|
|
|
98
105
|
...(launch.sourceProject ? { source_project: launch.sourceProject } : {}),
|
|
99
106
|
...(launch.learning ? { learning: { seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.workflows?.length ? { workflows: [...launch.learning.workflows] } : {}), ...(launch.learning.noWorkflows ? { noWorkflows: true } : {}), ...(launch.learning.model ? { model: launch.learning.model } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}), ...(launch.learning.use ? { use: true } : {}), ...(launch.learning.seededAt !== undefined ? { seededAt: launch.learning.seededAt } : {}) } } : {}),
|
|
100
107
|
...(launch.workflowFirst === false ? { workflow_first: false } : {}),
|
|
101
|
-
...(launch.replay ? { replay:
|
|
102
|
-
...(launch.audit ? { audit: { of: launch.audit.of, workflow: launch.audit.workflow, digest: launch.audit.digest } } : {}),
|
|
108
|
+
...(launch.replay ? { replay: replayBody(launch.replay) } : {}),
|
|
109
|
+
...(launch.audit ? { audit: replayBody({ of: launch.audit.of, workflow: launch.audit.workflow, digest: launch.audit.digest, ...(launch.audit.deadlineAt !== undefined ? { deadlineAt: launch.audit.deadlineAt } : {}) }) } : {}),
|
|
103
110
|
...(launch.trigger ? { trigger: launch.trigger } : {}),
|
|
104
111
|
...(launch.inputOrigin ? { input_origin: launch.inputOrigin } : {}),
|
|
105
112
|
...(launch.followUp ? { follow_up: true } : {}),
|
package/dist/run-view.js
CHANGED
|
@@ -234,7 +234,10 @@ export function answersOf(entries, { final } = {}) {
|
|
|
234
234
|
}
|
|
235
235
|
/** The run's active cap park, from its journal: the last agentrun.budget entry the cap wrote when it parked the run for
|
|
236
236
|
* room, unless an agentrun.raise after it cleared the pause (the run goes on at the raised cap then). A re-park writes a
|
|
237
|
-
* fresh budget entry, which a raise before it does not clear, so the last of the two in log order decides.
|
|
237
|
+
* fresh budget entry, which a raise before it does not clear, so the last of the two in log order decides. A raise entry
|
|
238
|
+
* clears the park it names (its `pause`, as the runner reads it: raiseStateOf), or any when it names none (one written
|
|
239
|
+
* before raises named their pause): a retry of an earlier raise names that raise's pause, and the park the run stands at
|
|
240
|
+
* since stays. */
|
|
238
241
|
function activeBudget(entries) {
|
|
239
242
|
return activePark(entries)?.mark;
|
|
240
243
|
}
|
|
@@ -244,8 +247,11 @@ function activePark(entries) {
|
|
|
244
247
|
for (const entry of entries) {
|
|
245
248
|
if (entry.kind === KINDS.budget)
|
|
246
249
|
park = { mark: dataOf(entry), id: String(entry.id) };
|
|
247
|
-
else if (entry.kind === KINDS.raise)
|
|
248
|
-
|
|
250
|
+
else if (entry.kind === KINDS.raise && park) {
|
|
251
|
+
const named = entry.data?.pause;
|
|
252
|
+
if (named === undefined || String(named) === park.id)
|
|
253
|
+
park = undefined;
|
|
254
|
+
}
|
|
249
255
|
}
|
|
250
256
|
return park;
|
|
251
257
|
}
|
package/dist/runnable.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// provider's key, a default model, a tier's model) saves as a warning. Either refuses a run, 409 agent_not_runnable.
|
|
5
5
|
import { WORKFLOW_ADAPTERS } from "./runner/workflow-adapters.js";
|
|
6
6
|
import { DECISION_ADAPTER, decisionModelsNamed, providerMissing, providersNamed } from "./decisions.js";
|
|
7
|
-
import {
|
|
7
|
+
import { adapterBinds } from "./tool-list.js";
|
|
8
8
|
import { sentence } from "./errors.js";
|
|
9
9
|
import { DEFAULT_HARNESS, harnessOffers } from "./harness.js";
|
|
10
10
|
import { harnessOf, onAdapter } from "./harness-table.js";
|
|
@@ -231,10 +231,10 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
|
|
|
231
231
|
// Its writes into work/ go by path from this machine, and a box's command could swap a link in on their way.
|
|
232
232
|
else if (toolOf(tool).runnerOnly && place?.mode === "sandbox")
|
|
233
233
|
out.push({ field: `definition.tools[${index}]`, reason: "not_an_option", message: `${tool} does not run in a sandbox place yet: it saves files into the run's work/ from this server, outside the box, and a command in the box could point those writes elsewhere on this server. Give it to an agent whose place is the runner.`, fix: `Remove "${tool}" from definition.tools.`, host: false, tool });
|
|
234
|
-
// Another harness gets the host tools
|
|
235
|
-
// any other tool this host binds (
|
|
236
|
-
// run, never runs without it.
|
|
237
|
-
else if (onAdapter(env, harness) && !
|
|
234
|
+
// Another harness gets the host tools (host-tools.ts: the file tools, ask_person, web_fetch and web_search) and the
|
|
235
|
+
// browser (tool-list.ts adapterBinds): any other tool this host binds (subagent, pdf_pages, llm) is pi's here and
|
|
236
|
+
// refuses the run, never runs without it.
|
|
237
|
+
else if (onAdapter(env, harness) && !adapterBinds(tool))
|
|
238
238
|
out.push({ field: `definition.tools[${index}]`, reason: NOT_SET_UP, message: `${tool} runs on pi here; on ${harness} it is not bound yet.`, host: true, tool });
|
|
239
239
|
else {
|
|
240
240
|
unset(`definition.tools[${index}]`, tool);
|
|
@@ -91,6 +91,8 @@ function cardOf(tool, shown, args) {
|
|
|
91
91
|
const COMMAND_REQUEST_PREFIX = commandRequest(0).replace(/0$/, "");
|
|
92
92
|
/** What a CLI's request held at a cut turn (TurnCut) is refused with: the turn ended at the person's question. */
|
|
93
93
|
const TURN_CUT_AT_QUESTION = "the turn ended at its question to the person";
|
|
94
|
+
/** What a learning child's request after its deadline (LoopDeps.pastDeadline) is refused with, once its cancel stopped it. */
|
|
95
|
+
const PAST_LEARNING_DEADLINE = "this learning run reached its deadline: nothing more is sent";
|
|
94
96
|
/** What a run that waits on no one (AdapterRunSpec.neverWaits) would have waited on, by its park's cause: its end says so. */
|
|
95
97
|
const WAITS_ON = {
|
|
96
98
|
approval: "a person's approval of a tool call",
|
|
@@ -359,8 +361,12 @@ async function openCliRecord(harness, journal, context, now, cwd, endsItsCalls =
|
|
|
359
361
|
let text = "";
|
|
360
362
|
/** A model message was written at a request's start (flushSaid) and no other flush has come since. */
|
|
361
363
|
let flushedAtRequest = false;
|
|
362
|
-
/** The end-of-run turn's answer while that turn runs (answering), else undefined
|
|
364
|
+
/** The end-of-run turn's answer while that turn runs (answering), else undefined: its last message, as pi's answer is,
|
|
365
|
+
* the text since the turn's last message boundary. */
|
|
363
366
|
let answer;
|
|
367
|
+
/** A message boundary (text_end, a call) came in the end-of-run turn: its next text starts the answer anew. A partial
|
|
368
|
+
* stream the CLI asked again for whole is never read with the whole answer after it. */
|
|
369
|
+
let answerCut = false;
|
|
364
370
|
// One write at a time, in the order they were asked for, a failed one never stopping the next.
|
|
365
371
|
let chain = Promise.resolve();
|
|
366
372
|
const inTurn = (work) => (chain = chain.then(work, work));
|
|
@@ -387,11 +393,18 @@ async function openCliRecord(harness, journal, context, now, cwd, endsItsCalls =
|
|
|
387
393
|
if (event.type === "text") {
|
|
388
394
|
if (answer === undefined)
|
|
389
395
|
text += event.delta;
|
|
390
|
-
else
|
|
396
|
+
else {
|
|
397
|
+
if (answerCut)
|
|
398
|
+
answer = "";
|
|
399
|
+
answerCut = false;
|
|
391
400
|
answer += event.delta;
|
|
401
|
+
}
|
|
392
402
|
}
|
|
393
|
-
else if (event.type === "tool_start" || event.type === "text_end")
|
|
403
|
+
else if (event.type === "tool_start" || event.type === "text_end") {
|
|
404
|
+
if (answer !== undefined)
|
|
405
|
+
answerCut = true;
|
|
394
406
|
void flushText().catch(() => undefined);
|
|
407
|
+
}
|
|
395
408
|
else if (event.type === "turn_end")
|
|
396
409
|
void flushText(event).catch(() => undefined);
|
|
397
410
|
else if (event.type === "notice") {
|
|
@@ -535,6 +548,7 @@ async function openCliRecord(harness, journal, context, now, cwd, endsItsCalls =
|
|
|
535
548
|
}),
|
|
536
549
|
answering: async (requestId, prompt, keep) => {
|
|
537
550
|
answer = "";
|
|
551
|
+
answerCut = false;
|
|
538
552
|
await inTurn(async () => {
|
|
539
553
|
if (askedAt.has(requestId))
|
|
540
554
|
return;
|
|
@@ -1736,6 +1750,14 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1736
1750
|
return { ...pending, refuse: text, figures };
|
|
1737
1751
|
};
|
|
1738
1752
|
const beforeRequest = async (request) => {
|
|
1753
|
+
// A learning child past its deadline (LoopDeps.pastDeadline) sends nothing more on its run's key: the request
|
|
1754
|
+
// waits here, unsent, for the cancel its runner hands the loop at that deadline, and leaves refused at that stop.
|
|
1755
|
+
if (deps.pastDeadline?.aborted) {
|
|
1756
|
+
const stop = AbortSignal.any([deps.signal, stopAbort.signal]);
|
|
1757
|
+
if (!stop.aborted)
|
|
1758
|
+
await new Promise((resolve) => stop.addEventListener("abort", () => resolve(), { once: true }));
|
|
1759
|
+
return { refuse: PAST_LEARNING_DEADLINE, forGood: true };
|
|
1760
|
+
}
|
|
1739
1761
|
// A run whose booked spend passed its cap sends nothing more: it ends in the cap's words (overCap), never paused,
|
|
1740
1762
|
// whatever else would pause it (a paid call's refusal, pendingPause). One a paid call stopped for good
|
|
1741
1763
|
// (paid-calls.ts stopRun) ends in that call's words, which say why, past its cap too.
|
|
@@ -2734,6 +2756,12 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2734
2756
|
}
|
|
2735
2757
|
const paused = raising.budget;
|
|
2736
2758
|
const resumes = raising.resumes;
|
|
2759
|
+
// Parking again from here (no raise of this claim resumed it, or no follow-up can be sent), decided on what the
|
|
2760
|
+
// claim read before its raise entry's commit: a raise row that reaches it from now on, that commit's wait
|
|
2761
|
+
// included, waits for the run's next claim (raise), never taken by a claim that is parking, which would leave the
|
|
2762
|
+
// run parked with nothing to wake it.
|
|
2763
|
+
if (paused && (!resumes || raising.capUsd === undefined || !spec.cap?.followUpOf))
|
|
2764
|
+
pausing = true;
|
|
2737
2765
|
await takeRaises();
|
|
2738
2766
|
if (paused) {
|
|
2739
2767
|
// No raise resumed it (each refused, or a retry of one before): its pause stands as it was, its budget entry
|
|
@@ -76,12 +76,15 @@ export interface ClaimComputer {
|
|
|
76
76
|
export type ComputerForClaim = typeof claimComputer;
|
|
77
77
|
/** The wires pi speaks on the runner: main's pi's (provider.ts), Anthropic's Messages and OpenAI's Responses. */
|
|
78
78
|
export declare const PI_WIRES: readonly Wire[];
|
|
79
|
+
/** The browser's catalog name (tools.ts TOOLS.browser). */
|
|
80
|
+
export declare const BROWSER_TOOL = "browser";
|
|
79
81
|
/** Whether the runner offers the browser at all: on pi's native route (PiAdapterOptions.extensions), where pi-browser's
|
|
80
|
-
* durable extension runs in the claim's Harness, its tools pi's own tool tasks (their memo, task and conversations)
|
|
82
|
+
* durable extension runs in the claim's Harness, its tools pi's own tool tasks (their memo, task and conversations); on
|
|
83
|
+
* another harness, its extension in the same Harness and its tools host tools (browserHostTools). */
|
|
81
84
|
export declare const BROWSER_ON_RUNNER = true;
|
|
82
85
|
/** Whether the runner installs the browser for a run whose revision grants `granted`, or whose computer is a browser
|
|
83
|
-
* (host.browserComputer), fail closed: only
|
|
84
|
-
* booking on its ToolHost (host.ledger.paid), so no browser call is held on this process's own spend. */
|
|
86
|
+
* (host.browserComputer), fail closed: only where the runner offers it (BROWSER_ON_RUNNER), and only with the run's
|
|
87
|
+
* ledger booking on its ToolHost (host.ledger.paid), so no browser call is held on this process's own spend. */
|
|
85
88
|
export declare const browserListed: (host: Pick<ToolHost, "ledger" | "browserComputer">, granted: readonly string[]) => boolean;
|
|
86
89
|
/** What the runner hands the spec builder, beside the claim and the loop's own Harness (the AdapterRun): the store (its
|
|
87
90
|
* agent and run reads, and the live-viewer seam the browser tool writes through), the data directory a Mode 1 run folder
|
|
@@ -425,6 +428,14 @@ export declare function claimLiveAt(deps: Pick<AdapterSpecDeps, "env" | "sealKey
|
|
|
425
428
|
* CLI spec share. Each runs under the adapter loop's one gate (spec.gate) on the claim's keys (host.env), and books its
|
|
426
429
|
* paid requests on the run's one ledger itself (bookedIn): they carry no settle of their own. */
|
|
427
430
|
export declare function webHostTools(host: ToolHost, granted: readonly string[], ctx: HostToolCtx): Promise<HostTool[]>;
|
|
431
|
+
/** The browser on a harness other than pi (the CLI spec): tools.ts's own binding on this run's ToolHost, as pi's native
|
|
432
|
+
* route binds it (its store, claim and seal key, its live viewers, its money on host.ledger, its computer the claim's),
|
|
433
|
+
* its durable extension installed in the run's registry (host.install), so its documents and its release and hand-over
|
|
434
|
+
* tasks are the run's Harness's, and its reconcile, release and drain on the host's lifecycle (the spec's `lifecycle`).
|
|
435
|
+
* Each of its registrations is a host tool (host-tools.ts hostToolOf, RUNS_ONCE: a call a crash cut off is answered
|
|
436
|
+
* interrupted, its session left to the next claim's reconcile), under the adapter loop's one gate (spec.gate), which
|
|
437
|
+
* holds each to the table's `browser` (tool-gate.ts BROWSER_REGISTRATIONS). None unless browserListed. */
|
|
438
|
+
export declare function browserHostTools(host: ToolHost, granted: readonly string[], plane: RunLaunch["plane"], ctx: HostToolCtx): Promise<HostTool[]>;
|
|
428
439
|
/** What a claim's MCP servers and calendar_events may reach on loopback (mcpForClaim's and buildToolHost's `loopback` and
|
|
429
440
|
* `own`): nothing unless mcpLoopback; else loopback, never at mcpOwn's ports nor mcpOwnOf's, read now. Read once per
|
|
430
441
|
* claim. */
|
|
@@ -29,7 +29,7 @@ import { deniedText, noApproverText, runGate } from "../tool-gate.js";
|
|
|
29
29
|
import { DECISION_PROVIDER_KEYS, loadToolSettings, recheckPlane, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
30
30
|
import { readApprovers } from "../server-approvers.js";
|
|
31
31
|
import { ASK_TOOL, askPerson, toolOf, webAnswerCut } from "../tools.js";
|
|
32
|
-
import { hostToolOf } from "../host-tools.js";
|
|
32
|
+
import { hostToolOf, RUNS_ONCE } from "../host-tools.js";
|
|
33
33
|
import { WEB_SEARCH_TOOL } from "../web-search.js";
|
|
34
34
|
import { environmentLine, runZone } from "../environment.js";
|
|
35
35
|
import { effortGuidance } from "../effort-guidance.js";
|
|
@@ -49,7 +49,8 @@ import { filesToCopy, placeRunInputs } from "../uploads.js";
|
|
|
49
49
|
import { handedSignInReadsBack, signInReads } from "../sign-ins-store.js";
|
|
50
50
|
import { UNREADABLE_SIGN_IN } from "../run-view.js";
|
|
51
51
|
import { durableWait } from "../workflow/pi-versions.js";
|
|
52
|
-
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, subagentTierKeys, tierModelKeys, underClaimed, withoutModelKeys } from "./claim-secrets.js";
|
|
52
|
+
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, keyedNow, hostDecisionKeys, learnedDecisionKeys, subagentTierKeys, tierModelKeys, underClaimed, withoutModelKeys } from "./claim-secrets.js";
|
|
53
|
+
import { atRunEnd } from "../learning-work.js";
|
|
53
54
|
import { compareEndOfRun, GRADER, withGrader } from "./compare-end.js";
|
|
54
55
|
import { agreeOnOf } from "../learning-setting.js";
|
|
55
56
|
import { catalogSessionNames, claimMetering, mcpWhereHeld } from "./mcp-run.js";
|
|
@@ -79,7 +80,7 @@ import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
|
|
|
79
80
|
import { heldSpecOf } from "./held-run.js";
|
|
80
81
|
import { loopComputerOf } from "./computer-channel.js";
|
|
81
82
|
import { githubAppAccess } from "./github-app.js";
|
|
82
|
-
import { prCheckoutForClaim } from "./pr-checkout.js";
|
|
83
|
+
import { checkoutWhereNoExec, prCheckoutForClaim } from "./pr-checkout.js";
|
|
83
84
|
import { holdStored, storeSecrets } from "./store-secrets.js";
|
|
84
85
|
import { bashPolicyOf } from "../bash-read-only.js";
|
|
85
86
|
import { monidForClaim, withMonid } from "./monid-run.js";
|
|
@@ -90,13 +91,14 @@ import { agentOfRun, routeTrace } from "../otel/genai.js";
|
|
|
90
91
|
/** The wires pi speaks on the runner: main's pi's (provider.ts), Anthropic's Messages and OpenAI's Responses. */
|
|
91
92
|
export const PI_WIRES = Object.freeze(["anthropic-messages", "openai-responses"]);
|
|
92
93
|
/** The browser's catalog name (tools.ts TOOLS.browser). */
|
|
93
|
-
const BROWSER_TOOL = "browser";
|
|
94
|
+
export const BROWSER_TOOL = "browser";
|
|
94
95
|
/** Whether the runner offers the browser at all: on pi's native route (PiAdapterOptions.extensions), where pi-browser's
|
|
95
|
-
* durable extension runs in the claim's Harness, its tools pi's own tool tasks (their memo, task and conversations)
|
|
96
|
+
* durable extension runs in the claim's Harness, its tools pi's own tool tasks (their memo, task and conversations); on
|
|
97
|
+
* another harness, its extension in the same Harness and its tools host tools (browserHostTools). */
|
|
96
98
|
export const BROWSER_ON_RUNNER = true;
|
|
97
99
|
/** Whether the runner installs the browser for a run whose revision grants `granted`, or whose computer is a browser
|
|
98
|
-
* (host.browserComputer), fail closed: only
|
|
99
|
-
* booking on its ToolHost (host.ledger.paid), so no browser call is held on this process's own spend. */
|
|
100
|
+
* (host.browserComputer), fail closed: only where the runner offers it (BROWSER_ON_RUNNER), and only with the run's
|
|
101
|
+
* ledger booking on its ToolHost (host.ledger.paid), so no browser call is held on this process's own spend. */
|
|
100
102
|
export const browserListed = (host, granted) => BROWSER_ON_RUNNER && host.ledger?.paid !== undefined && (granted.includes(BROWSER_TOOL) || host.browserComputer !== undefined);
|
|
101
103
|
/** A template eval case's files (EvalFakes.files) written into the run's work folder at its claim, after its inputs and
|
|
102
104
|
* before its computer and its first turn, so they reach a computer's /workspace as its uploads do. Each one the folder
|
|
@@ -436,8 +438,9 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
436
438
|
// The pull request's checkout, when the revision asks for one (pr-checkout.ts): the server's own fetch before the first
|
|
437
439
|
// turn, with the GitHub App's read-only token for that one repository (or none); the run is told what it holds, or why
|
|
438
440
|
// there is none. Held from the fetch's start, so the release (after the tools' end) removes it however the claim ends; a
|
|
439
|
-
// person's stop ends the fetch at once (run.stopped).
|
|
440
|
-
|
|
441
|
+
// person's stop ends the fetch at once (run.stopped). On an Archil region with no serverless exec (noExec) the disk runs
|
|
442
|
+
// no command: the checkout waits for the run's computer (below, checkoutWhereNoExec).
|
|
443
|
+
let checkout = body.checkout && noExec === undefined ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part }), body.checkout) : undefined;
|
|
441
444
|
holds.hold({ checkout });
|
|
442
445
|
// The run's skills and its learning seed, laid in its folder through the run's Workspace now, before its computer
|
|
443
446
|
// exists: on Archil the computer's mount of the folder takes the disk's write delegation, and from then on every write
|
|
@@ -516,6 +519,12 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
516
519
|
filedIn = tools.workspace;
|
|
517
520
|
let remoteProjectCapture = false;
|
|
518
521
|
holds.hold({ tools: { end: () => remoteProjectCapture ? Promise.resolve() : tools.end() } });
|
|
522
|
+
// On an Archil region with no serverless exec, the checkout now: in the computer that mounts the run's folder, through
|
|
523
|
+
// its own exec, writing through its mount; with none, the run is told why there is none (pr-checkout.ts).
|
|
524
|
+
if (body.checkout && noExec !== undefined) {
|
|
525
|
+
checkout = await checkoutWhereNoExec(deps, tools.shell === "computer" ? tools.workspace : undefined, noExec, launch, cut, claimSignal, (part) => holds.hold({ checkout: part }), body.checkout, (words) => run.phase?.(words));
|
|
526
|
+
holds.hold({ checkout });
|
|
527
|
+
}
|
|
519
528
|
// The run's model route: its model through routeOf (NEVER re-resolved — the launch's model, pinned at start), the catalog
|
|
520
529
|
// price with tiers for the cap, and the proxy's price (pi-ai calculateCost, tiered).
|
|
521
530
|
// pi speaks both of main's wires: an OpenAI-family model's route is OpenAI's Responses itself.
|
|
@@ -594,6 +603,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
594
603
|
...(route.price ? { price: route.price } : {}),
|
|
595
604
|
sessionsDir: join(harnesses, String(claim.epoch)),
|
|
596
605
|
...(route.fetch ? { fetch: route.fetch } : {}),
|
|
606
|
+
...(route.local ? { local: true } : {}),
|
|
597
607
|
redact: cut,
|
|
598
608
|
}, {
|
|
599
609
|
// Read when the session opens (pi.ts), so the browser's extension pushed by bindNonHandTools below is in it.
|
|
@@ -675,12 +685,13 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
675
685
|
// The audits that finished since are written first (runner/audit.ts settleAudits): a hold they make decides this claim.
|
|
676
686
|
const admitAuxiliary = runnerSeam() ? undefined : sourceAuxiliaryAdmitter(deps.store, { data: deps.data, sealKey: deps.sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } });
|
|
677
687
|
// None for a held run, so its claim reads no saved key for spend beside it (claimSpendOff).
|
|
678
|
-
|
|
688
|
+
// A claim on the run's own key runs its learning work on that key (keyed), its check at the run's end (atEnd).
|
|
689
|
+
const audits = heldRefusal === undefined ? { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, shown, sealKey: deps.sealKey, spendOff: await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey), keyed: keyedNow(runKey), atEnd: atRunEnd(log), admitAuxiliary } : undefined;
|
|
679
690
|
// Each step writes the store or reads another run (runner/learned-first.ts): in a run's own process its runner takes
|
|
680
691
|
// them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself. A held run its model kept from
|
|
681
692
|
// running takes none of them: it settles no audit and starts no replay run, starts on no workflow, and its tool runs
|
|
682
693
|
// none (so no learned tier is routed, below).
|
|
683
|
-
const learned = audits ? await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log, shown, spendOff: audits.spendOff, admitAuxiliary }, seedLaid?.workflows ?? []) : { choice: { reason: "held" }, workflows: [] };
|
|
694
|
+
const learned = audits ? await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log, shown, spendOff: audits.spendOff, keyed: audits.keyed, atEnd: audits.atEnd, admitAuxiliary }, seedLaid?.workflows ?? []) : { choice: { reason: "held" }, workflows: [] };
|
|
684
695
|
const firstChoice = learned.choice;
|
|
685
696
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
686
697
|
// answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
|
|
@@ -799,6 +810,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
|
|
|
799
810
|
tools: sessionTools,
|
|
800
811
|
context: "fresh",
|
|
801
812
|
...(thinking ? { thinking: thinking } : {}),
|
|
813
|
+
// The run's model's window, from its route's catalog entry: pi holds every tool result to its share (boundPiResult).
|
|
814
|
+
...(route.contextWindow ? { contextWindow: route.contextWindow } : {}),
|
|
802
815
|
};
|
|
803
816
|
// The person's first message: the start body's content, with the run's file manifest beside it (run-manifest.ts), read
|
|
804
817
|
// through the run's Workspace (Mode 2: its inputs/ on the disk, never a folder of this machine).
|
|
@@ -1171,6 +1184,30 @@ export async function webHostTools(host, granted, ctx) {
|
|
|
1171
1184
|
}
|
|
1172
1185
|
return tools;
|
|
1173
1186
|
}
|
|
1187
|
+
/** `host` for the browser's binding: its vendor the launch's plane (resolved when the run was created, runs-over-store.ts
|
|
1188
|
+
* planeFor) checked again against the keys this claim read from the store (recheckPlane, which keeps the plane's Jev
|
|
1189
|
+
* off), as both specs bind it. */
|
|
1190
|
+
function browserHostOf(host, plane) {
|
|
1191
|
+
const checked = plane ? recheckPlane(plane, host.env) : {};
|
|
1192
|
+
const env = { ...host.env };
|
|
1193
|
+
delete env[TOOL_PLANE_ENV];
|
|
1194
|
+
if (Object.keys(checked).length)
|
|
1195
|
+
env[TOOL_PLANE_ENV] = JSON.stringify(checked);
|
|
1196
|
+
return { ...host, env };
|
|
1197
|
+
}
|
|
1198
|
+
/** The browser on a harness other than pi (the CLI spec): tools.ts's own binding on this run's ToolHost, as pi's native
|
|
1199
|
+
* route binds it (its store, claim and seal key, its live viewers, its money on host.ledger, its computer the claim's),
|
|
1200
|
+
* its durable extension installed in the run's registry (host.install), so its documents and its release and hand-over
|
|
1201
|
+
* tasks are the run's Harness's, and its reconcile, release and drain on the host's lifecycle (the spec's `lifecycle`).
|
|
1202
|
+
* Each of its registrations is a host tool (host-tools.ts hostToolOf, RUNS_ONCE: a call a crash cut off is answered
|
|
1203
|
+
* interrupted, its session left to the next claim's reconcile), under the adapter loop's one gate (spec.gate), which
|
|
1204
|
+
* holds each to the table's `browser` (tool-gate.ts BROWSER_REGISTRATIONS). None unless browserListed. */
|
|
1205
|
+
export async function browserHostTools(host, granted, plane, ctx) {
|
|
1206
|
+
if (!browserListed(host, granted))
|
|
1207
|
+
return [];
|
|
1208
|
+
const binding = await toolOf(BROWSER_TOOL).bind(browserHostOf(host, plane));
|
|
1209
|
+
return binding.tools.flatMap((registration) => hostToolOf(BROWSER_TOOL, registration, ctx, RUNS_ONCE) ?? []);
|
|
1210
|
+
}
|
|
1174
1211
|
async function bindNonHandTools(host, kind, granted, run, context, results, root, plane, workflows, native, permissions, tiers, mcp, modelName, replay) {
|
|
1175
1212
|
// Fail closed (browserListed): the browser binds only on the native route (BROWSER_ON_RUNNER) and with the claim's
|
|
1176
1213
|
// one-ledger booking on its ToolHost (host.ledger.paid); otherwise its extension is not installed. learned_workflow
|
|
@@ -1193,14 +1230,8 @@ async function bindNonHandTools(host, kind, granted, run, context, results, root
|
|
|
1193
1230
|
// claim read from the store (recheckPlane, which keeps the plane's Jev off). Its durable extension goes to piAdapter
|
|
1194
1231
|
// (`native`), never wrapped as a HostTool and never installed here too (piAdapter installs it once); its lifecycle (the
|
|
1195
1232
|
// Config per conversation, reconcile, the release drain) through the host's hooks into the spec's lifecycle.
|
|
1196
|
-
if (browser)
|
|
1197
|
-
|
|
1198
|
-
const env = { ...host.env };
|
|
1199
|
-
delete env[TOOL_PLANE_ENV];
|
|
1200
|
-
if (Object.keys(checked).length)
|
|
1201
|
-
env[TOOL_PLANE_ENV] = JSON.stringify(checked);
|
|
1202
|
-
await toolOf(BROWSER_TOOL).bind({ ...host, env, install: (extension) => void native.push(extension) });
|
|
1203
|
-
}
|
|
1233
|
+
if (browser)
|
|
1234
|
+
await toolOf(BROWSER_TOOL).bind({ ...browserHostOf(host, plane), install: (extension) => void native.push(extension) });
|
|
1204
1235
|
// TODO (decisions, option (a)): a pi run's decision tools book on the run's ONE cap (runCap's run.decisions), which the
|
|
1205
1236
|
// adapter loop makes from its own sessions and hands the spec at open — the loop passes { decisions, models } the same way
|
|
1206
1237
|
// it passes spec.lifecycle. The decision providers come from the claim's secrets (claim-secrets.ts). Wired against that
|
|
@@ -23,6 +23,8 @@ export interface HarnessLaunch {
|
|
|
23
23
|
readonly sessionsDir: string;
|
|
24
24
|
/** The proxy's upstream fetch (a test's scripted origin). */
|
|
25
25
|
readonly fetch?: typeof fetch;
|
|
26
|
+
/** The model runs on this machine (the route's `local`: an Ollama model): a CLI waits longer on its silent stream. */
|
|
27
|
+
readonly local?: boolean;
|
|
26
28
|
/** The runner's one redactor (LoopDeps.redact), holding the keys the claim opens: pi's session proxy cuts a provider's
|
|
27
29
|
* error with it before pi has it. */
|
|
28
30
|
readonly redact: HeldRedact;
|
|
@@ -33,6 +33,9 @@ export const RUNNER_HARNESSES = {
|
|
|
33
33
|
provider: { origin: launch.provider.origin, credential: launch.provider.credential, ...(launch.provider.headers ? { headers: launch.provider.headers } : {}) },
|
|
34
34
|
...(launch.price ? { price: launch.price } : {}),
|
|
35
35
|
...(launch.fetch ? { fetch: launch.fetch } : {}),
|
|
36
|
+
// A local model says nothing while it loads, reads its prompt or thinks: the CLI waits it out. A paid route's hung
|
|
37
|
+
// stream keeps the CLI's own limit, so it holds the run's slot and its cap no longer than that.
|
|
38
|
+
...(launch.local ? { streamIdleMs: claude.LOCAL_STREAM_IDLE_MS } : {}),
|
|
36
39
|
sessionsDir: launch.sessionsDir,
|
|
37
40
|
...extra,
|
|
38
41
|
});
|