mapigate 0.5.141 → 0.5.150
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 +8 -8
- package/dist/cli/commands/restart.js +9 -1
- package/dist/cli/commands/start.js +15 -2
- package/dist/core/capabilities/index.js +13 -6
- package/dist/core/capabilities/modelDictionary.js +23 -7
- package/dist/core/router/ruleEngine.js +11 -1
- package/dist/core/usage/pricing.js +52 -24
- package/dist/mitm/handlers/antigravity/config.js +6 -0
- package/dist/mitm/handlers/base.js +18 -8
- package/dist/mitm/server.js +19 -4
- package/dist/mitm/toolsHelper.js +2 -0
- package/dist/providers/catalog/coarena/index.js +3 -0
- package/dist/providers/catalog/coarena/metadata.js +104 -0
- package/dist/providers/catalog/coarena/provider.js +91 -0
- package/dist/providers/catalog/coarena/quota.js +119 -0
- package/dist/providers/generated/chunks/chunk1.js +2 -2
- package/dist/providers/generated/chunks/chunk2.js +2 -2
- package/dist/providers/generated/chunks/chunk3.js +2 -2
- package/dist/providers/generated/chunks/chunk4.js +2 -0
- package/dist/providers/generated/runtime/chunk1.js +2 -2
- package/dist/providers/generated/runtime/chunk2.js +2 -2
- package/dist/providers/generated/runtime/chunk3.js +2 -2
- package/dist/providers/generated/runtime/chunk4.js +2 -0
- package/dist/providers/runtime/antigravity/executor.js +1 -1
- package/dist/providers/runtime/antigravity/metadata.js +2 -2
- package/dist/providers/runtime/antigravity/models.js +2 -0
- package/dist/providers/runtime/antigravity/provider.js +2 -2
- package/dist/providers/runtime/antigravity/routes.js +2 -2
- package/dist/providers/runtime/antigravity/types.js +4 -2
- package/dist/providers/runtime/gemini/metadata.js +1 -1
- package/dist/providers/runtime/gemini/provider.js +2 -2
- package/dist/providers/runtime/gemini-cli/provider.js +2 -2
- package/dist/providers/runtime/trae/index.js +1 -0
- package/dist/providers/runtime/trae/metadata.js +1 -0
- package/dist/providers/runtime/trae/provider.js +7 -0
- package/dist/providers/runtime/trae/quota.js +99 -0
- package/dist/providers/runtime/zed/metadata.js +1 -1
- package/dist/providers/runtime/zed/models.js +68 -8
- package/dist/providers/runtime/zed/provider.js +60 -15
- package/dist/providers/runtime/zed/quota.js +69 -12
- package/dist/providers/runtime/zed/routes.js +7 -0
- package/dist/server/lifecycle.js +2 -2
- package/dist/server/proxy/executorHelpers.js +52 -4
- package/dist/server/routes/apiModels.js +141 -8
- package/dist/server/routes/apiProviders.js +21 -14
- package/dist/server/routes/mitmRouterTargetHelper.js +14 -1
- package/dist/shared/constants/quotaOrder.js +5 -0
- package/dist/shared/utils/modelUtils.js +64 -0
- package/dist/storage/database.js +14 -0
- package/dist/storage/repositories/accountModelRepo.js +14 -1
- package/dist/storage/repositories/providerRepo.js +66 -38
- package/dist/storage/repositories/settingsRepo.js +41 -0
- package/dist/storage/repositories/toolMappingRepo.js +29 -0
- package/dist/web/assets/{CliToolsTab-rKSWLJC3.js → CliToolsTab-D_MUwimj.js} +1 -1
- package/dist/web/assets/CombosTab-EWUYC3TU.js +1 -0
- package/dist/web/assets/{ConfirmModal-OWeauwYv.js → ConfirmModal-CMfDss7P.js} +1 -1
- package/dist/web/assets/{ConsoleLogTab-rZe8zCb_.js → ConsoleLogTab-BSMXSYrR.js} +1 -1
- package/dist/web/assets/{EditAccountModal-CAg-yIOn.js → EditAccountModal-OrvqLLBP.js} +1 -1
- package/dist/web/assets/{EndpointTab-B-Jb4wAG.js → EndpointTab-BwtzqXUN.js} +1 -1
- package/dist/web/assets/MitmTab-C7g7GUXW.js +14 -0
- package/dist/web/assets/ModelAutocompleteInput-DEb_clZC.js +1 -0
- package/dist/web/assets/ProviderDetailPage-BIfOQupC.js +6 -0
- package/dist/web/assets/{ProvidersTab-yzmb4w0D.js → ProvidersTab-CwJo_EUX.js} +1 -1
- package/dist/web/assets/QuotaTab-PFvP6yAb.js +1 -0
- package/dist/web/assets/{SettingsTab-LkByv4Sg.js → SettingsTab-DwAbjIW3.js} +1 -1
- package/dist/web/assets/{UsageTab-Hr8XPZD4.js → UsageTab-85tTb2_C.js} +1 -1
- package/dist/web/assets/{index-CKuvklEr.js → index-CWkEEbms.js} +2 -2
- package/dist/web/assets/metadataRegistry-FuJXbCt4.js +1 -0
- package/dist/web/assets/providers/coarena/icon.png +0 -0
- package/dist/web/assets/providers/coarena/icon.svg +3 -0
- package/dist/web/assets/{providersData-DS1-ETBi.js → providersData-Y57rBt5o.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/CombosTab-D1_cfssh.js +0 -1
- package/dist/web/assets/MitmTab-5dKeNi4T.js +0 -14
- package/dist/web/assets/ModelAutocompleteInput-CoinzdsW.js +0 -1
- package/dist/web/assets/ProviderDetailPage-D-fodBhz.js +0 -6
- package/dist/web/assets/QuotaTab-BXevQzen.js +0 -1
- package/dist/web/assets/metadataRegistry-NuDSSkP9.js +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
### Local-first AI model gateway and token optimizer for coding assistants
|
|
6
6
|
|
|
7
|
-
**One local endpoint (`http://127.0.0.1:20128`) that speaks the OpenAI, Anthropic, and Responses APIs, and routes to
|
|
7
|
+
**One local endpoint (`http://127.0.0.1:20128`) that speaks the OpenAI, Anthropic, and Responses APIs, and routes to 152+ AI providers.**
|
|
8
8
|
*Works with Claude Code, Cursor, Cline, Codex, OpenCode, and 26 coding tools in total, plus GitHub Copilot, Kiro IDE, and Antigravity through a local MITM proxy.*
|
|
9
9
|
|
|
10
10
|
---
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
[](LICENSE)
|
|
14
14
|
[](#)
|
|
15
15
|
[](https://www.typescriptlang.org/)
|
|
16
|
-
[](package.json)
|
|
17
17
|
|
|
18
|
-
[**What is Mapigate?**](#-what-is-mapigate) • [**Gateway API**](#-gateway-api) • [**Supported Providers**](#-supported-providers-
|
|
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
|
|
|
20
20
|
</div>
|
|
21
21
|
|
|
@@ -30,7 +30,7 @@ Mapigate is a local API gateway that runs on your machine (Node.js, single port
|
|
|
30
30
|
| | |
|
|
31
31
|
| :--- | :--- |
|
|
32
32
|
| **Client APIs** | OpenAI Chat Completions (`/v1/chat/completions`), Anthropic Messages (`/v1/messages`), OpenAI Responses (`/v1/responses`), model list (`/v1/models`). Streaming and non-streaming. |
|
|
33
|
-
| **Providers** |
|
|
33
|
+
| **Providers** | 152+ built in: 32 runtime (OAuth / custom auth: Claude, OpenAI, Gemini, Copilot, Codex, Kiro, Cursor, Bedrock, Azure…), 119 catalog (OpenRouter, Groq, Cerebras, Mistral, Together, Moonshot, Z.ai, local Ollama / LM Studio…), plus the combo engine. More via the community catalog. |
|
|
34
34
|
| **Coding tools** | 26 with config definitions (`mpg connect`): Claude Code, Codex, OpenCode, Cline, Roo Code, Continue, Qwen Code, Crush, Factory Droid… Cursor via base URL override. Copilot, Kiro IDE, and Antigravity via MITM. |
|
|
35
35
|
| **Routing** | Model aliases, global and per-tool model mappings, combos (`fallback`, `round-robin`, `fusion`, `lkgp`, `p2c`), multi-account rotation (`round-robin` / `fill-first`), automatic fallback on 429 and quota errors. |
|
|
36
36
|
| **Token saving** | Modular Token Saver: RTK in-place compression (`git diff`, terminal logs, search results — 20–40% fewer input tokens), Caveman style compression, Ponytail minimalist coding, and Custom Prompts. Fail-open, and error results are never compressed. |
|
|
@@ -63,7 +63,7 @@ graph TD
|
|
|
63
63
|
VAULT[("SQLite (WAL) + AES-256-GCM vault")]
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
subgraph UPSTREAM["
|
|
66
|
+
subgraph UPSTREAM["152+ providers"]
|
|
67
67
|
P1["Runtime: Claude, OpenAI, Gemini, Copilot, Codex, Kiro, Bedrock..."]
|
|
68
68
|
P2["Catalog: OpenRouter, Groq, Cerebras, Mistral, Together..."]
|
|
69
69
|
P3["Local: Ollama, LM Studio, Jan"]
|
|
@@ -115,14 +115,14 @@ The dashboard and CLI use a REST management API under `/api/*` (providers, accou
|
|
|
115
115
|
|
|
116
116
|
---
|
|
117
117
|
|
|
118
|
-
## 🌐 Supported Providers (
|
|
118
|
+
## 🌐 Supported Providers (152+)
|
|
119
119
|
|
|
120
|
-
Mapigate ships with **
|
|
120
|
+
Mapigate ships with **152+ provider modules**, discovered automatically from `src/providers/` by `npm run codegen`:
|
|
121
121
|
|
|
122
122
|
| Tier | Count | What it covers |
|
|
123
123
|
| :--- | :---: | :--- |
|
|
124
124
|
| **Runtime** (`src/providers/runtime/`) | 32 | Providers with custom auth, OAuth, or streaming: `claude`, `openai`, `gemini`, `gemini-cli`, `antigravity`, `bedrock`, `azure`, `cloudflare`, `deepseek`, `github` (Copilot), `codex`, `cursor`, `cursor-api`, `kiro`, `xkiro`, `windsurf`, `zed`, `trae`, `qoder`, `cline`, `codebuddy`, `devin`, `opencode`, `grok`, `grok-cli`, `kimi`, `glm`, `minimax`, `minimax-code`, `mimo`, `alicode`, `ollama` |
|
|
125
|
-
| **Catalog** (`src/providers/catalog/`) |
|
|
125
|
+
| **Catalog** (`src/providers/catalog/`) | 119 | Standard OpenAI/Anthropic-compatible API-key providers: Anthropic, OpenRouter, Groq, Cerebras, Together, Fireworks, DeepInfra, Mistral, Codestral, Cohere, Perplexity, NVIDIA, Hugging Face, Vertex AI, Databricks, Snowflake, watsonx, SambaNova, Nebius, Novita, SiliconFlow, Moonshot, Z.ai, StepFun, Baidu, Tencent, Volcengine, Vercel AI Gateway, LM Studio, Jan, local Ollama, Coarena, and more |
|
|
126
126
|
| **Composite** (`src/providers/composite/`) | 1 | The `combo` engine (fallback, round-robin, fusion, lkgp, p2c) |
|
|
127
127
|
| **Community catalog** | — | Additional providers importable from the dashboard (**Providers → Community Catalog**) |
|
|
128
128
|
|
|
@@ -4,7 +4,15 @@ import { DEFAULT_PORT, DEFAULT_HOST, APP_NAME } from "../../shared/constants/ind
|
|
|
4
4
|
import { ProcessManager } from "../daemon/processManager.js";
|
|
5
5
|
import { PortHelper } from "../daemon/portHelper.js";
|
|
6
6
|
export async function runRestart(options = {}) {
|
|
7
|
-
|
|
7
|
+
let targetPort = options?.port ? Number(options.port) : undefined;
|
|
8
|
+
if (!targetPort) {
|
|
9
|
+
try {
|
|
10
|
+
const { SettingsRepository } = await import("../../storage/repositories/settingsRepo.js");
|
|
11
|
+
targetPort = SettingsRepository.getEndpointSettings().port;
|
|
12
|
+
}
|
|
13
|
+
catch { }
|
|
14
|
+
}
|
|
15
|
+
const port = targetPort || DEFAULT_PORT;
|
|
8
16
|
const spinner = ora(`Restarting ${APP_NAME} daemon...`).start();
|
|
9
17
|
await ProcessManager.stopDaemon(port);
|
|
10
18
|
PortHelper.cleanPort(port);
|
|
@@ -17,8 +17,21 @@ export function openBrowser(url) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
export async function runStart(options = {}) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
let targetPort = options.port ? Number(options.port) : undefined;
|
|
21
|
+
let targetHost = options.host;
|
|
22
|
+
if (!targetPort || !targetHost) {
|
|
23
|
+
try {
|
|
24
|
+
const { SettingsRepository } = await import("../../storage/repositories/settingsRepo.js");
|
|
25
|
+
const dbSettings = SettingsRepository.getEndpointSettings();
|
|
26
|
+
if (!targetPort && dbSettings.port)
|
|
27
|
+
targetPort = dbSettings.port;
|
|
28
|
+
if (!targetHost && dbSettings.host)
|
|
29
|
+
targetHost = dbSettings.host;
|
|
30
|
+
}
|
|
31
|
+
catch { }
|
|
32
|
+
}
|
|
33
|
+
const port = targetPort || DEFAULT_PORT;
|
|
34
|
+
const host = targetHost || DEFAULT_HOST;
|
|
22
35
|
const webUrl = `http://${host === "0.0.0.0" ? "localhost" : host}:${port}`;
|
|
23
36
|
if (options.daemon) {
|
|
24
37
|
const spinner = ora(`Starting ${APP_NAME} in background...`).start();
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { DEFAULT_CAPABILITIES, PROVIDER_CAPABILITIES, MODEL_CAPABILITIES, } from "./constants.js";
|
|
13
13
|
import { looksLikeVisionModel, matchPattern, PATTERN_CAPABILITIES, } from "./patterns.js";
|
|
14
14
|
import { getRegistryProvider, getAllRegistryProviders, } from "../../providers/core/metadataRegistry.js";
|
|
15
|
+
import { normalizeModelCompareKey } from "../../shared/utils/modelUtils.js";
|
|
15
16
|
export * from "./types.js";
|
|
16
17
|
export * from "./constants.js";
|
|
17
18
|
export * from "./patterns.js";
|
|
@@ -38,13 +39,17 @@ export function getCapabilitiesForModel(provider, model) {
|
|
|
38
39
|
return { ...DEFAULT_CAPABILITIES };
|
|
39
40
|
const baseModel = model.includes("/") ? model.split("/").pop() : model;
|
|
40
41
|
const inferredProvider = (!provider && model.includes("/")) ? model.split("/")[0] : provider;
|
|
42
|
+
const cleanProvider = inferredProvider ? inferredProvider.replace(/\[.*?\]$/, "") : null;
|
|
41
43
|
// 1. Primary Source of Truth: Provider Metadata Registry
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
const targetKey = normalizeModelCompareKey(baseModel);
|
|
45
|
+
if (cleanProvider) {
|
|
46
|
+
const regProvider = getRegistryProvider(cleanProvider);
|
|
44
47
|
if (regProvider?.models) {
|
|
45
48
|
const match = regProvider.models.find((m) => m.id === model ||
|
|
46
49
|
m.id === baseModel ||
|
|
47
|
-
(m.upstreamModelId && (m.upstreamModelId === model || m.upstreamModelId === baseModel))
|
|
50
|
+
(m.upstreamModelId && (m.upstreamModelId === model || m.upstreamModelId === baseModel)) ||
|
|
51
|
+
normalizeModelCompareKey(m.id) === targetKey ||
|
|
52
|
+
(m.upstreamModelId && normalizeModelCompareKey(m.upstreamModelId) === targetKey));
|
|
48
53
|
if (match?.capabilities) {
|
|
49
54
|
const normalized = normalizeModelCapabilities(match.capabilities);
|
|
50
55
|
if (normalized) {
|
|
@@ -63,7 +68,9 @@ export function getCapabilitiesForModel(provider, model) {
|
|
|
63
68
|
continue;
|
|
64
69
|
const match = regProvider.models.find((m) => m.id === model ||
|
|
65
70
|
m.id === baseModel ||
|
|
66
|
-
(m.upstreamModelId && (m.upstreamModelId === model || m.upstreamModelId === baseModel))
|
|
71
|
+
(m.upstreamModelId && (m.upstreamModelId === model || m.upstreamModelId === baseModel)) ||
|
|
72
|
+
normalizeModelCompareKey(m.id) === targetKey ||
|
|
73
|
+
(m.upstreamModelId && normalizeModelCompareKey(m.upstreamModelId) === targetKey));
|
|
67
74
|
if (match?.capabilities) {
|
|
68
75
|
const normalized = normalizeModelCapabilities(match.capabilities);
|
|
69
76
|
if (normalized) {
|
|
@@ -76,8 +83,8 @@ export function getCapabilitiesForModel(provider, model) {
|
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
85
|
// 2. Provider-specific runtime override
|
|
79
|
-
if (
|
|
80
|
-
const pCaps = PROVIDER_CAPABILITIES[
|
|
86
|
+
if (cleanProvider && PROVIDER_CAPABILITIES[cleanProvider]) {
|
|
87
|
+
const pCaps = PROVIDER_CAPABILITIES[cleanProvider];
|
|
81
88
|
if (pCaps[model])
|
|
82
89
|
return { ...DEFAULT_CAPABILITIES, ...pCaps[model] };
|
|
83
90
|
if (pCaps[baseModel])
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Automatically derives reasoning and effort tiers (High, Medium, Low, Extra Low, Thinking)
|
|
6
6
|
* as well as tags (:free, -preview, -beta) and date versions from the model ID.
|
|
7
7
|
*/
|
|
8
|
+
import { normalizeModelCompareKey } from "../../shared/utils/modelUtils.js";
|
|
8
9
|
export const STANDARD_MODELS = {
|
|
9
10
|
// ── Claude (Anthropic) ──
|
|
10
11
|
"claude-fable-5-1": "Claude Fable 5.1",
|
|
@@ -302,6 +303,22 @@ export function formatModelDisplayNameFallback(modelId) {
|
|
|
302
303
|
})
|
|
303
304
|
.join(" ");
|
|
304
305
|
}
|
|
306
|
+
const NORMALIZED_STANDARD_MODELS = new Map();
|
|
307
|
+
let lastCatalogSize = 0;
|
|
308
|
+
function ensureNormalizedIndex() {
|
|
309
|
+
const currentSize = Object.keys(STANDARD_MODELS).length;
|
|
310
|
+
if (NORMALIZED_STANDARD_MODELS.size === 0 || lastCatalogSize !== currentSize) {
|
|
311
|
+
NORMALIZED_STANDARD_MODELS.clear();
|
|
312
|
+
for (const [id, name] of Object.entries(STANDARD_MODELS)) {
|
|
313
|
+
const normKey = normalizeModelCompareKey(id);
|
|
314
|
+
if (!NORMALIZED_STANDARD_MODELS.has(normKey)) {
|
|
315
|
+
NORMALIZED_STANDARD_MODELS.set(normKey, name);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
lastCatalogSize = currentSize;
|
|
319
|
+
}
|
|
320
|
+
return NORMALIZED_STANDARD_MODELS;
|
|
321
|
+
}
|
|
305
322
|
function lookupStandardModel(key) {
|
|
306
323
|
if (!key)
|
|
307
324
|
return undefined;
|
|
@@ -310,13 +327,12 @@ function lookupStandardModel(key) {
|
|
|
310
327
|
const lower = key.toLowerCase();
|
|
311
328
|
if (STANDARD_MODELS[lower])
|
|
312
329
|
return STANDARD_MODELS[lower];
|
|
313
|
-
// Try dot-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
return STANDARD_MODELS[dashToDot];
|
|
330
|
+
// Try normalized dot/dash equivalent (e.g. "kimi-k3-1-pro" <-> "kimi-k3.1-pro")
|
|
331
|
+
const index = ensureNormalizedIndex();
|
|
332
|
+
const normKey = normalizeModelCompareKey(lower);
|
|
333
|
+
const normalizedMatch = index.get(normKey);
|
|
334
|
+
if (normalizedMatch)
|
|
335
|
+
return normalizedMatch;
|
|
320
336
|
return undefined;
|
|
321
337
|
}
|
|
322
338
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeModelCompareKey } from "../../shared/utils/modelUtils.js";
|
|
1
2
|
const CONTEXT_MARKER = /\[1m\]$/i;
|
|
2
3
|
/**
|
|
3
4
|
* Strips [1m] context marker from model name.
|
|
@@ -33,7 +34,16 @@ export class RuleEngine {
|
|
|
33
34
|
resolveModel(rawModel) {
|
|
34
35
|
const { model: strippedModel, is1mContext } = stripModelContextMarker(rawModel);
|
|
35
36
|
const cleanModel = (strippedModel || rawModel).replace(/\[\d+[mk]?\]$/i, "").trim();
|
|
36
|
-
|
|
37
|
+
let rule = this.rules.get(cleanModel);
|
|
38
|
+
if (!rule) {
|
|
39
|
+
const cleanKey = normalizeModelCompareKey(cleanModel);
|
|
40
|
+
for (const [alias, r] of this.rules.entries()) {
|
|
41
|
+
if (normalizeModelCompareKey(alias) === cleanKey) {
|
|
42
|
+
rule = r;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
37
47
|
return {
|
|
38
48
|
model: rule ? rule.targetModel : cleanModel,
|
|
39
49
|
rule,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Pricing rates for AI models in $/1M tokens
|
|
2
|
+
import { normalizeModelCompareKey } from "../../shared/utils/modelUtils.js";
|
|
2
3
|
export const ZERO_PRICING = {
|
|
3
4
|
input: 0,
|
|
4
5
|
output: 0,
|
|
@@ -47,23 +48,36 @@ export function extractModelPricingCandidates(model) {
|
|
|
47
48
|
stripping = false;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
// 4. Dot vs Dash version variants
|
|
51
|
+
// 4. Dot vs Dash version variants (universal for any model: e.g. k3-1 <-> k3.1, 3-5 <-> 3.5, 4-5 <-> 4.5)
|
|
51
52
|
const variants = [];
|
|
52
53
|
for (const c of candidates) {
|
|
53
|
-
//
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
variants.push(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
// Replace dash between numbers with dot: e.g. "kimi-k3-1-pro" -> "kimi-k3.1-pro"
|
|
55
|
+
const dashToDotNum = c.replace(/(\d+)-(\d+)/g, "$1.$2");
|
|
56
|
+
if (dashToDotNum !== c && !candidates.includes(dashToDotNum) && !variants.includes(dashToDotNum)) {
|
|
57
|
+
variants.push(dashToDotNum);
|
|
58
|
+
}
|
|
59
|
+
// Replace dot between numbers with dash: e.g. "kimi-k3.1-pro" -> "kimi-k3-1-pro"
|
|
60
|
+
const dotToDashNum = c.replace(/(\d+)\.(\d+)/g, "$1-$2");
|
|
61
|
+
if (dotToDashNum !== c && !candidates.includes(dotToDashNum) && !variants.includes(dotToDashNum)) {
|
|
62
|
+
variants.push(dotToDashNum);
|
|
63
|
+
}
|
|
64
|
+
// Claude specific pattern variants (claude-(opus|sonnet|haiku)-X-Y)
|
|
61
65
|
const dot2 = c.replace(/claude-(opus|sonnet|haiku)-(\d+)-(\d+)/g, "claude-$1-$2.$3");
|
|
62
|
-
if (dot2 !== c && !candidates.includes(dot2))
|
|
66
|
+
if (dot2 !== c && !candidates.includes(dot2) && !variants.includes(dot2))
|
|
63
67
|
variants.push(dot2);
|
|
64
68
|
const dash2 = c.replace(/claude-(opus|sonnet|haiku)-(\d+)\.(\d+)/g, "claude-$1-$2-$3");
|
|
65
|
-
if (dash2 !== c && !candidates.includes(dash2))
|
|
69
|
+
if (dash2 !== c && !candidates.includes(dash2) && !variants.includes(dash2))
|
|
66
70
|
variants.push(dash2);
|
|
71
|
+
// Also strip single-word brand prefixes (e.g. "kimi-k3.1-pro" -> "k3.1-pro")
|
|
72
|
+
if (c.includes("-")) {
|
|
73
|
+
const parts = c.split("-");
|
|
74
|
+
if (parts.length > 1) {
|
|
75
|
+
const withoutPrefix = parts.slice(1).join("-");
|
|
76
|
+
if (withoutPrefix && !candidates.includes(withoutPrefix) && !variants.includes(withoutPrefix)) {
|
|
77
|
+
variants.push(withoutPrefix);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
67
81
|
}
|
|
68
82
|
return [...candidates, ...variants];
|
|
69
83
|
}
|
|
@@ -187,10 +201,10 @@ export const PATTERN_PRICING = [
|
|
|
187
201
|
{ pattern: /(argon|carbon)/i, pricing: { input: 2.00, output: 10.00, cached: 0.10, reasoning: 10.00, cache_creation: 2.00 } },
|
|
188
202
|
{ pattern: /gemini-4-hydrogen/i, pricing: { input: 1.50, output: 7.50, cached: 0.075, reasoning: 7.50, cache_creation: 1.50 } },
|
|
189
203
|
{ pattern: /hydrogen/i, pricing: { input: 1.50, output: 7.50, cached: 0.075, reasoning: 7.50, cache_creation: 1.50 } },
|
|
190
|
-
{ pattern: /k3
|
|
204
|
+
{ pattern: /k3[.-]1.*highspeed/i, pricing: { input: 4.00, output: 20.00, cached: 0.20, reasoning: 20.00, cache_creation: 4.00 } },
|
|
191
205
|
{ pattern: /kimi.*highspeed/i, pricing: { input: 4.00, output: 20.00, cached: 0.20, reasoning: 20.00, cache_creation: 4.00 } },
|
|
192
|
-
{ pattern: /k3
|
|
193
|
-
{ pattern: /kimi.*k3
|
|
206
|
+
{ pattern: /k3[.-]1/i, pricing: { input: 2.00, output: 10.00, cached: 0.20, reasoning: 10.00, cache_creation: 2.00 } },
|
|
207
|
+
{ pattern: /kimi.*k3[.-]1/i, pricing: { input: 2.00, output: 10.00, cached: 0.20, reasoning: 10.00, cache_creation: 2.00 } },
|
|
194
208
|
{ pattern: /kimi.*k3/i, pricing: { input: 3.00, output: 15.00, cached: 0.30, reasoning: 15.00, cache_creation: 3.00 } },
|
|
195
209
|
{ pattern: /^k3$/i, pricing: { input: 3.00, output: 15.00, cached: 0.30, reasoning: 15.00, cache_creation: 3.00 } },
|
|
196
210
|
{ pattern: /kimi/i, pricing: { input: 3.00, output: 15.00, cached: 0.30, reasoning: 15.00, cache_creation: 3.00 } },
|
|
@@ -199,11 +213,11 @@ export const PATTERN_PRICING = [
|
|
|
199
213
|
{ pattern: /mimo/i, pricing: { input: 0.14, output: 0.28, cached: 0.0028, reasoning: 0.28, cache_creation: 0.14 } },
|
|
200
214
|
{ pattern: /codex/i, pricing: { input: 1.75, output: 14.00, cached: 0.175, reasoning: 14.00, cache_creation: 1.75 } },
|
|
201
215
|
{ pattern: /claude-.*(fable|mythos)/i, pricing: { input: 10.00, output: 50.00, cached: 1.00, reasoning: 50.00, cache_creation: 12.50 } },
|
|
202
|
-
{ pattern: /claude-.*opus-5
|
|
216
|
+
{ pattern: /claude-.*opus-5[.-]5/i, pricing: { input: 4.00, output: 20.00, cached: 0.40, reasoning: 20.00, cache_creation: 5.00 } },
|
|
203
217
|
{ pattern: /claude-.*opus/i, pricing: { input: 5.00, output: 25.00, cached: 0.50, reasoning: 25.00, cache_creation: 6.25 } },
|
|
204
218
|
{ pattern: /claude-.*sonnet-5/i, pricing: { input: 2.00, output: 10.00, cached: 0.20, reasoning: 10.00, cache_creation: 2.50 } },
|
|
205
219
|
{ pattern: /claude-.*sonnet/i, pricing: { input: 3.00, output: 15.00, cached: 0.30, reasoning: 15.00, cache_creation: 3.75 } },
|
|
206
|
-
{ pattern: /claude-.*haiku-5
|
|
220
|
+
{ pattern: /claude-.*haiku-5[.-]5/i, pricing: { input: 0.10, output: 0.50, cached: 0.01, reasoning: 0.50, cache_creation: 0.125 } },
|
|
207
221
|
{ pattern: /claude-.*haiku/i, pricing: { input: 0.80, output: 4.00, cached: 0.08, reasoning: 4.00, cache_creation: 1.00 } },
|
|
208
222
|
{ pattern: /claude/i, pricing: { input: 3.00, output: 15.00, cached: 0.30, reasoning: 15.00, cache_creation: 3.75 } },
|
|
209
223
|
{ pattern: /gemini-.*flash/i, pricing: { input: 0.30, output: 2.50, cached: 0.03, reasoning: 3.75, cache_creation: 0.30 } },
|
|
@@ -215,30 +229,38 @@ export const PATTERN_PRICING = [
|
|
|
215
229
|
{ pattern: /deepseek/i, pricing: { input: 0.14, output: 0.28, cached: 0.014, reasoning: 0.28, cache_creation: 0.14 } },
|
|
216
230
|
{ pattern: /gpt-6.*terra/i, pricing: { input: 1.00, output: 5.00, cached: 0.05, reasoning: 5.00, cache_creation: 1.00 } },
|
|
217
231
|
{ pattern: /gpt-6/i, pricing: { input: 2.00, output: 10.00, cached: 0.10, reasoning: 10.00, cache_creation: 2.00 } },
|
|
218
|
-
{ pattern: /gpt-5
|
|
219
|
-
{ pattern: /gpt-5
|
|
220
|
-
{ pattern: /gpt-5
|
|
221
|
-
{ pattern: /gpt-5
|
|
222
|
-
{ pattern: /gpt-5
|
|
232
|
+
{ pattern: /gpt-5[.-]6-luna/i, pricing: { input: 0.20, output: 1.20, cached: 0.02, reasoning: 1.20, cache_creation: 0.20 } },
|
|
233
|
+
{ pattern: /gpt-5[.-]6-terra/i, pricing: { input: 2.00, output: 12.00, cached: 0.20, reasoning: 12.00, cache_creation: 2.00 } },
|
|
234
|
+
{ pattern: /gpt-5[.-]6-sol/i, pricing: { input: 4.00, output: 20.00, cached: 0.40, reasoning: 20.00, cache_creation: 4.00 } },
|
|
235
|
+
{ pattern: /gpt-5[.-]5/i, pricing: { input: 5.00, output: 30.00, cached: 0.50, reasoning: 30.00, cache_creation: 5.00 } },
|
|
236
|
+
{ pattern: /gpt-5[.-]4/i, pricing: { input: 2.50, output: 15.00, cached: 0.25, reasoning: 15.00, cache_creation: 2.50 } },
|
|
223
237
|
{ pattern: /gpt-4o/i, pricing: { input: 2.50, output: 10.00, cached: 1.25, reasoning: 15.00, cache_creation: 2.50 } },
|
|
224
238
|
{ pattern: /gpt-5/i, pricing: { input: 1.25, output: 10.00, cached: 0.625, reasoning: 10.00, cache_creation: 1.25 } },
|
|
225
239
|
{ pattern: /gpt-4/i, pricing: { input: 2.50, output: 10.00, cached: 1.25, reasoning: 15.00, cache_creation: 2.50 } },
|
|
226
240
|
{ pattern: /o1/i, pricing: { input: 15.00, output: 60.00, cached: 7.50, reasoning: 90.00, cache_creation: 15.00 } },
|
|
227
241
|
{ pattern: /o3/i, pricing: { input: 1.10, output: 4.40, cached: 0.55, reasoning: 4.40, cache_creation: 1.10 } },
|
|
228
242
|
{ pattern: /qwen.*turbo/i, pricing: { input: 0.05, output: 0.20, cached: 0.01, reasoning: 0.20, cache_creation: 0.05 } },
|
|
229
|
-
{ pattern: /qwen.*(3
|
|
243
|
+
{ pattern: /qwen.*(3[.-]8|3)-max/i, pricing: { input: 2.00, output: 6.00, cached: 0.40, reasoning: 6.00, cache_creation: 2.00 } },
|
|
230
244
|
{ pattern: /qwen.*max/i, pricing: { input: 1.60, output: 6.40, cached: 0.40, reasoning: 6.40, cache_creation: 1.60 } },
|
|
231
245
|
{ pattern: /qwen.*plus/i, pricing: { input: 0.40, output: 1.20, cached: 0.10, reasoning: 1.20, cache_creation: 0.40 } },
|
|
232
246
|
{ pattern: /qwen.*coder.*7b/i, pricing: { input: 0.03, output: 0.10, cached: 0.005, reasoning: 0.10, cache_creation: 0.03 } },
|
|
233
247
|
{ pattern: /qwen/i, pricing: { input: 0.40, output: 1.20, cached: 0.10, reasoning: 1.20, cache_creation: 0.40 } },
|
|
234
248
|
];
|
|
249
|
+
// Normalized index of model pricing for fast O(1) dot/dash lookups
|
|
250
|
+
const NORMALIZED_MODEL_PRICING = new Map();
|
|
251
|
+
for (const [key, rates] of Object.entries(MODEL_PRICING)) {
|
|
252
|
+
const normKey = normalizeModelCompareKey(key);
|
|
253
|
+
if (!NORMALIZED_MODEL_PRICING.has(normKey)) {
|
|
254
|
+
NORMALIZED_MODEL_PRICING.set(normKey, rates);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
235
257
|
export function getPricingForModel(provider, model) {
|
|
236
258
|
if (!model)
|
|
237
259
|
return null;
|
|
238
260
|
if (isFreeModel(model))
|
|
239
261
|
return ZERO_PRICING;
|
|
240
262
|
const candidates = extractModelPricingCandidates(model);
|
|
241
|
-
// 1. Direct match in MODEL_PRICING
|
|
263
|
+
// 1. Direct exact match in MODEL_PRICING (O(1))
|
|
242
264
|
for (const cand of candidates) {
|
|
243
265
|
if (MODEL_PRICING[cand])
|
|
244
266
|
return MODEL_PRICING[cand];
|
|
@@ -246,7 +268,13 @@ export function getPricingForModel(provider, model) {
|
|
|
246
268
|
// Also check original raw model
|
|
247
269
|
if (MODEL_PRICING[model])
|
|
248
270
|
return MODEL_PRICING[model];
|
|
249
|
-
// 2.
|
|
271
|
+
// 2. Normalized dot/dash comparison with MODEL_PRICING keys (O(1))
|
|
272
|
+
for (const cand of candidates) {
|
|
273
|
+
const rates = NORMALIZED_MODEL_PRICING.get(normalizeModelCompareKey(cand));
|
|
274
|
+
if (rates)
|
|
275
|
+
return rates;
|
|
276
|
+
}
|
|
277
|
+
// 3. Pattern matching across original model and stripped candidates
|
|
250
278
|
for (const { pattern, pricing } of PATTERN_PRICING) {
|
|
251
279
|
if (pattern.test(model))
|
|
252
280
|
return pricing;
|
|
@@ -41,21 +41,25 @@ export const toolConfig = {
|
|
|
41
41
|
"gemini-3.1-pro-high": "gemini-pro-agent",
|
|
42
42
|
"gemini-3-pro-high": "gemini-pro-agent",
|
|
43
43
|
"gemini-3-pro-low": "gemini-3.1-pro-low",
|
|
44
|
+
"claude-sonnet-5-5-max": "claude-sonnet-5-5-max",
|
|
44
45
|
"claude-sonnet-5-5-high": "claude-sonnet-5-5-high",
|
|
45
46
|
"claude-sonnet-5-5-medium": "claude-sonnet-5-5-medium",
|
|
46
47
|
"claude-sonnet-5-5-low": "claude-sonnet-5-5-low",
|
|
47
48
|
"claude-sonnet-5-5": "claude-sonnet-5-5",
|
|
48
49
|
"claude-sonnet-5.5": "claude-sonnet-5-5",
|
|
50
|
+
"claude-sonnet-5.5-max": "claude-sonnet-5-5-max",
|
|
49
51
|
"claude-sonnet-5.5-high": "claude-sonnet-5-5-high",
|
|
50
52
|
"claude-sonnet-5.5-medium": "claude-sonnet-5-5-medium",
|
|
51
53
|
"claude-sonnet-5.5-low": "claude-sonnet-5-5-low",
|
|
52
54
|
"claude-sonnet-5-5-thinking": "claude-sonnet-5-5",
|
|
53
55
|
"claude-sonnet-5.5-thinking": "claude-sonnet-5-5",
|
|
56
|
+
"claude-opus-5-5-max": "claude-opus-5-5-max",
|
|
54
57
|
"claude-opus-5-5-high": "claude-opus-5-5-high",
|
|
55
58
|
"claude-opus-5-5-medium": "claude-opus-5-5-medium",
|
|
56
59
|
"claude-opus-5-5-low": "claude-opus-5-5-low",
|
|
57
60
|
"claude-opus-5-5": "claude-opus-5-5",
|
|
58
61
|
"claude-opus-5.5": "claude-opus-5-5",
|
|
62
|
+
"claude-opus-5.5-max": "claude-opus-5-5-max",
|
|
59
63
|
"claude-opus-5.5-high": "claude-opus-5-5-high",
|
|
60
64
|
"claude-opus-5.5-medium": "claude-opus-5-5-medium",
|
|
61
65
|
"claude-opus-5.5-low": "claude-opus-5-5-low",
|
|
@@ -83,9 +87,11 @@ export const toolConfig = {
|
|
|
83
87
|
{ match: /flash.*agent|agent.*flash|flash/i, alias: "gemini-3.8-flash-high" },
|
|
84
88
|
{ match: /pro.*low|low.*pro/i, alias: "gemini-3.1-pro-low" },
|
|
85
89
|
{ match: /gemini.*pro|pro.*gemini/i, alias: "gemini-pro-agent" },
|
|
90
|
+
{ match: /opus.*5[.-]5.*max|5[.-]5.*opus.*max/i, alias: "claude-opus-5-5-max" },
|
|
86
91
|
{ match: /opus.*5[.-]5.*high|5[.-]5.*opus.*high/i, alias: "claude-opus-5-5-high" },
|
|
87
92
|
{ match: /opus.*5[.-]5.*medium|5[.-]5.*opus.*medium/i, alias: "claude-opus-5-5-medium" },
|
|
88
93
|
{ match: /opus.*5[.-]5.*low|5[.-]5.*opus.*low/i, alias: "claude-opus-5-5-low" },
|
|
94
|
+
{ match: /sonnet.*5[.-]5.*max|5[.-]5.*sonnet.*max/i, alias: "claude-sonnet-5-5-max" },
|
|
89
95
|
{ match: /sonnet.*5[.-]5.*high|5[.-]5.*sonnet.*high/i, alias: "claude-sonnet-5-5-high" },
|
|
90
96
|
{ match: /sonnet.*5[.-]5.*medium|5[.-]5.*sonnet.*medium/i, alias: "claude-sonnet-5-5-medium" },
|
|
91
97
|
{ match: /sonnet.*5[.-]5.*low|5[.-]5.*sonnet.*low/i, alias: "claude-sonnet-5-5-low" },
|
|
@@ -21,12 +21,12 @@ export function getRouterTarget() {
|
|
|
21
21
|
if (configured.baseUrl) {
|
|
22
22
|
const apiKey = process.env.ROUTER_API_KEY ? process.env.ROUTER_API_KEY.trim() : (configured.apiKey || "");
|
|
23
23
|
let authHeader = apiKey ? `Bearer ${apiKey}` : "";
|
|
24
|
-
//
|
|
24
|
+
// Dedicated MITM key for local gateway when no explicit key configured
|
|
25
25
|
if (!authHeader && !configured.isRemote) {
|
|
26
26
|
try {
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
authHeader = `Bearer ${
|
|
27
|
+
const mitmKey = SettingsRepository.getOrCreateMitmApiKey();
|
|
28
|
+
if (mitmKey?.key && mitmKey.isActive) {
|
|
29
|
+
authHeader = `Bearer ${mitmKey.key}`;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
catch { }
|
|
@@ -48,9 +48,9 @@ export function getRouterTarget() {
|
|
|
48
48
|
let authHeader = process.env.ROUTER_API_KEY ? `Bearer ${process.env.ROUTER_API_KEY.trim()}` : "";
|
|
49
49
|
if (!authHeader) {
|
|
50
50
|
try {
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
authHeader = `Bearer ${
|
|
51
|
+
const mitmKey = SettingsRepository.getOrCreateMitmApiKey();
|
|
52
|
+
if (mitmKey?.key && mitmKey.isActive) {
|
|
53
|
+
authHeader = `Bearer ${mitmKey.key}`;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
catch { }
|
|
@@ -62,9 +62,19 @@ export function getRouterTarget() {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
catch {
|
|
65
|
+
let authHeader = process.env.ROUTER_API_KEY ? `Bearer ${process.env.ROUTER_API_KEY.trim()}` : "";
|
|
66
|
+
if (!authHeader) {
|
|
67
|
+
try {
|
|
68
|
+
const mitmKey = SettingsRepository.getOrCreateMitmApiKey();
|
|
69
|
+
if (mitmKey?.key && mitmKey.isActive) {
|
|
70
|
+
authHeader = `Bearer ${mitmKey.key}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch { }
|
|
74
|
+
}
|
|
65
75
|
return {
|
|
66
76
|
baseUrl: DEFAULT_ROUTER_BASE,
|
|
67
|
-
authHeader
|
|
77
|
+
authHeader,
|
|
68
78
|
isRemote: false,
|
|
69
79
|
};
|
|
70
80
|
}
|
package/dist/mitm/server.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getCertForDomain } from "./cert/generate.js";
|
|
|
6
6
|
import { passthroughHttps, registerAllMitmHandlers, } from "./handlers/index.js";
|
|
7
7
|
import { MitmHandlerRegistry } from "./registry.js";
|
|
8
8
|
import { MitmRepository } from "../storage/repositories/mitmRepo.js";
|
|
9
|
-
import { getToolForHost, isChatRequest, isModelDiscoveryRequest, extractModel, normalizeModelSlug, MODEL_SYNONYMS, MODEL_PATTERNS, MODEL_NO_MAP, } from "./config.js";
|
|
9
|
+
import { getToolForHost, isChatRequest, isModelDiscoveryRequest, extractModel, normalizeModelSlug, normalizeModelCompareKey, MODEL_SYNONYMS, MODEL_PATTERNS, MODEL_NO_MAP, } from "./config.js";
|
|
10
10
|
import { removeAllDNSEntriesSync } from "./dns/dnsConfig.js";
|
|
11
11
|
registerAllMitmHandlers(MitmHandlerRegistry);
|
|
12
12
|
const DEFAULT_PRIMARY_PORT = 443;
|
|
@@ -48,13 +48,16 @@ export function resolveModelMapping(tool, incomingModel) {
|
|
|
48
48
|
return null;
|
|
49
49
|
const rawNormalized = incomingModel.replace(/^models\//, "").trim();
|
|
50
50
|
const incomingSlug = normalizeModelSlug(incomingModel);
|
|
51
|
+
const incomingKey = normalizeModelCompareKey(incomingModel);
|
|
51
52
|
const toolSynonyms = MODEL_SYNONYMS[tool] || {};
|
|
52
53
|
const synonymTarget = toolSynonyms[rawNormalized] ||
|
|
53
54
|
toolSynonyms[rawNormalized.toLowerCase()] ||
|
|
54
55
|
toolSynonyms[incomingSlug] ||
|
|
56
|
+
toolSynonyms[incomingKey] ||
|
|
55
57
|
rawNormalized;
|
|
56
58
|
const synonymSlug = normalizeModelSlug(synonymTarget);
|
|
57
|
-
|
|
59
|
+
const synonymKey = normalizeModelCompareKey(synonymTarget);
|
|
60
|
+
// 1. Exact match (Strict First) with synonym, normalized ID, or slug
|
|
58
61
|
for (const m of mappings) {
|
|
59
62
|
const mLower = m.sourceModel.toLowerCase();
|
|
60
63
|
const mSlug = normalizeModelSlug(m.sourceModel);
|
|
@@ -65,12 +68,22 @@ export function resolveModelMapping(tool, incomingModel) {
|
|
|
65
68
|
return m.targetModel.trim() || null;
|
|
66
69
|
}
|
|
67
70
|
}
|
|
71
|
+
// 2. Auto-detect fallback: dot/dash interchangeable comparison (e.g. "kimi-k3-1-pro" <-> "kimi-k3.1-pro")
|
|
72
|
+
for (const m of mappings) {
|
|
73
|
+
const mKey = normalizeModelCompareKey(m.sourceModel);
|
|
74
|
+
if (mKey === incomingKey || mKey === synonymKey) {
|
|
75
|
+
return m.targetModel.trim() || null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
68
78
|
// 2. Prefix match
|
|
69
79
|
for (const m of mappings) {
|
|
70
80
|
const mSlug = normalizeModelSlug(m.sourceModel);
|
|
81
|
+
const mKey = normalizeModelCompareKey(m.sourceModel);
|
|
71
82
|
const mLower = m.sourceModel.toLowerCase();
|
|
72
83
|
if (incomingSlug.startsWith(mSlug) ||
|
|
73
84
|
synonymSlug.startsWith(mSlug) ||
|
|
85
|
+
incomingKey.startsWith(mKey) ||
|
|
86
|
+
synonymKey.startsWith(mKey) ||
|
|
74
87
|
mLower.startsWith(rawNormalized.toLowerCase())) {
|
|
75
88
|
return m.targetModel.trim() || null;
|
|
76
89
|
}
|
|
@@ -78,10 +91,12 @@ export function resolveModelMapping(tool, incomingModel) {
|
|
|
78
91
|
// 3. Pattern match (catches renamed or generic flash/opus variants)
|
|
79
92
|
const patterns = MODEL_PATTERNS[tool] || [];
|
|
80
93
|
for (const { match, alias } of patterns) {
|
|
81
|
-
if (match.test(rawNormalized) || match.test(synonymTarget) || match.test(incomingSlug)) {
|
|
94
|
+
if (match.test(rawNormalized) || match.test(synonymTarget) || match.test(incomingSlug) || match.test(incomingKey)) {
|
|
82
95
|
const aliasSlug = normalizeModelSlug(alias);
|
|
96
|
+
const aliasKey = normalizeModelCompareKey(alias);
|
|
83
97
|
const patternMapped = mappings.find((m) => m.sourceModel.toLowerCase() === alias.toLowerCase() ||
|
|
84
|
-
normalizeModelSlug(m.sourceModel) === aliasSlug
|
|
98
|
+
normalizeModelSlug(m.sourceModel) === aliasSlug ||
|
|
99
|
+
normalizeModelCompareKey(m.sourceModel) === aliasKey);
|
|
85
100
|
if (patternMapped)
|
|
86
101
|
return patternMapped.targetModel.trim() || null;
|
|
87
102
|
}
|
package/dist/mitm/toolsHelper.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { MITM_TOOLS } from "./handlers/generated/toolsConfig.js";
|
|
2
|
+
import { normalizeModelCompareKey, areModelNamesEquivalent } from "../shared/utils/modelUtils.js";
|
|
3
|
+
export { normalizeModelCompareKey, areModelNamesEquivalent };
|
|
2
4
|
export const TOOL_HOSTS = Object.fromEntries(MITM_TOOLS.map((t) => [t.id, t.hosts]));
|
|
3
5
|
export const ALL_MITM_HOSTS = Array.from(new Set(MITM_TOOLS.flatMap((t) => t.hosts)));
|
|
4
6
|
export const TARGET_HOSTS = [...ALL_MITM_HOSTS];
|