mapigate 0.5.155 → 0.5.160
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/README.md +1 -1
- package/dist/core/capabilities/modelDictionary.js +1 -1
- package/dist/core/usage/pricing.js +1 -1
- package/dist/mitm/dns/dnsConfig.js +9 -10
- package/dist/mitm/handlers/antigravity/config.js +2 -2
- package/dist/mitm/handlers/antigravity/converter.js +3 -2
- package/dist/mitm/handlers/antigravity/interceptor.js +8 -4
- package/dist/mitm/handlers/antigravity/modelInjector.js +1 -1
- package/dist/mitm/handlers/copilot/config.js +2 -2
- package/dist/providers/composite/combo/fallbackStrategy.js +1 -1
- package/dist/providers/core/base/baseProvider.js +1 -1
- package/dist/providers/runtime/antigravity/executor.js +10 -10
- package/dist/providers/runtime/antigravity/models.js +1 -1
- package/dist/providers/runtime/antigravity/schema.js +1 -1
- package/dist/providers/runtime/antigravity/types.js +1 -1
- package/dist/providers/runtime/github/auth.js +1 -1
- package/dist/providers/runtime/github/quota.js +1 -1
- package/dist/providers/runtime/kiro/createResponse.js +1 -1
- package/dist/providers/runtime/kiro/executor.js +5 -5
- package/dist/server/proxy/pipeline.js +5 -5
- package/dist/server/proxy/singleModelExecutor.js +5 -5
- package/dist/shared/utils/dnsResolver.js +1 -1
- package/dist/web/assets/{CliToolsTab-CJ1qK1mc.js → CliToolsTab-B_lNHS7I.js} +1 -1
- package/dist/web/assets/{CombosTab-C__IN7Vh.js → CombosTab-Cs2KWP8i.js} +1 -1
- package/dist/web/assets/{ConfirmModal-S6NP0OqD.js → ConfirmModal-73IbJAih.js} +1 -1
- package/dist/web/assets/{ConsoleLogTab-BW7FAr8M.js → ConsoleLogTab-DswA4_eC.js} +1 -1
- package/dist/web/assets/{EditAccountModal-BOJ3dX8Q.js → EditAccountModal-tMfNcAXT.js} +1 -1
- package/dist/web/assets/{EndpointTab-DpvqvtLI.js → EndpointTab-CweuNkGD.js} +1 -1
- package/dist/web/assets/{MitmTab-BkYhPR9f.js → MitmTab-BBl5YAE3.js} +3 -3
- package/dist/web/assets/{ModelAutocompleteInput-DEb_clZC.js → ModelAutocompleteInput-AZuprXC_.js} +1 -1
- package/dist/web/assets/{ProviderDetailPage-D7ptkJW2.js → ProviderDetailPage-CQh2gHX6.js} +1 -1
- package/dist/web/assets/{ProvidersTab-C0UAYPzg.js → ProvidersTab-CcpCZwlv.js} +1 -1
- package/dist/web/assets/{QuotaTab-CK7pgfKr.js → QuotaTab-CaoBW7ru.js} +1 -1
- package/dist/web/assets/{SettingsTab-DpK_sfw0.js → SettingsTab-15Sy7cCT.js} +1 -1
- package/dist/web/assets/{UsageTab-dv87ggGC.js → UsageTab-wcmWwuXa.js} +1 -1
- package/dist/web/assets/{index-D3Xjro_O.js → index-CYeNOWj5.js} +2 -2
- package/dist/web/assets/metadataRegistry-BkOuhIJ2.js +1 -0
- package/dist/web/assets/{providersData-Y57rBt5o.js → providersData-Bf-DlZQW.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/metadataRegistry-FuJXbCt4.js +0 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
[](LICENSE)
|
|
14
14
|
[](#)
|
|
15
15
|
[](https://www.typescriptlang.org/)
|
|
16
|
-
[](package.json)
|
|
17
17
|
|
|
18
18
|
[**What is Mapigate?**](#-what-is-mapigate) • [**Gateway API**](#-gateway-api) • [**Supported Providers**](#-supported-providers-152) • [**Quick Start**](#-quick-start-get-running-in-60s) • [**Token Saver**](#-feature-1-token-saver-modular-token-optimization) • [**Smart Routing & Combos**](#-feature-2-smart-routing--combo-engine) • [**Connect Coding Tools**](#-feature-3-one-click-connection-for-26-coding-assistants) • [**MITM Interceptor**](#-feature-4-mitm-https-interceptor-for-closed-tools) • [**Web Dashboard**](#-feature-5-web-dashboard-tour) • [**CLI Reference**](#-cli-reference-mapigate--mpg)
|
|
19
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var M=Object.defineProperty;var t=(e,i)=>M(e,"name",{value:i,configurable:!0});import{normalizeModelCompareKey as k}from"../../shared/utils/modelUtils.js";const l={"claude-fable-5-1":"Claude Fable 5.1","claude-fable-5.1":"Claude Fable 5.1","claude-fable-5":"Claude Fable 5","claude-fable":"Claude Fable","claude-opus-5.5":"Claude Opus 5.5","claude-opus-5-5":"Claude Opus 5.5","claude-sonnet-5.5":"Claude Sonnet 5.5","claude-sonnet-5-5":"Claude Sonnet 5.5","claude-haiku-5.5":"Claude Haiku 5.5","claude-haiku-5-5":"Claude Haiku 5.5","claude-opus-5":"Claude Opus 5","claude-sonnet-5":"Claude Sonnet 5","claude-haiku-5":"Claude Haiku 5","claude-haiku-6":"Claude Haiku 6","claude-opus-4.8":"Claude Opus 4.8","claude-opus-4-8":"Claude Opus 4.8","claude-opus-4.7":"Claude Opus 4.7","claude-opus-4-7":"Claude Opus 4.7","claude-sonnet-4.7":"Claude Sonnet 4.7","claude-sonnet-4-7":"Claude Sonnet 4.7","claude-sonnet-4.6":"Claude Sonnet 4.6","claude-sonnet-4-6":"Claude Sonnet 4.6","claude-opus-4.6":"Claude Opus 4.6","claude-opus-4-6":"Claude Opus 4.6","claude-sonnet-4.5":"Claude Sonnet 4.5","claude-sonnet-4-5":"Claude Sonnet 4.5","claude-opus-4.5":"Claude Opus 4.5","claude-opus-4-5":"Claude Opus 4.5","claude-haiku-4.5":"Claude Haiku 4.5","claude-haiku-4-5":"Claude Haiku 4.5","claude-sonnet-4":"Claude Sonnet 4","claude-opus-4":"Claude Opus 4","claude-haiku-4":"Claude Haiku 4","claude-3-7-sonnet":"Claude 3.7 Sonnet","claude-3.7-sonnet":"Claude 3.7 Sonnet","claude-3-5-sonnet":"Claude 3.5 Sonnet","claude-3.5-sonnet":"Claude 3.5 Sonnet","claude-3-5-haiku":"Claude 3.5 Haiku","claude-3.5-haiku":"Claude 3.5 Haiku","claude-3-opus":"Claude 3 Opus","claude-3-haiku":"Claude 3 Haiku","gpt-6.1-sol":"GPT-6.1 Sol","gpt-6.1-terra":"GPT-6.1 Terra","gpt-6-astra":"GPT-6.0 Astra","gpt-6-sol":"GPT-6.0 Sol","gpt-6-luna":"GPT-6.0 Luna","gpt-6":"GPT-6","gpt-5.6-sol":"GPT-5.6 Sol","gpt-5.6-terra":"GPT-5.6 Terra","gpt-5.6-luna":"GPT-5.6 Luna","gpt-5.5-codex":"GPT-5.5 Codex","gpt-5.5":"GPT-5.5","gpt-5.4":"GPT-5.4","gpt-5.4-mini":"GPT-5.4 Mini","gpt-5.4-nano":"GPT-5.4 Nano","gpt-5.3-codex":"GPT-5.3 Codex","gpt-5.2-codex":"GPT-5.2 Codex","gpt-5.2":"GPT-5.2","gpt-5.1":"GPT-5.1","gpt-5":"GPT-5","gpt-5-mini":"GPT-5 Mini","gpt-5-nano":"GPT-5 Nano","codex-pro":"Codex Pro","codex-auto-review":"Codex Auto Review","gpt-4.5":"GPT-4.5","gpt-4.5-preview":"GPT-4.5 Preview","gpt-4.1":"GPT-4.1","gpt-4.1-mini":"GPT-4.1 Mini","gpt-4.1-nano":"GPT-4.1 Nano","gpt-4o":"GPT-4o","gpt-4o-mini":"GPT-4o Mini","gpt-4-turbo":"GPT-4 Turbo","gpt-4":"GPT-4","gpt-3.5-turbo":"GPT-3.5 Turbo","o4-mini":"o4 Mini",o4:"o4","o3-pro":"o3 Pro","o3-mini":"o3 Mini",o3:"o3","o1-pro":"o1 Pro",o1:"o1","o1-mini":"o1 Mini","o1-preview":"o1 Preview","gemini-4-argon":"Gemini 4 Argon","gemini-4-carbon":"Gemini 4 Carbon","gemini-4-hydrogen":"Gemini 4 Hydrogen","gemini-4-ultra":"Gemini 4 Ultra","gemini-4-pro":"Gemini 4 Pro","gemini-4-flash":"Gemini 4 Flash","gemini-4":"Gemini 4","gemini-3.8-flash":"Gemini 3.8 Flash","gemini-3.8-pro":"Gemini 3.8 Pro","gemini-3.7-flash":"Gemini 3.7 Flash","gemini-3.7-pro":"Gemini 3.7 Pro","gemini-3.6-flash":"Gemini 3.6 Flash","gemini-3.6-pro":"Gemini 3.6 Pro","gemini-3.5-flash":"Gemini 3.5 Flash","gemini-3.5-pro":"Gemini 3.5 Pro","gemini-3.1-pro":"Gemini 3.1 Pro","gemini-3-flash":"Gemini 3 Flash","gemini-3-pro":"Gemini 3 Pro","gemini-2.5-pro":"Gemini 2.5 Pro","gemini-2.5-flash":"Gemini 2.5 Flash","gemini-2.0-pro":"Gemini 2.0 Pro","gemini-2.0-flash":"Gemini 2.0 Flash","gemini-2.0-flash-lite":"Gemini 2.0 Flash Lite","gemini-2.0-flash-thinking":"Gemini 2.0 Flash Thinking","gemini-1.5-pro":"Gemini 1.5 Pro","gemini-1.5-flash":"Gemini 1.5 Flash","gemini-1.5-flash-8b":"Gemini 1.5 Flash 8B","gemma-3-27b":"Gemma 3 27B","gemma-3-12b":"Gemma 3 12B","gemma-3-4b":"Gemma 3 4B","gemma-2-27b":"Gemma 2 27B","gemma-2-9b":"Gemma 2 9B","deepseek-v4-pro":"DeepSeek V4 Pro","deepseek-v4.1-flash":"DeepSeek V4.1 Flash","deepseek-v4-1-flash":"DeepSeek V4.1 Flash","deepseek-v4.1":"DeepSeek V4.1","deepseek-v4-flash":"DeepSeek V4 Flash","deepseek-v4":"DeepSeek V4","deepseek-flash":"DeepSeek Flash","deepseek-3.2":"DeepSeek 3.2","deepseek-3-2":"DeepSeek 3.2","deepseek-v3.2":"DeepSeek V3.2","deepseek-v3":"DeepSeek V3","deepseek-chat":"DeepSeek V3","deepseek-r1":"DeepSeek R1","deepseek-reasoner":"DeepSeek R1","deepseek-coder":"DeepSeek Coder","deepseek-coder-v2":"DeepSeek Coder V2","qwen3.8-flash":"Qwen 3.8 Flash","qwen3.7-plus":"Qwen 3.7 Plus","qwen3.7":"Qwen 3.7","qwen3.6":"Qwen 3.6","qwen3.5":"Qwen 3.5","qwen3-coder-next":"Qwen3 Coder Next","qwen3-coder":"Qwen3 Coder Next","qwen3-max":"Qwen3 Max","qwen-2.5-coder-32b":"Qwen 2.5 Coder 32B","qwen-2.5-coder-14b":"Qwen 2.5 Coder 14B","qwen-2.5-coder-7b":"Qwen 2.5 Coder 7B","qwen-2.5-coder-1.5b":"Qwen 2.5 Coder 1.5B","qwen-2.5-72b-instruct":"Qwen 2.5 72B Instruct","qwen-2.5-32b-instruct":"Qwen 2.5 32B Instruct","qwen-2.5-14b-instruct":"Qwen 2.5 14B Instruct","qwen-2.5-7b-instruct":"Qwen 2.5 7B Instruct","qwq-32b":"QwQ 32B","qwq-plus":"QwQ Plus","kimi-k3.1-pro":"Kimi K3.1 Pro","kimi-k3.1":"Kimi K3.1","kimi-k3-1":"Kimi K3.1","kimi-k3":"Kimi K3","kimi-for-coding":"Kimi For Coding","kimi-k2.8-preview":"Kimi K2.8 Preview","kimi-k2.8":"Kimi K2.8","kimi-k2.7-code":"Kimi K2.7 Code","kimi-k2.7":"Kimi K2.7","kimi-k2.6":"Kimi K2.6","kimi-k2.5":"Kimi K2.5","kimi-k1.5":"Kimi K1.5","moonshot-v1":"Moonshot V1","mimo-v2.6":"MiMo V2.6","mimo-v2.5":"MiMo V2.5","mimo-omni":"MiMo Omni","mimo-v2":"MiMo V2","minimax-m3":"MiniMax M3","minimax-m3-free":"MiniMax M3 (Free)","minimax-m2.7":"MiniMax M2.7","minimax-m2.5":"MiniMax M2.5","minimax-m2-5":"MiniMax M2.5","minimax-m2.1":"MiniMax M2.1","minimax-m2-1":"MiniMax M2.1","minimax-text-01":"MiniMax Text 01","minimax-abab6.5s":"MiniMax Abab 6.5s","doubao-seed-evolving":"Doubao Seed Evolving","doubao-seed-2-1-turbo":"Doubao Seed 2.1 Turbo","doubao-seed-2.1-turbo":"Doubao Seed 2.1 Turbo","doubao-seed-2-0-mini":"Doubao Seed 2.0 Mini","doubao-seed-2.0-mini":"Doubao Seed 2.0 Mini","doubao-seed-2.0":"Doubao Seed 2.0","glm-5.3-flash":"GLM-5.3 Flash","glm-5.3":"GLM-5.3","glm-5.2":"GLM-5.2","glm-5.1":"GLM-5.1","glm-5":"GLM-5",glm5:"GLM-5","glm-4.7-flash":"GLM-4.7 Flash","glm-4.6":"GLM-4.6","glm-4-plus":"GLM-4 Plus","glm-4-flash":"GLM-4 Flash","glm-4-long":"GLM-4 Long","glm-4-zero":"GLM-4 Zero","llama-4-scout":"Llama 4 Scout","llama-4":"Llama 4","llama-3.3-70b-instruct":"Llama 3.3 70B Instruct","llama-3.2-3b-instruct":"Llama 3.2 3B Instruct","llama-3.2-1b-instruct":"Llama 3.2 1B Instruct","llama-3.1-405b-instruct":"Llama 3.1 405B Instruct","llama-3.1-70b-instruct":"Llama 3.1 70B Instruct","llama-3.1-8b-instruct":"Llama 3.1 8B Instruct","codestral-latest":"Codestral Latest","codestral-2501":"Codestral 2501",devstral:"Devstral","mistral-large-latest":"Mistral Large Latest","mistral-small-3.1-24b-instruct":"Mistral Small 3.1 24B Instruct","mistral-small-latest":"Mistral Small Latest","ministral-8b":"Ministral 8B","ministral-3b":"Ministral 3B","mai-code-1.1-flash":"MAI-Code 1.1 Flash","mai-code-1.1":"MAI-Code 1.1","grok-4.7":"Grok 4.7","grok-4.6":"Grok 4.6","grok-4.5":"Grok 4.5","grok-4":"Grok 4","grok-3":"Grok 3","grok-2":"Grok 2",auto:"Auto (Agent Mode)","simple-task":"Simple Task","permission-classifier":"Permission Classifier","gpt-oss-120b":"GPT-OSS 120B"},f=/[-_:@](extra-low|high-thinking|medium-thinking|low-thinking|high|medium|low|thinking|free|preview|latest|beta|eco|instruct|chat|v[0-9]+(?:\.[0-9]+)*|[0-9]{8})$/i;function C(e){const i=e.toLowerCase();switch(i){case"high":return" (High)";case"medium":return" (Medium)";case"low":return" (Low)";case"extra-low":return" (Extra Low)";case"thinking":return" (Thinking)";case"high-thinking":return" (High Thinking)";case"medium-thinking":return" (Medium Thinking)";case"low-thinking":return" (Low Thinking)";case"free":return" (Free)";case"preview":return" (Preview)";case"beta":return" (Beta)";case"eco":return" (Eco)";default:return/^v[0-9]+(?:\.[0-9]+)*$/i.test(i)?` ${i.toUpperCase()}`:""}}t(C,"formatSuffixTag");function b(e){return e?(e.includes("/")?e.split("/").pop():e).replace(/\[[^\]]*\]/g,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().split(" ").map(n=>/^(gpt|llm|ai|api|vl|dall|tts|stt|oss|r1|v[0-9]+|b|k)$/i.test(n)?n.toUpperCase():n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}t(b,"formatModelDisplayNameFallback");const r=new Map;let h=0;function w(){const e=Object.keys(l).length;if(r.size===0||h!==e){r.clear();for(const[i,n]of Object.entries(l)){const a=k(i);r.has(a)||r.set(a,n)}h=e}return r}t(w,"ensureNormalizedIndex");function u(e){if(!e)return;if(l[e])return l[e];const i=e.toLowerCase();if(l[i])return l[i];const n=w(),a=k(i),o=n.get(a);if(o)return o}t(u,"lookupStandardModel");function T(e){if(!e)return"";let i=e.includes("/")?e.split("/").pop():e;i=i.trim();let n="";/\[1m\]/i.test(i)&&(n=" (1M Context)",i=i.replace(/\[1m\]/i,""));const a=u(i);if(a)return`${a}${n}`;let o=i;const m=[];let d=!0;for(;d;){const s=o.match(f);if(s&&s.index!==void 0&&s.index>0){const G=s[1],g=C(G);if(g&&m.unshift(g),o=o.slice(0,s.index),u(o))break}else d=!1}const c=u(o),p=m.join("");return c?`${c}${p}${n}`:`${b(o)||o}${p}${n}`}t(T,"resolveModelDisplayName");function L(){const e=new Set,i=[];for(const[n,a]of Object.entries(l))e.has(a)||(e.add(a),i.push({id:n,name:a}));return i}t(L,"getCanonicalModelList");export{l as STANDARD_MODELS,b as formatModelDisplayNameFallback,L as getCanonicalModelList,T as resolveModelDisplayName};
|
|
1
|
+
var M=Object.defineProperty;var t=(e,i)=>M(e,"name",{value:i,configurable:!0});import{normalizeModelCompareKey as k}from"../../shared/utils/modelUtils.js";const l={"claude-fable-5-1":"Claude Fable 5.1","claude-fable-5.1":"Claude Fable 5.1","claude-fable-5":"Claude Fable 5","claude-fable":"Claude Fable","claude-opus-5.5":"Claude Opus 5.5","claude-opus-5-5":"Claude Opus 5.5","claude-sonnet-5.5":"Claude Sonnet 5.5","claude-sonnet-5-5":"Claude Sonnet 5.5","claude-haiku-5.5":"Claude Haiku 5.5","claude-haiku-5-5":"Claude Haiku 5.5","claude-opus-5":"Claude Opus 5","claude-sonnet-5":"Claude Sonnet 5","claude-haiku-5":"Claude Haiku 5","claude-haiku-6":"Claude Haiku 6","claude-opus-4.8":"Claude Opus 4.8","claude-opus-4-8":"Claude Opus 4.8","claude-opus-4.7":"Claude Opus 4.7","claude-opus-4-7":"Claude Opus 4.7","claude-sonnet-4.7":"Claude Sonnet 4.7","claude-sonnet-4-7":"Claude Sonnet 4.7","claude-sonnet-4.6":"Claude Sonnet 4.6","claude-sonnet-4-6":"Claude Sonnet 4.6","claude-opus-4.6":"Claude Opus 4.6","claude-opus-4-6":"Claude Opus 4.6","claude-sonnet-4.5":"Claude Sonnet 4.5","claude-sonnet-4-5":"Claude Sonnet 4.5","claude-opus-4.5":"Claude Opus 4.5","claude-opus-4-5":"Claude Opus 4.5","claude-haiku-4.5":"Claude Haiku 4.5","claude-haiku-4-5":"Claude Haiku 4.5","claude-sonnet-4":"Claude Sonnet 4","claude-opus-4":"Claude Opus 4","claude-haiku-4":"Claude Haiku 4","claude-3-7-sonnet":"Claude 3.7 Sonnet","claude-3.7-sonnet":"Claude 3.7 Sonnet","claude-3-5-sonnet":"Claude 3.5 Sonnet","claude-3.5-sonnet":"Claude 3.5 Sonnet","claude-3-5-haiku":"Claude 3.5 Haiku","claude-3.5-haiku":"Claude 3.5 Haiku","claude-3-opus":"Claude 3 Opus","claude-3-haiku":"Claude 3 Haiku","gpt-6.1-sol":"GPT-6.1 Sol","gpt-6.1-terra":"GPT-6.1 Terra","gpt-6-astra":"GPT-6.0 Astra","gpt-6-sol":"GPT-6.0 Sol","gpt-6-luna":"GPT-6.0 Luna","gpt-6":"GPT-6","gpt-5.6-sol":"GPT-5.6 Sol","gpt-5.6-terra":"GPT-5.6 Terra","gpt-5.6-luna":"GPT-5.6 Luna","gpt-5.5-codex":"GPT-5.5 Codex","gpt-5.5":"GPT-5.5","gpt-5.4":"GPT-5.4","gpt-5.4-mini":"GPT-5.4 Mini","gpt-5.4-nano":"GPT-5.4 Nano","gpt-5.3-codex":"GPT-5.3 Codex","gpt-5.2-codex":"GPT-5.2 Codex","gpt-5.2":"GPT-5.2","gpt-5.1":"GPT-5.1","gpt-5":"GPT-5","gpt-5-mini":"GPT-5 Mini","gpt-5-nano":"GPT-5 Nano","codex-pro":"Codex Pro","codex-auto-review":"Codex Auto Review","gpt-4.5":"GPT-4.5","gpt-4.5-preview":"GPT-4.5 Preview","gpt-4.1":"GPT-4.1","gpt-4.1-mini":"GPT-4.1 Mini","gpt-4.1-nano":"GPT-4.1 Nano","gpt-4o":"GPT-4o","gpt-4o-mini":"GPT-4o Mini","gpt-4-turbo":"GPT-4 Turbo","gpt-4":"GPT-4","gpt-3.5-turbo":"GPT-3.5 Turbo","o4-mini":"o4 Mini",o4:"o4","o3-pro":"o3 Pro","o3-mini":"o3 Mini",o3:"o3","o1-pro":"o1 Pro",o1:"o1","o1-mini":"o1 Mini","o1-preview":"o1 Preview","gemini-4-argon":"Gemini 4 Argon","gemini-4-carbon":"Gemini 4 Carbon","gemini-4-hydrogen":"Gemini 4 Hydrogen","gemini-4-neon":"Gemini 4 Neon","gemini-4-ultra":"Gemini 4 Ultra","gemini-4-pro":"Gemini 4 Pro","gemini-4-flash":"Gemini 4 Flash","gemini-4":"Gemini 4","gemini-3.8-flash":"Gemini 3.8 Flash","gemini-3.8-pro":"Gemini 3.8 Pro","gemini-3.7-flash":"Gemini 3.7 Flash","gemini-3.7-pro":"Gemini 3.7 Pro","gemini-3.6-flash":"Gemini 3.6 Flash","gemini-3.6-pro":"Gemini 3.6 Pro","gemini-3.5-flash":"Gemini 3.5 Flash","gemini-3.5-pro":"Gemini 3.5 Pro","gemini-3.1-pro":"Gemini 3.1 Pro","gemini-3-flash":"Gemini 3 Flash","gemini-3-pro":"Gemini 3 Pro","gemini-2.5-pro":"Gemini 2.5 Pro","gemini-2.5-flash":"Gemini 2.5 Flash","gemini-2.0-pro":"Gemini 2.0 Pro","gemini-2.0-flash":"Gemini 2.0 Flash","gemini-2.0-flash-lite":"Gemini 2.0 Flash Lite","gemini-2.0-flash-thinking":"Gemini 2.0 Flash Thinking","gemini-1.5-pro":"Gemini 1.5 Pro","gemini-1.5-flash":"Gemini 1.5 Flash","gemini-1.5-flash-8b":"Gemini 1.5 Flash 8B","gemma-3-27b":"Gemma 3 27B","gemma-3-12b":"Gemma 3 12B","gemma-3-4b":"Gemma 3 4B","gemma-2-27b":"Gemma 2 27B","gemma-2-9b":"Gemma 2 9B","deepseek-v4-pro":"DeepSeek V4 Pro","deepseek-v4.1-flash":"DeepSeek V4.1 Flash","deepseek-v4-1-flash":"DeepSeek V4.1 Flash","deepseek-v4.1":"DeepSeek V4.1","deepseek-v4-flash":"DeepSeek V4 Flash","deepseek-v4":"DeepSeek V4","deepseek-flash":"DeepSeek Flash","deepseek-3.2":"DeepSeek 3.2","deepseek-3-2":"DeepSeek 3.2","deepseek-v3.2":"DeepSeek V3.2","deepseek-v3":"DeepSeek V3","deepseek-chat":"DeepSeek V3","deepseek-r1":"DeepSeek R1","deepseek-reasoner":"DeepSeek R1","deepseek-coder":"DeepSeek Coder","deepseek-coder-v2":"DeepSeek Coder V2","qwen3.8-flash":"Qwen 3.8 Flash","qwen3.7-plus":"Qwen 3.7 Plus","qwen3.7":"Qwen 3.7","qwen3.6":"Qwen 3.6","qwen3.5":"Qwen 3.5","qwen3-coder-next":"Qwen3 Coder Next","qwen3-coder":"Qwen3 Coder Next","qwen3-max":"Qwen3 Max","qwen-2.5-coder-32b":"Qwen 2.5 Coder 32B","qwen-2.5-coder-14b":"Qwen 2.5 Coder 14B","qwen-2.5-coder-7b":"Qwen 2.5 Coder 7B","qwen-2.5-coder-1.5b":"Qwen 2.5 Coder 1.5B","qwen-2.5-72b-instruct":"Qwen 2.5 72B Instruct","qwen-2.5-32b-instruct":"Qwen 2.5 32B Instruct","qwen-2.5-14b-instruct":"Qwen 2.5 14B Instruct","qwen-2.5-7b-instruct":"Qwen 2.5 7B Instruct","qwq-32b":"QwQ 32B","qwq-plus":"QwQ Plus","kimi-k3.1-pro":"Kimi K3.1 Pro","kimi-k3.1":"Kimi K3.1","kimi-k3-1":"Kimi K3.1","kimi-k3":"Kimi K3","kimi-for-coding":"Kimi For Coding","kimi-k2.8-preview":"Kimi K2.8 Preview","kimi-k2.8":"Kimi K2.8","kimi-k2.7-code":"Kimi K2.7 Code","kimi-k2.7":"Kimi K2.7","kimi-k2.6":"Kimi K2.6","kimi-k2.5":"Kimi K2.5","kimi-k1.5":"Kimi K1.5","moonshot-v1":"Moonshot V1","mimo-v2.6":"MiMo V2.6","mimo-v2.5":"MiMo V2.5","mimo-omni":"MiMo Omni","mimo-v2":"MiMo V2","minimax-m3":"MiniMax M3","minimax-m3-free":"MiniMax M3 (Free)","minimax-m2.7":"MiniMax M2.7","minimax-m2.5":"MiniMax M2.5","minimax-m2-5":"MiniMax M2.5","minimax-m2.1":"MiniMax M2.1","minimax-m2-1":"MiniMax M2.1","minimax-text-01":"MiniMax Text 01","minimax-abab6.5s":"MiniMax Abab 6.5s","doubao-seed-evolving":"Doubao Seed Evolving","doubao-seed-2-1-turbo":"Doubao Seed 2.1 Turbo","doubao-seed-2.1-turbo":"Doubao Seed 2.1 Turbo","doubao-seed-2-0-mini":"Doubao Seed 2.0 Mini","doubao-seed-2.0-mini":"Doubao Seed 2.0 Mini","doubao-seed-2.0":"Doubao Seed 2.0","glm-5.3-flash":"GLM-5.3 Flash","glm-5.3":"GLM-5.3","glm-5.2":"GLM-5.2","glm-5.1":"GLM-5.1","glm-5":"GLM-5",glm5:"GLM-5","glm-4.7-flash":"GLM-4.7 Flash","glm-4.6":"GLM-4.6","glm-4-plus":"GLM-4 Plus","glm-4-flash":"GLM-4 Flash","glm-4-long":"GLM-4 Long","glm-4-zero":"GLM-4 Zero","llama-4-scout":"Llama 4 Scout","llama-4":"Llama 4","llama-3.3-70b-instruct":"Llama 3.3 70B Instruct","llama-3.2-3b-instruct":"Llama 3.2 3B Instruct","llama-3.2-1b-instruct":"Llama 3.2 1B Instruct","llama-3.1-405b-instruct":"Llama 3.1 405B Instruct","llama-3.1-70b-instruct":"Llama 3.1 70B Instruct","llama-3.1-8b-instruct":"Llama 3.1 8B Instruct","codestral-latest":"Codestral Latest","codestral-2501":"Codestral 2501",devstral:"Devstral","mistral-large-latest":"Mistral Large Latest","mistral-small-3.1-24b-instruct":"Mistral Small 3.1 24B Instruct","mistral-small-latest":"Mistral Small Latest","ministral-8b":"Ministral 8B","ministral-3b":"Ministral 3B","mai-code-2-flash":"MAI-Code 2 Flash","mai-code-2":"MAI-Code 2","mai-code-1.1-flash":"MAI-Code 1.1 Flash","mai-code-1.1":"MAI-Code 1.1","grok-4.7":"Grok 4.7","grok-4.6":"Grok 4.6","grok-4.5":"Grok 4.5","grok-4":"Grok 4","grok-3":"Grok 3","grok-2":"Grok 2",auto:"Auto (Agent Mode)","simple-task":"Simple Task","permission-classifier":"Permission Classifier","gpt-oss-120b":"GPT-OSS 120B"},f=/[-_:@](extra-low|high-thinking|medium-thinking|low-thinking|xhigh|high|medium|low|thinking|free|preview|latest|beta|eco|instruct|chat|v[0-9]+(?:\.[0-9]+)*|[0-9]{8})$/i;function C(e){const i=e.toLowerCase();switch(i){case"xhigh":return" (Extra)";case"high":return" (High)";case"medium":return" (Medium)";case"low":return" (Low)";case"extra-low":return" (Extra Low)";case"thinking":return" (Thinking)";case"high-thinking":return" (High Thinking)";case"medium-thinking":return" (Medium Thinking)";case"low-thinking":return" (Low Thinking)";case"free":return" (Free)";case"preview":return" (Preview)";case"beta":return" (Beta)";case"eco":return" (Eco)";default:return/^v[0-9]+(?:\.[0-9]+)*$/i.test(i)?` ${i.toUpperCase()}`:""}}t(C,"formatSuffixTag");function b(e){return e?(e.includes("/")?e.split("/").pop():e).replace(/\[[^\]]*\]/g,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().split(" ").map(n=>/^(gpt|llm|ai|api|vl|dall|tts|stt|oss|r1|v[0-9]+|b|k)$/i.test(n)?n.toUpperCase():n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}t(b,"formatModelDisplayNameFallback");const r=new Map;let h=0;function w(){const e=Object.keys(l).length;if(r.size===0||h!==e){r.clear();for(const[i,n]of Object.entries(l)){const a=k(i);r.has(a)||r.set(a,n)}h=e}return r}t(w,"ensureNormalizedIndex");function u(e){if(!e)return;if(l[e])return l[e];const i=e.toLowerCase();if(l[i])return l[i];const n=w(),a=k(i),o=n.get(a);if(o)return o}t(u,"lookupStandardModel");function T(e){if(!e)return"";let i=e.includes("/")?e.split("/").pop():e;i=i.trim();let n="";/\[1m\]/i.test(i)&&(n=" (1M Context)",i=i.replace(/\[1m\]/i,""));const a=u(i);if(a)return`${a}${n}`;let o=i;const m=[];let d=!0;for(;d;){const s=o.match(f);if(s&&s.index!==void 0&&s.index>0){const G=s[1],g=C(G);if(g&&m.unshift(g),o=o.slice(0,s.index),u(o))break}else d=!1}const c=u(o),p=m.join("");return c?`${c}${p}${n}`:`${b(o)||o}${p}${n}`}t(T,"resolveModelDisplayName");function L(){const e=new Set,i=[];for(const[n,a]of Object.entries(l))e.has(a)||(e.add(a),i.push({id:n,name:a}));return i}t(L,"getCanonicalModelList");export{l as STANDARD_MODELS,b as formatModelDisplayNameFallback,L as getCanonicalModelList,T as resolveModelDisplayName};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=Object.defineProperty;var s=(e,n)=>f(e,"name",{value:n,configurable:!0});import{normalizeModelCompareKey as m}from"../../shared/utils/modelUtils.js";const k={input:0,output:0,cached:0,reasoning:0,cache_creation:0},x=/[-:_.](high|medium|low|extra-low|thinking|reasoning|free|beta|exact|preview|latest|extended|instruct|chat|turbo|online|search|tiered|v\d+|\d{8}|\d{4}-\d{2}-\d{2})$/i;function w(e){if(!e)return[];let n=e.includes("/")?e.split("/").pop():e;n=n.trim().toLowerCase(),n=n.replace(/\[[^\]]+\]/g,"");const t=[];n&&t.push(n);let c=n,u=!0;for(;u;){const i=c.match(x);i&&i.index!==void 0&&i.index>0?(c=c.slice(0,i.index),c&&!t.includes(c)&&t.push(c)):u=!1}const a=[];for(const i of t){const p=i.replace(/(\d+)-(\d+)/g,"$1.$2");p!==i&&!t.includes(p)&&!a.includes(p)&&a.push(p);const r=i.replace(/(\d+)\.(\d+)/g,"$1-$2");r!==i&&!t.includes(r)&&!a.includes(r)&&a.push(r);const h=i.replace(/claude-(opus|sonnet|haiku)-(\d+)-(\d+)/g,"claude-$1-$2.$3");h!==i&&!t.includes(h)&&!a.includes(h)&&a.push(h);const o=i.replace(/claude-(opus|sonnet|haiku)-(\d+)\.(\d+)/g,"claude-$1-$2-$3");if(o!==i&&!t.includes(o)&&!a.includes(o)&&a.push(o),i.includes("-")){const d=i.split("-");if(d.length>1){const _=d.slice(1).join("-");_&&!t.includes(_)&&!a.includes(_)&&a.push(_)}}}return[...t,...a]}s(w,"extractModelPricingCandidates");const b=["cline-free/","free/","local/"];function $(e){if(!e)return!1;const n=e.toLowerCase();return b.some(t=>n.startsWith(t))}s($,"isFreeModel");const g={"claude-fable-5.1":{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5},"claude-fable-5":{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5},"claude-mythos-5.1":{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5},"claude-mythos-5":{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5},"claude-opus-5.5":{input:4,output:20,cached:.4,reasoning:20,cache_creation:5},"claude-opus-5":{input:5,output:25,cached:.5,reasoning:25,cache_creation:6.25},"claude-opus-4-6":{input:5,output:25,cached:.5,reasoning:25,cache_creation:6.25},"claude-opus-4.5":{input:5,output:25,cached:.5,reasoning:25,cache_creation:6.25},"claude-opus-4.1":{input:15,output:75,cached:1.5,reasoning:75,cache_creation:18.75},"claude-opus-4":{input:15,output:25,cached:7.5,reasoning:112.5,cache_creation:15},"claude-sonnet-5.5":{input:2,output:10,cached:.2,reasoning:10,cache_creation:2.5},"claude-sonnet-5":{input:2,output:10,cached:.2,reasoning:10,cache_creation:2.5},"claude-sonnet-4-6":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-sonnet-4.5":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-sonnet-4":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-haiku-5.5":{input:.1,output:.5,cached:.01,reasoning:.5,cache_creation:.125},"claude-haiku-4.5":{input:1,output:5,cached:.1,reasoning:5,cache_creation:1.25},"claude-3.7-sonnet":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-3-7-sonnet":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-3.5-sonnet":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-3-5-sonnet":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-3.5-haiku":{input:.8,output:4,cached:.08,reasoning:4,cache_creation:1},"claude-3-5-haiku":{input:.8,output:4,cached:.08,reasoning:4,cache_creation:1},"claude-3-opus":{input:15,output:75,cached:1.5,reasoning:75,cache_creation:18.75},"claude-3-haiku":{input:.25,output:1.25,cached:.025,reasoning:1.25,cache_creation:.3125},"gpt-4o":{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5},"gpt-4o-mini":{input:.15,output:.6,cached:.075,reasoning:.9,cache_creation:.15},"gpt-4.1":{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5},"gpt-5":{input:1.25,output:10,cached:.625,reasoning:10,cache_creation:1.25},"gpt-5-mini":{input:.25,output:2,cached:.125,reasoning:2,cache_creation:.25},"gpt-5-codex":{input:1.25,output:10,cached:.625,reasoning:10,cache_creation:1.25},"gpt-5.1-codex":{input:1.25,output:10,cached:.625,reasoning:10,cache_creation:1.25},"gpt-5.1-codex-mini":{input:1.5,output:6,cached:.75,reasoning:9,cache_creation:1.5},"gpt-5.2-codex":{input:1.75,output:14,cached:.175,reasoning:14,cache_creation:1.75},"gpt-5.3-codex":{input:1.75,output:14,cached:.175,reasoning:14,cache_creation:1.75},"gpt-5.3-codex-spark":{input:3,output:12,cached:.3,reasoning:12,cache_creation:3},"gpt-5.4":{input:2.5,output:15,cached:.25,reasoning:15,cache_creation:2.5},"gpt-5.4-mini":{input:.25,output:1.5,cached:.025,reasoning:1.5,cache_creation:.25},"gpt-5.5":{input:5,output:30,cached:.5,reasoning:30,cache_creation:5},"gpt-5.6":{input:2.5,output:15,cached:.25,reasoning:15,cache_creation:2.5},"gpt-5.6-luna":{input:.2,output:1.2,cached:.02,reasoning:1.2,cache_creation:.2},"gpt-5.6-terra":{input:2,output:12,cached:.2,reasoning:12,cache_creation:2},"gpt-5.6-sol":{input:4,output:20,cached:.4,reasoning:20,cache_creation:4},"gpt-6.1-sol":{input:2,output:10,cached:.1,reasoning:10,cache_creation:2},"gpt-6.1-terra":{input:1,output:5,cached:.05,reasoning:5,cache_creation:1},"gpt-6-astra":{input:2,output:10,cached:.1,reasoning:10,cache_creation:2},o1:{input:15,output:60,cached:7.5,reasoning:90,cache_creation:15},"o1-mini":{input:3,output:12,cached:1.5,reasoning:18,cache_creation:3},o3:{input:2,output:8,cached:.5,reasoning:8,cache_creation:2},"o3-mini":{input:1.1,output:4.4,cached:.55,reasoning:4.4,cache_creation:1.1},"o4-mini":{input:1.1,output:4.4,cached:.275,reasoning:4.4,cache_creation:1.1},"gemini-2.5-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-flash":{input:.15,output:.6,cached:.0375,reasoning:.6,cache_creation:.15},"gemini-3-flash":{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5},"gemini-3-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-3.7-flash":{input:1.5,output:7.5,cached:.15,reasoning:11.25,cache_creation:1.875},"gemini-3.8-flash":{input:1.5,output:7.5,cached:.15,reasoning:11.25,cache_creation:1.875},"gemini-4-argon":{input:2,output:10,cached:.1,reasoning:10,cache_creation:2},"gemini-4-carbon":{input:2,output:10,cached:.1,reasoning:10,cache_creation:2},"gemini-4-hydrogen":{input:1.5,output:7.5,cached:.075,reasoning:7.5,cache_creation:1.5},"deepseek-chat":{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14},"deepseek-reasoner":{input:.55,output:2.19,cached:.14,reasoning:2.19,cache_creation:.55},"deepseek-r1":{input:.55,output:2.19,cached:.14,reasoning:2.19,cache_creation:.55},"deepseek-v3":{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14},"deepseek-v4.1-flash":{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14},"deepseek-v4-pro":{input:.66,output:1.98,cached:.066,reasoning:1.98,cache_creation:.66},"qwen-turbo":{input:.05,output:.2,cached:.01,reasoning:.2,cache_creation:.05},"qwen-2.5-coder-32b":{input:.07,output:.2,cached:.01,reasoning:.2,cache_creation:.07},"qwen-2.5-coder-7b":{input:.03,output:.1,cached:.005,reasoning:.1,cache_creation:.03},"qwen-coder-plus":{input:.4,output:1.2,cached:.1,reasoning:1.2,cache_creation:.4},"qwen-plus":{input:.4,output:1.2,cached:.1,reasoning:1.2,cache_creation:.4},"qwen3.7-plus":{input:.4,output:1.6,cached:.1,reasoning:1.6,cache_creation:.4},"qwen-max":{input:1.6,output:6.4,cached:.4,reasoning:6.4,cache_creation:1.6},"qwen3.8-max":{input:2,output:6,cached:.4,reasoning:6,cache_creation:2},"mimo-v2.6-pro":{input:.435,output:.87,cached:.0036,reasoning:.87,cache_creation:.435},"mimo-v2.6-flash":{input:.14,output:.28,cached:.0028,reasoning:.28,cache_creation:.14},"mimo-v2.5":{input:.14,output:.28,cached:.0028,reasoning:.28,cache_creation:.14},"mimo-v2":{input:.14,output:.28,cached:.0028,reasoning:.28,cache_creation:.14},"k3.1-pro":{input:2,output:10,cached:.2,reasoning:10,cache_creation:2},"kimi-k3.1-pro":{input:2,output:10,cached:.2,reasoning:10,cache_creation:2},"k3.1-pro-highspeed":{input:4,output:20,cached:.2,reasoning:20,cache_creation:4},"kimi-k3.1-pro-highspeed":{input:4,output:20,cached:.2,reasoning:20,cache_creation:4},k3:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-k3":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-for-coding":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-for-coding-highspeed":{input:4,output:20,cached:.2,reasoning:20,cache_creation:4},"kimi-k2.7-code":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-k2.6":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-k2.5":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"minimax-m3":{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3},"minimax-m3.1-flash":{input:.15,output:.6,cached:.03,reasoning:.6,cache_creation:.15},"minimax-m2.7":{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3},"minimax-m2.5":{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3},"minimax-m2.1":{input:.2,output:1.1,cached:.04,reasoning:1.1,cache_creation:.2},"minimax-text-01":{input:.2,output:1.1,cached:.04,reasoning:1.1,cache_creation:.2}},T=[{pattern:/minimax.*flash/i,pricing:{input:.15,output:.6,cached:.03,reasoning:.6,cache_creation:.15}},{pattern:/minimax.*(m3|m2\.7|m2\.5)/i,pricing:{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3}},{pattern:/minimax/i,pricing:{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3}},{pattern:/gemini-4-(argon|carbon)/i,pricing:{input:2,output:10,cached:.1,reasoning:10,cache_creation:2}},{pattern:/(argon|carbon)/i,pricing:{input:2,output:10,cached:.1,reasoning:10,cache_creation:2}},{pattern:/gemini-4-hydrogen/i,pricing:{input:1.5,output:7.5,cached:.075,reasoning:7.5,cache_creation:1.5}},{pattern:/hydrogen/i,pricing:{input:1.5,output:7.5,cached:.075,reasoning:7.5,cache_creation:1.5}},{pattern:/k3[.-]1.*highspeed/i,pricing:{input:4,output:20,cached:.2,reasoning:20,cache_creation:4}},{pattern:/kimi.*highspeed/i,pricing:{input:4,output:20,cached:.2,reasoning:20,cache_creation:4}},{pattern:/k3[.-]1/i,pricing:{input:2,output:10,cached:.2,reasoning:10,cache_creation:2}},{pattern:/kimi.*k3[.-]1/i,pricing:{input:2,output:10,cached:.2,reasoning:10,cache_creation:2}},{pattern:/kimi.*k3/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3}},{pattern:/^k3$/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3}},{pattern:/kimi/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3}},{pattern:/moonshot/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3}},{pattern:/mimo.*pro/i,pricing:{input:.435,output:.87,cached:.0036,reasoning:.87,cache_creation:.435}},{pattern:/mimo/i,pricing:{input:.14,output:.28,cached:.0028,reasoning:.28,cache_creation:.14}},{pattern:/codex/i,pricing:{input:1.75,output:14,cached:.175,reasoning:14,cache_creation:1.75}},{pattern:/claude-.*(fable|mythos)/i,pricing:{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5}},{pattern:/claude-.*opus-5[.-]5/i,pricing:{input:4,output:20,cached:.4,reasoning:20,cache_creation:5}},{pattern:/claude-.*opus/i,pricing:{input:5,output:25,cached:.5,reasoning:25,cache_creation:6.25}},{pattern:/claude-.*sonnet-5/i,pricing:{input:2,output:10,cached:.2,reasoning:10,cache_creation:2.5}},{pattern:/claude-.*sonnet/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75}},{pattern:/claude-.*haiku-5[.-]5/i,pricing:{input:.1,output:.5,cached:.01,reasoning:.5,cache_creation:.125}},{pattern:/claude-.*haiku/i,pricing:{input:.8,output:4,cached:.08,reasoning:4,cache_creation:1}},{pattern:/claude/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75}},{pattern:/gemini-.*flash/i,pricing:{input:.3,output:2.5,cached:.03,reasoning:3.75,cache_creation:.3}},{pattern:/gemini-.*pro/i,pricing:{input:2,output:12,cached:.25,reasoning:18,cache_creation:2}},{pattern:/gemini/i,pricing:{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5}},{pattern:/deepseek.*v4.*pro/i,pricing:{input:.66,output:1.98,cached:.066,reasoning:1.98,cache_creation:.66}},{pattern:/deepseek.*v4/i,pricing:{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14}},{pattern:/deepseek.*reason/i,pricing:{input:.55,output:2.19,cached:.14,reasoning:2.19,cache_creation:.55}},{pattern:/deepseek/i,pricing:{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14}},{pattern:/gpt-6.*terra/i,pricing:{input:1,output:5,cached:.05,reasoning:5,cache_creation:1}},{pattern:/gpt-6/i,pricing:{input:2,output:10,cached:.1,reasoning:10,cache_creation:2}},{pattern:/gpt-5[.-]6-luna/i,pricing:{input:.2,output:1.2,cached:.02,reasoning:1.2,cache_creation:.2}},{pattern:/gpt-5[.-]6-terra/i,pricing:{input:2,output:12,cached:.2,reasoning:12,cache_creation:2}},{pattern:/gpt-5[.-]6-sol/i,pricing:{input:4,output:20,cached:.4,reasoning:20,cache_creation:4}},{pattern:/gpt-5[.-]5/i,pricing:{input:5,output:30,cached:.5,reasoning:30,cache_creation:5}},{pattern:/gpt-5[.-]4/i,pricing:{input:2.5,output:15,cached:.25,reasoning:15,cache_creation:2.5}},{pattern:/gpt-4o/i,pricing:{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5}},{pattern:/gpt-5/i,pricing:{input:1.25,output:10,cached:.625,reasoning:10,cache_creation:1.25}},{pattern:/gpt-4/i,pricing:{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5}},{pattern:/o1/i,pricing:{input:15,output:60,cached:7.5,reasoning:90,cache_creation:15}},{pattern:/o3/i,pricing:{input:1.1,output:4.4,cached:.55,reasoning:4.4,cache_creation:1.1}},{pattern:/qwen.*turbo/i,pricing:{input:.05,output:.2,cached:.01,reasoning:.2,cache_creation:.05}},{pattern:/qwen.*(3[.-]8|3)-max/i,pricing:{input:2,output:6,cached:.4,reasoning:6,cache_creation:2}},{pattern:/qwen.*max/i,pricing:{input:1.6,output:6.4,cached:.4,reasoning:6.4,cache_creation:1.6}},{pattern:/qwen.*plus/i,pricing:{input:.4,output:1.2,cached:.1,reasoning:1.2,cache_creation:.4}},{pattern:/qwen.*coder.*7b/i,pricing:{input:.03,output:.1,cached:.005,reasoning:.1,cache_creation:.03}},{pattern:/qwen/i,pricing:{input:.4,output:1.2,cached:.1,reasoning:1.2,cache_creation:.4}}],l=new Map;for(const[e,n]of Object.entries(g)){const t=m(e);l.has(t)||l.set(t,n)}function q(e,n){if(!n)return null;if($(n))return k;const t=w(n);for(const c of t)if(g[c])return g[c];if(g[n])return g[n];for(const c of t){const u=l.get(m(c));if(u)return u}for(const{pattern:c,pricing:u}of T){if(c.test(n))return u;for(const a of t)if(c.test(a))return u}return{input:1,output:4,cached:.2,cache_creation:1}}s(q,"getPricingForModel");function E(e,n,t){if(!e)return 0;const c=q(t,n);if(!c)return 0;const u=e.promptTokens??e.prompt_tokens??0,a=e.cachedTokens??e.cached_tokens??0,i=e.cacheCreationTokens??e.cache_creation_input_tokens??0,p=e.completionTokens??e.completion_tokens??0,r=e.reasoningTokens??e.reasoning_tokens??0,h=Math.max(0,u-a-i);let o=0;o+=h*(c.input/1e6),a>0&&(o+=a*(c.cached/1e6)),i>0&&(o+=i*((c.cache_creation??c.input)/1e6));const d=c.reasoning?Math.max(0,p-r):p;return o+=d*(c.output/1e6),r>0&&c.reasoning&&(o+=r*(c.reasoning/1e6)),Number(o.toFixed(6))}s(E,"calculateCostFromTokens");function M(e){return!e||isNaN(e)||e<0?"$0.00":e<.01&&e>0?"<$0.01":`$${e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}s(M,"formatCost");export{b as FREE_MODEL_NAMESPACES,g as MODEL_PRICING,x as MODEL_SUFFIX_REGEX,T as PATTERN_PRICING,k as ZERO_PRICING,E as calculateCostFromTokens,w as extractModelPricingCandidates,M as formatCost,q as getPricingForModel,$ as isFreeModel};
|
|
1
|
+
var f=Object.defineProperty;var s=(e,n)=>f(e,"name",{value:n,configurable:!0});import{normalizeModelCompareKey as m}from"../../shared/utils/modelUtils.js";const k={input:0,output:0,cached:0,reasoning:0,cache_creation:0},x=/[-:_.](high|medium|low|extra-low|thinking|reasoning|free|beta|exact|preview|latest|extended|instruct|chat|turbo|online|search|tiered|v\d+|\d{8}|\d{4}-\d{2}-\d{2})$/i;function w(e){if(!e)return[];let n=e.includes("/")?e.split("/").pop():e;n=n.trim().toLowerCase(),n=n.replace(/\[[^\]]+\]/g,"");const t=[];n&&t.push(n);let c=n,u=!0;for(;u;){const i=c.match(x);i&&i.index!==void 0&&i.index>0?(c=c.slice(0,i.index),c&&!t.includes(c)&&t.push(c)):u=!1}const a=[];for(const i of t){const p=i.replace(/(\d+)-(\d+)/g,"$1.$2");p!==i&&!t.includes(p)&&!a.includes(p)&&a.push(p);const r=i.replace(/(\d+)\.(\d+)/g,"$1-$2");r!==i&&!t.includes(r)&&!a.includes(r)&&a.push(r);const h=i.replace(/claude-(opus|sonnet|haiku)-(\d+)-(\d+)/g,"claude-$1-$2.$3");h!==i&&!t.includes(h)&&!a.includes(h)&&a.push(h);const o=i.replace(/claude-(opus|sonnet|haiku)-(\d+)\.(\d+)/g,"claude-$1-$2-$3");if(o!==i&&!t.includes(o)&&!a.includes(o)&&a.push(o),i.includes("-")){const d=i.split("-");if(d.length>1){const _=d.slice(1).join("-");_&&!t.includes(_)&&!a.includes(_)&&a.push(_)}}}return[...t,...a]}s(w,"extractModelPricingCandidates");const b=["cline-free/","free/","local/"];function $(e){if(!e)return!1;const n=e.toLowerCase();return b.some(t=>n.startsWith(t))}s($,"isFreeModel");const g={"claude-fable-5.1":{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5},"claude-fable-5":{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5},"claude-mythos-5.1":{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5},"claude-mythos-5":{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5},"claude-opus-5.5":{input:4,output:20,cached:.4,reasoning:20,cache_creation:5},"claude-opus-5":{input:5,output:25,cached:.5,reasoning:25,cache_creation:6.25},"claude-opus-4-6":{input:5,output:25,cached:.5,reasoning:25,cache_creation:6.25},"claude-opus-4.5":{input:5,output:25,cached:.5,reasoning:25,cache_creation:6.25},"claude-opus-4.1":{input:15,output:75,cached:1.5,reasoning:75,cache_creation:18.75},"claude-opus-4":{input:15,output:25,cached:7.5,reasoning:112.5,cache_creation:15},"claude-sonnet-5.5":{input:2,output:10,cached:.2,reasoning:10,cache_creation:2.5},"claude-sonnet-5":{input:2,output:10,cached:.2,reasoning:10,cache_creation:2.5},"claude-sonnet-4-6":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-sonnet-4.5":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-sonnet-4":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-haiku-5.5":{input:.1,output:.5,cached:.01,reasoning:.5,cache_creation:.125},"claude-haiku-4.5":{input:1,output:5,cached:.1,reasoning:5,cache_creation:1.25},"claude-3.7-sonnet":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-3-7-sonnet":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-3.5-sonnet":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-3-5-sonnet":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75},"claude-3.5-haiku":{input:.8,output:4,cached:.08,reasoning:4,cache_creation:1},"claude-3-5-haiku":{input:.8,output:4,cached:.08,reasoning:4,cache_creation:1},"claude-3-opus":{input:15,output:75,cached:1.5,reasoning:75,cache_creation:18.75},"claude-3-haiku":{input:.25,output:1.25,cached:.025,reasoning:1.25,cache_creation:.3125},"gpt-4o":{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5},"gpt-4o-mini":{input:.15,output:.6,cached:.075,reasoning:.9,cache_creation:.15},"gpt-4.1":{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5},"gpt-5":{input:1.25,output:10,cached:.625,reasoning:10,cache_creation:1.25},"gpt-5-mini":{input:.25,output:2,cached:.125,reasoning:2,cache_creation:.25},"gpt-5-codex":{input:1.25,output:10,cached:.625,reasoning:10,cache_creation:1.25},"gpt-5.1-codex":{input:1.25,output:10,cached:.625,reasoning:10,cache_creation:1.25},"gpt-5.1-codex-mini":{input:1.5,output:6,cached:.75,reasoning:9,cache_creation:1.5},"gpt-5.2-codex":{input:1.75,output:14,cached:.175,reasoning:14,cache_creation:1.75},"gpt-5.3-codex":{input:1.75,output:14,cached:.175,reasoning:14,cache_creation:1.75},"gpt-5.3-codex-spark":{input:3,output:12,cached:.3,reasoning:12,cache_creation:3},"gpt-5.4":{input:2.5,output:15,cached:.25,reasoning:15,cache_creation:2.5},"gpt-5.4-mini":{input:.25,output:1.5,cached:.025,reasoning:1.5,cache_creation:.25},"gpt-5.5":{input:5,output:30,cached:.5,reasoning:30,cache_creation:5},"gpt-5.6":{input:2.5,output:15,cached:.25,reasoning:15,cache_creation:2.5},"gpt-5.6-luna":{input:.2,output:1.2,cached:.02,reasoning:1.2,cache_creation:.2},"gpt-5.6-terra":{input:2,output:12,cached:.2,reasoning:12,cache_creation:2},"gpt-5.6-sol":{input:4,output:20,cached:.4,reasoning:20,cache_creation:4},"gpt-6.1-sol":{input:2,output:10,cached:.1,reasoning:10,cache_creation:2},"gpt-6.1-terra":{input:1,output:5,cached:.05,reasoning:5,cache_creation:1},"gpt-6-astra":{input:2,output:10,cached:.1,reasoning:10,cache_creation:2},o1:{input:15,output:60,cached:7.5,reasoning:90,cache_creation:15},"o1-mini":{input:3,output:12,cached:1.5,reasoning:18,cache_creation:3},o3:{input:2,output:8,cached:.5,reasoning:8,cache_creation:2},"o3-mini":{input:1.1,output:4.4,cached:.55,reasoning:4.4,cache_creation:1.1},"o4-mini":{input:1.1,output:4.4,cached:.275,reasoning:4.4,cache_creation:1.1},"gemini-2.5-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-flash":{input:.15,output:.6,cached:.0375,reasoning:.6,cache_creation:.15},"gemini-3-flash":{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5},"gemini-3-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-3.7-flash":{input:1.5,output:7.5,cached:.15,reasoning:11.25,cache_creation:1.875},"gemini-3.8-flash":{input:1.5,output:7.5,cached:.15,reasoning:11.25,cache_creation:1.875},"gemini-4-argon":{input:2,output:10,cached:.1,reasoning:10,cache_creation:2},"gemini-4-carbon":{input:2,output:10,cached:.1,reasoning:10,cache_creation:2},"gemini-4-hydrogen":{input:1.5,output:7.5,cached:.075,reasoning:7.5,cache_creation:1.5},"gemini-4-neon":{input:3,output:15,cached:.15,reasoning:15,cache_creation:3},"deepseek-chat":{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14},"deepseek-reasoner":{input:.55,output:2.19,cached:.14,reasoning:2.19,cache_creation:.55},"deepseek-r1":{input:.55,output:2.19,cached:.14,reasoning:2.19,cache_creation:.55},"deepseek-v3":{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14},"deepseek-v4.1-flash":{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14},"deepseek-v4-pro":{input:.66,output:1.98,cached:.066,reasoning:1.98,cache_creation:.66},"qwen-turbo":{input:.05,output:.2,cached:.01,reasoning:.2,cache_creation:.05},"qwen-2.5-coder-32b":{input:.07,output:.2,cached:.01,reasoning:.2,cache_creation:.07},"qwen-2.5-coder-7b":{input:.03,output:.1,cached:.005,reasoning:.1,cache_creation:.03},"qwen-coder-plus":{input:.4,output:1.2,cached:.1,reasoning:1.2,cache_creation:.4},"qwen-plus":{input:.4,output:1.2,cached:.1,reasoning:1.2,cache_creation:.4},"qwen3.7-plus":{input:.4,output:1.6,cached:.1,reasoning:1.6,cache_creation:.4},"qwen-max":{input:1.6,output:6.4,cached:.4,reasoning:6.4,cache_creation:1.6},"qwen3.8-max":{input:2,output:6,cached:.4,reasoning:6,cache_creation:2},"mimo-v2.6-pro":{input:.435,output:.87,cached:.0036,reasoning:.87,cache_creation:.435},"mimo-v2.6-flash":{input:.14,output:.28,cached:.0028,reasoning:.28,cache_creation:.14},"mimo-v2.5":{input:.14,output:.28,cached:.0028,reasoning:.28,cache_creation:.14},"mimo-v2":{input:.14,output:.28,cached:.0028,reasoning:.28,cache_creation:.14},"k3.1-pro":{input:2,output:10,cached:.2,reasoning:10,cache_creation:2},"kimi-k3.1-pro":{input:2,output:10,cached:.2,reasoning:10,cache_creation:2},"k3.1-pro-highspeed":{input:4,output:20,cached:.2,reasoning:20,cache_creation:4},"kimi-k3.1-pro-highspeed":{input:4,output:20,cached:.2,reasoning:20,cache_creation:4},k3:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-k3":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-for-coding":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-for-coding-highspeed":{input:4,output:20,cached:.2,reasoning:20,cache_creation:4},"kimi-k2.7-code":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-k2.6":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"kimi-k2.5":{input:3,output:15,cached:.3,reasoning:15,cache_creation:3},"minimax-m3":{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3},"minimax-m3.1-flash":{input:.15,output:.6,cached:.03,reasoning:.6,cache_creation:.15},"minimax-m2.7":{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3},"minimax-m2.5":{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3},"minimax-m2.1":{input:.2,output:1.1,cached:.04,reasoning:1.1,cache_creation:.2},"minimax-text-01":{input:.2,output:1.1,cached:.04,reasoning:1.1,cache_creation:.2}},T=[{pattern:/minimax.*flash/i,pricing:{input:.15,output:.6,cached:.03,reasoning:.6,cache_creation:.15}},{pattern:/minimax.*(m3|m2\.7|m2\.5)/i,pricing:{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3}},{pattern:/minimax/i,pricing:{input:.3,output:1.2,cached:.06,reasoning:1.2,cache_creation:.3}},{pattern:/gemini-4-(argon|carbon)/i,pricing:{input:2,output:10,cached:.1,reasoning:10,cache_creation:2}},{pattern:/(argon|carbon)/i,pricing:{input:2,output:10,cached:.1,reasoning:10,cache_creation:2}},{pattern:/gemini-4-neon/i,pricing:{input:3,output:15,cached:.15,reasoning:15,cache_creation:3}},{pattern:/neon/i,pricing:{input:3,output:15,cached:.15,reasoning:15,cache_creation:3}},{pattern:/gemini-4-hydrogen/i,pricing:{input:1.5,output:7.5,cached:.075,reasoning:7.5,cache_creation:1.5}},{pattern:/hydrogen/i,pricing:{input:1.5,output:7.5,cached:.075,reasoning:7.5,cache_creation:1.5}},{pattern:/k3[.-]1.*highspeed/i,pricing:{input:4,output:20,cached:.2,reasoning:20,cache_creation:4}},{pattern:/kimi.*highspeed/i,pricing:{input:4,output:20,cached:.2,reasoning:20,cache_creation:4}},{pattern:/k3[.-]1/i,pricing:{input:2,output:10,cached:.2,reasoning:10,cache_creation:2}},{pattern:/kimi.*k3[.-]1/i,pricing:{input:2,output:10,cached:.2,reasoning:10,cache_creation:2}},{pattern:/kimi.*k3/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3}},{pattern:/^k3$/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3}},{pattern:/kimi/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3}},{pattern:/moonshot/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3}},{pattern:/mimo.*pro/i,pricing:{input:.435,output:.87,cached:.0036,reasoning:.87,cache_creation:.435}},{pattern:/mimo/i,pricing:{input:.14,output:.28,cached:.0028,reasoning:.28,cache_creation:.14}},{pattern:/codex/i,pricing:{input:1.75,output:14,cached:.175,reasoning:14,cache_creation:1.75}},{pattern:/claude-.*(fable|mythos)/i,pricing:{input:10,output:50,cached:1,reasoning:50,cache_creation:12.5}},{pattern:/claude-.*opus-5[.-]5/i,pricing:{input:4,output:20,cached:.4,reasoning:20,cache_creation:5}},{pattern:/claude-.*opus/i,pricing:{input:5,output:25,cached:.5,reasoning:25,cache_creation:6.25}},{pattern:/claude-.*sonnet-5/i,pricing:{input:2,output:10,cached:.2,reasoning:10,cache_creation:2.5}},{pattern:/claude-.*sonnet/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75}},{pattern:/claude-.*haiku-5[.-]5/i,pricing:{input:.1,output:.5,cached:.01,reasoning:.5,cache_creation:.125}},{pattern:/claude-.*haiku/i,pricing:{input:.8,output:4,cached:.08,reasoning:4,cache_creation:1}},{pattern:/claude/i,pricing:{input:3,output:15,cached:.3,reasoning:15,cache_creation:3.75}},{pattern:/gemini-.*flash/i,pricing:{input:.3,output:2.5,cached:.03,reasoning:3.75,cache_creation:.3}},{pattern:/gemini-.*pro/i,pricing:{input:2,output:12,cached:.25,reasoning:18,cache_creation:2}},{pattern:/gemini/i,pricing:{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5}},{pattern:/deepseek.*v4.*pro/i,pricing:{input:.66,output:1.98,cached:.066,reasoning:1.98,cache_creation:.66}},{pattern:/deepseek.*v4/i,pricing:{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14}},{pattern:/deepseek.*reason/i,pricing:{input:.55,output:2.19,cached:.14,reasoning:2.19,cache_creation:.55}},{pattern:/deepseek/i,pricing:{input:.14,output:.28,cached:.014,reasoning:.28,cache_creation:.14}},{pattern:/gpt-6.*terra/i,pricing:{input:1,output:5,cached:.05,reasoning:5,cache_creation:1}},{pattern:/gpt-6/i,pricing:{input:2,output:10,cached:.1,reasoning:10,cache_creation:2}},{pattern:/gpt-5[.-]6-luna/i,pricing:{input:.2,output:1.2,cached:.02,reasoning:1.2,cache_creation:.2}},{pattern:/gpt-5[.-]6-terra/i,pricing:{input:2,output:12,cached:.2,reasoning:12,cache_creation:2}},{pattern:/gpt-5[.-]6-sol/i,pricing:{input:4,output:20,cached:.4,reasoning:20,cache_creation:4}},{pattern:/gpt-5[.-]5/i,pricing:{input:5,output:30,cached:.5,reasoning:30,cache_creation:5}},{pattern:/gpt-5[.-]4/i,pricing:{input:2.5,output:15,cached:.25,reasoning:15,cache_creation:2.5}},{pattern:/gpt-4o/i,pricing:{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5}},{pattern:/gpt-5/i,pricing:{input:1.25,output:10,cached:.625,reasoning:10,cache_creation:1.25}},{pattern:/gpt-4/i,pricing:{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5}},{pattern:/o1/i,pricing:{input:15,output:60,cached:7.5,reasoning:90,cache_creation:15}},{pattern:/o3/i,pricing:{input:1.1,output:4.4,cached:.55,reasoning:4.4,cache_creation:1.1}},{pattern:/qwen.*turbo/i,pricing:{input:.05,output:.2,cached:.01,reasoning:.2,cache_creation:.05}},{pattern:/qwen.*(3[.-]8|3)-max/i,pricing:{input:2,output:6,cached:.4,reasoning:6,cache_creation:2}},{pattern:/qwen.*max/i,pricing:{input:1.6,output:6.4,cached:.4,reasoning:6.4,cache_creation:1.6}},{pattern:/qwen.*plus/i,pricing:{input:.4,output:1.2,cached:.1,reasoning:1.2,cache_creation:.4}},{pattern:/qwen.*coder.*7b/i,pricing:{input:.03,output:.1,cached:.005,reasoning:.1,cache_creation:.03}},{pattern:/qwen/i,pricing:{input:.4,output:1.2,cached:.1,reasoning:1.2,cache_creation:.4}}],l=new Map;for(const[e,n]of Object.entries(g)){const t=m(e);l.has(t)||l.set(t,n)}function q(e,n){if(!n)return null;if($(n))return k;const t=w(n);for(const c of t)if(g[c])return g[c];if(g[n])return g[n];for(const c of t){const u=l.get(m(c));if(u)return u}for(const{pattern:c,pricing:u}of T){if(c.test(n))return u;for(const a of t)if(c.test(a))return u}return{input:1,output:4,cached:.2,cache_creation:1}}s(q,"getPricingForModel");function E(e,n,t){if(!e)return 0;const c=q(t,n);if(!c)return 0;const u=e.promptTokens??e.prompt_tokens??0,a=e.cachedTokens??e.cached_tokens??0,i=e.cacheCreationTokens??e.cache_creation_input_tokens??0,p=e.completionTokens??e.completion_tokens??0,r=e.reasoningTokens??e.reasoning_tokens??0,h=Math.max(0,u-a-i);let o=0;o+=h*(c.input/1e6),a>0&&(o+=a*(c.cached/1e6)),i>0&&(o+=i*((c.cache_creation??c.input)/1e6));const d=c.reasoning?Math.max(0,p-r):p;return o+=d*(c.output/1e6),r>0&&c.reasoning&&(o+=r*(c.reasoning/1e6)),Number(o.toFixed(6))}s(E,"calculateCostFromTokens");function M(e){return!e||isNaN(e)||e<0?"$0.00":e<.01&&e>0?"<$0.01":`$${e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}s(M,"formatCost");export{b as FREE_MODEL_NAMESPACES,g as MODEL_PRICING,x as MODEL_SUFFIX_REGEX,T as PATTERN_PRICING,k as ZERO_PRICING,E as calculateCostFromTokens,w as extractModelPricingCandidates,M as formatCost,q as getPricingForModel,$ as isFreeModel};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`),i.stdin.end())})}d($,"execWithPassword");async function N(t){h||(L?await $("dscacheutil -flushcache && killall -HUP mDNSResponder",t):await $("resolvectl flush-caches 2>/dev/null || true",t))}d(N,"flushDNS");function Q(){try{if(!f.existsSync(u))return{antigravity:!1,kiro:!1,copilot:!1};const t=f.readFileSync(u,"utf8"),s={};for(const n of Object.keys(m)){const o=g(n),r=o.length>0?Array.from(new Set(o.flatMap(i=>i.split(/\s+/).slice(1)))):m[n]||[];s[n]=r.length>0&&r.every(i=>C(t,i))}return s}catch{return{antigravity:!1,kiro:!1,copilot:!1}}}d(Q,"checkAllDNSStatus");async function K(t,s){const n=t.map(e=>e.toLowerCase()).filter(e=>!!m[e]);if(n.length===0)return;const o=f.existsSync(u)?f.readFileSync(u,"utf8"):"",r=o.split(/\r?\n/),i=[],c=[];for(const e of n){const l=g(e);for(const p of l){const a=p.split(/\s+/).filter(Boolean);if(a.length<2)continue;const y=a[0],x=a[1];!r.some(I=>{const D=I.trim();if(D.startsWith("#"))return!1;const v=D.split(/\s+/).filter(Boolean);return v.length>=2&&v[0]===y&&v.includes(x)})&&!i.includes(p)&&(i.push(p),c.includes(x)||c.push(x))}}if(i.length===0){console.log(`[MITM DNS] Tools (${n.join(", ")}): already active in hosts file`);return}try{const e=h?`\r
|
|
1
|
+
var A=Object.defineProperty;var d=(t,s)=>A(t,"name",{value:s,configurable:!0});import{execSync as S,spawn as M}from"node:child_process";import a from"node:fs";import j from"node:os";import H from"node:path";import{TOOL_HOSTS as h}from"../../shared/constants/mitmToolHosts.js";import{MitmRepository as C}from"../../storage/repositories/mitmRepo.js";import{runElevatedPowerShell as O,isAdmin as E,quotePs as k}from"./winElevated.js";const m=process.platform==="win32",F=process.platform==="darwin",u=m?H.join(process.env.SystemRoot||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts";function b(t,s="127.0.0.1"){return[`${s} ${t}`]}d(b,"dnsLines");function K(t,s){return t.split(/\r?\n/).some(o=>{const r=o.trim();if(r.startsWith("#"))return!1;const i=r.split(/\s+/).filter(Boolean);if(i.length<2)return!1;const c=i[0];return(c==="127.0.0.1"||c==="::1"||c.startsWith("127."))&&i.slice(1).includes(s)})}d(K,"hasHostEntry");function w(t){let s="";try{s=C.getToolHosts(t)}catch{}return s?s.split(/\r?\n/).map(n=>n.trim()).filter(n=>n&&!n.startsWith("#")):(h[t]||[]).flatMap(o=>b(o))}d(w,"getToolConfiguredLines");function g(t,s){const n=t.trim();if(n.startsWith("#"))return!1;const o=n.split(/\s+/).filter(Boolean);return o.length<2?!1:s.some(r=>o.slice(1).includes(r))}d(g,"isLineMatchingHosts");function I(t,s,n){const o=`${t}.mapigate.new`,r=`${t}.mapigate.bak`;try{a.writeFileSync(o,n,"utf8");try{a.unlinkSync(r)}catch{}a.renameSync(t,r);try{a.renameSync(o,t)}catch(i){try{a.renameSync(r,t)}catch{a.writeFileSync(t,s,"utf8")}throw i}try{a.unlinkSync(r)}catch{}}finally{try{a.unlinkSync(o)}catch{}}}d(I,"atomicWriteHostsWin");async function N(t,s,n){if(E()){I(t,s,n);try{S("ipconfig /flushdns",{windowsHide:!0,stdio:"ignore"})}catch{}return}const o=a.mkdtempSync(H.join(j.tmpdir(),"mapigate-hosts-")),r=H.join(o,"hosts");a.writeFileSync(r,n,"utf8");try{const i=`
|
|
2
|
+
Copy-Item -Path ${k(r)} -Destination ${k(t)} -Force;
|
|
3
|
+
ipconfig /flushdns | Out-Null;
|
|
4
|
+
`;await O(i)}finally{try{a.rmSync(o,{recursive:!0,force:!0})}catch{}}}d(N,"writeHostsFileWin");function T(){if(m)return!1;try{return S("command -v sudo",{stdio:"ignore",windowsHide:!0}),!0}catch{return!1}}d(T,"isSudoAvailable");function B(){if(m||!T())return!0;try{return S("sudo -n true",{stdio:"ignore",windowsHide:!0}),!0}catch{return!1}}d(B,"canRunSudoWithoutPassword");function X(){return!m&&T()&&!B()}d(X,"isSudoPasswordRequired");function $(t,s){return new Promise((n,o)=>{const r=T(),i=r?s?M("sudo",["-S","sh","-c",t],{stdio:["pipe","pipe","pipe"],windowsHide:!0}):M("sudo",["-n","sh","-c",t],{stdio:["ignore","pipe","pipe"],windowsHide:!0}):M("sh",["-c",t],{stdio:["ignore","pipe","pipe"],windowsHide:!0});let c="",e="",l=!1;const p=setTimeout(()=>{if(!l){l=!0;try{i.kill("SIGKILL")}catch{}o(new Error("Command timed out after 15 seconds"))}},15e3);i.stdout?.on("data",f=>{c+=f.toString()}),i.stderr?.on("data",f=>{e+=f.toString()}),i.on("error",f=>{l||(l=!0,clearTimeout(p),o(f))}),i.on("close",f=>{l||(l=!0,clearTimeout(p),f===0?n(c):o(new Error(e||`Exit code ${f}`)))}),r&&s&&i.stdin&&(i.stdin.write(`${s}
|
|
5
|
+
`),i.stdin.end())})}d($,"execWithPassword");async function D(t){m||(F?await $("dscacheutil -flushcache && killall -HUP mDNSResponder",t):await $("resolvectl flush-caches 2>/dev/null || true",t))}d(D,"flushDNS");function Y(){try{if(!a.existsSync(u))return{antigravity:!1,kiro:!1,copilot:!1};const t=a.readFileSync(u,"utf8"),s={};for(const n of Object.keys(h)){const o=w(n),r=o.length>0?Array.from(new Set(o.flatMap(i=>i.split(/\s+/).slice(1)))):h[n]||[];s[n]=r.length>0&&r.every(i=>K(t,i))}return s}catch{return{antigravity:!1,kiro:!1,copilot:!1}}}d(Y,"checkAllDNSStatus");async function P(t,s){const n=t.map(e=>e.toLowerCase()).filter(e=>!!h[e]);if(n.length===0)return;const o=a.existsSync(u)?a.readFileSync(u,"utf8"):"",r=o.split(/\r?\n/),i=[],c=[];for(const e of n){const l=w(e);for(const p of l){const f=p.split(/\s+/).filter(Boolean);if(f.length<2)continue;const y=f[0],x=f[1];!r.some(W=>{const L=W.trim();if(L.startsWith("#"))return!1;const v=L.split(/\s+/).filter(Boolean);return v.length>=2&&v[0]===y&&v.includes(x)})&&!i.includes(p)&&(i.push(p),c.includes(x)||c.push(x))}}if(i.length===0){console.log(`[MITM DNS] Tools (${n.join(", ")}): already active in hosts file`);return}try{const e=m?`\r
|
|
7
6
|
`:`
|
|
8
|
-
`,l=o.replace(/[\r\n\s]+$/g,""),p=i.join(e),
|
|
7
|
+
`,l=o.replace(/[\r\n\s]+$/g,""),p=i.join(e),f=l?`${l}${e}${p}${e}`:`${p}${e}`;if(m)await N(u,o,f);else{const y=f.replace(/'/g,"'\\''");await $(`printf '%s' '${y}' | tee ${u} > /dev/null`,s),await D(s)}console.log(`[MITM DNS] Tools (${n.join(", ")}): added entries for ${c.join(", ")}`)}catch(e){const l=e.message?.includes("incorrect password")?"Wrong sudo password":`Failed to add DNS entries: ${e.message}`;throw new Error(l)}}d(P,"addMultipleDNSEntries");async function Z(t,s){const n=t.toLowerCase();if(!h[n])throw new Error(`Unknown tool: ${t}`);await P([n],s)}d(Z,"addDNSEntry");async function tt(t,s){const n=t.toLowerCase(),o=w(n).map(e=>e.split(/\s+/).slice(1)).flat(),r=Array.from(new Set([...h[n]||[],...o]));if(r.length===0)throw new Error(`Unknown tool: ${t}`);const i=a.existsSync(u)?a.readFileSync(u,"utf8"):"";if(!i.split(/\r?\n/).some(e=>g(e,r))){console.log(`[MITM DNS] ${t}: already inactive in hosts file`);return}try{const e=m?`\r
|
|
9
8
|
`:`
|
|
10
|
-
`,p=i.split(/\r?\n/).filter(y=>!
|
|
9
|
+
`,p=i.split(/\r?\n/).filter(y=>!g(y,r)).join(e).replace(/[\r\n\s]+$/g,""),f=p?`${p}${e}`:"";if(m)await N(u,i,f);else{const y=f.replace(/'/g,"'\\''");await $(`printf '%s' '${y}' | tee ${u} > /dev/null`,s),await D(s)}console.log(`[MITM DNS] ${t}: removed entries for ${r.join(", ")}`)}catch(e){const l=e.message?.includes("incorrect password")?"Wrong sudo password":`Failed to remove DNS entry: ${e.message}`;throw new Error(l)}}d(tt,"removeDNSEntry");async function et(t){const s=a.existsSync(u)?a.readFileSync(u,"utf8"):"",o=Object.keys(h).flatMap(c=>w(c).flatMap(e=>e.split(/\s+/).slice(1))),r=Array.from(new Set([...Object.values(h).flat(),...o]));if(!s.split(/\r?\n/).some(c=>g(c,r))){console.log("[MITM DNS] All tools: already inactive in hosts file");return}try{const c=m?`\r
|
|
11
10
|
`:`
|
|
12
|
-
`,l=s.split(/\r?\n/).filter(
|
|
11
|
+
`,l=s.split(/\r?\n/).filter(f=>!g(f,r)).join(c).replace(/[\r\n\s]+$/g,""),p=l?`${l}${c}`:"";if(m)await N(u,s,p);else{const f=p.replace(/'/g,"'\\''");await $(`printf '%s' '${f}' | tee ${u} > /dev/null`,t),await D(t)}console.log("[MITM DNS] All tools: removed hosts entries in single operation")}catch(c){const e=c.message?.includes("incorrect password")?"Wrong sudo password":`Failed to remove DNS entries: ${c.message}`;throw console.error(`[MITM DNS] ${e}`),new Error(e)}}d(et,"removeAllDNSEntries");function st(){try{if(!a.existsSync(u))return;const s=Object.keys(h).flatMap(l=>w(l).flatMap(p=>p.split(/\s+/).slice(1))),n=Array.from(new Set([...Object.values(h).flat(),...s])),o=a.readFileSync(u,"utf8"),r=m?`\r
|
|
13
12
|
`:`
|
|
14
|
-
`,c=o.split(/\r?\n/).filter(l=>!
|
|
13
|
+
`,c=o.split(/\r?\n/).filter(l=>!g(l,n)).join(r).replace(/[\r\n\s]+$/g,""),e=c?`${c}${r}`:"";if(e===o)return;if(m&&E())try{I(u,o,e)}catch{a.writeFileSync(u,e,"utf8")}else a.writeFileSync(u,e,"utf8");if(m)try{S("ipconfig /flushdns",{windowsHide:!0,stdio:"ignore"})}catch{}else if(F)try{S("dscacheutil -flushcache && killall -HUP mDNSResponder",{stdio:"ignore"})}catch{}else try{S("resolvectl flush-caches 2>/dev/null || true",{stdio:"ignore"})}catch{}}catch(t){process.env.NODE_ENV!=="test"&&console.warn(`[MITM DNS] Warning: Could not clean up hosts file synchronously on exit (${t?.message||t}). Administrator privileges may be required to modify ${u}.`)}}d(st,"removeAllDNSEntriesSync");export{u as HOSTS_FILE,Z as addDNSEntry,P as addMultipleDNSEntries,I as atomicWriteHostsWin,B as canRunSudoWithoutPassword,Y as checkAllDNSStatus,b as dnsLines,$ as execWithPassword,D as flushDNS,w as getToolConfiguredLines,K as hasHostEntry,T as isSudoAvailable,X as isSudoPasswordRequired,et as removeAllDNSEntries,st as removeAllDNSEntriesSync,tt as removeDNSEntry};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
127.0.0.1 cloudcode-pa.googleapis.com`,hostRewrite:{"cloudcode-pa.googleapis.com":"daily-cloudcode-pa.googleapis.com"},matchesHost:
|
|
1
|
+
var a=Object.defineProperty;var n=(i,e)=>a(i,"name",{value:e,configurable:!0});const g={id:"antigravity",name:"Antigravity IDE",image:"/assets/providers/antigravity/icon.png",desc:"Intercept Google Antigravity IDE requests via MITM proxy",hosts:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],urlPatterns:[":generateContent",":streamGenerateContent",":fetchAvailableModels","/v1internal:fetchAvailableModels"],defaultHost:`127.0.0.1 daily-cloudcode-pa.googleapis.com
|
|
2
|
+
127.0.0.1 cloudcode-pa.googleapis.com`,hostRewrite:{"cloudcode-pa.googleapis.com":"daily-cloudcode-pa.googleapis.com"},matchesHost:n(i=>{const e=(i||"").split(":")[0].trim().toLowerCase();return["cloudcode-pa.googleapis.com","daily-cloudcode-pa.googleapis.com"].some(o=>e===o||e.endsWith("."+o))},"matchesHost"),isModelListRequest:n(i=>(i.url||"").toLowerCase().includes("fetchavailablemodels"),"isModelListRequest"),modelSynonyms:{"gemini-default":"gemini-3.8-flash-medium","gemini-3.5-flash-high":"gemini-3.8-flash-high","gemini-3.5-flash-medium":"gemini-3.8-flash-medium","gemini-3.5-flash-low":"gemini-3.8-flash-low","gemini-3.5-flash-extra-low":"gemini-3.8-flash-low","gemini-3.8-flash":"gemini-3.8-flash-medium","gemini-3.8-flash-high":"gemini-3.8-flash-high","gemini-3.8-flash-medium":"gemini-3.8-flash-medium","gemini-3.8-flash-low":"gemini-3.8-flash-low","gemini-3.1-pro-high":"gemini-pro-agent","gemini-3-pro-high":"gemini-pro-agent","gemini-3-pro-low":"gemini-3.1-pro-low","claude-sonnet-5-5-max":"claude-sonnet-5-5-max","claude-sonnet-5-5-high":"claude-sonnet-5-5-high","claude-sonnet-5-5-medium":"claude-sonnet-5-5-medium","claude-sonnet-5-5-low":"claude-sonnet-5-5-low","claude-sonnet-5-5":"claude-sonnet-5-5","claude-sonnet-5.5":"claude-sonnet-5-5","claude-sonnet-5.5-max":"claude-sonnet-5-5-max","claude-sonnet-5.5-high":"claude-sonnet-5-5-high","claude-sonnet-5.5-medium":"claude-sonnet-5-5-medium","claude-sonnet-5.5-low":"claude-sonnet-5-5-low","claude-sonnet-5-5-thinking":"claude-sonnet-5-5","claude-sonnet-5.5-thinking":"claude-sonnet-5-5","claude-opus-5-5-max":"claude-opus-5-5-max","claude-opus-5-5-high":"claude-opus-5-5-high","claude-opus-5-5-medium":"claude-opus-5-5-medium","claude-opus-5-5-low":"claude-opus-5-5-low","claude-opus-5-5":"claude-opus-5-5","claude-opus-5.5":"claude-opus-5-5","claude-opus-5.5-max":"claude-opus-5-5-max","claude-opus-5.5-high":"claude-opus-5-5-high","claude-opus-5.5-medium":"claude-opus-5-5-medium","claude-opus-5.5-low":"claude-opus-5-5-low","claude-opus-5-5-thinking":"claude-opus-5-5","claude-opus-5.5-thinking":"claude-opus-5-5","claude-sonnet-4.6":"claude-sonnet-4-6","claude-opus-4.6":"claude-opus-4-6-thinking","claude-opus-4.6-thinking":"claude-opus-4-6-thinking","gemini-4-argon":"gemini-4-argon-medium","gemini-4-argon-high":"gemini-4-argon-high","gemini-4-argon-medium":"gemini-4-argon-medium","gemini-4-argon-low":"gemini-4-argon-low","gemini-4-carbon":"gemini-4-carbon-medium","gemini-4-carbon-high":"gemini-4-carbon-high","gemini-4-carbon-medium":"gemini-4-carbon-medium","gemini-4-carbon-low":"gemini-4-carbon-low","gemini-4-hydrogen":"gemini-4-hydrogen-medium","gemini-4-hydrogen-xhigh":"gemini-4-hydrogen-xhigh","gemini-4-hydrogen-high":"gemini-4-hydrogen-high","gemini-4-hydrogen-medium":"gemini-4-hydrogen-medium","gemini-4-hydrogen-low":"gemini-4-hydrogen-low","gemini-4-neon":"gemini-4-neon-medium","gemini-4-neon-xhigh":"gemini-4-neon-xhigh","gemini-4-neon-high":"gemini-4-neon-high","gemini-4-neon-medium":"gemini-4-neon-medium","gemini-4-neon-low":"gemini-4-neon-low"},modelPatterns:[{match:/flash.*extra.*low|extra.*low.*flash|flash.*low|low.*flash/i,alias:"gemini-3.8-flash-low"},{match:/flash.*medium|medium.*flash/i,alias:"gemini-3.8-flash-medium"},{match:/flash.*agent|agent.*flash|flash/i,alias:"gemini-3.8-flash-high"},{match:/pro.*low|low.*pro/i,alias:"gemini-3.1-pro-low"},{match:/gemini.*pro|pro.*gemini/i,alias:"gemini-pro-agent"},{match:/opus.*5[.-]5.*max|5[.-]5.*opus.*max/i,alias:"claude-opus-5-5-max"},{match:/opus.*5[.-]5.*high|5[.-]5.*opus.*high/i,alias:"claude-opus-5-5-high"},{match:/opus.*5[.-]5.*medium|5[.-]5.*opus.*medium/i,alias:"claude-opus-5-5-medium"},{match:/opus.*5[.-]5.*low|5[.-]5.*opus.*low/i,alias:"claude-opus-5-5-low"},{match:/sonnet.*5[.-]5.*max|5[.-]5.*sonnet.*max/i,alias:"claude-sonnet-5-5-max"},{match:/sonnet.*5[.-]5.*high|5[.-]5.*sonnet.*high/i,alias:"claude-sonnet-5-5-high"},{match:/sonnet.*5[.-]5.*medium|5[.-]5.*sonnet.*medium/i,alias:"claude-sonnet-5-5-medium"},{match:/sonnet.*5[.-]5.*low|5[.-]5.*sonnet.*low/i,alias:"claude-sonnet-5-5-low"},{match:/opus.*5[.-]5|5[.-]5.*opus/i,alias:"claude-opus-5-5"},{match:/sonnet.*5[.-]5|5[.-]5.*sonnet/i,alias:"claude-sonnet-5-5"},{match:/opus/i,alias:"claude-opus-4-6-thinking"},{match:/sonnet|claude/i,alias:"claude-sonnet-4-6"},{match:/gpt.*oss|oss/i,alias:"gpt-oss-120b-medium"},{match:/carbon.*high/i,alias:"gemini-4-carbon-high"},{match:/carbon.*low/i,alias:"gemini-4-carbon-low"},{match:/carbon/i,alias:"gemini-4-carbon-medium"},{match:/hydrogen.*xhigh/i,alias:"gemini-4-hydrogen-xhigh"},{match:/hydrogen.*high/i,alias:"gemini-4-hydrogen-high"},{match:/hydrogen.*low/i,alias:"gemini-4-hydrogen-low"},{match:/hydrogen/i,alias:"gemini-4-hydrogen-medium"},{match:/neon.*xhigh/i,alias:"gemini-4-neon-xhigh"},{match:/neon.*high/i,alias:"gemini-4-neon-high"},{match:/neon.*low/i,alias:"gemini-4-neon-low"},{match:/neon/i,alias:"gemini-4-neon-medium"},{match:/argon.*high|gemini.*4.*high/i,alias:"gemini-4-argon-high"},{match:/argon.*low|gemini.*4.*low/i,alias:"gemini-4-argon-low"},{match:/argon|gemini.*4/i,alias:"gemini-4-argon-medium"}],modelNoMap:[/^tab[_-]/i],defaultModels:["gemini-4-argon","gemini-4-argon-high","gemini-4-argon-medium","gemini-4-argon-low","gemini-4-carbon","gemini-4-carbon-high","gemini-4-carbon-medium","gemini-4-carbon-low","gemini-4-hydrogen","gemini-4-hydrogen-xhigh","gemini-4-hydrogen-high","gemini-4-hydrogen-medium","gemini-4-hydrogen-low","gemini-4-neon","gemini-4-neon-xhigh","gemini-4-neon-high","gemini-4-neon-medium","gemini-4-neon-low","gemini-3.8-flash-high","gemini-3.8-flash-medium","gemini-3.8-flash-low","gemini-3.1-pro-high","gemini-3.1-pro-low","claude-sonnet-5.5-thinking","claude-sonnet-5.5-high","claude-sonnet-5.5-medium","claude-sonnet-5.5-low","claude-opus-5.5-thinking","claude-opus-5.5-high","claude-opus-5.5-medium","claude-opus-5.5-low","claude-sonnet-4.6-thinking","claude-opus-4.6-thinking","gpt-oss-120b-medium"]};export{g as toolConfig};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}
|
|
1
|
+
var b=Object.defineProperty;var m=(t,n)=>b(t,"name",{value:n,configurable:!0});function D(){return{toolCalls:new Map}}m(D,"createGeminiStreamState");function M(t){const n=t?.request;return n&&typeof n=="object"&&("contents"in n||"systemInstruction"in n||"generationConfig"in n||"tools"in n)?n:t}m(M,"resolveGeminiSource");function C(t){return(t||[]).filter(n=>!n.thought).map(n=>n.text).filter(n=>!!n).join(`
|
|
2
|
+
`)}m(C,"joinPartsText");function R(t){const n=t.response,o=Array.isArray(t.parts)?C(t.parts):"";if(n==null)return o;if(typeof n=="string")return n||o;if(typeof n=="object"&&!Array.isArray(n)){const s=n;if("result"in s&&Object.keys(s).length===1)return(typeof s.result=="string"?s.result:JSON.stringify(s.result??""))||o;if(Object.keys(s).length===0&&o)return o}const e=JSON.stringify(n);return o?`${e}
|
|
3
|
+
${o}`:e}m(R,"serializeFunctionResponse");function I(t){if(t&&typeof t=="object"&&!Array.isArray(t))return t;if(typeof t=="string"){const n=t.trim();if(!n)return{};try{const o=JSON.parse(n);return o&&typeof o=="object"&&!Array.isArray(o)?o:{value:o}}catch{return{raw:n}}}return{}}m(I,"parseToolArguments");function P(t,n,o){const e=M(t),s=[];if(e.systemInstruction){const h=C(e.systemInstruction.parts);h&&s.push({role:"system",content:h})}const p=new Map,g=new Set,i=e.contents||[];for(let h=0;h<i.length;h++){const x=i[h],y=x.parts||[],d=y.filter(a=>a.functionResponse||a.function_response);if(x.role==="model"){const a=C(y),c=[];for(let u=0;u<y.length;u++){const f=y[u]?.functionCall||y[u]?.function_call;if(!f?.name)continue;const A=f.id||`call_${h}_${u}_${f.name}`,k=p.get(f.name)||[];k.push(A),p.set(f.name,k),g.add(A),c.push({id:A,type:"function",function:{name:f.name,arguments:JSON.stringify(f.args??{})}})}if(c.length>0?s.push({role:"assistant",content:a||null,tool_calls:c}):(a||d.length===0)&&s.push({role:"assistant",content:a}),d.length===0)continue}for(const a of d){const c=a.functionResponse||a.function_response,u=c.name?p.get(c.name):void 0;let f;if(c.id&&g.has(c.id)){if(f=c.id,g.delete(c.id),u){const A=u.indexOf(c.id);A!==-1&&u.splice(A,1)}}else u&&u.length>0?(f=u.shift(),g.delete(f)):f=c.id||`call_${c.name||"tool"}`;s.push({role:"tool",tool_call_id:f,content:R(c)})}if(x.role==="model")continue;const S=y.filter(a=>!a.functionResponse&&!a.function_response&&!a.thought);if(S.some(a=>a.inlineData?.data)){const a=[];for(const c of S)if(c.text)a.push({type:"text",text:c.text});else if(c.inlineData?.data){const u=c.inlineData.mimeType||"image/png";a.push({type:"image_url",image_url:{url:`data:${u};base64,${c.inlineData.data}`}})}a.length>0&&s.push({role:"user",content:a})}else{const a=C(S);(a||d.length===0)&&s.push({role:"user",content:a})}}const r={model:n,messages:s,stream:!!o};if(Array.isArray(e.tools)&&e.tools.length>0){const h=[];for(const x of e.tools){const y=x.functionDeclarations||x.function_declarations||[];for(const d of y)d?.name&&h.push({type:"function",function:{name:d.name,...d.description?{description:d.description}:{},parameters:d.parameters||d.parametersJsonSchema||d.parameters_json_schema||{type:"object",properties:{}}}})}h.length>0&&(r.tools=h)}const l=e.toolConfig?.functionCallingConfig||e.tool_config?.function_calling_config,T=l?.mode?.toUpperCase(),O=l?.allowedFunctionNames||l?.allowed_function_names;T==="NONE"?r.tool_choice="none":T==="ANY"?Array.isArray(O)&&O.length===1?r.tool_choice={type:"function",function:{name:O[0]}}:r.tool_choice="required":T==="AUTO"&&(r.tool_choice="auto");const _=e.generationConfig||{};return _.maxOutputTokens!=null&&(r.max_tokens=_.maxOutputTokens),_.temperature!=null&&(r.temperature=_.temperature),_.topP!=null&&(r.top_p=_.topP),_.stopSequences?.length&&(r.stop=_.stopSequences),r}m(P,"convertGeminiToOpenAI");function j(t){if(t)return t==="stop"||t==="tool_calls"?"STOP":t==="length"?"MAX_TOKENS":t==="content_filter"?"SAFETY":"STOP"}m(j,"mapFinishReason");function q(t){const n=t?.choices?.[0]||{},o=n.message||{},e=[];if((o.reasoning_content||o.reasoning)&&e.push({text:o.reasoning_content||o.reasoning,thought:!0}),o.content!=null&&o.content!==""&&e.push({text:o.content}),Array.isArray(o.tool_calls))for(const r of o.tool_calls)r?.function?.name&&e.push({functionCall:{...r.id?{id:r.id}:{},name:r.function.name,args:I(r.function.arguments)}});e.length===0&&e.push({text:""});const s=j(n.finish_reason),p={content:{role:"model",parts:e}};s&&(p.finishReason=s);const g=[p],i={response:{candidates:g},candidates:g};if(t?.usage){const r={promptTokenCount:t.usage.prompt_tokens||0,candidatesTokenCount:t.usage.completion_tokens||0,totalTokenCount:t.usage.total_tokens||0};i.response.usageMetadata=r,i.usageMetadata=r}return i}m(q,"convertOpenAIToGeminiResponse");function N(t){if(t.toolCalls.size===0)return[];const n=[],o=Array.from(t.toolCalls.keys()).sort((e,s)=>e-s);for(const e of o){const s=t.toolCalls.get(e);s.name&&n.push({functionCall:{...s.id?{id:s.id}:{},name:s.name,args:I(s.arguments)}})}return t.toolCalls.clear(),n}m(N,"flushAccumulatedToolCalls");function G(t){const n=N(t);if(n.length===0)return null;const o={content:{role:"model",parts:n},finishReason:"STOP"};return{response:{candidates:[o]},candidates:[o]}}m(G,"flushGeminiStreamToolCalls");function F(t,n){if(!t?.choices||t.choices.length===0){if(t?.usage){const i={promptTokenCount:t.usage.prompt_tokens||0,candidatesTokenCount:t.usage.completion_tokens||0,totalTokenCount:t.usage.total_tokens||0};return{response:{usageMetadata:i},usageMetadata:i}}return null}const o=t.choices[0],e=o.delta||{},s=[];if((e.reasoning_content||e.reasoning)&&s.push({text:e.reasoning_content||e.reasoning,thought:!0}),e.content!=null&&e.content!==""&&s.push({text:e.content}),Array.isArray(e.tool_calls))if(n)for(const i of e.tool_calls){let r=typeof i.index=="number"?i.index:0,l=n.toolCalls.get(r);if(l&&i.id&&l.id&&i.id!==l.id){for(;n.toolCalls.has(r);)r++;l=void 0}l||(l={id:"",name:"",arguments:""}),i.id&&(l.id=i.id),i.function?.name&&(l.name+=i.function.name),typeof i.function?.arguments=="string"&&(l.arguments+=i.function.arguments),n.toolCalls.set(r,l)}else for(const i of e.tool_calls)i?.function?.name&&s.push({functionCall:{...i.id?{id:i.id}:{},name:i.function.name,args:I(i.function.arguments)}});const p=j(o.finish_reason);if(p&&n&&s.push(...N(n)),s.length===0&&!p)return null;const g={content:{role:"model",parts:s.length>0?s:[{text:""}]}};return p&&(g.finishReason=p),{response:{candidates:[g]},candidates:[g]}}m(F,"convertOpenAIToGeminiChunk");export{P as convertGeminiToOpenAI,F as convertOpenAIToGeminiChunk,q as convertOpenAIToGeminiResponse,D as createGeminiStreamState,G as flushGeminiStreamToolCalls,C as joinPartsText,j as mapFinishReason,M as resolveGeminiSource};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);
|
|
1
|
+
var J=Object.defineProperty;var p=(o,e)=>J(o,"name",{value:e,configurable:!0});import{fetchRouter as k,waitForDrainOrClose as u}from"../base.js";import{convertGeminiToOpenAI as x,convertOpenAIToGeminiResponse as W,convertOpenAIToGeminiChunk as G,createGeminiStreamState as L,flushGeminiStreamToolCalls as C}from"./converter.js";async function H(o,e,O,T){const f=o.url?.includes(":streamGenerateContent");try{const r=JSON.parse(O.toString("utf-8")),v=x(r,T,!!f),n=await k(v,"/v1/chat/completions",o.headers);if(!n.ok){const t=await n.text().catch(()=>"");throw new Error(`Router error ${n.status}: ${t}`)}if(!f){const t=await n.json(),a=W(t),i=JSON.stringify(a);e.headersSent||e.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Content-Length":String(Buffer.byteLength(i))}),e.end(i);return}if(e.headersSent||e.writeHead(200,{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-cache",Connection:"keep-alive","X-Accel-Buffering":"no"}),!n.body){e.end();return}const l=n.body.getReader(),N=new TextDecoder,m=L();let h="",c=!1;const w=p(()=>{c=!0,l.cancel().catch(()=>{})},"onClose");e.once("close",w);try{for(;!(c||e.destroyed);){const{done:t,value:a}=await l.read();if(t)break;h+=N.decode(a,{stream:!0});const i=h.split(`
|
|
2
|
+
`);h=i.pop()||"";for(const b of i){if(c||e.destroyed)break;const y=b.trim();if(!y||!y.startsWith("data:"))continue;const g=y.slice(5).trim();if(g==="[DONE]"){const s=C(m);if(s){const d=`data: ${JSON.stringify(s)}\r
|
|
3
3
|
\r
|
|
4
|
-
`;e.write(
|
|
4
|
+
`;e.write(d)||await u(e)}continue}try{const s=JSON.parse(g),d=G(s,m);if(d){const S=`data: ${JSON.stringify(d)}\r
|
|
5
5
|
\r
|
|
6
|
-
|
|
6
|
+
`;e.write(S)||await u(e)}}catch{}}}if(!c&&!e.destroyed){const t=C(m);if(t){const a=`data: ${JSON.stringify(t)}\r
|
|
7
|
+
\r
|
|
8
|
+
`;e.write(a)||await u(e)}}}finally{e.removeListener("close",w);try{l.cancel().catch(()=>{})}catch{}!e.writableEnded&&!e.destroyed&&e.end()}}catch(r){f?(e.headersSent||e.writeHead(200,{"Content-Type":"text/event-stream"}),e.end(`data: ${JSON.stringify({error:{message:r.message}})}\r
|
|
9
|
+
\r
|
|
10
|
+
`)):(e.headersSent||e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:{message:r.message,type:"mitm_error"}})))}}p(H,"interceptAntigravity");export{H as interceptAntigravity};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var A=Object.defineProperty;var p=(e,r)=>A(e,"name",{value:r,configurable:!0});import{fetchUpstreamDirect as I,decompressBuffer as j}from"../base.js";import{toolConfig as S}from"./config.js";import{resolveModelDisplayName as L}from"../../../core/capabilities/modelDictionary.js";import{MitmRepository as N}from"../../../storage/repositories/mitmRepo.js";const C=/^(.*?)\s*\((low|medium|high|xhigh|max)(?:\s+thinking)?\)\s*$/i,O=/^(.*?)\s*\(thinking\)\s*$/i;function v(e,r){return(r||L(e)||e).replace(/\s*\(Extra\)\s*$/i," (xhigh)")}p(v,"formatAntigravityDisplayName");function R(e,r){if(!e||typeof e!="object"||e.error)return e;(!e.models||typeof e.models!="object"||Array.isArray(e.models))&&(e.models={});const f=new Set(Object.keys(e.models).map(t=>t.toLowerCase())),M=Object.values(e.models).find(t=>t&&!t.unavailableReason&&!t.unavailable_reason)||Object.values(e.models)[0]||null;if(e.deprecatedModelIds&&typeof e.deprecatedModelIds=="object")for(const t of Object.keys(e.deprecatedModelIds))/argon|claude|gemini/i.test(t)&&delete e.deprecatedModelIds[t];if(e.deprecated_model_ids&&typeof e.deprecated_model_ids=="object")for(const t of Object.keys(e.deprecated_model_ids))/argon|claude|gemini/i.test(t)&&delete e.deprecated_model_ids[t];const n=(S.defaultModels||[]).map(t=>({id:t,name:L(t)||t}));try{const t=N.getMappings("antigravity");for(const s of t)s.sourceModel&&!n.some(d=>d.id.toLowerCase()===s.sourceModel.toLowerCase())&&n.push({id:s.sourceModel,name:L(s.sourceModel)||s.sourceModel})}catch{}if(r&&Array.isArray(r))for(const t of r)t.id&&!n.some(s=>s.id.toLowerCase()===t.id.toLowerCase())&&n.push(t);const a=e.agentModelSorts!==void 0?"agentModelSorts":e.agent_model_sorts!==void 0?"agent_model_sorts":"agentModelSorts";(!Array.isArray(e[a])||e[a].length===0)&&(e[a]=[{displayName:"Recommended",groups:[{displayName:"Recommended",modelIds:[]}]}]);const u=e[a].find(t=>String(t?.displayName||t?.display_name||"").toLowerCase()==="recommended")||e[a][0];(!u.groups||!Array.isArray(u.groups)||u.groups.length===0)&&(u.groups=[{displayName:"Recommended",modelIds:[]}]);const i=u.groups[0],m=i.modelIds!==void 0?"modelIds":i.model_ids!==void 0?"model_ids":"modelIds";Array.isArray(i[m])||(i[m]=[]);for(const t of n){const s=t.id.trim();if(!s)continue;const d=s.toLowerCase(),l=v(s,t.name);if(!f.has(d))f.add(d),e.models[s]={...M?{...M}:{},model:s,displayName:l,disabled:!1,preview:!1,supportsImages:!0,supportsAdaptiveThinking:!0},delete e.models[s].tagTitle,delete e.models[s].tagDescription,delete e.models[s].unavailableReason,delete e.models[s].unavailable_reason,delete e.models[s].disabledReason,delete e.models[s].disabled_reason;else{const o=Object.keys(e.models).find(h=>h.toLowerCase()===d)||s;e.models[o]&&typeof e.models[o]=="object"&&(e.models[o].model=e.models[o].model||o,e.models[o].displayName=v(o,e.models[o].displayName||l),e.models[o].disabled=!1,e.models[o].preview=!1,e.models[o].supportsAdaptiveThinking=!0,delete e.models[o].tagTitle,delete e.models[o].tagDescription,delete e.models[o].unavailableReason,delete e.models[o].unavailable_reason,delete e.models[o].disabledReason,delete e.models[o].disabled_reason)}i[m].some(o=>String(o).toLowerCase()===d)||i[m].push(s)}const _=new Map;for(const t of i[m]){const s=e.models[t];if(!s)continue;const d=String(s.displayName||t).trim(),l=C.exec(d);if(!l)continue;const b=l[1].trim().toLowerCase(),o=l[2].toLowerCase();let h=_.get(b);h||(h=new Set,_.set(b,h)),h.add(o)}const w=new Set;for(const[t,s]of _.entries())s.size>=2&&w.add(t);const g=new Set;i[m]=i[m].filter(t=>{const s=e.models[t];if(!s)return!1;const d=String(s.displayName||t).trim(),l=d.toLowerCase();if(w.has(l))return!1;const b=O.exec(d);return b&&w.has(b[1].trim().toLowerCase())||g.has(l)?!1:(g.add(l),!0)});for(const[,t]of Object.entries(e.models))t&&typeof t=="object"&&(t.disabled=!1,(/unavailable/i.test(t.tagTitle||"")||/unavailable/i.test(t.tagDescription||""))&&(delete t.tagTitle,delete t.tagDescription),delete t.unavailableReason,delete t.unavailable_reason,delete t.disabledReason,delete t.disabled_reason);const c=e.defaultAgentModelId!==void 0?"defaultAgentModelId":e.default_agent_model_id!==void 0?"default_agent_model_id":"defaultAgentModelId";return!e[c]&&Object.keys(e.models).length>0&&(e[c]=Object.keys(e.models)[0]),e}p(R,"augmentAntigravityModelsPayload");async function D(e,r,f,M){try{const n=await I(e,f);if(n.statusCode!==200){r.writeHead(n.statusCode,n.headers),r.end(n.body);return}const a=n.headers["content-encoding"],i=j(n.body,a).toString("utf-8"),m=JSON.parse(i),_=R(m),w=JSON.stringify(_),g=Buffer.from(w,"utf-8"),c={...n.headers,"content-type":"application/json; charset=utf-8","content-length":String(g.length)};delete c["content-encoding"],delete c["Content-Encoding"],delete c["transfer-encoding"],delete c["Transfer-Encoding"],c["content-length"]=String(g.length),r.writeHead(200,c),r.end(g)}catch(n){console.warn("[MITM Antigravity] Model augmentation failed, falling back to passthrough:",n?.message||n),await M(e,r,f)}}p(D,"interceptAntigravityModels");export{R as augmentAntigravityModelsPayload,D as interceptAntigravityModels};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var s=Object.defineProperty;var
|
|
1
|
+
var s=Object.defineProperty;var e=(t,o)=>s(t,"name",{value:o,configurable:!0});const a={id:"copilot",name:"GitHub Copilot",image:"/assets/providers/github/icon.png",desc:"Intercept GitHub Copilot requests in VS Code via MITM proxy",hosts:["api.githubcopilot.com","copilot-proxy.githubusercontent.com","api.individual.githubcopilot.com","api.business.githubcopilot.com","api.enterprise.githubcopilot.com"],urlPatterns:["/chat/completions","/v1/messages","/responses","/models"],defaultHost:`127.0.0.1 api.githubcopilot.com
|
|
2
2
|
127.0.0.1 copilot-proxy.githubusercontent.com
|
|
3
3
|
127.0.0.1 api.individual.githubcopilot.com
|
|
4
4
|
127.0.0.1 api.business.githubcopilot.com
|
|
5
|
-
127.0.0.1 api.enterprise.githubcopilot.com`,matchesHost:
|
|
5
|
+
127.0.0.1 api.enterprise.githubcopilot.com`,matchesHost:e(t=>{const o=(t||"").split(":")[0].trim().toLowerCase();return["githubcopilot.com","copilot-proxy.githubusercontent.com"].some(i=>o===i||o.endsWith("."+i))},"matchesHost"),isModelListRequest:e(t=>{const o=(t.url||"").toLowerCase().split("?")[0];return o==="/models"||o==="/v1/models"||o.endsWith("/models")},"isModelListRequest"),defaultModels:["auto","claude-haiku-4.5","claude-haiku-5.5","claude-sonnet-4","claude-sonnet-4.6","claude-sonnet-5","claude-sonnet-5.5","claude-opus-4.8","claude-opus-5","claude-opus-5.5","claude-fable-5","claude-fable-5.1","claude-fable-5.2","copilot-search-a","copilot-search-b","gpt-3.5-turbo","gpt-4","gpt-4.1","gpt-4o","gpt-4o-mini","gpt-5-mini","gpt-5.2","gpt-5.2-codex","gpt-5.3-codex","gpt-5.4","gpt-5.4-nano","gpt-5.6-terra","gpt-5.6-luna","gpt-5.6-sol","gpt-6-astra","gpt-6-luna","gpt-6-sol","gpt-6.1-terra","gpt-6.1-sol","mai-code-1.1-flash","mai-code-2-flash","mai-code-2","gemini-3.7-flash","gemini-3.8-flash","gemini-4-argon","grok-4.5","grok-4.6","grok-4.7","kimi-k3"]};export{a as toolConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var L=Object.defineProperty;var h=(t,n)=>L(t,"name",{value:n,configurable:!0});import{detectRequiredCapabilities as R}from"../../../core/router/capacityAdapter.js";import{isZeroContentResponse as
|
|
1
|
+
var L=Object.defineProperty;var h=(t,n)=>L(t,"name",{value:n,configurable:!0});import{detectRequiredCapabilities as R}from"../../../core/router/capacityAdapter.js";import{isZeroContentResponse as y}from"../../../core/adapters/helpers/zeroContentCheck.js";import{logger as B}from"../../../shared/logger.js";import{getRotatedModels as P,reorderByCapabilities as U,getLkgpModel as j,recordComboSuccess as z,getComboModelScore as T,recordComboModelResult as F,getModelCapabilityTier as A}from"./state.js";const D={info:h((t,...n)=>B.info("COMBO",t,...n),"info"),warn:h((t,...n)=>B.warn("COMBO",t,...n),"warn")};function N(t,n){if(t===499)return{shouldFallback:!1,cooldownMs:0,requestScoped:!1};if(t===429)return{shouldFallback:!0,cooldownMs:1500};if(t===502||t===503||t===504)return{shouldFallback:!0,cooldownMs:1e3};if(t>=500)return{shouldFallback:!0,cooldownMs:500};const a=(n||"").toLowerCase();return a.includes("quota")||a.includes("rate limit")||a.includes("insufficient")||a.includes("balance")||a.includes("credit")||a.includes("overloaded")||a.includes("capacity")||a.includes("resource_exhausted")?{shouldFallback:!0,cooldownMs:1e3}:t>=400&&t<500&&t!==401&&t!==402&&t!==403&&t!==404?{shouldFallback:!1,cooldownMs:0,requestScoped:!0}:{shouldFallback:!1}}h(N,"checkFallbackError");async function _(t){const{body:n,models:a,handleSingleModel:S,log:c=D,comboName:k="",comboStrategy:p="fallback",comboStickyLimit:q=1,autoSwitch:$=!0}=t;let l=P(a,k,p,q),m=new Set;if($&&(m=R(n),m.size>0&&(l=U(l,m))),p==="lkgp"&&l.length>1){const r=j(k);r&&l.includes(r)&&(!$||m.size===0||A(r,m)<2)&&(l=[r,...l.filter(d=>d!==r)])}if(p==="p2c"&&l.length>=2){const r=Math.floor(Math.random()*l.length);let o=Math.floor(Math.random()*(l.length-1));o>=r&&o++;const d=l[r],e=l[o],u=T(d),f=T(e),[w,i]=u>=f?[r,o]:[o,r],C=l.filter((O,s)=>s!==w&&s!==i);l=[l[w],l[i],...C]}let g=503,M="All combo models failed",b=null,x=l[0]||"";for(let r=0;r<l.length;r++){const o=l[r];x=o,c.info(`[COMBO:Fallback] Trying model ${r+1}/${l.length}: ${o}`);const d=Date.now();try{const e=await S(n,o,!1),u=Date.now()-d;if(F(o,e.ok,u),e.ok){const s=e.json!==void 0?e.json:e.data!==void 0?e.data:e.text;if(!e.isStream&&s!==void 0&&y(s)){c.warn(`[COMBO:Fallback] Model ${o} returned HTTP 200 with zero content, failing over`),F(o,!1,u),g=502,M="Upstream returned HTTP 200 with empty content";continue}return c.info(`[COMBO:Fallback] Model ${o} succeeded`),z(k,o),{...e,modelUsed:o}}const f=e.error||e.text||String(e.status),{shouldFallback:w,cooldownMs:i,requestScoped:C}=N(e.status,f);g=e.status,M=f;const O=e.accountName?` [${e.accountName}]`:"";if(C){c.warn(`[COMBO:Fallback] Model ${o}${O} rejected request (${e.status}): ${f}, trying next model`),b||(b={...e,modelUsed:o});continue}if(!w)return c.warn(`[COMBO:Fallback] Model ${o}${O} failed with unretryable error ${e.status}: ${f}`),{...e,modelUsed:o};i&&i>0&&i<=3e3&&r<l.length-1&&await new Promise(s=>setTimeout(s,i))}catch(e){const u=Date.now()-d;F(o,!1,u),g=500,M=e.message||String(e),c.warn(`[COMBO:Fallback] Model ${o} threw exception: ${M}`)}}return b?(c.warn(`[COMBO:Fallback] All combo models failed; returning first request-scoped error (${b.status})`),b):{ok:!1,status:g,error:M,modelUsed:x}}h(_,"handleFallbackChat");export{N as checkFallbackError,_ as handleFallbackChat,y as isZeroContentResponse};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var H=Object.defineProperty;var g=(
|
|
1
|
+
var H=Object.defineProperty;var g=(d,e)=>H(d,"name",{value:e,configurable:!0});import{isRateLimitOrQuotaError as P}from"../../../core/resilience/index.js";import{extractModelsFromPayload as I}from"../../../core/scanner/payloadExtractor.js";import{resolveCandidateUrls as M}from"../../../core/scanner/urlResolver.js";import{getRegistryProvider as A}from"../metadataRegistry.js";import{fetchWithDnsBypass as k}from"../../../shared/utils/dnsResolver.js";import{exec as C}from"node:child_process";import{promisify as F}from"node:util";const L=F(C);function D(d){try{const e=new URL(d).hostname.toLowerCase();return!!(e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"||/^\d{1,3}(\.\d{1,3}){3}$/.test(e))}catch{return!1}}g(D,"isLocalOrIpHost");async function E(d){if(!d||typeof d!="string")return!1;const e=d.trim();if(!/^[a-zA-Z0-9_.-]+$/.test(e))return!1;try{const t=process.platform==="win32",r=t?`where ${e}`:`which ${e}`,i=t?{...process.env,PATH:`${process.env.APPDATA}\\npm;${process.env.PATH}`}:process.env;return await L(r,{windowsHide:!0,env:i}),!0}catch{return!1}}g(E,"checkBinaryInstalled");import{extractTokenFromAccount as w,extractHeader as b}from"./tokenExtractor.js";function B(...d){const e=d.flatMap(t=>typeof t=="string"?t.split(","):[]).map(t=>t.trim()).filter(Boolean);return[...new Set(e)].join(",")}g(B,"mergeAnthropicBeta");class x{static{g(this,"BaseProvider")}requiresAccount=!0;requiresApiKey;isLocal;defaultBaseUrl;streamType="sse";resolveTargetFormat(e,t){}resolveUpstreamModelId(e){const t=e.targetModel||"";if(!t)return t;const r=t.match(/^(.*?)(\([^()]+\))$/),i=r?r[1]:t,a=r?r[2]:"",f=(e.provider?.models||[]).find(c=>c.id===i||c.upstreamModelId&&c.upstreamModelId===i);return f?.upstreamModelId?`${f.upstreamModelId}${a}`:t}buildUrl(e){const r=((e.account?.providerSpecificData?.baseUrl||"").trim()||e.provider?.baseUrl||A(this.id)?.baseUrl||"").trim();if(r.includes("/chat/completions")||r.includes("/messages")||r.includes("/responses")||r.includes("/generateAssistantResponse"))return r;const a=r.replace(/\/+$/,"");return this.defaultFormat==="claude"?a.endsWith("/v1")?`${a}/messages`:`${a}/v1/messages`:a.endsWith("/v1")?`${a}/chat/completions`:`${a}/v1/chat/completions`}async buildHeaders(e){const t=w(e.account),r=e.account?.providerSpecificData||{},i=e.provider,a=i?.requiresApiKey===!1||i?.authType==="none"||this.requiresApiKey===!1,f=A(i?.id||this.id)?.defaultHeaders||this.defaultHeaders||{},c={"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{},...f,...e.provider?.customHeaders||{}};for(const[y,v]of Object.entries(c))(v===""||v==null)&&delete c[y];return r.chatgptAccountId&&(c["chatgpt-account-id"]=r.chatgptAccountId,c["ChatGPT-Account-Id"]=r.chatgptAccountId),a&&!t&&delete c.Authorization,(i?.category==="webCookie"||i?.format==="grok-web"||i?.id==="grok-web"||i?.id==="iflow"||i?.id==="perplexity-web")&&(delete c.Authorization,t&&(c.Cookie=t)),this.applyAnthropicClientHeaders(c,e),c}applyAnthropicClientHeaders(e,t){const r=b(t.req,"anthropic-beta"),i=b(t.req,"anthropic-version");if(r){const a=Object.keys(e).find(s=>s.toLowerCase()==="anthropic-beta");if(a){const s=B(e[a],r);delete e[a],e["anthropic-beta"]=s}else e["anthropic-beta"]=r}if(t.is1mContext&&(this.defaultFormat==="claude"||this.id==="anthropic"||this.id==="claude")){const a=e["anthropic-beta"]||e["Anthropic-Beta"];e["anthropic-beta"]=B(a,"context-1m-2025-08-07"),delete e["Anthropic-Beta"]}if(i){const a=Object.keys(e).find(s=>s.toLowerCase()==="anthropic-version");a&&delete e[a],e["anthropic-version"]=i}}transformRequestBody(e){return e.body}isRateLimitOrQuotaError(e,t){return P(e,t)}supportsQuota(){return!1}async probeModels(e){const t=(e.apiKey||e.account?.rawApiKey||"").trim(),r=e.account?.providerSpecificData||e.providerSpecificData||{},i=A(this.id),a=i?.validateUrl&&(i.validateUrl.includes("/models")||i.validateUrl.includes("/tags"))?i.validateUrl:void 0;let s=(e.baseUrl||r.baseUrl||this.defaultBaseUrl||a||i?.baseUrl||"").replace(/\/+$/,"");if(!s)return{success:!1,error:"Base URL is required to probe models."};if(s.startsWith("devin://")||s.startsWith("auggie://")||s.startsWith("zcode://")||s.includes("://")&&s.endsWith("/stdio")){const p=this.id.includes("devin")?"devin":this.id.includes("auggie")?"auggie":this.id.includes("zcode")?"zcode":"";return await E(p)?{success:!0,endpointUrl:s,count:1}:{success:!1,error:`${this.name} CLI binary "${p||this.id}" not found locally. Please install ${p||this.name} or connect via standard API.`}}const c=r.accountId||"";c&&s.includes("{accountId}")&&(s=s.replace(/\{accountId\}/g,c));const T=M(s,e.format||this.defaultFormat,this.id,i,e.region||r.region),y=this.defaultFormat==="claude"||this.id.includes("anthropic")||this.id.includes("claude"),v=this.defaultFormat==="gemini"||this.id.includes("gemini")||e.format==="gemini"||s.toLowerCase().includes("generativelanguage")||s.toLowerCase().includes("googleapis.com"),m={Accept:"application/json",...i?.defaultHeaders||{},...e.customHeaders||{}};t&&(y?(m["x-api-key"]=t,m["anthropic-version"]="2023-06-01"):v?m["x-goog-api-key"]=t:m.Authorization=t.startsWith("Bearer ")?t:`Bearer ${t}`);let $=null,u=null;const U=e.timeoutMs||6e3;for(const p of T)try{const l=await(D(p)?fetch:k)(p,{method:"GET",headers:m,signal:AbortSignal.timeout(U)});if(l.ok||l.status===200){const n=await l.json(),o=I(n,this.id);if(o.length>0)return{success:!0,endpointUrl:p,models:o,count:o.length};continue}if(l.status===401||l.status===403){let n="";try{const o=await l.json();o?.error?.message?n=o.error.message:o?.message?n=o.message:typeof o?.error=="string"&&(n=o.error)}catch{const o=await l.text().catch(()=>"");o&&!o.includes("<html")&&o.length<200&&(n=o.trim())}$=n?`Authentication failed (HTTP ${l.status}): ${n}`:`Authentication failed (HTTP ${l.status}) for account "${e.account?.name||this.name}". Please verify credentials.`}else{let n=l.statusText;try{const o=await l.json();(o?.message||o?.error?.message||o?.detail)&&(n=o?.message||o?.error?.message||o?.detail)}catch{}l.status===404&&u&&(u.includes("HTTP 5")||u.includes("HTTP 401")||u.includes("HTTP 403"))||(u=`Endpoint ${p} returned HTTP ${l.status}: ${n}`)}}catch(h){const l=h instanceof Error?h.message:String(h);if(l.includes("ENOTFOUND")){const n=s.match(/https?:\/\/([^/]+)/);u=`Domain "${n?n[1]:s}" could not be resolved (DNS ENOTFOUND). The service may be offline or moved.`}else if(s.includes("localhost")||s.includes("127.0.0.1")){const n=s.match(/:(\d+)/),o=n?` (port ${n[1]})`:"";u=`Local server for ${this.name} is not running on ${s}. Start ${this.name}${o} to connect.`}else u=`Failed to connect to ${p}: ${l}`}return{success:!1,error:$||u||"Failed to probe models",authError:$||void 0}}}export{x as BaseProvider,E as checkBinaryInstalled,b as extractHeader,w as extractTokenFromAccount,B as mergeAnthropicBeta};
|