@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37
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 +298 -0
- package/README.md +417 -219
- package/dist/adapters.d.ts +12 -2
- package/dist/adapters.js +27 -2
- package/dist/agent-rows.d.ts +2 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +9 -4
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +79 -7
- package/dist/archil-settings.js +140 -14
- package/dist/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +12 -57
- package/dist/cap.js +20 -160
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +3 -33
- package/dist/cli.js +17 -26
- package/dist/composio-preset.d.ts +36 -0
- package/dist/composio-preset.js +179 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +48 -0
- package/dist/computer-calls.js +126 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +160 -0
- package/dist/computer-live.js +643 -0
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +38 -1
- package/dist/computer-view.d.ts +24 -2
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +297 -0
- package/dist/computers.d.ts +79 -12
- package/dist/computers.js +147 -28
- package/dist/console/assets/index-Cn6JX1uH.js +563 -0
- package/dist/console/assets/index-DRN62V5v.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.js +5 -5
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -24
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/github.d.ts +22 -2
- package/dist/github.js +42 -8
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-view.d.ts +3 -1
- package/dist/graph-view.js +25 -1
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +36 -2
- package/dist/host-tools.d.ts +9 -10
- package/dist/host-tools.js +7 -7
- package/dist/hosted-search.d.ts +5 -4
- package/dist/hosted-search.js +2 -7
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +11 -2
- package/dist/learn/check.js +124 -6
- package/dist/learn/commit.d.ts +43 -7
- package/dist/learn/commit.js +166 -22
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +37 -1
- package/dist/learn/general.d.ts +66 -0
- package/dist/learn/general.js +73 -0
- package/dist/learn/grade.d.ts +22 -1
- package/dist/learn/grade.js +107 -16
- package/dist/learn/index.d.ts +1 -1
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning.sh +12 -1
- package/dist/learn/notes.d.ts +3 -0
- package/dist/learn/notes.js +3 -0
- package/dist/learn/reflect.d.ts +14 -2
- package/dist/learn/reflect.js +54 -30
- package/dist/learn/skills.d.ts +37 -5
- package/dist/learn/skills.js +60 -7
- package/dist/learned-nodes.d.ts +6 -2
- package/dist/learned-workflow.d.ts +43 -9
- package/dist/learned-workflow.js +128 -37
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +32 -4
- package/dist/learning-routes.js +48 -12
- package/dist/learning-words.d.ts +9 -0
- package/dist/learning-words.js +12 -2
- package/dist/learning.d.ts +39 -19
- package/dist/learning.js +88 -46
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/mcp-gateway.d.ts +9 -0
- package/dist/mcp-gateway.js +60 -11
- package/dist/mcp-oauth.d.ts +57 -7
- package/dist/mcp-oauth.js +133 -18
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -3
- package/dist/mcp-probe.js +106 -29
- package/dist/mcp-secret-writes.js +8 -0
- package/dist/mcp-servers-store.d.ts +38 -15
- package/dist/mcp-servers-store.js +120 -23
- package/dist/mcp-store.d.ts +10 -4
- package/dist/mcp-store.js +17 -6
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +5 -5
- package/dist/model.js +29 -16
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +586 -64
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +1 -1
- package/dist/paid-calls.js +1 -1
- package/dist/place-offers.d.ts +96 -0
- package/dist/place-offers.js +202 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +21 -32
- package/dist/port-models.d.ts +2 -1
- package/dist/port-models.js +5 -3
- package/dist/print.d.ts +16 -9
- package/dist/print.js +15 -17
- package/dist/propose.d.ts +4 -0
- package/dist/propose.js +34 -11
- package/dist/provider.js +3 -2
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +1 -1
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-launch.d.ts +28 -3
- package/dist/run-launch.js +14 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +56 -44
- package/dist/run-view.d.ts +8 -5
- package/dist/run-view.js +18 -10
- package/dist/runnable.d.ts +2 -2
- package/dist/runnable.js +6 -2
- package/dist/runner/adapter-loop.d.ts +39 -8
- package/dist/runner/adapter-loop.js +770 -83
- package/dist/runner/adapter-run-spec.d.ts +36 -7
- package/dist/runner/adapter-run-spec.js +171 -37
- package/dist/runner/adapters/pi-computer.d.ts +7 -0
- package/dist/runner/adapters/pi-computer.js +43 -0
- package/dist/runner/adapters/pi.d.ts +20 -7
- package/dist/runner/adapters/pi.js +111 -26
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +26 -12
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +27 -3
- package/dist/runner/cli-run-spec.js +198 -74
- package/dist/runner/commands.d.ts +8 -2
- package/dist/runner/commands.js +31 -6
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +61 -0
- package/dist/runner/conformance/harness.d.ts +0 -1
- package/dist/runner/conformance/harness.js +87 -18
- package/dist/runner/conformance/subject.d.ts +1 -1
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +22 -12
- package/dist/runner/end-of-run.js +38 -16
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +6 -4
- package/dist/runner/harness-loops.js +16 -2
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +35 -6
- package/dist/runner/journal-kinds.js +20 -1
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +37 -1
- package/dist/runner/learning-end.js +115 -14
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +15 -5
- package/dist/runner/learning-loop.d.ts +139 -7
- package/dist/runner/learning-loop.js +369 -32
- package/dist/runner/learning-seed.d.ts +9 -0
- package/dist/runner/learning-seed.js +14 -1
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +16 -1
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +10 -2
- package/dist/runner/loop.js +22 -1
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +38 -6
- package/dist/runner/mcp-claim.d.ts +11 -4
- package/dist/runner/mcp-claim.js +140 -23
- package/dist/runner/mcp-github.d.ts +4 -2
- package/dist/runner/mcp-github.js +1 -8
- package/dist/runner/mcp-run.d.ts +6 -4
- package/dist/runner/mcp-run.js +16 -3
- package/dist/runner/metrics.d.ts +15 -2
- package/dist/runner/metrics.js +21 -2
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +60 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +19 -0
- package/dist/runner/reflect-hook.js +20 -8
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +231 -27
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +1 -1
- package/dist/runner/spec-holds.d.ts +8 -3
- package/dist/runner/spec-holds.js +12 -10
- package/dist/runner/store-port.d.ts +7 -2
- package/dist/runner/store-secrets.js +21 -4
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +190 -0
- package/dist/runner/workflow-host.d.ts +24 -3
- package/dist/runner/workflow-host.js +24 -4
- package/dist/runner/workflow-loop.d.ts +6 -3
- package/dist/runner/workflow-loop.js +9 -8
- package/dist/runner/workflow-spec.d.ts +39 -15
- package/dist/runner/workflow-spec.js +143 -40
- package/dist/runs-over-store.d.ts +16 -6
- package/dist/runs-over-store.js +145 -29
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +75 -63
- package/dist/server.js +712 -316
- package/dist/settings-wake.d.ts +21 -0
- package/dist/settings-wake.js +59 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +9 -2
- package/dist/store/agent-body.js +16 -8
- package/dist/store/command-wake.d.ts +12 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/deadline.js +9 -5
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +4 -4
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +15 -6
- package/dist/store/postgres/connection.js +9 -4
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +85 -13
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -47
- package/dist/store/sqlite/run-patch.d.ts +25 -7
- package/dist/store/sqlite/run-patch.js +58 -14
- package/dist/store/sqlite/store.js +331 -59
- package/dist/store/store.d.ts +330 -21
- package/dist/store/store.js +34 -2
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +2 -4
- package/dist/store-reads/cap.js +16 -7
- package/dist/store-reads/decisions.d.ts +3 -3
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +5 -4
- package/dist/store-reads/journal.js +118 -27
- package/dist/store-reads/learning.d.ts +34 -4
- package/dist/store-reads/learning.js +137 -23
- package/dist/store-reads/runs.d.ts +7 -5
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +70 -29
- package/dist/template-eval.js +8 -5
- package/dist/template-github-permissions.d.ts +22 -8
- package/dist/template-github-permissions.js +35 -15
- package/dist/templates.d.ts +64 -0
- package/dist/templates.js +101 -16
- package/dist/timeline/timeline.d.ts +30 -1
- package/dist/timeline/timeline.js +29 -13
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +27 -7
- package/dist/tool-budget.js +21 -9
- package/dist/tool-gate.d.ts +23 -10
- package/dist/tool-gate.js +60 -44
- package/dist/tool-plane.d.ts +46 -28
- package/dist/tool-plane.js +73 -31
- package/dist/tools.d.ts +31 -38
- package/dist/tools.js +117 -74
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +26 -6
- package/dist/trigger-signatures.js +44 -8
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +10 -6
- package/dist/triggers.js +37 -7
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/turns.js +16 -1
- package/dist/usage-lines.d.ts +1 -1
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +41 -4
- package/dist/web-fetch.d.ts +1 -1
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +147 -103
- package/dist/webhooks.js +564 -324
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +113 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +89 -0
- package/dist/workflow/node.js +101 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +32 -0
- package/dist/workflow/pi-versions.js +65 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +77 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +412 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow-run.d.ts +2 -2
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +11 -0
- package/dist/workspace/archil-claim.js +18 -10
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.js +2 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +32 -17
- package/dist/workspace/computer-deps.js +37 -14
- package/dist/workspace/computer-for-claim.d.ts +58 -13
- package/dist/workspace/computer-for-claim.js +267 -26
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +36 -56
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +5 -1
- package/dist/workspace/computer-ledger.js +11 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +37 -0
- package/dist/workspace/computer-script.js +138 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +7 -4
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
- package/dist/workspace/resolve-computer.d.ts +45 -11
- package/dist/workspace/resolve-computer.js +72 -14
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +35 -18
- package/dist/workspace/run-tools.js +24 -29
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace.js +1 -1
- package/package.json +19 -21
- package/templates/README.md +9 -6
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/templates/market-monitor/agent.md +1 -1
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -71
- package/dist/budget.js +0 -199
- package/dist/console/assets/index-B7NKTU8E.css +0 -1
- package/dist/console/assets/index-CXZMgJE7.js +0 -550
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/templates/code-review/rules/REVIEW.md +0 -41
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
// and does NO token refresh: it is the owner's create/preview/save/refresh(tools)/remove and the OAuth sign-in, and nothing
|
|
9
9
|
// a run's launch calls.
|
|
10
10
|
import { ApiError, invalid } from "./errors.js";
|
|
11
|
-
import { authOf, canonical, credentialMissing, listServer, marked, MAX_OAUTH_VALUE_BYTES, nameOf, notFound, oauthValueValid, pricesListed, pricesOf, scopesValid, urlOf, } from "./mcp-probe.js";
|
|
11
|
+
import { authOf, canonical, credentialInQuery, credentialInQueryWords, credentialMissing, savedOrGiven, shownUrl, listServer, marked, MAX_OAUTH_VALUE_BYTES, nameOf, notFound, oauthValueValid, pricesListed, pricesOf, scopesValid, urlOf, } from "./mcp-probe.js";
|
|
12
12
|
import { listMcpServers, openServerCredential, putPendingSignIn, removeMcpServer, removeMcpServerIfCredential, rewriteMcpServer, saveMcpServerIfCredential, takePendingSignIn } from "./mcp-store.js";
|
|
13
13
|
import { checkPrivateHosts, privateOAuthHosts, savePrivateOAuthHosts } from "./mcp-private-hosts.js";
|
|
14
14
|
// MCP's secret writes, registered with the one gate as the registry loads (the server's dispatch reads them).
|
|
15
15
|
import { credentialMark } from "./mcp-secret-writes.js";
|
|
16
16
|
import { secretMeta, secretName } from "./secret-writes.js";
|
|
17
|
-
import { issuerOf, MAX_PENDING, MCP_SETTINGS_PAGE, McpSignIns, reasonOf, SIGN_IN_AGAIN, systemNetwork } from "./mcp-oauth.js";
|
|
17
|
+
import { dialAt, issuerOf, LOOPBACK, MAX_PENDING, MCP_SETTINGS_PAGE, mcpServerAt, McpSignIns, reasonOf, SIGN_IN_AGAIN, systemNetwork } from "./mcp-oauth.js";
|
|
18
18
|
import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
|
|
19
19
|
import { GITHUB_MCP_ONLY, GITHUB_MCP_ORIGIN, githubMcpUrl } from "./github.js";
|
|
20
20
|
import { serverGate } from "./tool-plane.js";
|
|
@@ -23,6 +23,8 @@ import { unknownFields } from "./validate.js";
|
|
|
23
23
|
* each re-applied onto the row read again, before it is refused in words. */
|
|
24
24
|
const REWRITE_TRIES = 3;
|
|
25
25
|
const SCOPE_LIST = "scopes is a list of 1 to 32 OAuth scopes.";
|
|
26
|
+
/** The longest an MCP server's address check (its name's lookup) may take before a door answers. */
|
|
27
|
+
const ADDRESS_CHECK_MS = 15_000;
|
|
26
28
|
const MAX_VALUE_BYTES = MAX_OAUTH_VALUE_BYTES;
|
|
27
29
|
/** The row a conditional save wrote, or the refusal when it wrote nothing: the server's credential changed while the save
|
|
28
30
|
* listed its tools (another save, a sign-in or a removal landed), and writing would drop or undo it. */
|
|
@@ -71,6 +73,7 @@ function pendingOverStore(store, sealKey) {
|
|
|
71
73
|
export class McpServersOverStore {
|
|
72
74
|
store;
|
|
73
75
|
version;
|
|
76
|
+
network;
|
|
74
77
|
/** The connected GitHub App's installation token for listing a `github_app` server's tools as it is previewed, saved
|
|
75
78
|
* or refreshed (github-connection.ts tokenForListing); a run's own is minted at its claim (runner/mcp-claim.ts). Set by
|
|
76
79
|
* the server; absent, such a server's tools can't be listed (github_not_connected). */
|
|
@@ -83,9 +86,12 @@ export class McpServersOverStore {
|
|
|
83
86
|
/** The callbacks under way, which close() waits out before the server lets its data go. */
|
|
84
87
|
inflight = new Set();
|
|
85
88
|
stopped = new AbortController();
|
|
89
|
+
/** Whether this server is a local install (attach): only then may an MCP server's URL be on loopback. */
|
|
90
|
+
loopback = false;
|
|
86
91
|
constructor(store, env, version, network = systemNetwork) {
|
|
87
92
|
this.store = store;
|
|
88
93
|
this.version = version;
|
|
94
|
+
this.network = network;
|
|
89
95
|
// The server never starts without a seal key (seal-key.ts bootSealKey), so there is no keyless registry: every
|
|
90
96
|
// credential is kept sealed under it.
|
|
91
97
|
const sealKey = sealKeyOf(env[SEAL_KEY_ENV]);
|
|
@@ -94,10 +100,15 @@ export class McpServersOverStore {
|
|
|
94
100
|
this.sealKey = sealKey;
|
|
95
101
|
this.signIns = new McpSignIns(network, pendingOverStore(store, sealKey), () => privateOAuthHosts(store));
|
|
96
102
|
}
|
|
97
|
-
/** This server's address as a browser reaches it and where it listens.
|
|
98
|
-
|
|
103
|
+
/** This server's address as a browser reaches it and where it listens (McpServers.attach). `local`: whether its
|
|
104
|
+
* operator said this is a local install (ServeOptions.mcpLoopback, the CLI's AGENTRUN_MCP_ALLOW_LOOPBACK=1), the one kind
|
|
105
|
+
* of server an MCP server's URL may be on loopback for. Never inferred from where it listens: a hosted container
|
|
106
|
+
* listens on loopback behind its proxy too. Omitted, or never attached, it is not one. */
|
|
107
|
+
attach(base, listening, local) {
|
|
99
108
|
this.signIns.base = base.replace(/\/+$/, "");
|
|
100
109
|
this.signIns.listening = listening.replace(/\/+$/, "");
|
|
110
|
+
this.loopback = local === true;
|
|
111
|
+
this.signIns.loopback = this.loopback;
|
|
101
112
|
}
|
|
102
113
|
clientDocument() {
|
|
103
114
|
return this.signIns.clientDocument();
|
|
@@ -144,20 +155,46 @@ export class McpServersOverStore {
|
|
|
144
155
|
const name = String(body.name);
|
|
145
156
|
const kept = await this.need(name);
|
|
146
157
|
const url = new URL(kept.url);
|
|
147
|
-
|
|
158
|
+
const send = await this.reached(kept.auth, url, stop);
|
|
159
|
+
return marked(kept.url, await this.signInNoted(url, this.listServer(url, await this.withAppToken(kept.auth, url, (await this.opened(name, kept, "name")).headers, stop), send, stop), stop));
|
|
148
160
|
}
|
|
149
|
-
|
|
161
|
+
// `name` with a url: the saved server the form is editing. Its address as every read shows it (shownUrl), sent back
|
|
162
|
+
// unchanged, is the saved one here too (as save and sign-in map it): the browser never gets the real address back.
|
|
163
|
+
const { name: editing, ...asked } = body;
|
|
164
|
+
const saved = editing === undefined ? undefined : await this.store.mcp.server(String(editing));
|
|
165
|
+
const { url, auth } = this.admit({ ...asked, ...(asked.url !== undefined ? { url: savedOrGiven(asked.url, saved?.url) } : {}) });
|
|
150
166
|
// A github_app server's credential is a token of the App, minted here, as for a saved one: its static headers are optional.
|
|
151
|
-
|
|
167
|
+
// A per_run server's are optional too: they only list its tools, for a server that lists them only to a caller it knows.
|
|
168
|
+
if (auth.type !== "none" && auth.type !== "github_app" && auth.type !== "per_run" && !auth.headers)
|
|
152
169
|
throw invalid([credentialMissing(auth.type, "A preview needs the credential it is to connect with.")]);
|
|
153
|
-
|
|
170
|
+
const send = await this.reached(auth.type, url, stop);
|
|
171
|
+
return marked(url.href, await this.signInNoted(url, this.listServer(url, await this.withAppToken(auth.type, url, auth.headers ?? {}, stop), send, stop), stop));
|
|
172
|
+
}
|
|
173
|
+
/** `listing`, and when it is refused as a server that signs in with OAuth (auth_required, `auth: oauth`), whether that
|
|
174
|
+
* sign-in can start with no Client ID entered (`details.oauth.registration`, McpSignIns.registration), so the console
|
|
175
|
+
* asks for one up front. `stop`: the preview's, which cuts that discovery too. */
|
|
176
|
+
async signInNoted(url, listing, stop) {
|
|
177
|
+
try {
|
|
178
|
+
return await listing;
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
const details = error instanceof ApiError && error.code === "auth_required" ? error.extra.details : undefined;
|
|
182
|
+
if (details?.auth === "oauth") {
|
|
183
|
+
const registration = await this.signIns.registration(url, stop);
|
|
184
|
+
if (registration)
|
|
185
|
+
details.oauth = registration;
|
|
186
|
+
}
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
154
189
|
}
|
|
155
190
|
/** PUT: preview, then keep the server with the tools listed. A body with no credential keeps the sealed one, while the
|
|
156
191
|
* auth type and the URL's origin stay the same. */
|
|
157
192
|
async save(name, body, stop, checkedAgainst) {
|
|
158
193
|
nameOf(name);
|
|
159
|
-
const { url, auth, prices } = this.admit(body, true);
|
|
160
194
|
const was = await this.store.mcp.server(name);
|
|
195
|
+
// Its URL as every read shows it (shownUrl), sent back unchanged: the saved one.
|
|
196
|
+
const { url, auth, prices } = this.admit({ ...body, ...(body.url !== undefined ? { url: savedOrGiven(body.url, was?.url) } : {}) }, true);
|
|
197
|
+
const send = await this.reached(auth.type, url, stop);
|
|
161
198
|
// The credential this save may write over: the one the secret-write gate let it through against (`checkedAgainst`,
|
|
162
199
|
// its credentialMark), else the one read here. The write compares it in its own statement, after the listing's wait.
|
|
163
200
|
const against = checkedAgainst !== undefined ? checkedAgainst : credentialMark(was);
|
|
@@ -180,6 +217,9 @@ export class McpServersOverStore {
|
|
|
180
217
|
keeping = true;
|
|
181
218
|
}
|
|
182
219
|
}
|
|
220
|
+
else if (auth.type === "per_run") {
|
|
221
|
+
// Keeps no credential: the headers sent, if any, only list its tools now. Each run hands its own (mcp_auth).
|
|
222
|
+
}
|
|
183
223
|
else if (auth.type !== "none" && !headers) {
|
|
184
224
|
if (!was || was.auth !== auth.type)
|
|
185
225
|
throw invalid([credentialMissing(auth.type, `The server ${name} has no saved ${auth.type} credential to keep.`)]);
|
|
@@ -192,7 +232,7 @@ export class McpServersOverStore {
|
|
|
192
232
|
else if (auth.type !== "none") {
|
|
193
233
|
credential = { type: "headers", headers: headers };
|
|
194
234
|
}
|
|
195
|
-
const listed = await this.listServer(url, await this.withAppToken(auth.type, url, headers ?? {}, stop), stop);
|
|
235
|
+
const listed = await this.listServer(url, await this.withAppToken(auth.type, url, headers ?? {}, stop), send, stop);
|
|
196
236
|
const unlisted = Object.keys(prices ?? {}).filter((tool) => !listed.tools.some((listedTool) => listedTool.name === tool));
|
|
197
237
|
if (unlisted.length)
|
|
198
238
|
throw invalid(unlisted.map((tool) => ({ field: `prices.${tool}`, reason: "not_an_option", message: `The server ${name} lists no tool ${tool}; its tools are ${listed.tools.map((t) => t.name).join(", ") || "none"}.` })));
|
|
@@ -217,8 +257,9 @@ export class McpServersOverStore {
|
|
|
217
257
|
/** POST refresh: list the saved server's tools again, keep them, and say what was added, removed and changed. */
|
|
218
258
|
async refresh(name, stop) {
|
|
219
259
|
const was = await this.need(name);
|
|
260
|
+
const send = await this.reached(was.auth, new URL(was.url), stop);
|
|
220
261
|
const open = await this.opened(name, was, "name");
|
|
221
|
-
const listed = await this.listServer(new URL(was.url), await this.withAppToken(was.auth, new URL(was.url), open.headers, stop), stop);
|
|
262
|
+
const listed = await this.listServer(new URL(was.url), await this.withAppToken(was.auth, new URL(was.url), open.headers, stop), send, stop);
|
|
222
263
|
const before = new Map(was.tools.map((tool) => [tool.name, canonical(tool)]));
|
|
223
264
|
const after = new Map(listed.tools.map((tool) => [tool.name, canonical(tool)]));
|
|
224
265
|
// A refresh re-lists the tools and leaves the credential as it is (rewriteKeeping: a run's refreshed set kept meanwhile
|
|
@@ -260,20 +301,29 @@ export class McpServersOverStore {
|
|
|
260
301
|
}
|
|
261
302
|
/** DELETE. `checkedAgainst`: the credential the secret-write gate let a token's removal through against (one with
|
|
262
303
|
* none: removing it drops no secret); the row goes only while it is still that, in the store's one statement, so a
|
|
263
|
-
* credential saved meanwhile is never dropped by it.
|
|
304
|
+
* credential saved meanwhile is never dropped by it. An OAuth one's sign-in is then let go at its authorization server
|
|
305
|
+
* (its refresh token revoked, RFC 7009, where its metadata names a revocation_endpoint), behind the answer: best effort,
|
|
306
|
+
* never holding or failing the removal. A claimed run sees the removal at its next call (runner/mcp-claim.ts check). */
|
|
264
307
|
async remove(name, checkedAgainst) {
|
|
265
308
|
await this.need(name);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
309
|
+
// The credential revoked is the one the deleting statement saw (RETURNING): a run's refresh landing before it is in it,
|
|
310
|
+
// one landing after finds no row to keep. A sign-in kept as expired has no refresh token left to revoke.
|
|
311
|
+
const removed = checkedAgainst === undefined ? await removeMcpServer(this.store, this.sealKey, name)
|
|
312
|
+
: checkedAgainst === null ? undefined : await removeMcpServerIfCredential(this.store, this.sealKey, name, checkedAgainst);
|
|
313
|
+
if (checkedAgainst !== undefined && !removed)
|
|
269
314
|
changedMeanwhile(name, undefined);
|
|
270
315
|
await this.store.flush();
|
|
316
|
+
const open = removed?.opened;
|
|
317
|
+
const credential = open && "credential" in open && open.credential.type === "oauth" && !open.credential.expired ? open.credential : undefined;
|
|
318
|
+
if (credential && removed)
|
|
319
|
+
void this.track(this.signIns.revoke(credential.set, removed.url, this.stopped.signal));
|
|
271
320
|
}
|
|
272
321
|
/** POST .../{name}/oauth/start: `{url, scopes?, client_id?, client_secret?}`; answers the URL the owner opens. */
|
|
273
322
|
async oauthStart(name, body) {
|
|
274
323
|
nameOf(name);
|
|
275
324
|
const issues = unknownFields(body, ["url", "scopes", "client_id", "client_secret"]);
|
|
276
|
-
|
|
325
|
+
// Its URL as every read shows it (shownUrl), sent back unchanged: the saved one.
|
|
326
|
+
const url = urlOf(savedOrGiven(body.url, (await this.store.mcp.server(name))?.url), issues);
|
|
277
327
|
const { scopes, client_id, client_secret } = body;
|
|
278
328
|
if (scopes !== undefined && !scopesValid(scopes))
|
|
279
329
|
issues.push({ field: "scopes", reason: "invalid", message: SCOPE_LIST });
|
|
@@ -284,6 +334,8 @@ export class McpServersOverStore {
|
|
|
284
334
|
issues.push({ field: "client_id", reason: "missing", message: "A client_secret goes with the client_id it is the secret of." });
|
|
285
335
|
if (issues.length)
|
|
286
336
|
throw invalid(issues);
|
|
337
|
+
// The MCP server's own address first: its sign-in's discovery is sent there.
|
|
338
|
+
await this.reached("oauth", url);
|
|
287
339
|
const was = await this.store.mcp.server(name);
|
|
288
340
|
// A body with no client_id signs in again with the client kept in the sealed token set, for the same origin only.
|
|
289
341
|
const kept = typeof client_id !== "string" && was?.auth === "oauth" && new URL(was.url).origin === url.origin ? await this.openedSet(name, was) : undefined;
|
|
@@ -312,8 +364,10 @@ export class McpServersOverStore {
|
|
|
312
364
|
const error = query.get("error");
|
|
313
365
|
if (error)
|
|
314
366
|
return back(/^[a-z_]{1,64}$/.test(error) ? error : "sign_in_failed");
|
|
367
|
+
// Checked again before the code is spent: the owner's list may have changed since the start.
|
|
368
|
+
const send = await this.reached("oauth", new URL(entry.url), stop);
|
|
315
369
|
const set = await this.signIns.finish(entry, query.get("code") ?? "", query.get("iss") ?? undefined, stop);
|
|
316
|
-
const listed = await this.listServer(new URL(entry.url), { authorization: `Bearer ${set.tokens.access_token}` }, stop);
|
|
370
|
+
const listed = await this.listServer(new URL(entry.url), { authorization: `Bearer ${set.tokens.access_token}` }, send, stop);
|
|
317
371
|
const now = await this.store.mcp.server(entry.name);
|
|
318
372
|
// Saved, signed in to again or forgotten since this sign-in started: that stands.
|
|
319
373
|
if ((now ? saving(now) : null) !== entry.was)
|
|
@@ -334,9 +388,46 @@ export class McpServersOverStore {
|
|
|
334
388
|
return back(await reasonOf(error));
|
|
335
389
|
}
|
|
336
390
|
}
|
|
337
|
-
listServer(url, headers, stop) {
|
|
338
|
-
// The shared probe (mcp-probe.listServer), bound also to this server's own stop.
|
|
339
|
-
return listServer(url, headers, this.version, AbortSignal.any([this.stopped.signal, ...(stop ? [stop] : [])]));
|
|
391
|
+
listServer(url, headers, send, stop) {
|
|
392
|
+
// The shared probe (mcp-probe.listServer), bound also to this server's own stop, each request sent as `send` (reached).
|
|
393
|
+
return listServer(url, headers, this.version, AbortSignal.any([this.stopped.signal, ...(stop ? [stop] : [])]), send);
|
|
394
|
+
}
|
|
395
|
+
/** How a request to the MCP server at `url` goes, or a 422 on url before anything is sent to it (or a token minted for
|
|
396
|
+
* it): a github_app server anywhere but GitHub's hosted MCP (GITHUB_MCP_ONLY, as withAppToken says), and at it, as it
|
|
397
|
+
* is, since that one origin is this server's to name, never the owner's; any other server held to the address rule
|
|
398
|
+
* (mcp-oauth.ts mcpServerAt, the one an authorization server's endpoint is held to), with the private-network hosts the
|
|
399
|
+
* owner allows read now, loopback only for a local install. The fetch it answers dials the address checked. A name
|
|
400
|
+
* that does not resolve is the unreachable server it always was (424). */
|
|
401
|
+
async reached(type, url, stop) {
|
|
402
|
+
// A saved row's URL is held to the save's rule too: one with a credential in its query is refused, nothing sent.
|
|
403
|
+
const inQuery = credentialInQuery(url);
|
|
404
|
+
if (inQuery)
|
|
405
|
+
throw invalid([{ field: "url", reason: "invalid", message: credentialInQueryWords(inQuery) }]);
|
|
406
|
+
if (type === "github_app") {
|
|
407
|
+
if (!githubMcpUrl(url, this.appOrigin))
|
|
408
|
+
throw invalid([{ field: "url", reason: "not_allowed", message: GITHUB_MCP_ONLY }]);
|
|
409
|
+
return fetch;
|
|
410
|
+
}
|
|
411
|
+
// A URL on loopback as written, on a server its operator never said is a local install: refused, saying how to say so.
|
|
412
|
+
if (!this.loopback && LOOPBACK.test(url.hostname))
|
|
413
|
+
throw invalid([{ field: "url", reason: "not_allowed", message: loopbackWords(url.hostname) }]);
|
|
414
|
+
const signal = AbortSignal.any([AbortSignal.timeout(ADDRESS_CHECK_MS), this.stopped.signal, ...(stop ? [stop] : [])]);
|
|
415
|
+
let at;
|
|
416
|
+
try {
|
|
417
|
+
at = await mcpServerAt(url, signal, this.network, { own: this.signIns.own, allowed: await privateOAuthHosts(this.store), loopback: this.loopback });
|
|
418
|
+
}
|
|
419
|
+
catch (error) {
|
|
420
|
+
if (stop?.aborted || this.stopped.signal.aborted)
|
|
421
|
+
throw error;
|
|
422
|
+
// Its address check outlived its time: a name lookup that never answered.
|
|
423
|
+
throw new ApiError("upstream_failed", `Could not reach the MCP server at ${url.origin} (DNS lookup timed out after ${ADDRESS_CHECK_MS / 1000} s).`);
|
|
424
|
+
}
|
|
425
|
+
if ("refused" in at) {
|
|
426
|
+
if (at.unresolved)
|
|
427
|
+
throw new ApiError("upstream_failed", `Could not reach the MCP server at ${url.origin} (ENOTFOUND).`);
|
|
428
|
+
throw invalid([{ field: "url", reason: "not_allowed", message: `${at.refused.charAt(0).toUpperCase()}${at.refused.slice(1)}.` }]);
|
|
429
|
+
}
|
|
430
|
+
return dialAt(this.network, at.address);
|
|
340
431
|
}
|
|
341
432
|
async need(name) {
|
|
342
433
|
const row = await this.store.mcp.server(name);
|
|
@@ -346,7 +437,8 @@ export class McpServersOverStore {
|
|
|
346
437
|
}
|
|
347
438
|
/** The saved credential opened, or the refusal that asks for it again. */
|
|
348
439
|
async opened(name, row, field) {
|
|
349
|
-
// No credential kept: none for a server that takes none, nor for a github_app server with no static headers
|
|
440
|
+
// No credential kept: none for a server that takes none, nor for a github_app server with no static headers, nor for a
|
|
441
|
+
// per_run server (each run hands its own).
|
|
350
442
|
if (row.auth === "none" || row.sealed === null)
|
|
351
443
|
return { headers: {}, credential: { type: "headers", headers: {}, origin: new URL(row.url).origin } };
|
|
352
444
|
const open = await openServerCredential(this.store, this.sealKey, name);
|
|
@@ -374,7 +466,7 @@ export class McpServersOverStore {
|
|
|
374
466
|
const prices = (row.prices ?? undefined);
|
|
375
467
|
const listed = marked(row.url, { protocol: row.protocol ?? "unknown", server_info: row.serverInfo ?? null, ...(typeof row.instructions === "string" ? { instructions: row.instructions } : {}), tools });
|
|
376
468
|
const unmetered = tools.filter((tool) => !(prices && Object.hasOwn(prices, tool.name))).map((tool) => tool.name);
|
|
377
|
-
const opened = row.auth === "none" || (row.auth === "github_app" && row.sealed === null) ? null : await openServerCredential(this.store, this.sealKey, name);
|
|
469
|
+
const opened = row.auth === "none" || row.auth === "per_run" || (row.auth === "github_app" && row.sealed === null) ? null : await openServerCredential(this.store, this.sealKey, name);
|
|
378
470
|
const cred = opened && "credential" in opened ? opened.credential : undefined;
|
|
379
471
|
const set = cred?.type === "oauth" ? cred.set : undefined;
|
|
380
472
|
const expired = cred?.type === "oauth" && cred.expired === true;
|
|
@@ -384,7 +476,8 @@ export class McpServersOverStore {
|
|
|
384
476
|
const listedAt = new Date(row.listedAt ?? row.updatedAt).toISOString();
|
|
385
477
|
return {
|
|
386
478
|
name,
|
|
387
|
-
|
|
479
|
+
// Its origin, the path and query held as a secret (shownUrl): the whole URL is only ever sent to the server itself.
|
|
480
|
+
url: shownUrl(row.url),
|
|
388
481
|
...(prices && Object.keys(prices).length ? { prices } : {}),
|
|
389
482
|
...listed,
|
|
390
483
|
// Each priced tool's price in USD a call, as the owner saved them, on every read.
|
|
@@ -431,6 +524,10 @@ export class McpServersOverStore {
|
|
|
431
524
|
/** Which save of a server this is: a PUT or a sign-in makes a new one (its updated time moves), a refresh of its tools or
|
|
432
525
|
* token does not change the url. The staleness key an OAuth sign-in carries from start to callback. */
|
|
433
526
|
const saving = (row) => `${row.url} ${row.updatedAt}`;
|
|
527
|
+
/** The env that says this server is a local install (cli.ts), the one kind an MCP server may be on loopback for. */
|
|
528
|
+
export const MCP_ALLOW_LOOPBACK_ENV = "AGENTRUN_MCP_ALLOW_LOOPBACK";
|
|
529
|
+
/** What a URL on loopback says on a server that is not one, with how to make it one. */
|
|
530
|
+
export const loopbackWords = (host) => `${host} is this machine; set ${MCP_ALLOW_LOOPBACK_ENV}=1 when starting the server, only on a machine you alone use.`;
|
|
434
531
|
/** The owner's MCP registry over the one store. No load() is needed: every read goes to the store (the runner also writes
|
|
435
532
|
* the OAuth state), so a read is always current. */
|
|
436
533
|
export function mcpServersOverStore(store, env, version, network) {
|
package/dist/mcp-store.d.ts
CHANGED
|
@@ -54,14 +54,20 @@ export declare function rewriteMcpServer(store: {
|
|
|
54
54
|
}, seen: Uint8Array | null, { githubMcpOrigin }?: {
|
|
55
55
|
githubMcpOrigin?: string;
|
|
56
56
|
}): Promise<McpServerRow | undefined>;
|
|
57
|
-
/** The server's row goes
|
|
57
|
+
/** The server's row goes; what it held as it went (its address, its credential opened, as openServerCredential does), or
|
|
58
|
+
* undefined when there was no row. */
|
|
58
59
|
export declare function removeMcpServer(store: {
|
|
59
60
|
mcp: Pick<Mcp, "remove">;
|
|
60
|
-
}, name: string): Promise<
|
|
61
|
-
/** The server's row goes, only while its credential is still `expected` (Mcp.removeIfCredential).
|
|
61
|
+
}, sealKey: Buffer, name: string): Promise<RemovedMcpServer | undefined>;
|
|
62
|
+
/** The server's row goes, only while its credential is still `expected` (Mcp.removeIfCredential). Undefined when it is not. */
|
|
62
63
|
export declare function removeMcpServerIfCredential(store: {
|
|
63
64
|
mcp: Pick<Mcp, "removeIfCredential">;
|
|
64
|
-
}, name: string, expected: NonNullable<McpCredentialMark>): Promise<
|
|
65
|
+
}, sealKey: Buffer, name: string, expected: NonNullable<McpCredentialMark>): Promise<RemovedMcpServer | undefined>;
|
|
66
|
+
/** A removed row: its address and its credential opened (§7), the credential the one the deleting statement saw. */
|
|
67
|
+
export type RemovedMcpServer = {
|
|
68
|
+
url: string;
|
|
69
|
+
opened: OpenedMcpCredential | undefined;
|
|
70
|
+
};
|
|
65
71
|
/** Every saved server's row, by name (its credential stays sealed). */
|
|
66
72
|
export declare function listMcpServers(store: {
|
|
67
73
|
mcp: Pick<Mcp, "servers">;
|
package/dist/mcp-store.js
CHANGED
|
@@ -70,14 +70,25 @@ export async function rewriteMcpServer(store, server, seen, { githubMcpOrigin =
|
|
|
70
70
|
...(server.listedAt !== undefined ? { listedAt: server.listedAt } : {}), ...(server.updatedAt !== undefined ? { updatedAt: server.updatedAt } : {}),
|
|
71
71
|
}, seen);
|
|
72
72
|
}
|
|
73
|
-
/** The server's row goes
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
/** The server's row goes; what it held as it went (its address, its credential opened, as openServerCredential does), or
|
|
74
|
+
* undefined when there was no row. */
|
|
75
|
+
export async function removeMcpServer(store, sealKey, name) {
|
|
76
|
+
return removedServer(sealKey, name, await store.mcp.remove(name));
|
|
76
77
|
}
|
|
77
|
-
/** The server's row goes, only while its credential is still `expected` (Mcp.removeIfCredential).
|
|
78
|
-
export async function removeMcpServerIfCredential(store, name, expected) {
|
|
79
|
-
return store.mcp.removeIfCredential(name, expected);
|
|
78
|
+
/** The server's row goes, only while its credential is still `expected` (Mcp.removeIfCredential). Undefined when it is not. */
|
|
79
|
+
export async function removeMcpServerIfCredential(store, sealKey, name, expected) {
|
|
80
|
+
return removedServer(sealKey, name, await store.mcp.removeIfCredential(name, expected));
|
|
80
81
|
}
|
|
82
|
+
const removedServer = (sealKey, name, removed) => {
|
|
83
|
+
if (!removed)
|
|
84
|
+
return undefined;
|
|
85
|
+
try {
|
|
86
|
+
return { url: removed.url, opened: openMcpCredential(sealKey, { name, url: removed.url, sealed: removed.sealed }) };
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return { url: removed.url, opened: undefined };
|
|
90
|
+
}
|
|
91
|
+
};
|
|
81
92
|
/** Every saved server's row, by name (its credential stays sealed). */
|
|
82
93
|
export async function listMcpServers(store) {
|
|
83
94
|
return store.mcp.servers();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The current models a person may pick, by vendor, in the vendor's own ids (Anthropic's dashes; OpenRouter's dotted name
|
|
2
|
+
* for the same model is derived, provider.ts openRouterName). The everyday model first: it is the example a refusal gives.
|
|
3
|
+
* A candidate a harness cannot run on this server (one pi-ai's catalog does not list) is dropped before it is served
|
|
4
|
+
* (harness.ts harnessOffers). */
|
|
5
|
+
export declare const PICKABLE: readonly {
|
|
6
|
+
vendor: string;
|
|
7
|
+
ids: readonly string[];
|
|
8
|
+
}[];
|
|
9
|
+
/** `vendor`'s model `id` in the form this server runs it: `vendor/id` on the vendor's own key, or through OpenRouter
|
|
10
|
+
* (`openrouter/vendor/id`, Anthropic's id in OpenRouter's dotted name) when OpenRouter's key is the only one here. */
|
|
11
|
+
export declare function formOf(env: NodeJS.ProcessEnv, vendor: string, id: string): string;
|
|
12
|
+
/** The models offered for `harness` on this server, each in the form it takes, before the harness's own catalog is asked
|
|
13
|
+
* (harness.ts harnessOffers drops those it does not run). Behind serve's gateway every id is the gateway's own string, so
|
|
14
|
+
* the host's tier models stand for what it runs; with the faux model none is offered. */
|
|
15
|
+
export declare function pickerCandidates(env: NodeJS.ProcessEnv, harness: string): string[];
|
|
16
|
+
/** The model `given` most likely means, in the form this harness takes, or undefined when none is obvious: the same id
|
|
17
|
+
* with a dot for a dash or the other way, a missing provider, or a name without its `claude-` ("Sonnet 5.5"). */
|
|
18
|
+
export declare function likelyModel(env: NodeJS.ProcessEnv, harness: string, given: string): string | undefined;
|
|
19
|
+
/** What a refusal says of a model named in a form `harness` does not take: the form it takes, with examples this server
|
|
20
|
+
* can run, and the likely id when one is obvious. `host`: the name is the server's own default, not the revision's. No
|
|
21
|
+
* word of the catalog behind it: a person's words. */
|
|
22
|
+
export declare function modelFormWhy(env: NodeJS.ProcessEnv, harness: string, named: string, host: boolean): string;
|
|
23
|
+
/** "On pi, a model is <provider>/<model id>, like A or B": the forms this server can run, each of the harness's first
|
|
24
|
+
* vendor's everyday model, the vendor's own and OpenRouter's. Only the forms a key here runs; with neither key both, since
|
|
25
|
+
* either key makes one run. */
|
|
26
|
+
export declare function modelShape(env: NodeJS.ProcessEnv, harness: string): string;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// The models a person is offered to pick for each harness, in the exact form that harness takes, and the words a refusal
|
|
2
|
+
// uses when a model is named in a form it does not take. One list, served in capabilities (`harnesses[].models`) and read
|
|
3
|
+
// by the console's Model picker, so the picker, the save's refusal and a run's refusal never name different forms.
|
|
4
|
+
// A leaf of model.ts and provider.ts (it reads their tables only when called, never as it loads).
|
|
5
|
+
import { ADAPTER_FACTS } from "./adapter-facts.js";
|
|
6
|
+
import { FAUX_ENV, MODEL_KEYS } from "./model.js";
|
|
7
|
+
import { openRouterName } from "./provider.js";
|
|
8
|
+
import { WIRES } from "./wires.js";
|
|
9
|
+
/** The current models a person may pick, by vendor, in the vendor's own ids (Anthropic's dashes; OpenRouter's dotted name
|
|
10
|
+
* for the same model is derived, provider.ts openRouterName). The everyday model first: it is the example a refusal gives.
|
|
11
|
+
* A candidate a harness cannot run on this server (one pi-ai's catalog does not list) is dropped before it is served
|
|
12
|
+
* (harness.ts harnessOffers). */
|
|
13
|
+
export const PICKABLE = Object.freeze([
|
|
14
|
+
{ vendor: "anthropic", ids: Object.freeze(["claude-sonnet-5-5", "claude-opus-5-5", "claude-haiku-5-5", "claude-fable-5-2"]) },
|
|
15
|
+
{ vendor: "openai", ids: Object.freeze(["gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-luna"]) },
|
|
16
|
+
]);
|
|
17
|
+
/** The vendors whose models `harness` runs: pi any; an adapter harness, its wire's vendor. */
|
|
18
|
+
const vendorsOf = (harness) => {
|
|
19
|
+
const facts = ADAPTER_FACTS.find((f) => f.id === harness);
|
|
20
|
+
return facts ? [WIRES[facts.wire].vendor] : PICKABLE.map((p) => p.vendor);
|
|
21
|
+
};
|
|
22
|
+
/** `vendor`'s model `id` in the form this server runs it: `vendor/id` on the vendor's own key, or through OpenRouter
|
|
23
|
+
* (`openrouter/vendor/id`, Anthropic's id in OpenRouter's dotted name) when OpenRouter's key is the only one here. */
|
|
24
|
+
export function formOf(env, vendor, id) {
|
|
25
|
+
const row = MODEL_KEYS.find((r) => r.id === vendor);
|
|
26
|
+
if (row && !env[row.field] && env.OPENROUTER_API_KEY)
|
|
27
|
+
return `openrouter/${vendor}/${vendor === "anthropic" ? openRouterName(id) : id}`;
|
|
28
|
+
return `${vendor}/${id}`;
|
|
29
|
+
}
|
|
30
|
+
/** The models offered for `harness` on this server, each in the form it takes, before the harness's own catalog is asked
|
|
31
|
+
* (harness.ts harnessOffers drops those it does not run). Behind serve's gateway every id is the gateway's own string, so
|
|
32
|
+
* the host's tier models stand for what it runs; with the faux model none is offered. */
|
|
33
|
+
export function pickerCandidates(env, harness) {
|
|
34
|
+
if (env[FAUX_ENV])
|
|
35
|
+
return [];
|
|
36
|
+
// The gateway serves the harnesses whose wire goes through it (pi, and the OpenAI Responses wire: providerFor); the
|
|
37
|
+
// Anthropic Messages wire never does, so Claude is offered Anthropic's models on its own key.
|
|
38
|
+
const facts = ADAPTER_FACTS.find((f) => f.id === harness);
|
|
39
|
+
if (env.AGENT_MODEL_BASE_URL && facts?.wire !== "anthropic-messages")
|
|
40
|
+
return [...new Set([env.AGENT_MODEL, env.AGENT_MODEL_FAST, env.AGENT_MODEL_STRONG].filter((id) => Boolean(id)))];
|
|
41
|
+
const vendors = vendorsOf(harness);
|
|
42
|
+
return PICKABLE.filter((p) => vendors.includes(p.vendor)).flatMap((p) => p.ids.map((id) => formOf(env, p.vendor, id)));
|
|
43
|
+
}
|
|
44
|
+
/** A model id with its spelling taken out (case, spaces, dots, dashes), and the provider's segments off. */
|
|
45
|
+
const spelled = (given) => (given.split("/").pop() ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
46
|
+
/** The model `given` most likely means, in the form this harness takes, or undefined when none is obvious: the same id
|
|
47
|
+
* with a dot for a dash or the other way, a missing provider, or a name without its `claude-` ("Sonnet 5.5"). */
|
|
48
|
+
export function likelyModel(env, harness, given) {
|
|
49
|
+
const wanted = spelled(given);
|
|
50
|
+
if (!wanted)
|
|
51
|
+
return undefined;
|
|
52
|
+
const vendors = vendorsOf(harness);
|
|
53
|
+
for (const { vendor, ids } of PICKABLE) {
|
|
54
|
+
if (!vendors.includes(vendor))
|
|
55
|
+
continue;
|
|
56
|
+
const id = ids.find((each) => spelled(each) === wanted || spelled(each).endsWith(`-${wanted}`));
|
|
57
|
+
if (id)
|
|
58
|
+
return formOf(env, vendor, id);
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
/** What a refusal says of a model named in a form `harness` does not take: the form it takes, with examples this server
|
|
63
|
+
* can run, and the likely id when one is obvious. `host`: the name is the server's own default, not the revision's. No
|
|
64
|
+
* word of the catalog behind it: a person's words. */
|
|
65
|
+
export function modelFormWhy(env, harness, named, host) {
|
|
66
|
+
const likely = likelyModel(env, harness, named);
|
|
67
|
+
const subject = host ? `The server's default model ${named} is not one` : `${named} is not a model`;
|
|
68
|
+
return `${modelShape(env, harness)}: ${subject} ${harness} runs here.${likely && likely !== named ? ` Did you mean ${likely}?` : ""}`;
|
|
69
|
+
}
|
|
70
|
+
/** "On pi, a model is <provider>/<model id>, like A or B": the forms this server can run, each of the harness's first
|
|
71
|
+
* vendor's everyday model, the vendor's own and OpenRouter's. Only the forms a key here runs; with neither key both, since
|
|
72
|
+
* either key makes one run. */
|
|
73
|
+
export function modelShape(env, harness) {
|
|
74
|
+
const first = PICKABLE.find((p) => vendorsOf(harness).includes(p.vendor));
|
|
75
|
+
const id = first.ids[0];
|
|
76
|
+
const own = Boolean(env[MODEL_KEYS.find((r) => r.id === first.vendor).field]);
|
|
77
|
+
const router = Boolean(env.OPENROUTER_API_KEY);
|
|
78
|
+
const shown = [...(own || !router ? [`${first.vendor}/${id}`] : []), ...(router || !own ? [`openrouter/${first.vendor}/${first.vendor === "anthropic" ? openRouterName(id) : id}`] : [])];
|
|
79
|
+
return `On ${harness}, a model is <provider>/<model id>, like ${shown.join(" or ")}`;
|
|
80
|
+
}
|
package/dist/model.d.ts
CHANGED
|
@@ -15,8 +15,7 @@ export declare const withoutFaux: (env: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;
|
|
|
15
15
|
export declare const FAUX_UPSTREAM_ENV = "AGENTRUN_SERVE_FAUX_UPSTREAM";
|
|
16
16
|
/** The model the server's keys give a run that names none (hostModel at the run's launch, from every key the server
|
|
17
17
|
* holds), passed to its child as its effort is: behind a gateway the run holds the gateway's key alone, never the key
|
|
18
|
-
* that names its default (runs.ts). A model id, never a secret, so its name has no secret's segment
|
|
19
|
-
* secret-name rule): a harness's log keeps it (adapters.ts harnessLog). */
|
|
18
|
+
* that names its default (runs.ts). A model id, never a secret, so its name has no secret's segment: a harness's log keeps it (adapters.ts harnessLog). */
|
|
20
19
|
export declare const DEFAULT_MODEL_ENV = "AGENTRUN_SERVE_DEFAULT_MODEL";
|
|
21
20
|
export declare const MODEL_PROVIDER = "agent-model";
|
|
22
21
|
export declare const EFFORTS: readonly ["low", "medium", "high"];
|
|
@@ -150,11 +149,12 @@ export type FauxHelpers = {
|
|
|
150
149
|
/** The models for a run, and its model of each tier it uses and of no other: an agentic revision's `ref` (or the
|
|
151
150
|
* default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
|
|
152
151
|
* The faux module's replies, the gateway in the environment, or pi-ai's providers. `unpriced`: the ids of its models
|
|
153
|
-
* serve has no price for (a gateway model the catalog does not list, with no price set), which a cap cannot be kept on.
|
|
154
|
-
|
|
152
|
+
* serve has no price for (a gateway model the catalog does not list, with no price set), which a cap cannot be kept on.
|
|
153
|
+
* `tierRefs`: a model named for another tier (a subagent's model_tiers), chosen for it in place of the host's. */
|
|
154
|
+
export declare function runModels(env: NodeJS.ProcessEnv, ref: string | PinnedModel | undefined, tiers?: readonly Tier[], harness?: string, tierRefs?: Readonly<Partial<Record<Tier, string>>>): Promise<{
|
|
155
155
|
models: import("@earendil-works/pi-ai").MutableModels;
|
|
156
156
|
model: ModelRef | undefined;
|
|
157
|
-
byTier: Map<"
|
|
157
|
+
byTier: Map<"default" | "fast" | "strong", ModelRef>;
|
|
158
158
|
unpriced: Set<string>;
|
|
159
159
|
}>;
|
|
160
160
|
/** The run's model and pi-ai's catalog that prices it, where its harness's model is chosen on its wire's own settings (its
|
package/dist/model.js
CHANGED
|
@@ -9,6 +9,7 @@ import { pathToFileURL } from "node:url";
|
|
|
9
9
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
10
10
|
import { HARNESS_TABLE_ENV, harnessOf } from "./harness-table.js";
|
|
11
11
|
import { gatewayBase } from "./provider.js";
|
|
12
|
+
import { modelFormWhy } from "./model-form.js";
|
|
12
13
|
// Leaves, which the key rows below read as this module loads, in any import order (wires.ts, adapter-facts.ts).
|
|
13
14
|
import { ADAPTER_FACTS } from "./adapter-facts.js";
|
|
14
15
|
import { WIRES } from "./wires.js";
|
|
@@ -27,8 +28,7 @@ export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filte
|
|
|
27
28
|
export const FAUX_UPSTREAM_ENV = "AGENTRUN_SERVE_FAUX_UPSTREAM";
|
|
28
29
|
/** The model the server's keys give a run that names none (hostModel at the run's launch, from every key the server
|
|
29
30
|
* holds), passed to its child as its effort is: behind a gateway the run holds the gateway's key alone, never the key
|
|
30
|
-
* that names its default (runs.ts). A model id, never a secret, so its name has no secret's segment
|
|
31
|
-
* secret-name rule): a harness's log keeps it (adapters.ts harnessLog). */
|
|
31
|
+
* that names its default (runs.ts). A model id, never a secret, so its name has no secret's segment: a harness's log keeps it (adapters.ts harnessLog). */
|
|
32
32
|
export const DEFAULT_MODEL_ENV = "AGENTRUN_SERVE_DEFAULT_MODEL";
|
|
33
33
|
export const MODEL_PROVIDER = "agent-model";
|
|
34
34
|
export const EFFORTS = ["low", "medium", "high"];
|
|
@@ -56,7 +56,7 @@ export const MODEL_KEYS = Object.freeze([
|
|
|
56
56
|
{ id: "anthropic", label: "Anthropic", field: "ANTHROPIC_API_KEY", model: "anthropic/claude-sonnet-5-5", harnesses: onVendor("anthropic") },
|
|
57
57
|
{ id: "openai", label: "OpenAI", field: "OPENAI_API_KEY", model: "openai/gpt-6.1-sol", harnesses: onVendor("openai") },
|
|
58
58
|
// OpenRouter serves both wires: every harness runs on its key, an adapter harness on its wire's vendor's model there.
|
|
59
|
-
{ id: "openrouter", label: "OpenRouter", field: "OPENROUTER_API_KEY", model: "openrouter/openai/gpt-6-sol", harnesses: [DEFAULT_HARNESS, ...ADAPTER_FACTS.map((facts) => facts.id)], byVendor: { anthropic: "anthropic/claude-sonnet-5.5", openai: "openai/gpt-6-sol" } },
|
|
59
|
+
{ id: "openrouter", label: "OpenRouter", field: "OPENROUTER_API_KEY", model: "openrouter/openai/gpt-6.1-sol", harnesses: [DEFAULT_HARNESS, ...ADAPTER_FACTS.map((facts) => facts.id)], byVendor: { anthropic: "anthropic/claude-sonnet-5.5", openai: "openai/gpt-6.1-sol" } },
|
|
60
60
|
]);
|
|
61
61
|
/** pi, and the adapter harnesses whose wire (their facts') runs `vendor`'s models: those that talk to its own API. */
|
|
62
62
|
function onVendor(vendor) {
|
|
@@ -166,21 +166,24 @@ export async function chooseModel(env, ref, tier = "default", harness = DEFAULT_
|
|
|
166
166
|
return { why: `${none}: name the gateway's model in AGENT_MODEL where AgentRun starts, or add a model key in Settings → Model keys.`, host: true, needs: "key" };
|
|
167
167
|
// A revision's model, and a key's default (MODEL_KEYS: "provider/model"), go as the gateway takes its ids (bare: the
|
|
168
168
|
// part after the provider), that provider pricing them; the host's own AGENT_MODEL or tier id goes as configured.
|
|
169
|
-
|
|
169
|
+
// A name equal to one of the host's configured ids (the picker lists them: model-form.ts pickerCandidates) is that
|
|
170
|
+
// host id whoever names it, so a revision that picks it is sent what the host configured, never a cut of it.
|
|
171
|
+
const configured = [env.AGENT_MODEL, env.AGENT_MODEL_FAST, env.AGENT_MODEL_STRONG].includes(named);
|
|
172
|
+
const id = ref ?? (configured ? undefined : named);
|
|
170
173
|
const slash = id?.indexOf("/") ?? -1;
|
|
171
|
-
const sent = id && env.AGENT_MODEL_GATEWAY_IDS === "bare" ? id.slice(slash + 1) : named;
|
|
174
|
+
const sent = id && !configured && env.AGENT_MODEL_GATEWAY_IDS === "bare" ? id.slice(slash + 1) : named;
|
|
172
175
|
return { model: { provider: MODEL_PROVIDER, modelId: sent }, ...(id && slash > 0 ? { namedProvider: id.slice(0, slash) } : {}) };
|
|
173
176
|
}
|
|
174
177
|
if (!named)
|
|
175
178
|
return { why: `${none}: ${ADD_A_KEY}`, host: true, needs: "key" };
|
|
176
179
|
const slash = named.indexOf("/");
|
|
177
180
|
if (slash < 1)
|
|
178
|
-
return { why:
|
|
181
|
+
return { why: modelFormWhy(env, harness, named, ref === undefined), host: ref === undefined, needs: "model" };
|
|
179
182
|
const [provider, modelId] = [named.slice(0, slash), named.slice(slash + 1)];
|
|
180
183
|
const models = await providerModels(env);
|
|
181
184
|
const model = models.getModel(provider, modelId);
|
|
182
185
|
if (!model)
|
|
183
|
-
return { why:
|
|
186
|
+
return { why: modelFormWhy(env, harness, named, ref === undefined), host: ref === undefined, needs: "model" };
|
|
184
187
|
// A gateway ANTHROPIC_BASE_URL names that a key may not go to (gatewayBase): no Anthropic model runs, by its words.
|
|
185
188
|
const refused = provider === "anthropic" ? anthropicRefusal(models) : undefined;
|
|
186
189
|
if (refused)
|
|
@@ -250,6 +253,7 @@ export const PROVIDER_KEYS = {
|
|
|
250
253
|
"qwen-token-plan": ["QWEN_TOKEN_PLAN_API_KEY"],
|
|
251
254
|
"qwen-token-plan-cn": ["QWEN_TOKEN_PLAN_CN_API_KEY"],
|
|
252
255
|
"qwen-token-plan-individual": ["QWEN_TOKEN_PLAN_API_KEY"],
|
|
256
|
+
"qwen-token-plan-individual-cn": ["QWEN_TOKEN_PLAN_CN_API_KEY"],
|
|
253
257
|
radius: ["RADIUS_API_KEY"],
|
|
254
258
|
together: ["TOGETHER_API_KEY"],
|
|
255
259
|
typesafe: ["TYPESAFE_API_KEY"],
|
|
@@ -286,15 +290,16 @@ export function thinkingLevel(value) {
|
|
|
286
290
|
/** The models for a run, and its model of each tier it uses and of no other: an agentic revision's `ref` (or the
|
|
287
291
|
* default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
|
|
288
292
|
* The faux module's replies, the gateway in the environment, or pi-ai's providers. `unpriced`: the ids of its models
|
|
289
|
-
* serve has no price for (a gateway model the catalog does not list, with no price set), which a cap cannot be kept on.
|
|
290
|
-
|
|
293
|
+
* serve has no price for (a gateway model the catalog does not list, with no price set), which a cap cannot be kept on.
|
|
294
|
+
* `tierRefs`: a model named for another tier (a subagent's model_tiers), chosen for it in place of the host's. */
|
|
295
|
+
export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT_HARNESS, tierRefs = {}) {
|
|
291
296
|
const ai = await import("@earendil-works/pi-ai");
|
|
292
297
|
const { createModels, createProvider } = await import("@earendil-works/pi-ai/models");
|
|
293
298
|
const faux = env[FAUX_ENV];
|
|
294
299
|
const byTier = new Map();
|
|
295
300
|
const namedBy = new Map();
|
|
296
301
|
for (const tier of new Set(tiers)) {
|
|
297
|
-
const chosen = await chooseModel(env, tier === "default" ? ref :
|
|
302
|
+
const chosen = await chooseModel(env, tier === "default" ? ref : tierRefs[tier], tier, harness);
|
|
298
303
|
if ("why" in chosen)
|
|
299
304
|
throw new Error(chosen.why);
|
|
300
305
|
byTier.set(tier, chosen.model);
|
|
@@ -598,12 +603,14 @@ export function catalogPrice(catalog, id, named) {
|
|
|
598
603
|
return catalogEntries(catalog, id, undefined);
|
|
599
604
|
return catalogEntries(catalog, id.slice(slash + 1), id.slice(0, slash));
|
|
600
605
|
}
|
|
601
|
-
/** The forms of `id` with its version's separators written the other way: each digit-dash-digit as a dot (gpt-
|
|
602
|
-
* gpt-
|
|
603
|
-
* claude-haiku-
|
|
606
|
+
/** The forms of `id` with its version's separators written the other way: each digit-dash-digit as a dot (gpt-6-1-terra,
|
|
607
|
+
* gpt-6.1-terra; pair by pair, so llama-3-1-8b is llama-3.1-8b), and each digit-dot-digit as a dash (claude-haiku-5.5,
|
|
608
|
+
* claude-haiku-5-5). Not `id` itself. */
|
|
604
609
|
const flippedForms = (id) => [...new Set([id.replace(/(\d)-(\d)/g, "$1.$2"), id.replace(/(\d)\.(\d)/g, "$1-$2")])].filter((form) => form !== id);
|
|
605
610
|
/** `id`'s price in `catalog` (listedPrice): its own entries' metered price when the catalog lists one; else its flipped
|
|
606
|
-
* forms' (flippedForms), only when every metered entry they hold has one
|
|
611
|
+
* forms' (flippedForms), only when every metered entry they hold has one base price (input, output, cacheRead,
|
|
612
|
+
* cacheWrite; a long-context `tiers` table is not part of the comparison), the entry that carries `tiers` when one does
|
|
613
|
+
* (a long prompt is priced at the higher tier, erring high; entries with different `tiers` tables stay unpriced), else the first; else the metered price a gateway lists
|
|
607
614
|
* under a vendor's id for it (`<vendor>/<id>`, the named vendor's first: pi-ai lists the bare id of some models only
|
|
608
615
|
* under subscription plans, at $0, and the gateways that meter them under the vendor's). A flip that finds different
|
|
609
616
|
* prices leaves the model unpriced, and so does an id with no metered entry anywhere (#2339: a plan's $0 never prices a
|
|
@@ -615,8 +622,14 @@ function catalogEntries(catalog, id, named) {
|
|
|
615
622
|
return listed;
|
|
616
623
|
const flipped = flippedForms(id).flatMap((form) => (catalog.get(form) ?? []).filter(({ cost }) => cost.input + cost.output > 0));
|
|
617
624
|
if (flipped.length) {
|
|
618
|
-
const
|
|
619
|
-
|
|
625
|
+
const base = ({ input, output, cacheRead, cacheWrite }) => JSON.stringify([input, output, cacheRead, cacheWrite]);
|
|
626
|
+
const one = base(flipped[0].cost);
|
|
627
|
+
if (!flipped.every((entry) => base(entry.cost) === one))
|
|
628
|
+
return undefined;
|
|
629
|
+
const tiered = flipped.filter((entry) => entry.cost.tiers?.length);
|
|
630
|
+
if (tiered.some((entry) => JSON.stringify(entry.cost.tiers) !== JSON.stringify(tiered[0].cost.tiers)))
|
|
631
|
+
return undefined;
|
|
632
|
+
return (tiered[0] ?? flipped[0]).cost;
|
|
620
633
|
}
|
|
621
634
|
return vendorPrice(catalog, id, named);
|
|
622
635
|
}
|
package/dist/openapi.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export declare const UNSUPPORTED: Readonly<Record<string, string>>;
|
|
|
9
9
|
* run). They are left out of the served document, so no client is generated for them, and their paths answer 404.
|
|
10
10
|
* Capabilities say each is off (home.export, home.import, runs.kill). */
|
|
11
11
|
export declare const NOT_SERVED: readonly string[];
|
|
12
|
+
/** What a preview's tool list is (#84): the server's offer, listed with this credential, never what the credential may do. */
|
|
13
|
+
export declare const MCP_PREVIEW_SCOPE = "The tools are what the server offers, not what this credential allows: a read-only token still lists its write tools. A call the credential can't make is refused by the MCP server when a run makes it.";
|
|
12
14
|
/** The RUN_FIELDS every run's view and summary hold (runs.ts): required, beside the contract's. */
|
|
13
15
|
export declare const RUN_FIELDS_SENT: string[];
|
|
14
16
|
/** The capabilities every answer carries beside the contract's required ones (server.ts capabilitiesWith). */
|