@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.46
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 +148 -5
- package/README.md +385 -305
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +62 -19
- package/dist/composio-preset.js +69 -7
- package/dist/composio-triggers.d.ts +14 -0
- package/dist/composio-triggers.js +79 -15
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-C2MYaUBa.css +1 -0
- package/dist/console/assets/index-CZZeCReB.js +701 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +7 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +9 -1
- package/dist/harness-table.js +20 -3
- package/dist/harness.d.ts +1 -2
- package/dist/harness.js +3 -4
- package/dist/host.js +2 -1
- package/dist/import.d.ts +10 -0
- package/dist/import.js +28 -8
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +23 -89
- package/dist/learn/check.js +57 -335
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +89 -104
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +5 -5
- package/dist/learn/delete.js +8 -10
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +23 -5
- package/dist/learn/promote.js +40 -2
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
- package/dist/learn/{skills.js → workflow-draft.js} +48 -58
- package/dist/learn/workflow-nodes.js +1 -1
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +38 -24
- package/dist/learning-cost.js +41 -24
- package/dist/learning-routes.d.ts +91 -170
- package/dist/learning-routes.js +183 -421
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +21 -10
- package/dist/learning-setting.js +47 -11
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +61 -392
- package/dist/learning.js +101 -651
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +1 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +4 -4
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +4 -0
- package/dist/model.js +26 -9
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +273 -319
- package/dist/paid-calls.d.ts +8 -0
- package/dist/paid-calls.js +20 -0
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +15 -1
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +15 -89
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.js +1 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +8 -6
- package/dist/runner/adapter-loop.js +16 -12
- package/dist/runner/adapter-run-spec.d.ts +16 -4
- package/dist/runner/adapter-run-spec.js +64 -58
- package/dist/runner/adapters/index.js +22 -0
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/audit.js +30 -13
- package/dist/runner/beside.d.ts +6 -2
- package/dist/runner/beside.js +38 -9
- package/dist/runner/claim-secrets.d.ts +18 -2
- package/dist/runner/claim-secrets.js +42 -18
- package/dist/runner/cli-run-spec.js +55 -51
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +35 -13
- package/dist/runner/conformance/subject.d.ts +6 -0
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +2 -2
- package/dist/runner/feedback-round.js +7 -7
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +11 -59
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +2 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -69
- package/dist/runner/learning-end.js +250 -303
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +2 -3
- package/dist/runner/main.d.ts +17 -9
- package/dist/runner/main.js +82 -20
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +10 -5
- package/dist/runner/memory-claim.js +12 -6
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +12 -8
- package/dist/runner/promotion.js +37 -28
- package/dist/runner/reflect-hook.d.ts +64 -95
- package/dist/runner/reflect-hook.js +112 -225
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1230 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +1 -5
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +5 -1
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +7 -2
- package/dist/runs-over-store.d.ts +16 -28
- package/dist/runs-over-store.js +31 -38
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +55 -33
- package/dist/server.js +689 -322
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.js +246 -63
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +193 -36
- package/dist/store/store.js +25 -3
- package/dist/store-reads/learning.d.ts +102 -204
- package/dist/store-reads/learning.js +159 -321
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +29 -1
- package/dist/store-view.js +97 -31
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +8 -4
- package/dist/templates.js +44 -6
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +11 -4
- package/dist/triggers.d.ts +65 -6
- package/dist/triggers.js +125 -19
- package/dist/validate.js +1 -1
- package/dist/webhooks.d.ts +7 -2
- package/dist/webhooks.js +12 -5
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +7 -3
- package/dist/workspace/computer-for-claim.js +119 -22
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +33 -19
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/templates/README.md +8 -8
- package/templates/inbound-lead/agent.md +5 -4
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/kyb/agent.md +2 -1
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BUktRvS-.css +0 -1
- package/dist/console/assets/index-nB9kTfIN.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -35
- package/dist/learning-evals.js +0 -99
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
package/dist/runner/beside.js
CHANGED
|
@@ -14,7 +14,8 @@ export function besideRunnerOptions(serve, env) {
|
|
|
14
14
|
const drainMs = durationMs(drainTimeout);
|
|
15
15
|
if (drainMs === undefined)
|
|
16
16
|
throw new Error(`the drain timeout ${drainTimeout} is not a duration such as 8s`);
|
|
17
|
-
|
|
17
|
+
// `loopsTold`: the number was given (--max-runs, AGENTRUN_MAX_RUNS), not the host's memory's count.
|
|
18
|
+
return { loops: maxRunsOf(env, serve.maxRuns), loopsTold: serve.maxRuns !== undefined || Boolean(env.AGENTRUN_MAX_RUNS), drainMs };
|
|
18
19
|
}
|
|
19
20
|
/** What the CLI's stop waits on (stop-signals.ts StopDeps.stopping) with a runner beside the server: the server's runs
|
|
20
21
|
* and the runs the runner holds, and the longer of the server's bound and the runner's whole close (its drain, then
|
|
@@ -30,8 +31,9 @@ export function besideStopping(server, held, drainMs) {
|
|
|
30
31
|
* too (workspace/computer-janitor.ts), as the CLI's start asks. `hub`: the server's AttachHub (Serve.attachHub), which
|
|
31
32
|
* holds each paired computer's socket in this process, so a run here takes one. `dial`: the server's (Serve.dial), which
|
|
32
33
|
* a remote provider's create takes, so a machine that dials the server lands in this process's hub. Returns the runner
|
|
33
|
-
* and a close() that stops both and closes its store.
|
|
34
|
-
|
|
34
|
+
* and a close() that stops both and closes its store. `loopsTold`: `loops` was given (besideRunnerOptions), so on uid
|
|
35
|
+
* isolation a number past the helper's slots is refused rather than cut. */
|
|
36
|
+
export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, janitor, ownProcesses, hub, dial, mcpLoopback, mcpOwn, evalFakes, harnessInstall, onLine, onRunEnded } = {}) {
|
|
35
37
|
const { runnerName, startRunner } = await import("./runner.js");
|
|
36
38
|
const { dispatchRunner } = await import("./harness-loops.js");
|
|
37
39
|
const { routeOf } = await import("./model-route.js");
|
|
@@ -69,9 +71,34 @@ export async function runnerBeside(dataDir, { loops, drainMs, env, janitor, hub,
|
|
|
69
71
|
// email), by the agent each of its runs is of; only the eval, in its own process, hands them. `harnessInstall`: what a
|
|
70
72
|
// claim's first-use install installs with (the eval's sharedInstaller, which the server beside it takes too).
|
|
71
73
|
const { installForClaim } = await import("../harness-install.js");
|
|
72
|
-
const
|
|
73
|
-
//
|
|
74
|
-
|
|
74
|
+
const deps = { env: runs, data: dataDir, journal: (claim) => store.journal(claim), store, sealKey: seal.key, routeOf, computerForClaim: computers.computerForClaim, computerDeps: computers.computerDeps, ...(mcpLoopback ? { mcpLoopback: true } : {}), ...(mcpOwn ? { mcpOwn } : {}), ...(evalFakes ? { evalFakes } : {}), ...(harnessInstall ? { installForClaim: ((entry, dir, pins, given) => installForClaim(entry, dir, pins, { ...given, install: harnessInstall })) } : {}), log: (line) => console.error(`agentrun-serve runner: ${line}`) };
|
|
75
|
+
// `ownProcesses`: each run a process of its own (run-child-host.ts), as a user of its own where the image's helper can
|
|
76
|
+
// switch, as the CLI's start runs them; a helper that cannot is refused in words naming the setting. The template eval's
|
|
77
|
+
// runner (its fakes are functions of this process) runs its runs in this one.
|
|
78
|
+
let isolation;
|
|
79
|
+
let held = loops;
|
|
80
|
+
if (ownProcesses && !evalFakes && !harnessInstall) {
|
|
81
|
+
const { isolationLoops, runIsolationOf } = await import("./run-child-host.js");
|
|
82
|
+
try {
|
|
83
|
+
isolation = await runIsolationOf(process.env, loopsTold ? loops : undefined, deps.log);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
await store.close();
|
|
87
|
+
seal.release();
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
if (loops !== undefined && isolation.kind === "uid" && loops > isolation.slots)
|
|
91
|
+
deps.log(`each run runs as a user of its own, and the helper reaches ${isolation.slots} slots from slot ${isolation.first}: this runner holds at most ${isolation.slots} runs at once`);
|
|
92
|
+
if (loops !== undefined)
|
|
93
|
+
held = isolationLoops(isolation, loops);
|
|
94
|
+
else if (isolation.kind === "uid")
|
|
95
|
+
held = isolation.slots;
|
|
96
|
+
}
|
|
97
|
+
const { childLoops } = await import("./run-child-host.js");
|
|
98
|
+
const createLoop = isolation ? childLoops({ deps, isolation, log: deps.log }) : dispatchRunner(deps);
|
|
99
|
+
// It claims by the host's memory as well as by --max-runs (memory-claim.ts): a heavy harness's run waits queued for room,
|
|
100
|
+
// each run's own process weighed with it.
|
|
101
|
+
const { runnerMemory, RUN_PROCESS_MIB } = await import("./memory-claim.js");
|
|
75
102
|
// Before it claims: the scratch folders of runs that ended after their runner died (scratch-sweep.ts).
|
|
76
103
|
const { sweepEndedScratch } = await import("./scratch-sweep.js");
|
|
77
104
|
await sweepEndedScratch(store, dataDir, { log: (line) => console.error(`agentrun-serve runner: ${line}`) });
|
|
@@ -95,7 +122,7 @@ export async function runnerBeside(dataDir, { loops, drainMs, env, janitor, hub,
|
|
|
95
122
|
// A run's end lets go of what its earlier claims' computers left, with the same computers (run-end-computers.ts).
|
|
96
123
|
const { runEndComputers } = await import("../workspace/run-end-computers.js");
|
|
97
124
|
const runEnded = runEndComputers({ store, computers: computers.computerDeps, log: (line) => console.error(`agentrun-serve runner: ${line}`) });
|
|
98
|
-
const runner = startRunner({ store, name, createLoop, memory: runnerMemory(store, undefined, runs), onEvent: said, runEnded, ...(
|
|
125
|
+
const runner = startRunner({ store, name, createLoop, memory: runnerMemory(store, undefined, runs, isolation ? RUN_PROCESS_MIB : 0), onEvent: said, runEnded, ...(held !== undefined ? { loops: held } : {}), ...(drainMs !== undefined ? { drainMs } : {}) });
|
|
99
126
|
// The computer janitor over the same computers, when the start asks for it: never under --faux. Its lines are the
|
|
100
127
|
// runner's, on stderr (a stderr whose reader closed loses them, never the process: cli.ts).
|
|
101
128
|
const { startJanitor } = await import("../workspace/computer-janitor.js");
|
|
@@ -112,9 +139,11 @@ export async function runnerBeside(dataDir, { loops, drainMs, env, janitor, hub,
|
|
|
112
139
|
export async function serveWithRunner(options) {
|
|
113
140
|
const { fauxEnvOf, startServe } = await import("../server.js");
|
|
114
141
|
const { besideRunEnv } = await import("./main.js");
|
|
115
|
-
const { loops, drainMs } = besideRunnerOptions(options, process.env);
|
|
142
|
+
const { loops, loopsTold, drainMs } = besideRunnerOptions(options, process.env);
|
|
116
143
|
const serve = await startServe(options);
|
|
117
|
-
|
|
144
|
+
// Each run a process of its own, as a user of its own where the image's helper can switch, as the CLI's start runs
|
|
145
|
+
// them (cli.ts): the isolation the server's capabilities say (runIsolationOf over the same helper) is the runner's.
|
|
146
|
+
const beside = await runnerBeside(options.data, { loops, loopsTold, drainMs, env: besideRunEnv(process.env, fauxEnvOf(options)), ownProcesses: true, hub: serve.attachHub, dial: serve.dial, mcpLoopback: serve.localInstall, mcpOwn: serve.own, ...(options.log ? { onLine: options.log } : {}) }).catch(async (error) => {
|
|
118
147
|
await serve.close();
|
|
119
148
|
throw error;
|
|
120
149
|
});
|
|
@@ -5,6 +5,7 @@ import type { SealedKeys } from "../store/store.js";
|
|
|
5
5
|
import type { Revision } from "../agent-rows.js";
|
|
6
6
|
import type { HeldRedact } from "./redact.js";
|
|
7
7
|
import { type HeldModelKey } from "../run-model-key.js";
|
|
8
|
+
import { type RunModelKey } from "../store/seal.js";
|
|
8
9
|
/** What claimSecrets reads the keys from: the one store (its sealed keys) and the runner's seal key, and the runner's base
|
|
9
10
|
* environment (its own, with no server secret in it: those are the store's). */
|
|
10
11
|
export interface ClaimSecretsDeps {
|
|
@@ -48,7 +49,7 @@ export declare const MODEL_KEY_NAMES: readonly string[];
|
|
|
48
49
|
* and a provider the runner holds any key of gets none of its saved ones.
|
|
49
50
|
* The keys added are never enumerable either: a spread of the result, or a spawn given it, carries none of them. */
|
|
50
51
|
export declare function withModelKeys(env: NodeJS.ProcessEnv, opened: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
51
|
-
/** Every model key the server holds, for a model route with no revision to scope it by (
|
|
52
|
+
/** Every model key the server holds, for a model route with no revision to scope it by (an SDK run's compile turn): each
|
|
52
53
|
* by its name from `deps.env` first, then the store's sealed value, as claimSecrets reads them. */
|
|
53
54
|
export declare function savedModelKeys(deps: ClaimSecretsDeps): Promise<NodeJS.ProcessEnv>;
|
|
54
55
|
/** A run's own model key, held by its claim (run-model-key.ts): `fresh()` opens it from the run's launch again (a message's
|
|
@@ -60,6 +61,18 @@ export interface ClaimModelKey extends HeldModelKey {
|
|
|
60
61
|
/** Calls `listener` with the key now and with each new one fresh() opens: the run's redactors hold every key it held. */
|
|
61
62
|
watch(listener: (key: string) => void): void;
|
|
62
63
|
}
|
|
64
|
+
/** Run `runId`'s own model key as its launch's sealed column holds it, opened under `deps.sealKey`: none for a launch that
|
|
65
|
+
* holds none (or no launch row: a test's, an import's). Throws, in words, where the launch does not open. */
|
|
66
|
+
export declare function openRunModelKey(deps: {
|
|
67
|
+
readonly store: {
|
|
68
|
+
readonly runs: {
|
|
69
|
+
launch(runId: string): Promise<{
|
|
70
|
+
readonly sealed: Uint8Array | null;
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
readonly sealKey: Buffer | undefined;
|
|
75
|
+
}, runId: string): Promise<RunModelKey | undefined>;
|
|
63
76
|
/**
|
|
64
77
|
* The run's own model key for claim `runId`, opened from its launch's sealed column under the runner's seal key (the
|
|
65
78
|
* server sealed it there with mcp_auth, store/seal.ts). Undefined only where the server has no gateway and the run holds
|
|
@@ -84,8 +97,11 @@ export declare function holdRunKey(redact: HeldRedact, runKey: ClaimModelKey): v
|
|
|
84
97
|
/** Whether the claim opened a key of the run's own at its start: its routes then carry that key alone, its tools hold no
|
|
85
98
|
* model key, and no saved key is read for it. */
|
|
86
99
|
export declare const keyedAtClaim: (runKey: ClaimModelKey | undefined) => boolean;
|
|
100
|
+
/** Whether the server has a gateway (AGENT_MODEL_BASE_URL) and holds no key for it, in the runner's environment or saved:
|
|
101
|
+
* claimSpendOff's spend with no key to pay it. */
|
|
102
|
+
export declare function serverKeyless(deps: ClaimSecretsDeps): Promise<boolean>;
|
|
87
103
|
/** Why the claim's model spend after the run's turn, or beside it on runs the runner starts (a shadow audit, a replay
|
|
88
|
-
* check
|
|
104
|
+
* check), is skipped: `what` the work, asked when that spend would start. A run that brought
|
|
89
105
|
* its own key, at its start or with a message since (everHeld): that key is erased with its turn's end and the server's
|
|
90
106
|
* never pays for it (runKeyEndedFor). Else, a server that holds no gateway key (the runner's environment or
|
|
91
107
|
* Settings → Model keys) has none to spend (noServerKeyWords). Undefined where it runs. */
|
|
@@ -13,6 +13,7 @@ import { DECISION_KEYS, withoutSecrets } from "../secrets.js";
|
|
|
13
13
|
import { getSealedKey } from "../server-keys.js";
|
|
14
14
|
import { PLAN_PROVIDER, planOf, planReaderOf, withPlan } from "../chatgpt-plan.js";
|
|
15
15
|
import { handsParallel } from "../tool-plane.js";
|
|
16
|
+
import { held, held as runnerSeam } from "./held.js";
|
|
16
17
|
import { noServerKeyWords, runKeyEndedFor, runModelOrigin, withRunModelKey, withRunModelKeyLater } from "../run-model-key.js";
|
|
17
18
|
import { openRunLaunch } from "../store/seal.js";
|
|
18
19
|
import { StoreLaunchMissing } from "../store/store.js";
|
|
@@ -103,6 +104,10 @@ export async function learnedDecisionKeys(deps, workflows, allowed) {
|
|
|
103
104
|
export async function hostDecisionKeys(deps, providers) {
|
|
104
105
|
if (!providers.length)
|
|
105
106
|
return {};
|
|
107
|
+
// A run's own process holds no seal key: its runner reads them (held.ts).
|
|
108
|
+
const at = deps.sealKey ? undefined : held();
|
|
109
|
+
if (at)
|
|
110
|
+
return at.decisionKeys(providers);
|
|
106
111
|
return decisionKeysFor(await workingEnv(deps), { providers, parallelWeb: false });
|
|
107
112
|
}
|
|
108
113
|
/** The model keys the host's models of `tiers` need (model.ts modelKeys: each one's provider's, or the gateway's), read as
|
|
@@ -112,6 +117,12 @@ export async function hostDecisionKeys(deps, providers) {
|
|
|
112
117
|
export async function tierModelKeys(deps, tiers) {
|
|
113
118
|
if (!tiers.length)
|
|
114
119
|
return {};
|
|
120
|
+
// A run's own process holds no seal key: its runner reads them, the plan's reader with them (held.ts).
|
|
121
|
+
const at = deps.sealKey ? undefined : held();
|
|
122
|
+
if (at) {
|
|
123
|
+
const given = await at.tierModelKeys(tiers);
|
|
124
|
+
return given.plan ? withPlan({ ...given.keys }, given.plan) : { ...given.keys };
|
|
125
|
+
}
|
|
115
126
|
const working = await workingEnv(deps);
|
|
116
127
|
const out = {};
|
|
117
128
|
for (const name of modelKeys(working, undefined, tiers))
|
|
@@ -157,10 +168,12 @@ export function withModelKeys(env, opened) {
|
|
|
157
168
|
// The claim's ChatGPT sign-in (claimSecrets), else the runner's own.
|
|
158
169
|
return withPlan(out, planOf(opened) ?? planOf(env));
|
|
159
170
|
}
|
|
160
|
-
/** Every model key the server holds, for a model route with no revision to scope it by (
|
|
171
|
+
/** Every model key the server holds, for a model route with no revision to scope it by (an SDK run's compile turn): each
|
|
161
172
|
* by its name from `deps.env` first, then the store's sealed value, as claimSecrets reads them. */
|
|
162
173
|
export async function savedModelKeys(deps) {
|
|
163
|
-
|
|
174
|
+
// A run's own process holds no seal key: what its runner hands a claim whose routes read them (held.ts savedModelKeys).
|
|
175
|
+
const at = deps.sealKey ? undefined : held();
|
|
176
|
+
const out = at ? { ...(await at.savedModelKeys()) } : {};
|
|
164
177
|
for (const name of MODEL_KEY_NAMES) {
|
|
165
178
|
const value = deps.env?.[name] || (deps.sealKey ? await getSealedKey(deps.store, deps.sealKey, name) : undefined);
|
|
166
179
|
if (value !== undefined)
|
|
@@ -171,6 +184,21 @@ export async function savedModelKeys(deps) {
|
|
|
171
184
|
/** How many times fresh() reads a run's launch before it gives up, and the first wait between reads (doubled each time). */
|
|
172
185
|
const FRESH_TRIES = 3;
|
|
173
186
|
const FRESH_WAIT_MS = 50;
|
|
187
|
+
/** Run `runId`'s own model key as its launch's sealed column holds it, opened under `deps.sealKey`: none for a launch that
|
|
188
|
+
* holds none (or no launch row: a test's, an import's). Throws, in words, where the launch does not open. */
|
|
189
|
+
export async function openRunModelKey(deps, runId) {
|
|
190
|
+
const sealed = await deps.store.runs.launch(runId).then((launch) => launch.sealed, (error) => {
|
|
191
|
+
if (error instanceof StoreLaunchMissing)
|
|
192
|
+
return null;
|
|
193
|
+
throw error;
|
|
194
|
+
});
|
|
195
|
+
if (sealed === null)
|
|
196
|
+
return undefined;
|
|
197
|
+
const opened = deps.sealKey ? openRunLaunch(deps.sealKey, runId, sealed) : undefined;
|
|
198
|
+
if (!opened)
|
|
199
|
+
throw new Error("This run's launch secrets do not open with this runner's seal key: its model key is not sent.");
|
|
200
|
+
return opened.model;
|
|
201
|
+
}
|
|
174
202
|
/**
|
|
175
203
|
* The run's own model key for claim `runId`, opened from its launch's sealed column under the runner's seal key (the
|
|
176
204
|
* server sealed it there with mcp_auth, store/seal.ts). Undefined only where the server has no gateway and the run holds
|
|
@@ -181,20 +209,9 @@ const FRESH_WAIT_MS = 50;
|
|
|
181
209
|
*/
|
|
182
210
|
export async function claimModelKey(deps, runId) {
|
|
183
211
|
const origin = runModelOrigin(deps.env ?? {});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (error instanceof StoreLaunchMissing)
|
|
188
|
-
return null;
|
|
189
|
-
throw error;
|
|
190
|
-
});
|
|
191
|
-
if (sealed === null)
|
|
192
|
-
return undefined;
|
|
193
|
-
const opened = deps.sealKey ? openRunLaunch(deps.sealKey, runId, sealed) : undefined;
|
|
194
|
-
if (!opened)
|
|
195
|
-
throw new Error("This run's launch secrets do not open with this runner's seal key: its model key is not sent.");
|
|
196
|
-
return opened.model;
|
|
197
|
-
};
|
|
212
|
+
// A run's own process holds no seal key: its runner opens the claim's own launch, whatever run id this one names (held.ts).
|
|
213
|
+
const at = deps.sealKey ? undefined : runnerSeam();
|
|
214
|
+
const open = () => (at ? at.runModelKey() : openRunModelKey(deps, runId));
|
|
198
215
|
let held = await open();
|
|
199
216
|
if (held && held.origin !== origin)
|
|
200
217
|
throw new Error(`This run's model key was handed for the gateway at ${held.origin}, and AGENT_MODEL_BASE_URL names ${origin ?? "none"} here now: the key is never sent anywhere else.`);
|
|
@@ -245,13 +262,20 @@ export function holdRunKey(redact, runKey) {
|
|
|
245
262
|
/** Whether the claim opened a key of the run's own at its start: its routes then carry that key alone, its tools hold no
|
|
246
263
|
* model key, and no saved key is read for it. */
|
|
247
264
|
export const keyedAtClaim = (runKey) => runKey?.key() !== undefined;
|
|
265
|
+
/** Whether the server has a gateway (AGENT_MODEL_BASE_URL) and holds no key for it, in the runner's environment or saved:
|
|
266
|
+
* claimSpendOff's spend with no key to pay it. */
|
|
267
|
+
export async function serverKeyless(deps) {
|
|
268
|
+
return runModelOrigin(deps.env ?? {}) !== undefined && !(await savedModelKeys(deps))[GATEWAY_KEY_ENV];
|
|
269
|
+
}
|
|
248
270
|
/** Why the claim's model spend after the run's turn, or beside it on runs the runner starts (a shadow audit, a replay
|
|
249
|
-
* check
|
|
271
|
+
* check), is skipped: `what` the work, asked when that spend would start. A run that brought
|
|
250
272
|
* its own key, at its start or with a message since (everHeld): that key is erased with its turn's end and the server's
|
|
251
273
|
* never pays for it (runKeyEndedFor). Else, a server that holds no gateway key (the runner's environment or
|
|
252
274
|
* Settings → Model keys) has none to spend (noServerKeyWords). Undefined where it runs. */
|
|
253
275
|
export async function claimSpendOff(deps, runKey) {
|
|
254
|
-
|
|
276
|
+
// A run's own process holds no seal key, nor every saved key: its runner says whether the server holds a gateway key.
|
|
277
|
+
const at = deps.sealKey ? undefined : held();
|
|
278
|
+
const keyless = at ? await at.serverKeyless() : await serverKeyless(deps);
|
|
255
279
|
return (what) => (runKey?.everHeld() ? runKeyEndedFor(what) : keyless ? noServerKeyWords(what) : undefined);
|
|
256
280
|
}
|
|
257
281
|
/** The env a claimed run's model routes read: the run's own key alone where the claim opened one (withRunModelKey); else
|
|
@@ -21,7 +21,7 @@ import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
|
21
21
|
import { checkRaise, followUpOf, freeModelRequestsOf, parkOf, planCapModel } from "@parcha/agentrun-kernel/kernel/cap";
|
|
22
22
|
import { PLAN_LIMIT_WORDS } from "@parcha/agentrun-kernel";
|
|
23
23
|
import { confineOf, noNewPrivsPrefix, standsIn, thinkingFor } from "../adapters.js";
|
|
24
|
-
import { claimSettled, installDirOf, installForClaim, installingWords } from "../harness-install.js";
|
|
24
|
+
import { claimSettled, claudeCliIn, installDirOf, installForClaim, installingWords } from "../harness-install.js";
|
|
25
25
|
import { HarnessUnavailable } from "../provider.js";
|
|
26
26
|
import { effortGuidance } from "../effort-guidance.js";
|
|
27
27
|
import { outputContract } from "../answer-json.js";
|
|
@@ -42,13 +42,13 @@ import { recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.j
|
|
|
42
42
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
43
43
|
import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
44
44
|
import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
45
|
-
import {
|
|
45
|
+
import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
46
46
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
47
47
|
import { settingOfDefinition } from "../computer-setting.js";
|
|
48
48
|
import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
49
49
|
import { hadComputer } from "./computer-journal.js";
|
|
50
50
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
51
|
-
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, mcpReachOf, modelAskOf, PI_WIRES, webHostTools } from "./adapter-run-spec.js";
|
|
51
|
+
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, claimLiveAt, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, mcpReachOf, modelAskOf, PI_WIRES, webHostTools } from "./adapter-run-spec.js";
|
|
52
52
|
import { openTierProxies } from "./adapters/pi.js";
|
|
53
53
|
import { signInReads } from "../sign-ins-store.js";
|
|
54
54
|
import { isWebHostTool } from "../tool-list.js";
|
|
@@ -56,7 +56,8 @@ import { hostToolOf } from "../host-tools.js";
|
|
|
56
56
|
import { ASK_TOOL, askPerson } from "../tools.js";
|
|
57
57
|
import { fakedPlane } from "../web-fake.js";
|
|
58
58
|
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
|
|
59
|
-
import {
|
|
59
|
+
import { mcpWhereHeld } from "./mcp-run.js";
|
|
60
|
+
import { held as runnerSeam, heldSignInReads } from "./held.js";
|
|
60
61
|
import { DECISION_PROVIDER_KEYS, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
61
62
|
import { decisionProvidersIn } from "../decisions.js";
|
|
62
63
|
import { resolveHarness } from "./adapters/index.js";
|
|
@@ -64,13 +65,15 @@ import { entriesOf } from "./loop.js";
|
|
|
64
65
|
import { bookedSpend, cliModelWorked, cliRunMetrics, endCostOf, runCostOf } from "./metrics.js";
|
|
65
66
|
import { journalEntries } from "./journal-reader.js";
|
|
66
67
|
import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
68
|
+
import { replayCallsOver } from "./promotion.js";
|
|
69
|
+
import { learnedFirstWhereHeld } from "./learned-first.js";
|
|
70
|
+
import { pathMetrics } from "./workflow-first.js";
|
|
71
|
+
import { AUDIT_PARKED, withAudit } from "./audit.js";
|
|
72
|
+
import { runPathOverStore } from "../store-reads/learning.js";
|
|
71
73
|
import { specBuilt } from "./spec-holds.js";
|
|
72
74
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
73
75
|
import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
|
|
76
|
+
import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
|
|
74
77
|
import { heldSpecOf } from "./held-run.js";
|
|
75
78
|
import { loopComputerOf } from "./computer-channel.js";
|
|
76
79
|
import { githubAppAccess } from "./github-app.js";
|
|
@@ -121,7 +124,7 @@ export function capModelOf(id, wire, listed, unpriced, plan = false) {
|
|
|
121
124
|
function chosenCapModel(entry, env, chosen, wire) {
|
|
122
125
|
const priced = entry.priceModel(env, chosen.model);
|
|
123
126
|
const listed = chosen.models.getModel(priced.provider, priced.modelId);
|
|
124
|
-
return capModelOf(priced.modelId, wire, listed, chosen.unpriced.has(priced.modelId) || listed === undefined, priced.provider === PLAN_PROVIDER);
|
|
127
|
+
return capModelOf(priced.modelId, wire, listed, chosen.unpriced.has(priced.modelId) || listed === undefined, priced.provider === PLAN_PROVIDER || priced.provider === CLAUDE_LOGIN_PROVIDER);
|
|
125
128
|
}
|
|
126
129
|
/** The model a run of the CLI harness `entry` on `ref` (a revision's model; none, this host's default for it) is capped
|
|
127
130
|
* at here, as its run's spec prices it (modelsOf, chosenCapModel), before any run: a save's cap warning (cap-short.ts)
|
|
@@ -209,6 +212,11 @@ async function rmEmptyParents(parents) {
|
|
|
209
212
|
const code = error.code;
|
|
210
213
|
if (code === "ENOTEMPTY" || code === "EEXIST")
|
|
211
214
|
return;
|
|
215
|
+
// A folder this process may not remove ends the climb: a run's own process on a slot (run-child-host.ts) removes
|
|
216
|
+
// its harness folder, and the run's scratch folder and its agent's are its runner's, which sweeps them after the
|
|
217
|
+
// slot's reap.
|
|
218
|
+
if (code === "EACCES" || code === "EPERM")
|
|
219
|
+
return;
|
|
212
220
|
// Already gone (a sweep cut off after it, or never made): the folder above it may still be left empty.
|
|
213
221
|
if (code !== "ENOENT")
|
|
214
222
|
throw error;
|
|
@@ -319,7 +327,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
319
327
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
320
328
|
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
321
329
|
redact.hold(values); };
|
|
322
|
-
const mcp = await
|
|
330
|
+
const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...reach });
|
|
323
331
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
324
332
|
holds.hold({ passed: mcp });
|
|
325
333
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
@@ -334,7 +342,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
334
342
|
// fake) is spread into the mount, so no test reaches the real control plane. TODO(k2 lazy mint): the mint moves into
|
|
335
343
|
// computerForClaim (a mounting computer only), with the ttl the run's lifetime bound (not this fixed figure). As pi does.
|
|
336
344
|
// The disk is the run's (run-disk.ts): its launch record's, else its agent's, made on its first run that needs one.
|
|
337
|
-
: await
|
|
345
|
+
: await archilWhereHeld({ settings: archilSettings, keys: deps.store.sealedKeys, sealKey: deps.sealKey, signal: run.signal ?? new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS, ...(deps.mountControl ?? {}) }, run: { agentId: runRow.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store: deps.store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
|
|
338
346
|
// Each resource is held the moment it exists (spec-holds.ts): a throw after it lets it go. The claim's Archil keys go
|
|
339
347
|
// from memory last, once nothing more reads the disk.
|
|
340
348
|
holds.hold({ archil, keys: archil });
|
|
@@ -347,7 +355,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
347
355
|
// The pull request's checkout, when the revision asks for one, as the pi spec makes it (pr-checkout.ts).
|
|
348
356
|
const checkout = body.checkout === "pull_request" ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part })) : undefined;
|
|
349
357
|
holds.hold({ checkout });
|
|
350
|
-
|
|
358
|
+
// A run's own process copies nothing: its runner placed them before the process started (run-child-host.ts).
|
|
359
|
+
if (!(deps.sealKey === undefined && runnerSeam()))
|
|
360
|
+
await placeRunInputs(deps.data, claim.runId, ws.workspace, launch.files ?? [], messageText(launch.input));
|
|
351
361
|
// The run's skills and its learning seed laid before its computer exists, as the pi spec lays them (adapter-run-spec.ts):
|
|
352
362
|
// on Archil the computer's mount takes the disk's write delegation, and a lay over the disk's file API after it is
|
|
353
363
|
// refused (409) while the mount holds it.
|
|
@@ -356,21 +366,12 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
356
366
|
// The revision's own skills laid before they are read, as the pi spec lays them (adapter-run-spec.ts), with the kind's
|
|
357
367
|
// skill of a desktop or a phone (the revision's computer setting), in the harness's skill list beside the revision's.
|
|
358
368
|
const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
|
|
359
|
-
// A learning run's seed
|
|
360
|
-
//
|
|
369
|
+
// A learning run's seed read as the pi spec reads it (runner/learning-seed.ts): its learned workflows, the ones
|
|
370
|
+
// learned_workflow runs.
|
|
361
371
|
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
362
372
|
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
363
373
|
const seedLaid = start && !seedFailed(start)
|
|
364
|
-
? await layLearningSeed({
|
|
365
|
-
work: ws.workspace,
|
|
366
|
-
seed: start.seed,
|
|
367
|
-
folder: learningFolder,
|
|
368
|
-
own: Object.keys(revisionRow.skills ?? {}),
|
|
369
|
-
shown,
|
|
370
|
-
log,
|
|
371
|
-
...(start.notesOnly ? { workflows: false } : {}),
|
|
372
|
-
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
373
|
-
})
|
|
374
|
+
? await layLearningSeed({ seed: start.seed, folder: learningFolder, shown, log, ...(start.noWorkflows ? { workflows: false } : {}) })
|
|
374
375
|
: undefined;
|
|
375
376
|
// The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
|
|
376
377
|
// It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
|
|
@@ -419,9 +420,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
419
420
|
// those it would refuse, and is handed the rest), the output schema it answers in (answer-json.ts outputContract, as the
|
|
420
421
|
// pi spec gives it), then the effort guidance.
|
|
421
422
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
422
|
-
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section
|
|
423
|
+
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
|
|
423
424
|
const check = await entry.skillCheck?.();
|
|
424
|
-
const { system: instructions, native } = await systemOf(laid, [...Object.keys(body.skills ?? {}), ...kindSkills
|
|
425
|
+
const { system: instructions, native } = await systemOf(laid, [...Object.keys(body.skills ?? {}), ...kindSkills], ws.workspace, check, { onDemand: readsFiles(granted) });
|
|
425
426
|
const guidance = effortGuidance(launch.effort);
|
|
426
427
|
// The run's model (the launch's, pinned at start, else the revision's) and its adapter, as main builds them, on the
|
|
427
428
|
// environment main's server gives its runs: the server's data directory named (DATA_ENV), so the CLI's install is
|
|
@@ -443,9 +444,17 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
443
444
|
if (runKey)
|
|
444
445
|
holdRunKey(redact, runKey);
|
|
445
446
|
}
|
|
446
|
-
|
|
447
|
+
// Claude Code's login on this machine, where the owner turned it on for claude-agent here (claude-login.ts): the run
|
|
448
|
+
// carries only where it is, and its CLI says it is signed in before the run starts. A run that brought its own key
|
|
449
|
+
// runs on that key, and a run in a sandbox place on the model keys.
|
|
450
|
+
const login = keyed ? undefined : await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, name, launch.place);
|
|
451
|
+
const env = withClaudeLogin(cliRunEnv(deps.env, deps.data, claimed, launch.plane, runKey), login);
|
|
447
452
|
const chosen = await modelsOf(entry, env, modelAskOf(launch.model, body.model));
|
|
448
453
|
await planBeforeRun(env, chosen.model);
|
|
454
|
+
if (login && entry.priceModel(env, chosen.model).provider === CLAUDE_LOGIN_PROVIDER) {
|
|
455
|
+
const claude = await import("@parcha/agentrun-harness-claude");
|
|
456
|
+
await loginBeforeRun(login, loginCli(claudeCliIn(installDirOf(deps.data, name), claude.claudeAgentPlatform()), env), (cli, at) => claude.claudeLoginStatus(cli, at, env.PATH ? { path: env.PATH } : {}));
|
|
457
|
+
}
|
|
449
458
|
// The CLI's own process (the Claude CLI, Codex, OpenCode) starts under the no_new_privs pi's commands start under
|
|
450
459
|
// (adapters.ts' noNewPrivsPrefix): on Linux, setpriv --no-new-privs, so a setuid program or file capability it
|
|
451
460
|
// or a command it runs reaches grants nothing; none on macOS. Where setpriv is not usable the run is refused, in pi's words.
|
|
@@ -453,7 +462,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
453
462
|
// The run's clock: a template eval case's (EvalFakes.now), else the real one. Its environment line and the harness's own
|
|
454
463
|
// turn date (claude-agent's dateLine) read it.
|
|
455
464
|
const now = fakes?.now;
|
|
456
|
-
|
|
465
|
+
// A run's own process reads no trigger's row: its runner answers the zone (held.ts runZone).
|
|
466
|
+
const seam = deps.sealKey ? undefined : runnerSeam();
|
|
467
|
+
const zone = seam ? await seam.runZone() : await runZone(deps.store, launch.inputOrigin);
|
|
457
468
|
const built = await entry.adapter(env, { zone, model: chosen.model, models: chosen.models, unpriced: chosen.unpriced, ...(confine ? { confine } : {}), ...(native.length ? { skills: native } : {}), ...(now ? { now: () => now } : {}) });
|
|
458
469
|
// The harness's own session options, its private directory and its working directory (SessionIO's dir and cwd, which
|
|
459
470
|
// every CLI adapter reads), set on its open here, so the loop lends the session nothing of its own. A turn that ends on
|
|
@@ -516,8 +527,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
516
527
|
const tierRoute = tierRoutes.get(by);
|
|
517
528
|
return tierRoute && tierRoute.model === id ? capModelOfRoute(tierRoute) : undefined;
|
|
518
529
|
},
|
|
519
|
-
// What its
|
|
520
|
-
// (none: it queues none).
|
|
530
|
+
// What its audit's shadow took beside it, read by every gate with its own sessions (none: it starts none).
|
|
521
531
|
...(besideOf ? { beside: besideOf } : {}),
|
|
522
532
|
// The most requests on free models it makes, capped or not (AGENTRUN_FREE_MODEL_REQUESTS).
|
|
523
533
|
freeRequests: freeModelRequestsOf(deps.env),
|
|
@@ -561,32 +571,26 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
561
571
|
// The keys the claim hands the run (its web tools and its learned workflow's call nodes run on them): never learned
|
|
562
572
|
// (learningEndOfRun).
|
|
563
573
|
let handedKeys = [];
|
|
564
|
-
// A replay run lays only the workflow it replays (runner/promotion.ts replayLaid).
|
|
565
|
-
const laidFlows = replayLaid(launch, seedLaid?.workflows ?? []);
|
|
566
574
|
// The learned workflow the run starts on, before its agent's first turn, when one fits its input (workflow-first.ts),
|
|
567
575
|
// chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
|
|
568
576
|
// serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
|
|
569
577
|
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
570
578
|
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
|
|
571
579
|
// The audits that finished since are written first (runner/audit.ts settleAudits): a hold they make decides this claim.
|
|
572
|
-
// Model spend beside the run that its caller's key does not pay for (claimSpendOff): a shadow audit
|
|
573
|
-
//
|
|
580
|
+
// Model spend beside the run that its caller's key does not pay for (claimSpendOff): a shadow audit and a replay check
|
|
581
|
+
// are skipped, in words, where the run brought its own key or the server holds none.
|
|
574
582
|
const spendOff = await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey);
|
|
575
583
|
const audits = { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, folder: learningFolder, shown, sealKey: deps.sealKey, spendOff };
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
});
|
|
581
|
-
const firstChoice = learnsWorkflows(revision.kind, laidFlows) ? await workflowFirstOf(revision.kind, laidFlows, launch, log, () => pastRunsOverStore(deps.store, runRow.agentId), promotionGate(promotion), revision.body.outputSchema) : {};
|
|
582
|
-
// A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
|
|
583
|
-
await replayClaimed(deps.store, runRow.agentId, claim.runId, launch, firstChoice);
|
|
584
|
+
// Each step writes the store or reads another run (runner/learned-first.ts): in a run's own process its runner takes
|
|
585
|
+
// them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself.
|
|
586
|
+
const learned = await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log, folder: learningFolder, shown, spendOff }, seedLaid?.workflows ?? []);
|
|
587
|
+
const firstChoice = learned.choice;
|
|
584
588
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
585
|
-
// answered from that recording (runner/promotion.ts
|
|
586
|
-
const replay = await
|
|
589
|
+
// answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
|
|
590
|
+
const replay = learned.recorded ? await replayCallsOver(deps.store, claim.runId, new Map(learned.recorded)) : undefined;
|
|
587
591
|
const { serve: workflowFirst, revise: workflowRevise } = firstChoice;
|
|
588
592
|
// The tool runs what serves, never a revision not promoted (runner/promotion.ts toolFlowsFor).
|
|
589
|
-
const workflows =
|
|
593
|
+
const workflows = learned.workflows;
|
|
590
594
|
const learns = learnsWorkflows(revision.kind, workflows);
|
|
591
595
|
if (webNames.length || learns) {
|
|
592
596
|
// The claim's keys (above, already held by the redactors), a copy of its own for the tools' plane below.
|
|
@@ -607,7 +611,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
607
611
|
toolEnv[TOOL_PLANE_ENV] = JSON.stringify(launch.plane);
|
|
608
612
|
if (webNames.length) {
|
|
609
613
|
life = hostLifecycle();
|
|
610
|
-
const
|
|
614
|
+
const liveAt = await claimLiveAt(deps, claim.runId);
|
|
615
|
+
const host = buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: held, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}), ...reach, ...(liveAt ? { liveAt } : {}) });
|
|
611
616
|
gate.askedOn(host);
|
|
612
617
|
webTools = await webHostTools(host, granted, ctx);
|
|
613
618
|
}
|
|
@@ -652,21 +657,20 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
652
657
|
};
|
|
653
658
|
// A typed input's other fields follow its content as one json block (inputMessage).
|
|
654
659
|
const input = await firstMessage(inputMessage(launch.input), ws.workspace);
|
|
655
|
-
// The run's end-of-run step, when it learns, the same as the pi spec's: the
|
|
656
|
-
// store, its learning folder where the run's place keeps it — Mode 1 under the data directory, Mode 2 on this
|
|
657
|
-
// Archil disk — so the
|
|
660
|
+
// The run's end-of-run step, when it learns, the same as the pi spec's: the compile turn and the owner's correction over
|
|
661
|
+
// the run's store, its learning folder where the run's place keeps it — Mode 1 under the data directory, Mode 2 on this
|
|
662
|
+
// claim's Archil disk — so the draft is checked against the seed in the run's own Workspace, never this machine's local path.
|
|
658
663
|
// A replay run or an audit's shadow run asks nothing at its end: it is the promotion's, never the agent's to learn from.
|
|
659
664
|
// A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
|
|
660
665
|
// withAudit): at its end, so the shadow's cap is what the run's own left.
|
|
661
666
|
const endOfRun = launch.replay || launch.audit ? undefined : withAudit(learningEndOfRun(launch, {
|
|
662
667
|
store: deps.store,
|
|
663
668
|
data: deps.data,
|
|
664
|
-
spendOff,
|
|
665
669
|
...(deps.env ? { env: deps.env } : {}),
|
|
666
670
|
// What the run must never learn beside the runner's secrets: the keys its claim handed it, every secret the server
|
|
667
671
|
// keeps sealed (storeSecrets: the run's redactor holds the same list), and its sign-in's pointers, read back from the
|
|
668
672
|
// store's sign-ins under the seal key (learning-run.ts refused, on the runner).
|
|
669
|
-
signIns: signInReads(deps.store, deps.sealKey),
|
|
673
|
+
signIns: deps.sealKey ? signInReads(deps.store, deps.sealKey) : heldSignInReads(),
|
|
670
674
|
handed: handedKeys,
|
|
671
675
|
stored: () => storeSecrets(deps.store, deps.sealKey, deps.data),
|
|
672
676
|
log,
|
|
@@ -57,6 +57,12 @@ export type Seen = {
|
|
|
57
57
|
epoch: number;
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
+
/** What the process wrote after it said it stops at the point, in its file's order (each line is appended synchronously),
|
|
61
|
+
* or everything when it never said so. One millisecond of the clock can hold the loop's last write before the stop and
|
|
62
|
+
* the case's going on both, so the order, not the time, says which side of the stop a write is on. */
|
|
63
|
+
export declare function afterStop<T extends {
|
|
64
|
+
type?: string;
|
|
65
|
+
}>(events: readonly T[]): readonly T[];
|
|
60
66
|
/**
|
|
61
67
|
* The claim's fence, as the stalled process's own events show it: once it went on (`continuedAt`, its lease run out and no
|
|
62
68
|
* one holding the run yet), its old loop's writes under the claim it was held under are each refused by the fence, by name (ClaimLost
|