@parcha/agentrun-serve 0.1.0-beta.61 → 0.1.0-beta.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +102 -13
- package/dist/api-only.d.ts +4 -0
- package/dist/api-only.js +5 -1
- package/dist/archil-settings.d.ts +9 -0
- package/dist/archil-settings.js +8 -1
- package/dist/bash-read-only.d.ts +3 -0
- package/dist/bash-read-only.js +6 -3
- package/dist/chatgpt-plan.d.ts +26 -8
- package/dist/chatgpt-plan.js +89 -21
- package/dist/claude-login.d.ts +12 -5
- package/dist/claude-login.js +28 -3
- package/dist/cli.js +19 -8
- package/dist/composio-triggers.d.ts +9 -3
- package/dist/computers.d.ts +3 -0
- package/dist/computers.js +2 -1
- package/dist/console/assets/{backend-C9ffXUR5.js → backend-DEgVn5lC.js} +1 -1
- package/dist/console/assets/index-CG5tELph.js +639 -0
- package/dist/console/assets/share-CIeFK2Oe.js +6 -0
- package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/cut-pool.d.ts +14 -0
- package/dist/cut-pool.js +98 -0
- package/dist/cut-worker.d.ts +14 -0
- package/dist/cut-worker.js +16 -0
- package/dist/decisions.d.ts +4 -0
- package/dist/decisions.js +9 -1
- package/dist/env-switch.d.ts +3 -0
- package/dist/env-switch.js +3 -0
- package/dist/harness-table.d.ts +7 -0
- package/dist/harness-table.js +6 -3
- package/dist/import.d.ts +8 -1
- package/dist/import.js +36 -5
- package/dist/key-check.js +22 -8
- package/dist/learned-nodes.d.ts +2 -1
- package/dist/learned-nodes.js +2 -1
- package/dist/mcp-gateway.d.ts +24 -0
- package/dist/mcp-gateway.js +97 -8
- package/dist/mcp-servers-store.d.ts +7 -10
- package/dist/mcp-servers-store.js +15 -9
- package/dist/native/cli.js +5 -1
- package/dist/ollama-provider.d.ts +10 -3
- package/dist/ollama-provider.js +17 -7
- package/dist/openapi.js +29 -12
- package/dist/otel/tracer.d.ts +6 -3
- package/dist/otel/tracer.js +24 -6
- package/dist/page.d.ts +7 -0
- package/dist/page.js +17 -4
- package/dist/place.d.ts +25 -9
- package/dist/place.js +37 -11
- package/dist/print.d.ts +3 -2
- package/dist/print.js +8 -6
- package/dist/run-launch.js +16 -3
- package/dist/run-model-key.d.ts +2 -1
- package/dist/run-model-key.js +2 -1
- package/dist/run-reads-over-store.d.ts +7 -0
- package/dist/run-reads-over-store.js +32 -4
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +16 -6
- package/dist/runner/adapter-loop.js +64 -25
- package/dist/runner/adapter-run-spec.d.ts +6 -1
- package/dist/runner/adapter-run-spec.js +14 -11
- package/dist/runner/adapters/index.d.ts +4 -0
- package/dist/runner/adapters/index.js +2 -1
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +18 -7
- package/dist/runner/cli-run-spec.js +12 -8
- package/dist/runner/dispatch.js +2 -0
- package/dist/runner/harness-loops.d.ts +5 -0
- package/dist/runner/harness-loops.js +4 -1
- package/dist/runner/live-ticker.js +3 -1
- package/dist/runner/loop-contract.d.ts +4 -1
- package/dist/runner/mcp-run.d.ts +5 -0
- package/dist/runner/mcp-run.js +18 -0
- package/dist/runner/meta-tools.js +4 -4
- package/dist/runner/metrics.d.ts +4 -2
- package/dist/runner/metrics.js +5 -3
- package/dist/runner/native-loop.js +2 -2
- package/dist/runner/run-child-host.d.ts +10 -6
- package/dist/runner/run-child-host.js +44 -29
- package/dist/runner/run-child.js +1 -0
- package/dist/runner/runner.js +2 -0
- package/dist/runner/workflow-calls.d.ts +4 -3
- package/dist/runner/workflow-calls.js +41 -12
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/secret-rules.d.ts +0 -1
- package/dist/secret-rules.js +25 -5
- package/dist/server.d.ts +10 -1
- package/dist/server.js +114 -38
- package/dist/share-host.d.ts +111 -0
- package/dist/share-host.js +666 -0
- package/dist/store-reads/analytics.d.ts +15 -0
- package/dist/store-reads/analytics.js +17 -0
- package/dist/suggestions.js +32 -3
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +7 -3
- package/dist/tool-gate.d.ts +25 -9
- package/dist/tool-gate.js +58 -19
- package/dist/tool-plane.d.ts +1 -0
- package/dist/tool-plane.js +6 -2
- package/dist/trigger-composio.js +1 -1
- package/dist/webhooks.d.ts +3 -0
- package/dist/webhooks.js +5 -0
- package/dist/workspace/archil-claim.d.ts +7 -3
- package/dist/workspace/archil-claim.js +13 -5
- package/dist/workspace/archil-mount-credential.d.ts +6 -0
- package/dist/workspace/archil-mount-credential.js +11 -0
- package/dist/workspace/computer-deps.d.ts +5 -3
- package/dist/workspace/computer-deps.js +11 -9
- package/dist/workspace/computer-for-claim.d.ts +6 -2
- package/dist/workspace/computer-for-claim.js +43 -12
- package/dist/workspace/computer-janitor.d.ts +7 -4
- package/dist/workspace/computer-janitor.js +7 -4
- package/dist/workspace/computer-kept.d.ts +7 -1
- package/dist/workspace/computer-kept.js +7 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
- package/dist/workspace/mount-revoke-left.d.ts +16 -4
- package/dist/workspace/mount-revoke-left.js +42 -22
- package/dist/workspace/resolve-computer.d.ts +11 -5
- package/dist/workspace/resolve-computer.js +22 -13
- package/dist/workspace/run-end-computers.js +1 -1
- package/dist/workspace/run-tools.d.ts +10 -3
- package/dist/workspace/run-tools.js +5 -4
- package/dist/wrapped.d.ts +29 -2
- package/dist/wrapped.js +20 -3
- package/launcher/agentrun-serve +1 -1
- package/package.json +12 -12
- package/dist/console/assets/index-BnZV3lvW.js +0 -639
- package/dist/console/assets/share-B1o5mJ56.js +0 -6
- /package/dist/console/assets/{styles-D_znYrHR.js → styles-BGZxYkky.js} +0 -0
package/dist/place.js
CHANGED
|
@@ -17,9 +17,22 @@
|
|
|
17
17
|
// now it runs in the Docker box, and where it is not its run is refused in the same words. A workflow, a revision whose
|
|
18
18
|
// tools need no shell, and one with a tool the box refuses run on the runner. In Mode 2 (the runner's shell is Archil's
|
|
19
19
|
// serverless exec) the default is the runner, Docker answering or not: Mode 2 keeps the run's folder on Archil, which
|
|
20
|
-
// Docker's box can't mount, so a run given that box would only be refused.
|
|
20
|
+
// Docker's box can't mount, so a run given that box would only be refused. In Mode 2 on an Archil region with no
|
|
21
|
+
// serverless exec there is no default at all: the runner has no shell and Docker's box can't mount Archil, so a new
|
|
22
|
+
// agent with a shell tool names a sandbox computer (noExecIssue), Docker answering or not.
|
|
23
|
+
import { noExecWords } from "./archil-settings.js";
|
|
21
24
|
import { BOX_IDS, BOXES_ENV, DEFAULT_BOX } from "./place-offers.js";
|
|
22
25
|
import { sentence } from "./errors.js";
|
|
26
|
+
/** What a new agent with a shell tool and no computer sets on a Mode 2 server whose Archil region has no exec. */
|
|
27
|
+
const NO_EXEC_FIX = "Give the agent a sandbox computer (a box): set computer to {kind: sandbox, provider: <a sandbox provider in Settings → Computers>}; or leave bash out of its tools.";
|
|
28
|
+
/** The refusal of a new agent with a shell tool and no computer, at its save or deploy, on a Mode 2 server whose Archil
|
|
29
|
+
* region `region` has no serverless exec (RunnerShell `noExec`): it names a sandbox computer, never Docker's box. */
|
|
30
|
+
export const noExecIssue = (region) => ({
|
|
31
|
+
field: "definition.computer",
|
|
32
|
+
reason: "missing",
|
|
33
|
+
message: `name a sandbox computer: ${noExecWords(region)}, so a run with no computer has no shell, and the docker box can't mount Archil. ${NO_EXEC_FIX}`,
|
|
34
|
+
fix: NO_EXEC_FIX,
|
|
35
|
+
});
|
|
23
36
|
export const PLACE_MODES = ["runner", "sandbox"];
|
|
24
37
|
/** Every box, from what this server found at its start (place-offers.ts): one it did not find is not set up. */
|
|
25
38
|
export function boxAvailability(registry) {
|
|
@@ -58,10 +71,11 @@ export function newAgentPlace(registry) {
|
|
|
58
71
|
* (newAgentPlace) for an agentic revision with a tool that runs only in a box (`flags`, tools.ts: bash and the
|
|
59
72
|
* background tools); the runner for a workflow, which is never given a box, for one whose tools need no shell (none, or
|
|
60
73
|
* only read and write: a container would only hold up its start), and for one that names a tool the box refuses (the
|
|
61
|
-
* browser, runner-only for now).
|
|
62
|
-
*
|
|
74
|
+
* browser, runner-only for now). In Mode 2 (`runnerShell` not false), the runner for every revision: Docker's box can't
|
|
75
|
+
* mount the folder Mode 2 keeps on Archil. Where the runner has no shell there either (`noExec`), a shell tool's agent
|
|
76
|
+
* is refused at its save (noBoxRefusal) and its run (runnable.ts), never given Docker's box. */
|
|
63
77
|
export function defaultPlaceOf(kind, tools, registry, flags, runnerShell) {
|
|
64
|
-
if (kind === "workflow" || runnerShell || !wantsBox(tools, flags))
|
|
78
|
+
if (kind === "workflow" || runnerShell !== false || !wantsBox(tools, flags))
|
|
65
79
|
return { mode: "runner" };
|
|
66
80
|
const fresh = newAgentPlace(registry);
|
|
67
81
|
return "place" in fresh ? fresh.place : { mode: "runner" };
|
|
@@ -76,10 +90,15 @@ const wantsBox = (tools, flags) => {
|
|
|
76
90
|
* save it, where it would be given the default box (it names no tools, `tools` undefined, so it would get a shell, or a
|
|
77
91
|
* tool that runs only in a box) and this server does not have Docker's box, and where the runner has no shell
|
|
78
92
|
* (`runnerShell` false: Mode 1). On Mode 2 the runner's exec is a shell, and such a definition saves for the runner as
|
|
79
|
-
* it always did, its tools checked there (runnable.ts)
|
|
93
|
+
* it always did, its tools checked there (runnable.ts); on a Mode 2 region with no exec (`noExec`) there is no shell
|
|
94
|
+
* for a shell tool it names, Docker answering or not: it names a sandbox computer (noExecIssue). One that names no tools
|
|
95
|
+
* is saved on Mode 2's runner with none (server.ts defaultToolsAt), so it has no shell tool to refuse. Undefined for one
|
|
96
|
+
* that saves. */
|
|
80
97
|
export function noBoxRefusal(tools, registry, flags, runnerShell) {
|
|
81
|
-
if (runnerShell || !wantsBox(tools ?? NEW_AGENT_TOOLS, flags))
|
|
98
|
+
if (runnerShell === true || !wantsBox(tools ?? (runnerShell === false ? NEW_AGENT_TOOLS : []), flags))
|
|
82
99
|
return undefined;
|
|
100
|
+
if (runnerShell !== false)
|
|
101
|
+
return noExecIssue(runnerShell.noExec);
|
|
83
102
|
const fresh = newAgentPlace(registry);
|
|
84
103
|
return "reason" in fresh ? noPlaceIssue(registry) : undefined;
|
|
85
104
|
}
|
|
@@ -114,8 +133,10 @@ export function noBoxReason(registry, listed) {
|
|
|
114
133
|
* AGENTRUN_BOXES lists (`listed`), and, when none is ready, the boxes it does not list, with what to do.
|
|
115
134
|
* `byDefault`, with AGENTRUN_BOXES not set at all: short, the local box alone, said to be on by default, or why it is
|
|
116
135
|
* not, and where a new agent with no place goes then: it names its place, or, where the runner has a shell
|
|
117
|
-
* (`runnerShell`: Mode 2), it runs on the runner (placesOf).
|
|
136
|
+
* (`runnerShell`: Mode 2), it runs on the runner (placesOf). On a Mode 2 region with no exec (`noExec`), every form says
|
|
137
|
+
* a new agent with bash names a sandbox computer, and why. */
|
|
118
138
|
export function boxesLine(registry, listed, allow = "none", byDefault = false, runnerShell = false) {
|
|
139
|
+
const noExec = typeof runnerShell === "object" ? [`A new agent with bash names a sandbox computer (a box), or leaves bash out: ${noExecWords(runnerShell.noExec)}, and Mode 2 keeps workspaces on Archil, which the docker box can't mount.`] : [];
|
|
119
140
|
const boxes = boxAvailability(registry);
|
|
120
141
|
const ready = boxes.filter((box) => box.available).map((box) => box.id);
|
|
121
142
|
const said = ready.length ? [`${and(ready)} ${ready.length === 1 ? "is" : "are"} ready, so sandbox agents run their tools there.`] : [];
|
|
@@ -127,21 +148,26 @@ export function boxesLine(registry, listed, allow = "none", byDefault = false, r
|
|
|
127
148
|
const reach = boxes.filter((box) => box.available && box.network).map((box) => box.network === "allowlist" ? sentence(`${box.id} boxes reach only ${hosts}`) : sentence(`${box.id} boxes have no network${box.network_reason ? `: ${box.network_reason}` : ""}`));
|
|
128
149
|
if (byDefault) {
|
|
129
150
|
const box = defaultBox(registry);
|
|
151
|
+
if (!box?.available && noExec.length)
|
|
152
|
+
return [`Boxes: none.`, ...noExec, sentence(box?.reason ?? NO_REASON)].join(" ");
|
|
130
153
|
if (!box?.available)
|
|
131
154
|
return `Boxes: none, so ${runnerShell ? "new agents run on the runner" : "a new agent must name its place: a box, or the runner"}. ${sentence(box?.reason ?? NO_REASON)}`;
|
|
132
|
-
return [`Boxes: ${box.id} (on by default; set ${BOXES_ENV} to change).`, ...(runnerShell ? [`New agents run on the runner: Mode 2 keeps workspaces on Archil, which the ${box.id} box can't mount.`] :
|
|
155
|
+
return [`Boxes: ${box.id} (on by default; set ${BOXES_ENV} to change).`, ...(runnerShell === true ? [`New agents run on the runner: Mode 2 keeps workspaces on Archil, which the ${box.id} box can't mount.`] : noExec), ...reach].join(" ");
|
|
133
156
|
}
|
|
134
|
-
return ["Boxes:", ...(none ? ["none is ready, so sandbox agents do not run here."] : said), ...reach, ...why.map((box) => sentence(`${box.id}: ${box.reason ?? "not available"}`)), ...(rest ? [sentence(rest)] : [])].join(" ");
|
|
157
|
+
return ["Boxes:", ...(none ? ["none is ready, so sandbox agents do not run here."] : said), ...noExec, ...reach, ...why.map((box) => sentence(`${box.id}: ${box.reason ?? "not available"}`)), ...(rest ? [sentence(rest)] : [])].join(" ");
|
|
135
158
|
}
|
|
136
159
|
/** `places` in capabilities: the modes a revision may name, the place a new agent is saved with and a revision that
|
|
137
160
|
* names none runs in (`default_place`), each box, and the hosts a box whose `network` is `allowlist` reaches (`allow`,
|
|
138
161
|
* box-settings.ts boxAllowOf; empty for `none`). `default_place` is the runner where it has a shell (`runnerShell`:
|
|
139
162
|
* Mode 2's Archil exec), Docker answering or not (defaultPlaceOf); else Docker's box where this server has it; else
|
|
140
163
|
* null, no default: a new agent names its place, and `default_reason` is the words a no-place create is refused in
|
|
141
|
-
* (noBoxRefusal).
|
|
164
|
+
* (noBoxRefusal). On a Mode 2 region with no exec (`noExec`) it is null, Docker answering or not, and `default_reason`
|
|
165
|
+
* says to name a sandbox computer (noExecIssue). `default_reason` is there exactly when `default_place` is null. */
|
|
142
166
|
export const placesOf = (registry, allow = "none", runnerShell = false) => {
|
|
143
167
|
const fresh = newAgentPlace(registry);
|
|
144
|
-
const byDefault = runnerShell ? { default_place: { mode: "runner" } }
|
|
168
|
+
const byDefault = runnerShell === true ? { default_place: { mode: "runner" } }
|
|
169
|
+
: runnerShell !== false ? { default_place: null, default_reason: noExecIssue(runnerShell.noExec).message }
|
|
170
|
+
: "place" in fresh ? { default_place: fresh.place } : { default_place: null, default_reason: fresh.reason };
|
|
145
171
|
return { modes: [...PLACE_MODES], ...byDefault, boxes: boxAvailability(registry).map(stated), allow: allow === "none" ? [] : [...allow] };
|
|
146
172
|
};
|
|
147
173
|
/** A box with its state, `ready` when it is available and `unavailable` when not; and, on an available box, its network as the server set it, with
|
package/dist/print.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export type TokenSource = "made" | "file" | "env" | "list";
|
|
|
6
6
|
* people open (AGENTRUN_PUBLIC_URL), which the base URL and the link use. With `accounts` the page is the owner's
|
|
7
7
|
* password, so its link holds nothing; with none, the link holds this start's launch code (`launchCode`), never the
|
|
8
8
|
* token. `tokenIds`: the ids of the tokens the server takes (api-token.ts), named when there is more than one or a list
|
|
9
|
-
* gave them, never a secret. `apiOnly`: no console to open, so the line says what is served instead. `
|
|
10
|
-
* words (Serve's boxesLine), last. */
|
|
9
|
+
* gave them, never a secret. `apiOnly`: no console to open, so the line says what is served instead. `shareHost`: the
|
|
10
|
+
* same, and its API is under /r/v2. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
11
11
|
export declare function banner(o: {
|
|
12
12
|
url: string;
|
|
13
13
|
baseUrl: string;
|
|
@@ -19,6 +19,7 @@ export declare function banner(o: {
|
|
|
19
19
|
publicUrl?: string;
|
|
20
20
|
accounts?: boolean;
|
|
21
21
|
apiOnly?: boolean;
|
|
22
|
+
shareHost?: boolean;
|
|
22
23
|
launchCode?: string;
|
|
23
24
|
boxes?: string;
|
|
24
25
|
}): string[];
|
package/dist/print.js
CHANGED
|
@@ -5,19 +5,21 @@ import { join } from "node:path";
|
|
|
5
5
|
* people open (AGENTRUN_PUBLIC_URL), which the base URL and the link use. With `accounts` the page is the owner's
|
|
6
6
|
* password, so its link holds nothing; with none, the link holds this start's launch code (`launchCode`), never the
|
|
7
7
|
* token. `tokenIds`: the ids of the tokens the server takes (api-token.ts), named when there is more than one or a list
|
|
8
|
-
* gave them, never a secret. `apiOnly`: no console to open, so the line says what is served instead. `
|
|
9
|
-
* words (Serve's boxesLine), last. */
|
|
8
|
+
* gave them, never a secret. `apiOnly`: no console to open, so the line says what is served instead. `shareHost`: the
|
|
9
|
+
* same, and its API is under /r/v2. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
|
|
10
10
|
export function banner(o) {
|
|
11
11
|
const where = o.source === "env" ? "$AGENTRUN_TOKEN" : o.source === "list" ? "<a secret in $AGENTRUN_TOKENS>" : `<in ${join(o.data, ".token")}>`;
|
|
12
12
|
const key = o.source === "made" ? o.token : where;
|
|
13
13
|
return [
|
|
14
14
|
`agentrun-serve on ${o.baseUrl} (agent store in ${o.data}${o.listen ? `, listening on ${o.listen}` : ""})`,
|
|
15
|
-
`AGENTRUN_BASE_URL=${o.publicUrl ? `${o.publicUrl}/v2` : o.baseUrl}`,
|
|
15
|
+
`AGENTRUN_BASE_URL=${o.shareHost ? `${o.publicUrl ?? o.url}/r/v2` : o.publicUrl ? `${o.publicUrl}/v2` : o.baseUrl}`,
|
|
16
16
|
`AGENTRUN_API_KEY=${key}`,
|
|
17
17
|
...(o.tokenIds && (o.tokenIds.length > 1 || o.source === "list") ? [`API tokens taken (ids): ${o.tokenIds.join(", ")}`] : []),
|
|
18
|
-
o.
|
|
19
|
-
?
|
|
20
|
-
: o.
|
|
18
|
+
o.shareHost
|
|
19
|
+
? `Share host (--share-host): shares at ${o.publicUrl ?? o.url}/r/<id>; uploads to /r/v2/shares take a token and are re-scrubbed; every other address is a 404, and no runner, model key or computer runs here.`
|
|
20
|
+
: o.apiOnly
|
|
21
|
+
? "API only (AGENTRUN_API_ONLY=1): the run and deploy routes, a trigger's reads and its turn on or off, the MCP server names, a Composio server's save, a per_run server's save at an origin AGENTRUN_API_ONLY_MCP_ORIGINS lists and a server's delete are served; the console, sign-in, setup, other settings, the MCP endpoint, the other trigger routes and hooks are refused."
|
|
22
|
+
: o.accounts || o.launchCode === undefined ? `Open ${o.publicUrl ?? o.url}/` : `Open ${o.publicUrl ?? o.url}/?launch=${o.launchCode}`,
|
|
21
23
|
...(o.boxes ? [o.boxes] : []),
|
|
22
24
|
];
|
|
23
25
|
}
|
package/dist/run-launch.js
CHANGED
|
@@ -149,7 +149,7 @@ export function readLaunchBody(stored) {
|
|
|
149
149
|
const model = readModel(stored.model);
|
|
150
150
|
const boxAllow = readBoxAllow(stored.box_allow);
|
|
151
151
|
const archilDisk = readDisk(stored.archil_disk);
|
|
152
|
-
const
|
|
152
|
+
const hold = readHold(stored.hold);
|
|
153
153
|
return {
|
|
154
154
|
input: stored.input,
|
|
155
155
|
...(isObject(stored.sdk) && sdkBindingOf(stored.sdk) && typeof stored.sdk.instructions === "string" ? { sdk: stored.sdk } : {}),
|
|
@@ -178,9 +178,22 @@ export function readLaunchBody(stored) {
|
|
|
178
178
|
...(inputOrigin ? { inputOrigin } : {}),
|
|
179
179
|
...(stored.follow_up === true ? { followUp: true } : {}),
|
|
180
180
|
...(archilDisk ? { archilDisk } : {}),
|
|
181
|
-
...(
|
|
181
|
+
...(hold ? { hold } : {}),
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
|
+
/** A launch's hold as it keeps it, else undefined (none kept). A minutes that isn't a number waits HOLD_MINUTES. A hold
|
|
185
|
+
* kept that is not an object (a corrupt row, another version's) is a hold whose model was refused, in words that name
|
|
186
|
+
* the field and never what it holds: read as none, the run would start and its claim open its model's keys. */
|
|
187
|
+
function readHold(value) {
|
|
188
|
+
if (value === undefined)
|
|
189
|
+
return undefined;
|
|
190
|
+
if (!isObject(value))
|
|
191
|
+
return { minutes: HOLD_MINUTES, refused: unreadable("hold") };
|
|
192
|
+
const refused = readRefusal(value.refused);
|
|
193
|
+
return { minutes: typeof value.minutes === "number" ? value.minutes : HOLD_MINUTES, ...(refused ? { refused } : {}) };
|
|
194
|
+
}
|
|
195
|
+
/** The refusal of a held run whose launch's `field` can't be read. */
|
|
196
|
+
const unreadable = (field) => ({ message: `This run's model was kept from running at its create, and its launch's ${field} can't be read: it holds its computer only. Start a new run to run its agent.`, fields: [], details: {} });
|
|
184
197
|
/** A held run's model refusal as its launch keeps it, else undefined (none kept). One kept that can't be read (a corrupt
|
|
185
198
|
* row, another version's) is a refusal still, in words that name the field and never what it holds: read as none, the
|
|
186
199
|
* run would start and its claim open the keys its model was refused for. */
|
|
@@ -188,7 +201,7 @@ function readRefusal(value) {
|
|
|
188
201
|
if (value === undefined)
|
|
189
202
|
return undefined;
|
|
190
203
|
if (!isObject(value) || typeof value.message !== "string" || !Array.isArray(value.fields) || !isObject(value.details))
|
|
191
|
-
return
|
|
204
|
+
return unreadable("hold.refused");
|
|
192
205
|
return { message: value.message, fields: value.fields, details: value.details };
|
|
193
206
|
}
|
|
194
207
|
/** The run's learning start (its seed sha, its # Learned section and its learned workflows), read from one place by learning's
|
package/dist/run-model-key.d.ts
CHANGED
|
@@ -35,7 +35,8 @@ export type ModelKeyTarget = {
|
|
|
35
35
|
};
|
|
36
36
|
/** A created run's ModelKeyTarget: its revision's kind and its launch's pinned model. A held run its model kept from
|
|
37
37
|
* running (run-launch.ts hold.refused) pins none and makes no model call: no key is required for it, and one handed
|
|
38
|
-
* with it is refused as never used (modelKeyMisfit).
|
|
38
|
+
* with it is refused as never used (modelKeyMisfit). So its create asks no key (serverKeyMissing is false for it): a
|
|
39
|
+
* change that lets such a hold become an agent turn must check the run's model key at that turn. */
|
|
39
40
|
export declare function keyTargetOf(launch: Pick<RunLaunch, "model" | "native">, revision: {
|
|
40
41
|
readonly kind: string;
|
|
41
42
|
}): ModelKeyTarget;
|
package/dist/run-model-key.js
CHANGED
|
@@ -87,7 +87,8 @@ export function gatewayMove(env) {
|
|
|
87
87
|
export const modelKeyRequired = (message, env) => new ApiError("model_key_required", `This server holds no model key for this run's model (AGENT_MODEL_API_KEY is not set and none is saved in Settings → Model keys), so each run's caller brings its own: send model_key with ${message ? "a message that starts a turn" : "the run"}, a key for the model gateway at AGENT_MODEL_BASE_URL (such as a LiteLLM virtual key) minted for ${message ? "that turn" : "this run"}.${env ? gatewayMove(env) : ""}`, { fields: [{ field: "model_key", reason: "missing", message: "model_key is required here: the server holds no model key for this run's model." }] });
|
|
88
88
|
/** A created run's ModelKeyTarget: its revision's kind and its launch's pinned model. A held run its model kept from
|
|
89
89
|
* running (run-launch.ts hold.refused) pins none and makes no model call: no key is required for it, and one handed
|
|
90
|
-
* with it is refused as never used (modelKeyMisfit).
|
|
90
|
+
* with it is refused as never used (modelKeyMisfit). So its create asks no key (serverKeyMissing is false for it): a
|
|
91
|
+
* change that lets such a hold become an agent turn must check the run's model key at that turn. */
|
|
91
92
|
export function keyTargetOf(launch, revision) {
|
|
92
93
|
return { kind: revision.kind, ...(launch.model ? { model: launch.model } : {}), native: Boolean(launch.native) };
|
|
93
94
|
}
|
|
@@ -2,6 +2,7 @@ import { type InFlight } from "./in-flight.js";
|
|
|
2
2
|
import type { Context } from "@earendil-works/chord/context";
|
|
3
3
|
import type { TimelineEvent } from "./timeline/index.js";
|
|
4
4
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
5
|
+
import { cutInWorker } from "./cut-pool.js";
|
|
5
6
|
import { type RunCut } from "./run-cut.js";
|
|
6
7
|
import { type Page } from "./rows.js";
|
|
7
8
|
import { type FileView } from "./run-files.js";
|
|
@@ -42,6 +43,12 @@ export interface RunReadsDeps {
|
|
|
42
43
|
readonly context: Context;
|
|
43
44
|
/** The server's seal key: a run's census names each file by a MAC under it (run-census.ts fileMac). */
|
|
44
45
|
readonly sealKey: Buffer | undefined;
|
|
46
|
+
/** How long a cut read waits for its file's cut, made in the cut worker (cut-pool.ts), before it is refused 503: CUT_MS
|
|
47
|
+
* unless a test names less. */
|
|
48
|
+
readonly cutMs?: number;
|
|
49
|
+
/** What makes a cut read's cut: the server's cut worker (cutInWorker) unless a test names another, to see that the read
|
|
50
|
+
* answers the worker's text and refuses what the worker refuses. */
|
|
51
|
+
readonly cut?: typeof cutInWorker;
|
|
45
52
|
}
|
|
46
53
|
/** A run's files, through its Workspace (listRunFiles): every file, path-sorted, cut at the cap. A run with no folder lists
|
|
47
54
|
* none; a run whose output is withheld refuses (403), as its graph does. The same shape the route answered. With `cut`
|
|
@@ -9,6 +9,7 @@ import { ApiError } from "./errors.js";
|
|
|
9
9
|
import { GRAPH_CACHE_BYTES, PartCache, servedGraphView } from "./graph-served.js";
|
|
10
10
|
import { runGraph } from "./graph-view.js";
|
|
11
11
|
import { checkedPath, decodedPath } from "./home-path.js";
|
|
12
|
+
import { CUT_MS, cutInWorker, CutUnserved } from "./cut-pool.js";
|
|
12
13
|
import { censusCut, censusDigest } from "./run-census.js";
|
|
13
14
|
import { cutFileText } from "./run-file-cut.js";
|
|
14
15
|
import { underCut } from "./run-cut.js";
|
|
@@ -80,7 +81,10 @@ export const WITHHELD_UNCOUNTED = "This run was handed secrets of its own, and i
|
|
|
80
81
|
/** File `rel` of the run's `workspace` as UTF-8 text cut of everything the run's own cut holds (deps.cutValues, the set its
|
|
81
82
|
* timeline's calls are cut of: the server's keys, the keys a person saved, its secret stores' values, the sign-in refs
|
|
82
83
|
* the run was handed, and while its launch holds them what its caller handed it: its own model key, tool keys and MCP
|
|
83
|
-
* credentials), through redactSecrets over the whole text
|
|
84
|
+
* credentials), through cutFileText (run-file-cut.ts: redactSecrets over the whole text) in the cut worker
|
|
85
|
+
* (cut-pool.ts), off this server's event loop and under one deadline for the read (deps.cutMs, CUT_MS): past it, or
|
|
86
|
+
* when the worker fails, the read is 503
|
|
87
|
+
* (`unavailable`), never the text uncut. Each value and secret shape is replaced by "[redacted]" in
|
|
84
88
|
* place, and the text "[redacted]" whole when a value still shows in another form. A long run with no whitespace
|
|
85
89
|
* (compact JSON) is never blanked for its length. Once an end erased what its caller handed it, the run's census says
|
|
86
90
|
* where those sat (run-census.ts censusCut): a file still as counted is cut there too, and any other is withheld (403,
|
|
@@ -116,11 +120,33 @@ async function cutRunFile(store, runId, workspace, rel, req, res, deps) {
|
|
|
116
120
|
}
|
|
117
121
|
if (text.includes("\u0000"))
|
|
118
122
|
throw new ApiError("unsupported_media_type", "a cut read answers text, and this file holds a NUL byte");
|
|
119
|
-
|
|
123
|
+
// The cut is made in the cut worker, off this server's event loop, under one deadline for the whole read: every cut
|
|
124
|
+
// underCut asks for, and every read of the run's cut and census around them. Past it, or when the worker fails, the read
|
|
125
|
+
// is refused 503, never answered uncut, and never answered late.
|
|
126
|
+
const timeMs = deps.cutMs ?? CUT_MS;
|
|
127
|
+
const until = Date.now() + timeMs;
|
|
128
|
+
const unmade = (why) => new ApiError("unavailable", `this file's cut was not made (${why}), and it is never served uncut: read it again`);
|
|
129
|
+
const lateRead = `the read did not finish within ${timeMs} ms`;
|
|
130
|
+
const cutText = (values, held = []) => {
|
|
131
|
+
// Asked for past the deadline (the read has already been refused): no worker is started for it.
|
|
132
|
+
const left = until - Date.now();
|
|
133
|
+
if (left <= 0)
|
|
134
|
+
return Promise.reject(unmade(lateRead));
|
|
135
|
+
return (deps.cut ?? cutInWorker)(text, values, Buffer.byteLength(text), held, left).catch((error) => {
|
|
136
|
+
if (error instanceof CutUnserved)
|
|
137
|
+
throw unmade(error.message);
|
|
138
|
+
throw error;
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
let deadline;
|
|
142
|
+
const late = new Promise((_, reject) => {
|
|
143
|
+
deadline = setTimeout(() => reject(unmade(lateRead)), timeMs);
|
|
144
|
+
});
|
|
145
|
+
const made = underCut(() => deps.cutValues(store, runId), async (cut) => {
|
|
120
146
|
if (cut === "unreadable")
|
|
121
147
|
return { withheld: WITHHELD_SIGN_IN };
|
|
122
148
|
if (cut.censusDigest === undefined)
|
|
123
|
-
return { text:
|
|
149
|
+
return { text: await cutText(cut.values) };
|
|
124
150
|
// The run's end erased what its caller handed it: where those sat in this file is its census's to say. Read here, the
|
|
125
151
|
// one read that cuts by it; the cut names it by digest, so a census written since withholds this answer and the cut
|
|
126
152
|
// read again after it (underCut) builds it anew.
|
|
@@ -130,8 +156,10 @@ async function cutRunFile(store, runId, workspace, rel, req, res, deps) {
|
|
|
130
156
|
const held = censusCut(census, rel, bytes, text, deps.sealKey);
|
|
131
157
|
if (held === "unreadable")
|
|
132
158
|
return { withheld: WITHHELD_UNCOUNTED };
|
|
133
|
-
return { text:
|
|
159
|
+
return { text: held === "whole" ? "[redacted]" : await cutText(cut.values, held) };
|
|
134
160
|
});
|
|
161
|
+
// Whichever settles first. A read refused at its deadline leaves underCut to finish on its own, its answer dropped.
|
|
162
|
+
const shown = await Promise.race([made, late]).finally(() => clearTimeout(deadline));
|
|
135
163
|
if ("withheld" in shown)
|
|
136
164
|
throw new ApiError("forbidden", shown.withheld);
|
|
137
165
|
const body = Buffer.from(shown.text);
|
package/dist/runnable.d.ts
CHANGED
|
@@ -115,9 +115,11 @@ export declare function deniedComputer(revision: RevisionShape, settings: ToolSe
|
|
|
115
115
|
* setting can be had here now, or its refusal (resolve-computer.ts computerReadiness); none given, the box check.
|
|
116
116
|
* `shellOf`: where a run of an agent with that computer setting has its shell here now (resolve-computer.ts
|
|
117
117
|
* runShellOf, in the server's mode): a sandbox-only tool on the runner is let by it (Mode 2's Archil exec runs bash);
|
|
118
|
-
* none given, the runner has no shell. `
|
|
119
|
-
*
|
|
120
|
-
|
|
118
|
+
* none given, the runner has no shell. `noExec`: in Mode 2, the server's Archil region where it has no serverless exec
|
|
119
|
+
* (archil-settings.ts noExecRegionOf), so a sandbox-only tool on the runner names a sandbox computer, never Docker's box,
|
|
120
|
+
* which can't mount Archil. `capUsd`: a save's cap (with `capped`), whose shortfall for one more step and an answer is
|
|
121
|
+
* a warning of its own (`short`, cap-short.ts); a run's check never names one. */
|
|
122
|
+
export declare function blockersOf(env: NodeJS.ProcessEnv, revision: RevisionShape, settings?: ToolSettingsMap, { capped, capUsd, boxes, offers, mcp, monid, decisionPrice, computerReady, shellOf, noExec }?: {
|
|
121
123
|
capped?: boolean;
|
|
122
124
|
capUsd?: number;
|
|
123
125
|
boxes?: readonly BoxOffer[];
|
|
@@ -135,6 +137,7 @@ export declare function blockersOf(env: NodeJS.ProcessEnv, revision: RevisionSha
|
|
|
135
137
|
readonly box?: string;
|
|
136
138
|
}>;
|
|
137
139
|
shellOf?: (setting: RevisionComputer) => Promise<ShellPlace>;
|
|
140
|
+
noExec?: string;
|
|
138
141
|
}): Promise<Blocker[]>;
|
|
139
142
|
/** A blocker as a field issue, for a 422 or a warning. */
|
|
140
143
|
export declare const issueOf: ({ field, reason, message, fix }: Blocker) => InputIssue;
|
package/dist/runnable.js
CHANGED
|
@@ -11,7 +11,8 @@ import { harnessOf, onAdapter } from "./harness-table.js";
|
|
|
11
11
|
import { capShortOf } from "./cap-short.js";
|
|
12
12
|
import { chooseModel } from "./model.js";
|
|
13
13
|
import { llmTiers, MODEL_NODES, nodeTiers, unpricedModels, workflowNodes } from "./model.js";
|
|
14
|
-
import {
|
|
14
|
+
import { noExecWords } from "./archil-settings.js";
|
|
15
|
+
import { boxAvailability, newAgentPlace, noExecIssue, noPlaceIssue, placeFix } from "./place.js";
|
|
15
16
|
import { allows, BOUND_TOOLS, CALL_TOOLS, grantedTools, missingEnv, NODE_TOOLS, shellTools, toolOf, workflowTools } from "./tools.js";
|
|
16
17
|
import { DENIED, isUnavailable, NO_PARALLEL_KEY, planeFor, whyUnavailable } from "./tool-plane.js";
|
|
17
18
|
import { computerDenied, denyPlace, permissionFrom, permissionKeys, permissionOf } from "./tool-gate.js";
|
|
@@ -69,9 +70,11 @@ export async function deniedComputer(revision, settings, shellOf) {
|
|
|
69
70
|
* setting can be had here now, or its refusal (resolve-computer.ts computerReadiness); none given, the box check.
|
|
70
71
|
* `shellOf`: where a run of an agent with that computer setting has its shell here now (resolve-computer.ts
|
|
71
72
|
* runShellOf, in the server's mode): a sandbox-only tool on the runner is let by it (Mode 2's Archil exec runs bash);
|
|
72
|
-
* none given, the runner has no shell. `
|
|
73
|
-
*
|
|
74
|
-
|
|
73
|
+
* none given, the runner has no shell. `noExec`: in Mode 2, the server's Archil region where it has no serverless exec
|
|
74
|
+
* (archil-settings.ts noExecRegionOf), so a sandbox-only tool on the runner names a sandbox computer, never Docker's box,
|
|
75
|
+
* which can't mount Archil. `capUsd`: a save's cap (with `capped`), whose shortfall for one more step and an answer is
|
|
76
|
+
* a warning of its own (`short`, cap-short.ts); a run's check never names one. */
|
|
77
|
+
export async function blockersOf(env, revision, settings = {}, { capped = false, capUsd, boxes = [], offers, mcp, monid, decisionPrice, computerReady, shellOf, noExec } = {}) {
|
|
75
78
|
const out = [];
|
|
76
79
|
/** A web tool its run would resolve unavailable (tool-plane.ts): a warning at save, a 409 at a run, never another
|
|
77
80
|
* provider in its place. One set to deny is not: its run starts, and the gate refuses each call. */
|
|
@@ -124,6 +127,12 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
|
|
|
124
127
|
* Docker's box is not here and both ways out, fixing that or keeping the agent on the runner without the tool. Where
|
|
125
128
|
* the runner has a shell that runs others (Mode 2's Archil exec runs bash), it says which. */
|
|
126
129
|
const shellOnRunner = (tool, field, named) => {
|
|
130
|
+
// On a Mode 2 region with no exec the runner has no shell and Docker's box can't mount Archil: a sandbox computer is
|
|
131
|
+
// the one way to run the tool. With no place named, in the words its save is refused in (noExecIssue).
|
|
132
|
+
if (noExec !== undefined && !named)
|
|
133
|
+
return { ...noExecIssue(noExec), host: false, tool };
|
|
134
|
+
if (noExec !== undefined)
|
|
135
|
+
return { field, reason: "not_an_option", message: `${tool} runs only in a box, and this agent's place is the runner, which has no shell here: ${noExecWords(noExec)}, and the docker box can't mount Archil. Give it a sandbox computer (a box), or remove "${tool}" from definition.tools.`, fix: `Remove "${tool}" from definition.tools.`, host: false, tool };
|
|
127
136
|
const fresh = newAgentPlace(boxes);
|
|
128
137
|
if (!named && !runnerShell.size && "reason" in fresh) {
|
|
129
138
|
// A tool the box refuses (the browser) keeps this agent out of every box, so naming one is no way out: its words
|
|
@@ -212,10 +221,11 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
|
|
|
212
221
|
if (!allows(BOUND_TOOLS, tool))
|
|
213
222
|
out.push({ field: `definition.tools[${index}]`, reason: "not_an_option", message: `${tool} is not a tool here: grant one of ${BOUND_TOOLS.join(", ")}, an MCP server's tool as mcp:<server>/<tool>, or a monid endpoint as monid:<provider>/<endpoint>.`, host: false, tool });
|
|
214
223
|
// A shell runs in a box; on the runner (no place names one) only what its shell here runs (runnerShell).
|
|
215
|
-
// One that names no place is refused
|
|
224
|
+
// One that names no place is refused once, whatever shell tools it names: at its place (Mode 1), or at its computer
|
|
225
|
+
// on a Mode 2 region with no exec.
|
|
216
226
|
else if (toolOf(tool).sandboxOnly && (place?.mode ?? "runner") === "runner" && !runnerShell.has(tool)) {
|
|
217
227
|
const blocker = shellOnRunner(tool, `definition.tools[${index}]`, !!place && !revision.unnamed);
|
|
218
|
-
if (!out.some((b) => b.field ===
|
|
228
|
+
if (!out.some((b) => b.field === blocker.field && b.message === blocker.message))
|
|
219
229
|
out.push(blocker);
|
|
220
230
|
}
|
|
221
231
|
// Its writes into work/ go by path from this machine, and a box's command could swap a link in on their way.
|
|
@@ -700,8 +700,9 @@ function adapterLoop(specOf, options, deps) {
|
|
|
700
700
|
* The agent is asked no turn of the job's: the run goes to its end-of-run turn, told the grade first (feedbackAsk). */
|
|
701
701
|
let feedbackNow;
|
|
702
702
|
/** A reopen of a run whose session is still new (a person stopped it before its first input was sent): resolved once the
|
|
703
|
-
* person's message is placed as that first input
|
|
704
|
-
*
|
|
703
|
+
* person's message is placed as that first input, or once the reopen's own message was answered unplaced (command):
|
|
704
|
+
* then no message places it, and the claim ends the run on the end it had before, sending nothing. The claim waits on
|
|
705
|
+
* it, never sending the input they stopped, however late the runner hands the message over. */
|
|
705
706
|
let firstInputPlaced;
|
|
706
707
|
/** Resolved once a pass of this claim has sent what its session starts on (the run's input, a follow-up, a recovery),
|
|
707
708
|
* or found nothing to send: a message handed over while the session is still new waits for it, so it lands after the
|
|
@@ -1079,12 +1080,19 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1079
1080
|
// the run's next turn, on a claim that lists them: the run's end opens it again with the message (as for a message
|
|
1080
1081
|
// that comes while the run ends), and a park's resume takes it. Every message after it waits the same way, whatever
|
|
1081
1082
|
// the credentials say at its own check (a later message may hand them no longer), so none runs before it. Said once
|
|
1082
|
-
// on the timeline, since the API answered the message as steered.
|
|
1083
|
+
// on the timeline, since the API answered the message as steered. A reopen's own message (the claim's turn, not yet
|
|
1084
|
+
// sent; never a wait's answer) came before the claim opened, so whatever it handed, the claim opened with: a
|
|
1085
|
+
// credential handed since is a later message's, and this one is still the claim's turn. Held, a reopen of a session
|
|
1086
|
+
// still new would wait for a first input that never comes. It is the first message to reach here while the reopen
|
|
1087
|
+
// is unsent (`by`): one after it, though that message was refused or left, is no reopen's and is checked.
|
|
1083
1088
|
if (leftForNextTurn)
|
|
1084
1089
|
return { later: "a message before this one runs as the run's next turn: this one runs after it" };
|
|
1085
1090
|
const claimMcp = mcp;
|
|
1086
1091
|
const leftOut = claimMcp?.leftOut;
|
|
1087
|
-
|
|
1092
|
+
const claimTurn = reopen !== undefined && !reopen.sent && reopen !== waitTurn ? reopen : undefined;
|
|
1093
|
+
if (claimTurn)
|
|
1094
|
+
claimTurn.by ??= command.id;
|
|
1095
|
+
if (claimMcp && leftOut?.length && claimTurn?.by !== command.id) {
|
|
1088
1096
|
const still = new Set(await claimMcp.fresh());
|
|
1089
1097
|
const handed = leftOut.filter((server) => !still.has(server));
|
|
1090
1098
|
if (handed.length) {
|
|
@@ -1109,8 +1117,9 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1109
1117
|
// and a person's stop or cancel (the stop that cuts the workflow's call, its spend and custody), a raise or a hand-back
|
|
1110
1118
|
// would never reach the run. `taken` here means its take rides on the commit that places it once the input is sent; a
|
|
1111
1119
|
// claim that ends first (a stop, a park, the workflow's answer) leaves the row untaken, for the run's end or its next
|
|
1112
|
-
// claim to settle, as any message the run's end finds untaken.
|
|
1113
|
-
|
|
1120
|
+
// claim to settle, as any message the run's end finds untaken. Once the claim sends nothing more (turnsOver), nothing
|
|
1121
|
+
// waits: the message is the run's next claim's.
|
|
1122
|
+
if (!turnsOver && (waitingFirst > 0 || (!reopen && session.state === "new") || servingFirst)) {
|
|
1114
1123
|
waitingFirst += 1;
|
|
1115
1124
|
const placing = afterFirst.then(() => placeSteer(command));
|
|
1116
1125
|
afterFirst = placing.then(() => void (waitingFirst -= 1), (error) => {
|
|
@@ -2340,7 +2349,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2340
2349
|
const traced = specNow?.trace;
|
|
2341
2350
|
const routed = request.route === undefined ? traced?.model : traced?.routes?.get(request.route)?.model;
|
|
2342
2351
|
const known = (asked) => asked === traced?.model || [...(traced?.routes?.values() ?? [])].some((via) => via.model === asked) || specNow?.runCap.modelOf(asked)?.id === asked;
|
|
2343
|
-
const model = tracedModel(request.model, { known, ...(routed ? { routed } : {}),
|
|
2352
|
+
const model = tracedModel(request.model, { known, ...(routed ? { routed } : {}), redact: deps.redact });
|
|
2344
2353
|
chats.set(ticket.turn, trace.request(model, request.route));
|
|
2345
2354
|
}
|
|
2346
2355
|
// The conversation that asked, as its client named it (pi's, one of several asking at once): whose answer reads
|
|
@@ -2493,10 +2502,12 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2493
2502
|
// go is marked first (LEARNED_ALLOWED), committed before the tool runs: a call issued again after a crash cut it may
|
|
2494
2503
|
// have run nodes and spent on such an attempt, so its refusal is then no proof it ran nothing, and it is kept
|
|
2495
2504
|
// `failed`, never `refused`, priced from what its call id booked (failedRecord). The newest of the call's marks and
|
|
2496
|
-
// records says which (learned-nodes.ts learnedCallRan): its bridge can't alone (a tool that nests is asked
|
|
2497
|
-
//
|
|
2498
|
-
// too. With neither, the bridge's `replayed` stands in: a
|
|
2499
|
-
//
|
|
2505
|
+
// records says which (learned-nodes.ts learnedCallRan): its bridge can't alone (a tool that nests is asked as
|
|
2506
|
+
// `replayed` only once an earlier attempt fixed a value or nested a call: process/tools.ts runNesting), nor can the
|
|
2507
|
+
// call's start on the CLI record, which a refusal writes too. With neither, the bridge's `replayed` stands in: a
|
|
2508
|
+
// run begun before the marks existed has none. Whatever is
|
|
2509
|
+
// kept, a refusal reads `failed` once anything was booked under the call id, or while an attempt let go was closed
|
|
2510
|
+
// by no refusal (workflow-calls.ts workflowCallsOf).
|
|
2500
2511
|
const learnedEntry = async (call, answer) => {
|
|
2501
2512
|
const named = call.tool === LEARNED_WORKFLOW_TOOL ? spec.gate?.learnedOf?.(call.args) : undefined;
|
|
2502
2513
|
const [journalOf, rootOf] = [harness, root];
|
|
@@ -2543,7 +2554,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2543
2554
|
// Every harness's events reach its trace first (its tool calls, a plan harness's turns), with a record or without.
|
|
2544
2555
|
const recorded = record ? onEvent(record) : undefined;
|
|
2545
2556
|
const traceAnd = (event) => {
|
|
2546
|
-
trace?.event(tracedEvent(event, { mcp: (name) => mcp?.catalogOf(specNow?.facts?.hostName?.(name) ?? name) !== undefined,
|
|
2557
|
+
trace?.event(tracedEvent(event, { mcp: (name) => mcp?.catalogOf(specNow?.facts?.hostName?.(name) ?? name) !== undefined, redact: deps.redact }));
|
|
2547
2558
|
recorded?.(event);
|
|
2548
2559
|
};
|
|
2549
2560
|
const io = { writer, models: counted, signal: deps.signal, onEvent: traceAnd, gate: sessionGate, ...(permission ? { permission } : {}), hostTool: hosted, ...(ownCalls ? { ownCalls } : {}), bookedCost, keepCalls, ...(record ? {} : { nestedEnded }) };
|
|
@@ -2725,6 +2736,10 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2725
2736
|
const resumes = raising.resumes;
|
|
2726
2737
|
await takeRaises();
|
|
2727
2738
|
if (paused) {
|
|
2739
|
+
// No raise resumed it (each refused, or a retry of one before): its pause stands as it was, its budget entry
|
|
2740
|
+
// unanswered, so it parks again on that entry with nothing written, never a second entry at the same cap.
|
|
2741
|
+
if (!resumes && (await raiseStateOf()).pause !== undefined)
|
|
2742
|
+
return await parkAgain(harness, gate);
|
|
2728
2743
|
if (!resumes || raising.capUsd === undefined || !spec.cap?.followUpOf)
|
|
2729
2744
|
return await parkAtCap(harness, root, gate, paused, "cap");
|
|
2730
2745
|
// The server's words, shown as its row ("AgentRun: …"), never as the person's; under the id a raise's answer named.
|
|
@@ -2760,7 +2775,18 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2760
2775
|
// runner reads on a later poll is waited for (or the run's stop, park or loss).
|
|
2761
2776
|
if (firstInputPlaced && !reopen.sent) {
|
|
2762
2777
|
const lost = new Promise((resolve) => (deps.signal.aborted ? resolve() : deps.signal.addEventListener("abort", () => resolve(), { once: true })));
|
|
2763
|
-
await Promise.race([firstInputPlaced, stopping, parking, harness.closed.then(() =>
|
|
2778
|
+
const woke = await Promise.race([firstInputPlaced.then(() => true), stopping.then(() => false), parking.then(() => false), harness.closed.then(() => false, () => false), lost.then(() => false)]);
|
|
2779
|
+
// Woken with nothing placed (the reopen's own message refused or left): the claim sends nothing into the
|
|
2780
|
+
// session that never started, asks nothing of it, and ends the run on the end it had before (a stop's, or its
|
|
2781
|
+
// learned workflow's answer). A message handed over from here on is the run's next claim's (`later`), never
|
|
2782
|
+
// queued for a first input that is never sent.
|
|
2783
|
+
if (woke && !reopen.sent) {
|
|
2784
|
+
turnsOver = true;
|
|
2785
|
+
reopen = undefined;
|
|
2786
|
+
inputSent();
|
|
2787
|
+
const { projectCheckpoint: _, ...before } = foundEntries.findLast((entry) => entry.kind === KINDS.end).data;
|
|
2788
|
+
return await writeEnd(harness, root, gate, before, []);
|
|
2789
|
+
}
|
|
2764
2790
|
}
|
|
2765
2791
|
const sent = reopen.sent;
|
|
2766
2792
|
const fed = reopen.feedback;
|
|
@@ -3784,16 +3810,16 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3784
3810
|
finish("lapsed");
|
|
3785
3811
|
}, () => undefined);
|
|
3786
3812
|
// So does a message left for the run's next turn (steer), the same way; one left while the wait was starting ends it
|
|
3787
|
-
// as soon as it holds.
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3813
|
+
// as soon as it holds. One left while an answer is placed (a message that waited for the run's first input is placed
|
|
3814
|
+
// off the runner's delivery, so the next row can arrive meanwhile) ends it once that answer is refused: no message
|
|
3815
|
+
// reaches the wait after it.
|
|
3816
|
+
endWaitNow = () => {
|
|
3817
|
+
cut = true;
|
|
3818
|
+
if (!mine.sent)
|
|
3819
|
+
finish("lapsed");
|
|
3820
|
+
};
|
|
3821
|
+
if (leftForNextTurn)
|
|
3822
|
+
endWaitNow();
|
|
3797
3823
|
void (async () => {
|
|
3798
3824
|
for (;;) {
|
|
3799
3825
|
await placing;
|
|
@@ -4052,6 +4078,12 @@ function adapterLoop(specOf, options, deps) {
|
|
|
4052
4078
|
await pauseAtCap(on, conversation, theGate, data);
|
|
4053
4079
|
return parkClaim(on, theGate, cause);
|
|
4054
4080
|
}
|
|
4081
|
+
/** The run parked again at the pause it was woken from, which no raise of this claim answered: nothing is written (its
|
|
4082
|
+
* budget entry and the row's words stand), and the release parks the row again (LoopEnd `again`). */
|
|
4083
|
+
async function parkAgain(on, theGate) {
|
|
4084
|
+
const end = await parkClaim(on, theGate, "cap");
|
|
4085
|
+
return end.state === "parked" ? { ...end, again: true } : end;
|
|
4086
|
+
}
|
|
4055
4087
|
/** Waits, at most the spec's parkSiblingsMs (PARK_SIBLINGS_MS), until no call pi started beside a parked one is still
|
|
4056
4088
|
* running: a model call of the same answer (its assistant entry) past its stored intent. Each one's result is then on the
|
|
4057
4089
|
* journal before the park seals it, and the resume hands it to the model with the parked call's answer, never as a call
|
|
@@ -4340,8 +4372,15 @@ function adapterLoop(specOf, options, deps) {
|
|
|
4340
4372
|
// never runs the message on the key held before it.
|
|
4341
4373
|
await specNow?.modelKey?.fresh();
|
|
4342
4374
|
}
|
|
4343
|
-
if (command.kind === "steer")
|
|
4344
|
-
|
|
4375
|
+
if (command.kind === "steer") {
|
|
4376
|
+
const outcome = await steer(command);
|
|
4377
|
+
// The reopen's own message refused or left (a trigger's in a session on its owner's sign-in): no message is the
|
|
4378
|
+
// claim's turn now, and a message after it is checked as any other, so a reopen of a session still new stops
|
|
4379
|
+
// waiting for its first input (firstInputPlaced); a message left meanwhile reopens the run on its next claim.
|
|
4380
|
+
if (!("taken" in outcome) && reopen !== undefined && reopen !== waitTurn && !reopen.sent && reopen.by === command.id)
|
|
4381
|
+
reopen.placed?.();
|
|
4382
|
+
return outcome;
|
|
4383
|
+
}
|
|
4345
4384
|
if (command.kind === "approve" || command.kind === "deny") {
|
|
4346
4385
|
// An answer names its approval: the asked call's id. One that names no call waiting for its answer (an old
|
|
4347
4386
|
// approval, another run's) is refused, never applied to the call that waits now.
|
|
@@ -95,6 +95,10 @@ export interface AdapterSpecDeps {
|
|
|
95
95
|
readonly journal: (claim: Claim) => Journal;
|
|
96
96
|
/** The one store: `runs` and `agents` for the run's revision, and the live-viewer seam for the browser tool. */
|
|
97
97
|
readonly store: Store & LiveViewerStore;
|
|
98
|
+
/** The plane the claim's runner capped (run-child-host.ts, by underServerCeilings) and chose the run's keys by, handed to
|
|
99
|
+
* the run's own process (run-child.ts): taken as it is there, never capped again on settings read later, so the run's
|
|
100
|
+
* tools and the keys it was handed are of one reading. Absent: the claim caps its launch itself. */
|
|
101
|
+
readonly claimedPlane?: RunLaunch["plane"];
|
|
98
102
|
/** The key the store's sealed values are opened under (store/seal.ts): the runner's. Undefined in a run's own process
|
|
99
103
|
* (run-child.ts), which never holds it: what a claim opens with it is asked of the runner there (held.ts). */
|
|
100
104
|
readonly sealKey: Buffer | undefined;
|
|
@@ -295,7 +299,8 @@ export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pi
|
|
|
295
299
|
readonly learn: (flows: readonly LearnedWorkflow[]) => void;
|
|
296
300
|
readonly askedOn: (host: ToolHost) => void;
|
|
297
301
|
readonly computerOff: () => boolean; /** Whether the run can write a file now, as its gate decides a save_as (RunGate.writeBar): what its files note and computer_screenshot's save_as are offered by. */
|
|
298
|
-
readonly writes: () => boolean;
|
|
302
|
+
readonly writes: () => boolean; /** The computer ops the gate refuses whatever their arguments (RunGate.opsRefused: not given, denied, or an ask no one can approve): what computer_op and a script's `computer` leave out. */
|
|
303
|
+
readonly opsRefused: () => readonly string[];
|
|
299
304
|
}>;
|
|
300
305
|
/** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
|
|
301
306
|
* and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
|