@code-yeongyu/senpi 2026.7.14 → 2026.7.16-2
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 +143 -0
- package/README.md +6 -6
- package/dist/bun/cli.js +2 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/list-models.d.ts +2 -2
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +4 -3
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +14 -5
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +8 -4
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +81 -30
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-providers.js +1 -1
- package/dist/core/auth-providers.js.map +1 -1
- package/dist/core/auth-storage.d.ts +32 -87
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +158 -221
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/cache-stats.d.ts +2 -2
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +1 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/build.js +6 -1
- package/dist/core/dynamic-prompt/build.js.map +1 -1
- package/dist/core/extensions/builtin/bash-timeout/timeout.js +2 -2
- package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +22 -13
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.js +3 -2
- package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +8 -2
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +3 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +15 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/model-config.d.ts +589 -0
- package/dist/core/model-config.d.ts.map +1 -0
- package/dist/core/model-config.js +288 -0
- package/dist/core/model-config.js.map +1 -0
- package/dist/core/model-registry.d.ts +17 -146
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +69 -943
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +8 -5
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +19 -18
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +81 -0
- package/dist/core/model-runtime.d.ts.map +1 -0
- package/dist/core/model-runtime.js +442 -0
- package/dist/core/model-runtime.js.map +1 -0
- package/dist/core/models-store.d.ts +17 -0
- package/dist/core/models-store.d.ts.map +1 -0
- package/dist/core/models-store.js +46 -0
- package/dist/core/models-store.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +7 -2
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/provider-composer.d.ts +64 -0
- package/dist/core/provider-composer.d.ts.map +1 -0
- package/dist/core/provider-composer.js +406 -0
- package/dist/core/provider-composer.js.map +1 -0
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +2 -1
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -0
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -0
- package/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -0
- package/dist/core/remote-catalog-provider.js +83 -0
- package/dist/core/remote-catalog-provider.js.map +1 -0
- package/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -0
- package/dist/core/runtime-credentials.js +35 -0
- package/dist/core/runtime-credentials.js.map +1 -0
- package/dist/core/sdk.d.ts +11 -20
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +61 -89
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/skills.js +1 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +1 -11
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +10 -13
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +22 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +4 -8
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +14 -12
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +13 -4
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +84 -41
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +4 -4
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +14 -25
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +5 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +155 -129
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +70 -8
- package/dist/package-manager-cli.js.map +1 -1
- package/docs/custom-provider.md +8 -11
- package/docs/extensions.md +78 -555
- package/docs/models.md +4 -0
- package/docs/packages.md +1 -0
- package/docs/providers.md +23 -11
- package/docs/sdk.md +79 -105
- package/docs/usage.md +1 -0
- package/examples/AGENTS.md +34 -0
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/kimi-deferred-tools.ts +61 -0
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/02-custom-model.ts +5 -8
- package/examples/sdk/09-api-keys-and-oauth.ts +13 -31
- package/examples/sdk/12-full-control.ts +8 -13
- package/examples/sdk/README.md +14 -18
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +32 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/local-module-loader.ts +2 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/rewrite-imports.ts +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +32 -32
- package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
- package/node_modules/@earendil-works/pi-ai/README.md +80 -25
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +23 -42
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +10 -6
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +9 -10
- package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +54 -5
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +23 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +24 -6
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +97 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +307 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.js +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.js +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts +9 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/anthropic.js +51 -116
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/github-copilot.js +18 -77
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts +23 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +49 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts +9 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/openai-codex.js +61 -155
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/pkce.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/pkce.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.d.ts +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +316 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/xai.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/xai.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/xai.js +189 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/xai.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +2 -4
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +9 -7
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +49 -10
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js +17 -0
- package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/cli.js +58 -76
- package/node_modules/@earendil-works/pi-ai/dist/cli.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +42 -0
- package/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js +49 -22
- package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/images-models.d.ts +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/images-models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/images-models.js +5 -4
- package/node_modules/@earendil-works/pi-ai/dist/images-models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts +25 -0
- package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/models-store.js +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/models-store.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +69 -30
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +328 -120
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +217 -31
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/oauth.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/oauth.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +11 -6
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +51 -10
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.js +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js +13 -20
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-stream.d.ts +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-stream.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-stream.js +21 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-stream.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js +11 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +1 -6
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +1 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js +56 -5
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +66 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +42 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +36 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +19 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +36 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +19 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +57 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +19 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +42 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +175 -139
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.d.ts +26 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +59 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius.d.ts +9 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius.js +54 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +84 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +74 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.js +15 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +6 -114
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +3 -92
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js +9 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js +6 -2
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js +92 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js +54 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/index.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/index.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.d.ts +7 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.js +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts +19 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js +217 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js +46 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.d.ts +13 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.js +144 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js +208 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js +17 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.js +34 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +12 -5
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +6 -1
- package/node_modules/@earendil-works/pi-pty/native/prebuilds/darwin-arm64/senpi_pty.darwin-arm64.node +0 -0
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.js +22 -4
- package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +6 -6
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts +0 -27
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts +0 -32
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts +0 -58
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js +0 -122
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/load.d.ts +0 -5
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/load.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/load.js +0 -22
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/load.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts +0 -45
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts +0 -64
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.js +0 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.js.map +0 -1
- /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/device-code.d.ts +0 -0
- /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/device-code.js +0 -0
- /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/oauth-page.d.ts +0 -0
- /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/oauth-page.js +0 -0
- /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/pkce.d.ts +0 -0
- /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/pkce.js +0 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/** Immutable, credential-blind models.json snapshot. */
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { Type } from "typebox";
|
|
5
|
+
import { Compile } from "typebox/compile";
|
|
6
|
+
import { stripJsonComments } from "../utils/json.js";
|
|
7
|
+
import { normalizePath } from "../utils/paths.js";
|
|
8
|
+
const PercentileCutoffsSchema = Type.Object({
|
|
9
|
+
p50: Type.Optional(Type.Number()),
|
|
10
|
+
p75: Type.Optional(Type.Number()),
|
|
11
|
+
p90: Type.Optional(Type.Number()),
|
|
12
|
+
p99: Type.Optional(Type.Number()),
|
|
13
|
+
});
|
|
14
|
+
const OpenRouterRoutingSchema = Type.Object({
|
|
15
|
+
allow_fallbacks: Type.Optional(Type.Boolean()),
|
|
16
|
+
require_parameters: Type.Optional(Type.Boolean()),
|
|
17
|
+
data_collection: Type.Optional(Type.Union([Type.Literal("deny"), Type.Literal("allow")])),
|
|
18
|
+
zdr: Type.Optional(Type.Boolean()),
|
|
19
|
+
enforce_distillable_text: Type.Optional(Type.Boolean()),
|
|
20
|
+
order: Type.Optional(Type.Array(Type.String())),
|
|
21
|
+
only: Type.Optional(Type.Array(Type.String())),
|
|
22
|
+
ignore: Type.Optional(Type.Array(Type.String())),
|
|
23
|
+
quantizations: Type.Optional(Type.Array(Type.String())),
|
|
24
|
+
sort: Type.Optional(Type.Union([
|
|
25
|
+
Type.String(),
|
|
26
|
+
Type.Object({
|
|
27
|
+
by: Type.Optional(Type.String()),
|
|
28
|
+
partition: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
29
|
+
}),
|
|
30
|
+
])),
|
|
31
|
+
max_price: Type.Optional(Type.Object({
|
|
32
|
+
prompt: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
33
|
+
completion: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
34
|
+
image: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
35
|
+
audio: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
36
|
+
request: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
37
|
+
})),
|
|
38
|
+
preferred_min_throughput: Type.Optional(Type.Union([Type.Number(), PercentileCutoffsSchema])),
|
|
39
|
+
preferred_max_latency: Type.Optional(Type.Union([Type.Number(), PercentileCutoffsSchema])),
|
|
40
|
+
});
|
|
41
|
+
const VercelGatewayRoutingSchema = Type.Object({
|
|
42
|
+
only: Type.Optional(Type.Array(Type.String())),
|
|
43
|
+
order: Type.Optional(Type.Array(Type.String())),
|
|
44
|
+
});
|
|
45
|
+
const ThinkingLevelMapValueSchema = Type.Union([Type.String(), Type.Null()]);
|
|
46
|
+
const ThinkingLevelMapSchema = Type.Object({
|
|
47
|
+
off: Type.Optional(ThinkingLevelMapValueSchema),
|
|
48
|
+
minimal: Type.Optional(ThinkingLevelMapValueSchema),
|
|
49
|
+
low: Type.Optional(ThinkingLevelMapValueSchema),
|
|
50
|
+
medium: Type.Optional(ThinkingLevelMapValueSchema),
|
|
51
|
+
high: Type.Optional(ThinkingLevelMapValueSchema),
|
|
52
|
+
xhigh: Type.Optional(ThinkingLevelMapValueSchema),
|
|
53
|
+
max: Type.Optional(ThinkingLevelMapValueSchema),
|
|
54
|
+
});
|
|
55
|
+
const ChatTemplateKwargScalarSchema = Type.Union([Type.String(), Type.Number(), Type.Boolean(), Type.Null()]);
|
|
56
|
+
const ChatTemplateKwargVariableSchema = Type.Object({
|
|
57
|
+
$var: Type.Union([Type.Literal("thinking.enabled"), Type.Literal("thinking.effort")]),
|
|
58
|
+
omitWhenOff: Type.Optional(Type.Boolean()),
|
|
59
|
+
});
|
|
60
|
+
const ChatTemplateKwargSchema = Type.Union([ChatTemplateKwargScalarSchema, ChatTemplateKwargVariableSchema]);
|
|
61
|
+
const OpenAICompletionsCompatSchema = Type.Object({
|
|
62
|
+
supportsStore: Type.Optional(Type.Boolean()),
|
|
63
|
+
supportsDeveloperRole: Type.Optional(Type.Boolean()),
|
|
64
|
+
supportsReasoningEffort: Type.Optional(Type.Boolean()),
|
|
65
|
+
supportsUsageInStreaming: Type.Optional(Type.Boolean()),
|
|
66
|
+
maxTokensField: Type.Optional(Type.Union([Type.Literal("max_completion_tokens"), Type.Literal("max_tokens")])),
|
|
67
|
+
requiresToolResultName: Type.Optional(Type.Boolean()),
|
|
68
|
+
requiresAssistantAfterToolResult: Type.Optional(Type.Boolean()),
|
|
69
|
+
requiresThinkingAsText: Type.Optional(Type.Boolean()),
|
|
70
|
+
requiresReasoningContentOnAssistantMessages: Type.Optional(Type.Boolean()),
|
|
71
|
+
supportsDisabledThinking: Type.Optional(Type.Boolean()),
|
|
72
|
+
thinkingFormat: Type.Optional(Type.Union([
|
|
73
|
+
Type.Literal("openai"),
|
|
74
|
+
Type.Literal("openrouter"),
|
|
75
|
+
Type.Literal("together"),
|
|
76
|
+
Type.Literal("deepseek"),
|
|
77
|
+
Type.Literal("zai"),
|
|
78
|
+
Type.Literal("qwen"),
|
|
79
|
+
Type.Literal("chat-template"),
|
|
80
|
+
Type.Literal("qwen-chat-template"),
|
|
81
|
+
Type.Literal("string-thinking"),
|
|
82
|
+
Type.Literal("ant-ling"),
|
|
83
|
+
])),
|
|
84
|
+
chatTemplateKwargs: Type.Optional(Type.Record(Type.String(), ChatTemplateKwargSchema)),
|
|
85
|
+
cacheControlFormat: Type.Optional(Type.Literal("anthropic")),
|
|
86
|
+
openRouterRouting: Type.Optional(OpenRouterRoutingSchema),
|
|
87
|
+
vercelGatewayRouting: Type.Optional(VercelGatewayRoutingSchema),
|
|
88
|
+
zaiToolStream: Type.Optional(Type.Boolean()),
|
|
89
|
+
supportsStrictMode: Type.Optional(Type.Boolean()),
|
|
90
|
+
toolCallFormat: Type.Optional(Type.String()),
|
|
91
|
+
sendSessionAffinityHeaders: Type.Optional(Type.Boolean()),
|
|
92
|
+
deferredToolsMode: Type.Optional(Type.Literal("kimi")),
|
|
93
|
+
sessionAffinityFormat: Type.Optional(Type.Union([Type.Literal("openai"), Type.Literal("openai-nosession"), Type.Literal("openrouter")])),
|
|
94
|
+
supportsLongCacheRetention: Type.Optional(Type.Boolean()),
|
|
95
|
+
});
|
|
96
|
+
const OpenAIResponsesCompatSchema = Type.Object({
|
|
97
|
+
supportsDeveloperRole: Type.Optional(Type.Boolean()),
|
|
98
|
+
sessionAffinityFormat: Type.Optional(Type.Union([Type.Literal("openai"), Type.Literal("openai-nosession"), Type.Literal("openrouter")])),
|
|
99
|
+
supportsLongCacheRetention: Type.Optional(Type.Boolean()),
|
|
100
|
+
supportsWebSocket: Type.Optional(Type.Boolean()),
|
|
101
|
+
supportsWebSearchPreview: Type.Optional(Type.Boolean()),
|
|
102
|
+
supportsToolSearch: Type.Optional(Type.Boolean()),
|
|
103
|
+
});
|
|
104
|
+
const AnthropicMessagesCompatSchema = Type.Object({
|
|
105
|
+
supportsEagerToolInputStreaming: Type.Optional(Type.Boolean()),
|
|
106
|
+
supportsLongCacheRetention: Type.Optional(Type.Boolean()),
|
|
107
|
+
sendSessionAffinityHeaders: Type.Optional(Type.Boolean()),
|
|
108
|
+
supportsCacheControlOnTools: Type.Optional(Type.Boolean()),
|
|
109
|
+
supportsDisabledThinking: Type.Optional(Type.Boolean()),
|
|
110
|
+
supportsTemperature: Type.Optional(Type.Boolean()),
|
|
111
|
+
supportsToolChoice: Type.Optional(Type.Boolean()),
|
|
112
|
+
supportsForcedToolChoice: Type.Optional(Type.Boolean()),
|
|
113
|
+
forceAdaptiveThinking: Type.Optional(Type.Boolean()),
|
|
114
|
+
allowEmptySignature: Type.Optional(Type.Boolean()),
|
|
115
|
+
supportsToolReferences: Type.Optional(Type.Boolean()),
|
|
116
|
+
});
|
|
117
|
+
const ProviderCompatSchema = Type.Union([
|
|
118
|
+
OpenAICompletionsCompatSchema,
|
|
119
|
+
OpenAIResponsesCompatSchema,
|
|
120
|
+
AnthropicMessagesCompatSchema,
|
|
121
|
+
]);
|
|
122
|
+
const ModelCostRatesSchema = {
|
|
123
|
+
input: Type.Number(),
|
|
124
|
+
output: Type.Number(),
|
|
125
|
+
cacheRead: Type.Number(),
|
|
126
|
+
cacheWrite: Type.Number(),
|
|
127
|
+
};
|
|
128
|
+
const ModelCostTierSchema = Type.Object({
|
|
129
|
+
inputTokensAbove: Type.Number(),
|
|
130
|
+
...ModelCostRatesSchema,
|
|
131
|
+
});
|
|
132
|
+
const ModelCostSchema = Type.Object({
|
|
133
|
+
...ModelCostRatesSchema,
|
|
134
|
+
tiers: Type.Optional(Type.Array(ModelCostTierSchema)),
|
|
135
|
+
});
|
|
136
|
+
const ExtraBodySchema = Type.Record(Type.String(), Type.Unknown());
|
|
137
|
+
const ModelDefinitionSchema = Type.Object({
|
|
138
|
+
id: Type.String({ minLength: 1 }),
|
|
139
|
+
name: Type.Optional(Type.String({ minLength: 1 })),
|
|
140
|
+
upstreamModelId: Type.Optional(Type.String({ minLength: 1 })),
|
|
141
|
+
serviceTier: Type.Optional(Type.Union([Type.Literal("auto"), Type.Literal("flex"), Type.Literal("priority")])),
|
|
142
|
+
promptPreset: Type.Optional(Type.String({ minLength: 1 })),
|
|
143
|
+
api: Type.Optional(Type.String({ minLength: 1 })),
|
|
144
|
+
baseUrl: Type.Optional(Type.String({ minLength: 1 })),
|
|
145
|
+
reasoning: Type.Optional(Type.Boolean()),
|
|
146
|
+
thinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),
|
|
147
|
+
input: Type.Optional(Type.Array(Type.Union([Type.Literal("text"), Type.Literal("image")]))),
|
|
148
|
+
cost: Type.Optional(ModelCostSchema),
|
|
149
|
+
contextWindow: Type.Optional(Type.Number()),
|
|
150
|
+
maxTokens: Type.Optional(Type.Number()),
|
|
151
|
+
headers: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
152
|
+
extraBody: Type.Optional(ExtraBodySchema),
|
|
153
|
+
cacheRetention: Type.Optional(Type.Union([Type.Literal("none"), Type.Literal("short"), Type.Literal("long")])),
|
|
154
|
+
compat: Type.Optional(ProviderCompatSchema),
|
|
155
|
+
});
|
|
156
|
+
const ModelOverrideSchema = Type.Object({
|
|
157
|
+
name: Type.Optional(Type.String({ minLength: 1 })),
|
|
158
|
+
promptPreset: Type.Optional(Type.String({ minLength: 1 })),
|
|
159
|
+
reasoning: Type.Optional(Type.Boolean()),
|
|
160
|
+
thinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),
|
|
161
|
+
thinkingLevelMapMode: Type.Optional(Type.Union([Type.Literal("merge"), Type.Literal("replace")])),
|
|
162
|
+
input: Type.Optional(Type.Array(Type.Union([Type.Literal("text"), Type.Literal("image")]))),
|
|
163
|
+
cost: Type.Optional(Type.Object({
|
|
164
|
+
input: Type.Optional(Type.Number()),
|
|
165
|
+
output: Type.Optional(Type.Number()),
|
|
166
|
+
cacheRead: Type.Optional(Type.Number()),
|
|
167
|
+
cacheWrite: Type.Optional(Type.Number()),
|
|
168
|
+
tiers: Type.Optional(Type.Array(ModelCostTierSchema)),
|
|
169
|
+
})),
|
|
170
|
+
contextWindow: Type.Optional(Type.Number()),
|
|
171
|
+
maxTokens: Type.Optional(Type.Number()),
|
|
172
|
+
headers: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
173
|
+
extraBody: Type.Optional(ExtraBodySchema),
|
|
174
|
+
cacheRetention: Type.Optional(Type.Union([Type.Literal("none"), Type.Literal("short"), Type.Literal("long")])),
|
|
175
|
+
compat: Type.Optional(ProviderCompatSchema),
|
|
176
|
+
});
|
|
177
|
+
const ProviderConfigSchema = Type.Object({
|
|
178
|
+
name: Type.Optional(Type.String({ minLength: 1 })),
|
|
179
|
+
disabled: Type.Optional(Type.Boolean()),
|
|
180
|
+
baseUrl: Type.Optional(Type.String({ minLength: 1 })),
|
|
181
|
+
apiKey: Type.Optional(Type.String({ minLength: 1 })),
|
|
182
|
+
api: Type.Optional(Type.String({ minLength: 1 })),
|
|
183
|
+
oauth: Type.Optional(Type.Literal("radius")),
|
|
184
|
+
headers: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
185
|
+
extraBody: Type.Optional(ExtraBodySchema),
|
|
186
|
+
cacheRetention: Type.Optional(Type.Union([Type.Literal("none"), Type.Literal("short"), Type.Literal("long")])),
|
|
187
|
+
compat: Type.Optional(ProviderCompatSchema),
|
|
188
|
+
authHeader: Type.Optional(Type.Boolean()),
|
|
189
|
+
whitelist: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
|
|
190
|
+
blacklist: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
|
|
191
|
+
models: Type.Optional(Type.Array(ModelDefinitionSchema)),
|
|
192
|
+
modelOverrides: Type.Optional(Type.Record(Type.String(), ModelOverrideSchema)),
|
|
193
|
+
});
|
|
194
|
+
const ModelsConfigSchema = Type.Object({
|
|
195
|
+
disabledProviders: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
|
|
196
|
+
providers: Type.Record(Type.String(), ProviderConfigSchema),
|
|
197
|
+
});
|
|
198
|
+
const validateModelsConfig = Compile(ModelsConfigSchema);
|
|
199
|
+
function formatValidationPath(error) {
|
|
200
|
+
if (error.keyword === "required") {
|
|
201
|
+
const requiredProperties = error.params.requiredProperties;
|
|
202
|
+
const requiredProperty = requiredProperties?.[0];
|
|
203
|
+
if (requiredProperty) {
|
|
204
|
+
const basePath = error.instancePath.replace(/^\//, "").replace(/\//g, ".");
|
|
205
|
+
return basePath ? `${basePath}.${requiredProperty}` : requiredProperty;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const path = error.instancePath.replace(/^\//, "").replace(/\//g, ".");
|
|
209
|
+
return path || "root";
|
|
210
|
+
}
|
|
211
|
+
function deepFreeze(value) {
|
|
212
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value))
|
|
213
|
+
return value;
|
|
214
|
+
for (const child of Object.values(value))
|
|
215
|
+
deepFreeze(child);
|
|
216
|
+
return Object.freeze(value);
|
|
217
|
+
}
|
|
218
|
+
/** One immutable load of models.json. */
|
|
219
|
+
export class ModelConfig {
|
|
220
|
+
constructor(providers, disabledProviders = new Set(), error) {
|
|
221
|
+
this.providers = providers;
|
|
222
|
+
this.disabledProviders = disabledProviders;
|
|
223
|
+
this.error = error;
|
|
224
|
+
}
|
|
225
|
+
static parse(content, path) {
|
|
226
|
+
let parsed;
|
|
227
|
+
try {
|
|
228
|
+
parsed = JSON.parse(stripJsonComments(content));
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
return new ModelConfig(new Map(), new Set(), `Failed to parse models.json: ${error instanceof Error ? error.message : error}\n\nFile: ${path}`);
|
|
232
|
+
}
|
|
233
|
+
if (!validateModelsConfig.Check(parsed)) {
|
|
234
|
+
const errors = validateModelsConfig
|
|
235
|
+
.Errors(parsed)
|
|
236
|
+
.map((error) => ` - ${formatValidationPath(error)}: ${error.message}`)
|
|
237
|
+
.join("\n") || "Unknown schema error";
|
|
238
|
+
return new ModelConfig(new Map(), new Set(), `Invalid models.json schema:\n${errors}\n\nFile: ${path}`);
|
|
239
|
+
}
|
|
240
|
+
const config = parsed;
|
|
241
|
+
const providers = new Map();
|
|
242
|
+
for (const [providerId, provider] of Object.entries(config.providers)) {
|
|
243
|
+
providers.set(providerId, deepFreeze(structuredClone(provider)));
|
|
244
|
+
}
|
|
245
|
+
return new ModelConfig(providers, new Set(config.disabledProviders ?? []));
|
|
246
|
+
}
|
|
247
|
+
static async load(modelsJsonPath) {
|
|
248
|
+
if (!modelsJsonPath)
|
|
249
|
+
return new ModelConfig(new Map());
|
|
250
|
+
const path = normalizePath(modelsJsonPath);
|
|
251
|
+
let content;
|
|
252
|
+
try {
|
|
253
|
+
content = await readFile(path, "utf-8");
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
if (error.code === "ENOENT")
|
|
257
|
+
return new ModelConfig(new Map());
|
|
258
|
+
return new ModelConfig(new Map(), new Set(), `Failed to load models.json: ${error instanceof Error ? error.message : error}\n\nFile: ${path}`);
|
|
259
|
+
}
|
|
260
|
+
return ModelConfig.parse(content, path);
|
|
261
|
+
}
|
|
262
|
+
static loadSync(modelsJsonPath) {
|
|
263
|
+
if (!modelsJsonPath)
|
|
264
|
+
return new ModelConfig(new Map());
|
|
265
|
+
const path = normalizePath(modelsJsonPath);
|
|
266
|
+
try {
|
|
267
|
+
return ModelConfig.parse(readFileSync(path, "utf-8"), path);
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
if (error.code === "ENOENT")
|
|
271
|
+
return new ModelConfig(new Map());
|
|
272
|
+
return new ModelConfig(new Map(), new Set(), `Failed to load models.json: ${error instanceof Error ? error.message : error}\n\nFile: ${path}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
getProvider(providerId) {
|
|
276
|
+
return this.providers.get(providerId);
|
|
277
|
+
}
|
|
278
|
+
getProviderIds() {
|
|
279
|
+
return [...this.providers.keys()];
|
|
280
|
+
}
|
|
281
|
+
isProviderDisabled(providerId) {
|
|
282
|
+
return this.disabledProviders.has(providerId) || this.providers.get(providerId)?.disabled === true;
|
|
283
|
+
}
|
|
284
|
+
getError() {
|
|
285
|
+
return this.error;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=model-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-config.js","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3C,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACjC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC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AO,CAAC,CAAC,CAAC,KAAK,aAAa,IAAI,EAAE,CAChG,CAAC;QACH,CAAC;IACF,CAAC;IAED,WAAW,CAAC,UAAkB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,cAAc;QACb,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,kBAAkB,CAAC,UAAkB;QACpC,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;IACpG,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD","sourcesContent":["/** Immutable, credential-blind models.json snapshot. */\n\nimport { readFileSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\nimport type { TLocalizedValidationError } from \"typebox/error\";\nimport { stripJsonComments } from \"../utils/json.ts\";\nimport { normalizePath } from \"../utils/paths.ts\";\n\nconst PercentileCutoffsSchema = Type.Object({\n\tp50: Type.Optional(Type.Number()),\n\tp75: Type.Optional(Type.Number()),\n\tp90: Type.Optional(Type.Number()),\n\tp99: Type.Optional(Type.Number()),\n});\n\nconst OpenRouterRoutingSchema = Type.Object({\n\tallow_fallbacks: Type.Optional(Type.Boolean()),\n\trequire_parameters: Type.Optional(Type.Boolean()),\n\tdata_collection: Type.Optional(Type.Union([Type.Literal(\"deny\"), Type.Literal(\"allow\")])),\n\tzdr: Type.Optional(Type.Boolean()),\n\tenforce_distillable_text: Type.Optional(Type.Boolean()),\n\torder: Type.Optional(Type.Array(Type.String())),\n\tonly: Type.Optional(Type.Array(Type.String())),\n\tignore: Type.Optional(Type.Array(Type.String())),\n\tquantizations: Type.Optional(Type.Array(Type.String())),\n\tsort: Type.Optional(\n\t\tType.Union([\n\t\t\tType.String(),\n\t\t\tType.Object({\n\t\t\t\tby: Type.Optional(Type.String()),\n\t\t\t\tpartition: Type.Optional(Type.Union([Type.String(), Type.Null()])),\n\t\t\t}),\n\t\t]),\n\t),\n\tmax_price: Type.Optional(\n\t\tType.Object({\n\t\t\tprompt: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t\tcompletion: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t\timage: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t\taudio: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t\trequest: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t}),\n\t),\n\tpreferred_min_throughput: Type.Optional(Type.Union([Type.Number(), PercentileCutoffsSchema])),\n\tpreferred_max_latency: Type.Optional(Type.Union([Type.Number(), PercentileCutoffsSchema])),\n});\n\nconst VercelGatewayRoutingSchema = Type.Object({\n\tonly: Type.Optional(Type.Array(Type.String())),\n\torder: Type.Optional(Type.Array(Type.String())),\n});\n\nconst ThinkingLevelMapValueSchema = Type.Union([Type.String(), Type.Null()]);\nconst ThinkingLevelMapSchema = Type.Object({\n\toff: Type.Optional(ThinkingLevelMapValueSchema),\n\tminimal: Type.Optional(ThinkingLevelMapValueSchema),\n\tlow: Type.Optional(ThinkingLevelMapValueSchema),\n\tmedium: Type.Optional(ThinkingLevelMapValueSchema),\n\thigh: Type.Optional(ThinkingLevelMapValueSchema),\n\txhigh: Type.Optional(ThinkingLevelMapValueSchema),\n\tmax: Type.Optional(ThinkingLevelMapValueSchema),\n});\n\nconst ChatTemplateKwargScalarSchema = Type.Union([Type.String(), Type.Number(), Type.Boolean(), Type.Null()]);\nconst ChatTemplateKwargVariableSchema = Type.Object({\n\t$var: Type.Union([Type.Literal(\"thinking.enabled\"), Type.Literal(\"thinking.effort\")]),\n\tomitWhenOff: Type.Optional(Type.Boolean()),\n});\nconst ChatTemplateKwargSchema = Type.Union([ChatTemplateKwargScalarSchema, ChatTemplateKwargVariableSchema]);\n\nconst OpenAICompletionsCompatSchema = Type.Object({\n\tsupportsStore: Type.Optional(Type.Boolean()),\n\tsupportsDeveloperRole: Type.Optional(Type.Boolean()),\n\tsupportsReasoningEffort: Type.Optional(Type.Boolean()),\n\tsupportsUsageInStreaming: Type.Optional(Type.Boolean()),\n\tmaxTokensField: Type.Optional(Type.Union([Type.Literal(\"max_completion_tokens\"), Type.Literal(\"max_tokens\")])),\n\trequiresToolResultName: Type.Optional(Type.Boolean()),\n\trequiresAssistantAfterToolResult: Type.Optional(Type.Boolean()),\n\trequiresThinkingAsText: Type.Optional(Type.Boolean()),\n\trequiresReasoningContentOnAssistantMessages: Type.Optional(Type.Boolean()),\n\tsupportsDisabledThinking: Type.Optional(Type.Boolean()),\n\tthinkingFormat: Type.Optional(\n\t\tType.Union([\n\t\t\tType.Literal(\"openai\"),\n\t\t\tType.Literal(\"openrouter\"),\n\t\t\tType.Literal(\"together\"),\n\t\t\tType.Literal(\"deepseek\"),\n\t\t\tType.Literal(\"zai\"),\n\t\t\tType.Literal(\"qwen\"),\n\t\t\tType.Literal(\"chat-template\"),\n\t\t\tType.Literal(\"qwen-chat-template\"),\n\t\t\tType.Literal(\"string-thinking\"),\n\t\t\tType.Literal(\"ant-ling\"),\n\t\t]),\n\t),\n\tchatTemplateKwargs: Type.Optional(Type.Record(Type.String(), ChatTemplateKwargSchema)),\n\tcacheControlFormat: Type.Optional(Type.Literal(\"anthropic\")),\n\topenRouterRouting: Type.Optional(OpenRouterRoutingSchema),\n\tvercelGatewayRouting: Type.Optional(VercelGatewayRoutingSchema),\n\tzaiToolStream: Type.Optional(Type.Boolean()),\n\tsupportsStrictMode: Type.Optional(Type.Boolean()),\n\ttoolCallFormat: Type.Optional(Type.String()),\n\tsendSessionAffinityHeaders: Type.Optional(Type.Boolean()),\n\tdeferredToolsMode: Type.Optional(Type.Literal(\"kimi\")),\n\tsessionAffinityFormat: Type.Optional(\n\t\tType.Union([Type.Literal(\"openai\"), Type.Literal(\"openai-nosession\"), Type.Literal(\"openrouter\")]),\n\t),\n\tsupportsLongCacheRetention: Type.Optional(Type.Boolean()),\n});\n\nconst OpenAIResponsesCompatSchema = Type.Object({\n\tsupportsDeveloperRole: Type.Optional(Type.Boolean()),\n\tsessionAffinityFormat: Type.Optional(\n\t\tType.Union([Type.Literal(\"openai\"), Type.Literal(\"openai-nosession\"), Type.Literal(\"openrouter\")]),\n\t),\n\tsupportsLongCacheRetention: Type.Optional(Type.Boolean()),\n\tsupportsWebSocket: Type.Optional(Type.Boolean()),\n\tsupportsWebSearchPreview: Type.Optional(Type.Boolean()),\n\tsupportsToolSearch: Type.Optional(Type.Boolean()),\n});\n\nconst AnthropicMessagesCompatSchema = Type.Object({\n\tsupportsEagerToolInputStreaming: Type.Optional(Type.Boolean()),\n\tsupportsLongCacheRetention: Type.Optional(Type.Boolean()),\n\tsendSessionAffinityHeaders: Type.Optional(Type.Boolean()),\n\tsupportsCacheControlOnTools: Type.Optional(Type.Boolean()),\n\tsupportsDisabledThinking: Type.Optional(Type.Boolean()),\n\tsupportsTemperature: Type.Optional(Type.Boolean()),\n\tsupportsToolChoice: Type.Optional(Type.Boolean()),\n\tsupportsForcedToolChoice: Type.Optional(Type.Boolean()),\n\tforceAdaptiveThinking: Type.Optional(Type.Boolean()),\n\tallowEmptySignature: Type.Optional(Type.Boolean()),\n\tsupportsToolReferences: Type.Optional(Type.Boolean()),\n});\n\nconst ProviderCompatSchema = Type.Union([\n\tOpenAICompletionsCompatSchema,\n\tOpenAIResponsesCompatSchema,\n\tAnthropicMessagesCompatSchema,\n]);\n\nconst ModelCostRatesSchema = {\n\tinput: Type.Number(),\n\toutput: Type.Number(),\n\tcacheRead: Type.Number(),\n\tcacheWrite: Type.Number(),\n};\nconst ModelCostTierSchema = Type.Object({\n\tinputTokensAbove: Type.Number(),\n\t...ModelCostRatesSchema,\n});\nconst ModelCostSchema = Type.Object({\n\t...ModelCostRatesSchema,\n\ttiers: Type.Optional(Type.Array(ModelCostTierSchema)),\n});\nconst ExtraBodySchema = Type.Record(Type.String(), Type.Unknown());\n\nconst ModelDefinitionSchema = Type.Object({\n\tid: Type.String({ minLength: 1 }),\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\tupstreamModelId: Type.Optional(Type.String({ minLength: 1 })),\n\tserviceTier: Type.Optional(Type.Union([Type.Literal(\"auto\"), Type.Literal(\"flex\"), Type.Literal(\"priority\")])),\n\tpromptPreset: Type.Optional(Type.String({ minLength: 1 })),\n\tapi: Type.Optional(Type.String({ minLength: 1 })),\n\tbaseUrl: Type.Optional(Type.String({ minLength: 1 })),\n\treasoning: Type.Optional(Type.Boolean()),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tinput: Type.Optional(Type.Array(Type.Union([Type.Literal(\"text\"), Type.Literal(\"image\")]))),\n\tcost: Type.Optional(ModelCostSchema),\n\tcontextWindow: Type.Optional(Type.Number()),\n\tmaxTokens: Type.Optional(Type.Number()),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\textraBody: Type.Optional(ExtraBodySchema),\n\tcacheRetention: Type.Optional(Type.Union([Type.Literal(\"none\"), Type.Literal(\"short\"), Type.Literal(\"long\")])),\n\tcompat: Type.Optional(ProviderCompatSchema),\n});\n\nconst ModelOverrideSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\tpromptPreset: Type.Optional(Type.String({ minLength: 1 })),\n\treasoning: Type.Optional(Type.Boolean()),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tthinkingLevelMapMode: Type.Optional(Type.Union([Type.Literal(\"merge\"), Type.Literal(\"replace\")])),\n\tinput: Type.Optional(Type.Array(Type.Union([Type.Literal(\"text\"), Type.Literal(\"image\")]))),\n\tcost: Type.Optional(\n\t\tType.Object({\n\t\t\tinput: Type.Optional(Type.Number()),\n\t\t\toutput: Type.Optional(Type.Number()),\n\t\t\tcacheRead: Type.Optional(Type.Number()),\n\t\t\tcacheWrite: Type.Optional(Type.Number()),\n\t\t\ttiers: Type.Optional(Type.Array(ModelCostTierSchema)),\n\t\t}),\n\t),\n\tcontextWindow: Type.Optional(Type.Number()),\n\tmaxTokens: Type.Optional(Type.Number()),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\textraBody: Type.Optional(ExtraBodySchema),\n\tcacheRetention: Type.Optional(Type.Union([Type.Literal(\"none\"), Type.Literal(\"short\"), Type.Literal(\"long\")])),\n\tcompat: Type.Optional(ProviderCompatSchema),\n});\n\nconst ProviderConfigSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\tdisabled: Type.Optional(Type.Boolean()),\n\tbaseUrl: Type.Optional(Type.String({ minLength: 1 })),\n\tapiKey: Type.Optional(Type.String({ minLength: 1 })),\n\tapi: Type.Optional(Type.String({ minLength: 1 })),\n\toauth: Type.Optional(Type.Literal(\"radius\")),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\textraBody: Type.Optional(ExtraBodySchema),\n\tcacheRetention: Type.Optional(Type.Union([Type.Literal(\"none\"), Type.Literal(\"short\"), Type.Literal(\"long\")])),\n\tcompat: Type.Optional(ProviderCompatSchema),\n\tauthHeader: Type.Optional(Type.Boolean()),\n\twhitelist: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),\n\tblacklist: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),\n\tmodels: Type.Optional(Type.Array(ModelDefinitionSchema)),\n\tmodelOverrides: Type.Optional(Type.Record(Type.String(), ModelOverrideSchema)),\n});\n\nconst ModelsConfigSchema = Type.Object({\n\tdisabledProviders: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),\n\tproviders: Type.Record(Type.String(), ProviderConfigSchema),\n});\nconst validateModelsConfig = Compile(ModelsConfigSchema);\n\nexport type ModelsJsonModel = Static<typeof ModelDefinitionSchema>;\nexport type ModelsJsonModelOverride = Static<typeof ModelOverrideSchema>;\nexport type ModelsJsonProvider = Static<typeof ProviderConfigSchema>;\ntype ModelsJson = Static<typeof ModelsConfigSchema>;\n\nfunction formatValidationPath(error: TLocalizedValidationError): string {\n\tif (error.keyword === \"required\") {\n\t\tconst requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;\n\t\tconst requiredProperty = requiredProperties?.[0];\n\t\tif (requiredProperty) {\n\t\t\tconst basePath = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\t\t\treturn basePath ? `${basePath}.${requiredProperty}` : requiredProperty;\n\t\t}\n\t}\n\tconst path = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\treturn path || \"root\";\n}\n\nfunction deepFreeze<T>(value: T): T {\n\tif (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n\tfor (const child of Object.values(value)) deepFreeze(child);\n\treturn Object.freeze(value);\n}\n\n/** One immutable load of models.json. */\nexport class ModelConfig {\n\tprivate readonly providers: ReadonlyMap<string, ModelsJsonProvider>;\n\tprivate readonly disabledProviders: ReadonlySet<string>;\n\tprivate readonly error: string | undefined;\n\n\tprivate constructor(\n\t\tproviders: ReadonlyMap<string, ModelsJsonProvider>,\n\t\tdisabledProviders: ReadonlySet<string> = new Set(),\n\t\terror?: string,\n\t) {\n\t\tthis.providers = providers;\n\t\tthis.disabledProviders = disabledProviders;\n\t\tthis.error = error;\n\t}\n\n\tprivate static parse(content: string, path: string): ModelConfig {\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(stripJsonComments(content));\n\t\t} catch (error) {\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\tnew Set(),\n\t\t\t\t`Failed to parse models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!validateModelsConfig.Check(parsed)) {\n\t\t\tconst errors =\n\t\t\t\tvalidateModelsConfig\n\t\t\t\t\t.Errors(parsed)\n\t\t\t\t\t.map((error) => ` - ${formatValidationPath(error)}: ${error.message}`)\n\t\t\t\t\t.join(\"\\n\") || \"Unknown schema error\";\n\t\t\treturn new ModelConfig(new Map(), new Set(), `Invalid models.json schema:\\n${errors}\\n\\nFile: ${path}`);\n\t\t}\n\n\t\tconst config = parsed as ModelsJson;\n\t\tconst providers = new Map<string, ModelsJsonProvider>();\n\t\tfor (const [providerId, provider] of Object.entries(config.providers)) {\n\t\t\tproviders.set(providerId, deepFreeze(structuredClone(provider)));\n\t\t}\n\t\treturn new ModelConfig(providers, new Set(config.disabledProviders ?? []));\n\t}\n\n\tstatic async load(modelsJsonPath: string | undefined): Promise<ModelConfig> {\n\t\tif (!modelsJsonPath) return new ModelConfig(new Map());\n\t\tconst path = normalizePath(modelsJsonPath);\n\t\tlet content: string;\n\t\ttry {\n\t\t\tcontent = await readFile(path, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return new ModelConfig(new Map());\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\tnew Set(),\n\t\t\t\t`Failed to load models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\t\treturn ModelConfig.parse(content, path);\n\t}\n\n\tstatic loadSync(modelsJsonPath: string | undefined): ModelConfig {\n\t\tif (!modelsJsonPath) return new ModelConfig(new Map());\n\t\tconst path = normalizePath(modelsJsonPath);\n\t\ttry {\n\t\t\treturn ModelConfig.parse(readFileSync(path, \"utf-8\"), path);\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return new ModelConfig(new Map());\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\tnew Set(),\n\t\t\t\t`Failed to load models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tgetProvider(providerId: string): ModelsJsonProvider | undefined {\n\t\treturn this.providers.get(providerId);\n\t}\n\n\tgetProviderIds(): readonly string[] {\n\t\treturn [...this.providers.keys()];\n\t}\n\n\tisProviderDisabled(providerId: string): boolean {\n\t\treturn this.disabledProviders.has(providerId) || this.providers.get(providerId)?.disabled === true;\n\t}\n\n\tgetError(): string | undefined {\n\t\treturn this.error;\n\t}\n}\n"]}
|
|
@@ -1,177 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import type { AuthStatus, AuthStorage } from "./auth-storage.ts";
|
|
7
|
-
declare const ThinkingLevelMapSchema: Type.TObject<{
|
|
8
|
-
off: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
9
|
-
minimal: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
10
|
-
low: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
11
|
-
medium: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
12
|
-
high: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
13
|
-
xhigh: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
14
|
-
max: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
15
|
-
}>;
|
|
16
|
-
declare const ServiceTierSchema: Type.TUnion<[Type.TLiteral<"auto">, Type.TLiteral<"flex">, Type.TLiteral<"priority">]>;
|
|
17
|
-
type ModelServiceTier = Static<typeof ServiceTierSchema>;
|
|
18
|
-
type ThinkingLevelMap = Static<typeof ThinkingLevelMapSchema>;
|
|
1
|
+
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
2
|
+
import { AuthStorage } from "./auth-storage.ts";
|
|
3
|
+
import type { ModelRuntime } from "./model-runtime.ts";
|
|
4
|
+
import type { AuthStatus, ProviderConfigInput } from "./provider-composer.ts";
|
|
5
|
+
export type { ProviderConfigInput } from "./provider-composer.ts";
|
|
19
6
|
export type ResolvedRequestAuth = {
|
|
20
7
|
ok: true;
|
|
21
8
|
apiKey?: string;
|
|
22
9
|
headers?: Record<string, string>;
|
|
23
10
|
extraBody?: Record<string, unknown>;
|
|
24
11
|
upstreamModelId?: string;
|
|
25
|
-
serviceTier?:
|
|
12
|
+
serviceTier?: "auto" | "flex" | "priority";
|
|
26
13
|
env?: Record<string, string>;
|
|
27
14
|
} | {
|
|
28
15
|
ok: false;
|
|
29
16
|
error: string;
|
|
30
17
|
};
|
|
18
|
+
export { clearApiKeyCache } from "./provider-composer.ts";
|
|
31
19
|
/**
|
|
32
|
-
*
|
|
20
|
+
* Synchronous compatibility facade exposed to extensions.
|
|
21
|
+
* Coding-agent internals use ModelRuntime directly.
|
|
33
22
|
*/
|
|
34
23
|
export declare class ModelRegistry {
|
|
35
|
-
private
|
|
36
|
-
private providerRequestConfigs;
|
|
37
|
-
private modelRequestHeaders;
|
|
38
|
-
private modelRequestExtraBody;
|
|
39
|
-
private modelRequestUpstreamIds;
|
|
40
|
-
private modelRequestServiceTiers;
|
|
41
|
-
private configModelOverrides;
|
|
42
|
-
private registeredProviders;
|
|
43
|
-
private loadError;
|
|
24
|
+
private readonly runtime;
|
|
44
25
|
readonly authStorage: AuthStorage;
|
|
45
|
-
|
|
46
|
-
private constructor();
|
|
26
|
+
constructor(runtime: ModelRuntime, authStorage?: AuthStorage);
|
|
47
27
|
static create(authStorage: AuthStorage, modelsJsonPath?: string): ModelRegistry;
|
|
48
28
|
static inMemory(authStorage: AuthStorage): ModelRegistry;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
refresh(): void;
|
|
53
|
-
/**
|
|
54
|
-
* Get any error from loading models.json (undefined if no error).
|
|
55
|
-
*/
|
|
29
|
+
get modelRuntime(): ModelRuntime;
|
|
30
|
+
/** Reload models.json asynchronously. Await before making synchronous registry reads. */
|
|
31
|
+
refresh(): Promise<void>;
|
|
56
32
|
getError(): string | undefined;
|
|
57
|
-
private loadModels;
|
|
58
|
-
/** Load built-in models and apply provider/model overrides */
|
|
59
|
-
private loadBuiltInModels;
|
|
60
|
-
private getConfiguredModelOverride;
|
|
61
|
-
private applyConfiguredModelOverride;
|
|
62
|
-
/** Merge custom models into built-in list by provider+id (custom wins on conflicts). */
|
|
63
|
-
private mergeCustomModels;
|
|
64
|
-
private loadCustomModels;
|
|
65
|
-
private validateConfig;
|
|
66
|
-
private parseModels;
|
|
67
|
-
/**
|
|
68
|
-
* Get all models (built-in + custom).
|
|
69
|
-
* If models.json had errors, returns only built-in models.
|
|
70
|
-
*/
|
|
71
33
|
getAll(): Model<Api>[];
|
|
72
|
-
/**
|
|
73
|
-
* Get only models that have auth configured.
|
|
74
|
-
* This is a fast check that doesn't refresh OAuth tokens.
|
|
75
|
-
*/
|
|
76
34
|
getAvailable(): Model<Api>[];
|
|
77
|
-
/**
|
|
78
|
-
* Find a model by provider and ID.
|
|
79
|
-
*/
|
|
80
35
|
find(provider: string, modelId: string): Model<Api> | undefined;
|
|
81
|
-
getUpstreamModelId(model: Model<Api>): string | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* Get API key for a model.
|
|
84
|
-
*/
|
|
85
36
|
hasConfiguredAuth(model: Model<Api>): boolean;
|
|
86
|
-
|
|
87
|
-
private storeProviderRequestConfig;
|
|
88
|
-
private storeModelHeaders;
|
|
89
|
-
private storeModelExtraBody;
|
|
90
|
-
private storeModelUpstreamId;
|
|
91
|
-
private storeModelServiceTier;
|
|
92
|
-
private clearModelRequestConfigForProvider;
|
|
93
|
-
/**
|
|
94
|
-
* Get API key and request headers for a model.
|
|
95
|
-
*/
|
|
37
|
+
getUpstreamModelId(model: Model<Api>): string | undefined;
|
|
96
38
|
getApiKeyAndHeaders(model: Model<Api>): Promise<ResolvedRequestAuth>;
|
|
97
|
-
/**
|
|
98
|
-
* Return auth status for a provider, including request auth configured in models.json.
|
|
99
|
-
* This intentionally does not execute command-backed config values.
|
|
100
|
-
*/
|
|
101
39
|
getProviderAuthStatus(provider: string): AuthStatus;
|
|
102
|
-
/**
|
|
103
|
-
* Get display name for a provider.
|
|
104
|
-
*/
|
|
105
40
|
getProviderDisplayName(provider: string): string;
|
|
106
|
-
/**
|
|
107
|
-
* Get API key for a provider.
|
|
108
|
-
*/
|
|
109
41
|
getApiKeyForProvider(provider: string): Promise<string | undefined>;
|
|
110
|
-
/**
|
|
111
|
-
* Check if a model is using OAuth credentials (subscription).
|
|
112
|
-
*/
|
|
113
42
|
isUsingOAuth(model: Model<Api>): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Register a provider dynamically (from extensions).
|
|
116
|
-
*
|
|
117
|
-
* If provider has models: replaces all existing models for this provider.
|
|
118
|
-
* If provider has only baseUrl/headers: overrides existing models' URLs.
|
|
119
|
-
* If provider has oauth: registers OAuth provider for /login support.
|
|
120
|
-
*/
|
|
121
43
|
registerProvider(providerName: string, config: ProviderConfigInput): void;
|
|
122
|
-
/**
|
|
123
|
-
* Unregister a previously registered provider.
|
|
124
|
-
*
|
|
125
|
-
* Removes the provider from the registry and reloads models from disk so that
|
|
126
|
-
* built-in models overridden by this provider are restored to their original state.
|
|
127
|
-
* Also resets dynamic OAuth and API stream registrations before reapplying
|
|
128
|
-
* remaining dynamic providers.
|
|
129
|
-
* Has no effect if the provider was never registered.
|
|
130
|
-
*/
|
|
131
44
|
unregisterProvider(providerName: string): void;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
* If the provider is already registered, defined values in the incoming config
|
|
135
|
-
* override existing ones; undefined values are preserved from the stored config.
|
|
136
|
-
* If the provider is not registered, the incoming config is stored as-is.
|
|
137
|
-
*/
|
|
138
|
-
private upsertRegisteredProvider;
|
|
139
|
-
private validateProviderConfig;
|
|
140
|
-
private applyProviderConfig;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Input type for registerProvider API.
|
|
144
|
-
*/
|
|
145
|
-
export interface ProviderConfigInput {
|
|
146
|
-
name?: string;
|
|
147
|
-
baseUrl?: string;
|
|
148
|
-
apiKey?: string;
|
|
149
|
-
api?: Api;
|
|
150
|
-
streamSimple?: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;
|
|
151
|
-
headers?: Record<string, string>;
|
|
152
|
-
extraBody?: Record<string, unknown>;
|
|
153
|
-
cacheRetention?: CacheRetention;
|
|
154
|
-
authHeader?: boolean;
|
|
155
|
-
/** OAuth provider for /login support */
|
|
156
|
-
oauth?: Omit<OAuthProviderInterface, "id">;
|
|
157
|
-
models?: Array<{
|
|
158
|
-
id: string;
|
|
159
|
-
name: string;
|
|
160
|
-
upstreamModelId?: string;
|
|
161
|
-
serviceTier?: ModelServiceTier;
|
|
162
|
-
api?: Api;
|
|
163
|
-
baseUrl?: string;
|
|
164
|
-
reasoning: boolean;
|
|
165
|
-
thinkingLevelMap?: ThinkingLevelMap;
|
|
166
|
-
input: Model<Api>["input"];
|
|
167
|
-
cost: Model<Api>["cost"];
|
|
168
|
-
contextWindow: number;
|
|
169
|
-
maxTokens: number;
|
|
170
|
-
headers?: Record<string, string>;
|
|
171
|
-
extraBody?: Record<string, unknown>;
|
|
172
|
-
cacheRetention?: CacheRetention;
|
|
173
|
-
compat?: Model<Api>["compat"];
|
|
174
|
-
}>;
|
|
45
|
+
getRegisteredProviderConfig(providerName: string): ProviderConfigInput | undefined;
|
|
46
|
+
getRegisteredProviderIds(): readonly string[];
|
|
175
47
|
}
|
|
176
|
-
export {};
|
|
177
48
|
//# sourceMappingURL=model-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY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