dal-code 1.0.49 → 1.0.51
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 +1043 -5
- package/dist/bundle/chunks/anthropic-messages-2P3UGLIO.js +5 -0
- package/dist/bundle/chunks/anthropic.js +74 -0
- package/dist/bundle/chunks/azure-openai-responses-S4GNH2XC.js +1 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +88 -0
- package/dist/bundle/chunks/chunk-2KOJ4RNS.js +43 -0
- package/dist/bundle/chunks/chunk-3YGHTGYM.js +7 -0
- package/dist/bundle/chunks/chunk-4LDEEFCY.js +1 -0
- package/dist/bundle/chunks/chunk-4UTLMBZZ.js +13 -0
- package/dist/bundle/chunks/chunk-567OJLS7.js +1 -0
- package/dist/bundle/chunks/chunk-5AGIVGSV.js +5 -0
- package/dist/bundle/chunks/chunk-6QGV3IWD.js +5 -0
- package/dist/bundle/chunks/chunk-723ZGEZ2.js +1 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +1 -0
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +1 -0
- package/dist/bundle/chunks/chunk-AL7NZVPP.js +1 -0
- package/dist/bundle/chunks/chunk-ATQJO2OE.js +3 -0
- package/dist/bundle/chunks/chunk-B7NRFMLU.js +8 -0
- package/dist/bundle/chunks/chunk-BEDAM2M7.js +81 -0
- package/dist/bundle/chunks/chunk-CF5GWZHW.js +30 -0
- package/dist/bundle/chunks/chunk-CFPQOC7P.js +1 -0
- package/dist/bundle/chunks/chunk-D2WTLI2T.js +19 -0
- package/dist/bundle/chunks/chunk-EH7SFF47.js +129 -0
- package/dist/bundle/chunks/chunk-FCKLBLA4.js +1 -0
- package/dist/bundle/chunks/chunk-FFMDRXC4.js +9 -0
- package/dist/bundle/chunks/chunk-GSGE3ULF.js +15 -0
- package/dist/bundle/chunks/chunk-H5FHS6BV.js +1 -0
- package/dist/bundle/chunks/chunk-HXK5EFBE.js +1172 -0
- package/dist/bundle/chunks/chunk-IEBK4HQA.js +1 -0
- package/dist/bundle/chunks/chunk-JE6UXK35.js +30 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +1 -0
- package/dist/bundle/chunks/chunk-K7VBBYTT.js +1 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +1 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +11 -0
- package/dist/bundle/chunks/chunk-ML5DIOWR.js +1 -0
- package/dist/bundle/chunks/chunk-NUIR7PPD.js +25 -0
- package/dist/bundle/chunks/chunk-P7FPUEYA.js +1 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +1 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +1 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +1 -0
- package/dist/bundle/chunks/chunk-PWZRJWNP.js +17 -0
- package/dist/bundle/chunks/chunk-R44HF4S5.js +9 -0
- package/dist/bundle/chunks/chunk-R47JBGS3.js +1 -0
- package/dist/bundle/chunks/chunk-RCVVRHMF.js +9 -0
- package/dist/bundle/chunks/chunk-RDZVAGPR.js +1 -0
- package/dist/bundle/chunks/chunk-RR3ZP63P.js +56 -0
- package/dist/bundle/chunks/chunk-SE42OS3U.js +21 -0
- package/dist/bundle/chunks/chunk-TMTOQ7H7.js +1 -0
- package/dist/bundle/chunks/chunk-UTB4DTYQ.js +1 -0
- package/dist/bundle/chunks/chunk-VNHNHA4V.js +1 -0
- package/dist/bundle/chunks/chunk-XJFQKN3N.js +2 -0
- package/dist/bundle/chunks/chunk-ZG74NES2.js +1 -0
- package/dist/bundle/chunks/cli-FWMQKBFA.js +30 -0
- package/dist/bundle/chunks/cli-ZEDY5U67.js +52 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-E6TEENDO.js +1 -0
- package/dist/bundle/chunks/codemode-worker.js +480 -0
- package/dist/bundle/chunks/dist-D3WIBXB5.js +10 -0
- package/dist/bundle/chunks/easter-egg-3d-5TFBCTIS.js +1 -0
- package/dist/bundle/chunks/execute-62LDYHXA.js +506 -0
- package/dist/bundle/chunks/github-copilot.js +1 -0
- package/dist/bundle/chunks/google-generative-ai-V5DLXTF7.js +1 -0
- package/dist/bundle/chunks/google-vertex-K3KYGGLI.js +1 -0
- package/dist/bundle/chunks/http-proxy-KF35JLJN.js +1 -0
- package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +12 -0
- package/dist/bundle/chunks/image-resize-worker.js +1 -0
- package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +20 -0
- package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +1 -0
- package/dist/bundle/chunks/kimi-coding.js +1 -0
- package/dist/bundle/chunks/lib-4AVRLBHM.js +8 -0
- package/dist/bundle/chunks/llama-cpp-classify-JCTIEHTL.js +21 -0
- package/dist/bundle/chunks/mcp-VF7EY5WC.js +10 -0
- package/dist/bundle/chunks/meta.js +1 -0
- package/dist/bundle/chunks/mistral-conversations-LVBXTF6R.js +4 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +2 -0
- package/dist/bundle/chunks/node-AUOGOBCN.js +1 -0
- package/dist/bundle/chunks/node-ZTHARAQV.js +15 -0
- package/dist/bundle/chunks/office-PONBADQP.js +419 -0
- package/dist/bundle/chunks/openai-chatgpt.js +74 -0
- package/dist/bundle/chunks/openai-codex-responses-WBZKNYLX.js +9 -0
- package/dist/bundle/chunks/openai-codex.js +74 -0
- package/dist/bundle/chunks/openai-completions-HMHQRGX4.js +6 -0
- package/dist/bundle/chunks/openai-decisions-R7OFRKLL.js +4 -0
- package/dist/bundle/chunks/openai-responses-BHXRQFCI.js +3 -0
- package/dist/bundle/chunks/openrouter-images-BIMNIXQZ.js +1 -0
- package/dist/bundle/chunks/openrouter.js +74 -0
- package/dist/bundle/chunks/pi-messages-X5YTLXQJ.js +7 -0
- package/dist/bundle/chunks/radius.js +74 -0
- package/dist/bundle/chunks/review-WCGIBVLM.js +80 -0
- package/dist/bundle/chunks/rewind-2OYLDDHH.js +8 -0
- package/dist/bundle/chunks/router-7E5LU7US.js +3 -0
- package/dist/bundle/chunks/runtime-5PTUOEM2.js +1 -0
- package/dist/bundle/chunks/sdk-ZUFIGPSS.js +1 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +3 -0
- package/dist/bundle/chunks/sync-LOX6TIM6.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-KOIOG3HP.js +1 -0
- package/dist/bundle/chunks/usage-2EVEFGNI.js +1 -0
- package/dist/bundle/chunks/virtual-modules-MYMONT3Y.js +1 -0
- package/dist/bundle/chunks/xai.js +1 -0
- package/dist/bundle/cli-runtime.js +2 -0
- package/dist/bundle/cli.js +2 -0
- package/dist/bundle/index.js +1 -0
- package/dist/bundle/rpc-entry.js +2 -0
- package/dist/cli/args.js +1 -1
- package/dist/cli/auth-command.js +9 -6
- package/dist/cli/auth-login.js +2 -0
- package/dist/cli/auth-logout.js +1 -0
- package/dist/cli/auth-terminal.js +5 -0
- package/dist/cli/config-selector.js +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.js +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session.d.ts +8 -1
- package/dist/core/agent-session.js +12 -9
- package/dist/core/auth-storage.js +1 -1
- package/dist/core/bash-executor.js +1 -1
- package/dist/core/bug-report.js +3 -3
- package/dist/core/cache-warmer.d.ts +3 -15
- package/dist/core/cache-warmer.js +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +3 -2
- package/dist/core/compaction/branch-summarization.js +5 -5
- package/dist/core/compaction/compaction.d.ts +1 -0
- package/dist/core/compaction/compaction.js +14 -14
- package/dist/core/compaction/tool-output-pruning.js +1 -1
- package/dist/core/compaction/utils.d.ts +0 -1
- package/dist/core/compaction/utils.js +8 -8
- package/dist/core/exec.d.ts +2 -0
- package/dist/core/exec.js +1 -1
- package/dist/core/export-html/template.css +9 -0
- package/dist/core/export-html/template.js +46 -39
- package/dist/core/export-html/tool-renderer.js +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/pi-ai-extension-view.js +1 -0
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/types.d.ts +25 -7
- package/dist/core/extensions/virtual-modules.js +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/mcp-servers.d.ts +6 -17
- package/dist/core/mcp-servers.js +1 -1
- package/dist/core/model-config.d.ts +1912 -2211
- package/dist/core/model-config.js +4 -4
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.js +1 -1
- package/dist/core/package-manager.d.ts +10 -1
- package/dist/core/package-manager.js +2 -2
- package/dist/core/pi-ai-schemas.js +1 -0
- package/dist/core/pi-manifest.js +1 -1
- package/dist/core/preferred-providers.js +1 -0
- package/dist/core/project-trust.js +2 -2
- package/dist/core/prompt-templates.js +2 -2
- package/dist/core/provider-composer.js +1 -1
- package/dist/core/provider-matching.js +1 -0
- package/dist/core/radius-mcp.js +1 -0
- package/dist/core/remote-catalog-provider.js +1 -1
- package/dist/core/resource-loader.d.ts +3 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/runtime-credentials.js +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/session-cwd.js +3 -7
- package/dist/core/session-manager.d.ts +1 -0
- package/dist/core/session-manager.js +12 -12
- package/dist/core/settings-defaults.js +1 -1
- package/dist/core/settings-manager.d.ts +4 -0
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-schema.d.ts +4 -2
- package/dist/core/settings-schema.js +1 -1
- package/dist/core/skills.js +3 -3
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/source-info.d.ts +8 -0
- package/dist/core/source-info.js +1 -1
- package/dist/core/system-prompt.js +3 -3
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.js +15 -15
- package/dist/core/tools/edit-diff.d.ts +9 -4
- package/dist/core/tools/edit-diff.js +22 -15
- package/dist/core/tools/edit.d.ts +3 -3
- package/dist/core/tools/edit.js +3 -3
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.js +10 -11
- package/dist/core/tools/grep.d.ts +3 -3
- package/dist/core/tools/grep.js +8 -12
- package/dist/core/tools/ls.d.ts +2 -2
- package/dist/core/tools/ls.js +4 -4
- package/dist/core/tools/powershell.js +6 -2
- package/dist/core/tools/read.d.ts +5 -2
- package/dist/core/tools/read.js +20 -19
- package/dist/core/tools/render-utils.js +5 -5
- package/dist/core/tools/renderers/write.js +10 -10
- package/dist/core/tools/tool-definition-wrapper.d.ts +11 -0
- package/dist/core/tools/truncate.d.ts +2 -8
- package/dist/core/tools/truncate.js +10 -10
- package/dist/core/tools/write.d.ts +2 -2
- package/dist/core/trust-manager.js +2 -2
- package/dist/core/usage-totals.js +1 -1
- package/dist/extensions/codemode/execute.js +12 -12
- package/dist/extensions/codemode/renderer.js +6 -6
- package/dist/extensions/codemode/tool.d.ts +2 -1
- package/dist/extensions/codemode/tool.js +11 -10
- package/dist/extensions/llama/client.js +5 -5
- package/dist/extensions/llama/ui.js +2 -2
- package/dist/extensions/mcp/cli.js +21 -19
- package/dist/extensions/mcp/config.js +2 -2
- package/dist/extensions/mcp/index.js +7 -7
- package/dist/extensions/mcp/oauth.d.ts +3 -22
- package/dist/extensions/mcp/oauth.js +2 -2
- package/dist/extensions/mcp/resources.d.ts +1 -1
- package/dist/extensions/mcp/resources.js +1 -1
- package/dist/extensions/mcp/runtime.d.ts +2 -2
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/extensions/mcp/tools.d.ts +1 -8
- package/dist/extensions/mcp/tools.js +4 -9
- package/dist/extensions/mcp/ui.js +1 -1
- package/dist/extensions/tool-search/tool.js +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/main.js +4 -4
- package/dist/modes/interactive/components/assistant-message.d.ts +4 -1
- package/dist/modes/interactive/components/assistant-message.js +2 -2
- package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/branch-summary-message.js +2 -2
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +2 -2
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-entry.js +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +5 -2
- package/dist/modes/interactive/components/custom-message.js +3 -3
- package/dist/modes/interactive/components/diff.js +3 -3
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -0
- package/dist/modes/interactive/components/extension-editor.js +1 -1
- package/dist/modes/interactive/components/extension-selector.js +2 -2
- package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
- package/dist/modes/interactive/components/login-dialog.js +1 -1
- package/dist/modes/interactive/components/markdown-transform.js +1 -1
- package/dist/modes/interactive/components/mermaid.js +4 -4
- package/dist/modes/interactive/components/model-selector.d.ts +1 -0
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts +2 -1
- package/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/dist/modes/interactive/components/provider-brand.js +1 -0
- package/dist/modes/interactive/components/radius-login-selector.js +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +2 -1
- package/dist/modes/interactive/components/session-selector.js +2 -2
- package/dist/modes/interactive/components/settings-submenu.js +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +2 -2
- package/dist/modes/interactive/components/tool-execution.d.ts +1 -0
- package/dist/modes/interactive/components/tool-execution.js +3 -3
- package/dist/modes/interactive/components/tree-selector.d.ts +2 -0
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +2 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/external-editor.js +3 -3
- package/dist/modes/interactive/interactive-mode.d.ts +10 -1
- package/dist/modes/interactive/interactive-mode.js +45 -40
- package/dist/modes/interactive/model-search.js +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +4 -0
- package/dist/modes/interactive/theme/theme.js +3 -6
- package/dist/modes/print-mode.js +7 -7
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-compat/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +3 -2
- package/dist/node_modules/@dalcode/dal-learn/src/index.js +16 -16
- package/dist/node_modules/@dalcode/dal-learn/src/lesson-events.js +1 -0
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +4 -3
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +4 -3
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/image-budget.js +1 -0
- package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-workflow/src/todo-snapshot.js +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +3 -3
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/README.md +8 -6
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +2 -2
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/README.md +58 -39
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +9 -9
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/strict-tool-limits.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/meta.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/trusted-url.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.d.ts +21 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-bedrock-provider.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-oauth.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/all.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +485 -498
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual-cn.json +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +65 -65
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/schema-builders.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/telemetry.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +4 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/openrouter-cost.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.d.ts +26 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.js +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/{typebox-helpers.d.ts → string-enum.d.ts} +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/string-enum.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.js +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +12 -5
- package/dist/node_modules/@earendil-works/pi-codemode/README.md +2 -2
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.js +4 -4
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +2 -0
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +32 -0
- package/dist/node_modules/@earendil-works/pi-mcp/README.md +60 -5
- package/dist/node_modules/@earendil-works/pi-mcp/dist/config.d.ts +45 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/config.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/callback.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.d.ts +42 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.d.ts +5 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.js +11 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/lines.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.js +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.d.ts +1 -4
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.js +2 -2
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +6 -4
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-schema/CHANGELOG.md +37 -0
- package/dist/node_modules/@earendil-works/pi-schema/LICENSE +21 -0
- package/dist/node_modules/@earendil-works/pi-schema/README.md +319 -0
- package/dist/node_modules/@earendil-works/pi-schema/THIRD_PARTY_NOTICES/typebox-LICENSE +23 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/annotations.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/builders.d.ts +89 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/builders.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/checks.d.ts +51 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/checks.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/coerce.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/compiler.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/explain.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date_time.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/duration.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/email.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_email.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/bidi.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/puny.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/idn-hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/ascii.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/puny.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/unicode.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/pattern/pattern.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv4.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv6.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri_reference.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer_uri_fragment.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/regex.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/relative_json_pointer.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/time.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_reference.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_template.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/url.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uuid.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/index.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/resolver.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/shared.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.d.ts +54 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.js +0 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/types.d.ts +25 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/types.js +0 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/validator.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/validator.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/package.json +43 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.js +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/render.js +2 -2
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +3 -1
- package/dist/node_modules/@earendil-works/pi-tui/README.md +2 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +3 -3
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +11 -10
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/text.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/keys.js +5 -5
- package/dist/node_modules/@earendil-works/pi-tui/dist/layout.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/program-status.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +4 -4
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +13 -13
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/package-manager-cli.js +17 -16
- package/dist/utils/ansi.js +1 -1
- package/dist/utils/changelog.js +3 -3
- package/dist/utils/clipboard-command.js +1 -1
- package/dist/utils/image-resize-core.js +1 -1
- package/dist/utils/image-resize.js +1 -1
- package/dist/utils/open-browser.js +1 -1
- package/dist/utils/paths.js +1 -1
- package/dist/utils/shell.js +3 -3
- package/dist/utils/syntax-highlight.js +4 -4
- package/dist/utils/terminal-question.js +1 -0
- package/dist/utils/tools-manager.js +1 -1
- package/dist/utils/web-url.js +1 -0
- package/examples/extensions/README.md +2 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +14 -14
- package/examples/extensions/debug-provider.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +19 -29
- package/examples/extensions/gondolin/package.json +2 -2
- package/examples/extensions/plan-mode/index.ts +20 -9
- package/examples/extensions/plan-mode/utils.ts +42 -16
- package/examples/extensions/preset.ts +2 -0
- package/examples/extensions/reload-runtime.ts +17 -5
- package/examples/extensions/subagent/README.md +14 -11
- package/examples/extensions/subagent/index.ts +392 -171
- package/examples/extensions/todo.ts +7 -0
- package/examples/extensions/tools.ts +2 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +20 -20
- package/examples/tsconfig.json +208 -0
- package/npm-shrinkwrap.json +407 -383
- package/package.json +6 -7
- package/examples/extensions/sandbox/index.ts +0 -327
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
- /package/dist/node_modules/@earendil-works/pi-mcp/{LICENSES → THIRD_PARTY_NOTICES}/modelcontextprotocol-typescript-sdk.txt +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Api, Model, SimpleStreamOptions } from "./types.ts";
|
|
2
|
+
export type CacheWarmingAction = "warm" | "stop";
|
|
3
|
+
export type CacheWarmingPhase = "streaming" | "idle";
|
|
4
|
+
export interface CacheWarmingDecision {
|
|
5
|
+
phase: CacheWarmingPhase;
|
|
6
|
+
warmCost: number;
|
|
7
|
+
missCost: number;
|
|
8
|
+
continuationProbability: number;
|
|
9
|
+
expectedSavings: number;
|
|
10
|
+
economicsAvailable: boolean;
|
|
11
|
+
action: CacheWarmingAction;
|
|
12
|
+
}
|
|
13
|
+
export declare const CACHE_WARMING_MAX_AGE_MS: number;
|
|
14
|
+
export declare const CACHE_WARMING_MAX_IDLE_AGE_MS: number;
|
|
15
|
+
export declare const CACHE_WARMING_MINIMUM_EXPECTED_SAVINGS = 0.05;
|
|
16
|
+
export declare const CACHE_WARMING_IDLE_CONTINUATION_PROBABILITY = 0.15;
|
|
17
|
+
export declare function getCacheWarmingDelayMs(ttlMs: number): number | undefined;
|
|
18
|
+
export declare function getPromptCacheTtlMs(model: Model<Api>, options: SimpleStreamOptions | undefined): number | undefined;
|
|
19
|
+
export declare function isCacheWarmingReplayable(model: Model<Api>, options: SimpleStreamOptions | undefined): boolean;
|
|
20
|
+
export declare function getCacheWarmingRequestOptions<T extends SimpleStreamOptions>(options: T, signal: AbortSignal): T;
|
|
21
|
+
export declare function evaluateCacheWarming(model: Model<Api>, promptTokens: number, phase: CacheWarmingPhase): CacheWarmingDecision;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _=Object.defineProperty;var c=(t,e)=>_(t,"name",{value:e,configurable:!0});import{calculateCost as p}from"./models.js";import{getProviderEnvValue as A}from"./utils/provider-env.js";const d=60*6e4,x=30*6e4,f=.05,M=.15;function R(t){if(!(t<=1e4))return Math.max(1,Math.floor(Math.min(t*.9,t-1e4)))}c(R,"getCacheWarmingDelayMs");function l(t,e){const n=e?.cacheRetention??(A("PI_CACHE_RETENTION",e?.env)==="long"?"long":"short");if(n==="none")return;const a=t.promptCache?.[n];return a===void 0?void 0:a*1e3}c(l,"getPromptCacheTtlMs");function m(t,e){return!e?.reasoning||t.api!=="anthropic-messages"?!0:t.compat?.forceAdaptiveThinking===!0}c(m,"isCacheWarmingReplayable");function W(t,e){return{...t,maxTokens:1,disableContinuation:!0,maxRetries:0,signal:e}}c(W,"getCacheWarmingRequestOptions");function N(t,e,n){const a=o(t,{cacheRead:e}),i=o(t,t.cost.cacheWrite>0?{cacheWrite:e}:{input:e}),r=o(t,{cacheRead:e,output:1}),u=Math.max(0,i-a),s=n==="idle"?M:1,h=e>0&&(a>0||i>0),C=s*u-r;return{phase:n,warmCost:r,missCost:u,continuationProbability:s,expectedSavings:C,economicsAvailable:h,action:C>=f?"warm":"stop"}}c(N,"evaluateCacheWarming");function o(t,e){const n={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},...e};return p(t,n).total}c(o,"price");export{M as CACHE_WARMING_IDLE_CONTINUATION_PROBABILITY,d as CACHE_WARMING_MAX_AGE_MS,x as CACHE_WARMING_MAX_IDLE_AGE_MS,f as CACHE_WARMING_MINIMUM_EXPECTED_SAVINGS,N as evaluateCacheWarming,R as getCacheWarmingDelayMs,W as getCacheWarmingRequestOptions,l as getPromptCacheTtlMs,m as isCacheWarmingReplayable};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
${n.message}`);for(let s=0;s<n.options.length;s++)console.log(` ${s+1}. ${n.options[s].label}`);const e=Number.parseInt(await a(o,`Enter number (1-${n.options.length}): `),10)-1,r=n.options[e];if(!r)throw new Error("Invalid selection");return r.id}return a(o,`${n.message}${n.placeholder?` (${n.placeholder})`:""}: `)}t(
|
|
2
|
+
var p=Object.defineProperty;var t=(o,n)=>p(o,"name",{value:n,configurable:!0});import{randomUUID as f}from"node:crypto";import{chmodSync as g,existsSync as d,readFileSync as m,writeFileSync as w}from"node:fs";import{createInterface as u}from"node:readline";import{builtinProviders as h}from"./providers/all.js";const l="auth.json",c=h().filter(o=>o.auth.oauth!==void 0);function a(o,n){return new Promise(e=>o.question(n,e))}t(a,"prompt");function $(){if(!d(l))return{};try{return JSON.parse(m(l,"utf-8"))}catch{return{}}}t($,"loadAuth");function y(o){d(l)&&g(l,384),w(l,JSON.stringify(o,null,2),{encoding:"utf-8",mode:384})}t(y,"saveAuth");async function b(o,n){if(n.type==="select"){console.log(`
|
|
3
|
+
${n.message}`);for(let s=0;s<n.options.length;s++)console.log(` ${s+1}. ${n.options[s].label}`);const e=Number.parseInt(await a(o,`Enter number (1-${n.options.length}): `),10)-1,r=n.options[e];if(!r)throw new Error("Invalid selection");return r.id}return a(o,`${n.message}${n.placeholder?` (${n.placeholder})`:""}: `)}t(b,"answerPrompt");async function E(o){const n=c.find(r=>r.id===o);if(!n)throw new Error(`Unknown provider: ${o}`);const e=u({input:process.stdin,output:process.stdout});try{const r=await n.auth.oauth.login({signal:new AbortController().signal,prompt:t(i=>b(e,i),"prompt"),notify:t(i=>{switch(i.type){case"auth_url":console.log(`
|
|
4
4
|
Open this URL in your browser:
|
|
5
5
|
${i.url}`),i.instructions&&console.log(i.instructions);break;case"device_code":console.log(`
|
|
6
6
|
Open this URL in your browser:
|
|
7
|
-
${i.verificationUri}`),console.log(`Enter code: ${i.userCode}`);break;case"info":case"progress":console.log(i.message);break}},"notify")},{getDeviceId:
|
|
8
|
-
Credentials saved to ${l}`)}finally{e.close()}}t(
|
|
7
|
+
${i.verificationUri}`),console.log(`Enter code: ${i.userCode}`);break;case"info":case"progress":console.log(i.message);break}},"notify")},{getDeviceId:f}),s=$();s[o]=r,y(s),console.log(`
|
|
8
|
+
Credentials saved to ${l}`)}finally{e.close()}}t(E,"login");async function v(){const o=process.argv.slice(2),n=o[0];if(!n||n==="help"||n==="--help"||n==="-h"){const e=c.map(r=>` ${r.id.padEnd(20)} ${r.name}`).join(`
|
|
9
9
|
`);console.log(`Usage: npx @earendil-works/pi-ai <command> [provider]
|
|
10
10
|
|
|
11
11
|
Commands:
|
|
@@ -13,4 +13,4 @@ Commands:
|
|
|
13
13
|
list List available providers
|
|
14
14
|
|
|
15
15
|
Providers:
|
|
16
|
-
${e}`);return}if(n==="list"){for(const e of c)console.log(`${e.id.padEnd(20)} ${e.name}`);return}if(n==="login"){let e=o[1];if(!e){const r=
|
|
16
|
+
${e}`);return}if(n==="list"){for(const e of c)console.log(`${e.id.padEnd(20)} ${e.name}`);return}if(n==="login"){let e=o[1];if(!e){const r=u({input:process.stdin,output:process.stdout});try{for(let i=0;i<c.length;i++)console.log(` ${i+1}. ${c[i].name}`);const s=Number.parseInt(await a(r,`Enter number (1-${c.length}): `),10)-1;e=c[s]?.id}finally{r.close()}}if(!e||!c.some(r=>r.id===e))throw new Error(`Unknown provider: ${e??""}`);await E(e);return}throw new Error(`Unknown command: ${n}`)}t(v,"main"),v().catch(o=>{console.error("Error:",o instanceof Error?o.message:String(o)),process.exit(1)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var T=Object.defineProperty;var A=(_,e)=>T(_,"name",{value:e,configurable:!0});var K=function(_,e){return typeof _=="string"&&/^\.\.?\//.test(_)?_.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(E,t,I,
|
|
1
|
+
var T=Object.defineProperty;var A=(_,e)=>T(_,"name",{value:e,configurable:!0});var K=function(_,e){return typeof _=="string"&&/^\.\.?\//.test(_)?_.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(E,t,I,N,a){return t?e?".jsx":".js":I&&(!N||!a)?E:I+N+"."+a.toLowerCase()+"js"}):_};let o=null,O=null,s=null;const r=A(_=>import(K(_)),"dynamicImport"),C="node:fs",R="node:os",l="node:path";typeof process<"u"&&(process.versions?.node||process.versions?.bun)&&(r(C).then(_=>{o=_.existsSync}),r(R).then(_=>{O=_.homedir}),r(l).then(_=>{s=_.join}));import{getProviderEnvValue as n}from"./utils/provider-env.js";const c="ANTHROPIC_AUTH_TOKEN",u="ANTHROPIC_OAUTH_TOKEN",f="ANTHROPIC_API_KEY",D="ANTHROPIC_FEDERATION_RULE_ID",x="ANTHROPIC_ORGANIZATION_ID",g="ANTHROPIC_SERVICE_ACCOUNT_ID",H="ANTHROPIC_IDENTITY_TOKEN_FILE",m="ANTHROPIC_WORKSPACE_ID";let i=null;function d(_){const e=_?.GOOGLE_APPLICATION_CREDENTIALS;if(e)return o?o(e):!1;if(i===null){if(!o||!O||!s)return typeof process<"u"&&(process.versions?.node||process.versions?.bun)||(i=!1),!1;const E=n("GOOGLE_APPLICATION_CREDENTIALS",_);E?i=o(E):i=o(s(O(),".config","gcloud","application_default_credentials.json"))}return i}A(d,"hasVertexAdcCredentials");function Y(_){if(_==="github-copilot")return["COPILOT_GITHUB_TOKEN"];if(_==="anthropic")return[c,u,f];const E={"ant-ling":"ANT_LING_API_KEY","qwen-token-plan":"QWEN_TOKEN_PLAN_API_KEY","qwen-token-plan-cn":"QWEN_TOKEN_PLAN_CN_API_KEY","qwen-token-plan-individual":"QWEN_TOKEN_PLAN_API_KEY","qwen-token-plan-individual-cn":"QWEN_TOKEN_PLAN_CN_API_KEY",openai:"OPENAI_API_KEY",azure:"AZURE_OPENAI_API_KEY",nvidia:"NVIDIA_API_KEY",deepseek:"DEEPSEEK_API_KEY",google:"GEMINI_API_KEY","google-vertex":"GOOGLE_CLOUD_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",xai:"XAI_API_KEY",typesafe:"TYPESAFE_API_KEY",radius:"RADIUS_API_KEY",openrouter:"OPENROUTER_API_KEY","vercel-ai-gateway":"AI_GATEWAY_API_KEY",zai:"ZAI_API_KEY","zai-coding-cn":"ZAI_CODING_CN_API_KEY",mistral:"MISTRAL_API_KEY",minimax:"MINIMAX_API_KEY","minimax-cn":"MINIMAX_CN_API_KEY",moonshotai:"MOONSHOT_API_KEY","moonshotai-cn":"MOONSHOT_API_KEY",huggingface:"HF_TOKEN",fireworks:"FIREWORKS_API_KEY",together:"TOGETHER_API_KEY",baseten:"BASETEN_API_KEY",opencode:"OPENCODE_API_KEY","opencode-go":"OPENCODE_API_KEY","kimi-coding":"KIMI_API_KEY",meta:"META_API_KEY","cloudflare-workers-ai":"CLOUDFLARE_API_KEY","cloudflare-ai-gateway":"CLOUDFLARE_API_KEY",xiaomi:"XIAOMI_API_KEY","xiaomi-token-plan-cn":"XIAOMI_TOKEN_PLAN_CN_API_KEY","xiaomi-token-plan-ams":"XIAOMI_TOKEN_PLAN_AMS_API_KEY","xiaomi-token-plan-sgp":"XIAOMI_TOKEN_PLAN_SGP_API_KEY"}[_];return E?[E]:void 0}A(Y,"getApiKeyEnvVars");function p(_,e){const E=Y(_);if(!E)return;const t=E.filter(I=>!!n(I,e));return t.length>0?t:void 0}A(p,"findEnvKeys");let P;function h(_){P=_}A(h,"setEnvApiKeyPolicy");function G(_,e){if(P&&!P(_))return;const E=p(_,e);if(E?.[0]){const t=_==="anthropic"?E.find(I=>I!==c):E[0];if(t)return n(t,e)}if(_==="google-vertex"){const t=d(e),I=!!(n("GOOGLE_CLOUD_PROJECT",e)||n("GCLOUD_PROJECT",e)),N=!!n("GOOGLE_CLOUD_LOCATION",e);if(t&&I&&N)return"<authenticated>"}if(_==="amazon-bedrock"&&(n("AWS_PROFILE",e)||n("AWS_ACCESS_KEY_ID",e)&&n("AWS_SECRET_ACCESS_KEY",e)||n("AWS_BEARER_TOKEN_BEDROCK",e)||n("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",e)||n("AWS_CONTAINER_CREDENTIALS_FULL_URI",e)||n("AWS_WEB_IDENTITY_TOKEN_FILE",e)))return"<authenticated>"}A(G,"getEnvApiKey");export{f as ANTHROPIC_API_KEY_ENV,c as ANTHROPIC_AUTH_TOKEN_ENV,D as ANTHROPIC_FEDERATION_RULE_ID_ENV,H as ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,u as ANTHROPIC_OAUTH_TOKEN_ENV,x as ANTHROPIC_ORGANIZATION_ID_ENV,g as ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,m as ANTHROPIC_WORKSPACE_ID_ENV,p as findEnvKeys,G as getEnvApiKey,h as setEnvApiKeyPolicy};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export type { Static, TSchema } from "typebox";
|
|
2
|
-
export { Type } from "typebox";
|
|
3
1
|
export type { AnthropicEffort, AnthropicOptions, AnthropicThinkingDisplay } from "./api/anthropic-messages.ts";
|
|
4
2
|
export type { AzureOpenAIResponsesOptions } from "./api/azure-openai-responses.ts";
|
|
5
3
|
export type { BedrockOptions, BedrockThinkingDisplay } from "./api/bedrock-converse-stream.ts";
|
|
@@ -17,6 +15,7 @@ export * from "./auth/credential-store.ts";
|
|
|
17
15
|
export * from "./auth/helpers.ts";
|
|
18
16
|
export { setAmbientAuthPolicy } from "./auth/resolve.ts";
|
|
19
17
|
export * from "./auth/types.ts";
|
|
18
|
+
export * from "./cache-warming.ts";
|
|
20
19
|
export type { OAuthAuthInfo, OAuthDeviceCodeInfo, OAuthLoginCallbacks, OAuthPrompt, OAuthSelectOption, OAuthSelectPrompt, } from "./compat/extension-oauth-types.ts";
|
|
21
20
|
export { getEnvApiKey, setEnvApiKeyPolicy } from "./env-api-keys.ts";
|
|
22
21
|
export * from "./models.ts";
|
|
@@ -30,9 +29,10 @@ export * from "./utils/identity.ts";
|
|
|
30
29
|
export * from "./utils/json-parse.ts";
|
|
31
30
|
export * from "./utils/overflow.ts";
|
|
32
31
|
export * from "./utils/retry.ts";
|
|
32
|
+
export * from "./utils/streaming-json.ts";
|
|
33
|
+
export * from "./utils/string-enum.ts";
|
|
33
34
|
export { contentText, getSystemMessageText, renderSystemMessageUpdate } from "./utils/text.ts";
|
|
34
35
|
export * from "./utils/transcript.ts";
|
|
35
|
-
export * from "./utils/typebox-helpers.ts";
|
|
36
36
|
export { uuidv7 } from "./utils/uuid.ts";
|
|
37
37
|
export * from "./utils/validation.ts";
|
|
38
38
|
export { PI_AI_VERSION } from "./utils/version.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from"./api/lazy.js";export*from"./auth/context.js";export*from"./auth/credential-store.js";export*from"./auth/helpers.js";import{setAmbientAuthPolicy as x}from"./auth/resolve.js";export*from"./auth/types.js";export*from"./cache-warming.js";import{getEnvApiKey as n,setEnvApiKeyPolicy as y}from"./env-api-keys.js";export*from"./models.js";export*from"./models-store.js";export*from"./providers/faux.js";export*from"./session-resources.js";export*from"./types.js";export*from"./utils/diagnostics.js";export*from"./utils/event-stream.js";export*from"./utils/identity.js";export*from"./utils/json-parse.js";export*from"./utils/overflow.js";export*from"./utils/retry.js";export*from"./utils/streaming-json.js";export*from"./utils/string-enum.js";import{contentText as T,getSystemMessageText as _,renderSystemMessageUpdate as b}from"./utils/text.js";export*from"./utils/transcript.js";import{uuidv7 as O}from"./utils/uuid.js";export*from"./utils/validation.js";import{PI_AI_VERSION as V}from"./utils/version.js";export{V as PI_AI_VERSION,T as contentText,n as getEnvApiKey,_ as getSystemMessageText,b as renderSystemMessageUpdate,x as setAmbientAuthPolicy,y as setEnvApiKeyPolicy,O as uuidv7};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var r=(o,e)=>i(o,"name",{value:e,configurable:!0});import{setBedrockProviderLoader as t}from"./api/bedrock-converse-stream.lazy.js";function m(){t(()=>import("./api/bedrock-converse-stream.js"))}r(m,"registerLazyBedrockProvider");export{m as registerLazyBedrockProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=Object.defineProperty;var t=(a,i)=>o(a,"name",{value:i,configurable:!0});import{registerBundledOAuthFlowLoaders as r}from"./auth/oauth/load.js";function p(){r({anthropic:t(async()=>(await import("./auth/oauth/anthropic.js")).anthropicOAuth,"anthropic"),openaiCodex:t(async()=>(await import("./auth/oauth/openai-codex.js")).openaiCodexOAuth,"openaiCodex"),openaiChatGPT:t(async()=>(await import("./auth/oauth/openai-chatgpt.js")).openaiChatGPTOAuth,"openaiChatGPT"),githubCopilot:t(async()=>(await import("./auth/oauth/github-copilot.js")).githubCopilotOAuth,"githubCopilot"),openrouter:t(async()=>(await import("./auth/oauth/openrouter.js")).openRouterOAuth,"openrouter"),kimiCoding:t(async()=>(await import("./auth/oauth/kimi-coding.js")).kimiCodingOAuth,"kimiCoding"),meta:t(async()=>(await import("./auth/oauth/meta.js")).metaOAuth,"meta"),xai:t(async()=>(await import("./auth/oauth/xai.js")).xaiOAuth,"xai"),radius:t(async a=>(await import("./auth/oauth/radius.js")).createRadiusOAuth(a),"radius")})}t(p,"registerLazyOAuthFlows");export{p as registerLazyOAuthFlows};
|
|
@@ -49,6 +49,7 @@ export interface Provider<TApi extends Api = Api> {
|
|
|
49
49
|
getModels(): readonly Model<TApi>[];
|
|
50
50
|
getAllModels?(): readonly ProviderModel<TApi>[];
|
|
51
51
|
refreshModels?(context: RefreshModelsContext): Promise<void>;
|
|
52
|
+
readonly refreshModelsAuth?: "credential" | "configured";
|
|
52
53
|
filterModels?(models: readonly Model<TApi>[], credential: Credential | undefined): readonly Model<TApi>[];
|
|
53
54
|
supportsApi?(api: Api): boolean;
|
|
54
55
|
filterAllModels?(models: readonly ProviderModel<TApi>[], credential: Credential | undefined): readonly ProviderModel<TApi>[];
|
|
@@ -29,6 +29,7 @@ import { OPENROUTER_CLASSIFIER_MODELS, OPENROUTER_IMAGE_MODELS, OPENROUTER_MODEL
|
|
|
29
29
|
import { QWEN_TOKEN_PLAN_CLASSIFIER_MODELS, QWEN_TOKEN_PLAN_IMAGE_MODELS, QWEN_TOKEN_PLAN_MODELS } from "./providers/qwen-token-plan.models.ts";
|
|
30
30
|
import { QWEN_TOKEN_PLAN_CN_CLASSIFIER_MODELS, QWEN_TOKEN_PLAN_CN_IMAGE_MODELS, QWEN_TOKEN_PLAN_CN_MODELS } from "./providers/qwen-token-plan-cn.models.ts";
|
|
31
31
|
import { QWEN_TOKEN_PLAN_INDIVIDUAL_CLASSIFIER_MODELS, QWEN_TOKEN_PLAN_INDIVIDUAL_IMAGE_MODELS, QWEN_TOKEN_PLAN_INDIVIDUAL_MODELS } from "./providers/qwen-token-plan-individual.models.ts";
|
|
32
|
+
import { QWEN_TOKEN_PLAN_INDIVIDUAL_CN_CLASSIFIER_MODELS, QWEN_TOKEN_PLAN_INDIVIDUAL_CN_IMAGE_MODELS, QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS } from "./providers/qwen-token-plan-individual-cn.models.ts";
|
|
32
33
|
import { RADIUS_CLASSIFIER_MODELS, RADIUS_IMAGE_MODELS, RADIUS_MODELS } from "./providers/radius.models.ts";
|
|
33
34
|
import { TOGETHER_CLASSIFIER_MODELS, TOGETHER_IMAGE_MODELS, TOGETHER_MODELS } from "./providers/together.models.ts";
|
|
34
35
|
import { TYPESAFE_CLASSIFIER_MODELS, TYPESAFE_IMAGE_MODELS, TYPESAFE_MODELS } from "./providers/typesafe.models.ts";
|
|
@@ -72,6 +73,7 @@ export declare const MODELS: {
|
|
|
72
73
|
readonly "qwen-token-plan": typeof QWEN_TOKEN_PLAN_MODELS;
|
|
73
74
|
readonly "qwen-token-plan-cn": typeof QWEN_TOKEN_PLAN_CN_MODELS;
|
|
74
75
|
readonly "qwen-token-plan-individual": typeof QWEN_TOKEN_PLAN_INDIVIDUAL_MODELS;
|
|
76
|
+
readonly "qwen-token-plan-individual-cn": typeof QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS;
|
|
75
77
|
readonly "radius": typeof RADIUS_MODELS;
|
|
76
78
|
readonly "together": typeof TOGETHER_MODELS;
|
|
77
79
|
readonly "typesafe": typeof TYPESAFE_MODELS;
|
|
@@ -116,6 +118,7 @@ export declare const IMAGE_MODELS: {
|
|
|
116
118
|
readonly "qwen-token-plan": typeof QWEN_TOKEN_PLAN_IMAGE_MODELS;
|
|
117
119
|
readonly "qwen-token-plan-cn": typeof QWEN_TOKEN_PLAN_CN_IMAGE_MODELS;
|
|
118
120
|
readonly "qwen-token-plan-individual": typeof QWEN_TOKEN_PLAN_INDIVIDUAL_IMAGE_MODELS;
|
|
121
|
+
readonly "qwen-token-plan-individual-cn": typeof QWEN_TOKEN_PLAN_INDIVIDUAL_CN_IMAGE_MODELS;
|
|
119
122
|
readonly "radius": typeof RADIUS_IMAGE_MODELS;
|
|
120
123
|
readonly "together": typeof TOGETHER_IMAGE_MODELS;
|
|
121
124
|
readonly "typesafe": typeof TYPESAFE_IMAGE_MODELS;
|
|
@@ -160,6 +163,7 @@ export declare const CLASSIFIER_MODELS: {
|
|
|
160
163
|
readonly "qwen-token-plan": typeof QWEN_TOKEN_PLAN_CLASSIFIER_MODELS;
|
|
161
164
|
readonly "qwen-token-plan-cn": typeof QWEN_TOKEN_PLAN_CN_CLASSIFIER_MODELS;
|
|
162
165
|
readonly "qwen-token-plan-individual": typeof QWEN_TOKEN_PLAN_INDIVIDUAL_CLASSIFIER_MODELS;
|
|
166
|
+
readonly "qwen-token-plan-individual-cn": typeof QWEN_TOKEN_PLAN_INDIVIDUAL_CN_CLASSIFIER_MODELS;
|
|
163
167
|
readonly "radius": typeof RADIUS_CLASSIFIER_MODELS;
|
|
164
168
|
readonly "together": typeof TOGETHER_CLASSIFIER_MODELS;
|
|
165
169
|
readonly "typesafe": typeof TYPESAFE_CLASSIFIER_MODELS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AMAZON_BEDROCK_CLASSIFIER_MODELS as E,AMAZON_BEDROCK_IMAGE_MODELS as _,AMAZON_BEDROCK_MODELS as O}from"./providers/amazon-bedrock.models.js";import{ANT_LING_CLASSIFIER_MODELS as
|
|
1
|
+
import{AMAZON_BEDROCK_CLASSIFIER_MODELS as E,AMAZON_BEDROCK_IMAGE_MODELS as _,AMAZON_BEDROCK_MODELS as O}from"./providers/amazon-bedrock.models.js";import{ANT_LING_CLASSIFIER_MODELS as I,ANT_LING_IMAGE_MODELS as S,ANT_LING_MODELS as L}from"./providers/ant-ling.models.js";import{ANTHROPIC_CLASSIFIER_MODELS as o,ANTHROPIC_IMAGE_MODELS as A,ANTHROPIC_MODELS as M}from"./providers/anthropic.models.js";import{AZURE_CLASSIFIER_MODELS as D,AZURE_IMAGE_MODELS as i,AZURE_MODELS as e}from"./providers/azure.models.js";import{BASETEN_CLASSIFIER_MODELS as r,BASETEN_IMAGE_MODELS as a,BASETEN_MODELS as n}from"./providers/baseten.models.js";import{CEREBRAS_CLASSIFIER_MODELS as N,CEREBRAS_IMAGE_MODELS as m,CEREBRAS_MODELS as t}from"./providers/cerebras.models.js";import{CLOUDFLARE_AI_GATEWAY_CLASSIFIER_MODELS as C,CLOUDFLARE_AI_GATEWAY_IMAGE_MODELS as R,CLOUDFLARE_AI_GATEWAY_MODELS as p}from"./providers/cloudflare-ai-gateway.models.js";import{CLOUDFLARE_WORKERS_AI_CLASSIFIER_MODELS as G,CLOUDFLARE_WORKERS_AI_IMAGE_MODELS as T,CLOUDFLARE_WORKERS_AI_MODELS as c}from"./providers/cloudflare-workers-ai.models.js";import{DEEPSEEK_CLASSIFIER_MODELS as F,DEEPSEEK_IMAGE_MODELS as f,DEEPSEEK_MODELS as l}from"./providers/deepseek.models.js";import{FIREWORKS_CLASSIFIER_MODELS as g,FIREWORKS_IMAGE_MODELS as P,FIREWORKS_MODELS as d}from"./providers/fireworks.models.js";import{GITHUB_COPILOT_CLASSIFIER_MODELS as s,GITHUB_COPILOT_IMAGE_MODELS as k,GITHUB_COPILOT_MODELS as K}from"./providers/github-copilot.models.js";import{GOOGLE_CLASSIFIER_MODELS as x,GOOGLE_IMAGE_MODELS as u,GOOGLE_MODELS as U}from"./providers/google.models.js";import{GOOGLE_VERTEX_CLASSIFIER_MODELS as X,GOOGLE_VERTEX_IMAGE_MODELS as w,GOOGLE_VERTEX_MODELS as W}from"./providers/google-vertex.models.js";import{GROQ_CLASSIFIER_MODELS as h,GROQ_IMAGE_MODELS as H,GROQ_MODELS as q}from"./providers/groq.models.js";import{HUGGINGFACE_CLASSIFIER_MODELS as v,HUGGINGFACE_IMAGE_MODELS as Q,HUGGINGFACE_MODELS as V}from"./providers/huggingface.models.js";import{KIMI_CODING_CLASSIFIER_MODELS as b,KIMI_CODING_IMAGE_MODELS as z,KIMI_CODING_MODELS as B}from"./providers/kimi-coding.models.js";import{META_CLASSIFIER_MODELS as Z,META_IMAGE_MODELS as y,META_MODELS as Y}from"./providers/meta.models.js";import{MINIMAX_CLASSIFIER_MODELS as j,MINIMAX_IMAGE_MODELS as J,MINIMAX_MODELS as $}from"./providers/minimax.models.js";import{MINIMAX_CN_CLASSIFIER_MODELS as EE,MINIMAX_CN_IMAGE_MODELS as _E,MINIMAX_CN_MODELS as OE}from"./providers/minimax-cn.models.js";import{MISTRAL_CLASSIFIER_MODELS as IE,MISTRAL_IMAGE_MODELS as SE,MISTRAL_MODELS as LE}from"./providers/mistral.models.js";import{MOONSHOTAI_CLASSIFIER_MODELS as oE,MOONSHOTAI_IMAGE_MODELS as AE,MOONSHOTAI_MODELS as ME}from"./providers/moonshotai.models.js";import{MOONSHOTAI_CN_CLASSIFIER_MODELS as DE,MOONSHOTAI_CN_IMAGE_MODELS as iE,MOONSHOTAI_CN_MODELS as eE}from"./providers/moonshotai-cn.models.js";import{NVIDIA_CLASSIFIER_MODELS as rE,NVIDIA_IMAGE_MODELS as aE,NVIDIA_MODELS as nE}from"./providers/nvidia.models.js";import{OPENAI_CLASSIFIER_MODELS as NE,OPENAI_IMAGE_MODELS as mE,OPENAI_MODELS as tE}from"./providers/openai.models.js";import{OPENAI_CODEX_CLASSIFIER_MODELS as CE,OPENAI_CODEX_IMAGE_MODELS as RE,OPENAI_CODEX_MODELS as pE}from"./providers/openai-codex.models.js";import{OPENCODE_CLASSIFIER_MODELS as GE,OPENCODE_IMAGE_MODELS as TE,OPENCODE_MODELS as cE}from"./providers/opencode.models.js";import{OPENCODE_GO_CLASSIFIER_MODELS as FE,OPENCODE_GO_IMAGE_MODELS as fE,OPENCODE_GO_MODELS as lE}from"./providers/opencode-go.models.js";import{OPENROUTER_CLASSIFIER_MODELS as gE,OPENROUTER_IMAGE_MODELS as PE,OPENROUTER_MODELS as dE}from"./providers/openrouter.models.js";import{QWEN_TOKEN_PLAN_CLASSIFIER_MODELS as sE,QWEN_TOKEN_PLAN_IMAGE_MODELS as kE,QWEN_TOKEN_PLAN_MODELS as KE}from"./providers/qwen-token-plan.models.js";import{QWEN_TOKEN_PLAN_CN_CLASSIFIER_MODELS as xE,QWEN_TOKEN_PLAN_CN_IMAGE_MODELS as uE,QWEN_TOKEN_PLAN_CN_MODELS as UE}from"./providers/qwen-token-plan-cn.models.js";import{QWEN_TOKEN_PLAN_INDIVIDUAL_CLASSIFIER_MODELS as XE,QWEN_TOKEN_PLAN_INDIVIDUAL_IMAGE_MODELS as wE,QWEN_TOKEN_PLAN_INDIVIDUAL_MODELS as WE}from"./providers/qwen-token-plan-individual.models.js";import{QWEN_TOKEN_PLAN_INDIVIDUAL_CN_CLASSIFIER_MODELS as hE,QWEN_TOKEN_PLAN_INDIVIDUAL_CN_IMAGE_MODELS as HE,QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS as qE}from"./providers/qwen-token-plan-individual-cn.models.js";import{RADIUS_CLASSIFIER_MODELS as vE,RADIUS_IMAGE_MODELS as QE,RADIUS_MODELS as VE}from"./providers/radius.models.js";import{TOGETHER_CLASSIFIER_MODELS as bE,TOGETHER_IMAGE_MODELS as zE,TOGETHER_MODELS as BE}from"./providers/together.models.js";import{TYPESAFE_CLASSIFIER_MODELS as ZE,TYPESAFE_IMAGE_MODELS as yE,TYPESAFE_MODELS as YE}from"./providers/typesafe.models.js";import{VERCEL_AI_GATEWAY_CLASSIFIER_MODELS as jE,VERCEL_AI_GATEWAY_IMAGE_MODELS as JE,VERCEL_AI_GATEWAY_MODELS as $E}from"./providers/vercel-ai-gateway.models.js";import{XAI_CLASSIFIER_MODELS as E_,XAI_IMAGE_MODELS as __,XAI_MODELS as O_}from"./providers/xai.models.js";import{XIAOMI_CLASSIFIER_MODELS as I_,XIAOMI_IMAGE_MODELS as S_,XIAOMI_MODELS as L_}from"./providers/xiaomi.models.js";import{XIAOMI_TOKEN_PLAN_AMS_CLASSIFIER_MODELS as o_,XIAOMI_TOKEN_PLAN_AMS_IMAGE_MODELS as A_,XIAOMI_TOKEN_PLAN_AMS_MODELS as M_}from"./providers/xiaomi-token-plan-ams.models.js";import{XIAOMI_TOKEN_PLAN_CN_CLASSIFIER_MODELS as D_,XIAOMI_TOKEN_PLAN_CN_IMAGE_MODELS as i_,XIAOMI_TOKEN_PLAN_CN_MODELS as e_}from"./providers/xiaomi-token-plan-cn.models.js";import{XIAOMI_TOKEN_PLAN_SGP_CLASSIFIER_MODELS as r_,XIAOMI_TOKEN_PLAN_SGP_IMAGE_MODELS as a_,XIAOMI_TOKEN_PLAN_SGP_MODELS as n_}from"./providers/xiaomi-token-plan-sgp.models.js";import{ZAI_CLASSIFIER_MODELS as N_,ZAI_IMAGE_MODELS as m_,ZAI_MODELS as t_}from"./providers/zai.models.js";import{ZAI_CODING_CN_CLASSIFIER_MODELS as C_,ZAI_CODING_CN_IMAGE_MODELS as R_,ZAI_CODING_CN_MODELS as p_}from"./providers/zai-coding-cn.models.js";const iO={"amazon-bedrock":O,"ant-ling":L,anthropic:M,azure:e,baseten:n,cerebras:t,"cloudflare-ai-gateway":p,"cloudflare-workers-ai":c,deepseek:l,fireworks:d,"github-copilot":K,google:U,"google-vertex":W,groq:q,huggingface:V,"kimi-coding":B,meta:Y,minimax:$,"minimax-cn":OE,mistral:LE,moonshotai:ME,"moonshotai-cn":eE,nvidia:nE,openai:tE,"openai-codex":pE,opencode:cE,"opencode-go":lE,openrouter:dE,"qwen-token-plan":KE,"qwen-token-plan-cn":UE,"qwen-token-plan-individual":WE,"qwen-token-plan-individual-cn":qE,radius:VE,together:BE,typesafe:YE,"vercel-ai-gateway":$E,xai:O_,xiaomi:L_,"xiaomi-token-plan-ams":M_,"xiaomi-token-plan-cn":e_,"xiaomi-token-plan-sgp":n_,zai:t_,"zai-coding-cn":p_},eO={"amazon-bedrock":_,"ant-ling":S,anthropic:A,azure:i,baseten:a,cerebras:m,"cloudflare-ai-gateway":R,"cloudflare-workers-ai":T,deepseek:f,fireworks:P,"github-copilot":k,google:u,"google-vertex":w,groq:H,huggingface:Q,"kimi-coding":z,meta:y,minimax:J,"minimax-cn":_E,mistral:SE,moonshotai:AE,"moonshotai-cn":iE,nvidia:aE,openai:mE,"openai-codex":RE,opencode:TE,"opencode-go":fE,openrouter:PE,"qwen-token-plan":kE,"qwen-token-plan-cn":uE,"qwen-token-plan-individual":wE,"qwen-token-plan-individual-cn":HE,radius:QE,together:zE,typesafe:yE,"vercel-ai-gateway":JE,xai:__,xiaomi:S_,"xiaomi-token-plan-ams":A_,"xiaomi-token-plan-cn":i_,"xiaomi-token-plan-sgp":a_,zai:m_,"zai-coding-cn":R_},rO={"amazon-bedrock":E,"ant-ling":I,anthropic:o,azure:D,baseten:r,cerebras:N,"cloudflare-ai-gateway":C,"cloudflare-workers-ai":G,deepseek:F,fireworks:g,"github-copilot":s,google:x,"google-vertex":X,groq:h,huggingface:v,"kimi-coding":b,meta:Z,minimax:j,"minimax-cn":EE,mistral:IE,moonshotai:oE,"moonshotai-cn":DE,nvidia:rE,openai:NE,"openai-codex":CE,opencode:GE,"opencode-go":FE,openrouter:gE,"qwen-token-plan":sE,"qwen-token-plan-cn":xE,"qwen-token-plan-individual":XE,"qwen-token-plan-individual-cn":hE,radius:vE,together:bE,typesafe:ZE,"vercel-ai-gateway":jE,xai:E_,xiaomi:I_,"xiaomi-token-plan-ams":o_,"xiaomi-token-plan-cn":D_,"xiaomi-token-plan-sgp":r_,zai:N_,"zai-coding-cn":C_};export{rO as CLASSIFIER_MODELS,eO as IMAGE_MODELS,iO as MODELS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var I=Object.defineProperty;var h=(o,e)=>I(o,"name",{value:e,configurable:!0});import{lazyStream as P}from"./api/lazy.js";import{defaultProviderAuthContext as L}from"./auth/context.js";import{InMemoryCredentialStore as _}from"./auth/credential-store.js";import{ModelsError as p,refreshStoredOAuthCredential as W,resolveProviderAuth as $}from"./auth/resolve.js";import{InMemoryModelsStore as N}from"./models-store.js";import{observeModelRequest as q}from"./telemetry.js";import{operationSignal as b,raceWithAbortSignal as A}from"./utils/abort.js";import{withFirstTokenTimeout as D}from"./utils/event-stream.js";import{getOpenCodeSessionHeaders as U,mergeClientIdentity as H}from"./utils/identity.js";import{assertChatModel as G,assertClassifierInputSupported as j,assertClassifierModel as z,assertImageModel as F,classifierErrorResult as E,getModelType as C,imageErrorResult as O,isModelType as k}from"./utils/model-operations.js";import{normalizeContext as R}from"./utils/transcript.js";import{ModelsError as me}from"./auth/resolve.js";import{AI_TELEMETRY_SCHEMA as ve}from"./telemetry.js";import{getModelType as be,isModelType as Ae}from"./utils/model-operations.js";const Y={chat:!0,image:!0,classifier:!0};function K(o){return Object.hasOwn(Y,C(o))}h(K,"hasKnownModelType");function V(o){return{...o,models:o.models.filter(K)}}h(V,"withKnownModelTypes");function x(o,e){if(!o&&!e)return;const r={...o};for(const[t,s]of Object.entries(e??{})){const i=t.toLowerCase();for(const a of Object.keys(r))a.toLowerCase()===i&&delete r[a];r[t]=s}return r}h(x,"mergeHeaders");class X{static{h(this,"ModelsImpl")}providers=new Map;credentials;modelsStore;authContext;identity;refreshGenerations=new Map;refreshControllers=new Map;publicationChains=new Map;constructor(e){this.credentials=e?.credentials??new _,this.modelsStore=e?.modelsStore??new N,this.authContext=e?.authContext??L(),this.identity=e?.identity}setProvider(e){this.supersedeProviderRefresh(e.id),this.providers.set(e.id,e)}deleteProvider(e){this.supersedeProviderRefresh(e),this.providers.delete(e)}clearProviders(){for(const e of new Set([...this.providers.keys(),...this.refreshControllers.keys()]))this.supersedeProviderRefresh(e);this.providers.clear()}getProviders(){return Array.from(this.providers.values())}getProvider(e){return this.providers.get(e)}getModels(e){if(e!==void 0){const t=this.providers.get(e);if(!t)return[];try{return t.getModels()}catch{return[]}}const r=[];for(const t of this.providers.values())try{r.push(...t.getModels())}catch{}return r}getAllModels(e){if(e!==void 0){const t=this.providers.get(e);if(!t)return[];try{return t.getAllModels?.()??t.getModels()}catch{return[]}}const r=[];for(const t of this.providers.values())try{r.push(...t.getAllModels?.()??t.getModels())}catch{}return r}getModelsOfType(e,r){return this.getAllModels(r).filter(t=>k(t,e))}getModel(e,r){return this.getModels(e).find(t=>t.id===r)}getModelOfType(e,r,t){return this.getModelsOfType(e,r).find(s=>s.id===t)}supersedeProviderRefresh(e){const r=(this.refreshGenerations.get(e)??0)+1;this.refreshGenerations.set(e,r);const t=this.refreshControllers.get(e);return t&&(this.refreshControllers.delete(e),t.abort()),r}beginProviderRefresh(e){const r=this.supersedeProviderRefresh(e),t=new AbortController;return this.refreshControllers.set(e,t),{generation:r,controller:t}}publishProviderModels(e,r,t,s){const i=this.publicationChains.get(e)??Promise.resolve(),a=(async()=>(await i.catch(()=>{}),t.aborted||this.refreshGenerations.get(e)!==r||(s.persist===null?await this.modelsStore.delete(e,{signal:t}):s.persist!==void 0&&await this.modelsStore.write(e,structuredClone(s.persist),{signal:t}),t.aborted||this.refreshGenerations.get(e)!==r)?!1:(s.update?.(),!0)))(),d=a.catch(()=>{});return this.publicationChains.set(e,d),d.then(()=>{this.publicationChains.get(e)===d&&this.publicationChains.delete(e)}),A(a,t)}async runProviderRefreshPhase(e,r,t,s,i,a){const d=await this.modelsStore.read(e.id,{signal:a});await e.refreshModels({credential:r,stored:d?V(structuredClone(d)):void 0,publish:h(c=>this.publishProviderModels(e.id,i,a,c),"publish"),allowNetwork:t,force:t?s:void 0,signal:a,baseUrl:e.baseUrl})}async refresh(e={}){const r=e.allowNetwork??!0,t=b(e.signal),s=new Map;if(t.aborted)return{aborted:!0,errors:s};const i=e.providers?new Set(e.providers):void 0,a=Array.from(this.providers.values()).filter(c=>c.refreshModels!==void 0&&(!i||i.has(c.id))),d=Promise.all(a.map(async c=>{const{generation:v,controller:y}=this.beginProviderRefresh(c.id),g=AbortSignal.any([t,y.signal]),M=(async()=>{let m,w;try{m=await this.readCredential(c.id,g)}catch(l){w=l}if(await this.runProviderRefreshPhase(c,m,!1,void 0,v,g),w!==void 0)throw w;if(!r||g.aborted)return;const n=await this.resolveRefreshCredential(c,m,g);n&&await this.runProviderRefreshPhase(c,n,!0,e.force,v,g)})();try{await A(M,g)}catch(m){g.aborted||s.set(c.id,m instanceof Error?m:new p("model_source",`Model refresh failed for ${c.id}`,{cause:m}))}finally{this.refreshControllers.get(c.id)===y&&this.refreshControllers.delete(c.id)}}));try{await A(d,t)}catch(c){if(!t.aborted)throw c}return{aborted:t.aborted,errors:new Map(s)}}async resolveRefreshCredential(e,r,t){if(r?.type==="oauth"){const d=e.auth.oauth;return d?Date.now()<r.expires?r:t.aborted?void 0:W(this.credentials,e.id,d,c=>Date.now()>=c.expires,t):void 0}const s=e.auth.apiKey;if(!s)return;const i=r?.type==="api_key"?r:void 0,a=await s.resolve({ctx:this.authContext,credential:i,signal:t});if(a)return{type:"api_key",key:a.auth.apiKey,env:a.env}}async readCredential(e,r){try{return await this.credentials.read(e,{signal:r})}catch(t){throw new p("auth",`Credential store read failed for ${e}`,{cause:t})}}async checkProviderAuth(e,r,t){if(r?.type==="oauth")return e.auth.oauth?{source:"OAuth",type:"oauth"}:void 0;const s=e.auth.apiKey;if(!s)return;if(s.check)try{return await s.check({ctx:this.authContext,credential:r?.type==="api_key"?r:void 0,signal:t})}catch(a){throw new p("auth",`API key auth check failed for provider ${e.id}`,{cause:a})}const i=await $(e,this.credentials,this.authContext,{signal:t});return i?{source:i.source,type:"api_key"}:void 0}checkAuth(e,r){const t=b(r?.signal),s=(async()=>{t.throwIfAborted();const i=this.providers.get(e);if(i)return this.checkProviderAuth(i,await this.readCredential(e,t),t)})();return A(s,t)}async getAuthenticatedProviders(e,r){r.throwIfAborted();const t=e?[this.providers.get(e)].filter(i=>i!==void 0):this.getProviders();return(await Promise.all(t.map(async i=>{const a=await this.readCredential(i.id,r);return{provider:i,credential:a,auth:await this.checkProviderAuth(i,a,r)}}))).filter(i=>i.auth!==void 0)}getAvailable(e,r){const t=b(r?.signal),s=(async()=>(await this.getAuthenticatedProviders(e,t)).flatMap(({provider:a,credential:d})=>{const c=a.getModels();return a.filterModels?.(c,d)??c}))();return A(s,t)}async getAvailableOfType(e,r,t){return(await this.getAllAvailable(r,t)).filter(s=>k(s,e))}getAllAvailable(e,r){const t=b(r?.signal),s=(async()=>(await this.getAuthenticatedProviders(e,t)).flatMap(({provider:a,credential:d})=>{const c=a.getAllModels?.()??a.getModels();if(a.filterAllModels)return a.filterAllModels(c,d);if(!a.filterModels)return c;const v=new Set(a.filterModels(a.getModels(),d).map(y=>y.id));return c.filter(y=>!k(y,"chat")||v.has(y.id))}))();return A(s,t)}async getAuth(e,r){const t=b(r?.signal),s=typeof e=="string"?e:e.provider,i=this.providers.get(s);if(!i)return;const a=await $(i,this.credentials,this.authContext,{...r,signal:t});return!a||typeof e=="string"||!e.headers?a:{...a,auth:{...a.auth,headers:x(a.auth.headers,e.headers)}}}async login(e,r,t,s){const i=b(t.signal);i.throwIfAborted();const a=this.providers.get(e);if(!a)throw new p("provider",`Unknown provider: ${e}`);const d=r==="oauth"?a.auth.oauth:a.auth.apiKey;if(!d?.login)throw new p("auth",`${a.name} does not support ${r} login`);const c=d.login({...t,signal:i},s),v=await A(c,i);let y=!1,g;const M=new Promise(w=>{g=w}),m=this.credentials.modify(e,async()=>(y=!0,g?.(),v),{signal:i});m.catch(()=>{});try{await new Promise((w,n)=>{const l=h(()=>{y||n(i.reason)},"onAbort");i.addEventListener("abort",l,{once:!0}),Promise.race([M,m]).then(()=>{i.removeEventListener("abort",l),w()},f=>{i.removeEventListener("abort",l),n(f)}),i.aborted&&l()}),await m}catch(w){throw i.throwIfAborted(),new p("auth",`Credential store modify failed for ${e}`,{cause:w})}return v}async logout(e,r){const t=b(r?.signal);t.throwIfAborted();try{await this.credentials.delete(e,{signal:t})}catch(s){throw t.throwIfAborted(),new p("auth",`Credential store delete failed for ${e}`,{cause:s})}}requireProvider(e){const r=this.providers.get(e.provider);if(!r)throw new p("provider",`Unknown provider: ${e.provider}`);return r}requireChatProvider(e){return G(e),this.requireProvider(e)}async applyAuth(e,r){this.requireProvider(e);const t=await this.getAuth(e,{apiKey:r?.apiKey,env:r?.env,signal:r?.signal});if(!t)throw new p("auth",`Provider is not configured: ${e.provider}`);const s=t.auth,i=r?.apiKey??s.apiKey,a=s.baseUrl?{...e,baseUrl:s.baseUrl}:e,d=r&&"sessionId"in r&&typeof r.sessionId=="string"?r.sessionId:void 0;let c=x(x(U(a,d),s.headers),r?.headers);r?.transformHeaders&&(c=await r.transformHeaders(c??{}));const v=t.env||r?.env?{...t.env??{},...r?.env??{}}:void 0,y=H(this.identity,r?.identity),{transformHeaders:g,firstTokenTimeoutMs:M,...m}=r??{},w={...m,apiKey:i,headers:c,env:v,...y===void 0?{}:{identity:y}};return{requestModel:a,requestOptions:w}}stream(e,r,t){const s=R(r);return D(t,t?.firstTokenTimeoutMs,i=>P(e,async()=>{const a=this.requireChatProvider(e),{requestModel:d,requestOptions:c}=await this.applyAuth(e,i);return a.stream(d,s,c)},q(e,t,!1)))}async complete(e,r,t){return this.stream(e,r,t).result()}streamSimple(e,r,t){const s=R(r);return D(t,t?.firstTokenTimeoutMs,i=>P(e,async()=>{const a=this.requireChatProvider(e),{requestModel:d,requestOptions:c}=await this.applyAuth(e,i);return a.streamSimple(d,s,c)},q(e,t,!1)))}async completeSimple(e,r,t){return this.streamSimple(e,r,t).result()}streamDeferred(e,r,t){return P(e,async()=>{const s=this.requireChatProvider(e);if(!s.fetchDeferred)throw new p("provider",`Provider ${e.provider} does not support deferred responses`);const{requestModel:i,requestOptions:a}=await this.applyAuth(e,t);return s.fetchDeferred(i,r,a)},q(e,t,!0))}async fetchDeferred(e,r,t){return this.streamDeferred(e,r,t).result()}async cancelDeferred(e,r,t){const s=this.requireChatProvider(e);if(!s.cancelDeferred)throw new p("provider",`Provider ${e.provider} does not support deferred responses`);const{requestModel:i,requestOptions:a}=await this.applyAuth(e,t);await s.cancelDeferred(i,r,a)}async generateImages(e,r,t){try{F(e);const s=this.requireProvider(e);if(!s.generateImages)throw new p("provider",`Provider ${e.provider} does not support image generation`);const{requestModel:i,requestOptions:a}=await this.applyAuth(e,t);return await s.generateImages(i,r,a)}catch(s){return O(e,s,t?.signal?.aborted)}}async classify(e,r,t){try{z(e),j(e,r);const s=this.requireProvider(e);if(!s.classify)throw new p("provider",`Provider ${e.provider} does not support classification`);const{requestModel:i,requestOptions:a}=await this.applyAuth(e,t);return await s.classify(i,r,a)}catch(s){return E(e,s,t?.signal?.aborted)}}}function de(o){return new X(o)}h(de,"createModels");function le(o){const e=o.api&&typeof o.api.stream=="function"?o.api:void 0,r=e||!o.api?void 0:o.api,t=o.images,s=o.classifiers,i=e?[e]:Object.values(r??{}).filter(n=>n!==void 0),a=Object.values(t??{}).filter(n=>n!==void 0),d=Object.values(s??{}).filter(n=>n!==void 0);if(i.length===0&&a.length===0&&d.length===0)throw new Error(`Provider ${o.id}: at least one of "api", "images", or "classifiers" is required.`);const c=o.models;let v=[];const y=o.fetchModels,g=h(()=>{const n=[...c];for(const l of v){const f=n.findIndex(u=>C(u)===C(l)&&u.id===l.id);f>=0?n[f]=l:n.push(l)}return n},"currentModels"),M=h(n=>e??r?.[n.api],"apiFor"),m=h((n,l)=>{const f=M(n);return f?l(f):P(n,async()=>{throw new p("stream",`Provider ${o.id} has no API implementation for "${n.api}"`)})},"dispatch"),w={id:o.id,name:o.name??o.id,baseUrl:o.baseUrl,headers:o.headers,auth:o.auth,getModels:h(()=>g().filter(n=>k(n,"chat")),"getModels"),getAllModels:g,refreshModels:y?async n=>{if(n.stored){const u=n.stored.models.filter(S=>S.provider===o.id).map(S=>S);if(!await n.publish({update:h(()=>{v=u},"update")}))return}if(!n.allowNetwork||n.signal.aborted)return;const l=await y(n);if(n.signal.aborted)return;const f=l.filter(K);await n.publish({persist:{models:f,checkedAt:Date.now()},update:h(()=>{v=f},"update")})}:void 0,filterModels:o.filterModels,supportsApi:h(n=>r?r[n]!==void 0:g().some(l=>l.api===n),"supportsApi"),filterAllModels:o.filterAllModels,stream:h((n,l,f)=>m(n,u=>u.stream(n,l,f)),"stream"),streamSimple:h((n,l,f)=>m(n,u=>u.streamSimple(n,l,f)),"streamSimple")};return i.some(n=>n.fetchDeferred!==void 0)&&(w.fetchDeferred=(n,l,f)=>P(n,async()=>{const u=M(n);if(!u?.fetchDeferred)throw new p("provider",`Provider ${o.id} does not support deferred responses for "${n.api}"`);return u.fetchDeferred(n,l,f)})),i.some(n=>n.cancelDeferred!==void 0)&&(w.cancelDeferred=async(n,l,f)=>{const u=M(n);if(!u?.cancelDeferred)throw new p("provider",`Provider ${o.id} cannot cancel deferred responses for "${n.api}"`);await u.cancelDeferred(n,l,f)}),t&&a.length>0&&(w.generateImages=async(n,l,f)=>{const u=t[n.api];return u?u.generateImages(n,l,f):O(n,new p("provider",`Provider ${o.id} has no image generation implementation for "${n.api}"`))}),s&&d.length>0&&(w.classify=async(n,l,f)=>{const u=s[n.api];return u?u.classify(n,l,f):E(n,new p("provider",`Provider ${o.id} has no classifier implementation for "${n.api}"`))}),w}h(le,"createProvider");function he(o,e){return k(o,"chat")&&o.api===e}h(he,"hasApi");function fe(o,e){const r=e.input+e.cacheRead+e.cacheWrite;let t=o.cost,s=-1;for(const d of o.cost.tiers??[])r>d.inputTokensAbove&&d.inputTokensAbove>s&&(t=d,s=d.inputTokensAbove);const i=e.cacheWrite1h??0,a=e.cacheWrite-i;return e.cost.input=t.input/1e6*e.input,e.cost.output=t.output/1e6*e.output,e.cost.cacheRead=t.cacheRead/1e6*e.cacheRead,e.cost.cacheWrite=(t.cacheWrite*a+t.input*2*i)/1e6,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite,e.cost}h(fe,"calculateCost");const T=["off","minimal","low","medium","high","xhigh","max"];function B(o){return o.reasoning?T.filter(e=>{const r=o.thinkingLevelMap?.[e];return r===null?!1:e==="xhigh"||e==="max"?r!==void 0:!0}):["off"]}h(B,"getSupportedThinkingLevels");function ue(o,e){const r=B(o);if(r.includes(e))return e;const t=T.indexOf(e);if(t===-1)return r[0]??"off";for(let s=t;s<T.length;s++){const i=T[s];if(r.includes(i))return i}for(let s=t-1;s>=0;s--){const i=T[s];if(r.includes(i))return i}return r[0]??"off"}h(ue,"clampThinkingLevel");function pe(o,e){return!o||!e?!1:C(o)===C(e)&&o.id===e.id&&o.provider===e.provider}h(pe,"modelsAreEqual");export{ve as AI_TELEMETRY_SCHEMA,me as ModelsError,fe as calculateCost,ue as clampThinkingLevel,de as createModels,le as createProvider,be as getModelType,B as getSupportedThinkingLevels,he as hasApi,Ae as isModelType,pe as modelsAreEqual};
|
|
1
|
+
var I=Object.defineProperty;var u=(o,e)=>I(o,"name",{value:e,configurable:!0});import{lazyStream as P}from"./api/lazy.js";import{defaultProviderAuthContext as L}from"./auth/context.js";import{InMemoryCredentialStore as _}from"./auth/credential-store.js";import{ModelsError as p,refreshStoredOAuthCredential as N,resolveProviderAuth as $}from"./auth/resolve.js";import{InMemoryModelsStore as W}from"./models-store.js";import{observeModelRequest as q}from"./telemetry.js";import{operationSignal as A,raceWithAbortSignal as b}from"./utils/abort.js";import{withFirstTokenTimeout as R}from"./utils/event-stream.js";import{getOpenCodeSessionHeaders as U,mergeClientIdentity as H}from"./utils/identity.js";import{assertChatModel as G,assertClassifierInputSupported as j,assertClassifierModel as F,assertImageModel as z,classifierErrorResult as D,getModelType as C,imageErrorResult as E,isModelType as k}from"./utils/model-operations.js";import{normalizeContext as O}from"./utils/transcript.js";import{ModelsError as me}from"./auth/resolve.js";import{AI_TELEMETRY_SCHEMA as ve}from"./telemetry.js";import{getModelType as Ae,isModelType as be}from"./utils/model-operations.js";const Y={chat:!0,image:!0,classifier:!0};function K(o){return Object.hasOwn(Y,C(o))}u(K,"hasKnownModelType");function V(o){return{...o,models:o.models.filter(K)}}u(V,"withKnownModelTypes");function x(o,e){if(!o&&!e)return;const r={...o};for(const[t,s]of Object.entries(e??{})){const i=t.toLowerCase();for(const a of Object.keys(r))a.toLowerCase()===i&&delete r[a];r[t]=s}return r}u(x,"mergeHeaders");class X{static{u(this,"ModelsImpl")}providers=new Map;credentials;modelsStore;authContext;identity;refreshGenerations=new Map;refreshControllers=new Map;publicationChains=new Map;constructor(e){this.credentials=e?.credentials??new _,this.modelsStore=e?.modelsStore??new W,this.authContext=e?.authContext??L(),this.identity=e?.identity}setProvider(e){this.supersedeProviderRefresh(e.id),this.providers.set(e.id,e)}deleteProvider(e){this.supersedeProviderRefresh(e),this.providers.delete(e)}clearProviders(){for(const e of new Set([...this.providers.keys(),...this.refreshControllers.keys()]))this.supersedeProviderRefresh(e);this.providers.clear()}getProviders(){return Array.from(this.providers.values())}getProvider(e){return this.providers.get(e)}getModels(e){if(e!==void 0){const t=this.providers.get(e);if(!t)return[];try{return t.getModels()}catch{return[]}}const r=[];for(const t of this.providers.values())try{r.push(...t.getModels())}catch{}return r}getAllModels(e){if(e!==void 0){const t=this.providers.get(e);if(!t)return[];try{return t.getAllModels?.()??t.getModels()}catch{return[]}}const r=[];for(const t of this.providers.values())try{r.push(...t.getAllModels?.()??t.getModels())}catch{}return r}getModelsOfType(e,r){return this.getAllModels(r).filter(t=>k(t,e))}getModel(e,r){return this.getModels(e).find(t=>t.id===r)}getModelOfType(e,r,t){return this.getModelsOfType(e,r).find(s=>s.id===t)}supersedeProviderRefresh(e){const r=(this.refreshGenerations.get(e)??0)+1;this.refreshGenerations.set(e,r);const t=this.refreshControllers.get(e);return t&&(this.refreshControllers.delete(e),t.abort()),r}beginProviderRefresh(e){const r=this.supersedeProviderRefresh(e),t=new AbortController;return this.refreshControllers.set(e,t),{generation:r,controller:t}}publishProviderModels(e,r,t,s){const i=this.publicationChains.get(e)??Promise.resolve(),a=(async()=>(await i.catch(()=>{}),t.aborted||this.refreshGenerations.get(e)!==r||(s.persist===null?await this.modelsStore.delete(e,{signal:t}):s.persist!==void 0&&await this.modelsStore.write(e,structuredClone(s.persist),{signal:t}),t.aborted||this.refreshGenerations.get(e)!==r)?!1:(s.update?.(),!0)))(),d=a.catch(()=>{});return this.publicationChains.set(e,d),d.then(()=>{this.publicationChains.get(e)===d&&this.publicationChains.delete(e)}),b(a,t)}async runProviderRefreshPhase(e,r,t,s,i,a){const d=await this.modelsStore.read(e.id,{signal:a});await e.refreshModels({credential:r,stored:d?V(structuredClone(d)):void 0,publish:u(c=>this.publishProviderModels(e.id,i,a,c),"publish"),allowNetwork:t,force:t?s:void 0,signal:a,baseUrl:e.baseUrl})}async refresh(e={}){const r=e.allowNetwork??!0,t=A(e.signal),s=new Map;if(t.aborted)return{aborted:!0,errors:s};const i=e.providers?new Set(e.providers):void 0,a=Array.from(this.providers.values()).filter(c=>c.refreshModels!==void 0&&(!i||i.has(c.id))),d=Promise.all(a.map(async c=>{const{generation:v,controller:y}=this.beginProviderRefresh(c.id),g=AbortSignal.any([t,y.signal]),M=(async()=>{let m,w;try{m=await this.readCredential(c.id,g)}catch(l){w=l}if(await this.runProviderRefreshPhase(c,m,!1,void 0,v,g),w!==void 0)throw w;if(!r||g.aborted)return;const n=await this.resolveNetworkRefresh(c,m,g);n&&await this.runProviderRefreshPhase(c,n.credential,!0,e.force,v,g)})();try{await b(M,g)}catch(m){g.aborted||s.set(c.id,m instanceof Error?m:new p("model_source",`Model refresh failed for ${c.id}`,{cause:m}))}finally{this.refreshControllers.get(c.id)===y&&this.refreshControllers.delete(c.id)}}));try{await b(d,t)}catch(c){if(!t.aborted)throw c}return{aborted:t.aborted,errors:new Map(s)}}async resolveNetworkRefresh(e,r,t){if(e.refreshModelsAuth==="configured")return await this.checkProviderAuth(e,r,t)?{}:void 0;const s=await this.resolveRefreshCredential(e,r,t);return s?{credential:s}:void 0}async resolveRefreshCredential(e,r,t){if(r?.type==="oauth"){const d=e.auth.oauth;return d?Date.now()<r.expires?r:t.aborted?void 0:N(this.credentials,e.id,d,c=>Date.now()>=c.expires,t):void 0}const s=e.auth.apiKey;if(!s)return;const i=r?.type==="api_key"?r:void 0,a=await s.resolve({ctx:this.authContext,credential:i,signal:t});if(a)return{type:"api_key",key:a.auth.apiKey,env:a.env}}async readCredential(e,r){try{return await this.credentials.read(e,{signal:r})}catch(t){throw new p("auth",`Credential store read failed for ${e}`,{cause:t})}}async checkProviderAuth(e,r,t){if(r?.type==="oauth")return e.auth.oauth?{source:"OAuth",type:"oauth"}:void 0;const s=e.auth.apiKey;if(!s)return;if(s.check)try{return await s.check({ctx:this.authContext,credential:r?.type==="api_key"?r:void 0,signal:t})}catch(a){throw new p("auth",`API key auth check failed for provider ${e.id}`,{cause:a})}const i=await $(e,this.credentials,this.authContext,{signal:t});return i?{source:i.source,type:"api_key"}:void 0}checkAuth(e,r){const t=A(r?.signal),s=(async()=>{t.throwIfAborted();const i=this.providers.get(e);if(i)return this.checkProviderAuth(i,await this.readCredential(e,t),t)})();return b(s,t)}async getAuthenticatedProviders(e,r){r.throwIfAborted();const t=e?[this.providers.get(e)].filter(i=>i!==void 0):this.getProviders();return(await Promise.all(t.map(async i=>{const a=await this.readCredential(i.id,r);return{provider:i,credential:a,auth:await this.checkProviderAuth(i,a,r)}}))).filter(i=>i.auth!==void 0)}getAvailable(e,r){const t=A(r?.signal),s=(async()=>(await this.getAuthenticatedProviders(e,t)).flatMap(({provider:a,credential:d})=>{const c=a.getModels();return a.filterModels?.(c,d)??c}))();return b(s,t)}async getAvailableOfType(e,r,t){return(await this.getAllAvailable(r,t)).filter(s=>k(s,e))}getAllAvailable(e,r){const t=A(r?.signal),s=(async()=>(await this.getAuthenticatedProviders(e,t)).flatMap(({provider:a,credential:d})=>{const c=a.getAllModels?.()??a.getModels();if(a.filterAllModels)return a.filterAllModels(c,d);if(!a.filterModels)return c;const v=new Set(a.filterModels(a.getModels(),d).map(y=>y.id));return c.filter(y=>!k(y,"chat")||v.has(y.id))}))();return b(s,t)}async getAuth(e,r){const t=A(r?.signal),s=typeof e=="string"?e:e.provider,i=this.providers.get(s);if(!i)return;const a=await $(i,this.credentials,this.authContext,{...r,signal:t});return!a||typeof e=="string"||!e.headers?a:{...a,auth:{...a.auth,headers:x(a.auth.headers,e.headers)}}}async login(e,r,t,s){const i=A(t.signal);i.throwIfAborted();const a=this.providers.get(e);if(!a)throw new p("provider",`Unknown provider: ${e}`);const d=r==="oauth"?a.auth.oauth:a.auth.apiKey;if(!d?.login)throw new p("auth",`${a.name} does not support ${r} login`);const c=d.login({...t,signal:i},s),v=await b(c,i);let y=!1,g;const M=new Promise(w=>{g=w}),m=this.credentials.modify(e,async()=>(y=!0,g?.(),v),{signal:i});m.catch(()=>{});try{await new Promise((w,n)=>{const l=u(()=>{y||n(i.reason)},"onAbort");i.addEventListener("abort",l,{once:!0}),Promise.race([M,m]).then(()=>{i.removeEventListener("abort",l),w()},h=>{i.removeEventListener("abort",l),n(h)}),i.aborted&&l()}),await m}catch(w){throw i.throwIfAborted(),new p("auth",`Credential store modify failed for ${e}`,{cause:w})}return v}async logout(e,r){const t=A(r?.signal);t.throwIfAborted();try{await this.credentials.delete(e,{signal:t})}catch(s){throw t.throwIfAborted(),new p("auth",`Credential store delete failed for ${e}`,{cause:s})}}requireProvider(e){const r=this.providers.get(e.provider);if(!r)throw new p("provider",`Unknown provider: ${e.provider}`);return r}requireChatProvider(e){return G(e),this.requireProvider(e)}async applyAuth(e,r){this.requireProvider(e);const t=await this.getAuth(e,{apiKey:r?.apiKey,env:r?.env,signal:r?.signal});if(!t)throw new p("auth",`Provider is not configured: ${e.provider}`);const s=t.auth,i=r?.apiKey??s.apiKey,a=s.baseUrl?{...e,baseUrl:s.baseUrl}:e,d=r&&"sessionId"in r&&typeof r.sessionId=="string"?r.sessionId:void 0;let c=x(x(U(a,d),s.headers),r?.headers);r?.transformHeaders&&(c=await r.transformHeaders(c??{}));const v=t.env||r?.env?{...t.env??{},...r?.env??{}}:void 0,y=H(this.identity,r?.identity),{transformHeaders:g,firstTokenTimeoutMs:M,...m}=r??{},w={...m,apiKey:i,headers:c,env:v,...y===void 0?{}:{identity:y}};return{requestModel:a,requestOptions:w}}stream(e,r,t){const s=O(r);return R(t,t?.firstTokenTimeoutMs,i=>P(e,async()=>{const a=this.requireChatProvider(e),{requestModel:d,requestOptions:c}=await this.applyAuth(e,i);return a.stream(d,s,c)},q(e,t,!1),i?.signal))}async complete(e,r,t){return this.stream(e,r,t).result()}streamSimple(e,r,t){const s=O(r);return R(t,t?.firstTokenTimeoutMs,i=>P(e,async()=>{const a=this.requireChatProvider(e),{requestModel:d,requestOptions:c}=await this.applyAuth(e,i);return a.streamSimple(d,s,c)},q(e,t,!1),i?.signal))}async completeSimple(e,r,t){return this.streamSimple(e,r,t).result()}streamDeferred(e,r,t){return P(e,async()=>{const s=this.requireChatProvider(e);if(!s.fetchDeferred)throw new p("provider",`Provider ${e.provider} does not support deferred responses`);const{requestModel:i,requestOptions:a}=await this.applyAuth(e,t);return s.fetchDeferred(i,r,a)},q(e,t,!0),t?.signal)}async fetchDeferred(e,r,t){return this.streamDeferred(e,r,t).result()}async cancelDeferred(e,r,t){const s=this.requireChatProvider(e);if(!s.cancelDeferred)throw new p("provider",`Provider ${e.provider} does not support deferred responses`);const{requestModel:i,requestOptions:a}=await this.applyAuth(e,t);await s.cancelDeferred(i,r,a)}async generateImages(e,r,t){try{z(e);const s=this.requireProvider(e);if(!s.generateImages)throw new p("provider",`Provider ${e.provider} does not support image generation`);const{requestModel:i,requestOptions:a}=await this.applyAuth(e,t);return await s.generateImages(i,r,a)}catch(s){return E(e,s,t?.signal?.aborted)}}async classify(e,r,t){try{F(e),j(e,r);const s=this.requireProvider(e);if(!s.classify)throw new p("provider",`Provider ${e.provider} does not support classification`);const{requestModel:i,requestOptions:a}=await this.applyAuth(e,t);return await s.classify(i,r,a)}catch(s){return D(e,s,t?.signal?.aborted)}}}function de(o){return new X(o)}u(de,"createModels");function le(o){const e=o.api&&typeof o.api.stream=="function"?o.api:void 0,r=e||!o.api?void 0:o.api,t=o.images,s=o.classifiers,i=e?[e]:Object.values(r??{}).filter(n=>n!==void 0),a=Object.values(t??{}).filter(n=>n!==void 0),d=Object.values(s??{}).filter(n=>n!==void 0);if(i.length===0&&a.length===0&&d.length===0)throw new Error(`Provider ${o.id}: at least one of "api", "images", or "classifiers" is required.`);const c=o.models;let v=[];const y=o.fetchModels,g=u(()=>{const n=[...c];for(const l of v){const h=n.findIndex(f=>C(f)===C(l)&&f.id===l.id);h>=0?n[h]=l:n.push(l)}return n},"currentModels"),M=u(n=>e??r?.[n.api],"apiFor"),m=u((n,l,h)=>{const f=M(n);return f?l(f):P(n,async()=>{throw new p("stream",`Provider ${o.id} has no API implementation for "${n.api}"`)},void 0,h)},"dispatch"),w={id:o.id,name:o.name??o.id,baseUrl:o.baseUrl,headers:o.headers,auth:o.auth,getModels:u(()=>g().filter(n=>k(n,"chat")),"getModels"),getAllModels:g,refreshModels:y?async n=>{if(n.stored){const f=n.stored.models.filter(S=>S.provider===o.id).map(S=>S);if(!await n.publish({update:u(()=>{v=f},"update")}))return}if(!n.allowNetwork||n.signal.aborted)return;const l=await y(n);if(n.signal.aborted)return;const h=l.filter(K);await n.publish({persist:{models:h,checkedAt:Date.now()},update:u(()=>{v=h},"update")})}:void 0,filterModels:o.filterModels,supportsApi:u(n=>r?r[n]!==void 0:g().some(l=>l.api===n),"supportsApi"),filterAllModels:o.filterAllModels,stream:u((n,l,h)=>m(n,f=>f.stream(n,l,h),h?.signal),"stream"),streamSimple:u((n,l,h)=>m(n,f=>f.streamSimple(n,l,h),h?.signal),"streamSimple")};return i.some(n=>n.fetchDeferred!==void 0)&&(w.fetchDeferred=(n,l,h)=>P(n,async()=>{const f=M(n);if(!f?.fetchDeferred)throw new p("provider",`Provider ${o.id} does not support deferred responses for "${n.api}"`);return f.fetchDeferred(n,l,h)},void 0,h?.signal)),i.some(n=>n.cancelDeferred!==void 0)&&(w.cancelDeferred=async(n,l,h)=>{const f=M(n);if(!f?.cancelDeferred)throw new p("provider",`Provider ${o.id} cannot cancel deferred responses for "${n.api}"`);await f.cancelDeferred(n,l,h)}),t&&a.length>0&&(w.generateImages=async(n,l,h)=>{const f=t[n.api];return f?f.generateImages(n,l,h):E(n,new p("provider",`Provider ${o.id} has no image generation implementation for "${n.api}"`))}),s&&d.length>0&&(w.classify=async(n,l,h)=>{const f=s[n.api];return f?f.classify(n,l,h):D(n,new p("provider",`Provider ${o.id} has no classifier implementation for "${n.api}"`))}),w}u(le,"createProvider");function he(o,e){return k(o,"chat")&&o.api===e}u(he,"hasApi");function fe(o,e){const r=e.input+e.cacheRead+e.cacheWrite;let t=o.cost,s=-1;for(const d of o.cost.tiers??[])r>d.inputTokensAbove&&d.inputTokensAbove>s&&(t=d,s=d.inputTokensAbove);const i=e.cacheWrite1h??0,a=e.cacheWrite-i;return e.cost.input=t.input/1e6*e.input,e.cost.output=t.output/1e6*e.output,e.cost.cacheRead=t.cacheRead/1e6*e.cacheRead,e.cost.cacheWrite=(t.cacheWrite*a+t.input*2*i)/1e6,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite,e.cost.totalFromProvider=!1,e.cost}u(fe,"calculateCost");const T=["off","minimal","low","medium","high","xhigh","max"];function B(o){return o.reasoning?T.filter(e=>{const r=o.thinkingLevelMap?.[e];return r===null?!1:e==="xhigh"||e==="max"?r!==void 0:!0}):["off"]}u(B,"getSupportedThinkingLevels");function ue(o,e){const r=B(o);if(r.includes(e))return e;const t=T.indexOf(e);if(t===-1)return r[0]??"off";for(let s=t;s<T.length;s++){const i=T[s];if(r.includes(i))return i}for(let s=t-1;s>=0;s--){const i=T[s];if(r.includes(i))return i}return r[0]??"off"}u(ue,"clampThinkingLevel");function pe(o,e){return!o||!e?!1:C(o)===C(e)&&o.id===e.id&&o.provider===e.provider}u(pe,"modelsAreEqual");export{ve as AI_TELEMETRY_SCHEMA,me as ModelsError,fe as calculateCost,ue as clampThinkingLevel,de as createModels,le as createProvider,Ae as getModelType,B as getSupportedThinkingLevels,he as hasApi,be as isModelType,pe as modelsAreEqual};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var p=Object.defineProperty;var e=(r,o)=>p(r,"name",{value:o,configurable:!0});import{CLASSIFIER_MODELS as t,IMAGE_MODELS as m,MODELS as i}from"../models.generated.js";import{createModels as f}from"../models.js";import{amazonBedrockProvider as a}from"./amazon-bedrock.js";import{antLingProvider as P}from"./ant-ling.js";import{anthropicProvider as v}from"./anthropic.js";import{azureProvider as l}from"./azure.js";import{basetenProvider as u}from"./baseten.js";import{cerebrasProvider as s}from"./cerebras.js";import{cloudflareAIGatewayProvider as c}from"./cloudflare-ai-gateway.js";import{cloudflareWorkersAIProvider as g}from"./cloudflare-workers-ai.js";import x from"./data/.manifest.json"with{type:"json"};import{deepseekProvider as M}from"./deepseek.js";import{fireworksProvider as k}from"./fireworks.js";import{githubCopilotProvider as C}from"./github-copilot.js";import{googleProvider as b}from"./google.js";import{googleVertexProvider as A}from"./google-vertex.js";import{groqProvider as B}from"./groq.js";import{huggingfaceProvider as I}from"./huggingface.js";import{kimiCodingProvider as
|
|
1
|
+
var p=Object.defineProperty;var e=(r,o)=>p(r,"name",{value:o,configurable:!0});import{CLASSIFIER_MODELS as t,IMAGE_MODELS as m,MODELS as i}from"../models.generated.js";import{createModels as f}from"../models.js";import{amazonBedrockProvider as a}from"./amazon-bedrock.js";import{antLingProvider as P}from"./ant-ling.js";import{anthropicProvider as v}from"./anthropic.js";import{azureProvider as l}from"./azure.js";import{basetenProvider as u}from"./baseten.js";import{cerebrasProvider as s}from"./cerebras.js";import{cloudflareAIGatewayProvider as c}from"./cloudflare-ai-gateway.js";import{cloudflareWorkersAIProvider as g}from"./cloudflare-workers-ai.js";import x from"./data/.manifest.json"with{type:"json"};import{deepseekProvider as M}from"./deepseek.js";import{fireworksProvider as k}from"./fireworks.js";import{githubCopilotProvider as C}from"./github-copilot.js";import{googleProvider as b}from"./google.js";import{googleVertexProvider as A}from"./google-vertex.js";import{groqProvider as B}from"./groq.js";import{huggingfaceProvider as I}from"./huggingface.js";import{kimiCodingProvider as w}from"./kimi-coding.js";import{metaProvider as h}from"./meta.js";import{minimaxProvider as O}from"./minimax.js";import{minimaxCnProvider as T}from"./minimax-cn.js";import{mistralProvider as D}from"./mistral.js";import{moonshotaiProvider as S}from"./moonshotai.js";import{moonshotaiCnProvider as j}from"./moonshotai-cn.js";import{nvidiaProvider as q}from"./nvidia.js";import{openaiProvider as y}from"./openai.js";import{openaiCodexProvider as E}from"./openai-codex.js";import{opencodeProvider as G}from"./opencode.js";import{opencodeGoProvider as L}from"./opencode-go.js";import{openrouterProvider as z}from"./openrouter.js";import{qwenTokenPlanProvider as N}from"./qwen-token-plan.js";import{qwenTokenPlanCnProvider as _}from"./qwen-token-plan-cn.js";import{qwenTokenPlanIndividualProvider as F}from"./qwen-token-plan-individual.js";import{qwenTokenPlanIndividualCnProvider as R}from"./qwen-token-plan-individual-cn.js";import{radiusProvider as n}from"./radius.js";import{togetherProvider as V}from"./together.js";import{typesafeProvider as W}from"./typesafe.js";import{vercelAIGatewayProvider as H}from"./vercel-ai-gateway.js";import{xaiProvider as J}from"./xai.js";import{xiaomiProvider as K}from"./xiaomi.js";import{xiaomiTokenPlanAmsProvider as Q}from"./xiaomi-token-plan-ams.js";import{xiaomiTokenPlanCnProvider as U}from"./xiaomi-token-plan-cn.js";import{xiaomiTokenPlanSgpProvider as X}from"./xiaomi-token-plan-sgp.js";import{zaiProvider as Y}from"./zai.js";import{zaiCodingCnProvider as Z}from"./zai-coding-cn.js";function Xr(r,o){return i[r]?.[o]}e(Xr,"getBuiltinModel");function Yr(r,o){return m[r]?.[o]}e(Yr,"getBuiltinImageModel");function Zr(r,o){return t[r]?.[o]}e(Zr,"getBuiltinClassifierModel");function $r(){return Object.keys(i)}e($r,"getBuiltinProviders");function ro(){const r=Date.parse(x.generatedAt);return Number.isNaN(r)?void 0:r}e(ro,"getBuiltinModelDataGeneratedAt");function $(r){const o=i[r];return Object.values(o??{})}e($,"getBuiltinModels");function rr(r){const o=m[r];return Object.values(o??{})}e(rr,"getBuiltinImageModels");function or(r){const o=t[r];return Object.values(o??{})}e(or,"getBuiltinClassifierModels");function oo(r){return[...$(r),...rr(r),...or(r)]}e(oo,"getAllBuiltinModels");function er(){return[a(),P(),v(),l(),u(),s(),c(),g(),M(),k(),C(),b(),A(),B(),I(),w(),h(),O(),T(),D(),S(),j(),q(),y(),E(),G(),L(),z(),N(),_(),F(),R(),n(),V(),W(),H(),J(),K(),Q(),U(),X(),Y(),Z()]}e(er,"builtinProviders");function eo(r){const o=f(r);for(const d of er())o.setProvider(d);return o}e(eo,"builtinModels");export{eo as builtinModels,er as builtinProviders,oo as getAllBuiltinModels,Zr as getBuiltinClassifierModel,or as getBuiltinClassifierModels,Yr as getBuiltinImageModel,rr as getBuiltinImageModels,Xr as getBuiltinModel,ro as getBuiltinModelDataGeneratedAt,$ as getBuiltinModels,$r as getBuiltinProviders,n as radiusProvider};
|