@parcha/agentrun-serve 0.1.0-beta.58 → 0.1.0-beta.60
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 +402 -1
- package/README.md +516 -190
- 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/agent-delete.d.ts +6 -9
- package/dist/agent-delete.js +5 -3
- package/dist/agent-package.js +11 -1
- package/dist/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- package/dist/api-only.d.ts +2 -2
- package/dist/api-only.js +3 -3
- package/dist/archil-routes.d.ts +4 -1
- package/dist/archil-routes.js +15 -12
- package/dist/archil-settings.d.ts +18 -8
- package/dist/archil-settings.js +35 -17
- 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 +7 -0
- package/dist/chatgpt-plan.js +35 -11
- package/dist/claude-login-token.d.ts +20 -11
- package/dist/claude-login-token.js +175 -107
- package/dist/claude-login.d.ts +124 -33
- package/dist/claude-login.js +562 -85
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli-learning/connections.js +1 -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-QnwGVBeU.js +166 -0
- package/dist/console/assets/index-DZi-muIj.js +629 -0
- package/dist/console/assets/share-pz61zIn9.js +6 -0
- package/dist/console/assets/styles-CcceGcu2.js +291 -0
- package/dist/console/assets/styles-fjQBFfMv.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/factory-activity.d.ts +68 -0
- package/dist/factory-activity.js +153 -0
- package/dist/factory-runs.d.ts +11 -0
- package/dist/factory-runs.js +52 -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/filed-tool.d.ts +32 -0
- package/dist/filed-tool.js +122 -0
- 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.d.ts +1 -2
- package/dist/harness-keys.js +10 -8
- 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 +12 -0
- package/dist/harness-table.js +21 -6
- package/dist/harness.js +6 -2
- 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-worker.js +2 -2
- package/dist/import.d.ts +20 -8
- package/dist/import.js +448 -187
- package/dist/key-refusal.d.ts +14 -2
- package/dist/key-refusal.js +97 -33
- package/dist/learn/audit.d.ts +28 -27
- package/dist/learn/audit.js +87 -62
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +35 -43
- package/dist/learn/commit.js +62 -270
- package/dist/learn/compile.d.ts +9 -6
- package/dist/learn/compile.js +51 -28
- package/dist/learn/corrections.js +1 -1
- package/dist/learn/delete.d.ts +5 -12
- package/dist/learn/delete.js +17 -30
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/forget-run.d.ts +16 -0
- package/dist/learn/forget-run.js +53 -0
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning-of.d.ts +0 -4
- package/dist/learn/learning-of.js +0 -5
- package/dist/learn/ledger.d.ts +32 -29
- package/dist/learn/ledger.js +26 -19
- package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
- package/dist/learn/{folder.js → legacy/folder.js} +4 -7
- package/dist/learn/legacy/place.d.ts +16 -0
- package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
- package/dist/learn/legacy/scrub.d.ts +28 -0
- package/dist/learn/legacy/scrub.js +258 -0
- package/dist/learn/promote.d.ts +119 -102
- package/dist/learn/promote.js +119 -262
- package/dist/learn/reset-ledger.d.ts +18 -0
- package/dist/learn/reset-ledger.js +14 -0
- package/dist/learn/rows.d.ts +186 -0
- package/dist/learn/rows.js +376 -0
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learn/workflow-draft.d.ts +4 -1
- package/dist/learn/workflow-draft.js +12 -2
- 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-reset.d.ts +1 -1
- package/dist/learning-reset.js +9 -11
- package/dist/learning-routes.d.ts +60 -81
- package/dist/learning-routes.js +187 -360
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +2 -0
- package/dist/learning.d.ts +18 -24
- package/dist/learning.js +35 -66
- 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 +22 -2
- package/dist/mcp-gateway.js +85 -11
- 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-resources.d.ts +1 -1
- 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/native/discovery.d.ts +6 -0
- package/dist/native/discovery.js +14 -1
- package/dist/native/remote.d.ts +5 -0
- package/dist/native/remote.js +16 -0
- package/dist/native/runtime.js +3 -2
- package/dist/observation/observer.d.ts +6 -6
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +290 -79
- 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 +58 -34
- package/dist/place-offers.js +96 -54
- package/dist/place.d.ts +41 -20
- package/dist/place.js +97 -47
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +3 -2
- package/dist/provider.js +17 -8
- package/dist/purged-workflow.d.ts +0 -33
- package/dist/purged-workflow.js +3 -71
- package/dist/redact/match.d.ts +42 -9
- package/dist/redact/match.js +356 -54
- 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.d.ts +3 -3
- package/dist/run-launch.js +16 -3
- package/dist/run-learning-served.d.ts +3 -3
- package/dist/run-learning-served.js +1 -1
- package/dist/run-listing.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/run-timeline-served.js +8 -5
- package/dist/runnable.js +26 -9
- 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 +73 -46
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +10 -9
- package/dist/runner/audit.js +64 -67
- 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 +87 -58
- package/dist/runner/compare-end.d.ts +2 -3
- package/dist/runner/compare-end.js +30 -11
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/disk-free.d.ts +15 -4
- package/dist/runner/disk-free.js +25 -7
- package/dist/runner/feedback-round.d.ts +1 -1
- package/dist/runner/feedback-round.js +2 -2
- package/dist/runner/harness-loops.js +3 -4
- package/dist/runner/held.d.ts +5 -12
- package/dist/runner/held.js +0 -25
- package/dist/runner/journal-kinds.d.ts +8 -2
- package/dist/runner/journal-kinds.js +23 -5
- package/dist/runner/learned-first.d.ts +0 -2
- package/dist/runner/learned-first.js +23 -7
- package/dist/runner/learning-end.d.ts +14 -24
- package/dist/runner/learning-end.js +52 -94
- package/dist/runner/learning-seed.d.ts +13 -16
- package/dist/runner/learning-seed.js +13 -23
- 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 +13 -12
- package/dist/runner/mcp-claim.js +21 -5
- package/dist/runner/mcp-run.d.ts +4 -0
- package/dist/runner/mcp-run.js +2 -0
- 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 +12 -11
- package/dist/runner/presence.d.ts +1 -4
- package/dist/runner/presence.js +6 -8
- package/dist/runner/promotion.d.ts +39 -36
- package/dist/runner/promotion.js +168 -112
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/reflect-hook.d.ts +2 -2
- package/dist/runner/reflect-hook.js +4 -1
- 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 +21 -14
- package/dist/runner/run-child-host.js +187 -141
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +3 -4
- package/dist/runner/runner.js +13 -9
- package/dist/runner/sdk-loop.js +10 -12
- 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/check.d.ts +1 -4
- package/dist/sdk/check.js +2 -3
- package/dist/sdk/runs.d.ts +26 -7
- package/dist/sdk/runs.js +194 -78
- 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 +55 -9
- package/dist/secrets.js +345 -21
- package/dist/server-fs.d.ts +1 -1
- package/dist/server-fs.js +1 -1
- package/dist/server-keys.d.ts +10 -3
- package/dist/server-keys.js +16 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +30 -18
- package/dist/server.js +520 -238
- 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/source-sync/auxiliary.js +2 -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/migrations/0032_learning_rows.sql +65 -0
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +60 -11
- package/dist/store/schema.js +147 -17
- package/dist/store/seal.d.ts +4 -1
- package/dist/store/sqlite/learning-rows.d.ts +23 -0
- package/dist/store/sqlite/learning-rows.js +559 -0
- 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 +9 -0
- package/dist/store/sqlite/store.js +194 -46
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +286 -38
- package/dist/store/store.js +27 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/journal.d.ts +33 -3
- package/dist/store-reads/journal.js +99 -4
- package/dist/store-reads/learning.d.ts +50 -45
- package/dist/store-reads/learning.js +153 -116
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.d.ts +24 -2
- package/dist/store-view.js +49 -17
- 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/templates.d.ts +10 -2
- package/dist/templates.js +31 -4
- 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 +54 -13
- package/dist/tool-plane.js +103 -32
- 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 +34 -0
- package/dist/web-holds.js +89 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +76 -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/archil-exec.js +1 -1
- package/dist/workspace/archil.d.ts +1 -1
- package/dist/workspace/archil.js +1 -1
- 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 +38 -18
- 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 +19 -4
- package/dist/workspace/computer-providers.js +40 -6
- package/dist/workspace/index.d.ts +2 -3
- package/dist/workspace/index.js +2 -3
- 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/paths.d.ts +0 -4
- package/dist/workspace/paths.js +0 -6
- 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 +7 -1
- package/dist/workspace/workspace.js +1 -1
- package/package.json +13 -14
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +22 -6
- package/templates/TOOLS.md +46 -0
- 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
- package/dist/workspace/learning-workspace.d.ts +0 -24
- /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
|
@@ -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,25 +36,26 @@ 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";
|
|
42
43
|
import { openRunMcpAuth, sealRunMcpAuth } from "../store/seal.js";
|
|
43
44
|
import { runZone } from "../environment.js";
|
|
44
45
|
import { shadowRunId } from "../learn/audit.js";
|
|
45
|
-
import { LEARNING_SCRIPT, learningWorkspace } from "../learn/folder.js";
|
|
46
46
|
import { agreeOnOf } from "../learning-setting.js";
|
|
47
|
-
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
47
|
+
import { openedAtUse, openRunWorkspace } from "../workspace/run-workspace.js";
|
|
48
48
|
import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
49
49
|
import { agentDirName, recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
|
|
50
50
|
import { keptKeyOf } from "../workspace/computer-kept.js";
|
|
51
|
-
import {
|
|
51
|
+
import { waitEndedKey } from "../browser-wait-ended.js";
|
|
52
|
+
import { browserHoldKey } from "../browser-hold.js";
|
|
53
|
+
import { claimModelKey, claimSecrets, claimSpendOff, hostDecisionKeys, learnedDecisionKeys, openRunModelKey, savedModelKeys, sendsNoModelKey, serverKeyless, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
|
|
52
54
|
import { githubAppAccess } from "./github-app.js";
|
|
53
55
|
import { githubPullOf, githubTargetOf } from "../github.js";
|
|
54
56
|
import { isObject } from "../validate.js";
|
|
55
57
|
import { liveForRun, runnerLiveOf } from "../live-reach.js";
|
|
56
|
-
import {
|
|
58
|
+
import { secretsShown } from "../learning.js";
|
|
57
59
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
58
60
|
import { messageText } from "../run-manifest.js";
|
|
59
61
|
import { filesToCopy, placeRunInputs } from "../uploads.js";
|
|
@@ -67,7 +69,9 @@ import { createDispatchLoop } from "./dispatch.js";
|
|
|
67
69
|
import { refuseRecipeTriggerRun, resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
|
|
68
70
|
import { isWorkflowRevision } from "./workflow-loop.js";
|
|
69
71
|
import { loginForRun } from "../claude-login.js";
|
|
70
|
-
import {
|
|
72
|
+
import { harnessOfBody } from "../harness.js";
|
|
73
|
+
import { agentRunLogin, LOGIN_CHANGED_SINCE_CLAIM, loginRunnerInProcess, loginTokensFor } from "../claude-login-token.js";
|
|
74
|
+
import { logLine } from "../print.js";
|
|
71
75
|
import { heardComputerHold } from "./computer-journal.js";
|
|
72
76
|
import { ClaimRefused } from "./loop-contract.js";
|
|
73
77
|
import { Channel, ChannelClosed } from "./run-channel.js";
|
|
@@ -75,12 +79,13 @@ import { registerRunErrors } from "./run-errors.js";
|
|
|
75
79
|
import { exposeSaveSlots } from "./save-slots.js";
|
|
76
80
|
import { runBigWrites } from "./big-writes.js";
|
|
77
81
|
import { SERVER_SLOTS } from "../web-save.js";
|
|
82
|
+
import { holdsEnv, noteHold } from "../web-holds.js";
|
|
78
83
|
import { launchOnItsDisk, readLaunchBody } from "../run-launch.js";
|
|
79
84
|
import { routedSubagentTiers, SUBAGENT_TOOL } from "./subagent.js";
|
|
80
85
|
import { sourceSyncOf } from "../source-sync/types.js";
|
|
81
86
|
import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
|
|
82
87
|
import { beginSourceIO } from "../source-sync/io.js";
|
|
83
|
-
import { runTools } from "../workspace/run-tools.js";
|
|
88
|
+
import { attachedIn, runTools } from "../workspace/run-tools.js";
|
|
84
89
|
import { ProjectHostGate } from "./project-host.js";
|
|
85
90
|
import { runProjectCheckpoint } from "./project-checkpoint.js";
|
|
86
91
|
/** The image's helper that starts a run's process as its slot's uid (packages/serve/runas). */
|
|
@@ -392,20 +397,58 @@ const always = () => true;
|
|
|
392
397
|
/** The settings a run's process may read, the server's own configuration its loop and tools read: its tool settings,
|
|
393
398
|
* its Archil settings (no credential), its MCP hosts and server names, its Claude-login mode and its approvers. */
|
|
394
399
|
const SHARED_SETTINGS = new Set(["tool-settings", "archil", "mcp.private_oauth_hosts", "mcp.server_own", "claude_login", "approvers"]);
|
|
400
|
+
/** The rows of the claim's own run that its process writes, and removes, itself, each with its string fields (beside the
|
|
401
|
+
* claim's epoch): its browser's wait that ended (browser-wait-ended.ts) and its browser's take (browser-hold.ts), each
|
|
402
|
+
* the run's process's report of its own browser to the server's reads. No other row is its to write. */
|
|
403
|
+
const ownWrittenSettings = (bound) => new Map([
|
|
404
|
+
[waitEndedKey(bound.claim.runId), ["at", "why"]],
|
|
405
|
+
[browserHoldKey(bound.claim.runId), ["session", "at"]],
|
|
406
|
+
]);
|
|
407
|
+
/** 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
|
|
408
|
+
* over, and the server parses the row on every read of the run and every Screen poll. */
|
|
409
|
+
const OWN_ROW_MAX_BYTES = 4096;
|
|
395
410
|
/** 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. */
|
|
411
|
+
* computer, browser wait and browser take, and its agent's Archil disk. Every other row (another run's or agent's)
|
|
412
|
+
* is not its to read. */
|
|
398
413
|
const ownSettings = (bound) => new Set([
|
|
399
414
|
`archil.run.${bound.claim.runId}`,
|
|
400
415
|
`sdk-run:${bound.claim.runId}`,
|
|
401
416
|
keptKeyOf(bound.claim.runId),
|
|
402
|
-
|
|
417
|
+
...ownWrittenSettings(bound).keys(),
|
|
403
418
|
`archil.agent.${bound.agentId}`,
|
|
404
|
-
`learning.promotions.${bound.agentId}`,
|
|
405
419
|
]);
|
|
406
420
|
/** Whether a run's process may read setting `key`. */
|
|
407
421
|
export const settingReadable = (key, bound) => typeof key === "string" && (SHARED_SETTINGS.has(key) || ownSettings(bound).has(key));
|
|
408
422
|
const readableSetting = (args, bound) => settingReadable(args[0], bound);
|
|
423
|
+
/** Whether a run's process may remove setting `key`: only its own run's browser rows (ownWrittenSettings), and only one no
|
|
424
|
+
* later claim wrote (removeOwnRow, which reads the row). */
|
|
425
|
+
const removableSetting = (args, bound) => typeof args[0] === "string" && ownWrittenSettings(bound).has(args[0]);
|
|
426
|
+
/** The remove of one of the claim's own browser rows (removableSetting): a row a later claim of the run wrote stays, as
|
|
427
|
+
* a write takes only the claim's own epoch (writableSetting), so a claim still closing never clears the take or the
|
|
428
|
+
* ended wait of the claim that holds the run now. The row goes only while it is the one read (Settings.removeIf), so a
|
|
429
|
+
* later claim's write that lands between the read and the remove stays too. A key with no row is left as it is. */
|
|
430
|
+
async function removeOwnRow(settings, key, bound, log) {
|
|
431
|
+
const row = await settings.get(key);
|
|
432
|
+
if (row === undefined)
|
|
433
|
+
return;
|
|
434
|
+
const epoch = typeof row === "object" && row !== null ? row.epoch : undefined;
|
|
435
|
+
if (typeof epoch === "number" && epoch > bound.claim.epoch) {
|
|
436
|
+
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`);
|
|
437
|
+
throw new ClaimRefused("a run's process may not call the store's settings.remove of a row a later claim wrote");
|
|
438
|
+
}
|
|
439
|
+
await settings.removeIf(key, row);
|
|
440
|
+
}
|
|
441
|
+
/** Whether a run's process may write `value` to setting `key`: one of its own run's browser rows, with that row's fields
|
|
442
|
+
* 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
|
|
443
|
+
* every clear of this claim (browser-hold.ts), so a later claim would read a take nobody holds. */
|
|
444
|
+
const writableSetting = ([key, value], bound) => {
|
|
445
|
+
const fields = typeof key === "string" ? ownWrittenSettings(bound).get(key) : undefined;
|
|
446
|
+
if (!fields || typeof value !== "object" || value === null || Array.isArray(value))
|
|
447
|
+
return false;
|
|
448
|
+
const row = value;
|
|
449
|
+
return Object.keys(row).length === fields.length + 1 && row.epoch === bound.claim.epoch && fields.every((field) => typeof row[field] === "string")
|
|
450
|
+
&& Buffer.byteLength(JSON.stringify(row)) <= OWN_ROW_MAX_BYTES;
|
|
451
|
+
};
|
|
409
452
|
/** 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
453
|
* refusal is said on the runner's log. Reads of the claim's run, its launch, its commands and its agent's revisions;
|
|
411
454
|
* 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 +471,8 @@ const STORE_CALLS = new Map([
|
|
|
428
471
|
["agents.revision", always],
|
|
429
472
|
["agents.revisions", ownAgent],
|
|
430
473
|
["settings.get", readableSetting],
|
|
474
|
+
["settings.put", writableSetting],
|
|
475
|
+
["settings.remove", removableSetting],
|
|
431
476
|
// Its rows filtered to the readable ones (storeCall).
|
|
432
477
|
["settings.all", always],
|
|
433
478
|
["mcp.pin", ownRun],
|
|
@@ -437,6 +482,8 @@ const STORE_CALLS = new Map([
|
|
|
437
482
|
["learning.proposals", ownAgent],
|
|
438
483
|
["learning.list", ownAgent],
|
|
439
484
|
["learning.get", always],
|
|
485
|
+
// Its agent's learning at a save (learning-seed.ts layLearningSeed): read only, its agent's alone.
|
|
486
|
+
["learning.itemsAt", ownAgent],
|
|
440
487
|
["computerLedger.book", ownClaim],
|
|
441
488
|
["computerLedger.list", ownRun],
|
|
442
489
|
["live.put", ownClaim],
|
|
@@ -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,19 +677,15 @@ 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
|
-
const learningFolder = async () => {
|
|
634
|
-
const made = await archilOf();
|
|
635
|
-
return made === undefined ? learningFolderOf(deps.data, run.agentId) : learningWorkspace({ mode: "archil", agentId: run.agentId, archil: made });
|
|
636
|
-
};
|
|
637
|
-
/** The learning folder's reader, made once the claim's Archil claim is known (learnedFirst's folder is synchronous). */
|
|
638
|
-
const folderNow = async () => {
|
|
639
|
-
const made = await archilOf();
|
|
640
|
-
return () => (made === undefined ? learningFolderOf(deps.data, run.agentId) : learningWorkspace({ mode: "archil", agentId: run.agentId, archil: made }));
|
|
641
|
-
};
|
|
642
689
|
/** What a learned workflow must never hold, as this runner sees it: every secret it holds (learning-seed.ts). */
|
|
643
690
|
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(store, sealKey, deps.data)), { local: true });
|
|
644
691
|
/** The workflows the claim's learned_workflow tool runs, as this runner chose them (held.learnedFirst): what scopes the
|
|
@@ -714,21 +761,35 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
714
761
|
// or refused); never its folder or its refresh token. Each token is carried into the runner's redactor for this run
|
|
715
762
|
// (redact.ts carry) before it is handed, a renewed one too: model text that repeats it is cut from the run's journal
|
|
716
763
|
// 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
|
-
//
|
|
764
|
+
// This answer is the one decision whether the run goes on the login: none, it does not. Its claim read the setting
|
|
765
|
+
// (staysInRunner); a claim that read it off is never put on it, whatever the setting says now. A claim that read it on
|
|
766
|
+
// has it read again here, at the start, with the claim's settings, data folder, harness and place. Its environment is
|
|
767
|
+
// the claim's (the process's, when the runner was given none) with a saved gateway laid over it (withSavedGatewayDeps),
|
|
768
|
+
// not always the very one the claim read with; that
|
|
769
|
+
// difference can only refuse the start, never hand another folder, since the login is handed only when both reads name
|
|
770
|
+
// the same folder: a turn-off, or a move to another folder,
|
|
771
|
+
// between the claim and the start refuses the start in LOGIN_CHANGED_SINCE_CLAIM's fixed words (no folder in them),
|
|
772
|
+
// 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
|
|
773
|
+
// 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,
|
|
774
|
+
// were each decided at the claim (staysInRunner: no login read for the one, LOGIN_MACHINE_NEEDS_SERVER_USER for the
|
|
775
|
+
// other), so neither reaches here on a login. The process reads no setting or machine id.
|
|
776
|
+
// None for a run that sends no model key (keyless: a held run, any run on a --faux runner, a faux-pinned one), whatever
|
|
777
|
+
// its claim read: the login is a model credential like any key.
|
|
719
778
|
claudeLogin: async () => {
|
|
720
|
-
if (
|
|
779
|
+
if (keyless)
|
|
721
780
|
return undefined;
|
|
722
|
-
const
|
|
723
|
-
const at = await loginForRun(store.settings, deps.data, deps.env ?? {}, harness, launch.place);
|
|
781
|
+
const at = reads.login;
|
|
724
782
|
if (!at)
|
|
725
783
|
return undefined;
|
|
726
|
-
|
|
727
|
-
|
|
784
|
+
const now = await loginForRun(store.settings, deps.data, deps.env ?? {}, harnessOfBody(launch), launch.place);
|
|
785
|
+
if (now?.dir !== at.dir)
|
|
786
|
+
throw new ClaimRefused(LOGIN_CHANGED_SINCE_CLAIM);
|
|
728
787
|
const carry = cut.carry;
|
|
729
788
|
if (!carry)
|
|
730
789
|
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
|
-
|
|
790
|
+
// Each renewal's outcome on the runner's log, in the server's line (print.ts logLine) under event claude_login:
|
|
791
|
+
// fixed words, a status and an OAuth error code, never a token.
|
|
792
|
+
const tokens = loginTokensFor(at, (fields) => log(logLine("claude_login", fields)));
|
|
732
793
|
return {
|
|
733
794
|
token: async () => {
|
|
734
795
|
const token = await tokens.token();
|
|
@@ -744,10 +805,27 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
744
805
|
return runSignIn(store, sealKey, claim, String(resolution), { vendors: vendorsOver(() => claimed, vendorFetch), log });
|
|
745
806
|
},
|
|
746
807
|
verifySignIn: (kept, at) => verifyRunSignIn(store, sealKey, claim, kept, Number(at)),
|
|
808
|
+
// None for a held run its model kept from running: nothing can call it, so no credential of it is opened.
|
|
747
809
|
mcp: (ask) => projectCall(async () => {
|
|
810
|
+
if (modelRefused)
|
|
811
|
+
return undefined;
|
|
748
812
|
const reach = await mcpReachOf(deps);
|
|
749
813
|
const harness = { commit: (change) => change({ appendEntry: async (_conversation, entry) => void (await ask.appendRoot(dataOnly(entry))) }) };
|
|
750
|
-
|
|
814
|
+
// 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
|
|
815
|
+
// it is the run's disk: through the computer this claim made once it mounts the folder (mountedFolder, the computer
|
|
816
|
+
// answer's), since the mount holds the disk's write delegation; over the disk's file API when no computer mounts it.
|
|
817
|
+
// That Workspace is opened at the first answer that files something, not at the claim: a claim whose MCP files
|
|
818
|
+
// nothing opens none (an open lists the run's folder, and makes it when it is missing). It only writes files over the
|
|
819
|
+
// 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
|
|
820
|
+
// opens mid-run, beside the archil answer's Workspace, whose commands may still be reading their spill files there.
|
|
821
|
+
// Opened once, and let go at the claim's release; an open that failed is tried again at the next answer. Its release is
|
|
822
|
+
// registered here, before any open, so an open still running at the release is ended too, and a filing after it opens
|
|
823
|
+
// nothing (openedAtUse). work() is read only when a call's answer files something (mcp-gateway.ts textOf, fileResults).
|
|
824
|
+
const disk = await archilOf();
|
|
825
|
+
const overTheDisk = disk === undefined ? undefined : openedAtUse(() => openRunWorkspace({ mode: 2, agentId: run.agentId, runId: claim.runId, archil: disk, sweep: false, log }));
|
|
826
|
+
if (overTheDisk)
|
|
827
|
+
releases.push(() => overTheDisk.end());
|
|
828
|
+
const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, toolSettings: revision.body.toolSettings, 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
829
|
if (!made)
|
|
752
830
|
return undefined;
|
|
753
831
|
releases.push(() => made.release());
|
|
@@ -788,10 +866,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
788
866
|
// that tier's model's key alone (through a gateway, the gateway's), none when the revision names agree_on (no
|
|
789
867
|
// grader). A learning run's grade and an SDK run's compile turn stay in the runner (runsInRunner): their process
|
|
790
868
|
// 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 = !
|
|
869
|
+
// keys are not its to spend, whatever its process asks; nor for a run that sends no model key (keyless: a held run,
|
|
870
|
+
// which routes no model and grades nothing, or a faux one, whose model sends none).
|
|
871
|
+
const subagent = !keyless && revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL);
|
|
872
|
+
const grades = !keyless && (launch.replay !== undefined || launch.audit !== undefined) && !agreeOnOf(revision.body.learning)?.length;
|
|
795
873
|
if (!subagent && !grades)
|
|
796
874
|
return {};
|
|
797
875
|
const { tiers, refs } = routedSubagentTiers(revision.body, keys.env ?? {});
|
|
@@ -801,9 +879,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
801
879
|
tierModelKeys: async (tiers) => {
|
|
802
880
|
// The tiers the claim's learned workflows name (learnedTiers), as this runner chose them (learnedFirst below): a
|
|
803
881
|
// 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)
|
|
882
|
+
// makes none: its learnedFirst is refused), nor to a run that sends no model key (keyless: a faux one's tiers run on
|
|
883
|
+
// the faux model).
|
|
805
884
|
const asked = new Set(tiers.filter((tier) => typeof tier === "string"));
|
|
806
|
-
const named = !
|
|
885
|
+
const named = !keyless && learnsWorkflows(revision.kind, learnedFlows) ? learnedTiers(learnedFlows).filter((tier) => asked.has(tier)) : [];
|
|
807
886
|
const keyed = await runKeyed();
|
|
808
887
|
const got = keyed ? {} : await tierModelKeys(keys, named);
|
|
809
888
|
const plan = planOf(got);
|
|
@@ -825,9 +904,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
825
904
|
// harness is a plan-billed recipe on this runner's table, and never another harness's. Opened for the recipe file
|
|
826
905
|
// the process loaded (`digest`), never the one this runner's table read at its start: a file swapped for another
|
|
827
906
|
// vendor's under the same id since then runs its own binary, and a key bound to the first file never opens for it.
|
|
907
|
+
// None for a held run its model kept from running: its agent never starts.
|
|
828
908
|
harnessKeys: async (digest) => {
|
|
829
909
|
const harness = launch.harness ?? revision.body.harness;
|
|
830
|
-
const recipe = harness === undefined ? undefined : planRecipeOf(deps.env, harness);
|
|
910
|
+
const recipe = harness === undefined || modelRefused ? undefined : planRecipeOf(deps.env, harness);
|
|
831
911
|
return recipe?.keys.length && typeof digest === "string" ? openHarnessKeys(store, sealKey, { ...recipe, digest }) : {};
|
|
832
912
|
},
|
|
833
913
|
liveViewerPut: (handover) => putLiveViewer(store, sealKey, claim, handover),
|
|
@@ -845,7 +925,6 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
845
925
|
signInForgotten: (resolution) => forgottenSignIns(store, sealKey, run.agentId, String(resolution)),
|
|
846
926
|
emailAccount: async () => (grantsEmail(granted) ? openAccount(store, sealKey) : undefined),
|
|
847
927
|
calendar: async () => (granted.includes(CALENDAR_EVENTS) ? openCalendar(store, sealKey) : undefined),
|
|
848
|
-
learning: async (method, args) => learningCall(await learningFolder(), method, args),
|
|
849
928
|
install: async (name, signal) => {
|
|
850
929
|
const harness = launch.harness ?? revision.body.harness;
|
|
851
930
|
const entry = harness === undefined ? undefined : harnessOf(deps.env, harness);
|
|
@@ -870,13 +949,21 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
870
949
|
hadComputer: async () => (await ask.hadComputer()) === true,
|
|
871
950
|
...(typeof ask.turnedOff === "string" ? { turnedOff: ask.turnedOff } : {}),
|
|
872
951
|
...(ask.signal instanceof AbortSignal ? { signal: ask.signal } : {}),
|
|
873
|
-
...(made ? { revokeMount: () => made.revoke(), inheritMount: () => made.inherit() } : {}),
|
|
952
|
+
...(made ? { revokeMount: () => made.revoke(), inheritMount: () => made.inherit(), mountDisk: () => made.disk.id } : {}),
|
|
874
953
|
...(typeof ask.onImageWait === "function" ? { onImageWait: ask.onImageWait } : {}),
|
|
875
954
|
...(typeof ask.onStarting === "function" ? { onStarting: ask.onStarting } : {}),
|
|
876
955
|
...(typeof ask.onConnected === "function" ? { onConnected: ask.onConnected } : {}),
|
|
877
956
|
...(typeof ask.onComputerNote === "function" ? { onComputerNote: ask.onComputerNote } : {}),
|
|
878
957
|
});
|
|
879
958
|
releases.push(() => ws.end());
|
|
959
|
+
// A Mode 2 computer that mounts the run's folder holds the disk's write delegation: what the claim's MCP files then
|
|
960
|
+
// goes through it, attached here as the run's process attaches it. A failed attach leaves the MCP on the disk's file
|
|
961
|
+
// API, which says in its answer that the file could not be saved.
|
|
962
|
+
if (mode === 2)
|
|
963
|
+
mountedFolder = await attachedIn(ws.workspace, got?.computer).catch((error) => {
|
|
964
|
+
log(`the run's folder could not be attached for the MCP's files: ${error?.message ?? String(error)}`);
|
|
965
|
+
return undefined;
|
|
966
|
+
});
|
|
880
967
|
// The computer let go by this runner at the claim's release too, before its folder: a process that crashed or broke
|
|
881
968
|
// its channel never calls its release. Idempotent with the process's own release and with its park (which keeps it).
|
|
882
969
|
const claimed = got;
|
|
@@ -889,7 +976,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
889
976
|
const { syncProject: _sync, ...exposed } = got;
|
|
890
977
|
return { ...exposed, ...(exposed.computer ? { computer: projectGate.capability(exposed.computer) } : {}),
|
|
891
978
|
release: (...args) => cleanProject(() => exposed.release(...args)),
|
|
892
|
-
...(exposed.park ? { park: (...args) => cleanProject(() => exposed.park(...args)) } : {})
|
|
979
|
+
...(exposed.park ? { park: (...args) => cleanProject(() => exposed.park(...args)) } : {}),
|
|
980
|
+
// The park's keep written ahead of it lands the folder's delta first, so it waits for the project's work as the
|
|
981
|
+
// park does.
|
|
982
|
+
...(exposed.keepRow ? { keepRow: () => cleanProject(() => exposed.keepRow()) } : {}) };
|
|
893
983
|
}
|
|
894
984
|
return got;
|
|
895
985
|
}),
|
|
@@ -915,14 +1005,13 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
915
1005
|
// compares its answer with the other one through its grader, handed in by the run's process (runner/compare-end.ts).
|
|
916
1006
|
// This runner reads both answers and the learning ledger, which no run's process may.
|
|
917
1007
|
if (launch.replay || launch.audit) {
|
|
918
|
-
const compare = compareEndOfRun(launch, { store,
|
|
1008
|
+
const compare = compareEndOfRun(launch, { store, log, redact: cut });
|
|
919
1009
|
const grade = input.grade;
|
|
920
1010
|
const rows = compare && grade && typeof input.grader === "string"
|
|
921
1011
|
? await compare({ runId: claim.runId, agentId: run.agentId, claim, outcome: input.outcome === "failed" ? "failed" : "completed", ...(input.cut === undefined ? {} : { cut: "faulted" }), grader: input.grader, grade: (request) => grade(request), ask: input.ask, signal: input.signal })
|
|
922
1012
|
: undefined;
|
|
923
1013
|
return rows?.compared ? { also: [], compared: dataOnly(rows.compared) } : undefined;
|
|
924
1014
|
}
|
|
925
|
-
const made = await archilOf();
|
|
926
1015
|
// The audit's spend, skipped as the run's spec skips it (claim-secrets.ts claimSpendOff): over the claim's own key.
|
|
927
1016
|
const spendOff = await claimSpendOff(keys, await claimModelKey(keys, claim.runId));
|
|
928
1017
|
// The audit's start after the step (audit.ts withAudit) is this runner's too: it reads the run's journal and writes
|
|
@@ -936,8 +1025,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
936
1025
|
stored: () => storeSecrets(store, sealKey, deps.data),
|
|
937
1026
|
log,
|
|
938
1027
|
decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys(keys, DECISION_PROVIDER_KEYS)) }),
|
|
939
|
-
|
|
940
|
-
}), { store, agentId: run.agentId, revisionId: run.revisionId, context: BACKGROUND_CONTEXT, folder: await folderNow(), shown, log, sealKey, spendOff, launch, redact: cut, admitAuxiliary });
|
|
1028
|
+
}), { store, agentId: run.agentId, revisionId: run.revisionId, context: BACKGROUND_CONTEXT, shown, log, sealKey, spendOff, launch, redact: cut, admitAuxiliary });
|
|
941
1029
|
if (!step)
|
|
942
1030
|
return undefined;
|
|
943
1031
|
// keptOf is the run's process's, asked over the channel: read once, for the round learningEndOfRun reads (the
|
|
@@ -965,11 +1053,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
965
1053
|
// the process's lay chose them: none where its lay laid none (`laid` false: a read that failed, a seed with no
|
|
966
1054
|
// workflows).
|
|
967
1055
|
const start = learningStartOf(launch);
|
|
968
|
-
const
|
|
969
|
-
const laid = ask?.laid === true && start && !seedFailed(start) && !start.noWorkflows ? await workflowsAt({ folder, store, shown }, start.seed).catch(() => []) : [];
|
|
1056
|
+
const laid = ask?.laid === true && start && !seedFailed(start) && !start.noWorkflows ? await workflowsAt({ store, agentId: run.agentId, shown }, start.seed).catch(() => []) : [];
|
|
970
1057
|
const spendOff = await claimSpendOff(keys, await claimModelKey(keys, claim.runId));
|
|
971
1058
|
const outputSchema = revision.body.outputSchema;
|
|
972
|
-
const got = await learnedFirst({ store, sealKey, agentId: run.agentId, runId: claim.runId, revisionId: run.revisionId, kind: revision.kind, ...(outputSchema !== undefined ? { outputSchema } : {}), launch, context: BACKGROUND_CONTEXT, log,
|
|
1059
|
+
const got = await learnedFirst({ store, sealKey, agentId: run.agentId, runId: claim.runId, revisionId: run.revisionId, kind: revision.kind, ...(outputSchema !== undefined ? { outputSchema } : {}), launch, context: BACKGROUND_CONTEXT, log, shown, spendOff, admitAuxiliary }, laid);
|
|
973
1060
|
learnedFlows = got.workflows;
|
|
974
1061
|
return cutDeep(dataOnly(got), cut);
|
|
975
1062
|
})()),
|
|
@@ -1018,54 +1105,11 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
1018
1105
|
}
|
|
1019
1106
|
/** `env`'s string values. */
|
|
1020
1107
|
const stringsOf = (env) => Object.fromEntries(Object.getOwnPropertyNames(env).flatMap((name) => (typeof env[name] === "string" ? [[name, env[name]]] : [])));
|
|
1021
|
-
/** The learning-script ops a run's process may run (learn/folder.ts): its reads alone. The folder's writers (the
|
|
1022
|
-
* end-of-run step's check, the learning run's merge, a repair) are the runner's. */
|
|
1023
|
-
const LEARNING_OPS = new Set(["read", "show", "has", "log", "diff", "status"]);
|
|
1024
|
-
/** A call of the learning folder a run's process asks (Held.learning), on the runner's own Workspace of the claim's
|
|
1025
|
-
* agent's folder: reads pass, and the learning script runs its reads, with the script's own environment (the script
|
|
1026
|
-
* laid by the runner as the folder's own); nothing the process asks writes there. */
|
|
1027
|
-
export async function learningCall(folder, method, args) {
|
|
1028
|
-
const ws = folder.workspace;
|
|
1029
|
-
try {
|
|
1030
|
-
switch (method) {
|
|
1031
|
-
case "read":
|
|
1032
|
-
return await ws.read(String(args[0]), args[1]);
|
|
1033
|
-
case "stat":
|
|
1034
|
-
return dataOnly(await ws.stat(String(args[0])));
|
|
1035
|
-
case "list":
|
|
1036
|
-
return dataOnly(await ws.list(String(args[0])));
|
|
1037
|
-
case "grep":
|
|
1038
|
-
return dataOnly(await ws.grep(String(args[0]), args[1]));
|
|
1039
|
-
case "write":
|
|
1040
|
-
// The learning script laid as learn/folder.ts lays it (ensureScript, before a script run): the runner's own text.
|
|
1041
|
-
if (args[0] === LEARNING_SCRIPT.file())
|
|
1042
|
-
return await LEARNING_SCRIPT.ensure(ws);
|
|
1043
|
-
throw new ClaimRefused(`a run's process may not write ${JSON.stringify(args[0])} in its learning folder`);
|
|
1044
|
-
case "append":
|
|
1045
|
-
case "remove":
|
|
1046
|
-
case "mkdir":
|
|
1047
|
-
throw new ClaimRefused(`a run's process may not ${method} ${JSON.stringify(args[0])} in its learning folder`);
|
|
1048
|
-
case "exec": {
|
|
1049
|
-
const argv = args[0];
|
|
1050
|
-
const options = (args[1] ?? {});
|
|
1051
|
-
if (!Array.isArray(argv) || argv[0] !== "sh" || argv[1] !== LEARNING_SCRIPT.file() || !LEARNING_OPS.has(String(argv[2])) || !argv.every((part) => typeof part === "string"))
|
|
1052
|
-
throw new ClaimRefused("a run's process runs no program in its learning folder but its learning script");
|
|
1053
|
-
await LEARNING_SCRIPT.ensure(ws);
|
|
1054
|
-
return dataOnly(await ws.exec(argv, { env: LEARNING_SCRIPT.env(), timeoutMs: LEARNING_SCRIPT.timeoutMs(), ...(options.stdin instanceof Uint8Array ? { stdin: options.stdin } : {}) }));
|
|
1055
|
-
}
|
|
1056
|
-
default:
|
|
1057
|
-
throw new ClaimRefused(`a run's learning folder has no ${method} in its process`);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
finally {
|
|
1061
|
-
await folder.end().catch(() => undefined);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
1108
|
/** The node and module a run's process starts with. */
|
|
1065
1109
|
export const childArgv = () => [process.execPath, "--import", new URL("../secrets.js", import.meta.url).pathname, new URL("./run-child.js", import.meta.url).pathname];
|
|
1066
1110
|
/** Whether a run stays in its runner's process rather than one of its own: one that runs no agent's code or tool here.
|
|
1067
1111
|
* A built-in learning run (its launch names harness "learning"): its grade is one ask through the runner's model route,
|
|
1068
|
-
* and its one write is the merge into the agent's learning
|
|
1112
|
+
* and its one write is the merge into the agent's learning, which no run's process may write. An SDK backend
|
|
1069
1113
|
* run (launch.sdk): its agent runs in the caller's application, and its loop here reads the evidence it posts and closes
|
|
1070
1114
|
* its inbox. A CLI capture (launch.cli_learning) likewise only receives source evidence and serves owner corrections.
|
|
1071
1115
|
* A native run (launch.native): its agent is the source machine's own sign-in, reached through the server's
|
|
@@ -1081,16 +1125,6 @@ export const loginRunnerInProcessWords = (other) => `This runner runs each run a
|
|
|
1081
1125
|
/** 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
1126
|
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
1127
|
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
1128
|
export async function staysInRunner(deps, harness, launch, runId, isolation) {
|
|
1095
1129
|
// 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
1130
|
// 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 +1134,45 @@ export async function staysInRunner(deps, harness, launch, runId, isolation) {
|
|
|
1100
1134
|
throw new ClaimRefused(RECIPE_NEEDS_SERVER_USER);
|
|
1101
1135
|
await refuseRecipeTriggerRun(deps, harness, launch);
|
|
1102
1136
|
if (runsInRunner(harness, launch))
|
|
1103
|
-
return
|
|
1137
|
+
return STAYS;
|
|
1104
1138
|
if (launch.documents !== undefined) {
|
|
1105
1139
|
const run = await deps.store.runs.get(runId);
|
|
1106
1140
|
const revision = run ? await deps.store.agents.revision(run.revisionId) : undefined;
|
|
1107
1141
|
if (revision && isWorkflowRevision(revision))
|
|
1108
|
-
return
|
|
1142
|
+
return STAYS;
|
|
1109
1143
|
}
|
|
1110
1144
|
const login = await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, harness, launch.place);
|
|
1111
1145
|
if (login === undefined)
|
|
1112
|
-
return
|
|
1146
|
+
return OFF_LOGIN;
|
|
1113
1147
|
if ((await openRunModelKey({ store: deps.store, sealKey: deps.sealKey }, runId)) !== undefined)
|
|
1114
|
-
return
|
|
1148
|
+
return OFF_LOGIN;
|
|
1115
1149
|
if (isolation.kind !== "uid")
|
|
1116
|
-
return
|
|
1150
|
+
return STAYS;
|
|
1117
1151
|
if (!agentRunLogin(login, deps.data))
|
|
1118
1152
|
throw new ClaimRefused(LOGIN_MACHINE_NEEDS_SERVER_USER);
|
|
1119
1153
|
const other = await loginRunnerInProcess(deps.data, deps.store.runners);
|
|
1120
1154
|
if (other !== undefined)
|
|
1121
1155
|
throw new ClaimRefused(loginRunnerInProcessWords(other));
|
|
1122
|
-
return false;
|
|
1156
|
+
return { stays: false, login };
|
|
1123
1157
|
}
|
|
1158
|
+
const STAYS = { stays: true };
|
|
1159
|
+
const OFF_LOGIN = { stays: false, login: undefined };
|
|
1124
1160
|
/** 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
1161
|
* the runner (staysInRunner). */
|
|
1126
1162
|
export function childLoops(options) {
|
|
1127
1163
|
// Each slot locked on the data directory too: another runner on it whose range overlaps this one's never runs a run
|
|
1128
1164
|
// on a slot this one holds.
|
|
1129
1165
|
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
1166
|
const here = resolveRunnerLoop(options.deps);
|
|
1132
1167
|
return createDispatchLoop({
|
|
1133
1168
|
launchOf: (runId) => options.deps.store.runs.launch(runId),
|
|
1134
|
-
resolve: async (harness, launch, runId) =>
|
|
1169
|
+
resolve: async (harness, launch, runId) => {
|
|
1170
|
+
const place = await staysInRunner(options.deps, harness, launch, runId, options.isolation);
|
|
1171
|
+
if (place.stays)
|
|
1172
|
+
return here(harness, launch, runId);
|
|
1173
|
+
const own = (loopDeps) => childLoop(options, slots, loopDeps, place.login);
|
|
1174
|
+
return own;
|
|
1175
|
+
},
|
|
1135
1176
|
});
|
|
1136
1177
|
}
|
|
1137
1178
|
registerRunErrors();
|
|
@@ -1142,12 +1183,6 @@ function withGatewayKey(claimed, key) {
|
|
|
1142
1183
|
Object.defineProperty(out, GATEWAY_KEY_ENV, { value: key, enumerable: false, writable: false, configurable: false });
|
|
1143
1184
|
return out;
|
|
1144
1185
|
}
|
|
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
1186
|
/** The environment a run's process starts with: the runner's run environment's plain values (runEnv: its secrets are
|
|
1152
1187
|
* not enumerable, so none is here), no key-shaped name, and where its keys come from. */
|
|
1153
1188
|
function childEnv(base, keys, extra) {
|
|
@@ -1170,7 +1205,8 @@ export function runChannel(socket, onClose, gate = SERVER_SLOTS, more = {}) {
|
|
|
1170
1205
|
saves = exposeSaveSlots(channel, gate);
|
|
1171
1206
|
return channel;
|
|
1172
1207
|
}
|
|
1173
|
-
|
|
1208
|
+
/** `login`: the Claude login this run's claim read (staysInRunner), the one its runner hands the run (ClaimReads). */
|
|
1209
|
+
function childLoop(options, slots, loopDeps, login) {
|
|
1174
1210
|
const { deps, isolation } = options;
|
|
1175
1211
|
const cut = loopDeps.redact ?? ((text) => text);
|
|
1176
1212
|
const log = (line) => options.log(cut(line));
|
|
@@ -1252,33 +1288,26 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1252
1288
|
const savedGateway = savedGatewayIn(claimEnv);
|
|
1253
1289
|
// The run's own keys: those its claim opens (claim-secrets.ts), the one list its loop in this process read. Its model
|
|
1254
1290
|
// 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.
|
|
1291
|
+
// host's default's now, where its revision names no model and a key saved since moved that default. On a --faux
|
|
1292
|
+
// runner, or pinned to the faux model, a run sends no model key (claim-secrets.ts sendsNoModelKey): its process is
|
|
1293
|
+
// handed none, not even its revision's model's.
|
|
1256
1294
|
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
1295
|
// A run that holds a model key of its own (model_key, its launch's) spends that key alone: its process is handed
|
|
1263
1296
|
// none of the server's model keys, as its spec drops them from its tools' (claim-secrets.ts withoutModelKeys).
|
|
1264
1297
|
// Copies: the runner's own reads (heldFor's `claimed`: what the run's learning must never keep) stay whole.
|
|
1265
1298
|
const keyed = (await openRunModelKey({ store: deps.store, sealKey: deps.sealKey }, claim.runId)) !== undefined;
|
|
1266
|
-
const toProcess = keyed ?
|
|
1299
|
+
const toProcess = keyed ? withoutModelKeys({ ...claimed }) : claimed;
|
|
1267
1300
|
// The saved gateway's key, kept off the claim's tool keys (claimSecrets), is handed for the run's model routes alone,
|
|
1268
1301
|
// read as the server's model keys are (savedModelKeys, over the claim's environment the gateway was laid over), as a
|
|
1269
1302
|
// 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
|
-
]);
|
|
1303
|
+
// run whose model sends no key (sendsNoModelKey: a held run its model kept from running, any run on a --faux runner,
|
|
1304
|
+
// a faux-pinned one).
|
|
1305
|
+
const gatewayKey = savedGateway && !sendsNoModelKey(launch, claimEnv) ? (keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }))[GATEWAY_KEY_ENV] || undefined : undefined;
|
|
1306
|
+
const handed = (name) => (name === GATEWAY_KEY_ENV && savedGateway ? gatewayKey : toProcess[name] || undefined);
|
|
1307
|
+
const keys = encode(SECRET_NAMES.flatMap((name) => {
|
|
1308
|
+
const value = handed(name);
|
|
1309
|
+
return value === undefined ? [] : [[name, value]];
|
|
1310
|
+
}));
|
|
1282
1311
|
const slot = await slots?.take();
|
|
1283
1312
|
if (slots && slot === undefined) {
|
|
1284
1313
|
// Every free slot of this runner is held by another runner on the data directory (ranges that overlap): the run
|
|
@@ -1300,8 +1329,17 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1300
1329
|
const tops = runTops(deps.data, runRow.agentId, claim.runId);
|
|
1301
1330
|
// The run's pieced writes (big-writes.ts): let go when its channel ends, or at the claim's release.
|
|
1302
1331
|
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);
|
|
1332
|
+
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);
|
|
1333
|
+
// The run's trace: its process posts each call of it (tracer.ts postedTracing), and this runner's tracing makes the
|
|
1334
|
+
// spans and exports them in the background. No exporter, flush or OTLP setting is ever the process's, so neither
|
|
1335
|
+
// its exit nor this claim's release waits on a collector. Made inside the claim's cleanup, so nothing it waits on
|
|
1336
|
+
// can keep the slot.
|
|
1337
|
+
let traced;
|
|
1304
1338
|
try {
|
|
1339
|
+
const tracing = await (options.tracing ?? genAiTracing()).catch(() => undefined);
|
|
1340
|
+
// Its agent is the one this runner reads from the store, never one the process posts; a read that fails is the
|
|
1341
|
+
// agent's id alone (agentOfRun).
|
|
1342
|
+
traced = tracing ? tracePosts(tracing, claim.runId, cut, await agentOfRun(deps.store.agents, runRow.agentId)) : undefined;
|
|
1305
1343
|
let extra = {};
|
|
1306
1344
|
let argv = [...(options.argv ?? childArgv())];
|
|
1307
1345
|
// A claim that resumes a run whose last runner ended before giving its folders back finds them its last slot's,
|
|
@@ -1320,7 +1358,8 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1320
1358
|
argv = [isolation.helper, "run", String(slot), "--keep-fd", "3", "--keep-fd", "4", "--", ...argv];
|
|
1321
1359
|
}
|
|
1322
1360
|
// The saved gateway's address and models go as plain variables (childEnv), and its mark says they are the saved one.
|
|
1323
|
-
|
|
1361
|
+
// The server's keyless holds now (web-holds.ts), so the run's Web starts with them: hold data alone.
|
|
1362
|
+
const env = childEnv(claimEnv, keys, { ...extra, ...holdsEnv(), ...(savedGateway ? { [SAVED_GATEWAY_ENV]: "1" } : {}) });
|
|
1324
1363
|
const [program, ...rest] = argv;
|
|
1325
1364
|
child = spawn(program, rest, { stdio: ["ignore", "inherit", "inherit", "pipe", "pipe"], env, detached: true });
|
|
1326
1365
|
exited = new Promise((resolve) => {
|
|
@@ -1340,6 +1379,9 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1340
1379
|
const bound = { claim, agentId: runRow.agentId, revisionId: runRow.revisionId };
|
|
1341
1380
|
channel.expose("store", (method, args) => storeCall(deps.store, method, args, bound, log));
|
|
1342
1381
|
channel.expose("journal", journalTarget(loopDeps.journal(claim), cut));
|
|
1382
|
+
const posts = traced;
|
|
1383
|
+
if (posts)
|
|
1384
|
+
channel.expose("trace", (method, args) => posts.post(method, args));
|
|
1343
1385
|
channel.expose("held", (method, args) => {
|
|
1344
1386
|
// Its own members alone: a name of Object's prototype (constructor, toString) is no call of Held.
|
|
1345
1387
|
const fn = Object.hasOwn(heldSide.held, method) ? heldSide.held[method] : undefined;
|
|
@@ -1361,6 +1403,8 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1361
1403
|
return undefined;
|
|
1362
1404
|
case "log":
|
|
1363
1405
|
return void log(String(args[0]));
|
|
1406
|
+
case "webHold":
|
|
1407
|
+
return void noteHold(args[0]);
|
|
1364
1408
|
default:
|
|
1365
1409
|
throw new ClaimRefused(`the runner has no ${method} for a run`);
|
|
1366
1410
|
}
|
|
@@ -1368,7 +1412,7 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1368
1412
|
loopDeps.live?.(() => latest);
|
|
1369
1413
|
const reach = await mcpReachOf(deps);
|
|
1370
1414
|
const init = {
|
|
1371
|
-
claim, data: deps.data, signal: loopDeps.signal, where: deps.store.where,
|
|
1415
|
+
claim, data: deps.data, signal: loopDeps.signal, where: deps.store.where, ...(traced ? { traced: true } : {}),
|
|
1372
1416
|
...(reach.loopback ? { mcpLoopback: true, mcpOwn: reach.own ?? [] } : {}),
|
|
1373
1417
|
...(deps.githubApi ? { githubApi: deps.githubApi } : {}),
|
|
1374
1418
|
...(deps.githubWeb ? { githubWeb: deps.githubWeb } : {}),
|
|
@@ -1396,6 +1440,8 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1396
1440
|
}
|
|
1397
1441
|
finally {
|
|
1398
1442
|
ready();
|
|
1443
|
+
// A process gone before it ended its trace: its spans end with the claim (after its own end, a no-op).
|
|
1444
|
+
await traced?.end("run-error");
|
|
1399
1445
|
await heldSide.projectEnd?.();
|
|
1400
1446
|
const reaped = await end(slot, tops).catch((error) => {
|
|
1401
1447
|
log(`run ${claim.runId}: its process's end failed: ${error?.message ?? error}`);
|