@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.39
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 +700 -0
- package/README.md +441 -177
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +1 -3
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +48 -23
- 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/bash-read-only.js +2 -1
- package/dist/browser-cost.js +52 -93
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -400
- package/dist/cap.js +6 -942
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +2 -6
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +25 -0
- package/dist/composio-preset.js +51 -8
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +12 -2
- package/dist/computer-live.js +21 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +18 -2
- package/dist/computer-view.js +21 -6
- package/dist/computer-viewer.js +40 -13
- package/dist/computers.d.ts +8 -2
- package/dist/computers.js +18 -8
- package/dist/console/assets/index-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/decisions.js +4 -0
- package/dist/email/account.d.ts +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/faux-computers.js +4 -2
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -22
- package/dist/harness-opencode/facts.js +5 -4
- package/dist/harness-opencode/host/policy.d.ts +4 -5
- package/dist/harness-opencode/host/policy.js +14 -33
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +8 -7
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +3 -3
- package/dist/hosted-search.js +51 -32
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +24 -4
- package/dist/learn/check.js +340 -7
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +250 -0
- package/dist/learn/compile.js +507 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +11 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +308 -0
- package/dist/learn/promote.js +321 -0
- package/dist/learn/refit.d.ts +48 -0
- package/dist/learn/refit.js +264 -0
- package/dist/learn/reflect.d.ts +5 -25
- package/dist/learn/reflect.js +14 -131
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +19 -16
- package/dist/learn/skills.js +157 -53
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +58 -2
- package/dist/learned-nodes.js +68 -5
- package/dist/learned-workflow.d.ts +58 -32
- package/dist/learned-workflow.js +215 -77
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +4 -4
- package/dist/learning-cost.d.ts +41 -11
- package/dist/learning-cost.js +31 -13
- package/dist/learning-routes.d.ts +12 -2
- package/dist/learning-routes.js +34 -6
- package/dist/learning-words.d.ts +8 -1
- package/dist/learning-words.js +11 -1
- package/dist/learning.d.ts +26 -1
- package/dist/learning.js +7 -4
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/llm.js +0 -3
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-gateway.d.ts +12 -20
- package/dist/mcp-gateway.js +16 -44
- package/dist/mcp-oauth.d.ts +5 -0
- package/dist/mcp-oauth.js +1 -1
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +113 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +102 -26
- package/dist/mcp-servers-store.js +151 -25
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +11 -0
- package/dist/mcp-store.js +16 -2
- 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 +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +39 -6
- package/dist/model.js +171 -32
- package/dist/monid.d.ts +50 -29
- package/dist/monid.js +234 -143
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +705 -126
- package/dist/paid-calls.d.ts +34 -32
- package/dist/paid-calls.js +52 -104
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +7 -2
- package/dist/port-models.js +5 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +8 -3
- package/dist/propose.js +28 -7
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +17 -2
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/reflect-range.js +2 -1
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +23 -1
- package/dist/run-launch.js +17 -4
- package/dist/run-learning-served.d.ts +84 -0
- package/dist/run-manifest.d.ts +8 -0
- package/dist/run-manifest.js +33 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +12 -10
- package/dist/run-view.d.ts +59 -41
- package/dist/run-view.js +128 -64
- package/dist/runnable.d.ts +13 -8
- package/dist/runnable.js +77 -60
- package/dist/runner/adapter-loop.d.ts +60 -15
- package/dist/runner/adapter-loop.js +1406 -464
- package/dist/runner/adapter-run-spec.d.ts +45 -14
- package/dist/runner/adapter-run-spec.js +200 -116
- package/dist/runner/adapters/pi.d.ts +40 -7
- package/dist/runner/adapters/pi.js +149 -38
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +150 -66
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +5 -3
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +149 -5
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +8 -5
- package/dist/runner/end-of-run.js +11 -6
- package/dist/runner/feedback-round.d.ts +79 -0
- package/dist/runner/feedback-round.js +127 -0
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +55 -13
- package/dist/runner/journal-kinds.js +19 -0
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +58 -19
- package/dist/runner/learning-end.js +316 -115
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +21 -1
- package/dist/runner/learning-loop.js +24 -6
- package/dist/runner/learning-seed.d.ts +4 -0
- package/dist/runner/learning-seed.js +14 -0
- package/dist/runner/loop-contract.d.ts +19 -3
- package/dist/runner/loop.d.ts +34 -1
- package/dist/runner/loop.js +55 -1
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +20 -53
- package/dist/runner/mcp-run.js +22 -88
- package/dist/runner/meta-tools.d.ts +44 -0
- package/dist/runner/meta-tools.js +344 -0
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +128 -42
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +149 -19
- package/dist/runner/monid-run.d.ts +18 -0
- package/dist/runner/monid-run.js +170 -0
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +146 -0
- package/dist/runner/promotion.js +803 -0
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +147 -49
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +34 -8
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +226 -0
- package/dist/runner/workflow-first.js +293 -0
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +32 -19
- package/dist/runner/workflow-spec.d.ts +5 -1
- package/dist/runner/workflow-spec.js +63 -48
- package/dist/runs-over-store.d.ts +41 -4
- package/dist/runs-over-store.js +64 -22
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +108 -20
- package/dist/server.js +874 -157
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +22 -7
- package/dist/store/agent-body.js +23 -14
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/connection.js +3 -1
- 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/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.js +3 -0
- package/dist/store/schema.d.ts +16 -0
- package/dist/store/schema.js +47 -8
- 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 +8 -1
- package/dist/store/sqlite/run-patch.js +33 -10
- package/dist/store/sqlite/store.js +184 -28
- package/dist/store/store.d.ts +98 -21
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +30 -1
- package/dist/store-reads/journal.js +141 -83
- package/dist/store-reads/learning.d.ts +179 -13
- package/dist/store-reads/learning.js +230 -68
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +109 -37
- package/dist/template-eval.d.ts +87 -16
- package/dist/template-eval.js +605 -120
- package/dist/template-github-permissions.d.ts +2 -2
- package/dist/template-github-permissions.js +2 -1
- 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 +274 -52
- package/dist/templates.js +670 -201
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +7 -5
- package/dist/timeline/index.js +7 -5
- package/dist/timeline/labels.d.ts +11 -4
- package/dist/timeline/labels.js +122 -8
- package/dist/timeline/origin.d.ts +20 -6
- package/dist/timeline/origin.js +13 -6
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +76 -20
- package/dist/timeline/timeline.js +184 -39
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +103 -76
- package/dist/tool-gate.js +200 -127
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +29 -0
- package/dist/tool-list.js +50 -0
- package/dist/tool-names.d.ts +76 -0
- package/dist/tool-names.js +101 -0
- package/dist/tool-plane.d.ts +34 -28
- package/dist/tool-plane.js +72 -37
- package/dist/tools.d.ts +59 -15
- package/dist/tools.js +46 -42
- package/dist/trigger-adapter.d.ts +85 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +228 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +94 -9
- package/dist/triggers.js +263 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +91 -50
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +6 -8
- package/dist/web-fetch.js +10 -53
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +25 -9
- package/dist/workspace/computer-deps.js +82 -38
- package/dist/workspace/computer-for-claim.d.ts +60 -4
- package/dist/workspace/computer-for-claim.js +203 -45
- package/dist/workspace/computer-hold.js +7 -1
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +2 -3
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +31 -11
- package/dist/workspace/kind-skills/phone/SKILL.md +29 -14
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +33 -1
- package/dist/workspace/resolve-computer.js +37 -16
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +40 -23
- package/dist/workspace/run-tools.js +46 -19
- package/dist/wrap-up.d.ts +35 -0
- package/dist/wrap-up.js +48 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +220 -60
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +46 -16
- 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 +3 -3
- 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/off-by-one/graders/no-repo-reads.md +2 -1
- 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/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -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 +5 -4
- package/templates/code-review/skills/review/REVIEWER.md +5 -4
- package/templates/code-review/skills/review/SKILL.md +11 -6
- 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 +5 -4
- 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 +5 -4
- 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-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -7
- package/dist/runner/adapters/pi-computer.js +0 -43
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -38
- package/dist/tool-budget.js +0 -62
- package/dist/workspace/computer-script.d.ts +0 -37
- package/dist/workspace/computer-script.js +0 -138
- 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/model-form.d.ts
CHANGED
|
@@ -13,6 +13,17 @@ export declare function formOf(env: NodeJS.ProcessEnv, vendor: string, id: strin
|
|
|
13
13
|
* (harness.ts harnessOffers drops those it does not run). Behind serve's gateway every id is the gateway's own string, so
|
|
14
14
|
* the host's tier models stand for what it runs; with the faux model none is offered. */
|
|
15
15
|
export declare function pickerCandidates(env: NodeJS.ProcessEnv, harness: string): string[];
|
|
16
|
+
/** A model a person may pick that runs at $0 (local-models.ts isFree, the kernel's freeModel on its catalog price: all
|
|
17
|
+
* zeros, every tier's too), in the form it takes, with its context window in tokens. */
|
|
18
|
+
export type FreeModel = {
|
|
19
|
+
id: string;
|
|
20
|
+
context_window: number;
|
|
21
|
+
};
|
|
22
|
+
/** The free models offered for `harness` on this server, besides pickerCandidates' (harness.ts harnessOffers drops those
|
|
23
|
+
* it does not run): OpenRouter's chat models whose catalog price is all zeros (pi-ai's own and serve's ADDED_MODELS), on
|
|
24
|
+
* pi with OpenRouter's key, by id. None for an adapter harness (each runs its own wire's vendor), behind a gateway (its
|
|
25
|
+
* ids are its own) or with the faux model. */
|
|
26
|
+
export declare function freeCandidates(env: NodeJS.ProcessEnv, harness: string): Promise<FreeModel[]>;
|
|
16
27
|
/** The model `given` most likely means, in the form this harness takes, or undefined when none is obvious: the same id
|
|
17
28
|
* with a dot for a dash or the other way, a missing provider, or a name without its `claude-` ("Sonnet 5.5"). */
|
|
18
29
|
export declare function likelyModel(env: NodeJS.ProcessEnv, harness: string, given: string): string | undefined;
|
package/dist/model-form.js
CHANGED
|
@@ -6,6 +6,8 @@ import { ADAPTER_FACTS } from "./adapter-facts.js";
|
|
|
6
6
|
import { FAUX_ENV, MODEL_KEYS } from "./model.js";
|
|
7
7
|
import { openRouterName } from "./provider.js";
|
|
8
8
|
import { WIRES } from "./wires.js";
|
|
9
|
+
import { PLAN_PROVIDER, planOf, signedIn } from "./chatgpt-plan.js";
|
|
10
|
+
import { PLAN_HARNESSES } from "./harness.js";
|
|
9
11
|
/** The current models a person may pick, by vendor, in the vendor's own ids (Anthropic's dashes; OpenRouter's dotted name
|
|
10
12
|
* for the same model is derived, provider.ts openRouterName). The everyday model first: it is the example a refusal gives.
|
|
11
13
|
* A candidate a harness cannot run on this server (one pi-ai's catalog does not list) is dropped before it is served
|
|
@@ -39,7 +41,21 @@ export function pickerCandidates(env, harness) {
|
|
|
39
41
|
if (env.AGENT_MODEL_BASE_URL && facts?.wire !== "anthropic-messages")
|
|
40
42
|
return [...new Set([env.AGENT_MODEL, env.AGENT_MODEL_FAST, env.AGENT_MODEL_STRONG].filter((id) => Boolean(id)))];
|
|
41
43
|
const vendors = vendorsOf(harness);
|
|
42
|
-
|
|
44
|
+
// Signed in to a ChatGPT plan, its models first for a harness that runs on it (`chatgpt/<model-id>`).
|
|
45
|
+
const plan = PLAN_HARNESSES.includes(harness) && signedIn(env) ? (planOf(env)?.models ?? []).map((id) => `${PLAN_PROVIDER}/${id}`) : [];
|
|
46
|
+
return [...plan, ...PICKABLE.filter((p) => vendors.includes(p.vendor)).flatMap((p) => p.ids.map((id) => formOf(env, p.vendor, id)))];
|
|
47
|
+
}
|
|
48
|
+
/** The free models offered for `harness` on this server, besides pickerCandidates' (harness.ts harnessOffers drops those
|
|
49
|
+
* it does not run): OpenRouter's chat models whose catalog price is all zeros (pi-ai's own and serve's ADDED_MODELS), on
|
|
50
|
+
* pi with OpenRouter's key, by id. None for an adapter harness (each runs its own wire's vendor), behind a gateway (its
|
|
51
|
+
* ids are its own) or with the faux model. */
|
|
52
|
+
export async function freeCandidates(env, harness) {
|
|
53
|
+
if (env[FAUX_ENV] || env.AGENT_MODEL_BASE_URL || !env.OPENROUTER_API_KEY || ADAPTER_FACTS.some((f) => f.id === harness))
|
|
54
|
+
return [];
|
|
55
|
+
const [{ builtinModels }, { withLocalModels, isFree }] = await Promise.all([import("@earendil-works/pi-ai/providers/all"), import("./local-models.js")]);
|
|
56
|
+
return withLocalModels(builtinModels()).getModels("openrouter").filter(isFree)
|
|
57
|
+
.map((model) => ({ id: `openrouter/${model.id}`, context_window: model.contextWindow }))
|
|
58
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
43
59
|
}
|
|
44
60
|
/** A model id with its spelling taken out (case, spaces, dots, dashes), and the provider's segments off. */
|
|
45
61
|
const spelled = (given) => (given.split("/").pop() ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
package/dist/model.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ModelCost } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { Wire } from "@parcha/agentrun-kernel";
|
|
3
|
+
import type { ThinkingLevelMap } from "./port-models.js";
|
|
2
4
|
import { type HarnessEntry } from "./harness-table.js";
|
|
3
5
|
import type { Revision } from "./agent-rows.js";
|
|
4
6
|
/** The child's environment names the faux module by absolute path. */
|
|
@@ -53,6 +55,14 @@ export declare const MODEL_KEYS: readonly {
|
|
|
53
55
|
* starts (MODEL_KEYS' fields), OpenRouter's named first, as its one key runs every harness. The order a default is
|
|
54
56
|
* taken in is MODEL_KEYS' own. */
|
|
55
57
|
export declare const ADD_A_KEY: string;
|
|
58
|
+
/** Whether a ChatGPT sign-in here would give `harness` its model, where it wants a key now: `signed_out` (none yet) or
|
|
59
|
+
* `expired` (sign in again). None where it would not: a harness that needs a key whatever the plan (PLAN_HARNESSES), a
|
|
60
|
+
* server that cannot sign in (a runner, a faux model), one behind serve's gateway (its model is the gateway's), one
|
|
61
|
+
* signed in, or one whose AGENT_MODEL names a key's model the harness runs (hostModel keeps it signed in or not). */
|
|
62
|
+
export declare function planWouldRun(env: NodeJS.ProcessEnv, harness: string): "signed_out" | "expired" | undefined;
|
|
63
|
+
/** `reason`, `harness`'s want of a key for its default model, with what a ChatGPT sign-in here would do about it
|
|
64
|
+
* (planWouldRun), in words; as it was where the sign-in would not. */
|
|
65
|
+
export declare function withPlanWords(env: NodeJS.ProcessEnv, harness: string, reason: string): string;
|
|
56
66
|
/** Whether `harness` runs the model `id` (its entry in the harness table: harness-table.ts): pi any; one on an adapter, its
|
|
57
67
|
* wire's vendor's model (or that vendor's on OpenRouter), or behind serve's gateway, on the wire it serves, any id. */
|
|
58
68
|
export declare const harnessRuns: (env: NodeJS.ProcessEnv, id: string, harness: string) => boolean;
|
|
@@ -64,8 +74,9 @@ export declare const harnessRuns: (env: NodeJS.ProcessEnv, id: string, harness:
|
|
|
64
74
|
export declare function hostModel(env: NodeJS.ProcessEnv, tier?: Tier, harness?: string): string | undefined;
|
|
65
75
|
/** `route_prefix`: the routing prefix this server puts before a gateway's model ids (MODEL_PROVIDER), which a reader takes off
|
|
66
76
|
* to show the gateway's own id; null with any other source. */
|
|
67
|
-
/** The values `models.source` takes here: a faux module, a gateway,
|
|
68
|
-
|
|
77
|
+
/** The values `models.source` takes here: a faux module, a gateway, each provider with its own key, or, with no key, a
|
|
78
|
+
* person's ChatGPT plan signed in here (chatgpt-plan.ts). */
|
|
79
|
+
export declare const MODEL_SOURCES: readonly ["faux", "gateway", "providers", "chatgpt"];
|
|
69
80
|
export type ModelSource = {
|
|
70
81
|
source: (typeof MODEL_SOURCES)[number];
|
|
71
82
|
route_prefix: string | null;
|
|
@@ -149,7 +160,8 @@ export type FauxHelpers = {
|
|
|
149
160
|
/** The models for a run, and its model of each tier it uses and of no other: an agentic revision's `ref` (or the
|
|
150
161
|
* default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
|
|
151
162
|
* The faux module's replies, the gateway in the environment, or pi-ai's providers. `unpriced`: the ids of its models
|
|
152
|
-
* serve has no price for (a gateway model the catalog does not list, with no price set), which a
|
|
163
|
+
* serve has no price for (a gateway model the catalog does not list, with no price set; an OpenRouter router), which a
|
|
164
|
+
* cap cannot be kept on.
|
|
153
165
|
* `tierRefs`: a model named for another tier (a subagent's model_tiers), chosen for it in place of the host's. */
|
|
154
166
|
export declare function runModels(env: NodeJS.ProcessEnv, ref: string | PinnedModel | undefined, tiers?: readonly Tier[], harness?: string, tierRefs?: Readonly<Partial<Record<Tier, string>>>): Promise<{
|
|
155
167
|
models: import("@earendil-works/pi-ai").MutableModels;
|
|
@@ -157,6 +169,18 @@ export declare function runModels(env: NodeJS.ProcessEnv, ref: string | PinnedMo
|
|
|
157
169
|
byTier: Map<"default" | "fast" | "strong", ModelRef>;
|
|
158
170
|
unpriced: Set<string>;
|
|
159
171
|
}>;
|
|
172
|
+
/**
|
|
173
|
+
* The wire a gateway model (`id`, as the gateway is sent it; `named`, the provider a revision's ref named) goes on: a
|
|
174
|
+
* Claude model on Anthropic's Messages API, any other on OpenAI's Responses API. The one fact is the model's vendor, read
|
|
175
|
+
* from the id serve already has: the provider segment before the model's own id (`anthropic/claude-sonnet-5.5`, a ref's
|
|
176
|
+
* named provider when ids go bare), else, where the id names none (`claude-opus-5-5`), Anthropic's provider in pi-ai's
|
|
177
|
+
* catalog listing it in either version form (catalogPrices). Why: the Responses API has no cache_control, so through a
|
|
178
|
+
* gateway's bridge from it to Anthropic a Claude model reads no prompt cache (the same 12.5k-token prompt sent twice read 0
|
|
179
|
+
* cached tokens), where on Messages pi-ai marks the system prompt, the last tool and the last user block, and the second
|
|
180
|
+
* read is cached. Every gateway serve ships for serves Messages beside Responses under the same base: LiteLLM's proxy, and
|
|
181
|
+
* OpenRouter (`<base>/v1/messages`, as pi-ai's own OpenRouter entries for Claude send).
|
|
182
|
+
*/
|
|
183
|
+
export declare function gatewayWire(catalog: ReadonlyMap<string, readonly Listed[]>, id: string, named: string | undefined): Wire;
|
|
160
184
|
/** 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
185
|
* entry's onWire: claude-agent's, never the gateway's; an OpenAI model reached through OpenRouter alone, which needs no
|
|
162
186
|
* OpenAI key: provider.ts modelOn). Anywhere else, the run's usual models (runModels). Shared by the per-run process
|
|
@@ -174,9 +198,10 @@ export declare function wireModels(entry: HarnessEntry, env: NodeJS.ProcessEnv,
|
|
|
174
198
|
export declare function runModelRef(env: NodeJS.ProcessEnv, revision: Revision): Promise<ModelRef | undefined>;
|
|
175
199
|
/** The models a run of `ref` (an agentic revision's own, else the host's) on `harness` would take, of `tiers`, that serve
|
|
176
200
|
* has no price for here: a gateway's (AGENT_MODEL_BASE_URL) id with no price set and none in the catalog in any form
|
|
177
|
-
* (gatewayPrices)
|
|
201
|
+
* (gatewayPrices), and OpenRouter's routers anywhere (their $0 is no price: routersOf). None else: pi-ai's providers
|
|
202
|
+
* price their own models, a $0 entry included, and a harness on a wire the gateway does not serve
|
|
178
203
|
* (Anthropic's Messages: provider.ts WIRES) prices
|
|
179
|
-
* by its catalog entry. One a cap cannot be kept on: capabilities' `models.priced`, and blockersOf's refusal of a capped
|
|
204
|
+
* by its catalog entry, and a ChatGPT plan's model costs no dollars. One a cap cannot be kept on: capabilities' `models.priced`, and blockersOf's refusal of a capped
|
|
180
205
|
* run. A model chooseModel cannot give is not this one's to say (its own blocker says why). */
|
|
181
206
|
export declare function unpricedModels(env: NodeJS.ProcessEnv, ref: string | undefined, tiers?: readonly Tier[], harness?: string): Promise<string[]>;
|
|
182
207
|
/** Why `models` (providerModels') send no request on Anthropic's route: ANTHROPIC_BASE_URL is a base a key may not go to,
|
|
@@ -195,9 +220,17 @@ export declare function providerModels(env: NodeJS.ProcessEnv): Promise<import("
|
|
|
195
220
|
export type Listed = {
|
|
196
221
|
provider: string;
|
|
197
222
|
cost: ModelCost;
|
|
223
|
+
thinkingLevelMap?: ThinkingLevelMap;
|
|
198
224
|
};
|
|
199
|
-
/** pi-ai's catalog list prices by model id: every provider's entry for it, in the catalog's order
|
|
225
|
+
/** pi-ai's catalog list prices by model id: every provider's entry for it, in the catalog's order, with the effort each
|
|
226
|
+
* thinking level asks for where the entry says. */
|
|
200
227
|
export declare function catalogPrices(): Promise<Map<string, Listed[]>>;
|
|
228
|
+
/** A gateway model's thinking levels in `catalog` (catalogPrices'), by its own id (the last segment of `id`) in either
|
|
229
|
+
* version form: the vendor's entry (the id's segment before it, else `named`); else each level every entry that says
|
|
230
|
+
* agrees on (gpt-6.1-sol's entries differ on `minimal` alone: openai-codex's asks low), a level they differ on left to
|
|
231
|
+
* pi-ai's default. None: undefined, pi-ai's defaults. So pi through a gateway at thinking off asks gpt-6.1-sol for no
|
|
232
|
+
* effort, as its catalog entries say (off: null), not the "none" it refuses. */
|
|
233
|
+
export declare function catalogThinking(catalog: ReadonlyMap<string, readonly Listed[]>, id: string, named: string | undefined): ThinkingLevelMap | undefined;
|
|
201
234
|
/** A gateway model's price in `catalog` (catalogPrices'), by its id as the host or the revision names it: a ref that names
|
|
202
235
|
* its provider (`named`), priced as that provider's entry, whether the id went whole or bare; a host model set whole
|
|
203
236
|
* (`vendor/model`) the catalog does not list as it is, priced as its model, the vendor named; else the id as it is. Each
|
package/dist/model.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
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
|
-
import { withLocalModels } from "./local-models.js";
|
|
8
|
+
import { isRouter, withLocalModels } from "./local-models.js";
|
|
8
9
|
import { pathToFileURL } from "node:url";
|
|
9
|
-
import { DEFAULT_HARNESS } from "./harness.js";
|
|
10
|
+
import { DEFAULT_HARNESS, PLAN_HARNESSES } from "./harness.js";
|
|
10
11
|
import { HARNESS_TABLE_ENV, harnessOf } from "./harness-table.js";
|
|
11
12
|
import { gatewayBase } from "./provider.js";
|
|
12
13
|
import { modelFormWhy } from "./model-form.js";
|
|
@@ -14,6 +15,7 @@ import { modelFormWhy } from "./model-form.js";
|
|
|
14
15
|
import { ADAPTER_FACTS } from "./adapter-facts.js";
|
|
15
16
|
import { WIRES } from "./wires.js";
|
|
16
17
|
import { authContextOf } from "./secrets.js";
|
|
18
|
+
import { EXPIRED, PLAN_DEFAULT_MODEL, PLAN_ORIGIN, PLAN_PROVIDER, planOf, signedIn, SIGNED_OUT } from "./chatgpt-plan.js";
|
|
17
19
|
/** The child's environment names the faux module by absolute path. */
|
|
18
20
|
export const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
|
|
19
21
|
/** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
|
|
@@ -71,6 +73,28 @@ const rowModel = (row, harness) => {
|
|
|
71
73
|
* starts (MODEL_KEYS' fields), OpenRouter's named first, as its one key runs every harness. The order a default is
|
|
72
74
|
* taken in is MODEL_KEYS' own. */
|
|
73
75
|
export const ADD_A_KEY = `add a model key in Settings → Model keys, or set ${[...MODEL_KEYS].sort((a, b) => Number(b.id === "openrouter") - Number(a.id === "openrouter")).map((row) => row.field).join(", ").replace(/, ([^,]+)$/, " or $1")} where AgentRun starts.`;
|
|
76
|
+
/** Whether a ChatGPT sign-in here would give `harness` its model, where it wants a key now: `signed_out` (none yet) or
|
|
77
|
+
* `expired` (sign in again). None where it would not: a harness that needs a key whatever the plan (PLAN_HARNESSES), a
|
|
78
|
+
* server that cannot sign in (a runner, a faux model), one behind serve's gateway (its model is the gateway's), one
|
|
79
|
+
* signed in, or one whose AGENT_MODEL names a key's model the harness runs (hostModel keeps it signed in or not). */
|
|
80
|
+
export function planWouldRun(env, harness) {
|
|
81
|
+
const plan = planOf(env);
|
|
82
|
+
if (!plan || env[FAUX_ENV] || env.AGENT_MODEL_BASE_URL || !PLAN_HARNESSES.includes(harness) || plan.state === "signed_in")
|
|
83
|
+
return undefined;
|
|
84
|
+
const named = env.AGENT_MODEL;
|
|
85
|
+
if (named && !named.startsWith(`${PLAN_PROVIDER}/`) && harnessRuns(env, named, harness))
|
|
86
|
+
return undefined;
|
|
87
|
+
return plan.state;
|
|
88
|
+
}
|
|
89
|
+
/** `reason`, `harness`'s want of a key for its default model, with what a ChatGPT sign-in here would do about it
|
|
90
|
+
* (planWouldRun), in words; as it was where the sign-in would not. */
|
|
91
|
+
export function withPlanWords(env, harness, reason) {
|
|
92
|
+
const state = planWouldRun(env, harness);
|
|
93
|
+
if (!state)
|
|
94
|
+
return reason;
|
|
95
|
+
const words = state === "expired" ? "your ChatGPT sign-in expired: sign in again (Settings → Model keys)" : "or sign in with ChatGPT (Settings → Model keys) to run it on your ChatGPT plan";
|
|
96
|
+
return `${reason.replace(/\.$/, "")}; ${words}.`;
|
|
97
|
+
}
|
|
74
98
|
/** Whether `harness` runs the model `id` (its entry in the harness table: harness-table.ts): pi any; one on an adapter, its
|
|
75
99
|
* wire's vendor's model (or that vendor's on OpenRouter), or behind serve's gateway, on the wire it serves, any id. */
|
|
76
100
|
export const harnessRuns = (env, id, harness) => harnessOf(env, harness)?.runs(env, id) ?? true;
|
|
@@ -83,15 +107,24 @@ export function hostModel(env, tier = "default", harness = DEFAULT_HARNESS) {
|
|
|
83
107
|
for (const id of [env[TIER_ENV[tier]], env.AGENT_MODEL])
|
|
84
108
|
if (id && harnessRuns(env, id, harness))
|
|
85
109
|
return id;
|
|
110
|
+
// Signed in to a ChatGPT plan, codex and pi run on it by default: a key's model is then named (`openai/<id>`).
|
|
111
|
+
if (PLAN_HARNESSES.includes(harness) && signedIn(env) && !env.AGENT_MODEL_BASE_URL)
|
|
112
|
+
return `${PLAN_PROVIDER}/${planModel(env)}`;
|
|
86
113
|
const row = MODEL_KEYS.find((row) => env[row.field] && row.harnesses.includes(harness));
|
|
87
114
|
return row ? rowModel(row, harness) : env[DEFAULT_MODEL_ENV] || undefined;
|
|
88
115
|
}
|
|
116
|
+
/** The plan's model a run that names none takes: GPT-6.1 Sol where the plan lists it, else the plan's first. */
|
|
117
|
+
const planModel = (env) => {
|
|
118
|
+
const models = planOf(env)?.models ?? [];
|
|
119
|
+
return models.includes(PLAN_DEFAULT_MODEL) ? PLAN_DEFAULT_MODEL : (models[0] ?? PLAN_DEFAULT_MODEL);
|
|
120
|
+
};
|
|
89
121
|
/** A faux model id per tier: `faux-1`, or the id a tier's variable names. */
|
|
90
122
|
const fauxModel = (env, tier) => (tier === "default" ? undefined : env[TIER_ENV[tier]]) || "faux-1";
|
|
91
123
|
/** `route_prefix`: the routing prefix this server puts before a gateway's model ids (MODEL_PROVIDER), which a reader takes off
|
|
92
124
|
* to show the gateway's own id; null with any other source. */
|
|
93
|
-
/** The values `models.source` takes here: a faux module, a gateway,
|
|
94
|
-
|
|
125
|
+
/** The values `models.source` takes here: a faux module, a gateway, each provider with its own key, or, with no key, a
|
|
126
|
+
* person's ChatGPT plan signed in here (chatgpt-plan.ts). */
|
|
127
|
+
export const MODEL_SOURCES = ["faux", "gateway", "providers", "chatgpt"];
|
|
95
128
|
/** What capabilities say about models here: where they come from, and the model of each tier (`default` is also what a
|
|
96
129
|
* revision that names none runs on). */
|
|
97
130
|
export function modelSource(env) {
|
|
@@ -100,6 +133,8 @@ export function modelSource(env) {
|
|
|
100
133
|
return { source: "faux", route_prefix: null, ...each((tier) => `faux/${fauxModel(env, tier)}`) };
|
|
101
134
|
if (env.AGENT_MODEL_BASE_URL)
|
|
102
135
|
return { source: "gateway", route_prefix: MODEL_PROVIDER, ...each((tier) => (hostModel(env, tier) ? `${MODEL_PROVIDER}/${hostModel(env, tier)}` : null)) };
|
|
136
|
+
if (signedIn(env) && !Object.values(PROVIDER_KEYS).flat().some((name) => env[name]))
|
|
137
|
+
return { source: "chatgpt", route_prefix: null, ...each((tier) => hostModel(env, tier) ?? null) };
|
|
103
138
|
return { source: "providers", route_prefix: null, ...each((tier) => hostModel(env, tier) ?? null) };
|
|
104
139
|
}
|
|
105
140
|
/** A workflow's nodes as the DSL's inspection lists them, each read from the document at its path: only what the
|
|
@@ -153,6 +188,8 @@ export async function chooseModel(env, ref, tier = "default", harness = DEFAULT_
|
|
|
153
188
|
const named = ref ?? hostModel(env, tier, harness);
|
|
154
189
|
// In a person's words (a first run from npx sees them): what to add and where. Operator detail is the README's.
|
|
155
190
|
const none = tier === "default" ? "No model yet" : `No model yet for this workflow's ${tier} tier`;
|
|
191
|
+
if (named?.startsWith(`${PLAN_PROVIDER}/`))
|
|
192
|
+
return planChoice(env, named.slice(PLAN_PROVIDER.length + 1));
|
|
156
193
|
if (env.AGENT_MODEL_BASE_URL) {
|
|
157
194
|
// A gateway its key may not go to (the one base rule, gatewayBase) runs no model, in its words: capabilities read it
|
|
158
195
|
// not ready, a save warns, and a run is refused before its process starts, so the key is never handed to one.
|
|
@@ -175,7 +212,7 @@ export async function chooseModel(env, ref, tier = "default", harness = DEFAULT_
|
|
|
175
212
|
return { model: { provider: MODEL_PROVIDER, modelId: sent }, ...(id && slash > 0 ? { namedProvider: id.slice(0, slash) } : {}) };
|
|
176
213
|
}
|
|
177
214
|
if (!named)
|
|
178
|
-
return { why: `${none}: ${ADD_A_KEY}
|
|
215
|
+
return { why: withPlanWords(env, harness, `${none}: ${ADD_A_KEY}`), host: true, needs: "key" };
|
|
179
216
|
const slash = named.indexOf("/");
|
|
180
217
|
if (slash < 1)
|
|
181
218
|
return { why: modelFormWhy(env, harness, named, ref === undefined), host: ref === undefined, needs: "model" };
|
|
@@ -195,6 +232,18 @@ export async function chooseModel(env, ref, tier = "default", harness = DEFAULT_
|
|
|
195
232
|
}
|
|
196
233
|
return { model: { provider, modelId } };
|
|
197
234
|
}
|
|
235
|
+
/** A model of the ChatGPT plan (`chatgpt/<model-id>`): runs where the plan is signed in and lists it, else why not, in
|
|
236
|
+
* words. Its token is never read here: a run asks for it at each request. */
|
|
237
|
+
function planChoice(env, modelId) {
|
|
238
|
+
const plan = planOf(env);
|
|
239
|
+
if (plan?.state === "expired")
|
|
240
|
+
return { why: EXPIRED, host: true, needs: "key" };
|
|
241
|
+
if (plan?.state !== "signed_in")
|
|
242
|
+
return { why: SIGNED_OUT, host: true, needs: "key" };
|
|
243
|
+
if (!plan.models.includes(modelId))
|
|
244
|
+
return { why: `The ChatGPT plan signed in here has no model ${modelId}: pick one of ${plan.models.map((id) => `${PLAN_PROVIDER}/${id}`).join(", ")}.`, host: false, needs: "model" };
|
|
245
|
+
return { model: { provider: PLAN_PROVIDER, modelId } };
|
|
246
|
+
}
|
|
198
247
|
/** The choice of a run whose start pinned its model: the pin itself, never chosen again. A gateway's pin (MODEL_PROVIDER)
|
|
199
248
|
* is the id the gateway was sent then, which no ref chooses back (joined to its provider it names no gateway model, and
|
|
200
249
|
* bare ids would cut it again), so it goes exactly as pinned, priced as main prices it (its namedProvider) while the
|
|
@@ -290,7 +339,8 @@ export function thinkingLevel(value) {
|
|
|
290
339
|
/** The models for a run, and its model of each tier it uses and of no other: an agentic revision's `ref` (or the
|
|
291
340
|
* default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
|
|
292
341
|
* The faux module's replies, the gateway in the environment, or pi-ai's providers. `unpriced`: the ids of its models
|
|
293
|
-
* serve has no price for (a gateway model the catalog does not list, with no price set), which a
|
|
342
|
+
* serve has no price for (a gateway model the catalog does not list, with no price set; an OpenRouter router), which a
|
|
343
|
+
* cap cannot be kept on.
|
|
294
344
|
* `tierRefs`: a model named for another tier (a subagent's model_tiers), chosen for it in place of the host's. */
|
|
295
345
|
export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT_HARNESS, tierRefs = {}) {
|
|
296
346
|
const ai = await import("@earendil-works/pi-ai");
|
|
@@ -309,8 +359,9 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
|
|
|
309
359
|
const model = byTier.get("default");
|
|
310
360
|
if (!faux && !env.AGENT_MODEL_BASE_URL) {
|
|
311
361
|
// Each provider's key from `env`, which holds this process's secrets, never from process.env (secrets.ts); Anthropic's
|
|
312
|
-
// at ANTHROPIC_BASE_URL when set (providerModels).
|
|
313
|
-
|
|
362
|
+
// at ANTHROPIC_BASE_URL when set (providerModels). pi-ai's providers price their own models, but for OpenRouter's
|
|
363
|
+
// routers, whose catalog zeros are no price (routersOf).
|
|
364
|
+
return { models: withRequestKeys(await providerModels(env), env), model, byTier, unpriced: routersOf(byTier.values()) };
|
|
314
365
|
}
|
|
315
366
|
const ids = [...new Set([...byTier.values()].map((m) => m.modelId))];
|
|
316
367
|
const models = createModels({ authContext: authContextOf(env) });
|
|
@@ -382,10 +433,15 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
|
|
|
382
433
|
return { models, model, byTier, unpriced };
|
|
383
434
|
}
|
|
384
435
|
// One base rule for every harness (provider.ts' gatewayBase): one trailing /v1 off, then the API under <base>/v1, so
|
|
385
|
-
// <gw>/api and <gw>/api/v1 both reach <gw>/api/v1/responses, as OpenRouter serves
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
const
|
|
436
|
+
// <gw>/api and <gw>/api/v1 both reach <gw>/api/v1/responses and <gw>/api/v1/messages, as OpenRouter serves them. pi-ai's
|
|
437
|
+
// Responses client takes the base with its /v1, its Messages client adds /v1/messages itself.
|
|
438
|
+
const base = gatewayBase("AGENT_MODEL_BASE_URL", env.AGENT_MODEL_BASE_URL);
|
|
439
|
+
const baseUrl = `${base}/v1`;
|
|
440
|
+
const [{ openAIResponsesApi }, { anthropicMessagesApi }] = await Promise.all([import("@earendil-works/pi-ai/api/openai-responses.lazy"), import("@earendil-works/pi-ai/api/anthropic-messages.lazy")]);
|
|
441
|
+
const catalog = await catalogPrices();
|
|
442
|
+
const namedOf = new Map([...byTier].map(([tier, model]) => [model.modelId, namedBy.get(tier)]));
|
|
443
|
+
const wireOf = (id) => gatewayWire(catalog, id, namedOf.get(id));
|
|
444
|
+
const priced = await gatewayPrices(env, byTier, namedBy, catalog);
|
|
389
445
|
const priceOf = (id) => {
|
|
390
446
|
const cost = priced.get(id);
|
|
391
447
|
if (cost)
|
|
@@ -394,34 +450,61 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
|
|
|
394
450
|
unpriced.add(id);
|
|
395
451
|
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
396
452
|
};
|
|
397
|
-
// `models` is priced first, which fills `unpriced`, and `api` is chosen by it.
|
|
453
|
+
// `models` is priced first, which fills `unpriced`, and `api` is chosen by it. Each model on its wire (gatewayWire), and
|
|
454
|
+
// the provider's client per wire, which pi-ai picks by the model's `api`.
|
|
455
|
+
const gatewayModels = ids.map((id) => {
|
|
456
|
+
const cost = priceOf(id);
|
|
457
|
+
// The effort each thinking level asks for, as the catalog says of the model (catalogThinking): sol's off sends none.
|
|
458
|
+
const thinking = catalogThinking(catalog, id, namedOf.get(id));
|
|
459
|
+
const shared = { id, name: id, provider: MODEL_PROVIDER, reasoning: true, input: ["text", "image"], cost, contextWindow: 128_000, maxTokens: 32_000, ...(thinking ? { thinkingLevelMap: thinking } : {}) };
|
|
460
|
+
return wireOf(id) === "anthropic-messages" ? { ...shared, api: "anthropic-messages", baseUrl: base } : { ...shared, api: "openai-responses", baseUrl, compat: { supportsDeveloperRole: false } };
|
|
461
|
+
});
|
|
462
|
+
const each = (api) => (unpriced.size ? unpricedApi(api, unpriced, ai) : api);
|
|
398
463
|
models.setProvider(createProvider({
|
|
399
464
|
id: MODEL_PROVIDER,
|
|
400
465
|
baseUrl,
|
|
401
466
|
auth: { apiKey: { name: GATEWAY_KEY_ENV, resolve: async () => ({ auth: { apiKey: env[GATEWAY_KEY_ENV] || "none" }, source: GATEWAY_KEY_ENV }) } },
|
|
402
|
-
models:
|
|
403
|
-
|
|
404
|
-
cost: priceOf(id), contextWindow: 128_000, maxTokens: 32_000, compat: { supportsDeveloperRole: false },
|
|
405
|
-
})),
|
|
406
|
-
api: unpriced.size ? unpricedApi(openAIResponsesApi(), unpriced, ai) : openAIResponsesApi(),
|
|
467
|
+
models: gatewayModels,
|
|
468
|
+
api: { "openai-responses": each(openAIResponsesApi()), "anthropic-messages": each(anthropicMessagesApi()) },
|
|
407
469
|
}));
|
|
408
470
|
return { models, model, byTier, unpriced };
|
|
409
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* The wire a gateway model (`id`, as the gateway is sent it; `named`, the provider a revision's ref named) goes on: a
|
|
474
|
+
* Claude model on Anthropic's Messages API, any other on OpenAI's Responses API. The one fact is the model's vendor, read
|
|
475
|
+
* from the id serve already has: the provider segment before the model's own id (`anthropic/claude-sonnet-5.5`, a ref's
|
|
476
|
+
* named provider when ids go bare), else, where the id names none (`claude-opus-5-5`), Anthropic's provider in pi-ai's
|
|
477
|
+
* catalog listing it in either version form (catalogPrices). Why: the Responses API has no cache_control, so through a
|
|
478
|
+
* gateway's bridge from it to Anthropic a Claude model reads no prompt cache (the same 12.5k-token prompt sent twice read 0
|
|
479
|
+
* cached tokens), where on Messages pi-ai marks the system prompt, the last tool and the last user block, and the second
|
|
480
|
+
* read is cached. Every gateway serve ships for serves Messages beside Responses under the same base: LiteLLM's proxy, and
|
|
481
|
+
* OpenRouter (`<base>/v1/messages`, as pi-ai's own OpenRouter entries for Claude send).
|
|
482
|
+
*/
|
|
483
|
+
export function gatewayWire(catalog, id, named) {
|
|
484
|
+
const segments = id.split("/");
|
|
485
|
+
const own = segments.at(-1);
|
|
486
|
+
const vendor = segments.length > 1 ? segments.at(-2) : named;
|
|
487
|
+
if (vendor !== undefined)
|
|
488
|
+
return vendor === "anthropic" ? "anthropic-messages" : "openai-responses";
|
|
489
|
+
const anthropic = [own, ...flippedForms(own)].some((form) => (catalog.get(form) ?? []).some((entry) => entry.provider === "anthropic"));
|
|
490
|
+
return anthropic ? "anthropic-messages" : "openai-responses";
|
|
491
|
+
}
|
|
410
492
|
/** The price of each gateway model of `byTier` (its tiers' models, `namedBy` the provider a ref named), in USD per million
|
|
411
493
|
* input, output, cache-read and cache-write tokens: a tier's own price (`AGENT_MODEL_FAST_PRICE`,
|
|
412
494
|
* `AGENT_MODEL_STRONG_PRICE`) goes with its model, else the default's (`AGENT_MODEL_PRICE`); a model two tiers share
|
|
413
495
|
* takes the default's. With none set, pi-ai's catalog prices it (catalogPrice), from a metered entry alone: a $0 one (a
|
|
414
496
|
* plan's, a free tier's) never prices it (#2339). An id with no price
|
|
415
497
|
* is absent: its answers carry no total (unpricedApi) and a harness books it unknown (adapters.ts priceOf), so the run's
|
|
416
|
-
* cost reads unknown, never $0, and a cap refuses it (blockersOf refuses a capped run on it before it starts).
|
|
417
|
-
|
|
498
|
+
* cost reads unknown, never $0, and a cap refuses it (blockersOf refuses a capped run on it before it starts). `listed`:
|
|
499
|
+
* the catalog (catalogPrices') when the caller has read it already. */
|
|
500
|
+
async function gatewayPrices(env, byTier, namedBy, listed) {
|
|
418
501
|
const prices = new Map();
|
|
419
502
|
for (const tier of ["default", "fast", "strong"]) {
|
|
420
503
|
const id = byTier.get(tier)?.modelId;
|
|
421
504
|
if (id !== undefined && !prices.has(id))
|
|
422
505
|
prices.set(id, { given: (tier !== "default" && env[`${TIER_ENV[tier]}_PRICE`]) || env.AGENT_MODEL_PRICE || undefined, named: namedBy.get(tier) });
|
|
423
506
|
}
|
|
424
|
-
const catalog = [...prices.values()].some((price) => price.given === undefined) ? await catalogPrices() : new Map();
|
|
507
|
+
const catalog = listed ?? ([...prices.values()].some((price) => price.given === undefined) ? await catalogPrices() : new Map());
|
|
425
508
|
const out = new Map();
|
|
426
509
|
for (const [id, { given, named }] of prices) {
|
|
427
510
|
if (given === undefined) {
|
|
@@ -445,7 +528,12 @@ export async function wireModels(entry, env, ref) {
|
|
|
445
528
|
throw new Error(`${entry.id} does not run here.`);
|
|
446
529
|
if ("why" in choice)
|
|
447
530
|
throw new Error(choice.why);
|
|
448
|
-
return { models: await providerModels(env), model: choice.model, byTier: new Map([["default", choice.model]]), unpriced:
|
|
531
|
+
return { models: await providerModels(env), model: choice.model, byTier: new Map([["default", choice.model]]), unpriced: routersOf([choice.model]) };
|
|
532
|
+
}
|
|
533
|
+
/** The ids of `models` that are OpenRouter's routers (local-models.ts isRouter): pi-ai's catalog lists each at $0, the
|
|
534
|
+
* price of no model, so serve has none for them. */
|
|
535
|
+
function routersOf(models) {
|
|
536
|
+
return new Set([...models].flatMap((model) => (model && isRouter(model.provider, model.modelId) ? [model.modelId] : [])));
|
|
449
537
|
}
|
|
450
538
|
/** The run's model ref (provider + model id), resolved exactly as the per-run process resolved it (app.ts): a workflow's
|
|
451
539
|
* from its nodes' tiers; an agentic harness that chooses on its own wire by wireModels, else the run's usual models. The
|
|
@@ -462,26 +550,32 @@ export async function runModelRef(env, revision) {
|
|
|
462
550
|
}
|
|
463
551
|
/** The models a run of `ref` (an agentic revision's own, else the host's) on `harness` would take, of `tiers`, that serve
|
|
464
552
|
* has no price for here: a gateway's (AGENT_MODEL_BASE_URL) id with no price set and none in the catalog in any form
|
|
465
|
-
* (gatewayPrices)
|
|
553
|
+
* (gatewayPrices), and OpenRouter's routers anywhere (their $0 is no price: routersOf). None else: pi-ai's providers
|
|
554
|
+
* price their own models, a $0 entry included, and a harness on a wire the gateway does not serve
|
|
466
555
|
* (Anthropic's Messages: provider.ts WIRES) prices
|
|
467
|
-
* by its catalog entry. One a cap cannot be kept on: capabilities' `models.priced`, and blockersOf's refusal of a capped
|
|
556
|
+
* by its catalog entry, and a ChatGPT plan's model costs no dollars. One a cap cannot be kept on: capabilities' `models.priced`, and blockersOf's refusal of a capped
|
|
468
557
|
* run. A model chooseModel cannot give is not this one's to say (its own blocker says why). */
|
|
469
558
|
export async function unpricedModels(env, ref, tiers = ["default"], harness = DEFAULT_HARNESS) {
|
|
470
559
|
const facts = harnessOf(env, harness)?.facts;
|
|
471
|
-
if (env[FAUX_ENV]
|
|
560
|
+
if (env[FAUX_ENV])
|
|
472
561
|
return [];
|
|
473
562
|
const byTier = new Map();
|
|
474
563
|
const namedBy = new Map();
|
|
475
564
|
for (const tier of new Set(tiers)) {
|
|
476
565
|
const chosen = await chooseModel(env, tier === "default" ? ref : undefined, tier, harness);
|
|
477
|
-
|
|
566
|
+
// A ChatGPT plan's model is billed to the plan: it costs a run no dollars, so a cap is kept on it (CapModel.plan).
|
|
567
|
+
if ("why" in chosen || chosen.model.provider === PLAN_PROVIDER)
|
|
478
568
|
continue;
|
|
479
569
|
byTier.set(tier, chosen.model);
|
|
480
570
|
if (chosen.namedProvider)
|
|
481
571
|
namedBy.set(tier, chosen.namedProvider);
|
|
482
572
|
}
|
|
573
|
+
// OpenRouter's routers on any wire: their catalog zeros are no price (routersOf).
|
|
574
|
+
const routers = [...routersOf(byTier.values())];
|
|
575
|
+
if (!env.AGENT_MODEL_BASE_URL || (facts && !WIRES[facts.wire].gateway))
|
|
576
|
+
return routers;
|
|
483
577
|
const priced = await gatewayPrices(env, byTier, namedBy);
|
|
484
|
-
return [...new Set([...byTier.values()].map((model) => model.modelId)
|
|
578
|
+
return [...new Set([...routers, ...[...byTier.values()].map((model) => model.modelId).filter((id) => !priced.has(id))])];
|
|
485
579
|
}
|
|
486
580
|
/** The requests a Models object sends, each with its options third. */
|
|
487
581
|
const REQUESTS = new Set(["stream", "streamSimple", "complete", "completeSimple"]);
|
|
@@ -503,7 +597,7 @@ export const anthropicRefusal = (models) => models.getProvider("anthropic")?.[RE
|
|
|
503
597
|
export async function providerModels(env) {
|
|
504
598
|
const { builtinModels } = await import("@earendil-works/pi-ai/providers/all");
|
|
505
599
|
// With the prices serve sets over pi-ai's catalog (local-models.ts): OpenRouter's particle-1 at its list price.
|
|
506
|
-
const models = withLocalModels(builtinModels({ authContext: authContextOf(env) }));
|
|
600
|
+
const models = await withPlanModels(withLocalModels(builtinModels({ authContext: authContextOf(env) })), env);
|
|
507
601
|
if (!env.ANTHROPIC_BASE_URL)
|
|
508
602
|
return models;
|
|
509
603
|
const [{ createProvider }, { anthropicMessagesApi }] = await Promise.all([import("@earendil-works/pi-ai/models"), import("@earendil-works/pi-ai/api/anthropic-messages.lazy")]);
|
|
@@ -530,6 +624,28 @@ export async function providerModels(env) {
|
|
|
530
624
|
}));
|
|
531
625
|
return models;
|
|
532
626
|
}
|
|
627
|
+
/** `models` with the ChatGPT plan's models where `env` is signed in to one: provider `chatgpt`, each OpenAI's catalog entry
|
|
628
|
+
* of its id on OpenAI's Responses API, the plan's token as its key, asked at each request. Booked at no price: the plan
|
|
629
|
+
* pays for them, never this server's cap. */
|
|
630
|
+
async function withPlanModels(models, env) {
|
|
631
|
+
const plan = planOf(env);
|
|
632
|
+
if (plan?.state !== "signed_in")
|
|
633
|
+
return models;
|
|
634
|
+
const [ai, { createProvider }, { openAIResponsesApi }] = await Promise.all([import("@earendil-works/pi-ai"), import("@earendil-works/pi-ai/models"), import("@earendil-works/pi-ai/api/openai-responses.lazy")]);
|
|
635
|
+
const baseUrl = `${PLAN_ORIGIN}/v1`;
|
|
636
|
+
const none = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
637
|
+
// A model the catalog doesn't list yet is sent no effort at thinking off (`off: null`): a plan model may refuse "none".
|
|
638
|
+
const listed = plan.models.map((id) => ({ ...(models.getModel("openai", id) ?? { name: id, api: "openai-responses", reasoning: true, thinkingLevelMap: { off: null }, input: ["text", "image"], contextWindow: 272_000, maxTokens: 128_000 }), id, provider: PLAN_PROVIDER, baseUrl, cost: none }));
|
|
639
|
+
models.setProvider(createProvider({
|
|
640
|
+
id: PLAN_PROVIDER,
|
|
641
|
+
name: "ChatGPT plan",
|
|
642
|
+
baseUrl,
|
|
643
|
+
auth: { apiKey: { name: "ChatGPT sign-in", resolve: async () => ({ auth: { apiKey: await plan.token() }, source: PLAN_PROVIDER }) } },
|
|
644
|
+
models: listed,
|
|
645
|
+
api: unpricedApi(openAIResponsesApi(), new Set(plan.models), ai),
|
|
646
|
+
}));
|
|
647
|
+
return models;
|
|
648
|
+
}
|
|
533
649
|
/** `models` with each request's `env` option carrying the REQUEST_KEYS that `env` holds (a run's process holds only
|
|
534
650
|
* those of its model's provider), so Bedrock's request finds its AWS keys there: in no environment, which would hand
|
|
535
651
|
* them to every program the run starts. A request's own `env` wins. With none held, `models` as it is. */
|
|
@@ -580,17 +696,40 @@ function unpricedApi(api, unpriced, ai) {
|
|
|
580
696
|
});
|
|
581
697
|
return { ...api, stream: unpricedOf(api.stream.bind(api)), streamSimple: unpricedOf(api.streamSimple.bind(api)) };
|
|
582
698
|
}
|
|
583
|
-
/** pi-ai's catalog list prices by model id: every provider's entry for it, in the catalog's order
|
|
699
|
+
/** pi-ai's catalog list prices by model id: every provider's entry for it, in the catalog's order, with the effort each
|
|
700
|
+
* thinking level asks for where the entry says. */
|
|
584
701
|
export async function catalogPrices() {
|
|
585
702
|
const { builtinModels } = await import("@earendil-works/pi-ai/providers/all");
|
|
586
703
|
const out = new Map();
|
|
587
704
|
for (const model of withLocalModels(builtinModels()).getModels()) {
|
|
588
705
|
const { input = 0, output = 0, cacheRead = 0, cacheWrite = 0, tiers } = model.cost ?? {};
|
|
589
706
|
const listed = out.get(model.id) ?? out.set(model.id, []).get(model.id);
|
|
590
|
-
listed.push({ provider: model.provider, cost: { input, output, cacheRead, cacheWrite, ...(tiers ? { tiers } : {}) } });
|
|
707
|
+
listed.push({ provider: model.provider, cost: { input, output, cacheRead, cacheWrite, ...(tiers ? { tiers } : {}) }, ...(model.thinkingLevelMap ? { thinkingLevelMap: model.thinkingLevelMap } : {}) });
|
|
591
708
|
}
|
|
592
709
|
return out;
|
|
593
710
|
}
|
|
711
|
+
/** A gateway model's thinking levels in `catalog` (catalogPrices'), by its own id (the last segment of `id`) in either
|
|
712
|
+
* version form: the vendor's entry (the id's segment before it, else `named`); else each level every entry that says
|
|
713
|
+
* agrees on (gpt-6.1-sol's entries differ on `minimal` alone: openai-codex's asks low), a level they differ on left to
|
|
714
|
+
* pi-ai's default. None: undefined, pi-ai's defaults. So pi through a gateway at thinking off asks gpt-6.1-sol for no
|
|
715
|
+
* effort, as its catalog entries say (off: null), not the "none" it refuses. */
|
|
716
|
+
export function catalogThinking(catalog, id, named) {
|
|
717
|
+
const segments = id.split("/");
|
|
718
|
+
const own = segments.at(-1);
|
|
719
|
+
const vendor = segments.length > 1 ? segments.at(-2) : named;
|
|
720
|
+
const saying = [own, ...flippedForms(own)].flatMap((form) => catalog.get(form) ?? []).flatMap((entry) => (entry.thinkingLevelMap ? [{ provider: entry.provider, map: entry.thinkingLevelMap }] : []));
|
|
721
|
+
const vendors = saying.find((entry) => entry.provider === vendor);
|
|
722
|
+
if (vendors)
|
|
723
|
+
return vendors.map;
|
|
724
|
+
const agreed = {};
|
|
725
|
+
for (const level of new Set(saying.flatMap((entry) => Object.keys(entry.map)))) {
|
|
726
|
+
const values = new Set(saying.map((entry) => entry.map[level]));
|
|
727
|
+
const [value] = values;
|
|
728
|
+
if (values.size === 1 && value !== undefined)
|
|
729
|
+
agreed[level] = value;
|
|
730
|
+
}
|
|
731
|
+
return Object.keys(agreed).length ? agreed : undefined;
|
|
732
|
+
}
|
|
594
733
|
/** A gateway model's price in `catalog` (catalogPrices'), by its id as the host or the revision names it: a ref that names
|
|
595
734
|
* its provider (`named`), priced as that provider's entry, whether the id went whole or bare; a host model set whole
|
|
596
735
|
* (`vendor/model`) the catalog does not list as it is, priced as its model, the vendor named; else the id as it is. Each
|