@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.36
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 +263 -0
- package/README.md +339 -179
- package/dist/adapters.d.ts +15 -2
- package/dist/adapters.js +34 -2
- package/dist/agent-rows.d.ts +3 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +25 -5
- 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 +90 -8
- package/dist/archil-settings.js +150 -14
- 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/bash-read-only.d.ts +13 -0
- package/dist/bash-read-only.js +77 -0
- 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 +2 -2
- package/dist/browser-cost.js +6 -4
- 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 +19 -44
- package/dist/cap.js +31 -77
- package/dist/cli.js +36 -27
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -57
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +8 -5
- package/dist/computer-setting.js +91 -26
- package/dist/computer-view.d.ts +11 -2
- package/dist/computer-view.js +2 -1
- package/dist/computers.d.ts +54 -8
- package/dist/computers.js +101 -22
- package/dist/console/assets/index-BI4Byidu.js +550 -0
- package/dist/console/assets/index-C19gUF2n.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-cap.d.ts +7 -29
- package/dist/decision-cap.js +3 -94
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +8 -5
- package/dist/explain.js +3 -1
- package/dist/faux-computers.js +4 -0
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.js +25 -7
- package/dist/github-faux.d.ts +26 -0
- package/dist/github-faux.js +76 -0
- package/dist/github.d.ts +28 -4
- package/dist/github.js +46 -10
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +2 -0
- package/dist/graph-view.js +29 -2
- 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-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness.js +1 -1
- package/dist/host-tools.d.ts +8 -9
- package/dist/host-tools.js +7 -7
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +126 -8
- package/dist/learn/commit.d.ts +40 -6
- package/dist/learn/commit.js +164 -20
- package/dist/learn/folder.d.ts +11 -3
- package/dist/learn/folder.js +40 -16
- package/dist/learn/grade.d.ts +22 -2
- package/dist/learn/grade.js +127 -19
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +11 -13
- package/dist/learn/notes.d.ts +17 -3
- package/dist/learn/notes.js +19 -6
- package/dist/learn/reflect.d.ts +5 -2
- package/dist/learn/reflect.js +48 -32
- package/dist/learn/skills.d.ts +52 -5
- package/dist/learn/skills.js +104 -21
- package/dist/learned-nodes.d.ts +18 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +27 -13
- package/dist/learned-workflow.js +110 -38
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-routes.d.ts +48 -2
- package/dist/learning-routes.js +99 -28
- package/dist/learning-run.d.ts +7 -5
- package/dist/learning-run.js +9 -6
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +6 -2
- package/dist/learning.d.ts +13 -28
- package/dist/learning.js +4 -18
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +11 -1
- package/dist/mcp-probe.d.ts +8 -1
- package/dist/mcp-probe.js +62 -20
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +12 -12
- package/dist/mcp-servers-store.js +8 -3
- package/dist/model.d.ts +8 -5
- package/dist/model.js +14 -6
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +236 -55
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/place-offers.d.ts +97 -0
- package/dist/place-offers.js +206 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +22 -32
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +31 -9
- package/dist/print.d.ts +1 -8
- package/dist/print.js +1 -14
- package/dist/propose.d.ts +3 -0
- package/dist/propose.js +25 -19
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-db.js +3 -3
- package/dist/run-launch.d.ts +18 -3
- package/dist/run-launch.js +11 -5
- package/dist/run-learning-served.d.ts +12 -1
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +4 -2
- package/dist/run-reads-over-store.js +10 -8
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.js +60 -38
- package/dist/run-view.d.ts +35 -16
- package/dist/run-view.js +64 -35
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +20 -4
- package/dist/runner/adapter-loop.d.ts +46 -5
- package/dist/runner/adapter-loop.js +381 -56
- package/dist/runner/adapter-run-spec.d.ts +46 -4
- package/dist/runner/adapter-run-spec.js +200 -45
- package/dist/runner/adapters/pi.d.ts +39 -3
- package/dist/runner/adapters/pi.js +124 -29
- package/dist/runner/beside.d.ts +8 -0
- package/dist/runner/beside.js +24 -2
- package/dist/runner/claim-secrets.d.ts +6 -0
- package/dist/runner/claim-secrets.js +15 -1
- package/dist/runner/cli-run-spec.d.ts +10 -0
- package/dist/runner/cli-run-spec.js +207 -64
- package/dist/runner/commands.d.ts +5 -1
- package/dist/runner/commands.js +3 -3
- package/dist/runner/conformance/harness.d.ts +1 -1
- package/dist/runner/conformance/harness.js +13 -10
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +46 -15
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +24 -1
- package/dist/runner/journal-kinds.d.ts +53 -7
- package/dist/runner/journal-kinds.js +29 -1
- package/dist/runner/learning-end.d.ts +15 -0
- package/dist/runner/learning-end.js +113 -20
- package/dist/runner/learning-factory.js +6 -2
- package/dist/runner/learning-loop.d.ts +75 -1
- package/dist/runner/learning-loop.js +215 -22
- package/dist/runner/learning-seed.d.ts +8 -0
- package/dist/runner/learning-seed.js +7 -1
- package/dist/runner/loop-contract.d.ts +12 -0
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +5 -1
- package/dist/runner/loop.js +20 -0
- package/dist/runner/main.d.ts +9 -4
- package/dist/runner/main.js +38 -13
- package/dist/runner/mcp-claim.d.ts +7 -0
- package/dist/runner/mcp-claim.js +35 -2
- package/dist/runner/mcp-github.d.ts +15 -4
- package/dist/runner/mcp-github.js +55 -11
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +2 -0
- package/dist/runner/metrics.d.ts +18 -1
- package/dist/runner/metrics.js +81 -1
- package/dist/runner/model-route.d.ts +6 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +59 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +1 -0
- package/dist/runner/reflect-hook.js +3 -3
- package/dist/runner/runner.js +136 -19
- package/dist/runner/spec-holds.d.ts +13 -3
- package/dist/runner/spec-holds.js +13 -10
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/store-secrets.js +17 -1
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +188 -0
- package/dist/runner/workflow-host.d.ts +25 -4
- package/dist/runner/workflow-host.js +26 -4
- package/dist/runner/workflow-loop.d.ts +9 -3
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +28 -13
- package/dist/runner/workflow-spec.js +247 -102
- package/dist/runs-over-store.d.ts +18 -7
- package/dist/runs-over-store.js +149 -31
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +0 -2
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/server-lock.js +4 -5
- package/dist/server.d.ts +49 -63
- package/dist/server.js +429 -230
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +22 -8
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +49 -0
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/connection.d.ts +4 -0
- package/dist/store/postgres/connection.js +64 -13
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +11 -8
- 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 -82
- package/dist/store/sqlite/run-patch.d.ts +18 -2
- package/dist/store/sqlite/run-patch.js +31 -2
- package/dist/store/sqlite/store.js +65 -11
- package/dist/store/store.d.ts +62 -12
- package/dist/store/store.js +22 -1
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +1 -3
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/journal.js +83 -15
- package/dist/store-reads/learning.d.ts +73 -3
- package/dist/store-reads/learning.js +232 -9
- package/dist/store-reads/runs.d.ts +6 -4
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-view.d.ts +15 -1
- package/dist/store-view.js +88 -29
- package/dist/template-eval.js +2 -1
- package/dist/templates.d.ts +73 -4
- package/dist/templates.js +113 -23
- package/dist/timeline/timeline.d.ts +11 -1
- package/dist/timeline/timeline.js +19 -4
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +26 -0
- package/dist/tool-budget.js +56 -0
- package/dist/tool-gate.d.ts +13 -3
- package/dist/tool-gate.js +15 -7
- package/dist/tool-plane.d.ts +42 -29
- package/dist/tool-plane.js +64 -27
- package/dist/tools.d.ts +53 -39
- package/dist/tools.js +174 -79
- package/dist/trigger-signatures.d.ts +1 -0
- package/dist/trigger-signatures.js +3 -1
- package/dist/triggers.d.ts +3 -3
- package/dist/triggers.js +2 -2
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +82 -9
- package/dist/usage-lines.d.ts +1 -1
- package/dist/usage.d.ts +1 -47
- package/dist/usage.js +3 -82
- package/dist/validate.d.ts +8 -0
- package/dist/validate.js +40 -3
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -2
- 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 +112 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +88 -0
- package/dist/workflow/node.js +99 -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 +9 -0
- package/dist/workflow/pi-versions.js +8 -0
- package/dist/workflow/readers.d.ts +36 -0
- package/dist/workflow/readers.js +145 -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 +76 -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 +411 -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/wal.d.ts +11 -0
- package/dist/workflow/wal.js +106 -0
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +13 -2
- package/dist/workspace/archil-claim.js +22 -13
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +18 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/archil.d.ts +2 -2
- package/dist/workspace/archil.js +25 -5
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/computer-deps.d.ts +18 -11
- package/dist/workspace/computer-deps.js +64 -40
- package/dist/workspace/computer-for-claim.d.ts +47 -9
- package/dist/workspace/computer-for-claim.js +236 -24
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +3 -8
- package/dist/workspace/computer-ledger.js +7 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +5 -4
- package/dist/workspace/index.js +2 -1
- package/dist/workspace/local.d.ts +3 -0
- package/dist/workspace/local.js +9 -0
- package/dist/workspace/paths.js +3 -2
- package/dist/workspace/pi-env.d.ts +4 -0
- package/dist/workspace/pi-env.js +3 -2
- package/dist/workspace/resolve-computer.d.ts +48 -12
- package/dist/workspace/resolve-computer.js +88 -19
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +6 -4
- package/dist/workspace/run-tools.js +17 -9
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace.d.ts +0 -3
- package/dist/workspace.js +2 -15
- package/package.json +11 -16
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -8
- 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/mentions-defused/case.yaml +15 -0
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
- package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
- package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
- package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
- package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
- 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/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
- package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
- package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
- package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
- package/templates/release-notes/agent.md +11 -0
- 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 -76
- package/dist/budget.js +0 -204
- package/dist/console/assets/index-RPHGlXmM.js +0 -540
- package/dist/console/assets/index-opTN5Naq.css +0 -1
- 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/templates/code-review/rules/REVIEW.md +0 -41
package/dist/mcp-probe.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ApiError, type InputIssue } from "./errors.js";
|
|
2
2
|
export declare const MCP_SERVER_NAME: RegExp;
|
|
3
|
-
|
|
3
|
+
/** `per_run`: the server keeps no credential; each run's caller hands one with the run (mcp_auth), held for that run alone. */
|
|
4
|
+
export declare const MCP_AUTH_TYPES: readonly ["none", "bearer", "headers", "oauth", "github_app", "per_run"];
|
|
4
5
|
/** Why a saved credential can't be used for a run's calls, each with its own remedy and no other, as the model reads it
|
|
5
6
|
* after "The MCP server <name>'s credential can't be used right now: " (mcp-gateway.ts). The one place they are said. */
|
|
6
7
|
export declare const UNUSABLE: {
|
|
@@ -12,6 +13,8 @@ export declare const UNUSABLE: {
|
|
|
12
13
|
readonly silent: "the sign-in server didn't answer; try again";
|
|
13
14
|
/** An access token past its expiry whose refresh the address check refused unsent (mcp-oauth.ts), followed by its words. */
|
|
14
15
|
readonly blocked: "its sign-in server's address is refused here";
|
|
16
|
+
/** A per_run server's run that was handed no credential for it (mcp_auth), or whose credential was erased at its end. */
|
|
17
|
+
readonly perRunMissing: "this server takes its credential from each run, and this run was handed none: its caller sends one as mcp_auth when it starts the run or sends it a message";
|
|
15
18
|
};
|
|
16
19
|
export declare const REFRESH_MARGIN_MS: number;
|
|
17
20
|
/** How long an access token given with no expiry is taken to last: it is refreshed within the margin of then. */
|
|
@@ -82,6 +85,10 @@ export declare function pricesOf(value: unknown, issues: InputIssue[]): McpPrice
|
|
|
82
85
|
export declare function urlOf(value: unknown, issues: InputIssue[]): URL | undefined;
|
|
83
86
|
/** The body's auth: its type and, when it sends one, its credential as the headers it becomes. */
|
|
84
87
|
export declare function authOf(value: unknown, issues: InputIssue[]): Auth | undefined;
|
|
88
|
+
/** A run's `mcp_auth` (POST /runs, POST /agents/{id}/runs, POST /runs/{id}/messages): the headers each named per_run
|
|
89
|
+
* server is called with for this run, `{"<server>": {"headers": {...}}}`. Checked for shape here; that each name is a
|
|
90
|
+
* saved per_run server is the caller's check. Undefined when absent or wrong (with its issues). */
|
|
91
|
+
export declare function mcpAuthOf(value: unknown, issues: InputIssue[]): Record<string, HeaderMap> | undefined;
|
|
85
92
|
/** The OAuth scope list a sign-in body may send: 1 to 32 OAuth scopes. */
|
|
86
93
|
export declare const scopesValid: (scopes: unknown) => boolean;
|
|
87
94
|
/** The longest an OAuth client id or secret a sign-in body may send. */
|
package/dist/mcp-probe.js
CHANGED
|
@@ -13,7 +13,8 @@ export const MCP_SERVER_NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
|
|
13
13
|
/** The names AgentRun's own tools are called by, which no MCP server takes: claude-agent calls the kernel's host tools
|
|
14
14
|
* as `mcp__hands__<tool>`, and monid's are `monid_<tool>` (tool-gate.ts settingsKeyOf reads both as AgentRun's). */
|
|
15
15
|
const RESERVED_MCP_NAMES = ["hands", "monid"];
|
|
16
|
-
|
|
16
|
+
/** `per_run`: the server keeps no credential; each run's caller hands one with the run (mcp_auth), held for that run alone. */
|
|
17
|
+
export const MCP_AUTH_TYPES = ["none", "bearer", "headers", "oauth", "github_app", "per_run"];
|
|
17
18
|
/** Where an owner updates a saved MCP server, as people read it. */
|
|
18
19
|
const MCP_SETTINGS = "Settings → MCP servers";
|
|
19
20
|
/** Why a saved credential can't be used for a run's calls, each with its own remedy and no other, as the model reads it
|
|
@@ -27,6 +28,8 @@ export const UNUSABLE = {
|
|
|
27
28
|
silent: "the sign-in server didn't answer; try again",
|
|
28
29
|
/** An access token past its expiry whose refresh the address check refused unsent (mcp-oauth.ts), followed by its words. */
|
|
29
30
|
blocked: "its sign-in server's address is refused here",
|
|
31
|
+
/** A per_run server's run that was handed no credential for it (mcp_auth), or whose credential was erased at its end. */
|
|
32
|
+
perRunMissing: "this server takes its credential from each run, and this run was handed none: its caller sends one as mcp_auth when it starts the run or sends it a message",
|
|
30
33
|
};
|
|
31
34
|
export const REFRESH_MARGIN_MS = 5 * 60_000;
|
|
32
35
|
/** How long an access token given with no expiry is taken to last: it is refreshed within the margin of then. */
|
|
@@ -130,7 +133,7 @@ export function authOf(value, issues) {
|
|
|
130
133
|
if (value === undefined)
|
|
131
134
|
return { type: "none" };
|
|
132
135
|
if (!isObject(value))
|
|
133
|
-
return void issues.push({ field: "auth", reason: "wrong_type", message: "auth is {type: none|bearer|headers|oauth|github_app, token?, headers?}." });
|
|
136
|
+
return void issues.push({ field: "auth", reason: "wrong_type", message: "auth is {type: none|bearer|headers|oauth|github_app|per_run, token?, headers?}." });
|
|
134
137
|
const before = issues.length;
|
|
135
138
|
issues.push(...unknownFields(value, ["type", "token", "headers"]).map((issue) => ({ ...issue, field: `auth.${issue.field}` })));
|
|
136
139
|
const type = value.type;
|
|
@@ -147,6 +150,8 @@ export function authOf(value, issues) {
|
|
|
147
150
|
let headers;
|
|
148
151
|
if (type === "github_app" && value.token !== undefined)
|
|
149
152
|
issues.push({ field: "auth.token", reason: "not_allowed", message: "auth.type github_app takes no token: the connected GitHub App's installation token is minted for each run." });
|
|
153
|
+
if (type === "per_run" && value.token !== undefined)
|
|
154
|
+
issues.push({ field: "auth.token", reason: "not_allowed", message: "auth.type per_run takes headers to list the server's tools with, never kept: a run's own credential is its mcp_auth." });
|
|
150
155
|
if ((type === "none" || type === "oauth") && (value.token !== undefined || value.headers !== undefined))
|
|
151
156
|
issues.push({ field: "auth", reason: "not_allowed", message: type === "none" ? "auth.type none sends no credential." : "auth.type oauth takes its credential from a sign-in, never from a body." });
|
|
152
157
|
if (type === "bearer") {
|
|
@@ -157,29 +162,66 @@ export function authOf(value, issues) {
|
|
|
157
162
|
headers = { authorization: `Bearer ${String(value.token)}` };
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
|
-
if (type === "headers" || type === "github_app") {
|
|
165
|
+
if (type === "headers" || type === "github_app" || type === "per_run") {
|
|
161
166
|
if (type === "headers" && value.token !== undefined)
|
|
162
167
|
issues.push({ field: "auth.token", reason: "not_allowed", message: "Named headers are auth.headers." });
|
|
163
|
-
if (value.headers !== undefined)
|
|
164
|
-
|
|
165
|
-
if (!entries.length || entries.length > MAX_HEADERS)
|
|
166
|
-
issues.push({ field: "auth.headers", reason: "invalid", message: `auth.headers names 1 to ${MAX_HEADERS} headers and their values.` });
|
|
167
|
-
headers = Object.create(null);
|
|
168
|
-
for (const [name, text] of entries) {
|
|
169
|
-
const lower = name.toLowerCase();
|
|
170
|
-
if (!HEADER_NAME.test(name) || RESERVED.has(lower))
|
|
171
|
-
issues.push({ field: `auth.headers.${name}`, reason: "invalid", message: `${name} is not a header a credential may be sent in.` });
|
|
172
|
-
else if (type === "github_app" && lower === "authorization")
|
|
173
|
-
issues.push({ field: `auth.headers.${name}`, reason: "not_allowed", message: "A github_app server's Authorization is the installation token minted for each run, never a saved one." });
|
|
174
|
-
else if (lower in headers)
|
|
175
|
-
issues.push({ field: `auth.headers.${name}`, reason: "duplicate", message: `${name} is named twice.` });
|
|
176
|
-
check(`auth.headers.${name}`, text);
|
|
177
|
-
headers[lower] = String(text);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
168
|
+
if (value.headers !== undefined)
|
|
169
|
+
headers = headersOf("auth.headers", value.headers, issues, type === "github_app" ? "A github_app server's Authorization is the installation token minted for each run, never a saved one." : undefined);
|
|
180
170
|
}
|
|
181
171
|
return issues.length > before ? undefined : { type: type, ...(headers ? { headers } : {}) };
|
|
182
172
|
}
|
|
173
|
+
/** A credential's named headers at `field`: 1 to MAX_HEADERS, each a header a credential may be sent in, its value text
|
|
174
|
+
* with no control character, within MAX_VALUE_BYTES. `noAuthorization`: why Authorization is refused, when it is. */
|
|
175
|
+
function headersOf(field, value, issues, noAuthorization) {
|
|
176
|
+
const entries = isObject(value) ? Object.entries(value) : [];
|
|
177
|
+
if (!entries.length || entries.length > MAX_HEADERS)
|
|
178
|
+
issues.push({ field, reason: "invalid", message: `${field} names 1 to ${MAX_HEADERS} headers and their values.` });
|
|
179
|
+
const headers = Object.create(null);
|
|
180
|
+
for (const [name, text] of entries) {
|
|
181
|
+
const lower = name.toLowerCase();
|
|
182
|
+
const at = `${field}.${name}`;
|
|
183
|
+
if (!HEADER_NAME.test(name) || RESERVED.has(lower))
|
|
184
|
+
issues.push({ field: at, reason: "invalid", message: `${name} is not a header a credential may be sent in.` });
|
|
185
|
+
else if (noAuthorization && lower === "authorization")
|
|
186
|
+
issues.push({ field: at, reason: "not_allowed", message: noAuthorization });
|
|
187
|
+
else if (lower in headers)
|
|
188
|
+
issues.push({ field: at, reason: "duplicate", message: `${name} is named twice.` });
|
|
189
|
+
if (typeof text !== "string" || text === "")
|
|
190
|
+
issues.push({ field: at, reason: "wrong_type", message: `${at} is text, not empty.` });
|
|
191
|
+
else if (CONTROL.test(text))
|
|
192
|
+
issues.push({ field: at, reason: "invalid", message: `${at} holds a control character.` });
|
|
193
|
+
else if (Buffer.byteLength(text) > MAX_VALUE_BYTES)
|
|
194
|
+
issues.push({ field: at, reason: "too_long", message: `${at} is at most ${MAX_VALUE_BYTES} bytes.` });
|
|
195
|
+
headers[lower] = String(text);
|
|
196
|
+
}
|
|
197
|
+
return headers;
|
|
198
|
+
}
|
|
199
|
+
/** The most servers one mcp_auth names. */
|
|
200
|
+
const MAX_MCP_AUTH_SERVERS = 8;
|
|
201
|
+
/** A run's `mcp_auth` (POST /runs, POST /agents/{id}/runs, POST /runs/{id}/messages): the headers each named per_run
|
|
202
|
+
* server is called with for this run, `{"<server>": {"headers": {...}}}`. Checked for shape here; that each name is a
|
|
203
|
+
* saved per_run server is the caller's check. Undefined when absent or wrong (with its issues). */
|
|
204
|
+
export function mcpAuthOf(value, issues) {
|
|
205
|
+
if (value === undefined)
|
|
206
|
+
return undefined;
|
|
207
|
+
const shape = 'mcp_auth is {"<server>": {"headers": {"<name>": "<value>"}}}, one entry for each per_run MCP server the run calls.';
|
|
208
|
+
if (!isObject(value) || !Object.keys(value).length || Object.keys(value).length > MAX_MCP_AUTH_SERVERS)
|
|
209
|
+
return void issues.push({ field: "mcp_auth", reason: isObject(value) ? "invalid" : "wrong_type", message: `${shape} It names 1 to ${MAX_MCP_AUTH_SERVERS} servers.` });
|
|
210
|
+
const before = issues.length;
|
|
211
|
+
const out = Object.create(null);
|
|
212
|
+
for (const [server, entry] of Object.entries(value)) {
|
|
213
|
+
const field = `mcp_auth.${server}`;
|
|
214
|
+
if (!MCP_SERVER_NAME.test(server))
|
|
215
|
+
issues.push({ field, reason: "invalid", message: `${server} is not an MCP server's name.` });
|
|
216
|
+
if (!isObject(entry)) {
|
|
217
|
+
issues.push({ field, reason: "wrong_type", message: shape });
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
issues.push(...unknownFields(entry, ["headers"]).map((issue) => ({ ...issue, field: `${field}.${issue.field}` })));
|
|
221
|
+
out[server] = headersOf(`${field}.headers`, entry.headers, issues);
|
|
222
|
+
}
|
|
223
|
+
return issues.length > before ? undefined : out;
|
|
224
|
+
}
|
|
183
225
|
/** The OAuth scope list a sign-in body may send: 1 to 32 OAuth scopes. */
|
|
184
226
|
export const scopesValid = (scopes) => Array.isArray(scopes) && scopes.length > 0 && scopes.length <= 32 && scopes.every((scope) => typeof scope === "string" && SCOPE.test(scope));
|
|
185
227
|
/** The longest an OAuth client id or secret a sign-in body may send. */
|
|
@@ -17,6 +17,10 @@ export function mcpWritesSecret(operation, body) {
|
|
|
17
17
|
return true;
|
|
18
18
|
if (operation !== "saveMcpServer" || !isObject(body) || !isObject(body.auth))
|
|
19
19
|
return false;
|
|
20
|
+
// A per_run server keeps no credential: headers sent with its save only list its tools, as a preview's do. The
|
|
21
|
+
// credentials it later receives are the ones each run's own caller hands it (mcp_auth).
|
|
22
|
+
if (body.auth.type === "per_run")
|
|
23
|
+
return false;
|
|
20
24
|
const { token, headers } = body.auth;
|
|
21
25
|
return token !== undefined || (isObject(headers) && Object.keys(headers).length > 0);
|
|
22
26
|
}
|
|
@@ -86,9 +86,9 @@ export declare class McpServersOverStore {
|
|
|
86
86
|
credential: "unreadable" | "sealed" | "expired" | null;
|
|
87
87
|
not_metered?: string[] | undefined;
|
|
88
88
|
tools: {
|
|
89
|
-
permission: "deny" | "
|
|
90
|
-
default_permission: "deny" | "
|
|
91
|
-
permissions: ("deny" | "
|
|
89
|
+
permission: "deny" | "allow" | "ask";
|
|
90
|
+
default_permission: "deny" | "allow" | "ask";
|
|
91
|
+
permissions: ("deny" | "allow" | "ask")[];
|
|
92
92
|
name: string;
|
|
93
93
|
title?: string;
|
|
94
94
|
description?: string;
|
|
@@ -121,9 +121,9 @@ export declare class McpServersOverStore {
|
|
|
121
121
|
credential: "unreadable" | "sealed" | "expired" | null;
|
|
122
122
|
not_metered?: string[] | undefined;
|
|
123
123
|
tools: {
|
|
124
|
-
permission: "deny" | "
|
|
125
|
-
default_permission: "deny" | "
|
|
126
|
-
permissions: ("deny" | "
|
|
124
|
+
permission: "deny" | "allow" | "ask";
|
|
125
|
+
default_permission: "deny" | "allow" | "ask";
|
|
126
|
+
permissions: ("deny" | "allow" | "ask")[];
|
|
127
127
|
name: string;
|
|
128
128
|
title?: string;
|
|
129
129
|
description?: string;
|
|
@@ -159,9 +159,9 @@ export declare class McpServersOverStore {
|
|
|
159
159
|
credential: "unreadable" | "sealed" | "expired" | null;
|
|
160
160
|
not_metered?: string[] | undefined;
|
|
161
161
|
tools: {
|
|
162
|
-
permission: "deny" | "
|
|
163
|
-
default_permission: "deny" | "
|
|
164
|
-
permissions: ("deny" | "
|
|
162
|
+
permission: "deny" | "allow" | "ask";
|
|
163
|
+
default_permission: "deny" | "allow" | "ask";
|
|
164
|
+
permissions: ("deny" | "allow" | "ask")[];
|
|
165
165
|
name: string;
|
|
166
166
|
title?: string;
|
|
167
167
|
description?: string;
|
|
@@ -198,9 +198,9 @@ export declare class McpServersOverStore {
|
|
|
198
198
|
credential: "unreadable" | "sealed" | "expired" | null;
|
|
199
199
|
not_metered?: string[] | undefined;
|
|
200
200
|
tools: {
|
|
201
|
-
permission: "deny" | "
|
|
202
|
-
default_permission: "deny" | "
|
|
203
|
-
permissions: ("deny" | "
|
|
201
|
+
permission: "deny" | "allow" | "ask";
|
|
202
|
+
default_permission: "deny" | "allow" | "ask";
|
|
203
|
+
permissions: ("deny" | "allow" | "ask")[];
|
|
204
204
|
name: string;
|
|
205
205
|
title?: string;
|
|
206
206
|
description?: string;
|
|
@@ -148,7 +148,8 @@ export class McpServersOverStore {
|
|
|
148
148
|
}
|
|
149
149
|
const { url, auth } = this.admit(body);
|
|
150
150
|
// 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
|
-
|
|
151
|
+
// 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.
|
|
152
|
+
if (auth.type !== "none" && auth.type !== "github_app" && auth.type !== "per_run" && !auth.headers)
|
|
152
153
|
throw invalid([credentialMissing(auth.type, "A preview needs the credential it is to connect with.")]);
|
|
153
154
|
return marked(url.href, await this.listServer(url, await this.withAppToken(auth.type, url, auth.headers ?? {}, stop), stop));
|
|
154
155
|
}
|
|
@@ -180,6 +181,9 @@ export class McpServersOverStore {
|
|
|
180
181
|
keeping = true;
|
|
181
182
|
}
|
|
182
183
|
}
|
|
184
|
+
else if (auth.type === "per_run") {
|
|
185
|
+
// Keeps no credential: the headers sent, if any, only list its tools now. Each run hands its own (mcp_auth).
|
|
186
|
+
}
|
|
183
187
|
else if (auth.type !== "none" && !headers) {
|
|
184
188
|
if (!was || was.auth !== auth.type)
|
|
185
189
|
throw invalid([credentialMissing(auth.type, `The server ${name} has no saved ${auth.type} credential to keep.`)]);
|
|
@@ -346,7 +350,8 @@ export class McpServersOverStore {
|
|
|
346
350
|
}
|
|
347
351
|
/** The saved credential opened, or the refusal that asks for it again. */
|
|
348
352
|
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
|
|
353
|
+
// No credential kept: none for a server that takes none, nor for a github_app server with no static headers, nor for a
|
|
354
|
+
// per_run server (each run hands its own).
|
|
350
355
|
if (row.auth === "none" || row.sealed === null)
|
|
351
356
|
return { headers: {}, credential: { type: "headers", headers: {}, origin: new URL(row.url).origin } };
|
|
352
357
|
const open = await openServerCredential(this.store, this.sealKey, name);
|
|
@@ -374,7 +379,7 @@ export class McpServersOverStore {
|
|
|
374
379
|
const prices = (row.prices ?? undefined);
|
|
375
380
|
const listed = marked(row.url, { protocol: row.protocol ?? "unknown", server_info: row.serverInfo ?? null, ...(typeof row.instructions === "string" ? { instructions: row.instructions } : {}), tools });
|
|
376
381
|
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);
|
|
382
|
+
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
383
|
const cred = opened && "credential" in opened ? opened.credential : undefined;
|
|
379
384
|
const set = cred?.type === "oauth" ? cred.set : undefined;
|
|
380
385
|
const expired = cred?.type === "oauth" && cred.expired === true;
|
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"];
|
|
@@ -26,6 +25,9 @@ export declare const THINKING_LEVELS: readonly ["low", "medium", "high", "xhigh"
|
|
|
26
25
|
export type ThinkingLevel = (typeof THINKING_LEVELS)[number];
|
|
27
26
|
export declare const TIERS: readonly ["fast", "default", "strong"];
|
|
28
27
|
export type Tier = (typeof TIERS)[number];
|
|
28
|
+
/** The model `env` names for `tier` of its own (AGENT_MODEL_FAST, AGENT_MODEL_STRONG; AGENT_MODEL for the default), or
|
|
29
|
+
* undefined when it names none: a tier the host has no model of, whose request runs on the run's own model. */
|
|
30
|
+
export declare const tierModelOf: (env: NodeJS.ProcessEnv, tier: Tier) => string | undefined;
|
|
29
31
|
/** The workflow node kinds that run on a model. */
|
|
30
32
|
export declare const MODEL_NODES: readonly ["agent", "decide", "extract", "report"];
|
|
31
33
|
/** The model providers whose key a person may save here (tool-keys.ts' `model` rows), in the order a default is taken
|
|
@@ -147,11 +149,12 @@ export type FauxHelpers = {
|
|
|
147
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
|
|
148
150
|
* default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
|
|
149
151
|
* The faux module's replies, the gateway in the environment, or pi-ai's providers. `unpriced`: the ids of its models
|
|
150
|
-
* serve has no price for (a gateway model the catalog does not list, with no price set), which a cap cannot be kept on.
|
|
151
|
-
|
|
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<{
|
|
152
155
|
models: import("@earendil-works/pi-ai").MutableModels;
|
|
153
156
|
model: ModelRef | undefined;
|
|
154
|
-
byTier: Map<"
|
|
157
|
+
byTier: Map<"default" | "fast" | "strong", ModelRef>;
|
|
155
158
|
unpriced: Set<string>;
|
|
156
159
|
}>;
|
|
157
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
|
@@ -27,8 +27,7 @@ export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filte
|
|
|
27
27
|
export const FAUX_UPSTREAM_ENV = "AGENTRUN_SERVE_FAUX_UPSTREAM";
|
|
28
28
|
/** The model the server's keys give a run that names none (hostModel at the run's launch, from every key the server
|
|
29
29
|
* 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). */
|
|
30
|
+
* 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
31
|
export const DEFAULT_MODEL_ENV = "AGENTRUN_SERVE_DEFAULT_MODEL";
|
|
33
32
|
export const MODEL_PROVIDER = "agent-model";
|
|
34
33
|
export const EFFORTS = ["low", "medium", "high"];
|
|
@@ -36,6 +35,9 @@ export const EFFORTS = ["low", "medium", "high"];
|
|
|
36
35
|
export const THINKING_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
37
36
|
export const TIERS = ["fast", "default", "strong"];
|
|
38
37
|
const TIER_ENV = { fast: "AGENT_MODEL_FAST", default: "AGENT_MODEL", strong: "AGENT_MODEL_STRONG" };
|
|
38
|
+
/** The model `env` names for `tier` of its own (AGENT_MODEL_FAST, AGENT_MODEL_STRONG; AGENT_MODEL for the default), or
|
|
39
|
+
* undefined when it names none: a tier the host has no model of, whose request runs on the run's own model. */
|
|
40
|
+
export const tierModelOf = (env, tier) => env[TIER_ENV[tier]] || undefined;
|
|
39
41
|
/** The workflow node kinds that run on a model. */
|
|
40
42
|
export const MODEL_NODES = ["agent", "decide", "extract", "report"];
|
|
41
43
|
/** The model providers whose key a person may save here (tool-keys.ts' `model` rows), in the order a default is taken
|
|
@@ -53,7 +55,7 @@ export const MODEL_KEYS = Object.freeze([
|
|
|
53
55
|
{ id: "anthropic", label: "Anthropic", field: "ANTHROPIC_API_KEY", model: "anthropic/claude-sonnet-5-5", harnesses: onVendor("anthropic") },
|
|
54
56
|
{ id: "openai", label: "OpenAI", field: "OPENAI_API_KEY", model: "openai/gpt-6.1-sol", harnesses: onVendor("openai") },
|
|
55
57
|
// OpenRouter serves both wires: every harness runs on its key, an adapter harness on its wire's vendor's model there.
|
|
56
|
-
{ 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" } },
|
|
58
|
+
{ 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" } },
|
|
57
59
|
]);
|
|
58
60
|
/** pi, and the adapter harnesses whose wire (their facts') runs `vendor`'s models: those that talk to its own API. */
|
|
59
61
|
function onVendor(vendor) {
|
|
@@ -283,15 +285,16 @@ export function thinkingLevel(value) {
|
|
|
283
285
|
/** The models for a run, and its model of each tier it uses and of no other: an agentic revision's `ref` (or the
|
|
284
286
|
* default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
|
|
285
287
|
* The faux module's replies, the gateway in the environment, or pi-ai's providers. `unpriced`: the ids of its models
|
|
286
|
-
* serve has no price for (a gateway model the catalog does not list, with no price set), which a cap cannot be kept on.
|
|
287
|
-
|
|
288
|
+
* serve has no price for (a gateway model the catalog does not list, with no price set), which a cap cannot be kept on.
|
|
289
|
+
* `tierRefs`: a model named for another tier (a subagent's model_tiers), chosen for it in place of the host's. */
|
|
290
|
+
export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT_HARNESS, tierRefs = {}) {
|
|
288
291
|
const ai = await import("@earendil-works/pi-ai");
|
|
289
292
|
const { createModels, createProvider } = await import("@earendil-works/pi-ai/models");
|
|
290
293
|
const faux = env[FAUX_ENV];
|
|
291
294
|
const byTier = new Map();
|
|
292
295
|
const namedBy = new Map();
|
|
293
296
|
for (const tier of new Set(tiers)) {
|
|
294
|
-
const chosen = await chooseModel(env, tier === "default" ? ref :
|
|
297
|
+
const chosen = await chooseModel(env, tier === "default" ? ref : tierRefs[tier], tier, harness);
|
|
295
298
|
if ("why" in chosen)
|
|
296
299
|
throw new Error(chosen.why);
|
|
297
300
|
byTier.set(tier, chosen.model);
|
|
@@ -314,6 +317,11 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
|
|
|
314
317
|
const price = typeof mod.cost === "object" ? mod.cost : undefined;
|
|
315
318
|
if (typeof mod.default !== "function")
|
|
316
319
|
throw new Error(`the faux module ${faux} has no default export function`);
|
|
320
|
+
// A faux model with no price ("unknown"), as a provider that does not price it: unpriced, so the runner's route books
|
|
321
|
+
// its requests at no known price (null), never at the placeholder cost's $0 (model-route.ts routeOf).
|
|
322
|
+
if (mod.cost === "unknown")
|
|
323
|
+
for (const id of ids)
|
|
324
|
+
unpriced.add(id);
|
|
317
325
|
const reply = mod.default;
|
|
318
326
|
const helpers = { message: ai.fauxAssistantMessage, text: ai.fauxText, thinking: ai.fauxThinking, toolCall: ai.fauxToolCall };
|
|
319
327
|
// `contextWindow` sizes the faux model's window, so a test can make a run long enough to compact; `maxTokens` its
|
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). */
|