@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
|
@@ -30,9 +30,8 @@ import { wireName } from "../catalog.js";
|
|
|
30
30
|
import { environmentLine, runZone } from "../environment.js";
|
|
31
31
|
import { factsOf, harnessOf, planRecipeOf } from "../harness-table.js";
|
|
32
32
|
import { layHarnessKeys, openHarnessKeys, RECIPE_SIGN_IN_PERSON_ONLY, RECIPE_TURN_PERSON_ONLY } from "../harness-keys.js";
|
|
33
|
-
import { laidLearned,
|
|
33
|
+
import { laidLearned, secretsShown } from "../learning.js";
|
|
34
34
|
import { laidOf, layLearningSeed } from "./learning-seed.js";
|
|
35
|
-
import { learningWorkspace } from "../learn/folder.js";
|
|
36
35
|
import { learningEndOfRun, spentBesideOf } from "./learning-end.js";
|
|
37
36
|
import { ollamaTagsOf, providerModels, runModels } from "../model.js";
|
|
38
37
|
import { OLLAMA_PROVIDER } from "../ollama-provider.js";
|
|
@@ -49,7 +48,7 @@ import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
|
49
48
|
import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
50
49
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
51
50
|
import { settingOfDefinition } from "../computer-setting.js";
|
|
52
|
-
import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
51
|
+
import { computerFilesNote, computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
53
52
|
import { computerTurnedOff, hadComputer, recordComputerOff } from "./computer-journal.js";
|
|
54
53
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
55
54
|
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, claimLiveAt, graderRouteOf, heldModelOf, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, mcpReachOf, modelAskOf, PI_WIRES, seedEvalFiles, webHostTools } from "./adapter-run-spec.js";
|
|
@@ -72,10 +71,9 @@ import { journalEntries } from "./journal-reader.js";
|
|
|
72
71
|
import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
|
|
73
72
|
import { replayCallsOver } from "./promotion.js";
|
|
74
73
|
import { learnedFirstWhereHeld } from "./learned-first.js";
|
|
75
|
-
import { pathMetrics } from "./workflow-first.js";
|
|
76
74
|
import { AUDIT_PARKED, withAudit } from "./audit.js";
|
|
77
75
|
import { compareEndOfRun, GRADER, withGrader } from "./compare-end.js";
|
|
78
|
-
import {
|
|
76
|
+
import { runPathMetricsOverStore } from "../store-reads/learning.js";
|
|
79
77
|
import { specBuilt } from "./spec-holds.js";
|
|
80
78
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
81
79
|
import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
|
|
@@ -91,7 +89,7 @@ import { monidForClaim, withMonid } from "./monid-run.js";
|
|
|
91
89
|
import { verifyPlacedProject, movedSkillFiles } from "../source-sync/claim.js";
|
|
92
90
|
import { projectCheckpointForRun } from "./project-checkpoint.js";
|
|
93
91
|
import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
|
|
94
|
-
import { routeTrace } from "../otel/genai.js";
|
|
92
|
+
import { agentOfRun, routeTrace } from "../otel/genai.js";
|
|
95
93
|
/** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
|
|
96
94
|
export const cliRefusesKind = (kind) => kind === "browser" ? "This agent's computer is a browser, which only the pi harness drives here: pick pi for this agent, or another kind of computer in Settings → Computers." : undefined;
|
|
97
95
|
/** The run's model and the catalog that prices it, as main chooses a CLI run's (app.ts wireModels and runModels): on the
|
|
@@ -255,6 +253,28 @@ async function rmEmptyParents(parents) {
|
|
|
255
253
|
}
|
|
256
254
|
}
|
|
257
255
|
}
|
|
256
|
+
/** The login a run starts on: Claude Code's login on this machine, where the owner turned it on for claude-agent here
|
|
257
|
+
* (claude-login.ts), the run carrying only where it is, its CLI saying it is signed in before the run starts. A run that
|
|
258
|
+
* brought its own key (`keyed`) runs on that key, and a run in a sandbox place on the model keys. A run's own process (no
|
|
259
|
+
* seal key: a user of its own, which cannot open the login's folder) goes on its runner's reader of the login's access
|
|
260
|
+
* token alone (held.ts claudeLogin), each token it hands held by `hold` (the redactors) and this process's own; its CLI
|
|
261
|
+
* then never gets a refresh token. Such a process never reads the login's setting itself: whether its run is on the
|
|
262
|
+
* login is its runner's to say. Its claim read the setting (run-child-host.ts staysInRunner), so a turn-on after the
|
|
263
|
+
* claim never moves it onto a login the claim did not check (a user of its own, a process runner on the same folder);
|
|
264
|
+
* a claim that read it on has the runner read it again at the start, which refuses the start in fixed words when that
|
|
265
|
+
* read names none or another folder. Nor could the process read it: the setting names the machine by the id in the
|
|
266
|
+
* server's data folder (claude-login.ts machineId), which the run's user can neither read nor make there. The runner's
|
|
267
|
+
* answer is the one decision (none: not on the login). A
|
|
268
|
+
* claim on a login other than AgentRun's own folder never gets this far: the claim itself is refused (staysInRunner,
|
|
269
|
+
* in LOGIN_MACHINE_NEEDS_SERVER_USER's words). A run in the runner itself (a seal key) reads the setting here. */
|
|
270
|
+
export async function runLoginOf(deps, keyed, name, place, hold) {
|
|
271
|
+
if (keyed)
|
|
272
|
+
return undefined;
|
|
273
|
+
if (deps.sealKey)
|
|
274
|
+
return loginForRun(deps.store.settings, deps.data, deps.env ?? {}, name, place);
|
|
275
|
+
const handed = await runnerSeam()?.claudeLogin();
|
|
276
|
+
return handed && heldTokenLogin(handed, hold);
|
|
277
|
+
}
|
|
258
278
|
/**
|
|
259
279
|
* One claimed CLI run's AdapterRunSpec, built from its launch record and its revision.
|
|
260
280
|
*
|
|
@@ -354,15 +374,6 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
354
374
|
});
|
|
355
375
|
}
|
|
356
376
|
}
|
|
357
|
-
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
358
|
-
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
359
|
-
// Before the session opens: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its words.
|
|
360
|
-
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
361
|
-
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
362
|
-
redact.hold(values); };
|
|
363
|
-
const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, web, launch) });
|
|
364
|
-
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
365
|
-
holds.hold({ passed: mcp });
|
|
366
377
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
367
378
|
// on the claim's Archil disk (archil-claim.ts: its keys from the store's sealed rows, under the runner's seal key, in
|
|
368
379
|
// this claim's memory only, dropped at the release); else Mode 1, the run's local folder.
|
|
@@ -386,6 +397,25 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
386
397
|
? await openRunWorkspace({ mode: 1, agentId: runRow.agentId, runId: claim.runId, data: deps.data, log })
|
|
387
398
|
: await openRunWorkspace({ mode: 2, agentId: runRow.agentId, runId: claim.runId, archil, log });
|
|
388
399
|
holds.hold({ ws });
|
|
400
|
+
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
401
|
+
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
402
|
+
// Before the session opens: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its words.
|
|
403
|
+
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
404
|
+
// A held run its model kept from running at its create (hold.refused) opens none: nothing can call one.
|
|
405
|
+
const heldRefusal = launch.hold?.refused?.message;
|
|
406
|
+
// What its gateway files (a long answer, a server's results) goes in the run's own files. In Mode 1 that is the run's
|
|
407
|
+
// folder on this machine (ws.workspace below, the folder a box bind-mounts). In Mode 2 it is the run's Archil disk:
|
|
408
|
+
// through the run's computer once it mounts the folder (filedIn, set at runTools), since the mount holds the disk's
|
|
409
|
+
// write delegation and a write over the disk's file API is refused (409) while it does; over that file API (ws.workspace)
|
|
410
|
+
// when no computer mounts it. The gateway reads work() only when a call is answered (mcp-gateway.ts textOf, fileResults),
|
|
411
|
+
// and a call reaches it only through the session this spec returns, after `tools` is made. After the run's Workspace,
|
|
412
|
+
// as the pi spec makes it: a refusal lets the Workspace and the Archil claim go (holds above).
|
|
413
|
+
let filedIn;
|
|
414
|
+
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
415
|
+
redact.hold(values); };
|
|
416
|
+
const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, toolSettings: body.toolSettings, work: () => (mode === 2 ? filedIn ?? ws.workspace : ws.workspace), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, web, launch) });
|
|
417
|
+
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
418
|
+
holds.hold({ passed: mcp });
|
|
389
419
|
// The pull request's checkout, when the revision asks for one, as the pi spec makes it (pr-checkout.ts).
|
|
390
420
|
const checkout = body.checkout ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part }), body.checkout) : undefined;
|
|
391
421
|
holds.hold({ checkout });
|
|
@@ -405,9 +435,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
405
435
|
// A learning run's seed read as the pi spec reads it (runner/learning-seed.ts): its learned workflows, the ones
|
|
406
436
|
// learned_workflow runs.
|
|
407
437
|
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
408
|
-
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
409
438
|
const seedLaid = start && !seedFailed(start)
|
|
410
|
-
? await layLearningSeed({ seed: start.seed,
|
|
439
|
+
? await layLearningSeed({ seed: start.seed, store: deps.store, agentId: runRow.agentId, shown, log, ...(start.noWorkflows ? { workflows: false } : {}) })
|
|
411
440
|
: undefined;
|
|
412
441
|
// The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
|
|
413
442
|
// It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
|
|
@@ -425,9 +454,10 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
425
454
|
// whose computer is a browser is refused in words at its claim, before anything is made.
|
|
426
455
|
// A person's stop ends the claim's waits at once: a first image pull or registration (Agent37's runs minutes) among them.
|
|
427
456
|
// Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer), as the pi
|
|
428
|
-
// spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount)
|
|
429
|
-
// screen's recording (computer.record) goes in the run's
|
|
430
|
-
|
|
457
|
+
// spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount); a park's
|
|
458
|
+
// row names the disk that credential is on (mountDisk). Its screen's recording (computer.record) goes in the run's
|
|
459
|
+
// recordings folder, as the pi spec's does.
|
|
460
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(offAlready ? { turnedOff: offAlready } : {}), recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(run.ledger ? { compute: { ledger: { paid: run.ledger.paid, pause: (refusal) => run.ledger.pause(refusal), judges: () => run.ledger.judges?.() ?? true }, env: deps.env } } : {}), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit(), mountDisk: () => archil.disk.id } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
431
461
|
holds.hold({ computer });
|
|
432
462
|
const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
|
|
433
463
|
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
@@ -453,11 +483,12 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
453
483
|
const bashPolicy = bashPolicyOf(body.toolSettings);
|
|
454
484
|
// A computer that replaced an earlier claim's holds its acts to what it showed, as the pi spec's does.
|
|
455
485
|
const tools = await runTools(ws.workspace, computer.computer, { mode, context, aliases: [scratch], ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }), ...(computer.replaced ? { replaced: true } : {}) });
|
|
486
|
+
filedIn = tools.workspace;
|
|
456
487
|
let remoteProjectCapture = false;
|
|
457
488
|
holds.hold({ tools: { end: () => remoteProjectCapture ? Promise.resolve() : tools.end() } });
|
|
458
489
|
const root = runFolder(deps.data, runRow.agentId, claim.runId);
|
|
459
490
|
// The system prompt, as main's harness branch builds it: the environment line, the instructions with what the agent
|
|
460
|
-
// learned laid in (learning.ts laidLearned, from the launch's learning start, so the runner reads no learning
|
|
491
|
+
// learned laid in (learning.ts laidLearned, from the launch's learning start, so the runner reads no learning rows), its
|
|
461
492
|
// own skills through systemOf with the harness's own check (a harness that loads skills itself keeps in the prompt only
|
|
462
493
|
// those it would refuse, and is handed the rest), the output schema it answers in (answer-json.ts outputContract, as the
|
|
463
494
|
// pi spec gives it), then the effort guidance.
|
|
@@ -488,16 +519,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
488
519
|
if (runKey)
|
|
489
520
|
holdRunKey(redact, runKey);
|
|
490
521
|
}
|
|
491
|
-
|
|
492
|
-
// carries only where it is, and its CLI says it is signed in before the run starts. A run that brought its own key
|
|
493
|
-
// runs on that key, and a run in a sandbox place on the model keys. A run's own process (a user of its own, which
|
|
494
|
-
// cannot open the login's folder) goes on its runner's reader of the login's access token alone (held.ts claudeLogin),
|
|
495
|
-
// each token it hands held by the redactors and this process's own; its CLI then never gets a refresh token. Whether
|
|
496
|
-
// such a claim goes on the login at all is its runner's answer alone (none: it does not): the setting names the
|
|
497
|
-
// machine by the id in the server's data folder (claude-login.ts machineId), which the run's user can neither read nor
|
|
498
|
-
// make there.
|
|
499
|
-
const handed = keyed || deps.sealKey ? undefined : await runnerSeam()?.claudeLogin();
|
|
500
|
-
const login = keyed ? undefined : handed ? heldTokenLogin(handed, hold) : deps.sealKey ? await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, name, launch.place) : undefined;
|
|
522
|
+
const login = await runLoginOf(deps, keyed, name, launch.place, hold);
|
|
501
523
|
const env = withClaudeLogin(cliRunEnv(deps.env, deps.data, claimed, launch.plane, runKey, claim), login);
|
|
502
524
|
// A plan-billed recipe's keys saved for its harness alone (harness-keys.ts), opened at each claim for this run's harness
|
|
503
525
|
// and no other (a run's own process asks its runner, which opens its claim's own: held.ts harnessKeys), held by the
|
|
@@ -511,28 +533,31 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
511
533
|
// is chosen, so it never falls to its owner's sign-in (a row counted at its claim may be gone, or not open, by now).
|
|
512
534
|
// A person's claim that laid none keeps its session on the sign-in (or on nothing) for good: a trigger's message the
|
|
513
535
|
// claim takes later is refused in it (personOnly), keys saved since or not, as no new claim opens them.
|
|
536
|
+
// A held run its model kept from running (hold.refused, above) opens none: its agent never starts.
|
|
514
537
|
const recipe = name === undefined ? undefined : planRecipeOf(deps.env ?? {}, name);
|
|
515
538
|
const recipeKeys = recipe?.keys;
|
|
516
539
|
let personOnly;
|
|
517
540
|
if (recipe !== undefined && recipeKeys?.length) {
|
|
518
541
|
for (const key of recipeKeys)
|
|
519
542
|
delete env[key];
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
543
|
+
if (heldRefusal === undefined) {
|
|
544
|
+
const opened = deps.sealKey ? await openHarnessKeys(deps.store, deps.sealKey, recipe) : ((await runnerSeam()?.harnessKeys(recipe.digest)) ?? {});
|
|
545
|
+
hold(Object.values(opened));
|
|
546
|
+
if (recipeKeys.every((key) => typeof opened[key] === "string" && opened[key] !== ""))
|
|
547
|
+
layHarnessKeys(env, opened);
|
|
548
|
+
else if (!personStarted(launch))
|
|
549
|
+
throw new ClaimRefused(RECIPE_SIGN_IN_PERSON_ONLY);
|
|
550
|
+
else
|
|
551
|
+
personOnly = RECIPE_TURN_PERSON_ONLY;
|
|
552
|
+
}
|
|
528
553
|
}
|
|
529
554
|
// A held run its model kept from running at its create (hold.refused) chooses no model here, and no plan or login is
|
|
530
555
|
// asked before it: its model's route chooses no model and reads no key, its adapter's provider being the stand-in that
|
|
531
|
-
// refuses every request in the create's words (adapters.ts providerOf), never a key or the Claude login
|
|
532
|
-
//
|
|
533
|
-
//
|
|
534
|
-
//
|
|
535
|
-
|
|
556
|
+
// refuses every request in the create's words (adapters.ts providerOf), never a key or the Claude login; a plan-billed
|
|
557
|
+
// agent's adapter is built on no key and refuses its start in those words (harness-table.ts acpPlanEntryOf). Its claim
|
|
558
|
+
// lays only the keys any claim of the run lays (its tools', a key handed with it: claimSecrets lays it no model key, and
|
|
559
|
+
// no key saved for its harness, above) and takes no learning step (below), so it holds the computer on a host with no
|
|
560
|
+
// key for its model, and a key saved since runs a new run, never this one.
|
|
536
561
|
const chosen = heldRefusal !== undefined ? heldChoice(body.model) : await modelsOf(entry, env, modelAskOf(launch.model, body.model));
|
|
537
562
|
if (heldRefusal === undefined) {
|
|
538
563
|
await planBeforeRun(env, chosen.model);
|
|
@@ -641,6 +666,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
641
666
|
// native tools are named by its facts on the owner's table (factsOf: a module's harness's too).
|
|
642
667
|
const ownerFacts = factsOf(deps.env, name);
|
|
643
668
|
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, { ...(mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {}), facts: ownerFacts, turnedOff: offAlready !== undefined, onComputerOff: (kind) => recordComputerOff(run.harness, kind) });
|
|
669
|
+
// A park lets a computer the gate turned off go rather than keep it (SpecHolds Held.computerOff).
|
|
670
|
+
holds.hold({ computerOff: gate.computerOff });
|
|
644
671
|
// The run's tools: the kernel registry's hands on its Workspace (and computer); the web host tools it is granted
|
|
645
672
|
// (web_fetch, web_search, monid), bound by the binding the pi spec uses (webHostTools) on the ToolHost the pi spec builds
|
|
646
673
|
// (buildToolHost); and the learned_workflow tool when the run has it (learnsWorkflows: its revision is agentic and the
|
|
@@ -684,7 +711,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
684
711
|
// The audits that finished since are written first (runner/audit.ts settleAudits): a hold they make decides this claim.
|
|
685
712
|
const admitAuxiliary = runnerSeam() ? undefined : sourceAuxiliaryAdmitter(deps.store, { data: deps.data, sealKey: deps.sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } });
|
|
686
713
|
// None for a held run, so its claim reads no saved key for spend beside it (claimSpendOff).
|
|
687
|
-
const audits = heldRefusal === undefined ? { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log,
|
|
714
|
+
const audits = heldRefusal === undefined ? { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, shown, sealKey: deps.sealKey, spendOff: await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey), admitAuxiliary } : undefined;
|
|
688
715
|
// A replay run's or a shadow's grader (runner/compare-end.ts), on a proxy of its own beside the CLI session's, as pi's
|
|
689
716
|
// is (adapter-run-spec.ts graderRouteOf), reached through the session's port while it is up. None: compared whole.
|
|
690
717
|
// None for a held run its model kept from running, whose model runs nowhere.
|
|
@@ -695,7 +722,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
695
722
|
// them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself. A held run its model kept from
|
|
696
723
|
// running takes none of them, as on pi: it settles no audit and starts no replay run, starts on no workflow, and its
|
|
697
724
|
// tool runs none (so no learned tier is routed, below).
|
|
698
|
-
const learned = audits ? await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log,
|
|
725
|
+
const learned = audits ? await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log, shown, spendOff: audits.spendOff, admitAuxiliary }, seedLaid?.workflows ?? []) : { choice: { reason: "held" }, workflows: [] };
|
|
699
726
|
const firstChoice = learned.choice;
|
|
700
727
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
701
728
|
// answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
|
|
@@ -765,21 +792,20 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
765
792
|
system: [environmentLine(now, zone), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line)),
|
|
766
793
|
// The web tools and the learned workflow's call nodes run on the claim's keys: their answers pass the runner's one
|
|
767
794
|
// redactor, as pi's do. Listed in the order the agent grants them, as main lists a CLI run's tools.
|
|
768
|
-
tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(askTool ? [askTool] : []), ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
|
|
795
|
+
tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), { results, writes: gate.writes() }), ...[...webTools, ...(askTool ? [askTool] : []), ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
|
|
769
796
|
context: "fresh",
|
|
770
797
|
...(thinking ? { thinking } : {}),
|
|
771
798
|
};
|
|
772
799
|
// A typed input's other fields follow its content as one json block (inputMessage).
|
|
773
800
|
const input = await firstMessage(inputMessage(launch.input), ws.workspace);
|
|
774
801
|
// The run's end-of-run step, when it learns, the same as the pi spec's: the compile turn and the owner's correction over
|
|
775
|
-
// the run's store, its
|
|
776
|
-
// claim's Archil disk — so the draft is checked against the seed in the run's own Workspace, never this machine's local path.
|
|
802
|
+
// the run's store, its draft checked against the seed in the agent's learning rows.
|
|
777
803
|
// A replay run or an audit's shadow run learns nothing at its end: it is the promotion's, never the agent's to learn
|
|
778
804
|
// from. With a grader it compares its answer with the other one (runner/compare-end.ts), on its own cap.
|
|
779
805
|
// A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
|
|
780
806
|
// withAudit): at its end, so the shadow's cap is what the run's own left.
|
|
781
807
|
// A held run (no audits) takes none, as on pi.
|
|
782
|
-
const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store,
|
|
808
|
+
const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, log, ...(run.redact ? { redact: run.redact } : {}) }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
|
|
783
809
|
store: deps.store,
|
|
784
810
|
data: deps.data,
|
|
785
811
|
...(deps.env ? { env: deps.env } : {}),
|
|
@@ -792,9 +818,6 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
792
818
|
log,
|
|
793
819
|
// A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
|
|
794
820
|
decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
|
|
795
|
-
learningFolder: archil === undefined
|
|
796
|
-
? (agentId) => learningFolderOf(deps.data, agentId)
|
|
797
|
-
: (agentId) => learningWorkspace({ mode: "archil", agentId, archil }),
|
|
798
821
|
}), { ...audits, launch, ...(run.redact ? { redact: run.redact } : {}) });
|
|
799
822
|
return {
|
|
800
823
|
adapter,
|
|
@@ -809,8 +832,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
809
832
|
// The answer's schema: a miss is asked again once (adapter-loop.ts, the output contract's retry), as on pi.
|
|
810
833
|
...(body.outputSchema !== undefined ? { outputSchema: body.outputSchema } : {}),
|
|
811
834
|
...(cap ? { cap } : {}),
|
|
812
|
-
// Its model, as its GenAI trace names it (otel/genai.ts); its requests' host is its CLI's own to choose.
|
|
813
|
-
|
|
835
|
+
// Its model, as its GenAI trace names it (otel/genai.ts); its requests' host is its CLI's own to choose. And the agent
|
|
836
|
+
// the run is of (its id and name; the loop cuts them).
|
|
837
|
+
trace: { ...routeTrace({ named: `${chosen.model.provider}/${chosen.model.modelId}`, model: chosen.model.modelId }), agent: await agentOfRun(deps.store.agents, runRow.agentId) },
|
|
814
838
|
// The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
|
|
815
839
|
// the catalog tools the session mounts; absent when none.
|
|
816
840
|
...(catalog ? { mcp: catalog } : {}),
|
|
@@ -834,6 +858,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
834
858
|
...(tools.computer ? { scriptComputer: tools.computer } : {}),
|
|
835
859
|
// A computer that replaced an earlier claim's: the model is told once, on its next request (the loop's computer note).
|
|
836
860
|
...(computer.replaced ? { computerNote: computerReplacedNote(computer.replaced) } : {}),
|
|
861
|
+
// A desktop or a phone that holds none of the run's files: the model is told once in the run where they are, or, where
|
|
862
|
+
// the gate would refuse a save (RunGate.writeBar), that a screenshot can't be saved to them.
|
|
863
|
+
...(tools.apart ? { computerFilesNote: computerFilesNote({ ...tools.apart, writes: gate.writes(), outlives: computer.outlives === true }) } : {}),
|
|
837
864
|
workRoot: root,
|
|
838
865
|
// Where the CLI works (its working directory, the run's folder to its file tools): what its absolute paths are read
|
|
839
866
|
// against on the run's rows.
|
|
@@ -861,14 +888,16 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
861
888
|
const metrics = cliRunMetrics(piShaped(entries), booked, { ...(thinking ? { effort: thinking } : {}), model: `${chosen.model.provider}/${chosen.model.modelId}`, catalog: await hashedMcpOf(deps.store, claim.runId) });
|
|
862
889
|
// Its cost is endCost's, read apart (an unknown one written as null, never left out: a follow-up's end clears the
|
|
863
890
|
// cost an earlier end stored).
|
|
864
|
-
return { metrics: { ...metrics, ...
|
|
891
|
+
return { metrics: { ...metrics, ...(await runPathMetricsOverStore(deps.store, claim.runId, launch, { ...(run.redact ? { redact: run.redact } : {}), choice: firstChoice.reason })), costBasis: costBasisOf(booked) } };
|
|
865
892
|
},
|
|
866
893
|
// A run started with hold: true holds its computer for its owner (computer-held.ts), as the pi spec's.
|
|
867
894
|
...(heldComputer ? { held: heldComputer } : {}),
|
|
868
895
|
// The run's Archil mount credential is revoked at its end on every outcome, even with no computer (idempotent with
|
|
869
896
|
// the computer's release). A run that minted none revokes nothing. At a park, a desktop or a phone is kept for the
|
|
870
|
-
// resume instead, its mount credential with it, as the pi spec's
|
|
871
|
-
|
|
897
|
+
// resume instead, its mount credential with it, as the pi spec's, said once its row is written; one the gate turned
|
|
898
|
+
// off is not, nor said to be.
|
|
899
|
+
keptWords: () => (computer.keeps === undefined || gate.computerOff() ? undefined : computerKeptWords(computer.keeps)),
|
|
900
|
+
...(computer.keeps && computer.keepRow ? { keep: () => computer.keepRow() } : {}),
|
|
872
901
|
release: (how) => holds.release(how),
|
|
873
902
|
...(movedProject ? { projectCheckpoint: projectCheckpointForRun({ store: deps.store, agentId: runRow.agentId, claim, launch, tools, computer,
|
|
874
903
|
workspace: { data: deps.data, sealKey: deps.sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } },
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { LearningFolder } from "../learn/folder.js";
|
|
2
1
|
import { type GraderReply } from "../learn/promote.js";
|
|
3
2
|
import type { PortModels } from "../port-models.js";
|
|
4
3
|
import type { RunLaunch } from "../run-launch.js";
|
|
@@ -9,13 +8,13 @@ import type { EndOfRunTurn } from "./loop-contract.js";
|
|
|
9
8
|
export declare const GRADER = "grader";
|
|
10
9
|
export type CompareEndDeps = {
|
|
11
10
|
readonly store: Store;
|
|
12
|
-
readonly folder: () => LearningFolder;
|
|
13
11
|
readonly log: (line: string) => void;
|
|
14
12
|
readonly redact?: (text: string) => string;
|
|
15
13
|
};
|
|
16
14
|
/** The end-of-run step of a replay run or an audit's shadow (its callers pass no other run): its comparison (above),
|
|
17
15
|
* asked only when the run completed, was not cut, has a grader (its route exists only for a revision that names no
|
|
18
|
-
* agree_on, graderRouteOf), and the two answers are not already the same
|
|
16
|
+
* agree_on, graderRouteOf), and the two answers are not already the same (then a replay keeps only the grade it was judged
|
|
17
|
+
* with, `same` and no model asked). In a run's own process the step is its runner's (held.ts endOfRun): it reads other runs and the
|
|
19
18
|
* learning ledger, which no run's process may. A comparison that fails keeps no verdict: the pair then differs, compared
|
|
20
19
|
* whole (compareAnswers), in the log's words. */
|
|
21
20
|
export declare function compareEndOfRun(launch: RunLaunch, deps: CompareEndDeps): EndOfRunTurn | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
2
|
-
import { gradeAnswers, sameAnswer } from "../learn/promote.js";
|
|
2
|
+
import { answersPair, comparedGrade, gradeAnswers, gradesOf, knownAnswerText, sameAnswer } from "../learn/promote.js";
|
|
3
3
|
import { runPathOverStore } from "../store-reads/learning.js";
|
|
4
4
|
import { auditedAnswerOf } from "./audit.js";
|
|
5
5
|
import { held, heldEndOfRun } from "./held.js";
|
|
@@ -11,27 +11,42 @@ export const GRADER = "grader";
|
|
|
11
11
|
const GRADER_MAX_TOKENS = 1_000;
|
|
12
12
|
/** The job input as the grader reads it: the launch's text, or its typed input as JSON. */
|
|
13
13
|
const inputText = (input) => (typeof input === "string" ? input : JSON.stringify(input ?? null));
|
|
14
|
-
/** The two answers a replay run or a shadow compares at its end: the
|
|
15
|
-
* answer is its own, when the workflow it replays answered it;
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
/** The two answers a replay run or a shadow compares at its end: the known one and the workflow's. A replay's workflow
|
|
15
|
+
* answer is its own, when the workflow it replays answered it; its known answer is its source run's newest grade's
|
|
16
|
+
* expected answer written over that run's own answer (knownAnswerText, which the check reads too), else that run's
|
|
17
|
+
* own answer, with that grade (`graded`, null for none), which its verdict keeps. A shadow's agent answer is its own;
|
|
18
|
+
* the workflow's is the served run's answer it audits (its open ledger line's turn). Null: nothing to compare. */
|
|
18
19
|
async function pairOf(launch, deps, runId) {
|
|
19
20
|
if (launch.replay) {
|
|
20
21
|
const path = await runPathOverStore(deps.store, runId, launch.learning, deps.redact);
|
|
21
22
|
if (path.path !== "workflow" || path.workflow !== launch.replay.workflow)
|
|
22
23
|
return null;
|
|
23
|
-
const
|
|
24
|
-
|
|
24
|
+
const workflow = await answerOf(deps.store, runId, BACKGROUND_CONTEXT);
|
|
25
|
+
const said = await answerOf(deps.store, launch.replay.of, BACKGROUND_CONTEXT);
|
|
26
|
+
// The grade read once: the verdict keeps it, so the check judges this input on the grade its grader was asked against.
|
|
27
|
+
const graded = await gradeOf(deps.store, launch.replay.of);
|
|
28
|
+
const agent = graded?.expected ? knownAnswerText(said, graded.expected) : said;
|
|
29
|
+
return workflow === null || agent === null ? null : { agent, workflow, graded };
|
|
25
30
|
}
|
|
26
31
|
if (launch.audit) {
|
|
27
|
-
|
|
32
|
+
// The shadow's agent's audit ledger: the shadow run is its agent's, as the served run it audits is.
|
|
33
|
+
const agentId = (await deps.store.runs.get(runId))?.agentId;
|
|
34
|
+
if (agentId === undefined)
|
|
35
|
+
return null;
|
|
36
|
+
const [agent, workflow] = [await answerOf(deps.store, runId, BACKGROUND_CONTEXT), await auditedAnswerOf({ store: deps.store, agentId, context: BACKGROUND_CONTEXT }, runId)];
|
|
28
37
|
return workflow === null || agent === null ? null : { agent, workflow };
|
|
29
38
|
}
|
|
30
39
|
return null;
|
|
31
40
|
}
|
|
41
|
+
/** Run `of`'s newest grade as the check judges it (comparedGrade), null when it has none. */
|
|
42
|
+
async function gradeOf(store, of) {
|
|
43
|
+
const source = await store.runs.get(of);
|
|
44
|
+
return comparedGrade(source ? (await gradesOf(store.learning, source.agentId)).findLast((one) => one.run === of) : undefined);
|
|
45
|
+
}
|
|
32
46
|
/** The end-of-run step of a replay run or an audit's shadow (its callers pass no other run): its comparison (above),
|
|
33
47
|
* asked only when the run completed, was not cut, has a grader (its route exists only for a revision that names no
|
|
34
|
-
* agree_on, graderRouteOf), and the two answers are not already the same
|
|
48
|
+
* agree_on, graderRouteOf), and the two answers are not already the same (then a replay keeps only the grade it was judged
|
|
49
|
+
* with, `same` and no model asked). In a run's own process the step is its runner's (held.ts endOfRun): it reads other runs and the
|
|
35
50
|
* learning ledger, which no run's process may. A comparison that fails keeps no verdict: the pair then differs, compared
|
|
36
51
|
* whole (compareAnswers), in the log's words. */
|
|
37
52
|
export function compareEndOfRun(launch, deps) {
|
|
@@ -42,10 +57,14 @@ export function compareEndOfRun(launch, deps) {
|
|
|
42
57
|
return undefined;
|
|
43
58
|
try {
|
|
44
59
|
const pair = await pairOf(launch, deps, input.runId);
|
|
45
|
-
if (!pair
|
|
60
|
+
if (!pair)
|
|
46
61
|
return undefined;
|
|
62
|
+
// Equal answers ask no model; a replay's record still keeps the grade it was judged with (Compared.graded).
|
|
63
|
+
if (sameAnswer(pair.agent, pair.workflow))
|
|
64
|
+
return pair.graded === undefined ? undefined : { also: [], compared: { same: true, pair: answersPair(pair.agent, pair.workflow), graded: pair.graded } };
|
|
47
65
|
const grade = input.grade;
|
|
48
|
-
const
|
|
66
|
+
const verdict = await gradeAnswers(inputText(launch.input), pair.agent, pair.workflow, { model: input.grader, ask: (request) => grade(request) });
|
|
67
|
+
const compared = pair.graded !== undefined ? { ...verdict, graded: pair.graded } : verdict;
|
|
49
68
|
return { also: [], compared };
|
|
50
69
|
}
|
|
51
70
|
catch (error) {
|
|
@@ -256,7 +256,7 @@ async function world(subject, t, timing = STEADY) {
|
|
|
256
256
|
* it (Claim.lost names that same runner), gives it back as a run it still holds, and the runner that then takes it over
|
|
257
257
|
* claims a released run, not a lost one: the timeline never says the run went on after the crashed runner was lost. */
|
|
258
258
|
const claimsSettled = async (name) => void (await Promise.allSettled([...(claiming.get(name) ?? [])]));
|
|
259
|
-
const start = async (name, setup, holder
|
|
259
|
+
const start = async (name, setup, holder) => {
|
|
260
260
|
const store = await openCaseStore({ dataDir: dir, role: "runner", url, env, clockFile });
|
|
261
261
|
stores.push(store);
|
|
262
262
|
// Each journal commit's outcome, by the claim's epoch (as child.ts records its process's): what a loop wrote, and
|
|
@@ -265,7 +265,6 @@ async function world(subject, t, timing = STEADY) {
|
|
|
265
265
|
const observedLoop = (deps) => {
|
|
266
266
|
const loop = factory({
|
|
267
267
|
...deps,
|
|
268
|
-
...more,
|
|
269
268
|
journal: (claim) => new Proxy(deps.journal(claim), {
|
|
270
269
|
get(target, property) {
|
|
271
270
|
const value = Reflect.get(target, property, target);
|
|
@@ -1116,7 +1115,7 @@ const CASES = [
|
|
|
1116
1115
|
answers.push(await input.ask(prompt, { origin: "reflect", deadlineMs: 10_000 }));
|
|
1117
1116
|
return undefined;
|
|
1118
1117
|
};
|
|
1119
|
-
await w.start("runner-a", { script: [{ say: "the job's answer" }, { say: "a note" }], tools, hooks: quiet, agentId: "agent-1"
|
|
1118
|
+
await w.start("runner-a", { script: [{ say: "the job's answer" }, { say: "a note" }], tools, hooks: quiet, agentId: "agent-1", endOfRun });
|
|
1120
1119
|
await w.ended("ended");
|
|
1121
1120
|
assert.equal(answers.length, 1, "asked once");
|
|
1122
1121
|
const answer = answers[0];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { CallRecord } from "../journal-reader.js";
|
|
3
|
-
import type { Journal, LoopFactory } from "../loop-contract.js";
|
|
3
|
+
import type { EndOfRunTurn, Journal, LoopFactory } from "../loop-contract.js";
|
|
4
4
|
/** One step of the model's script: call a tool, say a text, or say the text of the last steer it was given. */
|
|
5
5
|
export type ScriptStep = {
|
|
6
6
|
readonly call: ToolName | MetaToolName;
|
|
@@ -61,6 +61,9 @@ export interface ConformanceSetup {
|
|
|
61
61
|
readonly hooks: KernelHooks;
|
|
62
62
|
/** The run's agent, for the subject's spec to name (AdapterRunSpec.agentId): the end-of-run step is asked with it. */
|
|
63
63
|
readonly agentId?: string;
|
|
64
|
+
/** The run's end-of-run step, for the subject's spec to carry (AdapterRunSpec.endOfRun), where every run's step comes
|
|
65
|
+
* from: a loop's deps carry none. */
|
|
66
|
+
readonly endOfRun?: EndOfRunTurn;
|
|
64
67
|
/** Called with each message the subject's model is handed, when the subject can see it (a stand-in's fake reports what
|
|
65
68
|
* it consumed and at what priority): for a case's failure message to name, never asserted on. */
|
|
66
69
|
readonly received?: (message: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type KeyEnv } from "../key-meta.js";
|
|
2
2
|
import type { Settings } from "../store/store.js";
|
|
3
3
|
/** The file in the server's data root that holds its id (made once, kept across starts). */
|
|
4
4
|
export declare const DATA_ROOT_FILE = "data-root.id";
|
|
@@ -19,7 +19,8 @@ export declare function sharesServerDisk(store: {
|
|
|
19
19
|
}, dataDir: string): Promise<boolean | undefined>;
|
|
20
20
|
/** Whether the server is in Mode 2, by what the server holds, never by this runner's environment: the Archil settings
|
|
21
21
|
* saved in the store, or set in the server's own environment, whose names (never values) it says at each start
|
|
22
|
-
* (runner-check.ts RUN_ENV_KEY).
|
|
22
|
+
* (runner-check.ts RUN_ENV_KEY). The region is the one name a server in Mode 2 by its environment always has: its S3
|
|
23
|
+
* URL is the region's when it sets none, and a server whose settings there are not whole does not start. */
|
|
23
24
|
export declare function serverInArchilMode(store: {
|
|
24
25
|
settings: Pick<Settings, "get">;
|
|
25
26
|
}): Promise<boolean>;
|
|
@@ -35,10 +36,20 @@ export declare function diskFreeRefusal(store: {
|
|
|
35
36
|
export declare const DISK_FREE_MODE_1 = "this runner's data directory is not the server's, and the server keeps each run's folder on its own disk (Mode 1: the server holds no Archil settings, saved or in its environment), which this runner can't reach. Save the Archil settings so runs' folders are on Archil (Mode 2), or start the runner on the server's data directory.";
|
|
36
37
|
/** A disk-free runner's words while the server is in Mode 2 by its own environment and this runner holds no Archil settings. */
|
|
37
38
|
export declare const DISK_FREE_NO_ARCHIL: string;
|
|
39
|
+
/** Why a runner given a region without an S3 URL can't claim now, or undefined while it can. Such a runner reaches Archil
|
|
40
|
+
* at the region's S3 URL (archil-settings.ts ARCHIL_S3_URLS), and the server's may be another: the server is started with
|
|
41
|
+
* AGENTRUN_ARCHIL_S3_URL (its run-facing names say so, never the value, so one that is the region's own is refused too),
|
|
42
|
+
* or it is in Mode 2 by saved settings whose s3Url is not the runner's. Any runner, on the server's disk or not, on either
|
|
43
|
+
* store: a run's folder on Archil is reached by the runner and the server at one endpoint, or not claimed. */
|
|
44
|
+
export declare function archilS3Refusal(store: {
|
|
45
|
+
settings: Pick<Settings, "get">;
|
|
46
|
+
}, env: KeyEnv): Promise<string | undefined>;
|
|
47
|
+
/** A runner's words while it is given a region without an S3 URL and the server's S3 URL may be another (archilS3Refusal). */
|
|
48
|
+
export declare const ARCHIL_S3_URL_NOT_HELD: string;
|
|
38
49
|
/** How long a gate's answer is kept between polls (diskFreeGate): a change of mode reaches a runner within this. */
|
|
39
50
|
export declare const DISK_FREE_GATE_MS = 5000;
|
|
40
|
-
/** The runner's claim gate (runner.ts claimGate) for a runner on `dataDir`: diskFreeRefusal, its
|
|
41
|
-
* DISK_FREE_GATE_MS between polls and read again when asked fresh. */
|
|
51
|
+
/** The runner's claim gate (runner.ts claimGate) for a runner on `dataDir`: archilS3Refusal, else diskFreeRefusal, its
|
|
52
|
+
* answer kept for DISK_FREE_GATE_MS between polls and read again when asked fresh. */
|
|
42
53
|
export declare function diskFreeGate(store: {
|
|
43
54
|
settings: Pick<Settings, "get">;
|
|
44
55
|
}, dataDir: string, env: KeyEnv, storeKind: string, now?: () => number): (fresh: boolean) => Promise<string | undefined>;
|
package/dist/runner/disk-free.js
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
import { randomBytes } from "node:crypto";
|
|
13
13
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
14
14
|
import { join } from "node:path";
|
|
15
|
-
import { ARCHIL_SETTINGS_ENV, loadArchilSettings } from "../archil-settings.js";
|
|
15
|
+
import { ARCHIL_SETTINGS_ENV, archilSettingsFromEnv, loadArchilSettings } from "../archil-settings.js";
|
|
16
|
+
import { envValue } from "../key-meta.js";
|
|
16
17
|
import { serverRunEnv } from "./runner-check.js";
|
|
17
18
|
/** The file in the server's data root that holds its id (made once, kept across starts). */
|
|
18
19
|
export const DATA_ROOT_FILE = "data-root.id";
|
|
@@ -52,12 +53,13 @@ export async function sharesServerDisk(store, dataDir) {
|
|
|
52
53
|
}
|
|
53
54
|
/** Whether the server is in Mode 2, by what the server holds, never by this runner's environment: the Archil settings
|
|
54
55
|
* saved in the store, or set in the server's own environment, whose names (never values) it says at each start
|
|
55
|
-
* (runner-check.ts RUN_ENV_KEY).
|
|
56
|
+
* (runner-check.ts RUN_ENV_KEY). The region is the one name a server in Mode 2 by its environment always has: its S3
|
|
57
|
+
* URL is the region's when it sets none, and a server whose settings there are not whole does not start. */
|
|
56
58
|
export async function serverInArchilMode(store) {
|
|
57
59
|
if ((await loadArchilSettings(store)) !== undefined)
|
|
58
60
|
return true;
|
|
59
61
|
const names = await serverRunEnv(store);
|
|
60
|
-
return names !== undefined &&
|
|
62
|
+
return names !== undefined && names.includes(ARCHIL_SETTINGS_ENV.region);
|
|
61
63
|
}
|
|
62
64
|
/** Why a runner on `dataDir` can't serve the runs its store holds now, or undefined while it can. On Postgres, a runner
|
|
63
65
|
* whose `dataDir` is not the server's disk can't while the server keeps runs' folders on that disk (Mode 1: the server
|
|
@@ -78,18 +80,34 @@ export async function diskFreeRefusal(store, dataDir, env, storeKind) {
|
|
|
78
80
|
/** A disk-free runner's words while the server is in Mode 1: what the runner can't do, why, and the two ways out. */
|
|
79
81
|
export const DISK_FREE_MODE_1 = "this runner's data directory is not the server's, and the server keeps each run's folder on its own disk (Mode 1: the server holds no Archil settings, saved or in its environment), which this runner can't reach. Save the Archil settings so runs' folders are on Archil (Mode 2), or start the runner on the server's data directory.";
|
|
80
82
|
/** A disk-free runner's words while the server is in Mode 2 by its own environment and this runner holds no Archil settings. */
|
|
81
|
-
export const DISK_FREE_NO_ARCHIL = `this runner's data directory is not the server's, and the server keeps each run's folder on Archil (Mode 2) by the Archil settings in its environment, which this runner does not hold. Hand this runner the server's ${ARCHIL_SETTINGS_ENV.region} and ${ARCHIL_SETTINGS_ENV.s3Url}
|
|
83
|
+
export const DISK_FREE_NO_ARCHIL = `this runner's data directory is not the server's, and the server keeps each run's folder on Archil (Mode 2) by the Archil settings in its environment, which this runner does not hold. Hand this runner the server's ${ARCHIL_SETTINGS_ENV.region} (and ${ARCHIL_SETTINGS_ENV.s3Url} and ${ARCHIL_SETTINGS_ENV.image} when the server has them), or save the Archil settings in the store.`;
|
|
84
|
+
/** Why a runner given a region without an S3 URL can't claim now, or undefined while it can. Such a runner reaches Archil
|
|
85
|
+
* at the region's S3 URL (archil-settings.ts ARCHIL_S3_URLS), and the server's may be another: the server is started with
|
|
86
|
+
* AGENTRUN_ARCHIL_S3_URL (its run-facing names say so, never the value, so one that is the region's own is refused too),
|
|
87
|
+
* or it is in Mode 2 by saved settings whose s3Url is not the runner's. Any runner, on the server's disk or not, on either
|
|
88
|
+
* store: a run's folder on Archil is reached by the runner and the server at one endpoint, or not claimed. */
|
|
89
|
+
export async function archilS3Refusal(store, env) {
|
|
90
|
+
if (envValue(env, ARCHIL_SETTINGS_ENV.region) === undefined || envValue(env, ARCHIL_SETTINGS_ENV.s3Url) !== undefined)
|
|
91
|
+
return undefined;
|
|
92
|
+
const names = await serverRunEnv(store);
|
|
93
|
+
if (names?.includes(ARCHIL_SETTINGS_ENV.region))
|
|
94
|
+
return names.includes(ARCHIL_SETTINGS_ENV.s3Url) ? ARCHIL_S3_URL_NOT_HELD : undefined;
|
|
95
|
+
const saved = await loadArchilSettings(store);
|
|
96
|
+
return saved !== undefined && saved.s3Url !== archilSettingsFromEnv(env)?.s3Url ? ARCHIL_S3_URL_NOT_HELD : undefined;
|
|
97
|
+
}
|
|
98
|
+
/** A runner's words while it is given a region without an S3 URL and the server's S3 URL may be another (archilS3Refusal). */
|
|
99
|
+
export const ARCHIL_S3_URL_NOT_HELD = `this runner is given ${ARCHIL_SETTINGS_ENV.region} without ${ARCHIL_SETTINGS_ENV.s3Url}, so it would reach Archil at its region's S3 URL, and the server's may be another (the server is started with ${ARCHIL_SETTINGS_ENV.s3Url}, or its saved Archil settings hold another s3Url): a run's folder is reached at the server's or not at all. Hand this runner the server's S3 URL as ${ARCHIL_SETTINGS_ENV.s3Url}.`;
|
|
82
100
|
/** How long a gate's answer is kept between polls (diskFreeGate): a change of mode reaches a runner within this. */
|
|
83
101
|
export const DISK_FREE_GATE_MS = 5_000;
|
|
84
|
-
/** The runner's claim gate (runner.ts claimGate) for a runner on `dataDir`: diskFreeRefusal, its
|
|
85
|
-
* DISK_FREE_GATE_MS between polls and read again when asked fresh. */
|
|
102
|
+
/** The runner's claim gate (runner.ts claimGate) for a runner on `dataDir`: archilS3Refusal, else diskFreeRefusal, its
|
|
103
|
+
* answer kept for DISK_FREE_GATE_MS between polls and read again when asked fresh. */
|
|
86
104
|
export function diskFreeGate(store, dataDir, env, storeKind, now = Date.now) {
|
|
87
105
|
let kept;
|
|
88
106
|
return async (fresh) => {
|
|
89
107
|
const at = now();
|
|
90
108
|
if (!fresh && kept && at - kept.at < DISK_FREE_GATE_MS)
|
|
91
109
|
return kept.words;
|
|
92
|
-
const words = await diskFreeRefusal(store, dataDir, env, storeKind);
|
|
110
|
+
const words = (await archilS3Refusal(store, env)) ?? (await diskFreeRefusal(store, dataDir, env, storeKind));
|
|
93
111
|
kept = { at, words };
|
|
94
112
|
return words;
|
|
95
113
|
};
|
|
@@ -93,4 +93,4 @@ export declare function openFeedbackRound(store: Pick<Store, "runs" | "agents">,
|
|
|
93
93
|
* round it asks for (openFeedbackRound), and only then marks the kept grade with that round and its steer. The grade is
|
|
94
94
|
* kept first, so the round's end reads it; the round is named last, so a reopen that fails (thrown, or a run that can't
|
|
95
95
|
* be opened again) leaves a grade naming none, never one claiming a round that didn't open. The grade as kept. */
|
|
96
|
-
export declare function keepGrade(store: Pick<Store, "runs" | "agents" | "
|
|
96
|
+
export declare function keepGrade(store: Pick<Store, "runs" | "agents" | "learning">, agentId: string, grade: Grade, label: string | undefined, canTurn?: (launch: RunLaunch) => boolean): Promise<Grade>;
|
|
@@ -144,7 +144,7 @@ export async function openFeedbackRound(store, grade, label, canTurn = () => tru
|
|
|
144
144
|
* kept first, so the round's end reads it; the round is named last, so a reopen that fails (thrown, or a run that can't
|
|
145
145
|
* be opened again) leaves a grade naming none, never one claiming a round that didn't open. The grade as kept. */
|
|
146
146
|
export async function keepGrade(store, agentId, grade, label, canTurn) {
|
|
147
|
-
const kept = await putGrade(store.
|
|
147
|
+
const kept = await putGrade(store.learning, agentId, { ...grade, feedback: null });
|
|
148
148
|
const opened = await openFeedbackRound(store, kept, label, canTurn);
|
|
149
|
-
return opened ? markGradeRound(store.
|
|
149
|
+
return opened ? markGradeRound(store.learning, agentId, kept, opened) : kept;
|
|
150
150
|
}
|