@parcha/agentrun-serve 0.1.0-beta.58 → 0.1.0-beta.59
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 +325 -1
- package/README.md +332 -88
- package/dist/acp-package.d.ts +5 -1
- package/dist/acp-package.js +19 -2
- package/dist/adapters.d.ts +23 -2
- package/dist/adapters.js +106 -33
- package/dist/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +3 -2
- package/dist/box-paths.js +5 -4
- package/dist/browser-computer.d.ts +3 -8
- package/dist/browser-computer.js +12 -35
- package/dist/browser-cost.js +94 -20
- package/dist/capacity.d.ts +1 -1
- package/dist/capacity.js +3 -3
- package/dist/chatgpt-plan.d.ts +5 -0
- package/dist/chatgpt-plan.js +25 -11
- package/dist/claude-login-token.d.ts +15 -11
- package/dist/claude-login-token.js +167 -107
- package/dist/claude-login.d.ts +76 -31
- package/dist/claude-login.js +426 -79
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli.js +323 -292
- package/dist/composio-made.d.ts +1 -6
- package/dist/composio-made.js +1 -6
- package/dist/composio-owners.d.ts +26 -0
- package/dist/composio-owners.js +36 -0
- package/dist/composio-preset.d.ts +56 -23
- package/dist/composio-preset.js +173 -77
- package/dist/composio-triggers.d.ts +4 -4
- package/dist/composio-triggers.js +6 -7
- package/dist/compute-cost.js +11 -2
- package/dist/computer-attach.d.ts +6 -3
- package/dist/computer-attach.js +41 -29
- package/dist/computer-held-routes.d.ts +1 -1
- package/dist/computer-held-routes.js +9 -4
- package/dist/computer-keys.d.ts +11 -1
- package/dist/computer-keys.js +26 -1
- package/dist/computer-record.js +3 -1
- package/dist/computer-view.d.ts +5 -3
- package/dist/computer-view.js +10 -6
- package/dist/computer-viewer.js +36 -7
- package/dist/computers.d.ts +2 -1
- package/dist/computers.js +6 -3
- package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
- package/dist/console/assets/backend-BztxEAvb.js +166 -0
- package/dist/console/assets/index-LwNL4L9q.js +619 -0
- package/dist/console/assets/share-L84tlUDW.js +6 -0
- package/dist/console/assets/styles-CaRKlHke.js +291 -0
- package/dist/console/assets/styles-DQo8rzY-.css +1 -0
- package/dist/console/index.html +4 -3
- package/dist/console/share.html +17 -0
- package/dist/decisions.d.ts +17 -7
- package/dist/decisions.js +41 -15
- package/dist/dial-relay.js +10 -4
- package/dist/docker-daemon.js +4 -5
- package/dist/docker-host-addresses.js +29 -11
- package/dist/email/account.d.ts +6 -0
- package/dist/email/account.js +6 -0
- package/dist/email/authentication.d.ts +21 -0
- package/dist/email/authentication.js +106 -0
- package/dist/email/email-faux.d.ts +11 -2
- package/dist/email/email-faux.js +21 -5
- package/dist/email/mail.d.ts +25 -0
- package/dist/email/mail.js +58 -2
- package/dist/email/names.js +2 -2
- package/dist/email/tools.d.ts +9 -4
- package/dist/email/tools.js +95 -13
- package/dist/env-switch.d.ts +12 -2
- package/dist/env-switch.js +23 -3
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +11 -1
- package/dist/fal-price.js +33 -0
- package/dist/faux-computers.js +1 -1
- package/dist/filed-answer.d.ts +2 -2
- package/dist/filed-answer.js +2 -2
- package/dist/graph-served.d.ts +10 -5
- package/dist/graph-served.js +40 -10
- package/dist/handed-values.js +1 -2
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +45 -12
- package/dist/harness-keys.js +9 -6
- package/dist/harness-opencode/facts.js +2 -0
- package/dist/harness-recipe-entry.d.ts +9 -3
- package/dist/harness-recipe-entry.js +18 -9
- package/dist/harness-recipe.d.ts +21 -0
- package/dist/harness-recipe.js +25 -3
- package/dist/harness-table.d.ts +8 -0
- package/dist/harness-table.js +17 -6
- package/dist/helper-env.d.ts +4 -1
- package/dist/helper-env.js +4 -1
- package/dist/host-check.d.ts +2 -3
- package/dist/host-check.js +13 -7
- package/dist/hosted-search.js +1 -1
- package/dist/import.d.ts +11 -8
- package/dist/import.js +437 -186
- package/dist/key-refusal.d.ts +9 -2
- package/dist/key-refusal.js +86 -32
- package/dist/learn/audit.d.ts +8 -5
- package/dist/learn/audit.js +15 -7
- package/dist/learn/compile.d.ts +5 -2
- package/dist/learn/compile.js +45 -21
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/ledger.d.ts +32 -29
- package/dist/learn/ledger.js +26 -19
- package/dist/learn/promote.d.ts +79 -36
- package/dist/learn/promote.js +60 -65
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learned-nodes.d.ts +8 -5
- package/dist/learned-nodes.js +8 -5
- package/dist/learned-workflow.d.ts +2 -1
- package/dist/learned-workflow.js +13 -10
- package/dist/learning-cost.d.ts +25 -8
- package/dist/learning-cost.js +23 -8
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/listen-first.d.ts +5 -4
- package/dist/listen-first.js +4 -5
- package/dist/live-reach.d.ts +7 -0
- package/dist/live-reach.js +7 -0
- package/dist/mcp-api-only-origins.d.ts +15 -0
- package/dist/mcp-api-only-origins.js +40 -0
- package/dist/mcp-gateway.d.ts +16 -2
- package/dist/mcp-gateway.js +41 -3
- package/dist/mcp-oauth.d.ts +1 -1
- package/dist/mcp-oauth.js +3 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +3 -0
- package/dist/mcp-secret-writes.d.ts +24 -2
- package/dist/mcp-secret-writes.js +30 -2
- package/dist/mcp-servers-store.d.ts +52 -14
- package/dist/mcp-servers-store.js +165 -61
- package/dist/mcp-sources.d.ts +1 -2
- package/dist/mcp-sources.js +1 -2
- package/dist/mcp-store.d.ts +5 -5
- package/dist/mcp-store.js +3 -3
- package/dist/mcp.js +1 -1
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +202 -51
- package/dist/otel/genai.d.ts +83 -7
- package/dist/otel/genai.js +69 -9
- package/dist/otel/tracer.d.ts +42 -13
- package/dist/otel/tracer.js +241 -56
- package/dist/page.d.ts +7 -1
- package/dist/page.js +76 -22
- package/dist/paid-calls.d.ts +6 -4
- package/dist/paid-calls.js +15 -7
- package/dist/place-offers.d.ts +55 -34
- package/dist/place-offers.js +93 -54
- package/dist/place.d.ts +13 -14
- package/dist/place.js +56 -41
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +3 -2
- package/dist/provider.js +17 -8
- package/dist/redact/match.d.ts +27 -9
- package/dist/redact/match.js +266 -57
- package/dist/run-census.d.ts +1 -1
- package/dist/run-census.js +4 -5
- package/dist/run-cut.js +4 -5
- package/dist/run-export-store.d.ts +15 -0
- package/dist/run-export-store.js +30 -0
- package/dist/run-export.d.ts +139 -0
- package/dist/run-export.js +379 -0
- package/dist/run-file-cut.d.ts +5 -0
- package/dist/run-file-cut.js +13 -0
- package/dist/run-launch.js +16 -3
- package/dist/run-model-key.d.ts +15 -6
- package/dist/run-model-key.js +30 -31
- package/dist/run-reads-over-store.js +4 -4
- package/dist/run-secrets.js +3 -5
- package/dist/run-timeline-served.js +3 -1
- package/dist/runnable.js +2 -2
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +94 -47
- package/dist/runner/adapter-run-spec.d.ts +14 -1
- package/dist/runner/adapter-run-spec.js +64 -28
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +8 -5
- package/dist/runner/audit.js +37 -17
- package/dist/runner/beside.js +5 -6
- package/dist/runner/claim-secrets.d.ts +10 -3
- package/dist/runner/claim-secrets.js +29 -13
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +81 -46
- package/dist/runner/compare-end.d.ts +2 -1
- package/dist/runner/compare-end.js +25 -10
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/harness-loops.js +3 -3
- package/dist/runner/held.d.ts +5 -2
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +22 -4
- package/dist/runner/learned-first.js +20 -4
- package/dist/runner/learning-end.d.ts +2 -8
- package/dist/runner/learning-end.js +11 -19
- package/dist/runner/live-ticker.js +7 -5
- package/dist/runner/loop-contract.d.ts +0 -2
- package/dist/runner/loop.d.ts +7 -0
- package/dist/runner/loop.js +1 -0
- package/dist/runner/main.js +12 -11
- package/dist/runner/mcp-claim.js +21 -5
- package/dist/runner/meta-tools.js +3 -2
- package/dist/runner/metrics.d.ts +7 -0
- package/dist/runner/metrics.js +19 -0
- package/dist/runner/model-route.d.ts +10 -7
- package/dist/runner/model-route.js +79 -15
- package/dist/runner/native-loop.js +10 -8
- package/dist/runner/presence.d.ts +1 -4
- package/dist/runner/presence.js +6 -8
- package/dist/runner/promotion.d.ts +25 -13
- package/dist/runner/promotion.js +125 -50
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/responses-fetch.d.ts +36 -0
- package/dist/runner/responses-fetch.js +511 -0
- package/dist/runner/run-child-host.d.ts +20 -5
- package/dist/runner/run-child-host.js +179 -77
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +2 -3
- package/dist/runner/runner.js +13 -9
- package/dist/runner/sdk-loop.js +8 -8
- package/dist/runner/spec-holds.d.ts +8 -1
- package/dist/runner/spec-holds.js +9 -4
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +120 -32
- package/dist/runner/workflow-first.js +218 -94
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/runs-over-store.js +8 -7
- package/dist/save-once.d.ts +14 -0
- package/dist/save-once.js +31 -0
- package/dist/scrub-command.d.ts +34 -31
- package/dist/scrub-command.js +116 -147
- package/dist/sdk/runs.d.ts +6 -0
- package/dist/sdk/runs.js +89 -10
- package/dist/seal-key.js +4 -4
- package/dist/secret-cut.d.ts +3 -0
- package/dist/secret-cut.js +7 -1
- package/dist/secret-rules.d.ts +8 -1
- package/dist/secret-rules.js +482 -53
- package/dist/secrets.d.ts +51 -9
- package/dist/secrets.js +311 -21
- package/dist/server-keys.d.ts +4 -3
- package/dist/server-keys.js +4 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +15 -3
- package/dist/server.js +312 -80
- package/dist/share-context.d.ts +22 -0
- package/dist/share-context.js +76 -0
- package/dist/shell-lex.d.ts +105 -0
- package/dist/shell-lex.js +646 -0
- package/dist/sign-ins-store.d.ts +5 -7
- package/dist/sign-ins-store.js +12 -16
- package/dist/sign-ins.d.ts +7 -11
- package/dist/sign-ins.js +40 -41
- package/dist/skills/agentrun-serve/SKILL.md +5 -2
- package/dist/start-switches.d.ts +6 -5
- package/dist/start-switches.js +8 -4
- package/dist/stats.d.ts +5 -1
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/dialect.d.ts +4 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/mcp-record-keys.d.ts +10 -0
- package/dist/store/mcp-record-keys.js +13 -0
- package/dist/store/postgres/dialect.js +2 -0
- package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
- package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
- package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +33 -10
- package/dist/store/schema.js +70 -16
- package/dist/store/seal.d.ts +4 -1
- package/dist/store/sqlite/run-launch.d.ts +3 -10
- package/dist/store/sqlite/run-launch.js +12 -23
- package/dist/store/sqlite/run-patch.d.ts +17 -10
- package/dist/store/sqlite/run-patch.js +50 -13
- package/dist/store/sqlite/store.d.ts +3 -0
- package/dist/store/sqlite/store.js +116 -34
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +67 -32
- package/dist/store/store.js +14 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/learning.d.ts +35 -26
- package/dist/store-reads/learning.js +120 -92
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.js +10 -7
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.js +29 -13
- package/dist/template-eval.d.ts +72 -9
- package/dist/template-eval.js +358 -64
- package/dist/timeline/labels.d.ts +1 -1
- package/dist/timeline/labels.js +4 -3
- package/dist/timeline/timeline.d.ts +23 -11
- package/dist/timeline/timeline.js +115 -31
- package/dist/timeline/web-calls.d.ts +8 -6
- package/dist/timeline/web-calls.js +10 -6
- package/dist/tool-gate.d.ts +13 -1
- package/dist/tool-gate.js +43 -3
- package/dist/tool-keys-store.js +2 -4
- package/dist/tool-keys.d.ts +11 -0
- package/dist/tool-keys.js +16 -0
- package/dist/tool-plane.d.ts +50 -11
- package/dist/tool-plane.js +94 -30
- package/dist/tools.d.ts +5 -1
- package/dist/tools.js +7 -7
- package/dist/trigger-email.js +12 -6
- package/dist/triggers.d.ts +15 -34
- package/dist/triggers.js +119 -126
- package/dist/validate.d.ts +8 -1
- package/dist/validate.js +163 -23
- package/dist/web-fake.d.ts +2 -1
- package/dist/web-fake.js +8 -6
- package/dist/web-fetch.d.ts +8 -6
- package/dist/web-fetch.js +13 -11
- package/dist/web-holds.d.ts +32 -0
- package/dist/web-holds.js +86 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +75 -28
- package/dist/web-save.js +23 -12
- package/dist/web-search.js +14 -25
- package/dist/wires.d.ts +4 -3
- package/dist/wires.js +5 -4
- package/dist/workspace/archil-claim.d.ts +12 -5
- package/dist/workspace/archil-claim.js +45 -5
- package/dist/workspace/attach.js +52 -19
- package/dist/workspace/attached-computers.d.ts +6 -2
- package/dist/workspace/attached-computers.js +5 -4
- package/dist/workspace/computer-deps.d.ts +23 -6
- package/dist/workspace/computer-deps.js +35 -17
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +160 -54
- package/dist/workspace/computer-intervals.d.ts +2 -0
- package/dist/workspace/computer-intervals.js +1 -1
- package/dist/workspace/computer-janitor.d.ts +48 -14
- package/dist/workspace/computer-janitor.js +153 -44
- package/dist/workspace/computer-kept.d.ts +158 -32
- package/dist/workspace/computer-kept.js +288 -63
- package/dist/workspace/computer-providers.d.ts +8 -3
- package/dist/workspace/computer-providers.js +12 -5
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/local.js +41 -1
- package/dist/workspace/mount-revoke-left.d.ts +31 -0
- package/dist/workspace/mount-revoke-left.js +72 -0
- package/dist/workspace/paired-route.js +4 -5
- package/dist/workspace/resolve-computer.d.ts +5 -2
- package/dist/workspace/resolve-computer.js +9 -3
- package/dist/workspace/run-end-computers.d.ts +11 -5
- package/dist/workspace/run-end-computers.js +153 -28
- package/dist/workspace/run-tools.d.ts +22 -3
- package/dist/workspace/run-tools.js +17 -5
- package/dist/workspace/run-workspace.d.ts +14 -1
- package/dist/workspace/run-workspace.js +34 -1
- package/dist/workspace/workspace.d.ts +6 -0
- package/package.json +12 -13
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +22 -6
- package/dist/console/assets/backend-CSAWUqtZ.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-DPh29cyz.js +0 -747
|
@@ -17,8 +17,9 @@ import { existsSync } from "node:fs";
|
|
|
17
17
|
import { chmod, mkdir, rm } from "node:fs/promises";
|
|
18
18
|
import { dirname, join } from "node:path";
|
|
19
19
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
20
|
-
import { encode,
|
|
21
|
-
import {
|
|
20
|
+
import { encode, SECRET_NAMES, SECRETS_FD_ENV, SECRETS_LEN_ENV, withoutSecrets } from "../secrets.js";
|
|
21
|
+
import { genAiTracing, tracePosts } from "../otel/tracer.js";
|
|
22
|
+
import { agentOfRun } from "../otel/genai.js";
|
|
22
23
|
import { putLiveViewer, dropLiveViewer } from "../browser-live.js";
|
|
23
24
|
import { CALENDAR_EVENTS } from "../calendar/names.js";
|
|
24
25
|
import { openCalendar } from "../calendar/address.js";
|
|
@@ -35,7 +36,7 @@ import { DECISION_PROVIDER_KEYS } from "../tool-plane.js";
|
|
|
35
36
|
import { learningEndOfRun } from "./learning-end.js";
|
|
36
37
|
import { cutDeep, runnerSecrets } from "./redact.js";
|
|
37
38
|
import { storeSecrets } from "./store-secrets.js";
|
|
38
|
-
import { FAUX_ENV,
|
|
39
|
+
import { FAUX_ENV, GATEWAY_KEY_ENV } from "../model.js";
|
|
39
40
|
import { SAVED_GATEWAY_ENV, savedGatewayIn } from "../model-gateway.js";
|
|
40
41
|
import { FAUX_VENDOR_API_ENV } from "../tools.js";
|
|
41
42
|
import { withinCarried } from "../paid-calls.js";
|
|
@@ -44,11 +45,13 @@ import { runZone } from "../environment.js";
|
|
|
44
45
|
import { shadowRunId } from "../learn/audit.js";
|
|
45
46
|
import { LEARNING_SCRIPT, learningWorkspace } from "../learn/folder.js";
|
|
46
47
|
import { agreeOnOf } from "../learning-setting.js";
|
|
47
|
-
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
48
|
+
import { openedAtUse, openRunWorkspace } from "../workspace/run-workspace.js";
|
|
48
49
|
import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
49
50
|
import { agentDirName, recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
|
|
50
51
|
import { keptKeyOf } from "../workspace/computer-kept.js";
|
|
51
|
-
import {
|
|
52
|
+
import { waitEndedKey } from "../browser-wait-ended.js";
|
|
53
|
+
import { browserHoldKey } from "../browser-hold.js";
|
|
54
|
+
import { claimModelKey, claimSecrets, claimSpendOff, hostDecisionKeys, learnedDecisionKeys, openRunModelKey, savedModelKeys, sendsNoModelKey, serverKeyless, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
|
|
52
55
|
import { githubAppAccess } from "./github-app.js";
|
|
53
56
|
import { githubPullOf, githubTargetOf } from "../github.js";
|
|
54
57
|
import { isObject } from "../validate.js";
|
|
@@ -67,7 +70,9 @@ import { createDispatchLoop } from "./dispatch.js";
|
|
|
67
70
|
import { refuseRecipeTriggerRun, resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
|
|
68
71
|
import { isWorkflowRevision } from "./workflow-loop.js";
|
|
69
72
|
import { loginForRun } from "../claude-login.js";
|
|
70
|
-
import {
|
|
73
|
+
import { harnessOfBody } from "../harness.js";
|
|
74
|
+
import { agentRunLogin, LOGIN_CHANGED_SINCE_CLAIM, loginRunnerInProcess, loginTokensFor } from "../claude-login-token.js";
|
|
75
|
+
import { logLine } from "../print.js";
|
|
71
76
|
import { heardComputerHold } from "./computer-journal.js";
|
|
72
77
|
import { ClaimRefused } from "./loop-contract.js";
|
|
73
78
|
import { Channel, ChannelClosed } from "./run-channel.js";
|
|
@@ -75,12 +80,13 @@ import { registerRunErrors } from "./run-errors.js";
|
|
|
75
80
|
import { exposeSaveSlots } from "./save-slots.js";
|
|
76
81
|
import { runBigWrites } from "./big-writes.js";
|
|
77
82
|
import { SERVER_SLOTS } from "../web-save.js";
|
|
83
|
+
import { holdsEnv, noteHold } from "../web-holds.js";
|
|
78
84
|
import { launchOnItsDisk, readLaunchBody } from "../run-launch.js";
|
|
79
85
|
import { routedSubagentTiers, SUBAGENT_TOOL } from "./subagent.js";
|
|
80
86
|
import { sourceSyncOf } from "../source-sync/types.js";
|
|
81
87
|
import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
|
|
82
88
|
import { beginSourceIO } from "../source-sync/io.js";
|
|
83
|
-
import { runTools } from "../workspace/run-tools.js";
|
|
89
|
+
import { attachedIn, runTools } from "../workspace/run-tools.js";
|
|
84
90
|
import { ProjectHostGate } from "./project-host.js";
|
|
85
91
|
import { runProjectCheckpoint } from "./project-checkpoint.js";
|
|
86
92
|
/** The image's helper that starts a run's process as its slot's uid (packages/serve/runas). */
|
|
@@ -392,20 +398,59 @@ const always = () => true;
|
|
|
392
398
|
/** The settings a run's process may read, the server's own configuration its loop and tools read: its tool settings,
|
|
393
399
|
* its Archil settings (no credential), its MCP hosts and server names, its Claude-login mode and its approvers. */
|
|
394
400
|
const SHARED_SETTINGS = new Set(["tool-settings", "archil", "mcp.private_oauth_hosts", "mcp.server_own", "claude_login", "approvers"]);
|
|
401
|
+
/** The rows of the claim's own run that its process writes, and removes, itself, each with its string fields (beside the
|
|
402
|
+
* claim's epoch): its browser's wait that ended (browser-wait-ended.ts) and its browser's take (browser-hold.ts), each
|
|
403
|
+
* the run's process's report of its own browser to the server's reads. No other row is its to write. */
|
|
404
|
+
const ownWrittenSettings = (bound) => new Map([
|
|
405
|
+
[waitEndedKey(bound.claim.runId), ["at", "why"]],
|
|
406
|
+
[browserHoldKey(bound.claim.runId), ["session", "at"]],
|
|
407
|
+
]);
|
|
408
|
+
/** The most one of those rows may take, as JSON bytes: a session's tag, a time and a timeline row's words fit many times
|
|
409
|
+
* over, and the server parses the row on every read of the run and every Screen poll. */
|
|
410
|
+
const OWN_ROW_MAX_BYTES = 4096;
|
|
395
411
|
/** The settings of the claim's own run and agent a run's process may read: its run's Archil disk, SDK record, kept
|
|
396
|
-
* computer and browser
|
|
397
|
-
* not its to read. */
|
|
412
|
+
* computer, browser wait and browser take, and its agent's Archil disk and promotions. Every other row (another run's
|
|
413
|
+
* or agent's) is not its to read. */
|
|
398
414
|
const ownSettings = (bound) => new Set([
|
|
399
415
|
`archil.run.${bound.claim.runId}`,
|
|
400
416
|
`sdk-run:${bound.claim.runId}`,
|
|
401
417
|
keptKeyOf(bound.claim.runId),
|
|
402
|
-
|
|
418
|
+
...ownWrittenSettings(bound).keys(),
|
|
403
419
|
`archil.agent.${bound.agentId}`,
|
|
404
420
|
`learning.promotions.${bound.agentId}`,
|
|
405
421
|
]);
|
|
406
422
|
/** Whether a run's process may read setting `key`. */
|
|
407
423
|
export const settingReadable = (key, bound) => typeof key === "string" && (SHARED_SETTINGS.has(key) || ownSettings(bound).has(key));
|
|
408
424
|
const readableSetting = (args, bound) => settingReadable(args[0], bound);
|
|
425
|
+
/** Whether a run's process may remove setting `key`: only its own run's browser rows (ownWrittenSettings), and only one no
|
|
426
|
+
* later claim wrote (removeOwnRow, which reads the row). */
|
|
427
|
+
const removableSetting = (args, bound) => typeof args[0] === "string" && ownWrittenSettings(bound).has(args[0]);
|
|
428
|
+
/** The remove of one of the claim's own browser rows (removableSetting): a row a later claim of the run wrote stays, as
|
|
429
|
+
* a write takes only the claim's own epoch (writableSetting), so a claim still closing never clears the take or the
|
|
430
|
+
* ended wait of the claim that holds the run now. The row goes only while it is the one read (Settings.removeIf), so a
|
|
431
|
+
* later claim's write that lands between the read and the remove stays too. A key with no row is left as it is. */
|
|
432
|
+
async function removeOwnRow(settings, key, bound, log) {
|
|
433
|
+
const row = await settings.get(key);
|
|
434
|
+
if (row === undefined)
|
|
435
|
+
return;
|
|
436
|
+
const epoch = typeof row === "object" && row !== null ? row.epoch : undefined;
|
|
437
|
+
if (typeof epoch === "number" && epoch > bound.claim.epoch) {
|
|
438
|
+
log(`run ${bound.claim.runId}: its process asked the store for settings.remove of ${key}, which a later claim (epoch ${epoch}) wrote and a run's process may not remove`);
|
|
439
|
+
throw new ClaimRefused("a run's process may not call the store's settings.remove of a row a later claim wrote");
|
|
440
|
+
}
|
|
441
|
+
await settings.removeIf(key, row);
|
|
442
|
+
}
|
|
443
|
+
/** Whether a run's process may write `value` to setting `key`: one of its own run's browser rows, with that row's fields
|
|
444
|
+
* alone, each a string, the claim's own epoch, and at most OWN_ROW_MAX_BYTES. A row with a later epoch would be kept by
|
|
445
|
+
* every clear of this claim (browser-hold.ts), so a later claim would read a take nobody holds. */
|
|
446
|
+
const writableSetting = ([key, value], bound) => {
|
|
447
|
+
const fields = typeof key === "string" ? ownWrittenSettings(bound).get(key) : undefined;
|
|
448
|
+
if (!fields || typeof value !== "object" || value === null || Array.isArray(value))
|
|
449
|
+
return false;
|
|
450
|
+
const row = value;
|
|
451
|
+
return Object.keys(row).length === fields.length + 1 && row.epoch === bound.claim.epoch && fields.every((field) => typeof row[field] === "string")
|
|
452
|
+
&& Buffer.byteLength(JSON.stringify(row)) <= OWN_ROW_MAX_BYTES;
|
|
453
|
+
};
|
|
409
454
|
/** The store's methods a run's loop calls, each with what binds it to the claim. A method not here is refused, and the
|
|
410
455
|
* refusal is said on the runner's log. Reads of the claim's run, its launch, its commands and its agent's revisions;
|
|
411
456
|
* of what was spent beside it (its learning grades, its own audit's shadow run's row and launch, which its cap gates
|
|
@@ -428,6 +473,8 @@ const STORE_CALLS = new Map([
|
|
|
428
473
|
["agents.revision", always],
|
|
429
474
|
["agents.revisions", ownAgent],
|
|
430
475
|
["settings.get", readableSetting],
|
|
476
|
+
["settings.put", writableSetting],
|
|
477
|
+
["settings.remove", removableSetting],
|
|
431
478
|
// Its rows filtered to the readable ones (storeCall).
|
|
432
479
|
["settings.all", always],
|
|
433
480
|
["mcp.pin", ownRun],
|
|
@@ -456,6 +503,8 @@ export async function storeCall(store, method, args, bound, log) {
|
|
|
456
503
|
}
|
|
457
504
|
if (method === "readJournal")
|
|
458
505
|
return journalRead(store, args);
|
|
506
|
+
if (method === "settings.remove")
|
|
507
|
+
return removeOwnRow(store.settings, args[0], bound, log);
|
|
459
508
|
const path = method.split(".");
|
|
460
509
|
let target = store;
|
|
461
510
|
for (const part of path.slice(0, -1))
|
|
@@ -612,6 +661,8 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
612
661
|
};
|
|
613
662
|
const fromGitHub = launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github";
|
|
614
663
|
const github = () => githubAppAccess(store, sealKey, launch.input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) });
|
|
664
|
+
/** The run's folder as the computer this claim made mounts it (Mode 2), where the claim's MCP files once it is made. */
|
|
665
|
+
let mountedFolder;
|
|
615
666
|
/** Mode 2's Archil claim, made once for the claim on the runner, its folder the run's. */
|
|
616
667
|
let archil;
|
|
617
668
|
const archilOf = () => (archil ??= (async () => {
|
|
@@ -626,9 +677,14 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
626
677
|
* handed none of the server's (claim-secrets.ts keyedAtClaim, held here for the runner's answers). */
|
|
627
678
|
const runKeyed = async () => (await openRunModelKey(keys, claim.runId)) !== undefined;
|
|
628
679
|
/** Whether the claim's run is held, its model kept from running at its create (hold.refused): it routes no model, so
|
|
629
|
-
* whatever its process asks, the runner hands it no model key, answers it keyless
|
|
630
|
-
* learned workflows and its end-of-run step), as its spec asks for
|
|
680
|
+
* whatever its process asks, the runner hands it no model key (keyless, below), answers it keyless, opens it no harness
|
|
681
|
+
* key and no MCP, and refuses it a learning step (its learned workflows and its end-of-run step), as its spec asks for
|
|
682
|
+
* none of them (adapter-run-spec.ts, cli-run-spec.ts). */
|
|
631
683
|
const modelRefused = launch.hold?.refused !== undefined;
|
|
684
|
+
/** Whether the claim's run sends no model key (claim-secrets.ts sendsNoModelKey: a held run as above, any run on a --faux
|
|
685
|
+
* runner, a faux-pinned one; `deps.env` is the claim's environment): the runner answers its process no tier's model key.
|
|
686
|
+
* A faux run still runs its learned steps on the faux model: only modelRefused refuses them. */
|
|
687
|
+
const keyless = sendsNoModelKey(launch, deps.env ?? {});
|
|
632
688
|
const refusedSpend = () => new ClaimRefused("a held run its model kept from running asks its runner for no model spend: it routes no model and takes no learning step");
|
|
633
689
|
const learningFolder = async () => {
|
|
634
690
|
const made = await archilOf();
|
|
@@ -714,21 +770,35 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
714
770
|
// or refused); never its folder or its refresh token. Each token is carried into the runner's redactor for this run
|
|
715
771
|
// (redact.ts carry) before it is handed, a renewed one too: model text that repeats it is cut from the run's journal
|
|
716
772
|
// as the runner writes it (runner.ts fenced), from what it stages and from its rows, as the run's own tool keys are.
|
|
717
|
-
// This answer is the
|
|
718
|
-
//
|
|
773
|
+
// This answer is the one decision whether the run goes on the login: none, it does not. Its claim read the setting
|
|
774
|
+
// (staysInRunner); a claim that read it off is never put on it, whatever the setting says now. A claim that read it on
|
|
775
|
+
// has it read again here, at the start, with the claim's settings, data folder, harness and place. Its environment is
|
|
776
|
+
// the claim's (the process's, when the runner was given none) with a saved gateway laid over it (withSavedGatewayDeps),
|
|
777
|
+
// not always the very one the claim read with; that
|
|
778
|
+
// difference can only refuse the start, never hand another folder, since the login is handed only when both reads name
|
|
779
|
+
// the same folder: a turn-off, or a move to another folder,
|
|
780
|
+
// between the claim and the start refuses the start in LOGIN_CHANGED_SINCE_CLAIM's fixed words (no folder in them),
|
|
781
|
+
// never a start on a login the setting no longer names nor a fall to a model key the run was not claimed on. Nothing
|
|
782
|
+
// else of the claim is read again. A run with a model key of its own, and a login other than AgentRun's own folder,
|
|
783
|
+
// were each decided at the claim (staysInRunner: no login read for the one, LOGIN_MACHINE_NEEDS_SERVER_USER for the
|
|
784
|
+
// other), so neither reaches here on a login. The process reads no setting or machine id.
|
|
785
|
+
// None for a run that sends no model key (keyless: a held run, any run on a --faux runner, a faux-pinned one), whatever
|
|
786
|
+
// its claim read: the login is a model credential like any key.
|
|
719
787
|
claudeLogin: async () => {
|
|
720
|
-
if (
|
|
788
|
+
if (keyless)
|
|
721
789
|
return undefined;
|
|
722
|
-
const
|
|
723
|
-
const at = await loginForRun(store.settings, deps.data, deps.env ?? {}, harness, launch.place);
|
|
790
|
+
const at = reads.login;
|
|
724
791
|
if (!at)
|
|
725
792
|
return undefined;
|
|
726
|
-
|
|
727
|
-
|
|
793
|
+
const now = await loginForRun(store.settings, deps.data, deps.env ?? {}, harnessOfBody(launch), launch.place);
|
|
794
|
+
if (now?.dir !== at.dir)
|
|
795
|
+
throw new ClaimRefused(LOGIN_CHANGED_SINCE_CLAIM);
|
|
728
796
|
const carry = cut.carry;
|
|
729
797
|
if (!carry)
|
|
730
798
|
throw new ClaimRefused("This runner has no redactor that can cut the login's token from what its run writes, so it hands none.");
|
|
731
|
-
|
|
799
|
+
// Each renewal's outcome on the runner's log, in the server's line (print.ts logLine) under event claude_login:
|
|
800
|
+
// fixed words, a status and an OAuth error code, never a token.
|
|
801
|
+
const tokens = loginTokensFor(at, (fields) => log(logLine("claude_login", fields)));
|
|
732
802
|
return {
|
|
733
803
|
token: async () => {
|
|
734
804
|
const token = await tokens.token();
|
|
@@ -744,10 +814,27 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
744
814
|
return runSignIn(store, sealKey, claim, String(resolution), { vendors: vendorsOver(() => claimed, vendorFetch), log });
|
|
745
815
|
},
|
|
746
816
|
verifySignIn: (kept, at) => verifyRunSignIn(store, sealKey, claim, kept, Number(at)),
|
|
817
|
+
// None for a held run its model kept from running: nothing can call it, so no credential of it is opened.
|
|
747
818
|
mcp: (ask) => projectCall(async () => {
|
|
819
|
+
if (modelRefused)
|
|
820
|
+
return undefined;
|
|
748
821
|
const reach = await mcpReachOf(deps);
|
|
749
822
|
const harness = { commit: (change) => change({ appendEntry: async (_conversation, entry) => void (await ask.appendRoot(dataOnly(entry))) }) };
|
|
750
|
-
|
|
823
|
+
// What the gateway files goes in the run's own files. In Mode 1 that is the run's folder on this machine. In Mode 2
|
|
824
|
+
// it is the run's disk: through the computer this claim made once it mounts the folder (mountedFolder, the computer
|
|
825
|
+
// answer's), since the mount holds the disk's write delegation; over the disk's file API when no computer mounts it.
|
|
826
|
+
// That Workspace is opened at the first answer that files something, not at the claim: a claim whose MCP files
|
|
827
|
+
// nothing opens none (an open lists the run's folder, and makes it when it is missing). It only writes files over the
|
|
828
|
+
// disk's file API and runs no command, so it sweeps no exec spill folder, at its open or at its end (sweep: false): it
|
|
829
|
+
// opens mid-run, beside the archil answer's Workspace, whose commands may still be reading their spill files there.
|
|
830
|
+
// Opened once, and let go at the claim's release; an open that failed is tried again at the next answer. Its release is
|
|
831
|
+
// registered here, before any open, so an open still running at the release is ended too, and a filing after it opens
|
|
832
|
+
// nothing (openedAtUse). work() is read only when a call's answer files something (mcp-gateway.ts textOf, fileResults).
|
|
833
|
+
const disk = await archilOf();
|
|
834
|
+
const overTheDisk = disk === undefined ? undefined : openedAtUse(() => openRunWorkspace({ mode: 2, agentId: run.agentId, runId: claim.runId, archil: disk, sweep: false, log }));
|
|
835
|
+
if (overTheDisk)
|
|
836
|
+
releases.push(() => overTheDisk.end());
|
|
837
|
+
const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => (overTheDisk === undefined ? runFolder(deps.data, run.agentId, claim.runId) : mountedFolder ?? overTheDisk.workspace()), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, undefined, launch) });
|
|
751
838
|
if (!made)
|
|
752
839
|
return undefined;
|
|
753
840
|
releases.push(() => made.release());
|
|
@@ -788,10 +875,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
788
875
|
// that tier's model's key alone (through a gateway, the gateway's), none when the revision names agree_on (no
|
|
789
876
|
// grader). A learning run's grade and an SDK run's compile turn stay in the runner (runsInRunner): their process
|
|
790
877
|
// never asks, and gets none. And never for a run that holds a key of its own (its launch's, read now): the server's
|
|
791
|
-
// keys are not its to spend, whatever its process asks; nor for a
|
|
792
|
-
// no model and grades nothing.
|
|
793
|
-
const subagent = !
|
|
794
|
-
const grades = !
|
|
878
|
+
// keys are not its to spend, whatever its process asks; nor for a run that sends no model key (keyless: a held run,
|
|
879
|
+
// which routes no model and grades nothing, or a faux one, whose model sends none).
|
|
880
|
+
const subagent = !keyless && revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL);
|
|
881
|
+
const grades = !keyless && (launch.replay !== undefined || launch.audit !== undefined) && !agreeOnOf(revision.body.learning)?.length;
|
|
795
882
|
if (!subagent && !grades)
|
|
796
883
|
return {};
|
|
797
884
|
const { tiers, refs } = routedSubagentTiers(revision.body, keys.env ?? {});
|
|
@@ -801,9 +888,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
801
888
|
tierModelKeys: async (tiers) => {
|
|
802
889
|
// The tiers the claim's learned workflows name (learnedTiers), as this runner chose them (learnedFirst below): a
|
|
803
890
|
// tier the process names beyond them gets no key, and none before the choice (a held run its model kept from running
|
|
804
|
-
// makes none: its learnedFirst is refused)
|
|
891
|
+
// makes none: its learnedFirst is refused), nor to a run that sends no model key (keyless: a faux one's tiers run on
|
|
892
|
+
// the faux model).
|
|
805
893
|
const asked = new Set(tiers.filter((tier) => typeof tier === "string"));
|
|
806
|
-
const named = !
|
|
894
|
+
const named = !keyless && learnsWorkflows(revision.kind, learnedFlows) ? learnedTiers(learnedFlows).filter((tier) => asked.has(tier)) : [];
|
|
807
895
|
const keyed = await runKeyed();
|
|
808
896
|
const got = keyed ? {} : await tierModelKeys(keys, named);
|
|
809
897
|
const plan = planOf(got);
|
|
@@ -825,9 +913,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
825
913
|
// harness is a plan-billed recipe on this runner's table, and never another harness's. Opened for the recipe file
|
|
826
914
|
// the process loaded (`digest`), never the one this runner's table read at its start: a file swapped for another
|
|
827
915
|
// vendor's under the same id since then runs its own binary, and a key bound to the first file never opens for it.
|
|
916
|
+
// None for a held run its model kept from running: its agent never starts.
|
|
828
917
|
harnessKeys: async (digest) => {
|
|
829
918
|
const harness = launch.harness ?? revision.body.harness;
|
|
830
|
-
const recipe = harness === undefined ? undefined : planRecipeOf(deps.env, harness);
|
|
919
|
+
const recipe = harness === undefined || modelRefused ? undefined : planRecipeOf(deps.env, harness);
|
|
831
920
|
return recipe?.keys.length && typeof digest === "string" ? openHarnessKeys(store, sealKey, { ...recipe, digest }) : {};
|
|
832
921
|
},
|
|
833
922
|
liveViewerPut: (handover) => putLiveViewer(store, sealKey, claim, handover),
|
|
@@ -870,13 +959,21 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
870
959
|
hadComputer: async () => (await ask.hadComputer()) === true,
|
|
871
960
|
...(typeof ask.turnedOff === "string" ? { turnedOff: ask.turnedOff } : {}),
|
|
872
961
|
...(ask.signal instanceof AbortSignal ? { signal: ask.signal } : {}),
|
|
873
|
-
...(made ? { revokeMount: () => made.revoke(), inheritMount: () => made.inherit() } : {}),
|
|
962
|
+
...(made ? { revokeMount: () => made.revoke(), inheritMount: () => made.inherit(), mountDisk: () => made.disk.id } : {}),
|
|
874
963
|
...(typeof ask.onImageWait === "function" ? { onImageWait: ask.onImageWait } : {}),
|
|
875
964
|
...(typeof ask.onStarting === "function" ? { onStarting: ask.onStarting } : {}),
|
|
876
965
|
...(typeof ask.onConnected === "function" ? { onConnected: ask.onConnected } : {}),
|
|
877
966
|
...(typeof ask.onComputerNote === "function" ? { onComputerNote: ask.onComputerNote } : {}),
|
|
878
967
|
});
|
|
879
968
|
releases.push(() => ws.end());
|
|
969
|
+
// A Mode 2 computer that mounts the run's folder holds the disk's write delegation: what the claim's MCP files then
|
|
970
|
+
// goes through it, attached here as the run's process attaches it. A failed attach leaves the MCP on the disk's file
|
|
971
|
+
// API, which says in its answer that the file could not be saved.
|
|
972
|
+
if (mode === 2)
|
|
973
|
+
mountedFolder = await attachedIn(ws.workspace, got?.computer).catch((error) => {
|
|
974
|
+
log(`the run's folder could not be attached for the MCP's files: ${error?.message ?? String(error)}`);
|
|
975
|
+
return undefined;
|
|
976
|
+
});
|
|
880
977
|
// The computer let go by this runner at the claim's release too, before its folder: a process that crashed or broke
|
|
881
978
|
// its channel never calls its release. Idempotent with the process's own release and with its park (which keeps it).
|
|
882
979
|
const claimed = got;
|
|
@@ -889,7 +986,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
889
986
|
const { syncProject: _sync, ...exposed } = got;
|
|
890
987
|
return { ...exposed, ...(exposed.computer ? { computer: projectGate.capability(exposed.computer) } : {}),
|
|
891
988
|
release: (...args) => cleanProject(() => exposed.release(...args)),
|
|
892
|
-
...(exposed.park ? { park: (...args) => cleanProject(() => exposed.park(...args)) } : {})
|
|
989
|
+
...(exposed.park ? { park: (...args) => cleanProject(() => exposed.park(...args)) } : {}),
|
|
990
|
+
// The park's keep written ahead of it lands the folder's delta first, so it waits for the project's work as the
|
|
991
|
+
// park does.
|
|
992
|
+
...(exposed.keepRow ? { keepRow: () => cleanProject(() => exposed.keepRow()) } : {}) };
|
|
893
993
|
}
|
|
894
994
|
return got;
|
|
895
995
|
}),
|
|
@@ -1081,16 +1181,6 @@ export const loginRunnerInProcessWords = (other) => `This runner runs each run a
|
|
|
1081
1181
|
/** The words a run on a harness recipe is refused in where each run is a user of its own (harness-table.ts recipeHarness). */
|
|
1082
1182
|
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.`;
|
|
1083
1183
|
export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
|
|
1084
|
-
/** Whether run `runId` stays in its runner's process: runsInRunner's, and a workflow run on a server with a documents
|
|
1085
|
-
* directory (launch.documents), whose reads and writes (a pdf_pages call's pages) are rooted in a folder the server's
|
|
1086
|
-
* 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
|
|
1087
|
-
* Code's login on this machine (claude-login.ts loginForRun), where runs are the runner's own user (`process`), stays in
|
|
1088
|
-
* the runner, its CLI on the login's folder. Where each run is a user of its own (`uid`), a run on AgentRun's own login
|
|
1089
|
-
* folder is a process of its own handed the login's access token alone (held.ts claudeLogin, claude-login-token.ts),
|
|
1090
|
-
* never the folder; it is refused at its claim (ClaimRefused, in words) on this machine's own login (machineFolder), and
|
|
1091
|
-
* while a `process` runner on the same data folder is live (its CLI renews the folder's login itself). A run its caller
|
|
1092
|
-
* handed a model key (model_key) runs on that key and never on the login (cli-run-spec.ts), so it is a process of its
|
|
1093
|
-
* own like any other. */
|
|
1094
1184
|
export async function staysInRunner(deps, harness, launch, runId, isolation) {
|
|
1095
1185
|
// A recipe's harness reads its install, its check's note and its owner's sign-in, each the server user's alone: never
|
|
1096
1186
|
// 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
|
|
@@ -1100,38 +1190,45 @@ export async function staysInRunner(deps, harness, launch, runId, isolation) {
|
|
|
1100
1190
|
throw new ClaimRefused(RECIPE_NEEDS_SERVER_USER);
|
|
1101
1191
|
await refuseRecipeTriggerRun(deps, harness, launch);
|
|
1102
1192
|
if (runsInRunner(harness, launch))
|
|
1103
|
-
return
|
|
1193
|
+
return STAYS;
|
|
1104
1194
|
if (launch.documents !== undefined) {
|
|
1105
1195
|
const run = await deps.store.runs.get(runId);
|
|
1106
1196
|
const revision = run ? await deps.store.agents.revision(run.revisionId) : undefined;
|
|
1107
1197
|
if (revision && isWorkflowRevision(revision))
|
|
1108
|
-
return
|
|
1198
|
+
return STAYS;
|
|
1109
1199
|
}
|
|
1110
1200
|
const login = await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, harness, launch.place);
|
|
1111
1201
|
if (login === undefined)
|
|
1112
|
-
return
|
|
1202
|
+
return OFF_LOGIN;
|
|
1113
1203
|
if ((await openRunModelKey({ store: deps.store, sealKey: deps.sealKey }, runId)) !== undefined)
|
|
1114
|
-
return
|
|
1204
|
+
return OFF_LOGIN;
|
|
1115
1205
|
if (isolation.kind !== "uid")
|
|
1116
|
-
return
|
|
1206
|
+
return STAYS;
|
|
1117
1207
|
if (!agentRunLogin(login, deps.data))
|
|
1118
1208
|
throw new ClaimRefused(LOGIN_MACHINE_NEEDS_SERVER_USER);
|
|
1119
1209
|
const other = await loginRunnerInProcess(deps.data, deps.store.runners);
|
|
1120
1210
|
if (other !== undefined)
|
|
1121
1211
|
throw new ClaimRefused(loginRunnerInProcessWords(other));
|
|
1122
|
-
return false;
|
|
1212
|
+
return { stays: false, login };
|
|
1123
1213
|
}
|
|
1214
|
+
const STAYS = { stays: true };
|
|
1215
|
+
const OFF_LOGIN = { stays: false, login: undefined };
|
|
1124
1216
|
/** The runner's loop factory where each run is a process of its own: a ChildLoop per claim, but for a run that stays in
|
|
1125
1217
|
* the runner (staysInRunner). */
|
|
1126
1218
|
export function childLoops(options) {
|
|
1127
1219
|
// Each slot locked on the data directory too: another runner on it whose range overlaps this one's never runs a run
|
|
1128
1220
|
// on a slot this one holds.
|
|
1129
1221
|
const slots = options.isolation.kind === "uid" ? new Slots(options.isolation.first, options.isolation.slots, slotLocks(options.deps.data)) : undefined;
|
|
1130
|
-
const own = (loopDeps) => childLoop(options, slots, loopDeps);
|
|
1131
1222
|
const here = resolveRunnerLoop(options.deps);
|
|
1132
1223
|
return createDispatchLoop({
|
|
1133
1224
|
launchOf: (runId) => options.deps.store.runs.launch(runId),
|
|
1134
|
-
resolve: async (harness, launch, runId) =>
|
|
1225
|
+
resolve: async (harness, launch, runId) => {
|
|
1226
|
+
const place = await staysInRunner(options.deps, harness, launch, runId, options.isolation);
|
|
1227
|
+
if (place.stays)
|
|
1228
|
+
return here(harness, launch, runId);
|
|
1229
|
+
const own = (loopDeps) => childLoop(options, slots, loopDeps, place.login);
|
|
1230
|
+
return own;
|
|
1231
|
+
},
|
|
1135
1232
|
});
|
|
1136
1233
|
}
|
|
1137
1234
|
registerRunErrors();
|
|
@@ -1142,12 +1239,6 @@ function withGatewayKey(claimed, key) {
|
|
|
1142
1239
|
Object.defineProperty(out, GATEWAY_KEY_ENV, { value: key, enumerable: false, writable: false, configurable: false });
|
|
1143
1240
|
return out;
|
|
1144
1241
|
}
|
|
1145
|
-
/** The pair a run's process is handed this runner's OpenTelemetry settings in (secrets.ts OTEL_PAIR): none when it has
|
|
1146
|
-
* none. */
|
|
1147
|
-
export const otelPair = (env = process.env) => {
|
|
1148
|
-
const settings = otelSettings(env);
|
|
1149
|
-
return Object.keys(settings).length ? [[OTEL_PAIR, JSON.stringify(settings)]] : [];
|
|
1150
|
-
};
|
|
1151
1242
|
/** The environment a run's process starts with: the runner's run environment's plain values (runEnv: its secrets are
|
|
1152
1243
|
* not enumerable, so none is here), no key-shaped name, and where its keys come from. */
|
|
1153
1244
|
function childEnv(base, keys, extra) {
|
|
@@ -1170,7 +1261,8 @@ export function runChannel(socket, onClose, gate = SERVER_SLOTS, more = {}) {
|
|
|
1170
1261
|
saves = exposeSaveSlots(channel, gate);
|
|
1171
1262
|
return channel;
|
|
1172
1263
|
}
|
|
1173
|
-
|
|
1264
|
+
/** `login`: the Claude login this run's claim read (staysInRunner), the one its runner hands the run (ClaimReads). */
|
|
1265
|
+
function childLoop(options, slots, loopDeps, login) {
|
|
1174
1266
|
const { deps, isolation } = options;
|
|
1175
1267
|
const cut = loopDeps.redact ?? ((text) => text);
|
|
1176
1268
|
const log = (line) => options.log(cut(line));
|
|
@@ -1252,33 +1344,26 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1252
1344
|
const savedGateway = savedGatewayIn(claimEnv);
|
|
1253
1345
|
// The run's own keys: those its claim opens (claim-secrets.ts), the one list its loop in this process read. Its model
|
|
1254
1346
|
// keys are its pinned model's (claimSecrets scopes them by the launch's model), the one its route sends: never the
|
|
1255
|
-
// host's default's now, where its revision names no model and a key saved since moved that default.
|
|
1347
|
+
// host's default's now, where its revision names no model and a key saved since moved that default. On a --faux
|
|
1348
|
+
// runner, or pinned to the faux model, a run sends no model key (claim-secrets.ts sendsNoModelKey): its process is
|
|
1349
|
+
// handed none, not even its revision's model's.
|
|
1256
1350
|
const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, launch, claim.runId);
|
|
1257
|
-
// A --faux start alone is pinned to the faux model (model.ts chooseModel), which stands in for its revision's and
|
|
1258
|
-
// sends no key: its process is handed its revision's model's key with them, as a run of that model is handed it.
|
|
1259
|
-
// Only on a runner in faux mode too: a faux launch claimed where FAUX_ENV is unset gets no second claim. A held run its
|
|
1260
|
-
// model kept from running at its create (hold.refused) is laid no model key here either: its model runs nowhere.
|
|
1261
|
-
const ofRevision = launch.model?.provider === FAUX_PROVIDER && claimEnv[FAUX_ENV] ? await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, { ...(launch.plane ? { plane: launch.plane } : {}), ...(launch.hold ? { hold: launch.hold } : {}) }) : {};
|
|
1262
1351
|
// A run that holds a model key of its own (model_key, its launch's) spends that key alone: its process is handed
|
|
1263
1352
|
// none of the server's model keys, as its spec drops them from its tools' (claim-secrets.ts withoutModelKeys).
|
|
1264
1353
|
// Copies: the runner's own reads (heldFor's `claimed`: what the run's learning must never keep) stay whole.
|
|
1265
1354
|
const keyed = (await openRunModelKey({ store: deps.store, sealKey: deps.sealKey }, claim.runId)) !== undefined;
|
|
1266
|
-
const toProcess = keyed ?
|
|
1355
|
+
const toProcess = keyed ? withoutModelKeys({ ...claimed }) : claimed;
|
|
1267
1356
|
// The saved gateway's key, kept off the claim's tool keys (claimSecrets), is handed for the run's model routes alone,
|
|
1268
1357
|
// read as the server's model keys are (savedModelKeys, over the claim's environment the gateway was laid over), as a
|
|
1269
1358
|
// run in this process reads it from its environment by name; none to a run that brings its own key, and none to a
|
|
1270
|
-
// held run its model kept from running,
|
|
1271
|
-
|
|
1272
|
-
const
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
// The runner's OpenTelemetry settings, so the run's process exports its trace as this one would: on the pipe,
|
|
1279
|
-
// since no run's environment has them (runEnv), never in the process's environment.
|
|
1280
|
-
...otelPair(),
|
|
1281
|
-
]);
|
|
1359
|
+
// run whose model sends no key (sendsNoModelKey: a held run its model kept from running, any run on a --faux runner,
|
|
1360
|
+
// a faux-pinned one).
|
|
1361
|
+
const gatewayKey = savedGateway && !sendsNoModelKey(launch, claimEnv) ? (keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }))[GATEWAY_KEY_ENV] || undefined : undefined;
|
|
1362
|
+
const handed = (name) => (name === GATEWAY_KEY_ENV && savedGateway ? gatewayKey : toProcess[name] || undefined);
|
|
1363
|
+
const keys = encode(SECRET_NAMES.flatMap((name) => {
|
|
1364
|
+
const value = handed(name);
|
|
1365
|
+
return value === undefined ? [] : [[name, value]];
|
|
1366
|
+
}));
|
|
1282
1367
|
const slot = await slots?.take();
|
|
1283
1368
|
if (slots && slot === undefined) {
|
|
1284
1369
|
// Every free slot of this runner is held by another runner on the data directory (ranges that overlap): the run
|
|
@@ -1300,8 +1385,17 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1300
1385
|
const tops = runTops(deps.data, runRow.agentId, claim.runId);
|
|
1301
1386
|
// The run's pieced writes (big-writes.ts): let go when its channel ends, or at the claim's release.
|
|
1302
1387
|
const bigs = runBigWrites();
|
|
1303
|
-
const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed, signal: loopDeps.signal, ...(loopDeps.incarnation ? { incarnation: loopDeps.incarnation } : {}) }, cut, log, bigs);
|
|
1388
|
+
const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed, signal: loopDeps.signal, login, ...(loopDeps.incarnation ? { incarnation: loopDeps.incarnation } : {}) }, cut, log, bigs);
|
|
1389
|
+
// The run's trace: its process posts each call of it (tracer.ts postedTracing), and this runner's tracing makes the
|
|
1390
|
+
// spans and exports them in the background. No exporter, flush or OTLP setting is ever the process's, so neither
|
|
1391
|
+
// its exit nor this claim's release waits on a collector. Made inside the claim's cleanup, so nothing it waits on
|
|
1392
|
+
// can keep the slot.
|
|
1393
|
+
let traced;
|
|
1304
1394
|
try {
|
|
1395
|
+
const tracing = await (options.tracing ?? genAiTracing()).catch(() => undefined);
|
|
1396
|
+
// Its agent is the one this runner reads from the store, never one the process posts; a read that fails is the
|
|
1397
|
+
// agent's id alone (agentOfRun).
|
|
1398
|
+
traced = tracing ? tracePosts(tracing, claim.runId, cut, await agentOfRun(deps.store.agents, runRow.agentId)) : undefined;
|
|
1305
1399
|
let extra = {};
|
|
1306
1400
|
let argv = [...(options.argv ?? childArgv())];
|
|
1307
1401
|
// A claim that resumes a run whose last runner ended before giving its folders back finds them its last slot's,
|
|
@@ -1320,7 +1414,8 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1320
1414
|
argv = [isolation.helper, "run", String(slot), "--keep-fd", "3", "--keep-fd", "4", "--", ...argv];
|
|
1321
1415
|
}
|
|
1322
1416
|
// The saved gateway's address and models go as plain variables (childEnv), and its mark says they are the saved one.
|
|
1323
|
-
|
|
1417
|
+
// The server's keyless holds now (web-holds.ts), so the run's Web starts with them: hold data alone.
|
|
1418
|
+
const env = childEnv(claimEnv, keys, { ...extra, ...holdsEnv(), ...(savedGateway ? { [SAVED_GATEWAY_ENV]: "1" } : {}) });
|
|
1324
1419
|
const [program, ...rest] = argv;
|
|
1325
1420
|
child = spawn(program, rest, { stdio: ["ignore", "inherit", "inherit", "pipe", "pipe"], env, detached: true });
|
|
1326
1421
|
exited = new Promise((resolve) => {
|
|
@@ -1340,6 +1435,9 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1340
1435
|
const bound = { claim, agentId: runRow.agentId, revisionId: runRow.revisionId };
|
|
1341
1436
|
channel.expose("store", (method, args) => storeCall(deps.store, method, args, bound, log));
|
|
1342
1437
|
channel.expose("journal", journalTarget(loopDeps.journal(claim), cut));
|
|
1438
|
+
const posts = traced;
|
|
1439
|
+
if (posts)
|
|
1440
|
+
channel.expose("trace", (method, args) => posts.post(method, args));
|
|
1343
1441
|
channel.expose("held", (method, args) => {
|
|
1344
1442
|
// Its own members alone: a name of Object's prototype (constructor, toString) is no call of Held.
|
|
1345
1443
|
const fn = Object.hasOwn(heldSide.held, method) ? heldSide.held[method] : undefined;
|
|
@@ -1361,6 +1459,8 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1361
1459
|
return undefined;
|
|
1362
1460
|
case "log":
|
|
1363
1461
|
return void log(String(args[0]));
|
|
1462
|
+
case "webHold":
|
|
1463
|
+
return void noteHold(args[0]);
|
|
1364
1464
|
default:
|
|
1365
1465
|
throw new ClaimRefused(`the runner has no ${method} for a run`);
|
|
1366
1466
|
}
|
|
@@ -1368,7 +1468,7 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1368
1468
|
loopDeps.live?.(() => latest);
|
|
1369
1469
|
const reach = await mcpReachOf(deps);
|
|
1370
1470
|
const init = {
|
|
1371
|
-
claim, data: deps.data, signal: loopDeps.signal, where: deps.store.where,
|
|
1471
|
+
claim, data: deps.data, signal: loopDeps.signal, where: deps.store.where, ...(traced ? { traced: true } : {}),
|
|
1372
1472
|
...(reach.loopback ? { mcpLoopback: true, mcpOwn: reach.own ?? [] } : {}),
|
|
1373
1473
|
...(deps.githubApi ? { githubApi: deps.githubApi } : {}),
|
|
1374
1474
|
...(deps.githubWeb ? { githubWeb: deps.githubWeb } : {}),
|
|
@@ -1396,6 +1496,8 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1396
1496
|
}
|
|
1397
1497
|
finally {
|
|
1398
1498
|
ready();
|
|
1499
|
+
// A process gone before it ended its trace: its spans end with the claim (after its own end, a no-op).
|
|
1500
|
+
await traced?.end("run-error");
|
|
1399
1501
|
await heldSide.projectEnd?.();
|
|
1400
1502
|
const reaped = await end(slot, tops).catch((error) => {
|
|
1401
1503
|
log(`run ${claim.runId}: its process's end failed: ${error?.message ?? error}`);
|
package/dist/runner/run-child.js
CHANGED
|
@@ -19,21 +19,25 @@ import { registerRunErrors } from "./run-errors.js";
|
|
|
19
19
|
import { remoteSaveSlots } from "./save-slots.js";
|
|
20
20
|
import { runEnv } from "./main.js";
|
|
21
21
|
import { carriedLedger } from "../paid-calls.js";
|
|
22
|
+
import { reportHoldsTo } from "../web-holds.js";
|
|
22
23
|
import { heldHands } from "../workspace/computer-hold.js";
|
|
23
|
-
import {
|
|
24
|
+
import { postedTracing } from "../otel/tracer.js";
|
|
24
25
|
/** How often the run's process reads its loop's held state (LoopDeps.live) and posts it to its runner when it moved: the
|
|
25
26
|
* runner's live ticker reads the newest it was posted. */
|
|
26
27
|
const LIVE_POLL_MS = 200;
|
|
27
28
|
registerRunErrors();
|
|
28
29
|
const socket = new Socket({ fd: 4, readable: true, writable: true });
|
|
29
30
|
const channel = new Channel(socket, {
|
|
30
|
-
// The runner closed the channel (the loop's end answered) or is gone: nothing of the run's goes on
|
|
31
|
-
//
|
|
32
|
-
onClose: () => void setImmediate(() =>
|
|
31
|
+
// The runner closed the channel (the loop's end answered) or is gone: nothing of the run's goes on. Its trace is the
|
|
32
|
+
// runner's to send (postedTracing): nothing here waits on a collector.
|
|
33
|
+
onClose: () => void setImmediate(() => process.exit(0)),
|
|
33
34
|
// Each call carries the ledger of the tool call it is made in: what the runner does for it (an MCP tool's call, a
|
|
34
35
|
// computer's) books on the run's one ledger, as it would in the run's own process.
|
|
35
36
|
context: carriedLedger,
|
|
36
37
|
});
|
|
38
|
+
// A keyless hold the run meets is the server's (web-holds.ts): handed to the runner, whose server keeps it. An end JSON
|
|
39
|
+
// cannot carry (none named) goes as null.
|
|
40
|
+
reportHoldsTo((hold) => channel.post("runner", "webHold", [{ ...hold, until: Number.isFinite(hold.until) ? hold.until : null }]));
|
|
37
41
|
/** A journal's reads for run `runId`, each `call(read, args)` to the runner with the arguments the caller gave but its
|
|
38
42
|
* context (the runner reads with its own: run-child-host.ts readOf). */
|
|
39
43
|
function readerOf(runId, call) {
|
|
@@ -190,6 +194,9 @@ function childDeps(init, store, journal, held) {
|
|
|
190
194
|
...(init.githubMcpOrigin ? { githubMcpOrigin: init.githubMcpOrigin } : {}),
|
|
191
195
|
...(init.composioMcpOrigin ? { composioMcpOrigin: init.composioMcpOrigin } : {}),
|
|
192
196
|
...(init.mcpLoopback ? { mcpLoopback: true, mcpOwn: init.mcpOwn ?? [] } : {}),
|
|
197
|
+
// The run's trace, posted to the runner, which exports it: never one of this process's own (no OTLP setting reaches
|
|
198
|
+
// it, and nothing here flushes).
|
|
199
|
+
tracing: Promise.resolve(init.traced ? postedTracing((method, args) => channel.post("trace", method, args)) : undefined),
|
|
193
200
|
};
|
|
194
201
|
}
|
|
195
202
|
let loop;
|
|
@@ -28,7 +28,7 @@ import { DOCKER_IMAGE_ENV } from "../box-image.js";
|
|
|
28
28
|
import { RunnerLiveRefused, runnerLiveOf } from "../live-reach.js";
|
|
29
29
|
import { bootSealKey } from "../seal-key.js";
|
|
30
30
|
import { SECRET_NAMES } from "../secrets.js";
|
|
31
|
-
import { SEAL_KEY_ENV } from "../tool-keys.js";
|
|
31
|
+
import { notASealKey, SEAL_KEY_ENV, sealKeyOf } from "../tool-keys.js";
|
|
32
32
|
import { LAUNCH_HOOK_SECRET_ENV } from "../trigger-launch-hook.js";
|
|
33
33
|
/** The store.settings key a server keeps the names of its run-facing environment under at each start: `{ v: 1, names }`. */
|
|
34
34
|
export const RUN_ENV_KEY = "server.run_env";
|
|
@@ -173,6 +173,10 @@ export async function checkRunnerEnv(options) {
|
|
|
173
173
|
rows.push({ state: given ? "bad" : "missing", name: SEAL_KEY_ENV, why: error?.message ?? String(error) });
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
+
else if (given && !sealKeyOf(given)) {
|
|
177
|
+
// A key's shape needs no store: one that is not a key is bad here as the start refuses it, by length, never its value.
|
|
178
|
+
rows.push({ state: "bad", name: SEAL_KEY_ENV, why: `set, but ${notASealKey(given)}` });
|
|
179
|
+
}
|
|
176
180
|
else
|
|
177
181
|
rows.push(given ? { state: "skipped", name: SEAL_KEY_ENV, why: "set, and not checked against the store, which did not open" } : { state: "missing", name: SEAL_KEY_ENV, why: "the seal key the store's secrets are sealed under: unset" });
|
|
178
182
|
const names = store ? await serverRunEnv(store) : undefined;
|
package/dist/runner/runner.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BoundTimer } from "./loop.js";
|
|
1
2
|
import { type Claim, type LoopEnd, type LoopFactory } from "./loop-contract.js";
|
|
2
3
|
import { type RunnerStore } from "./store-port.js";
|
|
3
4
|
import { type RunPatch, type RunState } from "../store/store.js";
|
|
@@ -127,10 +128,8 @@ export interface RunnerOptions {
|
|
|
127
128
|
claimGate?: (fresh: boolean) => Promise<string | undefined>;
|
|
128
129
|
/** For tests: the claim deadline's clock (the deadline a claim not renewed in time is lost at, and the time its claimed
|
|
129
130
|
* until is reckoned from). Default: the real one. Nothing else in the runner reads it. */
|
|
130
|
-
clock?: {
|
|
131
|
+
clock?: BoundTimer & {
|
|
131
132
|
now(): number;
|
|
132
|
-
setTimeout(fn: () => void, ms: number): unknown;
|
|
133
|
-
clearTimeout(handle: unknown): void;
|
|
134
133
|
};
|
|
135
134
|
}
|
|
136
135
|
/** A runner's memory budget and its runs' weights, in MiB (RunnerOptions.memory). `weigh` answers each id it is given; an
|