@parcha/agentrun-serve 0.1.0-beta.36 → 0.1.0-beta.38
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 +452 -0
- package/README.md +311 -142
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +39 -14
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- 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/browser-cost.d.ts +1 -1
- package/dist/browser-cost.js +52 -93
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/cap.d.ts +0 -407
- package/dist/cap.js +4 -1028
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +4 -34
- package/dist/cli.js +13 -4
- package/dist/composio-preset.d.ts +53 -0
- package/dist/composio-preset.js +221 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +60 -0
- package/dist/computer-calls.js +209 -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 +165 -0
- package/dist/computer-live.js +655 -0
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +14 -0
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +311 -0
- package/dist/computers.d.ts +37 -8
- package/dist/computers.js +62 -14
- package/dist/console/assets/index-CjqQirbo.css +1 -0
- package/dist/console/assets/index-b6-XY5A9.js +576 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +3 -0
- package/dist/decisions.js +4 -0
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -26
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- package/dist/harness-opencode/adapter.js +7 -3
- package/dist/harness-opencode/facts.js +0 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -5
- package/dist/harness-opencode/host/policy.js +8 -32
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +0 -2
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +35 -1
- package/dist/host-tools.d.ts +2 -6
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +5 -6
- package/dist/hosted-search.js +2 -28
- 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/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +13 -5
- package/dist/learn/commit.d.ts +14 -2
- package/dist/learn/commit.js +23 -9
- package/dist/learn/compile.d.ts +243 -0
- package/dist/learn/compile.js +471 -0
- package/dist/learn/folder.d.ts +6 -0
- package/dist/learn/folder.js +4 -1
- package/dist/learn/general.d.ts +69 -0
- package/dist/learn/general.js +75 -0
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +29 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +253 -0
- package/dist/learn/promote.js +428 -0
- package/dist/learn/refit.d.ts +39 -0
- package/dist/learn/refit.js +236 -0
- package/dist/learn/reflect.d.ts +9 -20
- package/dist/learn/reflect.js +18 -125
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +50 -14
- package/dist/learn/skills.js +183 -47
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +50 -2
- package/dist/learned-nodes.js +41 -2
- package/dist/learned-workflow.d.ts +43 -3
- package/dist/learned-workflow.js +170 -28
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +18 -6
- package/dist/learning-cost.js +15 -7
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +37 -2
- package/dist/learning-routes.js +52 -8
- package/dist/learning-words.d.ts +13 -0
- package/dist/learning-words.js +13 -0
- package/dist/learning.d.ts +55 -17
- package/dist/learning.js +91 -48
- 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/llm.js +0 -3
- package/dist/mcp-gateway.d.ts +21 -20
- package/dist/mcp-gateway.js +76 -55
- package/dist/mcp-oauth.d.ts +62 -7
- package/dist/mcp-oauth.js +134 -19
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +107 -0
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -11
- package/dist/mcp-probe.js +60 -42
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +115 -25
- package/dist/mcp-servers-store.js +241 -43
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +21 -4
- package/dist/mcp-store.js +33 -8
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +69 -25
- package/dist/monid.d.ts +51 -25
- package/dist/monid.js +226 -140
- package/dist/openapi.js +694 -59
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +26 -29
- package/dist/paid-calls.js +46 -102
- package/dist/place-offers.d.ts +2 -3
- package/dist/place-offers.js +3 -7
- package/dist/place.js +1 -2
- package/dist/print.d.ts +15 -1
- package/dist/print.js +14 -3
- package/dist/propose.d.ts +10 -1
- package/dist/propose.js +30 -10
- package/dist/provider.js +12 -4
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +3 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +27 -2
- package/dist/run-launch.js +15 -4
- package/dist/run-learning-served.d.ts +13 -2
- package/dist/run-manifest.d.ts +5 -0
- package/dist/run-manifest.js +20 -0
- 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 +2 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +19 -8
- package/dist/run-view.js +62 -26
- package/dist/runnable.d.ts +0 -3
- package/dist/runnable.js +37 -29
- package/dist/runner/adapter-loop.d.ts +47 -17
- package/dist/runner/adapter-loop.js +1427 -303
- package/dist/runner/adapter-run-spec.d.ts +23 -9
- package/dist/runner/adapter-run-spec.js +162 -56
- package/dist/runner/adapters/pi-computer.d.ts +9 -0
- package/dist/runner/adapters/pi-computer.js +51 -0
- package/dist/runner/adapters/pi.d.ts +25 -11
- package/dist/runner/adapters/pi.js +168 -45
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +21 -11
- 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 +20 -3
- package/dist/runner/cli-run-spec.js +174 -64
- package/dist/runner/commands.d.ts +3 -1
- package/dist/runner/commands.js +28 -3
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +62 -0
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +224 -17
- package/dist/runner/conformance/subject.d.ts +12 -5
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +23 -12
- package/dist/runner/end-of-run.js +41 -16
- package/dist/runner/feedback-round.d.ts +52 -0
- package/dist/runner/feedback-round.js +79 -0
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +4 -2
- package/dist/runner/harness-loops.js +15 -1
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +44 -7
- package/dist/runner/journal-kinds.js +29 -0
- 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 +69 -13
- package/dist/runner/learning-end.js +340 -87
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +11 -5
- package/dist/runner/learning-loop.d.ts +86 -8
- package/dist/runner/learning-loop.js +178 -23
- package/dist/runner/learning-seed.d.ts +11 -0
- package/dist/runner/learning-seed.js +27 -0
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +26 -3
- package/dist/runner/loop.d.ts +21 -2
- package/dist/runner/loop.js +23 -2
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +27 -5
- package/dist/runner/mcp-claim.d.ts +15 -8
- package/dist/runner/mcp-claim.js +176 -71
- package/dist/runner/mcp-github.js +1 -1
- package/dist/runner/mcp-run.d.ts +21 -57
- package/dist/runner/mcp-run.js +25 -85
- package/dist/runner/meta-tools.d.ts +37 -0
- package/dist/runner/meta-tools.js +268 -0
- package/dist/runner/metrics.d.ts +11 -2
- package/dist/runner/metrics.js +26 -5
- package/dist/runner/model-route.js +12 -3
- package/dist/runner/monid-run.d.ts +16 -0
- package/dist/runner/monid-run.js +96 -0
- package/dist/runner/pr-checkout.d.ts +1 -0
- package/dist/runner/pr-checkout.js +1 -1
- package/dist/runner/promotion.d.ts +80 -0
- package/dist/runner/promotion.js +562 -0
- package/dist/runner/reflect-hook.d.ts +46 -13
- package/dist/runner/reflect-hook.js +149 -48
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +208 -17
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +9 -4
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-port.d.ts +4 -2
- package/dist/runner/store-secrets.js +4 -3
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +10 -13
- package/dist/runner/workflow-first.d.ts +216 -0
- package/dist/runner/workflow-first.js +303 -0
- package/dist/runner/workflow-host.d.ts +6 -1
- package/dist/runner/workflow-host.js +1 -1
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +15 -2
- package/dist/runner/workflow-spec.js +63 -23
- package/dist/runs-over-store.d.ts +17 -3
- package/dist/runs-over-store.js +59 -20
- 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/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 +119 -18
- package/dist/server.js +841 -202
- package/dist/settings-wake.d.ts +23 -0
- package/dist/settings-wake.js +65 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/command-wake.d.ts +13 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +13 -5
- package/dist/store/postgres/connection.js +3 -1
- package/dist/store/postgres/dialect.js +4 -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/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
- package/dist/store/schema.d.ts +10 -1
- package/dist/store/schema.js +104 -15
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +7 -5
- package/dist/store/sqlite/run-patch.js +45 -18
- package/dist/store/sqlite/store.js +331 -72
- package/dist/store/store.d.ts +312 -21
- package/dist/store/store.js +12 -1
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +8 -1
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +1 -1
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +30 -5
- package/dist/store-reads/journal.js +128 -56
- package/dist/store-reads/learning.d.ts +114 -12
- package/dist/store-reads/learning.js +238 -48
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +1 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +6 -0
- package/dist/store-view.js +59 -26
- package/dist/template-eval.d.ts +18 -9
- package/dist/template-eval.js +95 -68
- package/dist/template-github-permissions.d.ts +24 -10
- package/dist/template-github-permissions.js +36 -15
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +218 -46
- package/dist/templates.js +493 -181
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +4 -3
- package/dist/timeline/index.js +4 -3
- package/dist/timeline/labels.d.ts +6 -2
- package/dist/timeline/labels.js +93 -2
- package/dist/timeline/origin.d.ts +19 -5
- package/dist/timeline/origin.js +11 -4
- package/dist/timeline/timeline.d.ts +22 -1
- package/dist/timeline/timeline.js +34 -18
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-gate.d.ts +84 -50
- package/dist/tool-gate.js +179 -101
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +26 -0
- package/dist/tool-list.js +43 -0
- package/dist/tool-names.d.ts +71 -0
- package/dist/tool-names.js +99 -0
- package/dist/tool-plane.d.ts +33 -27
- package/dist/tool-plane.js +72 -39
- package/dist/tools.d.ts +32 -7
- package/dist/tools.js +37 -24
- 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 +25 -6
- package/dist/trigger-signatures.js +41 -7
- 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 +7 -3
- package/dist/triggers.js +35 -5
- package/dist/turns.js +16 -1
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +102 -45
- package/dist/web-fetch.d.ts +2 -8
- package/dist/web-fetch.js +2 -22
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +145 -102
- package/dist/webhooks.js +559 -322
- package/dist/workflow/decisions.d.ts +1 -1
- package/dist/workflow/node-runner.d.ts +2 -1
- package/dist/workflow/node.d.ts +2 -1
- package/dist/workflow/node.js +3 -1
- package/dist/workflow/pi-versions.d.ts +23 -0
- package/dist/workflow/pi-versions.js +57 -0
- package/dist/workflow/record-tool.d.ts +2 -1
- package/dist/workflow/store.d.ts +1 -1
- package/dist/workflow/task.js +3 -2
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +19 -9
- package/dist/workspace/computer-deps.js +24 -9
- package/dist/workspace/computer-for-claim.d.ts +23 -8
- package/dist/workspace/computer-for-claim.js +92 -33
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +41 -55
- package/dist/workspace/computer-ledger.d.ts +3 -1
- package/dist/workspace/computer-ledger.js +4 -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 +53 -0
- package/dist/workspace/computer-script.js +172 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +4 -2
- package/dist/workspace/index.js +3 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +132 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +104 -85
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +24 -1
- package/dist/workspace/resolve-computer.js +40 -16
- package/dist/workspace/run-tools.d.ts +56 -21
- package/dist/workspace/run-tools.js +55 -34
- package/dist/wrap-up.d.ts +21 -0
- package/dist/wrap-up.js +21 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +19 -16
- package/templates/README.md +111 -45
- package/templates/code-review/agent.md +30 -14
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- package/templates/code-review/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +3 -2
- package/templates/code-review/skills/review/REVIEWER.md +3 -2
- package/templates/code-review/skills/review/SKILL.md +4 -3
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-BI4Byidu.js +0 -550
- package/dist/console/assets/index-C19gUF2n.css +0 -1
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -26
- package/dist/tool-budget.js +0 -56
- package/dist/workflow/readers.d.ts +0 -36
- package/dist/workflow/readers.js +0 -145
- package/dist/workflow/wal.d.ts +0 -11
- package/dist/workflow/wal.js +0 -106
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
package/dist/mcp-store.d.ts
CHANGED
|
@@ -54,24 +54,41 @@ 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">;
|
|
68
74
|
}): Promise<McpServerRow[]>;
|
|
75
|
+
/** One saved server's row (its credential stays sealed), or undefined when no such server. */
|
|
76
|
+
export declare function getMcpServer(store: {
|
|
77
|
+
mcp: Pick<Mcp, "server">;
|
|
78
|
+
}, name: string): Promise<McpServerRow | undefined>;
|
|
79
|
+
/** The credential of a row already read, opened (§7), as openServerCredential does for a name. */
|
|
80
|
+
export declare function openMcpRow(sealKey: Buffer, row: Pick<McpServerRow, "name" | "url" | "sealed">): OpenedMcpCredential;
|
|
69
81
|
/** A saved server's credential opened (§7): the credential with its origin, or why not — none saved; unopened (another
|
|
70
82
|
* seal key, or not the store's format); damaged (saved for another origin than the row's url, so it is never sent).
|
|
71
83
|
* undefined when no such server. */
|
|
72
84
|
export declare function openServerCredential(store: {
|
|
73
85
|
mcp: Pick<Mcp, "server">;
|
|
74
86
|
}, sealKey: Buffer, name: string): Promise<OpenedMcpCredential | undefined>;
|
|
87
|
+
/** A refreshed OAuth `credential` sealed and kept as the server's, only while its row's credential is still the one the
|
|
88
|
+
* refresh started from (`row.sealed`): Mcp.keepRefreshed, whose `holder` is the refresh lease's. */
|
|
89
|
+
export declare function keepRefreshedCredential(store: {
|
|
90
|
+
mcp: Pick<Mcp, "keepRefreshed">;
|
|
91
|
+
}, sealKey: Buffer, row: Pick<McpServerRow, "name" | "url" | "sealed">, credential: McpCredential, holder: string): Promise<boolean>;
|
|
75
92
|
/** Saves an MCP OAuth sign-in in flight, its secret parts sealed (§7, AAD mcp_oauth_pending|<state>|sealed): the PKCE
|
|
76
93
|
* verifier and the OAuth `client` (which carries the owner's pre-registered client_secret, and any secret a dynamic
|
|
77
94
|
* registration issued) as one sealed JSON blob the store never opens. The rest of the sign-in's working state (discovery,
|
package/dist/mcp-store.js
CHANGED
|
@@ -70,24 +70,49 @@ 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();
|
|
84
95
|
}
|
|
96
|
+
/** One saved server's row (its credential stays sealed), or undefined when no such server. */
|
|
97
|
+
export async function getMcpServer(store, name) {
|
|
98
|
+
return store.mcp.server(name);
|
|
99
|
+
}
|
|
100
|
+
/** The credential of a row already read, opened (§7), as openServerCredential does for a name. */
|
|
101
|
+
export function openMcpRow(sealKey, row) {
|
|
102
|
+
return openMcpCredential(sealKey, { name: row.name, url: row.url, sealed: row.sealed });
|
|
103
|
+
}
|
|
85
104
|
/** A saved server's credential opened (§7): the credential with its origin, or why not — none saved; unopened (another
|
|
86
105
|
* seal key, or not the store's format); damaged (saved for another origin than the row's url, so it is never sent).
|
|
87
106
|
* undefined when no such server. */
|
|
88
107
|
export async function openServerCredential(store, sealKey, name) {
|
|
89
|
-
const row = await store
|
|
90
|
-
return row &&
|
|
108
|
+
const row = await getMcpServer(store, name);
|
|
109
|
+
return row && openMcpRow(sealKey, row);
|
|
110
|
+
}
|
|
111
|
+
/** A refreshed OAuth `credential` sealed and kept as the server's, only while its row's credential is still the one the
|
|
112
|
+
* refresh started from (`row.sealed`): Mcp.keepRefreshed, whose `holder` is the refresh lease's. */
|
|
113
|
+
export async function keepRefreshedCredential(store, sealKey, row, credential, holder) {
|
|
114
|
+
const { kept } = await store.mcp.keepRefreshed(row.name, { seen: row.sealed, sealed: sealMcpCredential(sealKey, row.name, credential, row.url), holder, tokenLeftMs: tokenLeftOf(credential) });
|
|
115
|
+
return kept;
|
|
91
116
|
}
|
|
92
117
|
/** Saves an MCP OAuth sign-in in flight, its secret parts sealed (§7, AAD mcp_oauth_pending|<state>|sealed): the PKCE
|
|
93
118
|
* verifier and the OAuth `client` (which carries the owner's pre-registered client_secret, and any secret a dynamic
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The most of one upstream answer read, by the probe and the gateway alike. */
|
|
2
|
+
export declare const MAX_RESPONSE: number;
|
|
3
|
+
/** `text` with every credential value in `values` replaced, whole and as its bare token (with any one-word scheme, such
|
|
4
|
+
* as `Bearer ` or `Basic `, taken off): an upstream answer or error that echoes a header, or only its token, never shows
|
|
5
|
+
* it to the model, the harness, the owner's save or the run's files. A value of any length is cut (a short token is a
|
|
6
|
+
* valid credential); only an empty one is skipped. */
|
|
7
|
+
export declare const scrub: (text: string, values: Iterable<string>) => string;
|
|
8
|
+
/** `res` with its body cut off at MAX_RESPONSE: past it the body errors, and `over` is told. */
|
|
9
|
+
export declare function capped(res: Response, over?: () => void): Response;
|
|
10
|
+
/** The official SDK client and its Streamable HTTP transport for `url`, one setup for every MCP connection: the
|
|
11
|
+
* 2026-07-28 revision first, a 2025-era server through its initialize. `fetch` is how every request goes (the caller's
|
|
12
|
+
* guard: credential, address check, no redirect, cap); `requestInit` is what the transport sends with each. */
|
|
13
|
+
export declare function mcpClient(sdk: typeof import("@modelcontextprotocol/client"), { name, version, url, fetch, requestInit }: {
|
|
14
|
+
name: string;
|
|
15
|
+
version: string;
|
|
16
|
+
url: URL;
|
|
17
|
+
fetch: typeof globalThis.fetch;
|
|
18
|
+
requestInit?: RequestInit;
|
|
19
|
+
}): {
|
|
20
|
+
client: import("@modelcontextprotocol/client").Client;
|
|
21
|
+
transport: import("@modelcontextprotocol/client").StreamableHTTPClientTransport;
|
|
22
|
+
};
|
package/dist/mcp-wire.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// What the MCP probe (mcp-probe.ts: a save's and a refresh's listing) and the run's gateway (mcp-gateway.ts: a call) share
|
|
2
|
+
// of the wire: the one credential scrubber, the one cap on an upstream answer, and the one SDK client the two build.
|
|
3
|
+
// A leaf: no store, no run, nothing sent here.
|
|
4
|
+
/** The most of one upstream answer read, by the probe and the gateway alike. */
|
|
5
|
+
export const MAX_RESPONSE = 4 * 1024 * 1024;
|
|
6
|
+
/** `text` with every credential value in `values` replaced, whole and as its bare token (with any one-word scheme, such
|
|
7
|
+
* as `Bearer ` or `Basic `, taken off): an upstream answer or error that echoes a header, or only its token, never shows
|
|
8
|
+
* it to the model, the harness, the owner's save or the run's files. A value of any length is cut (a short token is a
|
|
9
|
+
* valid credential); only an empty one is skipped. */
|
|
10
|
+
export const scrub = (text, values) => [...values].flatMap((value) => [value, value.replace(/^[A-Za-z][A-Za-z0-9_-]*\s+(?=\S+$)/, "")]).sort((a, b) => b.length - a.length).reduce((out, value) => (value.length > 0 ? out.split(value).join("[redacted]") : out), text);
|
|
11
|
+
/** `res` with its body cut off at MAX_RESPONSE: past it the body errors, and `over` is told. */
|
|
12
|
+
export function capped(res, over) {
|
|
13
|
+
if (!res.body)
|
|
14
|
+
return res;
|
|
15
|
+
let read = 0;
|
|
16
|
+
const body = res.body.pipeThrough(new TransformStream({
|
|
17
|
+
transform(chunk, controller) {
|
|
18
|
+
read += chunk.byteLength;
|
|
19
|
+
if (read > MAX_RESPONSE) {
|
|
20
|
+
over?.();
|
|
21
|
+
controller.error(new Error(`its answer is longer than ${MAX_RESPONSE} bytes`));
|
|
22
|
+
}
|
|
23
|
+
else
|
|
24
|
+
controller.enqueue(chunk);
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
27
|
+
return new Response(body, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
28
|
+
}
|
|
29
|
+
/** The official SDK client and its Streamable HTTP transport for `url`, one setup for every MCP connection: the
|
|
30
|
+
* 2026-07-28 revision first, a 2025-era server through its initialize. `fetch` is how every request goes (the caller's
|
|
31
|
+
* guard: credential, address check, no redirect, cap); `requestInit` is what the transport sends with each. */
|
|
32
|
+
export function mcpClient(sdk, { name, version, url, fetch, requestInit }) {
|
|
33
|
+
const transport = new sdk.StreamableHTTPClientTransport(url, { fetch, ...(requestInit ? { requestInit } : {}) });
|
|
34
|
+
const client = new sdk.Client({ name, version }, { capabilities: {}, versionNegotiation: { mode: "auto" } });
|
|
35
|
+
return { client, transport };
|
|
36
|
+
}
|
package/dist/mcp.js
CHANGED
|
@@ -90,7 +90,7 @@ export const TOOLS = [
|
|
|
90
90
|
authenticated: true, credential: "token", server: "agentrun-serve", version: context.version,
|
|
91
91
|
base_url: `${context.origin}/v2`, console_url: `${context.origin}/`,
|
|
92
92
|
harnesses: (caps.harnesses ?? []).filter((h) => h.available).map((h) => h.id),
|
|
93
|
-
tools: (caps.tools ?? []).filter((t) => t.available).map((t) => t.name),
|
|
93
|
+
tools: (caps.tools ?? []).filter((t) => t.available && !t.meta).map((t) => t.name),
|
|
94
94
|
efforts: caps.features?.efforts ?? [], thinking: caps.features?.thinking ?? [], models: caps.models ?? {},
|
|
95
95
|
};
|
|
96
96
|
return resultOf({ ...answer, bytes: Buffer.from(JSON.stringify(me)) });
|
|
@@ -149,12 +149,12 @@ export const TOOLS = [
|
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
151
|
name: "runs_start", title: "Start a run", annotations: { ...WRITE, openWorldHint: true },
|
|
152
|
-
description: "Starts a run of the agent's current revision, or of `revision` (POST /v2/agents/{agent_id}/runs), and answers at once with the run, queued. Then call runs_get until its status is completed, failed or cancelled, or input_required (answer with runs_respond). An agentic run's input is {content: \"the first message\"}; a workflow run's is what its workflow's input schema takes.",
|
|
152
|
+
description: "Starts a run of the agent's current revision, or of `revision` (POST /v2/agents/{agent_id}/runs), and answers at once with the run, queued. Then call runs_get until its status is completed, failed or cancelled, or input_required (answer with runs_respond). An agentic run's input is {content: \"the first message\"}, or, when its definition has an input_schema (agents_list shows it), an object that schema takes: its fields by name, content among them when the schema says so; one it refuses is input_invalid, a path per field. A workflow run's is what its workflow's input schema takes.",
|
|
153
153
|
inputSchema: {
|
|
154
154
|
type: "object", required: ["agent_id", "input"],
|
|
155
155
|
properties: {
|
|
156
156
|
agent_id: AGENT_ID,
|
|
157
|
-
input: { type: "object", description: "{content: string} for an agentic agent; the workflow's input for a workflow agent." },
|
|
157
|
+
input: { type: "object", description: "{content: string} for an agentic agent, or what its definition's input_schema takes; the workflow's input for a workflow agent." },
|
|
158
158
|
effort: { type: "string", enum: ["low", "medium", "high"], description: "Optional: how hard the model works on this run. Absent, the revision's own." },
|
|
159
159
|
revision: { type: "string", description: "Optional: a revision id of this agent to run in place of the current one." },
|
|
160
160
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CODEMODE, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH } from "@parcha/agentrun-kernel";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// The names of the three host tools over a run's own tools (runner/meta-tools.ts), apart from them so the gate reads them
|
|
2
|
+
// without loading a script sandbox. They are the kernel's, with the one predicate that offers them.
|
|
3
|
+
export { CODEMODE, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH } from "@parcha/agentrun-kernel";
|
|
@@ -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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ModelCost } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { Wire } from "@parcha/agentrun-kernel";
|
|
2
3
|
import { type HarnessEntry } from "./harness-table.js";
|
|
3
4
|
import type { Revision } from "./agent-rows.js";
|
|
4
5
|
/** The child's environment names the faux module by absolute path. */
|
|
@@ -157,6 +158,18 @@ export declare function runModels(env: NodeJS.ProcessEnv, ref: string | PinnedMo
|
|
|
157
158
|
byTier: Map<"default" | "fast" | "strong", ModelRef>;
|
|
158
159
|
unpriced: Set<string>;
|
|
159
160
|
}>;
|
|
161
|
+
/**
|
|
162
|
+
* The wire a gateway model (`id`, as the gateway is sent it; `named`, the provider a revision's ref named) goes on: a
|
|
163
|
+
* Claude model on Anthropic's Messages API, any other on OpenAI's Responses API. The one fact is the model's vendor, read
|
|
164
|
+
* from the id serve already has: the provider segment before the model's own id (`anthropic/claude-sonnet-5.5`, a ref's
|
|
165
|
+
* named provider when ids go bare), else, where the id names none (`claude-opus-5-5`), Anthropic's provider in pi-ai's
|
|
166
|
+
* catalog listing it in either version form (catalogPrices). Why: the Responses API has no cache_control, so through a
|
|
167
|
+
* gateway's bridge from it to Anthropic a Claude model reads no prompt cache (the same 12.5k-token prompt sent twice read 0
|
|
168
|
+
* cached tokens), where on Messages pi-ai marks the system prompt, the last tool and the last user block, and the second
|
|
169
|
+
* read is cached. Every gateway serve ships for serves Messages beside Responses under the same base: LiteLLM's proxy, and
|
|
170
|
+
* OpenRouter (`<base>/v1/messages`, as pi-ai's own OpenRouter entries for Claude send).
|
|
171
|
+
*/
|
|
172
|
+
export declare function gatewayWire(catalog: ReadonlyMap<string, readonly Listed[]>, id: string, named: string | undefined): Wire;
|
|
160
173
|
/** 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
|
|
161
174
|
* entry's onWire: claude-agent's, never the gateway's; an OpenAI model reached through OpenRouter alone, which needs no
|
|
162
175
|
* OpenAI key: provider.ts modelOn). Anywhere else, the run's usual models (runModels). Shared by the per-run process
|
package/dist/model.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// Where a run's model comes from. An agentic revision names one as "provider/model-id", or names none and runs on this
|
|
2
2
|
// host's default (`AGENT_MODEL`). A workflow's model node names a tier, and the host maps it: fast to
|
|
3
3
|
// `AGENT_MODEL_FAST`, strong to `AGENT_MODEL_STRONG`, each falling back to the default. With `--faux` every model is the
|
|
4
|
-
// faux module's (no key, no network); with `AGENT_MODEL_BASE_URL` every model id goes to that one
|
|
5
|
-
//
|
|
4
|
+
// faux module's (no key, no network); with `AGENT_MODEL_BASE_URL` every model id goes to that one gateway, a Claude model
|
|
5
|
+
// on Anthropic's Messages API and any other on OpenAI's Responses API (gatewayWire); otherwise pi-ai's providers serve
|
|
6
|
+
// it, each with its keys from the server's secrets (PROVIDER_KEYS): the
|
|
6
7
|
// launcher hands the server every one, and a run's process those of its model's provider, never in an environment.
|
|
7
8
|
import { withLocalModels } from "./local-models.js";
|
|
8
9
|
import { pathToFileURL } from "node:url";
|
|
9
10
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
10
11
|
import { HARNESS_TABLE_ENV, harnessOf } from "./harness-table.js";
|
|
11
12
|
import { gatewayBase } from "./provider.js";
|
|
13
|
+
import { modelFormWhy } from "./model-form.js";
|
|
12
14
|
// Leaves, which the key rows below read as this module loads, in any import order (wires.ts, adapter-facts.ts).
|
|
13
15
|
import { ADAPTER_FACTS } from "./adapter-facts.js";
|
|
14
16
|
import { WIRES } from "./wires.js";
|
|
@@ -165,21 +167,24 @@ export async function chooseModel(env, ref, tier = "default", harness = DEFAULT_
|
|
|
165
167
|
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" };
|
|
166
168
|
// A revision's model, and a key's default (MODEL_KEYS: "provider/model"), go as the gateway takes its ids (bare: the
|
|
167
169
|
// part after the provider), that provider pricing them; the host's own AGENT_MODEL or tier id goes as configured.
|
|
168
|
-
|
|
170
|
+
// A name equal to one of the host's configured ids (the picker lists them: model-form.ts pickerCandidates) is that
|
|
171
|
+
// host id whoever names it, so a revision that picks it is sent what the host configured, never a cut of it.
|
|
172
|
+
const configured = [env.AGENT_MODEL, env.AGENT_MODEL_FAST, env.AGENT_MODEL_STRONG].includes(named);
|
|
173
|
+
const id = ref ?? (configured ? undefined : named);
|
|
169
174
|
const slash = id?.indexOf("/") ?? -1;
|
|
170
|
-
const sent = id && env.AGENT_MODEL_GATEWAY_IDS === "bare" ? id.slice(slash + 1) : named;
|
|
175
|
+
const sent = id && !configured && env.AGENT_MODEL_GATEWAY_IDS === "bare" ? id.slice(slash + 1) : named;
|
|
171
176
|
return { model: { provider: MODEL_PROVIDER, modelId: sent }, ...(id && slash > 0 ? { namedProvider: id.slice(0, slash) } : {}) };
|
|
172
177
|
}
|
|
173
178
|
if (!named)
|
|
174
179
|
return { why: `${none}: ${ADD_A_KEY}`, host: true, needs: "key" };
|
|
175
180
|
const slash = named.indexOf("/");
|
|
176
181
|
if (slash < 1)
|
|
177
|
-
return { why:
|
|
182
|
+
return { why: modelFormWhy(env, harness, named, ref === undefined), host: ref === undefined, needs: "model" };
|
|
178
183
|
const [provider, modelId] = [named.slice(0, slash), named.slice(slash + 1)];
|
|
179
184
|
const models = await providerModels(env);
|
|
180
185
|
const model = models.getModel(provider, modelId);
|
|
181
186
|
if (!model)
|
|
182
|
-
return { why:
|
|
187
|
+
return { why: modelFormWhy(env, harness, named, ref === undefined), host: ref === undefined, needs: "model" };
|
|
183
188
|
// A gateway ANTHROPIC_BASE_URL names that a key may not go to (gatewayBase): no Anthropic model runs, by its words.
|
|
184
189
|
const refused = provider === "anthropic" ? anthropicRefusal(models) : undefined;
|
|
185
190
|
if (refused)
|
|
@@ -249,6 +254,7 @@ export const PROVIDER_KEYS = {
|
|
|
249
254
|
"qwen-token-plan": ["QWEN_TOKEN_PLAN_API_KEY"],
|
|
250
255
|
"qwen-token-plan-cn": ["QWEN_TOKEN_PLAN_CN_API_KEY"],
|
|
251
256
|
"qwen-token-plan-individual": ["QWEN_TOKEN_PLAN_API_KEY"],
|
|
257
|
+
"qwen-token-plan-individual-cn": ["QWEN_TOKEN_PLAN_CN_API_KEY"],
|
|
252
258
|
radius: ["RADIUS_API_KEY"],
|
|
253
259
|
together: ["TOGETHER_API_KEY"],
|
|
254
260
|
typesafe: ["TYPESAFE_API_KEY"],
|
|
@@ -377,10 +383,15 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
|
|
|
377
383
|
return { models, model, byTier, unpriced };
|
|
378
384
|
}
|
|
379
385
|
// One base rule for every harness (provider.ts' gatewayBase): one trailing /v1 off, then the API under <base>/v1, so
|
|
380
|
-
// <gw>/api and <gw>/api/v1 both reach <gw>/api/v1/responses, as OpenRouter serves
|
|
381
|
-
|
|
382
|
-
const
|
|
383
|
-
const
|
|
386
|
+
// <gw>/api and <gw>/api/v1 both reach <gw>/api/v1/responses and <gw>/api/v1/messages, as OpenRouter serves them. pi-ai's
|
|
387
|
+
// Responses client takes the base with its /v1, its Messages client adds /v1/messages itself.
|
|
388
|
+
const base = gatewayBase("AGENT_MODEL_BASE_URL", env.AGENT_MODEL_BASE_URL);
|
|
389
|
+
const baseUrl = `${base}/v1`;
|
|
390
|
+
const [{ openAIResponsesApi }, { anthropicMessagesApi }] = await Promise.all([import("@earendil-works/pi-ai/api/openai-responses.lazy"), import("@earendil-works/pi-ai/api/anthropic-messages.lazy")]);
|
|
391
|
+
const catalog = await catalogPrices();
|
|
392
|
+
const namedOf = new Map([...byTier].map(([tier, model]) => [model.modelId, namedBy.get(tier)]));
|
|
393
|
+
const wireOf = (id) => gatewayWire(catalog, id, namedOf.get(id));
|
|
394
|
+
const priced = await gatewayPrices(env, byTier, namedBy, catalog);
|
|
384
395
|
const priceOf = (id) => {
|
|
385
396
|
const cost = priced.get(id);
|
|
386
397
|
if (cost)
|
|
@@ -389,34 +400,59 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
|
|
|
389
400
|
unpriced.add(id);
|
|
390
401
|
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
391
402
|
};
|
|
392
|
-
// `models` is priced first, which fills `unpriced`, and `api` is chosen by it.
|
|
403
|
+
// `models` is priced first, which fills `unpriced`, and `api` is chosen by it. Each model on its wire (gatewayWire), and
|
|
404
|
+
// the provider's client per wire, which pi-ai picks by the model's `api`.
|
|
405
|
+
const gatewayModels = ids.map((id) => {
|
|
406
|
+
const cost = priceOf(id);
|
|
407
|
+
const shared = { id, name: id, provider: MODEL_PROVIDER, reasoning: true, input: ["text", "image"], cost, contextWindow: 128_000, maxTokens: 32_000 };
|
|
408
|
+
return wireOf(id) === "anthropic-messages" ? { ...shared, api: "anthropic-messages", baseUrl: base } : { ...shared, api: "openai-responses", baseUrl, compat: { supportsDeveloperRole: false } };
|
|
409
|
+
});
|
|
410
|
+
const each = (api) => (unpriced.size ? unpricedApi(api, unpriced, ai) : api);
|
|
393
411
|
models.setProvider(createProvider({
|
|
394
412
|
id: MODEL_PROVIDER,
|
|
395
413
|
baseUrl,
|
|
396
414
|
auth: { apiKey: { name: GATEWAY_KEY_ENV, resolve: async () => ({ auth: { apiKey: env[GATEWAY_KEY_ENV] || "none" }, source: GATEWAY_KEY_ENV }) } },
|
|
397
|
-
models:
|
|
398
|
-
|
|
399
|
-
cost: priceOf(id), contextWindow: 128_000, maxTokens: 32_000, compat: { supportsDeveloperRole: false },
|
|
400
|
-
})),
|
|
401
|
-
api: unpriced.size ? unpricedApi(openAIResponsesApi(), unpriced, ai) : openAIResponsesApi(),
|
|
415
|
+
models: gatewayModels,
|
|
416
|
+
api: { "openai-responses": each(openAIResponsesApi()), "anthropic-messages": each(anthropicMessagesApi()) },
|
|
402
417
|
}));
|
|
403
418
|
return { models, model, byTier, unpriced };
|
|
404
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* The wire a gateway model (`id`, as the gateway is sent it; `named`, the provider a revision's ref named) goes on: a
|
|
422
|
+
* Claude model on Anthropic's Messages API, any other on OpenAI's Responses API. The one fact is the model's vendor, read
|
|
423
|
+
* from the id serve already has: the provider segment before the model's own id (`anthropic/claude-sonnet-5.5`, a ref's
|
|
424
|
+
* named provider when ids go bare), else, where the id names none (`claude-opus-5-5`), Anthropic's provider in pi-ai's
|
|
425
|
+
* catalog listing it in either version form (catalogPrices). Why: the Responses API has no cache_control, so through a
|
|
426
|
+
* gateway's bridge from it to Anthropic a Claude model reads no prompt cache (the same 12.5k-token prompt sent twice read 0
|
|
427
|
+
* cached tokens), where on Messages pi-ai marks the system prompt, the last tool and the last user block, and the second
|
|
428
|
+
* read is cached. Every gateway serve ships for serves Messages beside Responses under the same base: LiteLLM's proxy, and
|
|
429
|
+
* OpenRouter (`<base>/v1/messages`, as pi-ai's own OpenRouter entries for Claude send).
|
|
430
|
+
*/
|
|
431
|
+
export function gatewayWire(catalog, id, named) {
|
|
432
|
+
const segments = id.split("/");
|
|
433
|
+
const own = segments.at(-1);
|
|
434
|
+
const vendor = segments.length > 1 ? segments.at(-2) : named;
|
|
435
|
+
if (vendor !== undefined)
|
|
436
|
+
return vendor === "anthropic" ? "anthropic-messages" : "openai-responses";
|
|
437
|
+
const anthropic = [own, ...flippedForms(own)].some((form) => (catalog.get(form) ?? []).some((entry) => entry.provider === "anthropic"));
|
|
438
|
+
return anthropic ? "anthropic-messages" : "openai-responses";
|
|
439
|
+
}
|
|
405
440
|
/** The price of each gateway model of `byTier` (its tiers' models, `namedBy` the provider a ref named), in USD per million
|
|
406
441
|
* input, output, cache-read and cache-write tokens: a tier's own price (`AGENT_MODEL_FAST_PRICE`,
|
|
407
442
|
* `AGENT_MODEL_STRONG_PRICE`) goes with its model, else the default's (`AGENT_MODEL_PRICE`); a model two tiers share
|
|
408
443
|
* takes the default's. With none set, pi-ai's catalog prices it (catalogPrice), from a metered entry alone: a $0 one (a
|
|
409
444
|
* plan's, a free tier's) never prices it (#2339). An id with no price
|
|
410
445
|
* is absent: its answers carry no total (unpricedApi) and a harness books it unknown (adapters.ts priceOf), so the run's
|
|
411
|
-
* cost reads unknown, never $0, and a cap refuses it (blockersOf refuses a capped run on it before it starts).
|
|
412
|
-
|
|
446
|
+
* cost reads unknown, never $0, and a cap refuses it (blockersOf refuses a capped run on it before it starts). `listed`:
|
|
447
|
+
* the catalog (catalogPrices') when the caller has read it already. */
|
|
448
|
+
async function gatewayPrices(env, byTier, namedBy, listed) {
|
|
413
449
|
const prices = new Map();
|
|
414
450
|
for (const tier of ["default", "fast", "strong"]) {
|
|
415
451
|
const id = byTier.get(tier)?.modelId;
|
|
416
452
|
if (id !== undefined && !prices.has(id))
|
|
417
453
|
prices.set(id, { given: (tier !== "default" && env[`${TIER_ENV[tier]}_PRICE`]) || env.AGENT_MODEL_PRICE || undefined, named: namedBy.get(tier) });
|
|
418
454
|
}
|
|
419
|
-
const catalog = [...prices.values()].some((price) => price.given === undefined) ? await catalogPrices() : new Map();
|
|
455
|
+
const catalog = listed ?? ([...prices.values()].some((price) => price.given === undefined) ? await catalogPrices() : new Map());
|
|
420
456
|
const out = new Map();
|
|
421
457
|
for (const [id, { given, named }] of prices) {
|
|
422
458
|
if (given === undefined) {
|
|
@@ -598,12 +634,14 @@ export function catalogPrice(catalog, id, named) {
|
|
|
598
634
|
return catalogEntries(catalog, id, undefined);
|
|
599
635
|
return catalogEntries(catalog, id.slice(slash + 1), id.slice(0, slash));
|
|
600
636
|
}
|
|
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-
|
|
637
|
+
/** The forms of `id` with its version's separators written the other way: each digit-dash-digit as a dot (gpt-6-1-terra,
|
|
638
|
+
* 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,
|
|
639
|
+
* claude-haiku-5-5). Not `id` itself. */
|
|
604
640
|
const flippedForms = (id) => [...new Set([id.replace(/(\d)-(\d)/g, "$1.$2"), id.replace(/(\d)\.(\d)/g, "$1-$2")])].filter((form) => form !== id);
|
|
605
641
|
/** `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
|
|
642
|
+
* forms' (flippedForms), only when every metered entry they hold has one base price (input, output, cacheRead,
|
|
643
|
+
* cacheWrite; a long-context `tiers` table is not part of the comparison), the entry that carries `tiers` when one does
|
|
644
|
+
* (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
645
|
* 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
646
|
* under subscription plans, at $0, and the gateways that meter them under the vendor's). A flip that finds different
|
|
609
647
|
* 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 +653,14 @@ function catalogEntries(catalog, id, named) {
|
|
|
615
653
|
return listed;
|
|
616
654
|
const flipped = flippedForms(id).flatMap((form) => (catalog.get(form) ?? []).filter(({ cost }) => cost.input + cost.output > 0));
|
|
617
655
|
if (flipped.length) {
|
|
618
|
-
const
|
|
619
|
-
|
|
656
|
+
const base = ({ input, output, cacheRead, cacheWrite }) => JSON.stringify([input, output, cacheRead, cacheWrite]);
|
|
657
|
+
const one = base(flipped[0].cost);
|
|
658
|
+
if (!flipped.every((entry) => base(entry.cost) === one))
|
|
659
|
+
return undefined;
|
|
660
|
+
const tiered = flipped.filter((entry) => entry.cost.tiers?.length);
|
|
661
|
+
if (tiered.some((entry) => JSON.stringify(entry.cost.tiers) !== JSON.stringify(tiered[0].cost.tiers)))
|
|
662
|
+
return undefined;
|
|
663
|
+
return (tiered[0] ?? flipped[0]).cost;
|
|
620
664
|
}
|
|
621
665
|
return vendorPrice(catalog, id, named);
|
|
622
666
|
}
|