@parcha/agentrun-serve 0.1.0-beta.52 → 0.1.0-beta.54
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 +149 -1
- package/README.md +295 -37
- package/dist/agent-delete.d.ts +5 -6
- package/dist/agent-delete.js +30 -67
- package/dist/agent-package.d.ts +71 -0
- package/dist/agent-package.js +345 -0
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +26 -20
- package/dist/agents-store.js +42 -34
- package/dist/api-only.d.ts +25 -6
- package/dist/api-only.js +34 -13
- package/dist/claude-login.d.ts +1 -0
- package/dist/claude-login.js +1 -1
- package/dist/cli-learning/cli.d.ts +3 -0
- package/dist/cli-learning/cli.js +17 -3
- package/dist/cli-learning/connections.js +3 -2
- package/dist/cli-learning/schema.js +2 -1
- package/dist/cli.js +76 -8
- package/dist/composio-preset.d.ts +3 -1
- package/dist/composio-preset.js +5 -3
- package/dist/composio-triggers.d.ts +4 -0
- package/dist/composio-triggers.js +4 -1
- package/dist/computer-needs.d.ts +32 -0
- package/dist/computer-needs.js +80 -0
- package/dist/computer-setting.d.ts +5 -2
- package/dist/computer-setting.js +8 -1
- package/dist/computers.d.ts +0 -2
- package/dist/computers.js +1 -1
- package/dist/console/assets/index-B_85An2t.js +745 -0
- package/dist/console/assets/index-n1YsbnYh.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +1 -0
- package/dist/console-links.js +2 -0
- package/dist/env-switch.d.ts +14 -0
- package/dist/env-switch.js +23 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +10 -0
- package/dist/eval-previous.js +4 -3
- package/dist/fal-price.js +10 -13
- package/dist/github-connection.d.ts +50 -1
- package/dist/github-connection.js +96 -3
- package/dist/github-faux.d.ts +11 -2
- package/dist/github-faux.js +138 -7
- package/dist/github-pull-request.d.ts +37 -0
- package/dist/github-pull-request.js +110 -0
- package/dist/handed-secret.d.ts +4 -0
- package/dist/handed-secret.js +10 -0
- package/dist/harness-archive.d.ts +15 -5
- package/dist/harness-archive.js +71 -34
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +36 -95
- package/dist/harness-egress.d.ts +23 -0
- package/dist/harness-egress.js +69 -0
- package/dist/harness-recipe-entry.d.ts +71 -0
- package/dist/harness-recipe-entry.js +184 -0
- package/dist/harness-recipe.d.ts +73 -6
- package/dist/harness-recipe.js +185 -31
- package/dist/harness-sign-in.d.ts +29 -0
- package/dist/harness-sign-in.js +122 -0
- package/dist/harness-table.d.ts +21 -0
- package/dist/harness-table.js +58 -3
- package/dist/harness-zip.d.ts +6 -0
- package/dist/harness-zip.js +203 -0
- package/dist/ids.d.ts +11 -0
- package/dist/ids.js +36 -0
- package/dist/learn/commit.d.ts +14 -1
- package/dist/learn/commit.js +156 -1
- package/dist/learn/compile.js +22 -8
- package/dist/learn/folder.d.ts +5 -0
- package/dist/learn/folder.js +10 -1
- package/dist/learn/learning.sh +15 -3
- package/dist/learn/promote.d.ts +2 -2
- package/dist/learn/secrets.js +30 -7
- package/dist/learning-routes.d.ts +23 -11
- package/dist/learning-routes.js +110 -20
- package/dist/learning.d.ts +9 -6
- package/dist/learning.js +9 -4
- package/dist/live-reach.d.ts +34 -7
- package/dist/live-reach.js +76 -11
- package/dist/mcp-gateway.js +15 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +8 -3
- package/dist/mcp-resources.d.ts +44 -0
- package/dist/mcp-resources.js +100 -0
- package/dist/mcp-servers-store.d.ts +16 -12
- package/dist/model.d.ts +4 -4
- package/dist/model.js +6 -6
- package/dist/native/cli.js +9 -2
- package/dist/native/connection.d.ts +2 -2
- package/dist/native/connection.js +5 -2
- package/dist/native/discovery.d.ts +2 -0
- package/dist/native/discovery.js +10 -6
- package/dist/native/remote-worker-bridge.js +36 -4
- package/dist/native/remote.d.ts +18 -1
- package/dist/native/remote.js +126 -37
- package/dist/native/schema.d.ts +6 -0
- package/dist/native/schema.js +31 -6
- package/dist/native/source-account.d.ts +13 -0
- package/dist/native/source-account.js +114 -0
- package/dist/native/source-capture-hooks.d.ts +5 -0
- package/dist/native/source-capture-hooks.js +102 -0
- package/dist/native/source-mcp-selection.d.ts +13 -0
- package/dist/native/source-mcp-selection.js +72 -0
- package/dist/native/source-runtime-tools.d.ts +19 -0
- package/dist/native/source-runtime-tools.js +103 -0
- package/dist/native/source-snapshot-types.d.ts +138 -0
- package/dist/native/source-snapshot-types.js +12 -0
- package/dist/native/source-snapshot.d.ts +8 -0
- package/dist/native/source-snapshot.js +1201 -0
- package/dist/observation/learning.js +3 -2
- package/dist/openapi.js +275 -40
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +12 -0
- package/dist/purged-workflow.js +43 -0
- package/dist/run-keys.d.ts +46 -0
- package/dist/run-keys.js +109 -0
- package/dist/run-launch.d.ts +16 -1
- package/dist/run-launch.js +30 -1
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +2 -2
- package/dist/run-model-key.js +5 -5
- package/dist/run-secrets.d.ts +2 -0
- package/dist/run-secrets.js +7 -4
- package/dist/run-view.d.ts +17 -0
- package/dist/run-view.js +25 -1
- package/dist/runner/adapter-loop.d.ts +11 -3
- package/dist/runner/adapter-loop.js +138 -22
- package/dist/runner/adapter-run-spec.js +26 -13
- package/dist/runner/audit.d.ts +2 -0
- package/dist/runner/audit.js +9 -1
- package/dist/runner/beside.js +2 -1
- package/dist/runner/claim-secrets.d.ts +29 -3
- package/dist/runner/claim-secrets.js +38 -4
- package/dist/runner/cli-run-spec.js +24 -13
- package/dist/runner/harness-loops.d.ts +6 -0
- package/dist/runner/harness-loops.js +11 -1
- package/dist/runner/held.d.ts +4 -0
- package/dist/runner/journal-kinds.d.ts +2 -0
- package/dist/runner/learned-first.d.ts +2 -0
- package/dist/runner/learned-first.js +1 -1
- package/dist/runner/learning-end.d.ts +7 -2
- package/dist/runner/learning-end.js +22 -10
- package/dist/runner/learning-seed.d.ts +9 -3
- package/dist/runner/learning-seed.js +2 -2
- package/dist/runner/main.d.ts +1 -0
- package/dist/runner/main.js +20 -13
- package/dist/runner/mcp-claim.js +6 -1
- package/dist/runner/mcp-run.d.ts +10 -7
- package/dist/runner/mcp-run.js +3 -5
- package/dist/runner/metrics.d.ts +4 -2
- package/dist/runner/metrics.js +15 -3
- package/dist/runner/monid-run.js +9 -11
- package/dist/runner/pr-checkout.d.ts +21 -4
- package/dist/runner/pr-checkout.js +103 -4
- package/dist/runner/project-checkpoint.d.ts +35 -0
- package/dist/runner/project-checkpoint.js +116 -0
- package/dist/runner/project-drain.d.ts +8 -0
- package/dist/runner/project-drain.js +25 -0
- package/dist/runner/project-host.d.ts +10 -0
- package/dist/runner/project-host.js +52 -0
- package/dist/runner/promotion.d.ts +14 -6
- package/dist/runner/promotion.js +98 -41
- package/dist/runner/redact.d.ts +13 -0
- package/dist/runner/redact.js +67 -1
- package/dist/runner/run-channel.d.ts +9 -0
- package/dist/runner/run-channel.js +15 -2
- package/dist/runner/run-child-host.d.ts +8 -4
- package/dist/runner/run-child-host.js +178 -45
- package/dist/runner/run-errors.js +2 -2
- package/dist/runner/runner-check.d.ts +3 -0
- package/dist/runner/runner-check.js +28 -2
- package/dist/runner/runner.js +26 -9
- package/dist/runner/store-secrets.js +7 -3
- package/dist/runner/workflow-first.d.ts +4 -0
- package/dist/runner/workflow-first.js +13 -0
- package/dist/runner/workflow-loop.d.ts +2 -1
- package/dist/runner/workflow-loop.js +2 -1
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/runs-over-store.d.ts +34 -6
- package/dist/runs-over-store.js +133 -25
- package/dist/sdk/runs.d.ts +11 -1
- package/dist/sdk/runs.js +117 -26
- package/dist/sdk/schema.js +12 -2
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/server.d.ts +79 -32
- package/dist/server.js +673 -113
- package/dist/skills/agentrun-serve/SKILL.md +2 -1
- package/dist/source-sync/adoption.d.ts +15 -0
- package/dist/source-sync/adoption.js +36 -0
- package/dist/source-sync/auxiliary.d.ts +23 -0
- package/dist/source-sync/auxiliary.js +64 -0
- package/dist/source-sync/capture-git.d.ts +5 -0
- package/dist/source-sync/capture-git.js +272 -0
- package/dist/source-sync/capture-project.d.ts +53 -0
- package/dist/source-sync/capture-project.js +206 -0
- package/dist/source-sync/capture-refusal.d.ts +7 -0
- package/dist/source-sync/capture-refusal.js +16 -0
- package/dist/source-sync/capture.d.ts +11 -0
- package/dist/source-sync/capture.js +22 -0
- package/dist/source-sync/checkpoint-gate.d.ts +21 -0
- package/dist/source-sync/checkpoint-gate.js +52 -0
- package/dist/source-sync/checkpoints.d.ts +66 -0
- package/dist/source-sync/checkpoints.js +168 -0
- package/dist/source-sync/claim.d.ts +11 -0
- package/dist/source-sync/claim.js +48 -0
- package/dist/source-sync/destination.d.ts +47 -0
- package/dist/source-sync/destination.js +239 -0
- package/dist/source-sync/io.d.ts +15 -0
- package/dist/source-sync/io.js +52 -0
- package/dist/source-sync/local.d.ts +43 -0
- package/dist/source-sync/local.js +229 -0
- package/dist/source-sync/prepare.d.ts +59 -0
- package/dist/source-sync/prepare.js +93 -0
- package/dist/source-sync/projects.d.ts +61 -0
- package/dist/source-sync/projects.js +130 -0
- package/dist/source-sync/registry.d.ts +95 -0
- package/dist/source-sync/registry.js +226 -0
- package/dist/source-sync/service.d.ts +33 -0
- package/dist/source-sync/service.js +118 -0
- package/dist/source-sync/skill-edits.d.ts +12 -0
- package/dist/source-sync/skill-edits.js +122 -0
- package/dist/source-sync/snapshots.d.ts +48 -0
- package/dist/source-sync/snapshots.js +448 -0
- package/dist/source-sync/types.d.ts +9 -0
- package/dist/source-sync/types.js +14 -0
- package/dist/source-sync/workspace.d.ts +66 -0
- package/dist/source-sync/workspace.js +273 -0
- package/dist/store/agent-body.d.ts +6 -2
- package/dist/store/agent-body.js +18 -7
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +2 -1
- package/dist/store/seal.d.ts +5 -1
- package/dist/store/seal.js +12 -3
- package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
- package/dist/store/sqlite/project-checkpoints.js +70 -0
- package/dist/store/sqlite/run-launch.d.ts +4 -12
- package/dist/store/sqlite/run-launch.js +5 -19
- package/dist/store/sqlite/store.js +224 -170
- package/dist/store/store.d.ts +116 -39
- package/dist/store/store.js +14 -1
- package/dist/store-reads/learning.d.ts +2 -2
- package/dist/store-view.d.ts +3 -1
- package/dist/store-view.js +17 -5
- package/dist/suggestions.d.ts +282 -0
- package/dist/suggestions.js +919 -0
- package/dist/telemetry.d.ts +8 -1
- package/dist/telemetry.js +12 -4
- package/dist/template-import.d.ts +27 -2
- package/dist/template-import.js +148 -13
- package/dist/templates.d.ts +103 -77
- package/dist/templates.js +71 -17
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +8 -0
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +8 -8
- package/dist/trigger-launch-hook.d.ts +49 -0
- package/dist/trigger-launch-hook.js +91 -0
- package/dist/trigger-targets.d.ts +14 -1
- package/dist/trigger-targets.js +20 -0
- package/dist/triggers.d.ts +54 -5
- package/dist/triggers.js +143 -8
- package/dist/uploads-archil.js +1 -1
- package/dist/uploads.js +1 -1
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +3 -4
- package/dist/workspace/computer-for-claim.d.ts +2 -0
- package/dist/workspace/computer-for-claim.js +43 -0
- package/dist/workspace/paths.d.ts +6 -0
- package/dist/workspace/paths.js +6 -0
- package/dist/workspace/resolve-computer.d.ts +1 -0
- package/dist/workspace/run-tools.d.ts +2 -0
- package/dist/workspace/run-tools.js +8 -0
- package/dist/workspace/synced-folder.d.ts +1 -1
- package/dist/workspace/synced-folder.js +11 -14
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +2 -1
- package/templates/README.md +8 -4
- package/templates/agent-scout/agent.md +46 -0
- package/templates/agent-scout/skills/scout/SKILL.md +88 -0
- package/templates/agent-scout/skills/scout/suggestions.schema.json +112 -0
- package/dist/console/assets/index-B-D0EM3j.js +0 -733
- package/dist/console/assets/index-DlQepP2J.css +0 -1
package/dist/runner/redact.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// loop's failed end), the runner's events, and the model route's error text that pi records. Each passes through the one
|
|
4
4
|
// function made here, which puts "[redacted]" in place of every secret value the runner holds, in every form a value
|
|
5
5
|
// can take in text (key-refusal.ts redactedAnswer: as written, JSON-escaped, base64, hex and percent-encoded).
|
|
6
|
-
import { redactedAnswer } from "../key-refusal.js";
|
|
6
|
+
import { heldNumber, redactedAnswer } from "../key-refusal.js";
|
|
7
7
|
import { MIN_SECRET } from "../learn/secrets.js";
|
|
8
8
|
import { hostSecrets, SECRET_NAMES } from "../secrets.js";
|
|
9
9
|
import { planOf } from "../chatgpt-plan.js";
|
|
@@ -39,6 +39,8 @@ export function heldRedactor(base) {
|
|
|
39
39
|
if (isHeld(base))
|
|
40
40
|
return base;
|
|
41
41
|
const held = new Set();
|
|
42
|
+
/** Each run's carried values and their cut, made at its first use after a carry. */
|
|
43
|
+
const carried = new Map();
|
|
42
44
|
const cut = ((text) => {
|
|
43
45
|
const once = base(text);
|
|
44
46
|
return once && held.size ? redactedAnswer(once, [...held]) : once;
|
|
@@ -48,12 +50,76 @@ export function heldRedactor(base) {
|
|
|
48
50
|
if (value.replace(/\s+/g, "").length >= MIN_SECRET)
|
|
49
51
|
held.add(value);
|
|
50
52
|
};
|
|
53
|
+
cut.carry = (runId, values) => {
|
|
54
|
+
cut.hold(values);
|
|
55
|
+
const kept = values.filter((value) => held.has(value));
|
|
56
|
+
if (!kept.length)
|
|
57
|
+
return;
|
|
58
|
+
const run = new Set([...(carried.get(runId)?.values ?? []), ...kept]);
|
|
59
|
+
carried.set(runId, { values: run });
|
|
60
|
+
};
|
|
61
|
+
cut.carried = (runId) => {
|
|
62
|
+
const run = carried.get(runId);
|
|
63
|
+
if (!run)
|
|
64
|
+
return undefined;
|
|
65
|
+
return (run.cut ??= secretRedactor([...run.values]));
|
|
66
|
+
};
|
|
67
|
+
cut.dropCarried = (runId) => void carried.delete(runId);
|
|
51
68
|
// Its values are the base's and every one held since; a base that does not know its own leaves them unknown.
|
|
52
69
|
const known = base.heldValues;
|
|
53
70
|
if (known)
|
|
54
71
|
withHeldValues(cut, () => [...new Set([...known(), ...held])]);
|
|
55
72
|
return cut;
|
|
56
73
|
}
|
|
74
|
+
/** Every string inside `value` cut by `cut`: what the run's process writes, as the runner's redactor would cut it in a
|
|
75
|
+
* loop of its own (rule three: no secret the runner holds is written). `names`: each object's and map's names too (a
|
|
76
|
+
* model may write a value as a JSON name); two names cut to one are both kept, the later ones numbered. A number that
|
|
77
|
+
* shows a value `cut` holds (a key of digits alone, quoted as a JSON number: key-refusal.ts heldNumber) is "[redacted]". */
|
|
78
|
+
export function cutDeep(value, cut, names = false) {
|
|
79
|
+
// The values `cut` holds, read once for the whole of `value` at its first number.
|
|
80
|
+
let held;
|
|
81
|
+
const shows = (number) => {
|
|
82
|
+
const text = String(number);
|
|
83
|
+
if (held === undefined)
|
|
84
|
+
held = cut.heldValues?.() ?? null;
|
|
85
|
+
if (!held)
|
|
86
|
+
return cut(text) !== text;
|
|
87
|
+
// Digits shorter than any held value can't hold one, in any form; only the same number written otherwise can.
|
|
88
|
+
if (text.length < MIN_SECRET)
|
|
89
|
+
return held.some((secret) => secret.trim() !== "" && Number(secret) === Number(number));
|
|
90
|
+
return heldNumber(number, held);
|
|
91
|
+
};
|
|
92
|
+
const named = (taken, key) => {
|
|
93
|
+
const once = names ? cut(key) : key;
|
|
94
|
+
let name = once;
|
|
95
|
+
for (let n = 2; taken(name); n++)
|
|
96
|
+
name = `${once} (${n})`;
|
|
97
|
+
return name;
|
|
98
|
+
};
|
|
99
|
+
const walk = (one) => {
|
|
100
|
+
if (typeof one === "string")
|
|
101
|
+
return cut(one);
|
|
102
|
+
if (typeof one === "number" || typeof one === "bigint")
|
|
103
|
+
return shows(one) ? "[redacted]" : one;
|
|
104
|
+
if (one === null || typeof one !== "object")
|
|
105
|
+
return one;
|
|
106
|
+
if (ArrayBuffer.isView(one) || one instanceof Date || one instanceof RegExp || one instanceof ArrayBuffer)
|
|
107
|
+
return one;
|
|
108
|
+
if (Array.isArray(one))
|
|
109
|
+
return one.map(walk);
|
|
110
|
+
if (one instanceof Map) {
|
|
111
|
+
const out = new Map();
|
|
112
|
+
for (const [k, v] of one)
|
|
113
|
+
out.set(typeof k === "string" ? named((name) => out.has(name), k) : k, walk(v));
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
const out = {};
|
|
117
|
+
for (const key of Object.keys(one))
|
|
118
|
+
Object.defineProperty(out, named((name) => Object.hasOwn(out, name), key), { value: walk(one[key]), enumerable: true, writable: true, configurable: true });
|
|
119
|
+
return out;
|
|
120
|
+
};
|
|
121
|
+
return walk(value);
|
|
122
|
+
}
|
|
57
123
|
/** The secrets a claim opened from the store (`env`, claimSecrets' environment for the run) held by `redact`, the run's
|
|
58
124
|
* one redactor, so a host tool's or a provider's error that echoes one is cut in the run's record, its end and its logs. */
|
|
59
125
|
export function holdClaimed(redact, env) {
|
|
@@ -9,6 +9,15 @@ export declare class ChannelClosed extends Error {
|
|
|
9
9
|
export declare class ChannelRefused extends Error {
|
|
10
10
|
name: string;
|
|
11
11
|
}
|
|
12
|
+
/** A call or an answer past the channel's cap: it fails alone, and the channel goes on. Its bytes and the cap cross with
|
|
13
|
+
* it (registered on both sides), so a runner can tell a run whose records no longer fit from one that may go on. */
|
|
14
|
+
export declare class FrameTooLarge extends RangeError {
|
|
15
|
+
name: string;
|
|
16
|
+
readonly bytes: number;
|
|
17
|
+
readonly limit: number;
|
|
18
|
+
/** `what`: "an answer", or "a call of <method>". */
|
|
19
|
+
constructor(what: string, bytes: number, limit: number);
|
|
20
|
+
}
|
|
12
21
|
export declare function registerErrors(classes: Record<string, abstract new (...args: never[]) => Error>): void;
|
|
13
22
|
/** What a target exposed by name does with a call: its method and arguments, as decoded. */
|
|
14
23
|
export type Dispatch = (method: string, args: unknown[]) => unknown;
|
|
@@ -24,6 +24,19 @@ export class ChannelClosed extends Error {
|
|
|
24
24
|
export class ChannelRefused extends Error {
|
|
25
25
|
name = "ChannelRefused";
|
|
26
26
|
}
|
|
27
|
+
/** A call or an answer past the channel's cap: it fails alone, and the channel goes on. Its bytes and the cap cross with
|
|
28
|
+
* it (registered on both sides), so a runner can tell a run whose records no longer fit from one that may go on. */
|
|
29
|
+
export class FrameTooLarge extends RangeError {
|
|
30
|
+
name = "FrameTooLarge";
|
|
31
|
+
bytes;
|
|
32
|
+
limit;
|
|
33
|
+
/** `what`: "an answer", or "a call of <method>". */
|
|
34
|
+
constructor(what, bytes, limit) {
|
|
35
|
+
super(what === "an answer" ? `an answer of ${bytes} bytes is past the channel's ${limit}` : `${what} is ${bytes} bytes, past the channel's ${limit}`);
|
|
36
|
+
this.bytes = bytes;
|
|
37
|
+
this.limit = limit;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
27
40
|
/** The error classes made again by name on the receiving side, so instanceof holds across the channel. Each side
|
|
28
41
|
* registers the ones it may receive (registerErrors). */
|
|
29
42
|
const ERRORS = new Map();
|
|
@@ -189,11 +202,11 @@ export class Channel {
|
|
|
189
202
|
if (message.t === "call") {
|
|
190
203
|
const pending = this.#pending.get(message.id);
|
|
191
204
|
this.#pending.delete(message.id);
|
|
192
|
-
pending?.reject(new
|
|
205
|
+
pending?.reject(new FrameTooLarge(`a call of ${String(message.m)}`, body.length, this.#maxFrame));
|
|
193
206
|
return;
|
|
194
207
|
}
|
|
195
208
|
if (message.t === "ok")
|
|
196
|
-
return this.#send({ t: "err", id: message.id, e: this.#encode(new
|
|
209
|
+
return this.#send({ t: "err", id: message.id, e: this.#encode(new FrameTooLarge("an answer", body.length, this.#maxFrame)) });
|
|
197
210
|
return;
|
|
198
211
|
}
|
|
199
212
|
const head = Buffer.alloc(4);
|
|
@@ -32,6 +32,9 @@ export declare const runIsolationName: (isolation: RunIsolation) => "uid" | "pro
|
|
|
32
32
|
export declare class RunIsolationRefused extends Error {
|
|
33
33
|
name: string;
|
|
34
34
|
}
|
|
35
|
+
/** Whether runIsolationOf gives `env` on this host `process` (every run as the runner's own user), told before it is
|
|
36
|
+
* asked: `same`, or no helper and not `slot`. A helper that is there but cannot switch refuses the runner instead. */
|
|
37
|
+
export declare const runsAsOwnUser: (env: NodeJS.ProcessEnv, helper?: string) => boolean;
|
|
35
38
|
/** This host's isolation for `loops` runs at once, by `env` and the helper: the helper's own check that it can switch
|
|
36
39
|
* (its effective set holds what it needs) decides `uid`; none installed (a local install), `process`; `same`, `process`
|
|
37
40
|
* said in the log. A helper that cannot switch is refused in words naming the setting, never a quiet fall back. `loops`
|
|
@@ -89,9 +92,6 @@ export declare function reapSlot(isolation: Extract<RunIsolation, {
|
|
|
89
92
|
/** `value` as data: every function, symbol and class's method left out, so nothing the runner holds is handed by
|
|
90
93
|
* reference to the run's process unless a target hands it on purpose. */
|
|
91
94
|
export declare function dataOnly(value: unknown, seen?: Set<object>): unknown;
|
|
92
|
-
/** Every string inside `value` cut by `cut`: what the run's process writes, as the runner's redactor would cut it in a
|
|
93
|
-
* loop of its own (rule three: no secret the runner holds is written). */
|
|
94
|
-
export declare function cutDeep<T>(value: T, cut: (text: string) => string): T;
|
|
95
95
|
/** What the store target knows of the claim: its run and the run's agent and revision. */
|
|
96
96
|
export interface Bound {
|
|
97
97
|
readonly claim: Claim;
|
|
@@ -116,6 +116,7 @@ interface ClaimReads {
|
|
|
116
116
|
readonly body: Record<string, unknown>;
|
|
117
117
|
};
|
|
118
118
|
readonly claimed: NodeJS.ProcessEnv;
|
|
119
|
+
readonly signal?: AbortSignal;
|
|
119
120
|
}
|
|
120
121
|
/** Held (held.ts) for one claim, on the runner: each answer the claim's own, read with the runner's seal key from the
|
|
121
122
|
* runner's own reads of the claim; every argument from the run's process is checked or ignored. `bigs`: the run's pieced
|
|
@@ -126,6 +127,7 @@ export declare function heldFor(deps: AdapterSpecDeps & {
|
|
|
126
127
|
held: Held;
|
|
127
128
|
inputs(): Promise<void>;
|
|
128
129
|
release(): Promise<void>;
|
|
130
|
+
projectEnd?(): Promise<void>;
|
|
129
131
|
};
|
|
130
132
|
/** A call of the learning folder a run's process asks (Held.learning), on the runner's own Workspace of the claim's
|
|
131
133
|
* agent's folder: reads pass, and the learning script runs its reads, with the script's own environment (the script
|
|
@@ -156,6 +158,9 @@ export declare const childArgv: () => string[];
|
|
|
156
158
|
export declare const runsInRunner: (harness: string, launch: Pick<RunLaunch, "sdk" | "native" | "cli_learning">) => boolean;
|
|
157
159
|
/** The words a run on Claude Code's login on this machine is refused in where each run is a user of its own. */
|
|
158
160
|
export declare const LOGIN_NEEDS_SERVER_USER = "A run on Claude Code's login on this machine needs runs under the server's own user, and this runner runs each run as a user of its own: set AGENTRUN_RUN_USER=same, or give the run a model_key.";
|
|
161
|
+
/** The words a run on a harness recipe is refused in where each run is a user of its own (harness-table.ts recipeHarness). */
|
|
162
|
+
export declare const RECIPE_NEEDS_SERVER_USER = "A run on a harness recipe needs runs under the server's own user, since its install, its check and its owner's sign-in are that user's alone, and this runner runs each run as a user of its own: set AGENTRUN_RUN_USER=same on this runner.";
|
|
163
|
+
export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
|
|
159
164
|
/** Whether run `runId` stays in its runner's process: runsInRunner's, and a workflow run on a server with a documents
|
|
160
165
|
* directory (launch.documents), whose reads and writes (a pdf_pages call's pages) are rooted in a folder the server's
|
|
161
166
|
* user holds and no slot's user is given; its nodes run the server's own tools alone, no agent's code. A run on Claude
|
|
@@ -176,4 +181,3 @@ export declare function runChannel(socket: Duplex, onClose: (why: Error) => void
|
|
|
176
181
|
readonly bigs?: RunBigWrites;
|
|
177
182
|
readonly maxFrame?: number;
|
|
178
183
|
}): Channel;
|
|
179
|
-
export {};
|
|
@@ -22,7 +22,7 @@ import { putLiveViewer, dropLiveViewer } from "../browser-live.js";
|
|
|
22
22
|
import { CALENDAR_EVENTS } from "../calendar/names.js";
|
|
23
23
|
import { openCalendar } from "../calendar/address.js";
|
|
24
24
|
import { openAccount } from "../email/account.js";
|
|
25
|
-
import { harnessOf } from "../harness-table.js";
|
|
25
|
+
import { harnessOf, recipeHarness } from "../harness-table.js";
|
|
26
26
|
import { installDirOf, installForClaim, shareInstall } from "../harness-install.js";
|
|
27
27
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
28
28
|
import { planOf } from "../chatgpt-plan.js";
|
|
@@ -31,7 +31,7 @@ import { vendorsOver } from "../sign-ins.js";
|
|
|
31
31
|
import { decisionProvidersIn, fauxFetch } from "../decisions.js";
|
|
32
32
|
import { DECISION_PROVIDER_KEYS } from "../tool-plane.js";
|
|
33
33
|
import { learningEndOfRun } from "./learning-end.js";
|
|
34
|
-
import { runnerSecrets } from "./redact.js";
|
|
34
|
+
import { cutDeep, heldRedactor, runnerSecrets } from "./redact.js";
|
|
35
35
|
import { storeSecrets } from "./store-secrets.js";
|
|
36
36
|
import { FAUX_ENV, GATEWAY_KEY_ENV } from "../model.js";
|
|
37
37
|
import { SAVED_GATEWAY_ENV, savedGatewayIn } from "../model-gateway.js";
|
|
@@ -47,7 +47,7 @@ import { agentDirName, recordingsFolder, runFolder, scratchFolder } from "../wor
|
|
|
47
47
|
import { keptKeyOf } from "../workspace/computer-kept.js";
|
|
48
48
|
import { claimModelKey, claimSecrets, claimSpendOff, hostDecisionKeys, learnedDecisionKeys, openRunModelKey, savedModelKeys, serverKeyless, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
|
|
49
49
|
import { githubAppAccess } from "./github-app.js";
|
|
50
|
-
import { githubPullOf } from "../github.js";
|
|
50
|
+
import { githubPullOf, githubTargetOf } from "../github.js";
|
|
51
51
|
import { isObject } from "../validate.js";
|
|
52
52
|
import { liveForRun, runnerLiveOf } from "../live-reach.js";
|
|
53
53
|
import { learningFolderOf, secretsShown } from "../learning.js";
|
|
@@ -58,10 +58,10 @@ import { withAudit } from "./audit.js";
|
|
|
58
58
|
import { compareEndOfRun } from "./compare-end.js";
|
|
59
59
|
import { learnedFirst } from "./learned-first.js";
|
|
60
60
|
import { workflowsAt } from "./learning-seed.js";
|
|
61
|
-
import { heldMcpOf, mcpForClaim
|
|
61
|
+
import { heldMcpOf, mcpForClaim } from "./mcp-run.js";
|
|
62
62
|
import { learnedTiers, learnsWorkflows, mcpReachOf } from "./adapter-run-spec.js";
|
|
63
63
|
import { createDispatchLoop } from "./dispatch.js";
|
|
64
|
-
import { resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
|
|
64
|
+
import { refuseRecipeTriggerRun, resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
|
|
65
65
|
import { isWorkflowRevision } from "./workflow-loop.js";
|
|
66
66
|
import { loginForRun } from "../claude-login.js";
|
|
67
67
|
import { heardComputerHold } from "./computer-journal.js";
|
|
@@ -73,6 +73,12 @@ import { runBigWrites } from "./big-writes.js";
|
|
|
73
73
|
import { SERVER_SLOTS } from "../web-save.js";
|
|
74
74
|
import { launchOnItsDisk, readLaunchBody } from "../run-launch.js";
|
|
75
75
|
import { SUBAGENT_TOOL } from "./subagent.js";
|
|
76
|
+
import { sourceSyncOf } from "../source-sync/types.js";
|
|
77
|
+
import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
|
|
78
|
+
import { beginSourceIO } from "../source-sync/io.js";
|
|
79
|
+
import { runTools } from "../workspace/run-tools.js";
|
|
80
|
+
import { ProjectHostGate } from "./project-host.js";
|
|
81
|
+
import { runProjectCheckpoint } from "./project-checkpoint.js";
|
|
76
82
|
/** The image's helper that starts a run's process as its slot's uid (packages/serve/runas). */
|
|
77
83
|
export const RUNAS_HELPER = "/usr/local/bin/agentrun-runas";
|
|
78
84
|
/** `same`: every run runs as the runner's own user, the helper unused, said in the runner's log. */
|
|
@@ -106,6 +112,9 @@ const execText = (file, args, timeoutMs) => new Promise((resolve) => {
|
|
|
106
112
|
resolve({ code: -1, stdout: "", stderr: error?.message ?? String(error) });
|
|
107
113
|
}
|
|
108
114
|
});
|
|
115
|
+
/** Whether runIsolationOf gives `env` on this host `process` (every run as the runner's own user), told before it is
|
|
116
|
+
* asked: `same`, or no helper and not `slot`. A helper that is there but cannot switch refuses the runner instead. */
|
|
117
|
+
export const runsAsOwnUser = (env, helper = RUNAS_HELPER) => env[RUN_USER_ENV] === "same" || (!existsSync(helper) && env[RUN_USER_ENV] !== "slot");
|
|
109
118
|
/** This host's isolation for `loops` runs at once, by `env` and the helper: the helper's own check that it can switch
|
|
110
119
|
* (its effective set holds what it needs) decides `uid`; none installed (a local install), `process`; `same`, `process`
|
|
111
120
|
* said in the log. A helper that cannot switch is refused in words naming the setting, never a quiet fall back. `loops`
|
|
@@ -363,24 +372,6 @@ export function dataOnly(value, seen = new Set()) {
|
|
|
363
372
|
seen.delete(value);
|
|
364
373
|
}
|
|
365
374
|
}
|
|
366
|
-
/** Every string inside `value` cut by `cut`: what the run's process writes, as the runner's redactor would cut it in a
|
|
367
|
-
* loop of its own (rule three: no secret the runner holds is written). */
|
|
368
|
-
export function cutDeep(value, cut) {
|
|
369
|
-
if (typeof value === "string")
|
|
370
|
-
return cut(value);
|
|
371
|
-
if (value === null || typeof value !== "object")
|
|
372
|
-
return value;
|
|
373
|
-
if (ArrayBuffer.isView(value) || value instanceof Date || value instanceof RegExp || value instanceof ArrayBuffer)
|
|
374
|
-
return value;
|
|
375
|
-
if (Array.isArray(value))
|
|
376
|
-
return value.map((item) => cutDeep(item, cut));
|
|
377
|
-
if (value instanceof Map)
|
|
378
|
-
return new Map([...value].map(([k, v]) => [k, cutDeep(v, cut)]));
|
|
379
|
-
const out = {};
|
|
380
|
-
for (const key of Object.keys(value))
|
|
381
|
-
Object.defineProperty(out, key, { value: cutDeep(value[key], cut), enumerable: true, writable: true, configurable: true });
|
|
382
|
-
return out;
|
|
383
|
-
}
|
|
384
375
|
const ownRun = (args, bound) => args[0] === bound.claim.runId;
|
|
385
376
|
/** The claim's run, or its own audit's shadow run, whose spend its cap gates read beside it (learning-end.ts besideOf). */
|
|
386
377
|
const ownRunOrShadow = (args, bound) => args[0] === bound.claim.runId || args[0] === shadowRunId(bound.claim.runId);
|
|
@@ -569,8 +560,52 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
569
560
|
const sealKey = deps.sealKey;
|
|
570
561
|
const store = deps.store;
|
|
571
562
|
const granted = revision.body.tools ?? [];
|
|
563
|
+
const admitAuxiliary = sourceAuxiliaryAdmitter(store, { data: deps.data, sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } });
|
|
572
564
|
const keys = { store, sealKey, env: deps.env };
|
|
573
565
|
const releases = [() => bigs.close()];
|
|
566
|
+
const source = sourceSyncOf(revision.body), placed = launch.sourceProject;
|
|
567
|
+
const moved = !!source && !!placed && source.id === placed.sourceId && source.project === placed.digest && placed.baselineRevision === run.revisionId;
|
|
568
|
+
const projectGate = moved ? new ProjectHostGate() : undefined;
|
|
569
|
+
const projectStop = new AbortController();
|
|
570
|
+
const projectSignal = reads.signal ? AbortSignal.any([reads.signal, projectStop.signal]) : projectStop.signal;
|
|
571
|
+
let projectIO, projectCapture;
|
|
572
|
+
let projectComputer, projectWorkspace, projectMode = 1;
|
|
573
|
+
let projectFailed = false, projectReleased = false, projectClosing = false, projectCaptureDone = false;
|
|
574
|
+
let projectRelease;
|
|
575
|
+
let projectCleanup;
|
|
576
|
+
const projectOwns = async (settlingAudit = false) => {
|
|
577
|
+
projectSignal.throwIfAborted();
|
|
578
|
+
const row = await store.runs.get(claim.runId);
|
|
579
|
+
// A never-waiting audit journals its Ask/cap as parked before terminalizing under this same claim. Only its
|
|
580
|
+
// checkpoint may finish from that state; ordinary held calls still require running, and claim identity is exact.
|
|
581
|
+
const settlingParkedAudit = settlingAudit && launch.audit !== undefined && row?.state === "parked";
|
|
582
|
+
if (!row || row.agentId !== run.agentId || row.revisionId !== run.revisionId || row.epoch !== claim.epoch || row.runner !== claim.runner || row.state !== "running" && !settlingParkedAudit)
|
|
583
|
+
throw new ClaimRefused("This project checkpoint no longer holds its original run claim.");
|
|
584
|
+
};
|
|
585
|
+
const ownProject = async (settlingAudit = false) => {
|
|
586
|
+
if (!projectGate)
|
|
587
|
+
return;
|
|
588
|
+
await projectOwns(settlingAudit);
|
|
589
|
+
await (projectIO ??= beginSourceIO(store, run.agentId, "snapshot"));
|
|
590
|
+
};
|
|
591
|
+
const projectCall = (work) => projectGate ? projectGate.run(async () => { await ownProject(); return work(); }) : work();
|
|
592
|
+
const projectWorkSettled = async () => { await projectCapture; await projectGate?.drain(); };
|
|
593
|
+
const projectSettled = async () => { await projectWorkSettled(); await projectCleanup?.catch(() => undefined); };
|
|
594
|
+
/** Cleanup closes capture admission synchronously. A capture already admitted finishes first; one arriving later
|
|
595
|
+
* cannot use resources being relinquished. Cleanup itself remains owned and is awaited by the host's release. */
|
|
596
|
+
const cleanProject = (work) => {
|
|
597
|
+
if (!projectGate)
|
|
598
|
+
return work();
|
|
599
|
+
if (projectReleased)
|
|
600
|
+
return Promise.reject(new ClaimRefused("This claim's project resources have already been released."));
|
|
601
|
+
projectClosing = true;
|
|
602
|
+
projectGate.close();
|
|
603
|
+
const previous = projectCleanup;
|
|
604
|
+
const pending = (async () => { await previous?.catch(() => undefined); await projectWorkSettled(); return work(); })();
|
|
605
|
+
projectCleanup = pending;
|
|
606
|
+
void pending.catch(() => { projectFailed = true; });
|
|
607
|
+
return pending;
|
|
608
|
+
};
|
|
574
609
|
const fromGitHub = launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github";
|
|
575
610
|
const github = () => githubAppAccess(store, sealKey, launch.input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) });
|
|
576
611
|
/** Mode 2's Archil claim, made once for the claim on the runner, its folder the run's. */
|
|
@@ -603,6 +638,62 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
603
638
|
/** The claim's one learned first choice: its promotion's writes are made once, however often the process asks. */
|
|
604
639
|
let chosen;
|
|
605
640
|
const held = {
|
|
641
|
+
projectCheckpoint: (...args) => {
|
|
642
|
+
if (args.length > 1 || args[0] !== undefined && !(args[0] instanceof AbortSignal))
|
|
643
|
+
throw new ClaimRefused("A project checkpoint accepts only its cancellation signal.");
|
|
644
|
+
if (!projectGate || !placed || !source)
|
|
645
|
+
throw new ClaimRefused("This claim has no matching placed source project.");
|
|
646
|
+
if (projectReleased)
|
|
647
|
+
throw new ClaimRefused("This claim's project resources have already been released.");
|
|
648
|
+
if (projectCapture)
|
|
649
|
+
return projectCapture;
|
|
650
|
+
if (projectClosing)
|
|
651
|
+
throw new ClaimRefused("This claim's project resources are closing for cleanup.");
|
|
652
|
+
projectGate.close();
|
|
653
|
+
const signal = args[0] ? AbortSignal.any([projectSignal, args[0], AbortSignal.timeout(60_000)]) : AbortSignal.any([projectSignal, AbortSignal.timeout(60_000)]);
|
|
654
|
+
const uncertain = () => ({ version: 1, status: "uncertain", sourceId: source.id, runId: claim.runId, epoch: claim.epoch, reason: "project_not_settled", stage: "drain" });
|
|
655
|
+
projectCapture = (async () => {
|
|
656
|
+
let checkpoint;
|
|
657
|
+
let tools;
|
|
658
|
+
let result;
|
|
659
|
+
try {
|
|
660
|
+
await projectGate.drain();
|
|
661
|
+
await ownProject(true);
|
|
662
|
+
signal.throwIfAborted();
|
|
663
|
+
await projectOwns(true);
|
|
664
|
+
if (projectGate.uncertain)
|
|
665
|
+
throw new ClaimRefused("An earlier project operation has an unresolved outcome.");
|
|
666
|
+
if (!projectComputer || !projectWorkspace)
|
|
667
|
+
throw new ClaimRefused("The project's held execution resources are unavailable.");
|
|
668
|
+
checkpoint = runProjectCheckpoint({ store, agentId: run.agentId, claim, launch, computer: projectComputer, ioHeld: true,
|
|
669
|
+
tools: { get workspace() { if (!tools)
|
|
670
|
+
throw new ClaimRefused("Project settlement has not opened its workspace."); return tools.workspace; },
|
|
671
|
+
settleProject: async () => { tools = await runTools(projectWorkspace, projectComputer.computer, { mode: projectMode, context: BACKGROUND_CONTEXT }); return tools.settleProject(); } },
|
|
672
|
+
workspace: { data: deps.data, sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } },
|
|
673
|
+
secrets: async () => runnerSecrets(deps.env, [...runnerSecrets(claimed), ...await storeSecrets(store, sealKey, deps.data)]), });
|
|
674
|
+
result = await checkpoint.capture(signal);
|
|
675
|
+
signal.throwIfAborted();
|
|
676
|
+
await projectOwns(true);
|
|
677
|
+
if (result.status !== "candidate" && result.status !== "discarded" && !checkpoint.refusalSettled())
|
|
678
|
+
projectFailed = true;
|
|
679
|
+
}
|
|
680
|
+
catch {
|
|
681
|
+
projectFailed = true;
|
|
682
|
+
result = checkpoint?.uncertain() ?? uncertain();
|
|
683
|
+
}
|
|
684
|
+
finally {
|
|
685
|
+
try {
|
|
686
|
+
await tools?.end();
|
|
687
|
+
}
|
|
688
|
+
catch {
|
|
689
|
+
projectFailed = true;
|
|
690
|
+
result = { ...uncertain(), reason: "project_capture_failed", stage: "cleanup" };
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return result;
|
|
694
|
+
})().finally(() => { projectCaptureDone = true; });
|
|
695
|
+
return projectCapture;
|
|
696
|
+
},
|
|
606
697
|
plan: async () => {
|
|
607
698
|
const plan = planOf(claimed);
|
|
608
699
|
if (!plan)
|
|
@@ -615,28 +706,32 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
615
706
|
return runSignIn(store, sealKey, claim, String(resolution), { vendors: vendorsOver(() => claimed, vendorFetch), log });
|
|
616
707
|
},
|
|
617
708
|
verifySignIn: (kept, at) => verifyRunSignIn(store, sealKey, claim, kept, Number(at)),
|
|
618
|
-
mcp: async (
|
|
709
|
+
mcp: (ask) => projectCall(async () => {
|
|
619
710
|
const reach = await mcpReachOf(deps);
|
|
620
711
|
const harness = { commit: (change) => change({ appendEntry: async (_conversation, entry) => void (await ask.appendRoot(dataOnly(entry))) }) };
|
|
621
|
-
const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => runFolder(deps.data, run.agentId, claim.runId), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...reach, capped:
|
|
712
|
+
const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => runFolder(deps.data, run.agentId, claim.runId), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...reach, capped: launch.maxCostUsd !== undefined, media: { env: deps.env, web: deps.evalFakes?.(run.agentId)?.web, slots: deps.saveSlots } });
|
|
622
713
|
if (!made)
|
|
623
714
|
return undefined;
|
|
624
715
|
releases.push(() => made.release());
|
|
625
|
-
|
|
626
|
-
|
|
716
|
+
const exposed = heldMcpOf(made, cut);
|
|
717
|
+
return projectGate ? projectGate.capability(exposed) : exposed;
|
|
718
|
+
}),
|
|
627
719
|
githubAppAccess: async () => {
|
|
628
720
|
// A run's process mints for one thing alone: its revision's pull-request checkout (pr-checkout.ts), of the pull
|
|
629
721
|
// request its launch's payload names, contents read. Its MCP mints on the runner (mcp above). So the mint handed
|
|
630
722
|
// here makes that token and no other, whatever repository or permissions the process names.
|
|
631
|
-
|
|
723
|
+
// A repository checkout's is the repository the run names (its start's repo, else the first https://github.com
|
|
724
|
+
// URL its owner's words name): the same one repository, contents read.
|
|
725
|
+
if (revision.body.checkout !== "pull_request" && revision.body.checkout !== "repository")
|
|
632
726
|
return undefined;
|
|
633
|
-
const
|
|
727
|
+
const content = isObject(launch.input) ? launch.input.content : launch.input;
|
|
728
|
+
const pull = revision.body.checkout === "pull_request" ? githubPullOf(content, { payload: fromGitHub }) : launch.repo !== undefined ? { repo: launch.repo } : githubTargetOf(content, { payload: fromGitHub });
|
|
634
729
|
if (!pull)
|
|
635
730
|
return undefined;
|
|
636
731
|
const access = await github();
|
|
637
732
|
if (!access)
|
|
638
733
|
return undefined;
|
|
639
|
-
const bound = { repo: pull.repo, ...(pull.installation !== undefined ? { installation: pull.installation } : {}) };
|
|
734
|
+
const bound = { repo: pull.repo, ...("installation" in pull && pull.installation !== undefined ? { installation: pull.installation } : {}) };
|
|
640
735
|
const mint = async (to) => {
|
|
641
736
|
if (to?.repo !== bound.repo || to.installation !== bound.installation) {
|
|
642
737
|
log(`run ${claim.runId}: its process asked for a GitHub token of another repository than its pull request's, which a run's process may not`);
|
|
@@ -702,7 +797,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
702
797
|
// install from before installs were shared too.
|
|
703
798
|
await shareInstall(installDirOf(deps.data, harness));
|
|
704
799
|
},
|
|
705
|
-
computer: async (
|
|
800
|
+
computer: (ask) => projectCall(async () => {
|
|
706
801
|
const made = await archilOf();
|
|
707
802
|
const mode = made === undefined ? 1 : 2;
|
|
708
803
|
const ws = made === undefined
|
|
@@ -726,17 +821,27 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
726
821
|
const claimed = got;
|
|
727
822
|
if (typeof claimed?.release === "function")
|
|
728
823
|
releases.push(() => claimed.release("ended"));
|
|
824
|
+
if (projectGate) {
|
|
825
|
+
projectComputer = got;
|
|
826
|
+
projectWorkspace = ws.workspace;
|
|
827
|
+
projectMode = mode;
|
|
828
|
+
const { syncProject: _sync, ...exposed } = got;
|
|
829
|
+
return { ...exposed, ...(exposed.computer ? { computer: projectGate.capability(exposed.computer) } : {}),
|
|
830
|
+
release: (...args) => cleanProject(() => exposed.release(...args)),
|
|
831
|
+
...(exposed.park ? { park: (...args) => cleanProject(() => exposed.park(...args)) } : {}) };
|
|
832
|
+
}
|
|
729
833
|
return got;
|
|
730
|
-
},
|
|
731
|
-
archil: async () => {
|
|
834
|
+
}),
|
|
835
|
+
archil: () => projectCall(async () => {
|
|
732
836
|
const made = await archilOf();
|
|
733
837
|
if (made === undefined)
|
|
734
838
|
return undefined;
|
|
735
839
|
const ws = await openRunWorkspace({ mode: 2, agentId: run.agentId, runId: claim.runId, archil: made, log });
|
|
736
840
|
releases.push(() => ws.end());
|
|
737
841
|
// A write bigger than the channel's frame is pulled in pieces and written here, on this Workspace (big-writes.ts).
|
|
738
|
-
return { workspace:
|
|
739
|
-
|
|
842
|
+
return { workspace: projectGate ? projectGate.capability(ws.workspace) : ws.workspace, pieces: projectGate ? projectGate.capability(bigs.pieces(ws.workspace)) : bigs.pieces(ws.workspace),
|
|
843
|
+
revoke: () => cleanProject(() => made.revoke()), inherit: () => projectCall(async () => made.inherit()), release: async () => { } };
|
|
844
|
+
}),
|
|
740
845
|
endOfRun: async (input) => {
|
|
741
846
|
// The step as the run's spec builds it in a runner (adapter-run-spec.ts), over the runner's reads of the claim: what
|
|
742
847
|
// the run must never learn is every secret this runner holds, the keys its claim handed it, every secret the server
|
|
@@ -767,7 +872,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
767
872
|
log,
|
|
768
873
|
decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys(keys, DECISION_PROVIDER_KEYS)) }),
|
|
769
874
|
learningFolder: made === undefined ? (agentId) => learningFolderOf(deps.data, agentId) : (agentId) => learningWorkspace({ mode: "archil", agentId, archil: made }),
|
|
770
|
-
}), { store, agentId: run.agentId, revisionId: run.revisionId, context: BACKGROUND_CONTEXT, folder: await folderNow(), shown, log, sealKey, spendOff, launch, redact: cut });
|
|
875
|
+
}), { store, agentId: run.agentId, revisionId: run.revisionId, context: BACKGROUND_CONTEXT, folder: await folderNow(), shown, log, sealKey, spendOff, launch, redact: cut, admitAuxiliary });
|
|
771
876
|
if (!step)
|
|
772
877
|
return undefined;
|
|
773
878
|
// keptOf is the run's process's, asked over the channel: read once, for the round learningEndOfRun reads (the
|
|
@@ -795,10 +900,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
795
900
|
// workflows).
|
|
796
901
|
const start = learningStartOf(launch);
|
|
797
902
|
const folder = await folderNow();
|
|
798
|
-
const laid = ask?.laid === true && start && !seedFailed(start) && !start.noWorkflows ? await workflowsAt({ folder, shown }, start.seed).catch(() => []) : [];
|
|
903
|
+
const laid = ask?.laid === true && start && !seedFailed(start) && !start.noWorkflows ? await workflowsAt({ folder, store, shown }, start.seed).catch(() => []) : [];
|
|
799
904
|
const spendOff = await claimSpendOff(keys, await claimModelKey(keys, claim.runId));
|
|
800
905
|
const outputSchema = revision.body.outputSchema;
|
|
801
|
-
const got = await learnedFirst({ store, sealKey, agentId: run.agentId, runId: claim.runId, revisionId: run.revisionId, kind: revision.kind, ...(outputSchema !== undefined ? { outputSchema } : {}), launch, context: BACKGROUND_CONTEXT, log, folder, shown, spendOff }, laid);
|
|
906
|
+
const got = await learnedFirst({ store, sealKey, agentId: run.agentId, runId: claim.runId, revisionId: run.revisionId, kind: revision.kind, ...(outputSchema !== undefined ? { outputSchema } : {}), launch, context: BACKGROUND_CONTEXT, log, folder, shown, spendOff, admitAuxiliary }, laid);
|
|
802
907
|
learnedFlows = got.workflows;
|
|
803
908
|
return cutDeep(dataOnly(got), cut);
|
|
804
909
|
})()),
|
|
@@ -812,7 +917,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
812
917
|
};
|
|
813
918
|
return {
|
|
814
919
|
held,
|
|
815
|
-
inputs: async () => {
|
|
920
|
+
inputs: () => projectCall(async () => {
|
|
816
921
|
// The run's uploads and its opening message (uploads.ts placeRunInputs), placed by this runner before the run's
|
|
817
922
|
// process starts: their hold is the server's alone.
|
|
818
923
|
const made = await archilOf();
|
|
@@ -825,11 +930,24 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
825
930
|
finally {
|
|
826
931
|
await ws.end();
|
|
827
932
|
}
|
|
828
|
-
},
|
|
829
|
-
release: async () => {
|
|
933
|
+
}),
|
|
934
|
+
release: () => projectRelease ??= (async () => {
|
|
935
|
+
projectReleased = true;
|
|
936
|
+
projectGate?.close();
|
|
937
|
+
await projectSettled();
|
|
938
|
+
let failed = false;
|
|
830
939
|
for (const release of releases.reverse())
|
|
831
|
-
await Promise.resolve(release()).catch((error) => log(`run ${claim.runId}: a release on its runner failed: ${error?.message ?? error}`));
|
|
832
|
-
|
|
940
|
+
await Promise.resolve(release()).catch((error) => { failed = true; log(`run ${claim.runId}: a release on its runner failed: ${error?.message ?? error}`); });
|
|
941
|
+
if (projectIO && !failed && !projectFailed && !projectGate?.uncertain && !projectSignal.aborted)
|
|
942
|
+
await (await projectIO).settled();
|
|
943
|
+
})(),
|
|
944
|
+
...(projectGate ? { projectEnd: async () => {
|
|
945
|
+
if (projectCapture && !projectCaptureDone)
|
|
946
|
+
projectStop.abort(new Error("The project host is ending."));
|
|
947
|
+
projectReleased = true;
|
|
948
|
+
projectGate.close();
|
|
949
|
+
await projectSettled();
|
|
950
|
+
} } : {}),
|
|
833
951
|
};
|
|
834
952
|
}
|
|
835
953
|
/** `env`'s string values. */
|
|
@@ -889,6 +1007,9 @@ export const childArgv = () => [process.execPath, "--import", new URL("../secret
|
|
|
889
1007
|
export const runsInRunner = (harness, launch) => harness === "learning" || Boolean(launch.sdk) || Boolean(launch.native) || Boolean(launch.cli_learning);
|
|
890
1008
|
/** The words a run on Claude Code's login on this machine is refused in where each run is a user of its own. */
|
|
891
1009
|
export const LOGIN_NEEDS_SERVER_USER = `A run on Claude Code's login on this machine needs runs under the server's own user, and this runner runs each run as a user of its own: set ${RUN_USER_ENV}=same, or give the run a model_key.`;
|
|
1010
|
+
/** The words a run on a harness recipe is refused in where each run is a user of its own (harness-table.ts recipeHarness). */
|
|
1011
|
+
export const RECIPE_NEEDS_SERVER_USER = `A run on a harness recipe needs runs under the server's own user, since its install, its check and its owner's sign-in are that user's alone, and this runner runs each run as a user of its own: set ${RUN_USER_ENV}=same on this runner.`;
|
|
1012
|
+
export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
|
|
892
1013
|
/** Whether run `runId` stays in its runner's process: runsInRunner's, and a workflow run on a server with a documents
|
|
893
1014
|
* directory (launch.documents), whose reads and writes (a pdf_pages call's pages) are rooted in a folder the server's
|
|
894
1015
|
* user holds and no slot's user is given; its nodes run the server's own tools alone, no agent's code. A run on Claude
|
|
@@ -898,6 +1019,12 @@ export const LOGIN_NEEDS_SERVER_USER = `A run on Claude Code's login on this mac
|
|
|
898
1019
|
* the server's user. A run its caller handed a model key (model_key) runs on that key and never on the login
|
|
899
1020
|
* (cli-run-spec.ts), so it is a process of its own like any other. */
|
|
900
1021
|
export async function staysInRunner(deps, harness, launch, runId, isolation) {
|
|
1022
|
+
// A recipe's harness reads its install, its check's note and its owner's sign-in, each the server user's alone: never
|
|
1023
|
+
// opened to a slot's user (the sign-in least of all), so where each run is a user of its own it is refused here. And a
|
|
1024
|
+
// plan-billed one's run that no person started (a schedule's, a trigger's) never runs on its owner's sign-in.
|
|
1025
|
+
if (isolation.kind === "uid" && recipeHarness(deps.env ?? {}, harness))
|
|
1026
|
+
throw new ClaimRefused(RECIPE_NEEDS_SERVER_USER);
|
|
1027
|
+
refuseRecipeTriggerRun(deps.env ?? {}, harness, launch);
|
|
901
1028
|
if (runsInRunner(harness, launch))
|
|
902
1029
|
return true;
|
|
903
1030
|
if (launch.documents !== undefined) {
|
|
@@ -1031,9 +1158,14 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1031
1158
|
// in this process has it laid (harness-loops.ts): the run's process reads no store row of it and holds no seal key.
|
|
1032
1159
|
const claimDeps = await withSavedGatewayDeps(deps);
|
|
1033
1160
|
const claimEnv = claimDeps.env ?? {};
|
|
1161
|
+
// Refuse before taking a slot: even a slot's final reap normalizes modes in its run folders.
|
|
1162
|
+
if (launch.sourceProject && isolation.kind === "uid" && !await loadArchilSettings(deps.store, claimEnv)) {
|
|
1163
|
+
ready();
|
|
1164
|
+
throw new ClaimRefused("project_mode_fidelity: This runner rewrites local project file permissions for per-user isolation. A moved project needs a destination that preserves its original permissions.");
|
|
1165
|
+
}
|
|
1034
1166
|
const savedGateway = savedGatewayIn(claimEnv);
|
|
1035
1167
|
// The run's own keys: those its claim opens (claim-secrets.ts), the one list its loop in this process read.
|
|
1036
|
-
const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }, revisionRow, launch);
|
|
1168
|
+
const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact ? heldRedactor(loopDeps.redact) : undefined }, revisionRow, launch, claim.runId);
|
|
1037
1169
|
// With them, its revision's own model's (a launch pinned at its start to another model, a --faux start's, is still
|
|
1038
1170
|
// handed its agent's model's key, as a run's own process was handed it before: run-secrets.ts secretsFor).
|
|
1039
1171
|
const ofRevision = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }, revisionRow, { ...(launch.plane ? { plane: launch.plane } : {}) });
|
|
@@ -1072,7 +1204,7 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1072
1204
|
const tops = runTops(deps.data, runRow.agentId, claim.runId);
|
|
1073
1205
|
// The run's pieced writes (big-writes.ts): let go when its channel ends, or at the claim's release.
|
|
1074
1206
|
const bigs = runBigWrites();
|
|
1075
|
-
const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed }, cut, log, bigs);
|
|
1207
|
+
const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed, signal: loopDeps.signal }, cut, log, bigs);
|
|
1076
1208
|
try {
|
|
1077
1209
|
let extra = {};
|
|
1078
1210
|
let argv = [...(options.argv ?? childArgv())];
|
|
@@ -1167,6 +1299,7 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1167
1299
|
}
|
|
1168
1300
|
finally {
|
|
1169
1301
|
ready();
|
|
1302
|
+
await heldSide.projectEnd?.();
|
|
1170
1303
|
const reaped = await end(slot, tops).catch((error) => {
|
|
1171
1304
|
log(`run ${claim.runId}: its process's end failed: ${error?.message ?? error}`);
|
|
1172
1305
|
return false;
|
|
@@ -9,7 +9,7 @@ import { LaunchUnreadable, UnknownHarness } from "./dispatch.js";
|
|
|
9
9
|
import { NeverFits } from "./harness-loops.js";
|
|
10
10
|
import { ClaimRefused } from "./loop-contract.js";
|
|
11
11
|
import { McpClaimRefused } from "./mcp-claim.js";
|
|
12
|
-
import { registerErrors } from "./run-channel.js";
|
|
12
|
+
import { FrameTooLarge, registerErrors } from "./run-channel.js";
|
|
13
13
|
import { ClaimLost } from "./runner.js";
|
|
14
14
|
/** Registers every error class a run's process and its runner hand each other (run-channel.ts registerErrors). */
|
|
15
15
|
export function registerRunErrors() {
|
|
@@ -17,6 +17,6 @@ export function registerRunErrors() {
|
|
|
17
17
|
ClaimRefused, NeverFits, McpClaimRefused, ClaimLost, UnknownHarness, LaunchUnreadable,
|
|
18
18
|
Fenced, CommandTaken, RunFinal, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreLaunchMissing, StoreWorkerLost, Unanswered,
|
|
19
19
|
ConversationBusy, ConversationIdle, ReadAfterWrite, ReadOnlySession, SessionFailed, StorageRequestError,
|
|
20
|
-
WorkspaceError,
|
|
20
|
+
WorkspaceError, FrameTooLarge,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Interfaces } from "../live-reach.js";
|
|
1
2
|
import type { Settings } from "../store/store.js";
|
|
2
3
|
/** The store.settings key a server keeps the names of its run-facing environment under at each start: `{ v: 1, names }`. */
|
|
3
4
|
export declare const RUN_ENV_KEY = "server.run_env";
|
|
@@ -31,6 +32,8 @@ export interface RunnerEnvCheckOptions {
|
|
|
31
32
|
readonly read: (name: string) => string | undefined;
|
|
32
33
|
/** Whether a TCP connect to `host`:`port` is answered within `ms` (a test's stand-in). */
|
|
33
34
|
readonly answers?: (host: string, port: number, ms: number) => Promise<boolean>;
|
|
35
|
+
/** This machine's network interfaces (a test's stand-in), for AGENTRUN_RUNNER_LIVE_HOST given as an IPv4 block. */
|
|
36
|
+
readonly interfaces?: Interfaces;
|
|
34
37
|
}
|
|
35
38
|
/** How long a forwarder has to answer the check's connect. */
|
|
36
39
|
export declare const FORWARDER_MS = 2000;
|