@parcha/agentrun-serve 0.1.0-beta.48 → 0.1.0-beta.50
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 +37 -0
- package/README.md +236 -26
- package/dist/agent-delete.d.ts +36 -12
- package/dist/agent-delete.js +213 -30
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +18 -5
- package/dist/agents.d.ts +8 -1
- package/dist/agents.js +14 -4
- package/dist/answer-json.d.ts +2 -2
- package/dist/answer-json.js +3 -4
- package/dist/api-only.d.ts +7 -10
- package/dist/api-only.js +9 -11
- package/dist/archil-routes.d.ts +1 -1
- package/dist/archil-routes.js +4 -3
- package/dist/browser-sessions.d.ts +56 -0
- package/dist/browser-sessions.js +117 -0
- package/dist/compute-cost.d.ts +101 -0
- package/dist/compute-cost.js +250 -0
- package/dist/computer-routes.d.ts +4 -15
- package/dist/computer-routes.js +6 -10
- package/dist/console/assets/index-D0mr9wfZ.css +1 -0
- package/dist/console/assets/index-D7G6o-1E.js +720 -0
- package/dist/console/index.html +2 -2
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +15 -5
- package/dist/eval-previous.d.ts +52 -0
- package/dist/eval-previous.js +164 -0
- package/dist/file-types.d.ts +2 -0
- package/dist/file-types.js +3 -1
- package/dist/harness.js +2 -1
- package/dist/import.js +4 -3
- package/dist/learn/check.d.ts +16 -4
- package/dist/learn/check.js +30 -26
- package/dist/learn/promote.d.ts +7 -1
- package/dist/learn/promote.js +47 -0
- package/dist/learn/repick.d.ts +43 -0
- package/dist/learn/repick.js +202 -0
- package/dist/learn/workflow-draft.d.ts +4 -0
- package/dist/learn/workflow-draft.js +10 -7
- package/dist/learned-workflow.d.ts +2 -0
- package/dist/learned-workflow.js +19 -2
- package/dist/learning-setting.d.ts +13 -0
- package/dist/learning-setting.js +23 -1
- package/dist/llms.txt +1 -1
- package/dist/openapi.js +180 -14
- package/dist/paid-calls.d.ts +17 -7
- package/dist/paid-calls.js +15 -9
- package/dist/run-launch.d.ts +2 -2
- package/dist/run-launch.js +2 -1
- package/dist/run-learning-served.d.ts +1 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-usage.d.ts +125 -0
- package/dist/run-usage.js +394 -0
- package/dist/runner/adapter-loop.d.ts +4 -0
- package/dist/runner/adapter-loop.js +66 -21
- package/dist/runner/adapter-run-spec.d.ts +8 -3
- package/dist/runner/adapter-run-spec.js +13 -6
- package/dist/runner/big-writes.d.ts +33 -0
- package/dist/runner/big-writes.js +105 -0
- package/dist/runner/cli-run-spec.js +14 -6
- package/dist/runner/conformance/harness.d.ts +2 -0
- package/dist/runner/conformance/harness.js +18 -4
- package/dist/runner/feedback-round.d.ts +29 -1
- package/dist/runner/feedback-round.js +54 -3
- package/dist/runner/held.d.ts +4 -1
- package/dist/runner/journal-kinds.d.ts +3 -1
- package/dist/runner/learning-end.js +54 -18
- package/dist/runner/loop-contract.d.ts +3 -0
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -0
- package/dist/runner/monid-run.js +2 -2
- package/dist/runner/promotion.js +8 -2
- package/dist/runner/reflect-hook.js +3 -2
- package/dist/runner/run-child-host.d.ts +15 -2
- package/dist/runner/run-child-host.js +24 -8
- package/dist/runner/run-child.js +3 -0
- package/dist/runner/save-slots.d.ts +9 -0
- package/dist/runner/save-slots.js +91 -0
- package/dist/runs-over-store.d.ts +3 -2
- package/dist/runs-over-store.js +9 -7
- package/dist/sdk/runs.d.ts +3 -4
- package/dist/sdk/runs.js +10 -7
- package/dist/sdk/runtimes.d.ts +19 -0
- package/dist/sdk/runtimes.js +23 -0
- package/dist/sdk/schema.d.ts +14 -8
- package/dist/sdk/schema.js +18 -6
- package/dist/server.d.ts +7 -3
- package/dist/server.js +223 -100
- package/dist/store/agent-body.d.ts +2 -3
- package/dist/store/agent-body.js +3 -2
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/open.d.ts +1 -1
- package/dist/store/open.js +1 -1
- package/dist/store/postgres/migrations/0021_purged.sql +13 -0
- package/dist/store/postgres/migrations/0022_computer_intervals.sql +27 -0
- package/dist/store/postgres/migrations/0023_computer_interval_resources.sql +14 -0
- package/dist/store/schema.d.ts +20 -1
- package/dist/store/schema.js +60 -5
- package/dist/store/sqlite/connection.d.ts +4 -1
- package/dist/store/sqlite/connection.js +5 -0
- package/dist/store/sqlite/run-patch.d.ts +8 -3
- package/dist/store/sqlite/run-patch.js +15 -7
- package/dist/store/sqlite/store.d.ts +2 -1
- package/dist/store/sqlite/store.js +279 -68
- package/dist/store/sqlite/worker.d.ts +9 -0
- package/dist/store/sqlite/worker.js +18 -1
- package/dist/store/store.d.ts +149 -9
- package/dist/store/store.js +63 -0
- package/dist/store-reads/analytics.js +2 -1
- package/dist/store-reads/cap.d.ts +17 -7
- package/dist/store-reads/cap.js +54 -4
- package/dist/store-reads/decisions.d.ts +21 -0
- package/dist/store-reads/decisions.js +22 -0
- package/dist/store-reads/journal.d.ts +8 -2
- package/dist/store-reads/journal.js +27 -8
- package/dist/store-reads/learning.d.ts +1 -1
- package/dist/store-reads/learning.js +5 -2
- package/dist/store-reads/runs.js +2 -0
- package/dist/store-reads/stats.js +4 -2
- package/dist/store-view.d.ts +12 -1
- package/dist/store-view.js +98 -38
- package/dist/template-eval.d.ts +15 -1
- package/dist/template-eval.js +92 -13
- package/dist/templates.d.ts +1 -1
- package/dist/templates.js +4 -3
- package/dist/timeline/labels.js +17 -0
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +6 -2
- package/dist/tools.js +22 -1
- package/dist/trigger-targets.d.ts +28 -9
- package/dist/trigger-targets.js +19 -16
- package/dist/triggers.d.ts +2 -1
- package/dist/triggers.js +5 -2
- package/dist/validate.d.ts +4 -2
- package/dist/validate.js +13 -3
- package/dist/viewer-credential.d.ts +3 -4
- package/dist/viewer-credential.js +6 -4
- package/dist/web-fake.d.ts +25 -0
- package/dist/web-fake.js +38 -1
- package/dist/web-save.d.ts +75 -0
- package/dist/web-save.js +235 -0
- package/dist/workspace/archil-claim.d.ts +5 -2
- package/dist/workspace/archil-claim.js +5 -2
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +19 -1
- package/dist/workspace/archil.d.ts +3 -0
- package/dist/workspace/archil.js +101 -16
- package/dist/workspace/computer-for-claim.d.ts +19 -1
- package/dist/workspace/computer-for-claim.js +88 -20
- package/dist/workspace/computer-intervals.d.ts +26 -0
- package/dist/workspace/computer-intervals.js +58 -0
- package/dist/workspace/computer-janitor.d.ts +7 -3
- package/dist/workspace/computer-janitor.js +14 -6
- package/dist/workspace/computer-kept.d.ts +7 -2
- package/dist/workspace/computer-kept.js +9 -2
- package/dist/workspace/pieced.d.ts +14 -0
- package/dist/workspace/pieced.js +23 -0
- package/dist/workspace/resolve-computer.d.ts +7 -4
- package/dist/workspace/resolve-computer.js +21 -32
- package/dist/workspace/run-disk.js +32 -12
- package/dist/workspace/run-end-computers.d.ts +1 -0
- package/dist/workspace/run-end-computers.js +4 -1
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +11 -6
- package/package.json +10 -10
- package/templates/README.md +36 -7
- package/dist/console/assets/index-CTGegcKt.css +0 -1
- package/dist/console/assets/index-D1Se6mgG.js +0 -715
package/dist/openapi.js
CHANGED
|
@@ -22,7 +22,7 @@ import { CALL_MS, PROTOCOL_METHODS } from "./computer-channel.js";
|
|
|
22
22
|
import { LAUNCH_LOST, SETUP_LOST } from "./files.js";
|
|
23
23
|
import { HARNESS_ID_PATTERN, HARNESSES } from "./harness.js";
|
|
24
24
|
import { LEARNING_LABEL, LEARNING_MODES, LEARNING_REASONS, LEARNING_STATES, RUN_LEARNING_USE } from "./learning.js";
|
|
25
|
-
import { AUDIT_DEFAULTS, AUDIT_MAX } from "./learning-setting.js";
|
|
25
|
+
import { AUDIT_DEFAULTS, AUDIT_MAX, REPICK_MAX_CHARS_DEFAULT, REPICK_MAX_CHARS_MAX } from "./learning-setting.js";
|
|
26
26
|
import { AFTER_STATES, CHEAPER_AFTER_RUNS, COST_CSV_COLUMNS, COST_WINDOW, COST_RUNS_DEFAULT, COST_RUNS_MAX, RUN_PATHS } from "./learning-cost.js";
|
|
27
27
|
import { FEEDBACK_ROUNDS, FEEDBACK_STATUSES } from "./runner/feedback-round.js";
|
|
28
28
|
import { COMPILE_AFTER_MAX } from "./learning-setting.js";
|
|
@@ -225,6 +225,98 @@ const RUN_GRAPH = {
|
|
|
225
225
|
},
|
|
226
226
|
},
|
|
227
227
|
};
|
|
228
|
+
/** GET /runs/{run_id}/usage's answer (run-usage.ts): one run's cost by line. Its line is not the contract's UsageLine
|
|
229
|
+
* (GET /usage's, a sum over runs by group). */
|
|
230
|
+
const COST_WORDS = {
|
|
231
|
+
so_far_usd: { type: "number", minimum: 0, description: "Beside a null `usd`, or a bound: what is known of it, the charges' own figures alone." },
|
|
232
|
+
unpriced: { type: "integer", minimum: 0, description: "Beside `so_far_usd`: how many of its charges have no known figure, or count at their hold." },
|
|
233
|
+
upper_bound: { const: true, description: "`usd` counts a request a crash or a stop cut at the hold its cap kept for it: the most it can have cost." },
|
|
234
|
+
};
|
|
235
|
+
const RUN_USAGE_LINE = {
|
|
236
|
+
type: "object", additionalProperties: false, required: ["meter", "model", "provider", "charged_by", "quantity", "unit", "basis", "usd"],
|
|
237
|
+
properties: {
|
|
238
|
+
meter: { enum: ["tokens", "tools", "browser_time", "compute_time"], description: "`tokens`: model requests, by model. `tools`: paid tool calls, by who charged for them; a workflow decision Parallel answered on its own API (this server's PARALLEL_API_KEY) is one, on the `parallel` line, never on `tokens`. `browser_time`: browser session time, by browser provider. `compute_time`: the time of the computers the run made, by provider and resource (`resource`, a GPU's `gpu_type`), priced by the operator's per-resource settings; sum a provider's lines for its compute figure.", "x-agentrun-serve": "runusage/5" },
|
|
239
|
+
model: { type: ["string", "null"], description: "On `tokens`: the model the requests were sent on, as the run's booking names it (a workflow decision's model too, but for a decision Parallel charged, which is on the `parallel` `tools` line). One line per model and route: the same model reached two ways is two lines. Null on the other meters, and when the record names none." },
|
|
240
|
+
provider: { type: ["string", "null"], description: "On `tokens`: the provider the requests went to, named only when this server sent them there itself (the run's own model on a provider's key). Null behind a model gateway, whose upstream this server does not know, and for a model it did not route (a workflow decision's). On `tools`: the vendor that charged for the calls, the same name as `charged_by` (the vendor that charges for a call is its provider). On `browser_time`: the browser provider. On `compute_time`: the computer provider, as this server's registry names it. Null where the record names none." },
|
|
241
|
+
charged_by: { type: ["string", "null"], description: "On `tools`: who charged for the calls, whose invoice they land on (`monid`, an MCP server's name, `parallel`). On `compute_time`: the computer provider, the same name as `provider`. Null on the other meters, and when the record names none." },
|
|
242
|
+
quantity: { type: ["number", "null"], minimum: 0, description: "In `unit`, as measured: never rounded to a billing increment, never topped up to a minimum. On `tokens`, the requests' input, cache read, cache write and output tokens as each reported them (a workflow decision's as its receipt does; a request that reported none is in `unmetered_requests`, in no token); on `tools`, the charges booked, one per paid call (a decision Parallel charged is one); on `browser_time`, the seconds this server's clock charged the provider's sessions for, its minimum per session included as the browser charged it; on `compute_time`, every second of every such computer of the run's times its figure (vCPUs, GiB of memory, GPUs, or GB of disk over a 730-hour month), a computer still open counted up to `measured_to`. Null when nothing measured it, or when a computer's figure is unknown (its provider said none and its create asked none)." },
|
|
243
|
+
unit: { enum: ["token", "call", "second", "vcpu_second", "gib_second", "gpu_second", "gb_month"] },
|
|
244
|
+
basis: { enum: ["reported", "estimate", "unpriced"], description: "How `usd` was reached. On `tokens`, as the run's `cost.basis` is, over the line's requests alone: `reported` when every request priced had its gateway's or provider's own figure, `estimate` when any was priced from a price table, `unpriced` when none was priced. On `tools`, `reported` when every charge with a figure is the provider's own (monid's answer says what it charged), `estimate` when any is a price this server holds (an MCP tool's saved price, Parallel's, a Parallel decision's list price), `unpriced` when none has a figure. On `browser_time`, `estimate` when any charge has a figure (the provider's price per hour on this server's clock, never its invoice), else `unpriced`. On `compute_time`, `estimate` when the run's ledger booked any of it at the operator's price (or its provider bills nothing, at $0), else `unpriced` (no price set for the resource, or its figure unknown): its time ran outside the run's cap, and `usd` is null." },
|
|
245
|
+
usd: { type: ["number", "null"], minimum: 0, description: "The line's cost on this server, as booked, joined by the rule `cost.usd` is (float noise rounded off at 1e-12). Null when a charge of it is unknown: never $0 for unknown." },
|
|
246
|
+
...COST_WORDS,
|
|
247
|
+
requests: { type: "integer", minimum: 0, description: "On `tokens`: the model requests booked." },
|
|
248
|
+
tokens: closed({ input: { type: "integer", minimum: 0, description: "Input not read from cache." }, output: { type: "integer", minimum: 0 }, cache_read: { type: "integer", minimum: 0 }, cache_write: { type: "integer", minimum: 0 } }, "On `tokens`: `quantity` by kind."),
|
|
249
|
+
unmetered_requests: { type: "integer", minimum: 0, description: "On `tokens`: requests that reported no tokens (booked with no usage, or sent and never answered), in no token count." },
|
|
250
|
+
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." },
|
|
251
|
+
resource: { enum: ["vcpu", "memory", "gpu", "disk"], description: "On `compute_time`: the resource the line counts." },
|
|
252
|
+
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." },
|
|
253
|
+
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." },
|
|
254
|
+
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`." },
|
|
255
|
+
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." },
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
/** One browser session on GET /runs/{run_id}/usage (browser-sessions.ts). */
|
|
259
|
+
const BROWSER_SESSION = {
|
|
260
|
+
type: "object", additionalProperties: false,
|
|
261
|
+
required: ["provider", "tag", "provider_session_id", "started_at", "ended_at", "release_reason", "charged_seconds", "provider_record", "provider_record_status"],
|
|
262
|
+
properties: {
|
|
263
|
+
provider: { type: "string", description: "The browser provider, as the `browser_time` line's `provider` names it." },
|
|
264
|
+
tag: { type: "string", description: "The run's own name for the session, the same on every read." },
|
|
265
|
+
provider_session_id: { type: ["string", "null"], description: "The provider's id for the session, by which its own records and bill find it. Null when no session was made (its create failed) or its end is not recorded." },
|
|
266
|
+
started_at: { type: ["string", "null"], format: "date-time", description: "When this server began opening the session. Null while its end is not recorded." },
|
|
267
|
+
ended_at: { type: ["string", "null"], format: "date-time", description: "When this server let the session go. Null when its end is not recorded (a run whose process was lost before the release was told): unknown, never zero." },
|
|
268
|
+
release_reason: { type: ["string", "null"], description: "Why the session ended, in the browser's words: `tool` (the agent closed it), `idle`, `relaunch`, `close` (its run let it go), `ended` (the provider ended it), `lost`, `create_failed`." },
|
|
269
|
+
charged_seconds: { type: ["number", "null"], minimum: 0, description: "The seconds of the session's time this server charged, on its own clock: what the `browser_time` line sums, the provider's minimum per session included where the browser charged one at the release. How long the session ran is `ended_at` less `started_at`. Null when none was charged (a free provider's, or no charge recorded)." },
|
|
270
|
+
provider_record: {
|
|
271
|
+
type: ["object", "null"], additionalProperties: false, required: ["started_at", "ended_at", "proxy_bytes"],
|
|
272
|
+
description: "The provider's own record of the session, read once when it was let go, for matching it to the provider's invoice. Null unless `provider_record_status` is `read`. A field is null where the provider's record does not hold it.",
|
|
273
|
+
properties: {
|
|
274
|
+
started_at: { type: ["string", "null"], format: "date-time" },
|
|
275
|
+
ended_at: { type: ["string", "null"], format: "date-time", description: "Null where the provider had not ended it when read." },
|
|
276
|
+
proxy_bytes: { type: ["integer", "null"], minimum: 0, description: "The bytes the session moved through the provider's proxy, as the provider counts them." },
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
provider_record_status: { enum: ["read", "not_offered", "not_found", "failed", "no_session", null], description: "What came of reading the provider's record: `read`; `not_offered`, the provider keeps none this server reads; `not_found`, the provider did not know the session; `failed`, the read failed or timed out; `no_session`, none was made. Null while the session's end is not recorded." },
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
/** One computer a run made on GET /runs/{run_id}/usage (run-usage.ts computerIntervalsOf, store computer_intervals). */
|
|
283
|
+
const COMPUTER_INTERVAL = {
|
|
284
|
+
type: "object", additionalProperties: false,
|
|
285
|
+
required: ["provider", "provider_id", "kind", "gpu", "cpus", "memory_mb", "disk_gb", "started_at", "ended_at", "kept", "booked_seconds"],
|
|
286
|
+
properties: {
|
|
287
|
+
provider: { type: "string", description: "The computer provider, as this server's registry names it (the agent's computer setting's `provider`: `docker`, `e2b`, `daytona`, ...)." },
|
|
288
|
+
provider_id: { type: "string", description: "The provider's own id for the computer, by which its console, its API and its invoice find it." },
|
|
289
|
+
kind: { type: ["string", "null"], description: "`sandbox`, `desktop` or `phone`. Null when not known." },
|
|
290
|
+
gpu: {
|
|
291
|
+
type: ["object", "null"], additionalProperties: false, required: ["type", "count"],
|
|
292
|
+
description: "The computer's GPUs: its provider's own figure where its answer gave one, else what its create asked for. Null when neither says it has any.",
|
|
293
|
+
properties: { type: { type: ["string", "null"] }, count: { type: ["integer", "null"], minimum: 0 } },
|
|
294
|
+
},
|
|
295
|
+
cpus: { type: ["number", "null"], minimum: 0, description: "The computer's vCPUs: its provider's own figure where its answer gave one (Daytona, E2B, Fly), else what its create asked for. Null when neither says: none is guessed." },
|
|
296
|
+
memory_mb: { type: ["integer", "null"], minimum: 0, description: "The computer's memory, in MB: its provider's own figure where its answer gave one, else what its create asked for. Null when neither says." },
|
|
297
|
+
disk_gb: { type: ["number", "null"], minimum: 0, description: "The computer's disk, in GB, where its provider's answer said it (Daytona). Null else.", "x-agentrun-serve": "runusage/4" },
|
|
298
|
+
started_at: { type: "string", format: "date-time", description: "When the provider's create answered with the computer, on this server's clock." },
|
|
299
|
+
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." },
|
|
300
|
+
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)." },
|
|
301
|
+
booked_seconds: { type: "number", minimum: 0, description: "How much of the computer's time a claim of the run held and booked on the run's ledger. The rest of its life is time no claim held (`unheld_quantity` on its `compute_time` lines). 0 for one whose provider has no price set, or that bills nothing.", "x-agentrun-serve": "runusage/4" },
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
const RUN_USAGE = {
|
|
305
|
+
type: "object", additionalProperties: false, required: ["run_id", "ended_at", "currency", "total", "lines", "browser_sessions", "computer_intervals", "reason"],
|
|
306
|
+
properties: {
|
|
307
|
+
run_id: ref("schemas/Id"),
|
|
308
|
+
ended_at: { type: ["string", "null"], format: "date-time", description: "When the run ended: the moment the lines cover. Null while it is at work. The lines change only while the run works, and a follow-up can open an ended run again (a trigger's often does); its next end is a later one. Keep `ended_at` beside the lines: a later read with another `ended_at`, or null, means the run moved since. `run.ended` fires at each end." },
|
|
309
|
+
currency: { const: "USD" },
|
|
310
|
+
total: {
|
|
311
|
+
type: ["object", "null"], additionalProperties: false, required: ["usd"], description: "The run's cost, joined from its lines. Null with no lines.",
|
|
312
|
+
properties: { usd: { type: ["number", "null"], minimum: 0, description: "The run's booking joined by the rule `cost.usd` is: the run's `cost.usd` on GET /runs/{run_id}, always. Null when a charge of it is unknown. A `compute_time` line that is `unpriced`, and any line's `unheld_quantity`, ran outside the run's booking and are not in it." }, ...COST_WORDS },
|
|
313
|
+
},
|
|
314
|
+
lines: { type: ["array", "null"], items: RUN_USAGE_LINE, description: "`tokens` lines first, then `tools`, then `browser_time`, then `compute_time`, each by its model, charger or provider (`compute_time` then by resource). A meter the run used nothing of has no line. Null when the server can't split the run (`reason`)." },
|
|
315
|
+
browser_sessions: { type: ["array", "null"], items: BROWSER_SESSION, description: "One record per browser session the run opened, in the order it opened them, for matching `browser_time` to the provider's own records and invoice by its session id. Empty for a run that opened none. Null exactly when `lines` is. Its words are cut of this server's secrets and the run's sign-ins, as the lines' names are.", "x-agentrun-serve": "runusage/2" },
|
|
316
|
+
computer_intervals: { type: ["array", "null"], items: COMPUTER_INTERVAL, description: "One record per computer the run made through its provider (a sandbox, a desktop, a phone), by when each was made: how long each lived for the run, one left running after it (`ended_at` null), and the provider's own id to match its invoice by. Not the agent's own persistent computer, a paired computer, or a browser's sessions (those are `browser_sessions`). Their time is on the `compute_time` lines. Empty for a run that made none (or one made before this server kept them). Null exactly when `lines` is. Its words are cut of this server's secrets and the run's sign-ins, as the lines' names are.", "x-agentrun-serve": "runusage/3" },
|
|
317
|
+
reason: { enum: ["running", "not_booked", "reopened", null], description: "Why `lines` is null: `running`, the run is at work and its booking still moves; `not_booked`, its figure is not its booking's (an imported run's, a native or SDK run's harness figure, a CLI run whose model requests went past its model proxy); `reopened`, a learning run a follow-up opened again, whose `cost.usd` is its first round's and whose booking can't be split by round. Null with lines." },
|
|
318
|
+
},
|
|
319
|
+
};
|
|
228
320
|
/** GET /runs/{run_id}/trace's answer (run-trace.ts). */
|
|
229
321
|
const RUN_TRACE = {
|
|
230
322
|
type: "object", additionalProperties: false, required: ["run_id", "model_requests", "spans", "dropped"],
|
|
@@ -859,7 +951,7 @@ const COMPUTER_PROVIDER = closedWith({
|
|
|
859
951
|
required: { type: "array", items: { type: "string" }, description: "The names of the secrets the provider needs; any other may stay unset." },
|
|
860
952
|
ready: { type: "boolean", description: "Whether a run could have its computer of this kind here now: it fits this server's folder mode and every required key is saved." },
|
|
861
953
|
runs_refused: PROVIDER_RUNS_REFUSED,
|
|
862
|
-
folder: { enum: ["bind", "archil", "sync", null], description: "The kind of the run's folder a run of an agent with this computer holds on this server now, by the rule a run's claim picks it by (this server's folder mode, and the provider's keys and image as this server has them)
|
|
954
|
+
folder: { enum: ["bind", "archil", "sync", null], description: "The kind of the run's folder a run of an agent with this computer holds on this server now, by the rule a run's claim picks it by (this server's folder mode, and the provider's keys and image as this server has them). `bind`: a folder of this machine (Mode 1). `archil`: the owner's Archil disk, where the provider takes an Archil mount, has Archil's image and does not dial this server. `sync`: a synced folder the runner keeps, for any other computer that takes a folder in Mode 2. Null: none. For a computer with no GPUs: `gpu.mounts` says which kinds its GPU computers take. A kind alone, never a key, an image or an address." },
|
|
863
955
|
shell: CHOICE_SHELL,
|
|
864
956
|
host_tools: CHOICE_HOST_TOOLS,
|
|
865
957
|
}, {
|
|
@@ -1254,6 +1346,7 @@ const TEMPLATE_APPLIED = closedWith({
|
|
|
1254
1346
|
template: { type: "string" },
|
|
1255
1347
|
version: { type: "string" },
|
|
1256
1348
|
agent_id: { type: "string", description: "The agent made, or the one updated (GET /agents/{agent_id})." },
|
|
1349
|
+
revision_version: { type: "integer", minimum: 1, description: "The number of the agent's revision this apply wrote, its current one now (its `definition.version`): 1 for an agent it made; on an update with agent_id, the new revision's." },
|
|
1257
1350
|
servers: { type: "object", additionalProperties: { type: ["string", "null"] }, description: "The saved MCP server each of the package's toolkits runs on, by toolkit; null: none here matches it (said under `mcp.<toolkit>`)." },
|
|
1258
1351
|
trigger_ids: { type: "array", items: { type: "string" }, description: "Its triggers, in the package's order (GET /triggers/{trigger_id})." },
|
|
1259
1352
|
warnings: { type: "array", items: ref("schemas/InputIssue"), description: "What this host still lacks for the agent to run, as POST /agents answers it; a webhook trigger the apply made adds a warning pointing to the console for its signing secret, never the secret itself (the first answer to the owner's signed-in session shows it once, under `webhook_secrets`)." },
|
|
@@ -1531,7 +1624,7 @@ const LEARNING_EXTENSIONS = {
|
|
|
1531
1624
|
"/runs/{run_id}/grade": {
|
|
1532
1625
|
put: {
|
|
1533
1626
|
operationId: "gradeRun", tags: ["runs"], summary: "Grade an ended run's answer: right or wrong, and the fields a right answer holds",
|
|
1534
|
-
description: `A person's feedback or an eval's label on a run that ended, kept for its agent (one grade a run: a later one replaces it; the newest ${GRADES_KEPT} are kept). Promotion reads none: a revision's check is scored against the agent's own recorded answers. A replay run is never graded. The run's path never changes on a grade: a grade of a run its learned workflow answered alone, right or wrong, is kept and nothing more ($0); a run the agent finished, graded with a \`label\`, opens again on a look-back on it. That round asks the agent no turn of the job's, only its end-of-run turn, and its spend is the run's learning (\`feedback\`).`,
|
|
1627
|
+
description: `A person's feedback or an eval's label on a run that ended, kept for its agent (one grade a run: a later one replaces it; the newest ${GRADES_KEPT} are kept). Promotion reads none: a revision's check is scored against the agent's own recorded answers. A replay run is never graded. The run's path never changes on a grade: a grade of a run its learned workflow answered alone, right or wrong, is kept and nothing more ($0); a run the agent finished, graded with a \`label\`, opens again on a look-back on it. That round asks the agent no turn of the job's, only its end-of-run turn, and its spend is the run's learning (\`feedback\`). A run that reads ended while it still learns from that end (its \`learning.state\` \`reflecting\`: its own look-back, or a grade's round) is \`409 run_learning\`, nothing kept: grade it once \`learning.state\` moves on.`,
|
|
1535
1628
|
parameters: [ref("parameters/RunId")],
|
|
1536
1629
|
requestBody: { required: true, content: { "application/json": { schema: { type: "object", additionalProperties: false, required: ["correct"], properties: { correct: { type: "boolean" }, expected: { type: "object", description: "The fields a right answer's JSON holds." }, source: { enum: [...GRADE_SOURCES], default: "feedback" }, label: { type: "string", maxLength: LABEL_MAX, description: "The grade's words (a teacher's label, a reviewer's note): what the run's look-back reads." } } } } } },
|
|
1537
1630
|
responses: { "200": json(GRADE, "The run's grade."), ...errors(400, 401, 404, 409, 429, 500) },
|
|
@@ -1595,7 +1688,7 @@ const LEARNING_EXTENSIONS = {
|
|
|
1595
1688
|
{ name: "limit", in: "query", required: false, description: `The latest runs to answer, each keeping its number. At most ${COST_RUNS_MAX}.`, schema: { type: "integer", minimum: 1, maximum: COST_RUNS_MAX, default: COST_RUNS_DEFAULT } },
|
|
1596
1689
|
{ name: "format", in: "query", required: false, description: "`csv`: the runs as CSV, columns " + COST_CSV_COLUMNS.join(", ") + ".", schema: { enum: ["json", "csv"], default: "json" } },
|
|
1597
1690
|
],
|
|
1598
|
-
responses: { "200": { description: "The agent's cost per run.", content: { "application/json": { schema: LEARNING_COST }, "text/csv": { schema: { type: "string" } } } }, ...errors(400, 401, 404, 429, 500) },
|
|
1691
|
+
responses: { "200": { description: "The agent's cost per run.", content: { "application/json": { schema: LEARNING_COST }, "text/csv": { schema: { type: "string" } } } }, ...errors(400, 401, 403, 404, 429, 500) },
|
|
1599
1692
|
"x-agentrun-serve": "learningcost/1",
|
|
1600
1693
|
},
|
|
1601
1694
|
},
|
|
@@ -1768,10 +1861,11 @@ const FILE_LIST = { type: "object", additionalProperties: false, required: ["fil
|
|
|
1768
1861
|
const EXTENSIONS = {
|
|
1769
1862
|
"/agents/{agent_id}": {
|
|
1770
1863
|
delete: {
|
|
1771
|
-
operationId: "deleteAgent", tags: ["agents"], summary: "Delete an agent another system owns",
|
|
1772
|
-
description: "
|
|
1864
|
+
operationId: "deleteAgent", tags: ["agents"], summary: "Delete an agent another system owns, or purge an archived agent made here",
|
|
1865
|
+
description: "An agent made here, once archived (`POST /agents/{agent_id}/archive`), is purged by the rule `DELETE /runs/{run_id}` purges a run by: its revisions' content (instructions, skills, notes), its name and description, its learning, its triggers, its saved sign-ins, its own computer, disk and folders go, and each of its runs is purged (a tombstone, its cost kept). The agent's row stays as its tombstone: every route of it answers `410 purged` with `details` {agent_id, archived_at, purged_at}, and no list shows it. What its runs cost stays in `/usage` and `/stats`. `204` when it is purged; a second `DELETE` is `204` too. An agent made here that is not archived is `409 agent_not_archived`, nothing purged; `409 run_not_final` while a run of it is live (`details.runs`), nothing purged; `503 unavailable` as below, the next `DELETE` finishing it. Purging one agent touches no other. Deleting or purging takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token: any other console session is `403 forbidden`.\n\n" +
|
|
1866
|
+
"An agent made by an inline run (`POST /runs` with `external`) is deleted whole, archived or not: its runs and everything kept of them (journals, launch records, messages, files), its triggers, its learning, its saved sign-ins, its own computer and disk, its revisions and the agent. A run whose launch named an Archil disk (`archil_disk`, the caller's) has its own folder there deleted; the disk and everything else on it are kept, and a disk Archil says is gone has nothing left to delete. Shared things (MCP servers, keys, computers) are kept. In order: the agent refuses new runs (a mark in the store that outlives a restart: a run, an inline run, a trigger's firing, an SDK run or a message that would open one of its runs again is `409 agent_not_runnable`, as is a new trigger of it, off too, a trigger moved to it or turned on, and a write to its home or learning), and its runs still going are cancelled and waited for; then its learning (its learning folder, and its promotions and grades); then the rest. `204` when it is gone; a second `DELETE` is `404`. `409 runs_in_flight` (a run did not end in time, or only its application ends it) and `409 learning_busy` (learning work in flight; each names what in `details.runs`) leave the agent refusing runs, as does `503 unavailable` while something it owns elsewhere is not deleted there yet: a trigger's registration upstream (Composio), a saved sign-in at its vendor, its own computer at its provider, its Archil disk (Archil failing or not reached, a run of another agent on it, or Archil off on this server), or a run's folder on a disk its launch named (Archil failing, a computer still holding the folder, or Archil off), or a trigger that reached the agent after its triggers were removed. Each is deleted there before the record here that names it, so none is left behind: send the `DELETE` again, which also finishes a delete that stopped part way.",
|
|
1773
1867
|
parameters: [AGENT_ID],
|
|
1774
|
-
responses: { "204": { description: "Deleted." }, ...errors(401, 404, 409, 429, 500, 503) },
|
|
1868
|
+
responses: { "204": { description: "Deleted, or purged." }, ...errors(401, 403, 404, 409, 429, 500, 503) },
|
|
1775
1869
|
"x-agentrun-serve": "agentdelete/1",
|
|
1776
1870
|
},
|
|
1777
1871
|
},
|
|
@@ -1922,6 +2016,15 @@ const EXTENSIONS = {
|
|
|
1922
2016
|
responses: { "200": json(RUN_TRACE, "The run's spans as they stand."), ...errors(401, 403, 404, 429, 500) },
|
|
1923
2017
|
},
|
|
1924
2018
|
},
|
|
2019
|
+
"/runs/{run_id}/usage": {
|
|
2020
|
+
get: {
|
|
2021
|
+
operationId: "getRunUsage", tags: ["runs"], summary: "What a run cost, by model, by who charged for its tools, and by browser provider",
|
|
2022
|
+
description: "One run's cost, line by line: its model requests by model (and the provider they went to, where this server sent them itself), its paid tool calls by who charged for them, and its browser time by provider. Each line has its quantity as measured, its dollars as the run's booking holds them, and how those were reached (`basis`). This server prices nothing here: the lines are the charges `cost.usd` already joins, so they add up to the run's `cost.usd` (`total`), and a charge no one knows is null, never $0. It reads the same for every kind of run that books its cost: an agentic run on any harness that sends its model requests through this server, and a workflow run with its decisions. Learning's spend for the run is not here: its end-of-run learning turn is this server's work for the agent, which `cost.usd` leaves out too; it is on the run read's `learning_usd`. While the run works, and for a run the server cannot split, `lines` is null and `reason` says why. A name on a line (a model, a provider, a charger) is cut of this server's secrets and the sign-ins the run was handed, as the run's trace is; 403 `forbidden` while this server can't read the browser sign-in the run was handed, as its trace answers.",
|
|
2023
|
+
parameters: [ref("parameters/RunId")],
|
|
2024
|
+
responses: { "200": json(RUN_USAGE, "The run's usage lines, or why it has none."), ...errors(401, 403, 404, 429, 500) },
|
|
2025
|
+
"x-agentrun-serve": "runusage/1",
|
|
2026
|
+
},
|
|
2027
|
+
},
|
|
1925
2028
|
"/runs/{run_id}/browser": {
|
|
1926
2029
|
get: {
|
|
1927
2030
|
operationId: "getRunBrowser", tags: ["runs"], summary: "Watch the run's browser live and take it over: its viewer link, for the owner",
|
|
@@ -2045,6 +2148,13 @@ const EXTENSIONS = {
|
|
|
2045
2148
|
},
|
|
2046
2149
|
},
|
|
2047
2150
|
"/runs/{run_id}": {
|
|
2151
|
+
delete: {
|
|
2152
|
+
operationId: "deleteRun", tags: ["runs"], summary: "Purge a run's content and keep its cost",
|
|
2153
|
+
description: "Purges a run that is not live: what it was given and what it did go, what it cost stays. Gone: its launch record (its input and prompt), its journal and timeline, its messages and commands, its outputs and files, the answers kept under its idempotency keys, its folders (on this machine, and its own folder on an Archil disk, its agent's or one its launch named; the disk and everything else on it are kept), its settings, the grades its agent keeps of it, and its kept learning's content (its learning's end, merged or dropped, stays, as `/stats` counts it). Its row stays as its tombstone: every route of it answers `410 purged` with `details` {run_id, agent_id, state, started_at, ended_at, cost_usd, cost_upper_bound, tools_usd, purged_at}, and no run list shows it. `/usage`, `/stats` and the spend a cap reads sum it as before: no total moves. The runs made from it are purged with it, each the same way: its audit's shadow run, the replay runs of its input and a learning run its kept learning names. Once it is purged, no replay or shadow run of it is started. Its agent, the agent's other runs and what its agent learned are kept: a promotion record keeps its decision, numbers and run ids (the run's among them), and what it copied from the run (a disagreement's input and answers, the grader's words, and the words a hold's reason quoted from them) is blanked; the learning folder's history may still name the run's id. `204` when it is purged; a second `DELETE` is `204` too; a run this server never had is `404`. Live (queued, working, waiting on a person or an approval, or held by a runner): `409 run_not_final` (`details.runs`, the run or each run made from it that is live, or a replay or shadow run of it a check or an audit started while the `DELETE` ran, which the next `DELETE` purges first), nothing purged; cancel it first (`POST /runs/{run_id}/cancel`). A run that ended and takes a follow-up (`idle`), or that a person stopped, is not live; one that reads so before its runner has written it ended is waited for (up to 30 seconds), then purged. `503 unavailable` while its folder on an Archil disk is not deleted there yet (Archil failing or off, a computer still holding the folder): the run is not purged, and the `DELETE` sent again finishes it, as it finishes a purge that stopped part way. Takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token: any other console session is `403 forbidden`.",
|
|
2154
|
+
parameters: [ref("parameters/RunId")],
|
|
2155
|
+
responses: { "204": { description: "Purged, now or before." }, ...errors(401, 403, 404, 409, 429, 500, 503) },
|
|
2156
|
+
"x-agentrun-serve": "purge/1",
|
|
2157
|
+
},
|
|
2048
2158
|
patch: {
|
|
2049
2159
|
operationId: "raiseRunCap", tags: ["runs"], summary: "Raise a run's spend cap",
|
|
2050
2160
|
description: "Raises `max_cost_usd` of a run that named one, agentic or workflow; only a raise: the new cap is above the run's current cap, its last raise included (422 otherwise, and for a run with no cap); the same raise sent again (a retry) changes nothing and answers as the first did. The run's serve.json keeps it before anything else, so its next process and a server started again run under it. A run paused at its cap (`pending.kind` budget) goes on: the answer comes at once (`resumed` true, its `message_id`), and once its process has been let go the server sends it one follow-up turn under that id, \"The cap was raised to $X; continue the task.\", which runs under the new cap; it is sent once, by a server started again if this one stopped before it went. A second raise before it goes answers the same `message_id`; one that cannot be sent is tried again, then the run ends failed, saying why. Caps within 1e-9 are the same cap. A run working holds the new cap from its next step; a step already under way keeps the cap it was admitted at (`note` says so). A workflow run takes no follow-up: paused at its cap, the step that waits there is judged again under the new cap in its process, or, once the pause let its process go (10 minutes on), the run is opened again under it and resumes from its journal, sending no completed node again (`resumed` true, no `message_id`); a working one's process holds the new cap from its next check. 409 not_continuable for an ended run, and for a run a person stopped (send it a message to go on, then raise its cap).",
|
|
@@ -2991,7 +3101,7 @@ const LEARNING_NULL = "Null for a run that does not learn: its agent's `learning
|
|
|
2991
3101
|
const LEARNING = {
|
|
2992
3102
|
oneOf: [
|
|
2993
3103
|
closedWith({
|
|
2994
|
-
state: { enum: [...LEARNING_STATES], description: "`seeded` when the run started from what its agent learned; `reflecting` while its end-of-run step runs (its compile turn, its owner's correction), and until what it wrote is checked
|
|
3104
|
+
state: { enum: [...LEARNING_STATES], description: "`seeded` when the run started from what its agent learned; `reflecting` while its end-of-run step runs (its compile turn, its owner's correction), and until what it wrote is checked); `reflecting` after the run's job ended (its own look-back, or the feedback round a grade opened) keeps the run's end: the run reads completed, failed or cancelled, with its `ended_at`, `result` and `error` as its job left them, and is read again after `poll_after_ms` (above 0) until its learning settles, its timeline `final: false` till then; stop answers `stopped: false` and cancel `already_terminal: true`, and a run tells `run.ended` once; `merged` once what it kept is on the folder's main; `dropped` when learning was skipped or refused, with `reason`." },
|
|
2995
3105
|
reason: LEARNING_REASON,
|
|
2996
3106
|
detail: { type: ["string", "null"], maxLength: 300, description: "Where the run's learning stands, in one sentence in a person's words (at most 300 characters, ending in an ellipsis when cut; a workflow's name in it is cut of the host's secrets as they are now before it is cut short, so none is shown in part), the same as its timeline row says: \"Started from 2 corrections and 1 workflow.\", \"Keeping what this run learned…\", \"Learned the workflow <name>.\", \"Kept your correction.\", \"Waiting for your OK: workflow <name>.\", \"Nothing new to keep from this run.\", \"Not kept: it didn't pass the checks (<rules>).\", \"Not kept: learning stopped (<why>).\" and so on. Never a secret or a value from the input, cut of the host's secrets as they are now. For a person: a client that acts on it reads `state` and `reason`, whose codes do not change." },
|
|
2997
3107
|
at: { type: "string", format: "date-time", description: "When the state last changed." },
|
|
@@ -3197,7 +3307,7 @@ const FIELD_EXTENSIONS = {
|
|
|
3197
3307
|
"x-agentrun-serve": "costbasis/1",
|
|
3198
3308
|
},
|
|
3199
3309
|
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 or its shadow is at work, or a part is unknown: never $0 for unknown.", "x-agentrun-serve": "allin/1" },
|
|
3200
|
-
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), as the run's ledger booked them, joined and rounded as `usd` is, so `usd` less this is its model requests and decisions. 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/
|
|
3310
|
+
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" },
|
|
3201
3311
|
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" },
|
|
3202
3312
|
plan: {
|
|
3203
3313
|
type: "object", additionalProperties: false, required: ["requests", "tokens", "on"],
|
|
@@ -3465,7 +3575,9 @@ const FIELD_EXTENSIONS = {
|
|
|
3465
3575
|
hold_window: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.hold_window, description: "The audit rows of the serving revision the hold rule reads: its newest this many (an owner's grade on a served run is one too)." },
|
|
3466
3576
|
hold_disagree: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.hold_disagree, description: "When at least this many of those rows disagree, the workflow stops serving (a hold, source `audit`) and is recompiled once with them as data, then checked again: promoted serves again, otherwise it stops. At most `hold_window`." },
|
|
3467
3577
|
stop_window: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.stop_window, description: "A second hold within this many served runs of the first stops the workflow for good, asking no compile." },
|
|
3468
|
-
|
|
3578
|
+
repick: { type: "boolean", default: false, description: "`true`: a learned workflow compiled from now on re-picks its answer's quotes from the pages its run fetched. When a quote in its first answer is in none of those pages, its one re-pick writes the answer again from the pages themselves (each sent as data, told it is untrusted text from the web and never instructions, with no tools), not from its compact notes alone. It is read when a draft is committed, so a workflow already kept is unchanged until its next compile. It reaches a re-pick of one model step, in the workflow or in the composed workflow that writes its answer; any other re-pick is kept as compiled, and the server's log says so. An agent whose workflows run through an SDK bridge ignores it. `false` or absent: the re-pick reads its compact notes and its draft." },
|
|
3579
|
+
repick_max_chars: { type: "integer", minimum: 1, maximum: REPICK_MAX_CHARS_MAX, default: REPICK_MAX_CHARS_DEFAULT, description: "The most characters of state a re-pick over the pages sends its model: past it, the longest strings (the pages) are cut first, each to one length and marked where it was cut. Its cost is the served run's, under the run's cost cap like every model request of the run. Read with `repick`, at each compile." },
|
|
3580
|
+
} }], default: false, description: "Whether an agentic revision's runs learn: `true`, its owner's corrections and learned workflows; an object, the same with the loop's numbers set on it (`compile_after`, `agree_min`, `alone_min`, `agree_on`, `audit_every`, `audit_every_later`, `audit_later_after`, `hold_window`, `hold_disagree`, `stop_window`, `repick`, `repick_max_chars`, each optional: one left out is its default; `true` is every default); `false`, nothing. A run that learns starts from what its agent has learned, its corrections.md whole in its instructions under `# Learned` and its learned workflows behind its learned_workflow tool; once its job is due, it is asked one compile turn that writes the job as a learned workflow, checked and committed. Kept when a definition says so, true, false or an object (its numbers in one order); a number out of range or an unknown key is a 422 `wrong_type`; absent, off, and an answer shows none. An edit that leaves it out keeps the agent's. A workflow revision keeps none. On a server whose learning is off (`capabilities.features.learning`), no run learns, whatever this says.", "x-agentrun-serve": "learning/1" },
|
|
3469
3581
|
checkout: { enum: ["pull_request", "none"], description: "What the server checks out in each run's folder before its first turn, an agentic definition's alone. `pull_request`: the pull request the run's GitHub event names (a GitHub trigger's firing: its repository, number, head and base), at its head, detached, in `repo/`, with its base and their merge base fetched beside it (refs `pr/head`, `pr/base`, `pr/merge-base`). The fetch is the server's own, one command on the run's folder, with an installation token of the server's GitHub App narrowed to that repository and `contents: read`, which the agent never holds: it is never in the folder, the checkout's git config, its remote's URL, the agent's environment or the log. With no App, or one not installed there, the fetch is anonymous, which a public repository answers. The run's system prompt says what was checked out, or why nothing was (no pull request named, the fetch failed), so it can read the change another way, such as the GitHub MCP. The checkout is removed when the run's claim ends. An edit that leaves it out keeps the agent's; `none` clears it. A template sets it from its manifest's `checkout`.", "x-agentrun-serve": "checkout/1" },
|
|
3470
3582
|
},
|
|
3471
3583
|
AgentCreate: {
|
|
@@ -3955,8 +4067,8 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
|
|
|
3955
4067
|
}
|
|
3956
4068
|
// A contract field this server takes with a meaning of its own, said on it.
|
|
3957
4069
|
definition.properties.max_cost_usd = { ...definition.properties.max_cost_usd, "x-agentrun-serve-note": "The agent's default cap of each run started without a max_cost_usd of its own (a run's own wins), kept with its revision: above 0 sets it, 0 clears it (no default), and an edit that leaves the field out keeps the agent's, so leaving a field out never removes a spend limit. An agentic definition's or a workflow's alike." };
|
|
3958
|
-
definition.properties.output_schema = { ...definition.properties.output_schema, "x-agentrun-serve-note": "An agentic definition's alone (a workflow's output is its workflow's): the JSON Schema its final answer's last fenced json block meets, at most 64 KiB, refused at save when it does not compile. A completed run's result.output is that block's value when it meets the schema, else null. An edit that leaves the field out keeps the agent's. A template's answer schema (its manifest's `output`) is set here at apply.
|
|
3959
|
-
definition.properties.input_schema = { ...definition.properties.input_schema, "x-agentrun-serve-note": "An agentic definition's alone (a workflow's input is its workflow's own schema): a JSON Schema object schema (`type: object`), at most 64 KiB, refused at save when it does not compile. Every run's `input` is checked against it with the full compiler, by POST /agents/{agent_id}/runs, a trigger's start_run target (at save and when it fires) and a template's triggers, and refused 422 `input_invalid` with an issue at each path (`input.company`, `input.topics.1`). `content` is reserved: named, it is `{type: string}`; it is always taken as text (the run's message)
|
|
4070
|
+
definition.properties.output_schema = { ...definition.properties.output_schema, "x-agentrun-serve-note": "An agentic definition's alone (a workflow's output is its workflow's): the JSON Schema its final answer's last fenced json block meets, at most 64 KiB, refused at save when it does not compile. A completed run's result.output is that block's value when it meets the schema, else null. An edit that leaves the field out keeps the agent's. A template's answer schema (its manifest's `output`) is set here at apply. Over 32 KiB, a scheduled run is handed only the fields the producing run's schema names in `x-carried`; carried arrays lose entries from the front until they fit, and the run is told how many. A save refuses an `x-carried` that is not unique root property names." };
|
|
4071
|
+
definition.properties.input_schema = { ...definition.properties.input_schema, "x-agentrun-serve-note": "An agentic definition's alone (a workflow's input is its workflow's own schema): a JSON Schema object schema (`type: object`), at most 64 KiB, refused at save when it does not compile. Every run's `input` is checked against it with the full compiler, by POST /agents/{agent_id}/runs, a trigger's start_run target (at save and when it fires) and a template's triggers, and refused 422 `input_invalid` with an issue at each path (`input.company`, `input.topics.1`). `content` is reserved: named, it is `{type: string}`; it is always taken as text (the run's message). It is required when the schema has no field of its own; when the schema's own fields are all optional, a run gives `content` or one of them, and an input with none is refused at `input.content`. The run's first message is `content`, then the other fields as one fenced json block under the line `Input:`. Absent: `{content: string}`. An edit that leaves the field out keeps the agent's. A template's `inputs` are set here at apply." };
|
|
3960
4072
|
const runResult = schemas.RunResult;
|
|
3961
4073
|
runResult.properties.output = { ...runResult.properties.output, "x-agentrun-serve-note": "A workflow run's output, as its workflow ended; an agentic run's, its final answer's last fenced json block when it meets the agent's output_schema, else null (no schema, no block, not JSON, or a value the schema refuses). The runner gives the model the schema in its instructions on every harness, and asks once more, in the same session under the same cap, when the answer misses it; output_error says why one still missed." };
|
|
3962
4074
|
// instructions XOR workflow (validate.ts): a workflow revision has none. version, skills and tools: this server
|
|
@@ -4197,8 +4309,9 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
|
|
|
4197
4309
|
const own = Object.keys(ERROR_STATUS).filter((code) => Array.isArray(errorCode.enum) && !errorCode.enum.includes(code));
|
|
4198
4310
|
if (own.length) {
|
|
4199
4311
|
errorCode.enum = [...errorCode.enum, ...own];
|
|
4200
|
-
// The newest addition that widened it: a client that validates against
|
|
4201
|
-
|
|
4312
|
+
// The newest addition that widened it: a client that validates against runners/1 refuses run_not_final, purged and
|
|
4313
|
+
// agent_not_archived.
|
|
4314
|
+
errorCode["x-agentrun-serve"] = "purge/1";
|
|
4202
4315
|
fields.push(...own.map((code) => `ErrorCode.${code}`));
|
|
4203
4316
|
}
|
|
4204
4317
|
// A start (or a message) while every runner here refused to claim any run: 503 runner_refused, not retryable, in the
|
|
@@ -4237,6 +4350,21 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
|
|
|
4237
4350
|
composio_in_use: closed({ triggers: { type: "array", items: closed({ id: { type: "string" }, name: { type: "string" } }), description: "The composio triggers that use it." } }),
|
|
4238
4351
|
runs_in_flight: closed({ runs: { type: "array", items: { type: "string" }, description: "The agent's runs not ended (DELETE /agents/{agent_id})." } }),
|
|
4239
4352
|
learning_busy: closed({ runs: { type: "array", items: { type: "string" }, description: "What of the agent's learning is at work (DELETE /agents/{agent_id}): each run of it not ended (its compile turn, a check's replay or an audit's shadow among them), by its id." } }),
|
|
4353
|
+
run_not_final: closed({ runs: { type: "array", items: { type: "string" }, description: "What is live (DELETE /runs/{run_id}, and an archived agent's DELETE /agents/{agent_id}): the run itself, each run made from it that is live, or each live run of the agent, by its id." } }),
|
|
4354
|
+
purged: {
|
|
4355
|
+
oneOf: [
|
|
4356
|
+
closed({
|
|
4357
|
+
run_id: { type: "string" }, agent_id: { type: "string" },
|
|
4358
|
+
state: { enum: ["ended", "stopped", "failed"], description: "The run's state as its row kept it: only a run that is not live is purged." },
|
|
4359
|
+
started_at: { type: "string", format: "date-time" }, ended_at: { type: ["string", "null"], format: "date-time" },
|
|
4360
|
+
cost_usd: { type: ["number", "null"], minimum: 0, description: "What it cost, as `/usage` sums it: its known cost, else its upper bound." },
|
|
4361
|
+
cost_upper_bound: { type: "boolean", description: "`cost_usd` is an upper bound, not a known cost." },
|
|
4362
|
+
tools_usd: { type: ["number", "null"], minimum: 0, description: "What its paid tools cost, as `/usage`'s tools meter read it; null when none was read." },
|
|
4363
|
+
purged_at: { type: "string", format: "date-time" },
|
|
4364
|
+
}, "A purged run's tombstone (every route of /runs/{run_id})."),
|
|
4365
|
+
closed({ agent_id: { type: "string" }, archived_at: { type: ["string", "null"], format: "date-time" }, purged_at: { type: "string", format: "date-time" } }, "A purged agent's tombstone (every route of /agents/{agent_id})."),
|
|
4366
|
+
],
|
|
4367
|
+
},
|
|
4240
4368
|
};
|
|
4241
4369
|
const extensions = [];
|
|
4242
4370
|
for (const [path, item] of Object.entries(EXTENSIONS)) {
|
|
@@ -4245,6 +4373,17 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
|
|
|
4245
4373
|
extensions.push(`${method.toUpperCase()} ${path}`);
|
|
4246
4374
|
}
|
|
4247
4375
|
}
|
|
4376
|
+
// purge/1: every route of a purged run or agent (DELETE /runs/{run_id}, DELETE /agents/{agent_id}) answers 410 purged
|
|
4377
|
+
// with its tombstone, its DELETE alone 204 again. A contract operation that gains the 410 is changed, and says so.
|
|
4378
|
+
doc.components.responses = {
|
|
4379
|
+
...doc.components.responses,
|
|
4380
|
+
Gone: {
|
|
4381
|
+
description: "`purged`: the run or agent was purged (`DELETE /runs/{run_id}`, `DELETE /agents/{agent_id}`); `details` is its tombstone.",
|
|
4382
|
+
headers: { "X-Request-Id": ref("headers/RequestId") },
|
|
4383
|
+
content: { "application/json": { schema: ref("schemas/Error") } },
|
|
4384
|
+
"x-agentrun-serve": "purge/1",
|
|
4385
|
+
},
|
|
4386
|
+
};
|
|
4248
4387
|
// examples/1: a working body for the operations in REQUEST_EXAMPLES, on the JSON media type; a contract operation that
|
|
4249
4388
|
// gains one is changed, and says so.
|
|
4250
4389
|
for (const [path, item] of Object.entries(doc.paths)) {
|
|
@@ -4282,6 +4421,33 @@ export function openapiDocument(capabilityOf, adapters = TRIGGER_ADAPTERS) {
|
|
|
4282
4421
|
Object.assign(doc.paths, hooks, NATIVE_PATHS, SDK_PATHS, OBSERVATION_PATHS);
|
|
4283
4422
|
doc.info["x-agentrun-serve"].extensions.push(...Object.entries({ ...NATIVE_PATHS, ...SDK_PATHS, ...OBSERVATION_PATHS }).flatMap(([path, item]) => Object.keys(item).map(method => `${method.toUpperCase()} ${path}`)));
|
|
4284
4423
|
doc.info["x-agentrun-serve"].extensions.push(...Object.keys(hooks).map((path) => `POST ${path}`));
|
|
4424
|
+
// purge/1, on every operation there is by now (each rewritten, never a shared constant's own object changed); `changed`
|
|
4425
|
+
// is info's own list. Every route of a purged run or agent, and each that writes to an agent its body names (a trigger
|
|
4426
|
+
// made for it or moved to it, a template applied onto it), which a purged one refuses.
|
|
4427
|
+
const namesAgent = new Set(["createTrigger", "updateTrigger", "applyTemplate"]);
|
|
4428
|
+
for (const [path, item] of Object.entries(doc.paths)) {
|
|
4429
|
+
const ofPurgeable = /^\/(runs\/\{run_id\}|agents\/\{agent_id\})(\/|$)/.test(path);
|
|
4430
|
+
if (!ofPurgeable && !Object.values(item).some((op) => typeof op === "object" && op !== null && namesAgent.has(op.operationId)))
|
|
4431
|
+
continue;
|
|
4432
|
+
const ops = { ...item };
|
|
4433
|
+
for (const [method, op] of Object.entries(ops)) {
|
|
4434
|
+
if (method === "parameters" || method.startsWith("x-") || !op.responses)
|
|
4435
|
+
continue;
|
|
4436
|
+
if (op.operationId === "deleteRun" || op.operationId === "deleteAgent")
|
|
4437
|
+
continue;
|
|
4438
|
+
if (!ofPurgeable && !namesAgent.has(op.operationId))
|
|
4439
|
+
continue;
|
|
4440
|
+
ops[method] = { ...op, responses: { ...op.responses, "410": ref("responses/Gone") } };
|
|
4441
|
+
if (op["x-agentrun-serve"] !== undefined)
|
|
4442
|
+
continue;
|
|
4443
|
+
// An operation whose responses an earlier addition changed keeps that one's mark, as a schema two additions widen does.
|
|
4444
|
+
const marks = (op["x-agentrun-serve-changed"] ?? {});
|
|
4445
|
+
ops[method]["x-agentrun-serve-changed"] = { ...marks, responses: marks.responses ?? "purge/1" };
|
|
4446
|
+
if (!changed.includes(`${method.toUpperCase()} ${path}`))
|
|
4447
|
+
changed.push(`${method.toUpperCase()} ${path}`);
|
|
4448
|
+
}
|
|
4449
|
+
doc.paths[path] = ops;
|
|
4450
|
+
}
|
|
4285
4451
|
return doc;
|
|
4286
4452
|
}
|
|
4287
4453
|
/** The document as served on `port`: the owner's session cookie named as the console sets it on that port
|
package/dist/paid-calls.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { Refusal } from "@parcha/agentrun-kernel";
|
|
2
2
|
import type { ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
-
/** Parallel's
|
|
4
|
-
|
|
3
|
+
/** The modes Parallel's Search API is priced in here; a request in any other mode (or naming none) has no price. */
|
|
4
|
+
export type ParallelSearchMode = "turbo" | "fast" | "basic" | "advanced";
|
|
5
|
+
/** Parallel's published prices (https://docs.parallel.ai/resources/pricing, read 2026-11-20). Search, by the request's
|
|
6
|
+
* `mode`: `turbo` or `fast` $1 per 1,000 requests, `basic` or `advanced` $5 per 1,000, each with 10 results included,
|
|
7
|
+
* and each result past those 10 $1 per 1,000. Extract: $1 per 1,000 URLs. */
|
|
8
|
+
export declare const PARALLEL_SEARCH_MODE_USD: Readonly<Record<ParallelSearchMode, number>>;
|
|
9
|
+
/** A `fast` search's price: the mode the web tools search in (web-search.ts). */
|
|
5
10
|
export declare const PARALLEL_SEARCH_USD = 0.001;
|
|
6
11
|
export declare const PARALLEL_SEARCH_RESULT_USD = 0.001;
|
|
7
12
|
export declare const PARALLEL_SEARCH_INCLUDED = 10;
|
|
@@ -13,12 +18,14 @@ export type Fee = {
|
|
|
13
18
|
usd: number;
|
|
14
19
|
basis: string;
|
|
15
20
|
};
|
|
16
|
-
/** A
|
|
17
|
-
|
|
21
|
+
/** A search in `mode` for `n` results: the mode's price (PARALLEL_SEARCH_MODE_USD), and $0.001 for each past the 10 it
|
|
22
|
+
* includes. The web tools search `fast`: $0.001. */
|
|
23
|
+
export declare const parallelSearchFee: (n: number, mode?: ParallelSearchMode) => Fee;
|
|
18
24
|
/** An extract of `urls` URLs (the web tools ask one at a time). */
|
|
19
25
|
export declare const parallelExtractFee: (urls?: number) => Fee;
|
|
20
|
-
/** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by
|
|
21
|
-
* extract's, by the URLs; undefined for an endpoint the web tools do not ask
|
|
26
|
+
/** The fee of a request to Parallel's `url` with `body`: its search's, by its `mode` and the results it asks for (10 by
|
|
27
|
+
* default), or its extract's, by the URLs; undefined for an endpoint the web tools do not ask, and for a search whose
|
|
28
|
+
* mode has no price here (one naming none, or one Parallel added since): never $0, never another mode's price. */
|
|
22
29
|
export declare function parallelFeeOf(url: string, body: unknown): Fee | undefined;
|
|
23
30
|
/** A paid request the run's cap refused, whose hold could not be kept, or that has no run's ledger to book it on:
|
|
24
31
|
* nothing was sent. Its message is the refusal, in the cap's words. */
|
|
@@ -43,7 +50,8 @@ export type LedgerRefusal = Refusal;
|
|
|
43
50
|
export type PaidBooking = {
|
|
44
51
|
/** `chargedBy`: who charges for it (the charge's `charged_by` on main's records: parallel, monid, an MCP server, a
|
|
45
52
|
* browser vendor), named on its runner.request. `under`: the model session whose tool call it runs in (RunTools.admit),
|
|
46
|
-
* whose requests in flight it is judged beside and never waits on.
|
|
53
|
+
* whose requests in flight it is judged beside and never waits on. `reported`: it settles at the provider's own figure
|
|
54
|
+
* for the call, written on its runner.request (GET /runs/{run_id}/usage says a `tools` line's basis by it). */
|
|
47
55
|
admit(request: {
|
|
48
56
|
id: string;
|
|
49
57
|
name: string;
|
|
@@ -57,6 +65,7 @@ export type PaidBooking = {
|
|
|
57
65
|
hold?: true;
|
|
58
66
|
ref?: string;
|
|
59
67
|
under?: string;
|
|
68
|
+
reported?: true;
|
|
60
69
|
}): Promise<unknown>;
|
|
61
70
|
/** `givenBack`: the hold let go unused, nothing sent (RunTools.settle). */
|
|
62
71
|
settle(id: string, usd: number | null, options?: {
|
|
@@ -118,6 +127,7 @@ export declare function paidStep<T>(paid: PaidBooking, call: string | undefined,
|
|
|
118
127
|
owed?: true;
|
|
119
128
|
hold?: true;
|
|
120
129
|
ref?: string;
|
|
130
|
+
reported?: true;
|
|
121
131
|
}, run: () => Promise<T>, chargeOf: (outcome: {
|
|
122
132
|
result: T;
|
|
123
133
|
} | {
|
package/dist/paid-calls.js
CHANGED
|
@@ -15,28 +15,34 @@
|
|
|
15
15
|
// tool books without the ledger passed down to it.
|
|
16
16
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
17
|
import { SPEND_CAP_REACHED } from "./cap.js";
|
|
18
|
-
/** Parallel's published prices (https://docs.parallel.ai/
|
|
19
|
-
* $1 per 1,000 requests
|
|
18
|
+
/** Parallel's published prices (https://docs.parallel.ai/resources/pricing, read 2026-11-20). Search, by the request's
|
|
19
|
+
* `mode`: `turbo` or `fast` $1 per 1,000 requests, `basic` or `advanced` $5 per 1,000, each with 10 results included,
|
|
20
|
+
* and each result past those 10 $1 per 1,000. Extract: $1 per 1,000 URLs. */
|
|
21
|
+
export const PARALLEL_SEARCH_MODE_USD = Object.freeze({ turbo: 0.001, fast: 0.001, basic: 0.005, advanced: 0.005 });
|
|
22
|
+
/** A `fast` search's price: the mode the web tools search in (web-search.ts). */
|
|
20
23
|
export const PARALLEL_SEARCH_USD = 0.001;
|
|
21
24
|
export const PARALLEL_SEARCH_RESULT_USD = 0.001;
|
|
22
25
|
export const PARALLEL_SEARCH_INCLUDED = 10;
|
|
23
26
|
export const PARALLEL_EXTRACT_USD = 0.001;
|
|
24
27
|
/** In whole millionths of a dollar, so a sum of prices is the price. */
|
|
25
28
|
const usd = (dollars) => Math.round(dollars * 1e6) / 1e6;
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
const isSearchMode = (mode) => typeof mode === "string" && Object.hasOwn(PARALLEL_SEARCH_MODE_USD, mode);
|
|
30
|
+
/** A search in `mode` for `n` results: the mode's price (PARALLEL_SEARCH_MODE_USD), and $0.001 for each past the 10 it
|
|
31
|
+
* includes. The web tools search `fast`: $0.001. */
|
|
32
|
+
export const parallelSearchFee = (n, mode = "fast") => {
|
|
28
33
|
const more = Math.max(0, n - PARALLEL_SEARCH_INCLUDED);
|
|
29
|
-
return { name: "Parallel's search", by: "parallel", usd: usd(
|
|
34
|
+
return { name: "Parallel's search", by: "parallel", usd: usd(PARALLEL_SEARCH_MODE_USD[mode] + PARALLEL_SEARCH_RESULT_USD * more), basis: more ? `Parallel's list price for a ${mode} search of ${n} results` : `Parallel's list price for a ${mode} search` };
|
|
30
35
|
};
|
|
31
36
|
/** An extract of `urls` URLs (the web tools ask one at a time). */
|
|
32
37
|
export const parallelExtractFee = (urls = 1) => ({ name: "Parallel's extract", by: "parallel", usd: usd(PARALLEL_EXTRACT_USD * urls), basis: urls === 1 ? "Parallel's list price for one URL" : `Parallel's list price for ${urls} URLs` });
|
|
33
|
-
/** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by
|
|
34
|
-
* extract's, by the URLs; undefined for an endpoint the web tools do not ask
|
|
38
|
+
/** The fee of a request to Parallel's `url` with `body`: its search's, by its `mode` and the results it asks for (10 by
|
|
39
|
+
* default), or its extract's, by the URLs; undefined for an endpoint the web tools do not ask, and for a search whose
|
|
40
|
+
* mode has no price here (one naming none, or one Parallel added since): never $0, never another mode's price. */
|
|
35
41
|
export function parallelFeeOf(url, body) {
|
|
36
42
|
const path = URL.parse(url)?.pathname;
|
|
37
43
|
const asked = (body ?? {});
|
|
38
44
|
if (path === "/v1/search")
|
|
39
|
-
return parallelSearchFee(typeof asked.advanced_settings?.max_results === "number" ? asked.advanced_settings.max_results : PARALLEL_SEARCH_INCLUDED);
|
|
45
|
+
return isSearchMode(asked.mode) ? parallelSearchFee(typeof asked.advanced_settings?.max_results === "number" ? asked.advanced_settings.max_results : PARALLEL_SEARCH_INCLUDED, asked.mode) : undefined;
|
|
40
46
|
if (path === "/v1/extract")
|
|
41
47
|
return parallelExtractFee(Array.isArray(asked.urls) ? Math.max(1, asked.urls.length) : 1);
|
|
42
48
|
return undefined;
|
|
@@ -149,7 +155,7 @@ export async function paidStep(paid, call, fee, run, chargeOf, pause) {
|
|
|
149
155
|
const id = `${call ?? fee.ref ?? fee.name}#${(paidSeq += 1)}`;
|
|
150
156
|
let admitted;
|
|
151
157
|
try {
|
|
152
|
-
admitted = await paid.admit({ id, name: fee.name, holdUsd: fee.holdUsd, basis: fee.basis, ...(call === undefined ? {} : { call }), chargedBy: fee.by, ...(fee.tool ? { tool: fee.tool } : {}), ...(fee.tag ? { tag: fee.tag } : {}), ...(fee.owed ? { owed: true } : {}), ...(fee.hold ? { hold: true } : {}), ...(fee.ref === undefined ? {} : { ref: fee.ref }) });
|
|
158
|
+
admitted = await paid.admit({ id, name: fee.name, holdUsd: fee.holdUsd, basis: fee.basis, ...(call === undefined ? {} : { call }), chargedBy: fee.by, ...(fee.tool ? { tool: fee.tool } : {}), ...(fee.tag ? { tag: fee.tag } : {}), ...(fee.owed ? { owed: true } : {}), ...(fee.hold ? { hold: true } : {}), ...(fee.ref === undefined ? {} : { ref: fee.ref }), ...(fee.reported ? { reported: true } : {}) });
|
|
153
159
|
}
|
|
154
160
|
catch (error) {
|
|
155
161
|
await pauseOn(error, pause);
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SdkBinding } from "./sdk/runtimes.js";
|
|
1
2
|
import type { SdkWorkflowTool, SdkWorkflowAdapter } from "./sdk/workflows.js";
|
|
2
3
|
import type { NativeBinding } from "./native/types.js";
|
|
3
4
|
import { type MessageOrigin } from "./timeline/index.js";
|
|
@@ -12,8 +13,7 @@ import type { Place } from "./workspace/place.js";
|
|
|
12
13
|
* `documents` and `boxAllow` are the per-run choices
|
|
13
14
|
* the old path recomputed; here they are pinned at start, and optional (a built-in run may name none). */
|
|
14
15
|
export interface RunLaunch {
|
|
15
|
-
readonly sdk?: {
|
|
16
|
-
runtime: "claude-agent-sdk" | "codex-sdk" | "eve";
|
|
16
|
+
readonly sdk?: SdkBinding & {
|
|
17
17
|
instructions: string;
|
|
18
18
|
model?: string;
|
|
19
19
|
workflow_tools?: SdkWorkflowTool[];
|
package/dist/run-launch.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sdkBindingOf } from "./sdk/runtimes.js";
|
|
1
2
|
import { nativeOf } from "./native/binding.js";
|
|
2
3
|
// A run's launch record: the one JSON body the server writes when it starts a run (start = INSERT run, design 2.1), and
|
|
3
4
|
// the runner reads at its claim to build the run's spec. It replaces the per-run `serve.json` the old per-run process read
|
|
@@ -104,7 +105,7 @@ export function readLaunchBody(stored) {
|
|
|
104
105
|
const archilDisk = readDisk(stored.archil_disk);
|
|
105
106
|
return {
|
|
106
107
|
input: stored.input,
|
|
107
|
-
...(isObject(stored.sdk) && (stored.sdk
|
|
108
|
+
...(isObject(stored.sdk) && sdkBindingOf(stored.sdk) && typeof stored.sdk.instructions === "string" ? { sdk: stored.sdk } : {}),
|
|
108
109
|
...(nativeOf(stored) ? { native: nativeOf(stored) } : {}),
|
|
109
110
|
title: typeof stored.title === "string" ? stored.title : "",
|
|
110
111
|
...(typeof stored.repo === "string" ? { repo: stored.repo } : {}),
|
|
@@ -44,7 +44,7 @@ export declare function servedRunLearning(deps: {
|
|
|
44
44
|
feedback_status: "running" | "ended" | "not_run" | null;
|
|
45
45
|
source: "feedback" | "eval";
|
|
46
46
|
graded_at: string;
|
|
47
|
-
path: "agent" | "workflow" | "replay" | "
|
|
47
|
+
path: "agent" | "workflow" | "replay" | "audit" | "handed_back";
|
|
48
48
|
workflow_digest: string | null;
|
|
49
49
|
feedback: "correction" | null;
|
|
50
50
|
run_id: string;
|
|
@@ -11,7 +11,7 @@ import { capNowOf } from "./runner/journal-kinds.js";
|
|
|
11
11
|
import { journalRecords } from "./runner/journal-reader.js";
|
|
12
12
|
import { decisionsOverStore } from "./store-reads/decisions.js";
|
|
13
13
|
import { readRun } from "./store-reads/runs.js";
|
|
14
|
-
import { runTimeline, wholeAnswerFor, wholeAnswers } from "./store-reads/journal.js";
|
|
14
|
+
import { runTimeline, servedSince, wholeAnswerFor, wholeAnswers } from "./store-reads/journal.js";
|
|
15
15
|
import { FINAL_STATES } from "./store/store.js";
|
|
16
16
|
/** Run `runId`'s Timeline rows as served: cut by its one cut set, its decision rows among them, its error rows in the
|
|
17
17
|
* run's error's words; none for a run withheld. `calls`: each call's arguments whole and its output's head to
|
|
@@ -20,7 +20,9 @@ export async function servedTimelineRows(deps, store, runId, context, calls = fa
|
|
|
20
20
|
// The run's rows, its decisions, its learning end and the triggers' names, all read in one snapshot of the store (one
|
|
21
21
|
// moment, whatever the run's runner writes meanwhile): a row from before an answer never sits beside one from after it.
|
|
22
22
|
// They are rendered under the run's cut, which is read before the snapshot and again after it (underCut): the cut only
|
|
23
|
-
// grows, so a cut that is the same after holds every value saved before the rows were read.
|
|
23
|
+
// grows, so a cut that is the same after holds every value saved before the rows were read. Its whole answers are kept
|
|
24
|
+
// only while no run's text was forgotten since it began (servedSince: a purge it overtook).
|
|
25
|
+
const since = servedSince(store);
|
|
24
26
|
const read = await underCut(() => runCutValues(deps, store, runId), async (cut) => {
|
|
25
27
|
if (cut === "unreadable")
|
|
26
28
|
return undefined;
|
|
@@ -47,7 +49,7 @@ export async function servedTimelineRows(deps, store, runId, context, calls = fa
|
|
|
47
49
|
const final = run?.state === "stopped" || run?.state === "failed" ? run.state
|
|
48
50
|
: stopAsked(view, run, await snapshot.commands(runId, 0)) ? "stopped" : undefined;
|
|
49
51
|
const options = { redact, settled: ended, ended: view ? view.state !== "running" : false, ...(calls ? { calls: { result: CALL_RESULT_CHARS, redact: (text) => redacted(text, values, CALL_RESULT_CHARS), held: (value) => heldNumber(value, values) } } : {}) };
|
|
50
|
-
const timeline = await wholeAnswers(snapshot, runId, context, await runTimeline(snapshot, runId, context, options), options, wholeAnswerFor(values));
|
|
52
|
+
const timeline = await wholeAnswers(snapshot, runId, context, await runTimeline(snapshot, runId, context, options), options, wholeAnswerFor(values), since);
|
|
51
53
|
// A run whose booked spend passed its cap says so, by how much, after its usage row (run-view.ts withOverCap, as main's
|
|
52
54
|
// served Timeline did): at the cap as it stands (a raise taken counts, capNowOf).
|
|
53
55
|
const capNow = capNowOf((await launchOf(snapshot, runId))?.maxCostUsd, records.entries);
|