@parcha/agentrun-serve 0.1.0-beta.32 → 0.1.0-beta.33
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 +78 -46
- package/dist/adapters.d.ts +0 -3
- package/dist/adapters.js +0 -7
- package/dist/agents.d.ts +1 -1
- package/dist/api-only.d.ts +14 -0
- package/dist/api-only.js +33 -0
- package/dist/archil-routes.d.ts +1 -1
- package/dist/box-egress-vm.d.ts +0 -8
- package/dist/box-egress-vm.js +0 -10
- package/dist/box-egress.d.ts +0 -4
- package/dist/box-egress.js +1 -16
- package/dist/box-paths.d.ts +25 -2
- package/dist/box-paths.js +79 -11
- package/dist/box-relay.d.ts +0 -11
- package/dist/box-relay.js +0 -20
- package/dist/box-settings.d.ts +46 -0
- package/dist/box-settings.js +107 -0
- package/dist/boxes.d.ts +4 -1
- package/dist/browser-cost.js +2 -1
- package/dist/browser-person.d.ts +0 -2
- package/dist/browser-person.js +0 -2
- package/dist/budget.d.ts +0 -4
- package/dist/budget.js +0 -7
- package/dist/cap.d.ts +0 -7
- package/dist/cap.js +0 -22
- package/dist/cli.js +23 -8
- package/dist/computers.d.ts +1 -1
- package/dist/console/assets/index-Dn0ngwG9.js +535 -0
- package/dist/console/assets/index-DvW6Aled.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/daytona-api.d.ts +0 -11
- package/dist/daytona-api.js +1 -82
- package/dist/docker-host-addresses.d.ts +37 -0
- package/dist/docker-host-addresses.js +110 -0
- package/dist/files.d.ts +0 -8
- package/dist/files.js +0 -17
- package/dist/github-connection.d.ts +1 -1
- package/dist/github-connection.js +1 -1
- package/dist/harness-install.d.ts +23 -0
- package/dist/harness-install.js +99 -4
- package/dist/harness.d.ts +4 -3
- package/dist/harness.js +16 -1
- package/dist/import.js +52 -13
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +19 -6
- package/dist/learned-workflow.d.ts +5 -4
- package/dist/learned-workflow.js +6 -3
- package/dist/learning-routes.d.ts +9 -46
- package/dist/learning-routes.js +25 -29
- package/dist/learning-run.d.ts +4 -231
- package/dist/learning-run.js +7 -651
- package/dist/live/translate.js +1 -1
- package/dist/mcp-gateway.d.ts +0 -3
- package/dist/mcp-gateway.js +0 -13
- package/dist/mcp-probe.d.ts +2 -2
- package/dist/mcp-probe.js +2 -2
- package/dist/mcp-servers-store.js +1 -1
- package/dist/openapi.js +3 -3
- package/dist/page.js +3 -1
- package/dist/paid-calls.js +3 -2
- package/dist/pause.d.ts +0 -2
- package/dist/pause.js +1 -8
- package/dist/place.d.ts +0 -5
- package/dist/place.js +0 -10
- package/dist/print.d.ts +2 -1
- package/dist/print.js +4 -2
- package/dist/run-db.d.ts +0 -2
- package/dist/run-db.js +0 -4
- package/dist/run-learning-served.d.ts +38 -0
- package/dist/run-learning-served.js +9 -0
- package/dist/run-secrets.d.ts +33 -0
- package/dist/run-secrets.js +53 -0
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +5 -9
- package/dist/run-view.js +4 -22
- package/dist/runner/adapter-loop.d.ts +8 -2
- package/dist/runner/adapter-loop.js +44 -12
- package/dist/runner/adapter-run-spec.d.ts +8 -0
- package/dist/runner/adapter-run-spec.js +6 -5
- package/dist/runner/adapters/pi.d.ts +4 -0
- package/dist/runner/adapters/pi.js +4 -1
- package/dist/runner/beside.js +19 -8
- package/dist/runner/claim-secrets.js +1 -1
- package/dist/runner/cli-run-spec.js +15 -1
- package/dist/runner/journal-kinds.d.ts +6 -0
- package/dist/runner/live-ticker.d.ts +1 -1
- package/dist/runner/live-ticker.js +28 -4
- package/dist/runner/loop-contract.d.ts +3 -2
- package/dist/runner/main.d.ts +11 -4
- package/dist/runner/main.js +39 -10
- package/dist/runner/mcp-claim.d.ts +1 -1
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/model-route.js +21 -2
- package/dist/runner/redact.d.ts +8 -2
- package/dist/runner/redact.js +11 -2
- package/dist/runner/workflow-spec.js +5 -9
- package/dist/runs-over-store.d.ts +1 -1
- package/dist/runs-over-store.js +16 -5
- package/dist/seal-key.d.ts +54 -15
- package/dist/seal-key.js +272 -84
- package/dist/sealed-settings.d.ts +2 -2
- package/dist/sealed-settings.js +3 -10
- package/dist/secrets.d.ts +2 -10
- package/dist/secrets.js +21 -17
- package/dist/server-secrets-store.js +1 -1
- package/dist/server-secrets.js +3 -0
- package/dist/server.d.ts +10 -6
- package/dist/server.js +89 -41
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/open.d.ts +12 -2
- package/dist/store/open.js +23 -3
- package/dist/store/postgres/migrate.js +18 -1
- package/dist/store/sqlite/store.js +23 -8
- package/dist/store/store.d.ts +3 -0
- package/dist/store-reads/journal.d.ts +16 -0
- package/dist/store-reads/journal.js +82 -6
- package/dist/store-view.js +38 -5
- package/dist/tool-keys.d.ts +4 -3
- package/dist/tool-keys.js +7 -4
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +4 -1
- package/dist/trigger-schedule.js +2 -1
- package/dist/trigger-secrets-shown.js +5 -1
- package/dist/workspace/computer-deps.d.ts +29 -0
- package/dist/workspace/computer-deps.js +48 -1
- package/dist/workspace/computer-for-claim.d.ts +7 -3
- package/dist/workspace/computer-for-claim.js +1 -1
- package/dist/workspace/computer-providers.d.ts +6 -2
- package/dist/workspace/computer-providers.js +1 -1
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace.d.ts +0 -3
- package/dist/workspace.js +0 -3
- package/launcher/agentrun-serve +6 -33
- package/package.json +14 -14
- package/templates/inbound-lead/agent.md +1 -1
- package/templates/kyb/agent.md +1 -1
- package/dist/app.d.ts +0 -5
- package/dist/app.js +0 -514
- package/dist/bounds.d.ts +0 -26
- package/dist/bounds.js +0 -137
- package/dist/console/assets/index-35-7aeIZ.js +0 -519
- package/dist/console/assets/index-Cejbov-Y.css +0 -1
- package/dist/content-filter.d.ts +0 -7
- package/dist/content-filter.js +0 -23
- package/dist/disk.d.ts +0 -33
- package/dist/disk.js +0 -85
- package/dist/door-line.d.ts +0 -23
- package/dist/door-line.js +0 -83
- package/dist/harness-app.d.ts +0 -69
- package/dist/harness-app.js +0 -1162
- package/dist/request-start.d.ts +0 -27
- package/dist/request-start.js +0 -381
- package/dist/run-box.d.ts +0 -205
- package/dist/run-box.js +0 -661
- package/dist/run-holder.d.ts +0 -52
- package/dist/run-holder.js +0 -139
- package/dist/runs.d.ts +0 -1200
- package/dist/runs.js +0 -4103
- package/dist/served-only.d.ts +0 -5
- package/dist/served-only.js +0 -12
package/dist/live/translate.js
CHANGED
|
@@ -171,7 +171,7 @@ export function translate(state, commit) {
|
|
|
171
171
|
}
|
|
172
172
|
if (entry.kind === KINDS.message) {
|
|
173
173
|
const said = dataOf(entry);
|
|
174
|
-
const message = { role: ROLE[said.role] ?? "user", content: said.role === "model" ? [{ type: "text", text: said.text }] : said.text };
|
|
174
|
+
const message = { role: ROLE[said.role] ?? "user", content: said.role === "model" ? [{ type: "text", text: said.text }] : said.text, ...(typeof said.at === "number" ? { timestamp: said.at } : {}) };
|
|
175
175
|
const synthetic = { ...entry, model: [message] };
|
|
176
176
|
state.entries.push(synthetic);
|
|
177
177
|
events.push({ type: "message_start", message, ...tag(entry) }, { type: "message_end", entry: synthetic, ...tag(entry) });
|
package/dist/mcp-gateway.d.ts
CHANGED
|
@@ -72,9 +72,6 @@ export declare function mcpHeaderProblem(inputSchema: unknown): string | undefin
|
|
|
72
72
|
* tool that cannot be pinned (its server no longer saved, the tool gone since a refresh, a header declaration it cannot
|
|
73
73
|
* send) throws, naming it and why: the run is refused, never started without it. */
|
|
74
74
|
export declare function mcpPinOf(names: readonly string[], source: McpServerSource): McpPin;
|
|
75
|
-
/** What a launch hands the run for its pin: each pinned server's URL now, with its headers only when it has not moved. A
|
|
76
|
-
* server no longer saved is absent. */
|
|
77
|
-
export declare function mcpCredentialsOf(pin: McpPin, source: McpServerSource, runId?: string): McpCredentials;
|
|
78
75
|
export interface McpGatewayOptions {
|
|
79
76
|
pin: McpPin;
|
|
80
77
|
credentials: McpCredentials;
|
package/dist/mcp-gateway.js
CHANGED
|
@@ -151,19 +151,6 @@ export function mcpPinOf(names, source) {
|
|
|
151
151
|
}
|
|
152
152
|
return pin;
|
|
153
153
|
}
|
|
154
|
-
/** What a launch hands the run for its pin: each pinned server's URL now, with its headers only when it has not moved. A
|
|
155
|
-
* server no longer saved is absent. */
|
|
156
|
-
export function mcpCredentialsOf(pin, source, runId) {
|
|
157
|
-
const out = Object.create(null);
|
|
158
|
-
for (const [name, pinned] of Object.entries(pin)) {
|
|
159
|
-
const saved = source.server(name);
|
|
160
|
-
if (!saved)
|
|
161
|
-
continue;
|
|
162
|
-
const credential = saved.url === pinned.url ? source.headers(name, runId) : undefined;
|
|
163
|
-
out[name] = { url: saved.url, ...(credential && "unopened" in credential ? { unopened: credential.unopened } : credential ? { headers: credential.headers, ...(credential.expires_at !== undefined ? { expires_at: credential.expires_at } : {}) } : {}) };
|
|
164
|
-
}
|
|
165
|
-
return out;
|
|
166
|
-
}
|
|
167
154
|
/** Why a connection failed, in a few words: the network's own code, read down the error's causes (the SDK wraps fetch's
|
|
168
155
|
* error, which wraps the socket's), else the deepest message, cut short. */
|
|
169
156
|
function unreachable(error) {
|
package/dist/mcp-probe.d.ts
CHANGED
|
@@ -60,8 +60,8 @@ export type Auth = {
|
|
|
60
60
|
type: AuthType;
|
|
61
61
|
headers?: HeaderMap;
|
|
62
62
|
};
|
|
63
|
-
/** How a server gets a seal key
|
|
64
|
-
export declare const SEAL_KEY_HOW = "
|
|
63
|
+
/** How a server gets a seal key (seal-key.ts). */
|
|
64
|
+
export declare const SEAL_KEY_HOW = "The server keeps one in seal/seal.key in its data directory, made at the first start, 0600 in a 0700 directory; or hand it AGENTRUN_SEAL_KEY (32 random bytes in base64).";
|
|
65
65
|
export declare const notFound: (name: string) => ApiError;
|
|
66
66
|
export declare const credentialMissing: (type: AuthType, message: string) => InputIssue;
|
|
67
67
|
export declare const nameOf: (name: string) => void;
|
package/dist/mcp-probe.js
CHANGED
|
@@ -69,8 +69,8 @@ const LOOPBACK = (host) => LOOPBACK_NAMES.includes(host) || LOOPBACK_V4.test(hos
|
|
|
69
69
|
export function boundTool(tool) {
|
|
70
70
|
return { name: tool.name, ...(tool.title ? { title: tool.title } : {}), ...(tool.description ? { description: tool.description } : {}), inputSchema: (tool.input_schema ?? {}), ...(tool.annotations ? { annotations: tool.annotations } : {}) };
|
|
71
71
|
}
|
|
72
|
-
/** How a server gets a seal key
|
|
73
|
-
export const SEAL_KEY_HOW = `
|
|
72
|
+
/** How a server gets a seal key (seal-key.ts). */
|
|
73
|
+
export const SEAL_KEY_HOW = `The server keeps one in seal/seal.key in its data directory, made at the first start, 0600 in a 0700 directory; or hand it ${SEAL_KEY_ENV} (32 random bytes in base64).`;
|
|
74
74
|
export const notFound = (name) => new ApiError("not_found", `No MCP server ${name}: GET /v2/settings/mcp-servers lists them.`);
|
|
75
75
|
export const credentialMissing = (type, message) => ({ field: type === "bearer" ? "auth.token" : type === "oauth" ? "auth.type" : "auth.headers", reason: "missing", message: type === "oauth" ? `${message} An OAuth server is signed in to first: POST /v2/settings/mcp-servers/{name}/oauth/start.` : message });
|
|
76
76
|
export const nameOf = (name) => {
|
|
@@ -88,7 +88,7 @@ export class McpServersOverStore {
|
|
|
88
88
|
constructor(store, env, version, network = systemNetwork) {
|
|
89
89
|
this.store = store;
|
|
90
90
|
this.version = version;
|
|
91
|
-
// The server never starts without a seal key (seal-key.ts
|
|
91
|
+
// The server never starts without a seal key (seal-key.ts bootSealKey), so there is no keyless registry: every
|
|
92
92
|
// credential is kept sealed under it.
|
|
93
93
|
const sealKey = sealKeyOf(env[SEAL_KEY_ENV]);
|
|
94
94
|
if (!sealKey)
|
package/dist/openapi.js
CHANGED
|
@@ -1152,13 +1152,13 @@ const EXTENSIONS = {
|
|
|
1152
1152
|
"/runs/{run_id}": {
|
|
1153
1153
|
patch: {
|
|
1154
1154
|
operationId: "raiseRunCap", tags: ["runs"], summary: "Raise a run's spend cap",
|
|
1155
|
-
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
|
|
1155
|
+
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).",
|
|
1156
1156
|
parameters: [ref("parameters/RunId")],
|
|
1157
1157
|
requestBody: { required: true, content: { "application/json": { schema: { type: "object", additionalProperties: false, required: ["max_cost_usd"], properties: { max_cost_usd: { type: "number", exclusiveMinimum: 0, description: "The new cap, above the run's current cap." } } } } } },
|
|
1158
1158
|
responses: {
|
|
1159
1159
|
"200": json({ type: "object", additionalProperties: false, required: ["run_id", "max_cost_usd", "resumed", "status", "state"], properties: {
|
|
1160
1160
|
run_id: { type: "string" }, max_cost_usd: { type: "number" }, resumed: { type: "boolean", description: "A run paused at its cap goes on: its follow-up turn is sent once its process has been let go." },
|
|
1161
|
-
message_id: { type: "string", description: "That follow-up's id, when `resumed`." }, note: { type: "string", description: "Said when the run
|
|
1161
|
+
message_id: { type: "string", description: "That follow-up's id, when `resumed`." }, note: { type: "string", description: "Said when the run is working: the raised cap holds from its next step, and a step already under way keeps the cap it was admitted at." },
|
|
1162
1162
|
status: ref("schemas/RunStatus"), state: ref("schemas/RunState"),
|
|
1163
1163
|
} }, "The run, its cap raised."),
|
|
1164
1164
|
...errors(401, 404, 409, 422, 429, 500),
|
|
@@ -1988,7 +1988,7 @@ const FIELD_EXTENSIONS = {
|
|
|
1988
1988
|
type: "object", additionalProperties: false, required: ["modes", "boxes", "allow"],
|
|
1989
1989
|
properties: {
|
|
1990
1990
|
modes: { type: "array", items: { enum: [...PLACE_MODES] } },
|
|
1991
|
-
boxes: { type: "array", items: { type: "object", additionalProperties: false, required: ["id", "available", "state"], properties: { id: { enum: [...BOX_IDS] }, available: { type: "boolean" }, state: { enum: [...BOX_STATES], description: "`ready`; `preparing`, available while the server builds (or pulls) the Docker box's image at its start (a sandbox run's first box waits for it, with a timeline row); `unavailable`, with the `reason`." }, reason: { type: "string", description: "Why the box is unavailable, or what a preparing one waits for. Docker is set up by default (AGENTRUN_BOXES not set), so docker's reason says first, in plain words, what is wrong on this machine, then what to do (`Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun`); every other box AGENTRUN_BOXES does not list says the setting that lists it." }, network: { enum: [...BOX_NETWORKS], description: "What an available box reaches: `allowlist`, the hosts in `allow`, and nothing else (a Docker box through its egress proxy, on Linux with a daemon of that machine's own; a program that skips the proxy has no route; a Daytona box through Daytona's domain list, whose proxy re-signs TLS with Daytona's CA), or `none`. A Docker box's `none` comes with `network_reason`, and so does a Daytona box's when Daytona could not keep a list here (a tier that takes none); neither has one when AGENTRUN_BOX_ALLOW is `none`.", "x-agentrun-serve": "place/2" }, network_reason: { type: "string", description: "Why an available box has no network for a cause of its own, naming what the server found: a Docker in a VM, a daemon on another machine, docker info that did not answer; or a Daytona that could not keep its domain list.", "x-agentrun-serve": "place/2" } } } },
|
|
1991
|
+
boxes: { type: "array", items: { type: "object", additionalProperties: false, required: ["id", "available", "state"], properties: { id: { enum: [...BOX_IDS] }, available: { type: "boolean" }, state: { enum: [...BOX_STATES], description: "`ready`; `preparing`, available while the server builds (or pulls) the Docker box's image at its start (a sandbox run's first box waits for it, with a timeline row); `unavailable`, with the `reason`." }, reason: { type: "string", description: "Why the box is unavailable, or what a preparing one waits for. Docker is set up by default (AGENTRUN_BOXES not set), so docker's reason says first, in plain words, what is wrong on this machine, then what to do (`Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun`); every other box AGENTRUN_BOXES does not list says the setting that lists it." }, network: { enum: [...BOX_NETWORKS], description: "What an available box reaches: `allowlist`, the hosts in `allow`, and nothing else (a Docker box through its egress proxy, on Linux with a daemon of that machine's own; a program that skips the proxy has no route; a Daytona box through Daytona's domain list, whose proxy re-signs TLS with Daytona's CA), or `none`. A Docker box's `none` comes with `network_reason`, and so does a Daytona box's when Daytona could not keep a list here (a tier that takes none); neither has one when AGENTRUN_BOX_ALLOW is `none`.", "x-agentrun-serve": "place/2" }, network_reason: { type: "string", description: "Why an available box has no network for a cause of its own, naming what the server found: a Docker in a VM, a daemon on another machine, docker info that did not answer; or a Daytona that could not keep its domain list.", "x-agentrun-serve": "place/2" }, host_addresses: { type: "array", items: { type: "string" }, description: "Docker's alone, for a server in a container of its Docker's (compose.yaml) under an allow-list: the Docker host's own IP addresses its computers' egress proxy refuses as the host's, the union of what the server read through Docker's socket at its start (the host's interfaces, and host.docker.internal's on Docker Desktop or OrbStack) and AGENTRUN_DOCKER_HOST_ADDRESSES. Absent on a host, where the proxy reads the host's own." } } } },
|
|
1992
1992
|
},
|
|
1993
1993
|
description: "The places a revision may name, this host's default, each box (whether this server has it, its state: ready, preparing or unavailable, and when not, why) and the hosts a box may reach.",
|
|
1994
1994
|
"x-agentrun-serve": "place/1",
|
package/dist/page.js
CHANGED
|
@@ -11,7 +11,9 @@ import { fileURLToPath } from "node:url";
|
|
|
11
11
|
import { storeApi } from "@parcha/pi-durable-agent/serve";
|
|
12
12
|
import { ApiError } from "./errors.js";
|
|
13
13
|
import { hostRefusedPage } from "./host-check.js";
|
|
14
|
-
|
|
14
|
+
// img-src names Google's favicon service and the four hosts it redirects to: the console's Keys page shows a provider's
|
|
15
|
+
// icon from it (apps/console/src/components/ProviderIcon.tsx), sent with no referrer. Everything else is this origin's.
|
|
16
|
+
const CSP = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https://www.google.com https://t0.gstatic.com https://t1.gstatic.com https://t2.gstatic.com https://t3.gstatic.com; base-uri 'none'; form-action https://github.com; frame-ancestors 'none'";
|
|
15
17
|
const SECURITY = { "content-security-policy": CSP, "x-content-type-options": "nosniff", "referrer-policy": "no-referrer", "cache-control": "no-store" };
|
|
16
18
|
const HTML = "text/html; charset=utf-8";
|
|
17
19
|
/** Strict-Transport-Security for a server whose public address (AGENTRUN_PUBLIC_URL) is https: a browser that saw it
|
package/dist/paid-calls.js
CHANGED
|
@@ -17,7 +17,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
17
17
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
18
18
|
import { TOOL_COST, TOOL_STARTED } from "@parcha/pi-durable-agent/timeline";
|
|
19
19
|
import { BARRIER, JOURNAL_SYNCHRONOUS, syncNow } from "@parcha/pi-durable-disk";
|
|
20
|
-
import { paidCall } from "./cap.js";
|
|
20
|
+
import { paidCall, SPEND_CAP_REACHED } from "./cap.js";
|
|
21
21
|
/** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
|
|
22
22
|
* $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
|
|
23
23
|
export const PARALLEL_SEARCH_USD = 0.001;
|
|
@@ -55,7 +55,8 @@ const roomOf = (error) => {
|
|
|
55
55
|
const given = error;
|
|
56
56
|
if (given?.code !== "spend_cap_reached" || given.forGood !== false || !given.figures)
|
|
57
57
|
return undefined;
|
|
58
|
-
|
|
58
|
+
// Its code rides with it: the model request the pause refuses next is the cap's refusal (Refusal.code), never a failure.
|
|
59
|
+
return { refuse: String(given.message), code: SPEND_CAP_REACHED, forGood: false, figures: given.figures };
|
|
59
60
|
};
|
|
60
61
|
/** A paid step refused for room pauses the run, through the call's ledger (Ledger.pause), before its refusal is told. */
|
|
61
62
|
const pauseOn = async (error) => {
|
package/dist/pause.d.ts
CHANGED
|
@@ -34,8 +34,6 @@ export type NodeLine = {
|
|
|
34
34
|
error_truncated?: boolean;
|
|
35
35
|
at: string;
|
|
36
36
|
};
|
|
37
|
-
/** Appends to the run's node log; a write that fails is lost, never the run's. */
|
|
38
|
-
export declare const nodeLog: (root: string) => (line: NodeLine) => void;
|
|
39
37
|
/** The node log of the run at `root`, in order; a torn last line is left out. */
|
|
40
38
|
export declare function readNodeLog(root: string): Promise<NodeLine[]>;
|
|
41
39
|
/** The llm calls the node log says answered, in order: a run's `llmRead` counts them, and its cost reads the rest. */
|
package/dist/pause.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// Live view: `live.json`, the driver's frame and the run's decision receipts, rewritten whole by the run's process when
|
|
13
13
|
// they change. The run's process holds its store exclusively (pi-durable-disk's exclusive profile: no other connection
|
|
14
14
|
// reads it until the process exits), so this file is what GET /v2/runs/{id}/graph reads while the run goes.
|
|
15
|
-
import {
|
|
15
|
+
import { existsSync, renameSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { join } from "node:path";
|
|
17
17
|
import { RUN_CANCELLED } from "./files.js";
|
|
18
18
|
export const RUN_PAUSED = "paused";
|
|
@@ -31,13 +31,6 @@ export function gated(root, fn) {
|
|
|
31
31
|
return fn(params);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
/** Appends to the run's node log; a write that fails is lost, never the run's. */
|
|
35
|
-
export const nodeLog = (root) => (line) => {
|
|
36
|
-
try {
|
|
37
|
-
appendFileSync(join(root, NODE_LOG), `${JSON.stringify(line)}\n`, { mode: 0o600 });
|
|
38
|
-
}
|
|
39
|
-
catch { }
|
|
40
|
-
};
|
|
41
34
|
/** The node log of the run at `root`, in order; a torn last line is left out. */
|
|
42
35
|
export async function readNodeLog(root) {
|
|
43
36
|
const { readFile } = await import("node:fs/promises");
|
package/dist/place.d.ts
CHANGED
|
@@ -55,16 +55,11 @@ export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly
|
|
|
55
55
|
};
|
|
56
56
|
/** A run's place: its revision's, else the place a revision that names none resolves to here (`fallback`: defaultPlaceOf). */
|
|
57
57
|
export declare const resolvePlace: (revision: Place | undefined, fallback: Place) => Place;
|
|
58
|
-
/** The place a run kept (its serve.json), or runner for a run kept before runs had one. */
|
|
59
|
-
export declare function storedPlace(value: unknown): Place;
|
|
60
58
|
/** Where a box has the run's work/ (bound, or seeded), and where its tools start: the same in every box. */
|
|
61
59
|
export declare const BOX_WORK = "/workspace";
|
|
62
60
|
/** The boxes that cannot bind a run's work/, being on another machine: its work/ is seeded at the box's making and
|
|
63
61
|
* pulled back (run-box.ts). */
|
|
64
62
|
export declare const REMOTE_BOXES: readonly BoxId[];
|
|
65
|
-
export declare const remotePlace: (place: Place) => boolean;
|
|
66
|
-
/** The run's work/ as its agent's tools see it: on the runner, `<runDir>/work`; in any box, BOX_WORK. */
|
|
67
|
-
export declare const agentWorkDir: (runDir: string, place: Place) => string;
|
|
68
63
|
/** `place` as a definition writes it, to copy: `"place": {"mode": "sandbox", "box": "docker"}`. */
|
|
69
64
|
export declare const placeFix: (place: Place) => string;
|
|
70
65
|
/** What is wrong with `place` as a definition gives it, as issues at `field`. Each names its fix: the field to remove,
|
package/dist/place.js
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
// (newAgentPlace). A revision that names no place resolves the same way at each run (defaultPlaceOf): this server's
|
|
13
13
|
// default_place, so where docker is there now it runs in the Docker box, and the runner where it is not. A workflow, and a
|
|
14
14
|
// revision with a tool the box refuses, run on the runner.
|
|
15
|
-
import { join } from "node:path";
|
|
16
15
|
import { BOX_IDS, BOXES_ENV, VM_PROVIDER } from "./boxes.js";
|
|
17
16
|
import { sentence } from "./errors.js";
|
|
18
17
|
export const PLACE_MODES = ["runner", "sandbox"];
|
|
@@ -106,20 +105,11 @@ const stated = ({ state, network, network_reason, ...offer }) => ({
|
|
|
106
105
|
});
|
|
107
106
|
/** A run's place: its revision's, else the place a revision that names none resolves to here (`fallback`: defaultPlaceOf). */
|
|
108
107
|
export const resolvePlace = (revision, fallback) => revision ?? fallback;
|
|
109
|
-
/** The place a run kept (its serve.json), or runner for a run kept before runs had one. */
|
|
110
|
-
export function storedPlace(value) {
|
|
111
|
-
if (!isObject(value) || value.mode !== "sandbox" || !listed(BOX_IDS, value.box))
|
|
112
|
-
return { mode: "runner" };
|
|
113
|
-
return { mode: "sandbox", box: value.box };
|
|
114
|
-
}
|
|
115
108
|
/** Where a box has the run's work/ (bound, or seeded), and where its tools start: the same in every box. */
|
|
116
109
|
export const BOX_WORK = "/workspace";
|
|
117
110
|
/** The boxes that cannot bind a run's work/, being on another machine: its work/ is seeded at the box's making and
|
|
118
111
|
* pulled back (run-box.ts). */
|
|
119
112
|
export const REMOTE_BOXES = ["daytona", VM_PROVIDER.id];
|
|
120
|
-
export const remotePlace = (place) => place.mode === "sandbox" && REMOTE_BOXES.includes(place.box);
|
|
121
|
-
/** The run's work/ as its agent's tools see it: on the runner, `<runDir>/work`; in any box, BOX_WORK. */
|
|
122
|
-
export const agentWorkDir = (runDir, place) => (place.mode === "runner" ? join(runDir, "work") : BOX_WORK);
|
|
123
113
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
124
114
|
const listed = (options, value) => typeof value === "string" && options.includes(value);
|
|
125
115
|
/** `place` as a definition writes it, to copy: `"place": {"mode": "sandbox", "box": "docker"}`. */
|
package/dist/print.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function boxImageLine(state: ImageState, started: boolean): strin
|
|
|
9
9
|
export type TokenSource = "made" | "file" | "env";
|
|
10
10
|
/** The banner's lines. The token is printed only when this start made it; else where it is. `publicUrl` is the address
|
|
11
11
|
* people open (AGENTRUN_PUBLIC_URL), which the base URL and the link use. With `accounts` the page is the owner's
|
|
12
|
-
* password, so its link holds no token. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
12
|
+
* password, so its link holds no token. `apiOnly`: no console to open, so the line says what is served instead. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
13
13
|
export declare function banner(o: {
|
|
14
14
|
url: string;
|
|
15
15
|
baseUrl: string;
|
|
@@ -19,6 +19,7 @@ export declare function banner(o: {
|
|
|
19
19
|
listen?: string;
|
|
20
20
|
publicUrl?: string;
|
|
21
21
|
accounts?: boolean;
|
|
22
|
+
apiOnly?: boolean;
|
|
22
23
|
boxes?: string;
|
|
23
24
|
}): string[];
|
|
24
25
|
/** One log line. */
|
package/dist/print.js
CHANGED
|
@@ -16,7 +16,7 @@ export function boxImageLine(state, started) {
|
|
|
16
16
|
}
|
|
17
17
|
/** The banner's lines. The token is printed only when this start made it; else where it is. `publicUrl` is the address
|
|
18
18
|
* people open (AGENTRUN_PUBLIC_URL), which the base URL and the link use. With `accounts` the page is the owner's
|
|
19
|
-
* password, so its link holds no token. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
19
|
+
* password, so its link holds no token. `apiOnly`: no console to open, so the line says what is served instead. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
20
20
|
export function banner(o) {
|
|
21
21
|
const where = o.source === "env" ? "$AGENTRUN_TOKEN" : `<in ${join(o.data, ".token")}>`;
|
|
22
22
|
const key = o.source === "made" ? o.token : where;
|
|
@@ -25,7 +25,9 @@ export function banner(o) {
|
|
|
25
25
|
`AGENTRUN_BASE_URL=${o.publicUrl ? `${o.publicUrl}/v2` : o.baseUrl}`,
|
|
26
26
|
`AGENTRUN_API_KEY=${key}`,
|
|
27
27
|
// Encoded: a "+" in a token reads as a space in a query string.
|
|
28
|
-
o.
|
|
28
|
+
o.apiOnly
|
|
29
|
+
? "API only (AGENTRUN_API_ONLY=1): the run routes are served; the console, sign-in, setup, settings, MCP, triggers and hooks are refused."
|
|
30
|
+
: o.accounts ? `Open ${o.publicUrl ?? o.url}/` : `Open ${o.publicUrl ?? o.url}/?token=${o.source === "made" ? encodeURIComponent(o.token) : where}`,
|
|
29
31
|
...(o.boxes ? [o.boxes] : []),
|
|
30
32
|
];
|
|
31
33
|
}
|
package/dist/run-db.d.ts
CHANGED
|
@@ -34,8 +34,6 @@ export declare class ChangedReadError extends Error {
|
|
|
34
34
|
* run now (reported to observers).
|
|
35
35
|
*/
|
|
36
36
|
export declare function readRunDbSync<T>(file: string, held: boolean, read: (db: DatabaseSync) => T): T;
|
|
37
|
-
/** readRunDbSync, for an async caller. */
|
|
38
|
-
export declare function readRunDb<T>(file: string, held: boolean, read: (db: DatabaseSync) => T): Promise<T>;
|
|
39
37
|
/** A read of a run's database whose last entry is below one already seen for that run: an older view of the file, which a
|
|
40
38
|
* read must never show (the monotonic guard). The caller keeps what it read before. */
|
|
41
39
|
export declare class BehindReadError extends Error {
|
package/dist/run-db.js
CHANGED
|
@@ -82,10 +82,6 @@ export function readRunDbSync(file, held, read) {
|
|
|
82
82
|
throw new ChangedReadError(file, attempt);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
/** readRunDbSync, for an async caller. */
|
|
86
|
-
export async function readRunDb(file, held, read) {
|
|
87
|
-
return readRunDbSync(file, held, read);
|
|
88
|
-
}
|
|
89
85
|
/** A read of a run's database whose last entry is below one already seen for that run: an older view of the file, which a
|
|
90
86
|
* read must never show (the monotonic guard). The caller keeps what it read before. */
|
|
91
87
|
export class BehindReadError extends Error {
|
|
@@ -41,3 +41,41 @@ export declare function servedRunLearning(deps: {
|
|
|
41
41
|
detail: string | null;
|
|
42
42
|
at: string;
|
|
43
43
|
} | null>;
|
|
44
|
+
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut by the
|
|
45
|
+
* run's one cut, or ApiError forbidden for a withheld run. */
|
|
46
|
+
export declare function servedRunDiff(deps: {
|
|
47
|
+
serverSecrets: () => string[];
|
|
48
|
+
signIns?: SignInReader;
|
|
49
|
+
}, store: Store, data: string, runId: string): Promise<{
|
|
50
|
+
base: string;
|
|
51
|
+
head: string;
|
|
52
|
+
files: ({
|
|
53
|
+
path: string;
|
|
54
|
+
status: string;
|
|
55
|
+
withheld: string;
|
|
56
|
+
patch?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
path: string;
|
|
59
|
+
status: string;
|
|
60
|
+
patch: string;
|
|
61
|
+
withheld?: undefined;
|
|
62
|
+
})[];
|
|
63
|
+
} | {
|
|
64
|
+
base: string;
|
|
65
|
+
head: null;
|
|
66
|
+
files: ({
|
|
67
|
+
path: string;
|
|
68
|
+
status: string;
|
|
69
|
+
withheld: string;
|
|
70
|
+
patch?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
path: string;
|
|
73
|
+
status: string;
|
|
74
|
+
patch: string;
|
|
75
|
+
withheld?: undefined;
|
|
76
|
+
})[];
|
|
77
|
+
} | {
|
|
78
|
+
base: string | null;
|
|
79
|
+
head: null;
|
|
80
|
+
files: never[];
|
|
81
|
+
}>;
|
|
@@ -7,6 +7,7 @@ import { secretsShown } from "./learning.js";
|
|
|
7
7
|
import { runCutValues } from "./run-cut.js";
|
|
8
8
|
import { WITHHELD_SIGN_IN } from "./run-view.js";
|
|
9
9
|
import { runLearningOverStore } from "./store-reads/learning.js";
|
|
10
|
+
import { runDiffOverStore } from "./learning-routes.js";
|
|
10
11
|
/** Run `runId`'s learning as GET /runs/{id}/learning serves it, or ApiError forbidden for a withheld run. */
|
|
11
12
|
export async function servedRunLearning(deps, store, runId) {
|
|
12
13
|
const cut = await runCutValues(deps, store, runId);
|
|
@@ -14,3 +15,11 @@ export async function servedRunLearning(deps, store, runId) {
|
|
|
14
15
|
throw new ApiError("forbidden", WITHHELD_SIGN_IN);
|
|
15
16
|
return runLearningOverStore(store, runId, secretsShown(cut.values), cut.values);
|
|
16
17
|
}
|
|
18
|
+
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut by the
|
|
19
|
+
* run's one cut, or ApiError forbidden for a withheld run. */
|
|
20
|
+
export async function servedRunDiff(deps, store, data, runId) {
|
|
21
|
+
const cut = await runCutValues(deps, store, runId);
|
|
22
|
+
if (cut === "unreadable")
|
|
23
|
+
throw new ApiError("forbidden", WITHHELD_SIGN_IN);
|
|
24
|
+
return runDiffOverStore(data, store, runId, secretsShown(cut.values));
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Revision } from "@parcha/pi-durable-agent";
|
|
2
|
+
import { type Tier } from "./model.js";
|
|
3
|
+
/** The secrets a run may be handed: every one but the server's own and the decision keys, which go apart. */
|
|
4
|
+
export declare const RUN_SECRETS: string[];
|
|
5
|
+
type KeyRow = {
|
|
6
|
+
kind: string;
|
|
7
|
+
fields: readonly string[];
|
|
8
|
+
unlocks: readonly string[];
|
|
9
|
+
};
|
|
10
|
+
/** What of a revision decides the secrets its runs are handed, none of it a key, read once per revision (a revision
|
|
11
|
+
* never changes): its harness, the model it names, the tools it binds (an agentic revision's `tools`, a workflow's on
|
|
12
|
+
* its model nodes and its `call` nodes), a workflow's tiers (those its model nodes and `llm` calls run on), and its
|
|
13
|
+
* decision providers (decisions.ts' decisionKeysFor: a workflow's decision nodes', providersNamed, Jev for a node that
|
|
14
|
+
* names none; an agentic revision's, none). Names only: no instruction and no skill. */
|
|
15
|
+
export type RunNeeds = {
|
|
16
|
+
harness: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
tools: readonly string[];
|
|
19
|
+
tiers?: readonly Tier[];
|
|
20
|
+
decisionProviders: readonly string[];
|
|
21
|
+
};
|
|
22
|
+
/** `revision`'s RunNeeds. */
|
|
23
|
+
export declare function needsOf(revision: Revision): Promise<RunNeeds>;
|
|
24
|
+
/** The secrets a run of `needs` is handed, by the keys `env` holds now: RUN_SECRETS but each field of a `tool` row of
|
|
25
|
+
* `rows` (TOOL_KEYS) that unlocks none of the tools the run binds; and but each model key its model does not need, from
|
|
26
|
+
* the host's model settings and the keys in `env`: a pi run's, its models' providers' keys or the gateway's (model.ts'
|
|
27
|
+
* modelKeys: its own model, or the host's of each tier it runs); a run on an adapter's, the one key its wire's route
|
|
28
|
+
* sends for the revision's model (adapters.ts' harnessModelKeys). Read at each claim, so a key saved with no restart
|
|
29
|
+
* counts at the next. */
|
|
30
|
+
export declare function keysFor(needs: RunNeeds, env: NodeJS.ProcessEnv, rows?: readonly KeyRow[]): string[];
|
|
31
|
+
/** The secrets a run of `revision` is handed with the keys `env` holds (needsOf, then keysFor). */
|
|
32
|
+
export declare function secretsFor(revision: Revision, rows?: readonly KeyRow[], env?: NodeJS.ProcessEnv): Promise<string[]>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { harnessModelKeys } from "./adapters.js";
|
|
2
|
+
import { BOX_KEYS } from "./boxes.js";
|
|
3
|
+
import { providersNamed } from "./decisions.js";
|
|
4
|
+
import { harnessOfBody } from "./harness.js";
|
|
5
|
+
import { harnessOf } from "./harness-table.js";
|
|
6
|
+
import { GATEWAY_KEY_ENV, llmTiers, modelKeys, nodeTiers, PROVIDER_KEYS, workflowNodes } from "./model.js";
|
|
7
|
+
import { DECISION_KEYS, SECRET_NAMES } from "./secrets.js";
|
|
8
|
+
import { TOOL_KEYS } from "./tool-keys.js";
|
|
9
|
+
import { workflowTools } from "./tools.js";
|
|
10
|
+
/** The server's own secrets, which a run never gets: the API token, by name or by value, the seal key the tool keys are
|
|
11
|
+
* kept under (tool-keys.ts), the store's URL (it may hold the database's password), and the boxes' keys (boxes.ts),
|
|
12
|
+
* which only the server's box providers use. */
|
|
13
|
+
const SERVER_ONLY = new Set(["AGENTRUN_TOKEN", "AGENTRUN_API_KEY", "AGENTRUN_SEAL_KEY", "AGENTRUN_STORE_URL", ...BOX_KEYS]);
|
|
14
|
+
/** The secrets a run may be handed: every one but the server's own and the decision keys, which go apart. */
|
|
15
|
+
export const RUN_SECRETS = SECRET_NAMES.filter((name) => !SERVER_ONLY.has(name) && !DECISION_KEYS.includes(name));
|
|
16
|
+
/** The fields a run gets only when its revision names what they unlock: a `tool` key's. Any other kind's (a model key's)
|
|
17
|
+
* is the model's to need, as every model key is. */
|
|
18
|
+
const scopedOf = (rows) => rows.filter((row) => row.kind === "tool").flatMap((row) => row.fields);
|
|
19
|
+
/** The model keys: every key of pi-ai's providers (model.ts' PROVIDER_KEYS) and the gateway's. A run gets those its model
|
|
20
|
+
* needs and no other (keysFor). A workflow's decision keys, OpenRouter's among them, go apart (decisions.ts), whatever
|
|
21
|
+
* its model. */
|
|
22
|
+
const MODEL_KEYS = [...new Set([...Object.values(PROVIDER_KEYS).flat(), GATEWAY_KEY_ENV])];
|
|
23
|
+
/** `revision`'s RunNeeds. */
|
|
24
|
+
export async function needsOf(revision) {
|
|
25
|
+
const workflow = revision.kind === "workflow" ? revision.body.workflow : undefined;
|
|
26
|
+
const nodes = workflow ? workflowNodes(workflow, (await import("@parcha/agentrun-dsl")).inspectWorkflow(workflow)) : undefined;
|
|
27
|
+
const bound = nodes && workflowTools(nodes);
|
|
28
|
+
return {
|
|
29
|
+
harness: harnessOfBody(revision.body),
|
|
30
|
+
...(revision.kind === "agentic" && revision.body.model ? { model: revision.body.model } : {}),
|
|
31
|
+
tools: bound ? [...bound.nodes, ...bound.calls] : [...(revision.body.tools ?? [])],
|
|
32
|
+
...(nodes ? { tiers: llmTiers(nodes, nodeTiers(nodes)) } : {}),
|
|
33
|
+
decisionProviders: nodes ? providersNamed(nodes) : [],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The secrets a run of `needs` is handed, by the keys `env` holds now: RUN_SECRETS but each field of a `tool` row of
|
|
37
|
+
* `rows` (TOOL_KEYS) that unlocks none of the tools the run binds; and but each model key its model does not need, from
|
|
38
|
+
* the host's model settings and the keys in `env`: a pi run's, its models' providers' keys or the gateway's (model.ts'
|
|
39
|
+
* modelKeys: its own model, or the host's of each tier it runs); a run on an adapter's, the one key its wire's route
|
|
40
|
+
* sends for the revision's model (adapters.ts' harnessModelKeys). Read at each claim, so a key saved with no restart
|
|
41
|
+
* counts at the next. */
|
|
42
|
+
export function keysFor(needs, env, rows = TOOL_KEYS) {
|
|
43
|
+
const named = new Set(needs.tools);
|
|
44
|
+
const unlocked = new Set(rows.filter((row) => row.unlocks.some((name) => named.has(name))).flatMap((row) => row.fields));
|
|
45
|
+
const scoped = scopedOf(rows);
|
|
46
|
+
const entry = harnessOf(env, needs.harness);
|
|
47
|
+
const model = new Set(!entry || entry.facts ? harnessModelKeys(needs.harness, env, needs.model) : needs.tiers ? modelKeys(env, undefined, needs.tiers) : modelKeys(env, needs.model));
|
|
48
|
+
return RUN_SECRETS.filter((name) => (!scoped.includes(name) || unlocked.has(name)) && (!MODEL_KEYS.includes(name) || model.has(name)));
|
|
49
|
+
}
|
|
50
|
+
/** The secrets a run of `revision` is handed with the keys `env` holds (needsOf, then keysFor). */
|
|
51
|
+
export async function secretsFor(revision, rows = TOOL_KEYS, env = process.env) {
|
|
52
|
+
return keysFor(await needsOf(revision), env, rows);
|
|
53
|
+
}
|
|
@@ -6,7 +6,7 @@ import { answersOf, asksOf, shownOf, withApprovalRows, withAsks } from "./run-vi
|
|
|
6
6
|
import { journalRecords } from "./runner/journal-reader.js";
|
|
7
7
|
import { decisionsOverStore } from "./store-reads/decisions.js";
|
|
8
8
|
import { readRun } from "./store-reads/runs.js";
|
|
9
|
-
import { runTimeline } from "./store-reads/journal.js";
|
|
9
|
+
import { runTimeline, wholeAnswerFor, wholeAnswers } from "./store-reads/journal.js";
|
|
10
10
|
import { FINAL_STATES } from "./store/store.js";
|
|
11
11
|
/** Run `runId`'s Timeline rows as served: cut by its one cut set, its decision rows among them, its error rows in the
|
|
12
12
|
* run's error's words; none for a run withheld. */
|
|
@@ -27,7 +27,10 @@ export async function servedTimelineRows(deps, store, runId, context) {
|
|
|
27
27
|
// A question the agent asked (ask_person) and waits on: its waiting row after the call's result (run-view.ts withAsks), as
|
|
28
28
|
// the run's view carries it and main's served Timeline did, so the console's "The agent asks" box reads that question,
|
|
29
29
|
// never an earlier wait's words.
|
|
30
|
-
|
|
30
|
+
// Its final answer whole, as the run's view serves it (store-reads/journal.ts wholeAnswers): a row's cut is no answer's.
|
|
31
|
+
const options = { redact };
|
|
32
|
+
const timeline = await wholeAnswers(store, runId, context, await runTimeline(store, runId, context, options), options, wholeAnswerFor(values));
|
|
33
|
+
const rows = withApprovalRows(withAsks(timeline), asksOf(records.entries), answersOf(records.entries, { final }), redact);
|
|
31
34
|
// A workflow's decisions: their rows among the model nodes' by time, each text shown through the cut set, with as many
|
|
32
35
|
// characters held back from a text stored cut as a held value takes in its widest form (main's decisionShown).
|
|
33
36
|
const receipts = await decisionsOverStore(store, runId, context).catch(() => null);
|
package/dist/run-view.d.ts
CHANGED
|
@@ -48,14 +48,9 @@ export declare const overByMiss: (usd: number, cap: number, bound: number) => bo
|
|
|
48
48
|
* so a run can pass its cap by its last request. The next request is then refused. `bound`: the requests' that ended since the cost last fit,
|
|
49
49
|
* bound; when the run passed its cap by no more than it, the row says a cache miss did it, and the most it could have. */
|
|
50
50
|
export declare function withOverCap(rows: TimelineEvent[], cap: number | undefined, bound?: number): TimelineEvent[];
|
|
51
|
-
/** The row of a refusal for room a run paused at (servedError): the server's `phase` row in these words (origin server,
|
|
52
|
-
* its id the refusal's with NOTE_SUFFIX, so it is no message: isMessageRow), marked `paused`, never an error row. The
|
|
53
|
-
* refusal's sentence is the pause's (pending.said), which a client shows once, as its banner. */
|
|
54
|
-
export declare const BUDGET_PAUSED = "Paused at the run's cap";
|
|
55
51
|
/** The waiting row of a run paused at its cap, after the refusal's row: "Waiting for you to raise the cap", and no
|
|
56
52
|
* more: the refusal's words are the pause's (pending.said), which a client shows once, as its banner. */
|
|
57
53
|
export declare const BUDGET_WAITING = "Waiting for you to raise the cap";
|
|
58
|
-
export declare function withPaused(rows: readonly TimelineEvent[]): TimelineEvent[];
|
|
59
54
|
/** The waiting row after each answered `ask_person` call, which the timeline module does not know. The question comes from
|
|
60
55
|
* the call's row, whose label this module registers. The server fed its rows through this; the store-backed view feeds the
|
|
61
56
|
* same rows through it, so a run waiting on a question reads the same pending. */
|
|
@@ -332,7 +327,8 @@ export interface RunMoment {
|
|
|
332
327
|
readonly pausedWords?: string;
|
|
333
328
|
/** The run is paused at its cap (pausedAt): raising the cap resumes it. */
|
|
334
329
|
readonly paused: boolean;
|
|
335
|
-
/** The run has a live process now (a runner holds its claim): a raise's cap holds from its next
|
|
330
|
+
/** The run has a live process now (a runner holds its claim): a raise's cap holds from its next step, not the one under
|
|
331
|
+
* way. */
|
|
336
332
|
readonly live: boolean;
|
|
337
333
|
/** A message that may not answer a person (a trigger's) is refused while the run waits on one, before anything else. */
|
|
338
334
|
readonly waitsOnPerson: boolean;
|
|
@@ -352,6 +348,9 @@ export interface RunMoment {
|
|
|
352
348
|
export declare function momentOf(run: RunView, facts: RunFacts, live: boolean): RunMoment;
|
|
353
349
|
/** An ended run's words, withheld while this server can't read the sign-in it was handed (load). */
|
|
354
350
|
export declare const WITHHELD_SIGN_IN = "This server can't read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged), so nothing the run said is shown.";
|
|
351
|
+
/** Why a run is refused at its claim: the browser sign-in it was handed can't be read here (the seal key changed or is
|
|
352
|
+
* missing, or the sign-in is damaged). */
|
|
353
|
+
export declare const UNREADABLE_SIGN_IN = "This server can't read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged): the run was stopped, so nothing it says can show it.";
|
|
355
354
|
/** A withheld run's title: a short line that fits the title's length and holds nothing the run said, so a title that
|
|
356
355
|
* repeats the handed sign-in is never served when this server can't cut it. The full sentence stays in the run's error
|
|
357
356
|
* and review. */
|
|
@@ -364,9 +363,6 @@ export type Handed = string[] | typeof MALFORMED;
|
|
|
364
363
|
/** A run's `sign_in_handed` as read from its serve.json: undefined when absent (never handed one); the hashes it names;
|
|
365
364
|
* MALFORMED for any other value. */
|
|
366
365
|
export declare function handedMark(value: unknown): Handed | undefined;
|
|
367
|
-
/** Every secret value a run's errors never show, as learning's checker holds them: every one this server never shows
|
|
368
|
-
* (serverSecrets, read now, so one rotated is cut at once) and what each launch handed the run. */
|
|
369
|
-
export declare const refusedValuesOf: (serverSecrets: () => string[], handed: ReadonlySet<string> | undefined) => string[];
|
|
370
366
|
/** A run's redactor (decision-rows.ts, tool previews): redacted over its refused values. */
|
|
371
367
|
export declare const redactorOf: (values: string[]) => (text: string) => string;
|
|
372
368
|
/** What serve shows of a run's error text, for every run kind: no held secret (redacted, key-refusal.ts' one rule) and
|
package/dist/run-view.js
CHANGED
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
// The pieces here so far: the cost reads (a run's cost, its paid tools' charges, the cost a view shows, what it has cost so
|
|
7
7
|
// far when the total is unknown) and the served row transforms a view applies to the timeline (the over-cap row, the
|
|
8
8
|
// paused run's waiting row). All read the same rows the timeline renders.
|
|
9
|
-
import {
|
|
9
|
+
import { chargedTool, isMessageRow, registerLabel, registerTurnEnding, scrubUrls } from "@parcha/pi-durable-agent/timeline";
|
|
10
10
|
import { CAP_TOLERANCE, FIT_TOLERANCE, money, roomRefusal } from "./cap.js";
|
|
11
|
-
import { servedOnly } from "./served-only.js";
|
|
12
11
|
import { APPROVAL_ROW, previewOf } from "./tool-gate.js";
|
|
13
12
|
import { ASK_TOOL } from "./tools.js";
|
|
14
13
|
import { LEARNING_LABEL } from "./learning.js";
|
|
@@ -85,26 +84,9 @@ export function withOverCap(rows, cap, bound = 0) {
|
|
|
85
84
|
const over = { ...usage, id: `${usage.id}:over_cap`, kind: "phase", summary, text: null };
|
|
86
85
|
return [...rows.slice(0, at + 1), over, ...rows.slice(at + 1)];
|
|
87
86
|
}
|
|
88
|
-
/** The row of a refusal for room a run paused at (servedError): the server's `phase` row in these words (origin server,
|
|
89
|
-
* its id the refusal's with NOTE_SUFFIX, so it is no message: isMessageRow), marked `paused`, never an error row. The
|
|
90
|
-
* refusal's sentence is the pause's (pending.said), which a client shows once, as its banner. */
|
|
91
|
-
export const BUDGET_PAUSED = "Paused at the run's cap";
|
|
92
87
|
/** The waiting row of a run paused at its cap, after the refusal's row: "Waiting for you to raise the cap", and no
|
|
93
88
|
* more: the refusal's words are the pause's (pending.said), which a client shows once, as its banner. */
|
|
94
89
|
export const BUDGET_WAITING = "Waiting for you to raise the cap";
|
|
95
|
-
export function withPaused(rows) {
|
|
96
|
-
const at = rows.findLastIndex((row) => row.paused === true);
|
|
97
|
-
if (at < 0)
|
|
98
|
-
return [...rows];
|
|
99
|
-
// The refusal's own marker (`paused`, servedError) and the server's origin stay on the refusal's row: the waiting row
|
|
100
|
-
// is no refusal and no row of the server's, and keeps the id it had, the refusal's own with ":paused".
|
|
101
|
-
const { paused: _marker, origin: _origin, ...refusal } = rows[at];
|
|
102
|
-
const own = refusal.id.endsWith(NOTE_SUFFIX) ? refusal.id.slice(0, -NOTE_SUFFIX.length) : refusal.id;
|
|
103
|
-
// Only the served view makes it (servedOnly): once the run is raised, show() stops making it and it goes, even while a
|
|
104
|
-
// live process feeds the timeline (keepCommitted).
|
|
105
|
-
const paused = servedOnly({ ...refusal, id: `${own}:paused`, kind: "waiting", summary: BUDGET_WAITING, text: BUDGET_WAITING, tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null });
|
|
106
|
-
return [...rows.slice(0, at + 1), paused, ...rows.slice(at + 1)];
|
|
107
|
-
}
|
|
108
90
|
/** A text clipped to `max` characters, with an ellipsis where it is cut (runs.ts' clip). */
|
|
109
91
|
const clip = (text, max) => (text.length > max ? `${text.slice(0, max - 1)}…` : text);
|
|
110
92
|
const ASKED = "Asked you: ";
|
|
@@ -465,6 +447,9 @@ export function momentOf(run, facts, live) {
|
|
|
465
447
|
// point: a run whose summary holds a handed pointer serves it cut, and an unreadable handed hash withholds it (rowShown). ---
|
|
466
448
|
/** An ended run's words, withheld while this server can't read the sign-in it was handed (load). */
|
|
467
449
|
export const WITHHELD_SIGN_IN = "This server can't read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged), so nothing the run said is shown.";
|
|
450
|
+
/** Why a run is refused at its claim: the browser sign-in it was handed can't be read here (the seal key changed or is
|
|
451
|
+
* missing, or the sign-in is damaged). */
|
|
452
|
+
export const UNREADABLE_SIGN_IN = "This server can't read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged): the run was stopped, so nothing it says can show it.";
|
|
468
453
|
/** A withheld run's title: a short line that fits the title's length and holds nothing the run said, so a title that
|
|
469
454
|
* repeats the handed sign-in is never served when this server can't cut it. The full sentence stays in the run's error
|
|
470
455
|
* and review. */
|
|
@@ -482,9 +467,6 @@ export function handedMark(value) {
|
|
|
482
467
|
return [...new Set(value)];
|
|
483
468
|
return MALFORMED;
|
|
484
469
|
}
|
|
485
|
-
/** Every secret value a run's errors never show, as learning's checker holds them: every one this server never shows
|
|
486
|
-
* (serverSecrets, read now, so one rotated is cut at once) and what each launch handed the run. */
|
|
487
|
-
export const refusedValuesOf = (serverSecrets, handed) => [...serverSecrets(), ...(handed ?? [])];
|
|
488
470
|
/** A run's redactor (decision-rows.ts, tool previews): redacted over its refused values. */
|
|
489
471
|
export const redactorOf = (values) => (text) => redacted(text, values);
|
|
490
472
|
/** What serve shows of a run's error text, for every run kind: no held secret (redacted, key-refusal.ts' one rule) and
|
|
@@ -77,14 +77,16 @@ export interface AdapterRunSpec {
|
|
|
77
77
|
* gives capUsd: () => undefined. */
|
|
78
78
|
readonly runCap: RunCapConfig;
|
|
79
79
|
/** The run's cap, when it has one (filled from the run's launch): its figure, and what a refusal does to the run (the
|
|
80
|
-
* kernel cap's parkOf: parked with a pending budget for a refusal a raise could fix, else failed in its words)
|
|
80
|
+
* kernel cap's parkOf: parked with a pending budget for a refusal a raise could fix, else failed in its words), at the
|
|
81
|
+
* cap the run is held to when it parks (`capUsd`: the newest raise's, else the launch's), which its pending budget
|
|
82
|
+
* names and the next raise is checked against. */
|
|
81
83
|
readonly cap?: {
|
|
82
84
|
readonly capUsd: number;
|
|
83
85
|
park(refusal: {
|
|
84
86
|
message: string;
|
|
85
87
|
forGood: boolean;
|
|
86
88
|
figures?: Refusal["figures"];
|
|
87
|
-
}): {
|
|
89
|
+
}, capUsd: number): {
|
|
88
90
|
outcome: "parked";
|
|
89
91
|
pending: BudgetData["pending"];
|
|
90
92
|
words: string;
|
|
@@ -188,6 +190,10 @@ export type AdapterRun = PiRun & {
|
|
|
188
190
|
* spec's per-claim resources let go of what they hold at once on it (the run's Archil mount credential). Absent where
|
|
189
191
|
* no loop gave one (a spec built alone). */
|
|
190
192
|
readonly signal?: AbortSignal;
|
|
193
|
+
/** The claim's signal, also aborted by any stop of the run (a person's stop or cancel among them): what a spec waits on
|
|
194
|
+
* while it is built (a CLI harness's first-use install), so a stop ends that wait at once and never the work it waits
|
|
195
|
+
* for. Absent where no loop gave one. */
|
|
196
|
+
readonly stopped?: AbortSignal;
|
|
191
197
|
/** Stages the run row's `summary` on the next commit of this pass that writes a root entry of `kind` whose data `test`
|
|
192
198
|
* takes, in that commit (a tool host's wait on the person, its claim held: the server tells run.needs_input by the
|
|
193
199
|
* summary). Absent where no loop gave one. */
|