mapigate 0.5.146 → 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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/commands/restart.js +9 -1
  3. package/dist/cli/commands/start.js +15 -2
  4. package/dist/core/capabilities/index.js +8 -2
  5. package/dist/core/capabilities/modelDictionary.js +23 -7
  6. package/dist/core/router/ruleEngine.js +11 -1
  7. package/dist/core/usage/pricing.js +52 -24
  8. package/dist/mitm/handlers/antigravity/config.js +6 -0
  9. package/dist/mitm/handlers/base.js +18 -8
  10. package/dist/mitm/server.js +19 -4
  11. package/dist/mitm/toolsHelper.js +2 -0
  12. package/dist/providers/runtime/antigravity/executor.js +1 -1
  13. package/dist/providers/runtime/antigravity/metadata.js +2 -2
  14. package/dist/providers/runtime/antigravity/models.js +2 -0
  15. package/dist/providers/runtime/antigravity/provider.js +2 -2
  16. package/dist/providers/runtime/antigravity/routes.js +2 -2
  17. package/dist/providers/runtime/antigravity/types.js +4 -2
  18. package/dist/providers/runtime/gemini/metadata.js +1 -1
  19. package/dist/providers/runtime/gemini/provider.js +2 -2
  20. package/dist/providers/runtime/gemini-cli/provider.js +2 -2
  21. package/dist/server/lifecycle.js +2 -2
  22. package/dist/server/proxy/executorHelpers.js +52 -4
  23. package/dist/server/routes/apiModels.js +141 -8
  24. package/dist/server/routes/apiProviders.js +21 -14
  25. package/dist/server/routes/mitmRouterTargetHelper.js +14 -1
  26. package/dist/shared/utils/modelUtils.js +64 -0
  27. package/dist/storage/database.js +14 -0
  28. package/dist/storage/repositories/accountModelRepo.js +14 -1
  29. package/dist/storage/repositories/providerRepo.js +66 -38
  30. package/dist/storage/repositories/settingsRepo.js +41 -0
  31. package/dist/storage/repositories/toolMappingRepo.js +29 -0
  32. package/dist/web/assets/{CliToolsTab-BYO-wJ7y.js → CliToolsTab-D_MUwimj.js} +1 -1
  33. package/dist/web/assets/CombosTab-EWUYC3TU.js +1 -0
  34. package/dist/web/assets/{ConfirmModal-BS3mAUd5.js → ConfirmModal-CMfDss7P.js} +1 -1
  35. package/dist/web/assets/{ConsoleLogTab-CSgZxPGW.js → ConsoleLogTab-BSMXSYrR.js} +1 -1
  36. package/dist/web/assets/{EditAccountModal-BhPOk3Ya.js → EditAccountModal-OrvqLLBP.js} +1 -1
  37. package/dist/web/assets/{EndpointTab-BRVjAng2.js → EndpointTab-BwtzqXUN.js} +1 -1
  38. package/dist/web/assets/MitmTab-C7g7GUXW.js +14 -0
  39. package/dist/web/assets/ModelAutocompleteInput-DEb_clZC.js +1 -0
  40. package/dist/web/assets/ProviderDetailPage-BIfOQupC.js +6 -0
  41. package/dist/web/assets/{ProvidersTab-BFdg0gXr.js → ProvidersTab-CwJo_EUX.js} +1 -1
  42. package/dist/web/assets/{QuotaTab-DXg3adeS.js → QuotaTab-PFvP6yAb.js} +1 -1
  43. package/dist/web/assets/{SettingsTab-DoYGKtDn.js → SettingsTab-DwAbjIW3.js} +1 -1
  44. package/dist/web/assets/{UsageTab-O6OK0i38.js → UsageTab-85tTb2_C.js} +1 -1
  45. package/dist/web/assets/{index-5TzViNxR.js → index-CWkEEbms.js} +2 -2
  46. package/dist/web/assets/metadataRegistry-FuJXbCt4.js +1 -0
  47. package/dist/web/assets/{providersData-BI_7MaUL.js → providersData-Y57rBt5o.js} +1 -1
  48. package/dist/web/index.html +1 -1
  49. package/package.json +1 -1
  50. package/dist/web/assets/CombosTab-CujUAbYQ.js +0 -1
  51. package/dist/web/assets/MitmTab-ZOoWyRnb.js +0 -14
  52. package/dist/web/assets/ModelAutocompleteInput-DJkxW2yD.js +0 -1
  53. package/dist/web/assets/ProviderDetailPage-CnWjM-0J.js +0 -6
  54. package/dist/web/assets/metadataRegistry-W75_wn57.js +0 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
14
14
  [![Platform](https://img.shields.io/badge/Platform-Windows%20%7C%20Linux%20%7C%20macOS-blueviolet.svg)](#)
15
15
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue.svg)](https://www.typescriptlang.org/)
16
- [![Version](https://img.shields.io/badge/version-0.5.146-orange.svg)](package.json)
16
+ [![Version](https://img.shields.io/badge/version-0.5.150-orange.svg)](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
 
@@ -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
- const port = Number(options?.port) || DEFAULT_PORT;
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
- const port = Number(options.port) || DEFAULT_PORT;
21
- const host = options.host || DEFAULT_HOST;
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";
@@ -40,12 +41,15 @@ export function getCapabilitiesForModel(provider, model) {
40
41
  const inferredProvider = (!provider && model.includes("/")) ? model.split("/")[0] : provider;
41
42
  const cleanProvider = inferredProvider ? inferredProvider.replace(/\[.*?\]$/, "") : null;
42
43
  // 1. Primary Source of Truth: Provider Metadata Registry
44
+ const targetKey = normalizeModelCompareKey(baseModel);
43
45
  if (cleanProvider) {
44
46
  const regProvider = getRegistryProvider(cleanProvider);
45
47
  if (regProvider?.models) {
46
48
  const match = regProvider.models.find((m) => m.id === model ||
47
49
  m.id === baseModel ||
48
- (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));
49
53
  if (match?.capabilities) {
50
54
  const normalized = normalizeModelCapabilities(match.capabilities);
51
55
  if (normalized) {
@@ -64,7 +68,9 @@ export function getCapabilitiesForModel(provider, model) {
64
68
  continue;
65
69
  const match = regProvider.models.find((m) => m.id === model ||
66
70
  m.id === baseModel ||
67
- (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));
68
74
  if (match?.capabilities) {
69
75
  const normalized = normalizeModelCapabilities(match.capabilities);
70
76
  if (normalized) {
@@ -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-to-dash or dash-to-dot variant
314
- const dotToDash = lower.replace(/\./g, "-");
315
- if (STANDARD_MODELS[dotToDash])
316
- return STANDARD_MODELS[dotToDash];
317
- const dashToDot = lower.replace(/-/g, ".");
318
- if (STANDARD_MODELS[dashToDot])
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
- const rule = this.rules.get(cleanModel);
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
- // claude-3-5-xxx <-> claude-3.5-xxx
54
- const dot1 = c.replace(/claude-(\d+)-(\d+)/g, "claude-$1.$2");
55
- if (dot1 !== c && !candidates.includes(dot1))
56
- variants.push(dot1);
57
- const dash1 = c.replace(/claude-(\d+)\.(\d+)/g, "claude-$1-$2");
58
- if (dash1 !== c && !candidates.includes(dash1))
59
- variants.push(dash1);
60
- // claude-(opus|sonnet|haiku)-(\d+)-(\d+) <-> claude-$1-$2.$3
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\.1.*highspeed/i, pricing: { input: 4.00, output: 20.00, cached: 0.20, reasoning: 20.00, cache_creation: 4.00 } },
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\.1/i, pricing: { input: 2.00, output: 10.00, cached: 0.20, reasoning: 10.00, cache_creation: 2.00 } },
193
- { pattern: /kimi.*k3\.1/i, pricing: { input: 2.00, output: 10.00, cached: 0.20, reasoning: 10.00, cache_creation: 2.00 } },
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\.5/i, pricing: { input: 4.00, output: 20.00, cached: 0.40, reasoning: 20.00, cache_creation: 5.00 } },
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\.5/i, pricing: { input: 0.10, output: 0.50, cached: 0.01, reasoning: 0.50, cache_creation: 0.125 } },
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\.6-luna/i, pricing: { input: 0.20, output: 1.20, cached: 0.02, reasoning: 1.20, cache_creation: 0.20 } },
219
- { pattern: /gpt-5\.6-terra/i, pricing: { input: 2.00, output: 12.00, cached: 0.20, reasoning: 12.00, cache_creation: 2.00 } },
220
- { pattern: /gpt-5\.6-sol/i, pricing: { input: 4.00, output: 20.00, cached: 0.40, reasoning: 20.00, cache_creation: 4.00 } },
221
- { pattern: /gpt-5\.5/i, pricing: { input: 5.00, output: 30.00, cached: 0.50, reasoning: 30.00, cache_creation: 5.00 } },
222
- { pattern: /gpt-5\.4/i, pricing: { input: 2.50, output: 15.00, cached: 0.25, reasoning: 15.00, cache_creation: 2.50 } },
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\.8|3)-max/i, pricing: { input: 2.00, output: 6.00, cached: 0.40, reasoning: 6.00, cache_creation: 2.00 } },
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. Pattern matching across original model and stripped candidates
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
- // Only fall back to local gateway key if target is local
24
+ // Dedicated MITM key for local gateway when no explicit key configured
25
25
  if (!authHeader && !configured.isRemote) {
26
26
  try {
27
- const activeKey = SettingsRepository.getGatewayApiKeys().find((k) => k.isActive)?.key;
28
- if (activeKey) {
29
- authHeader = `Bearer ${activeKey}`;
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 activeKey = SettingsRepository.getGatewayApiKeys().find((k) => k.isActive)?.key;
52
- if (activeKey) {
53
- authHeader = `Bearer ${activeKey}`;
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: process.env.ROUTER_API_KEY ? `Bearer ${process.env.ROUTER_API_KEY.trim()}` : "",
77
+ authHeader,
68
78
  isRemote: false,
69
79
  };
70
80
  }
@@ -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
- // 1. Exact match with synonym or normalized or slug
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
  }
@@ -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];
@@ -337,7 +337,7 @@ export async function executeAntigravity(context, providerInstance) {
337
337
  const headers = {
338
338
  "Content-Type": "application/json",
339
339
  Authorization: `Bearer ${creds.accessToken}`,
340
- "User-Agent": "antigravity/hub/2.31.2 darwin/arm64",
340
+ "User-Agent": "antigravity/hub/2.32.1 darwin/arm64",
341
341
  Accept: isStreaming ? "text/event-stream" : "application/json",
342
342
  "x-request-source": "local",
343
343
  };
@@ -27,7 +27,7 @@ export const metadata = {
27
27
  "validateUrl": "",
28
28
  "format": "antigravity",
29
29
  "defaultHeaders": {
30
- "User-Agent": "antigravity/hub/2.31.2 darwin/arm64"
30
+ "User-Agent": "antigravity/hub/2.32.1 darwin/arm64"
31
31
  },
32
32
  "thinkingMode": "auto",
33
33
  "oauth": {
@@ -45,7 +45,7 @@ export const metadata = {
45
45
  "apiVersion": "v1internal",
46
46
  "loadCodeAssistEndpoint": "https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",
47
47
  "onboardUserEndpoint": "https://cloudcode-pa.googleapis.com/v1internal:onboardUser",
48
- "loadCodeAssistUserAgent": "antigravity/hub/2.31.2 darwin/arm64",
48
+ "loadCodeAssistUserAgent": "antigravity/hub/2.32.1 darwin/arm64",
49
49
  "refreshLeadMs": 300000
50
50
  },
51
51
  models
@@ -24,10 +24,12 @@ export const models = [
24
24
  { "id": "gemini-3.1-pro-high", "name": "Gemini 3.1 Pro (High)", "upstreamModelId": "gemini-pro-agent", "isDefault": false },
25
25
  { "id": "gemini-pro-agent", "name": "Gemini 3.1 Pro (High)", "upstreamModelId": "gemini-pro-agent", "isDefault": false },
26
26
  { "id": "gemini-3.1-pro-low", "name": "Gemini 3.1 Pro (Low)", "upstreamModelId": "gemini-3.1-pro-low(low)", "isDefault": false },
27
+ { "id": "claude-sonnet-5-5-max", "name": "Claude Sonnet 5.5 (Max)", "upstreamModelId": "claude-sonnet-5-5-max(max)", "isDefault": false },
27
28
  { "id": "claude-sonnet-5-5-high", "name": "Claude Sonnet 5.5 (High)", "upstreamModelId": "claude-sonnet-5-5-high(high)", "isDefault": false },
28
29
  { "id": "claude-sonnet-5-5-medium", "name": "Claude Sonnet 5.5 (Medium)", "upstreamModelId": "claude-sonnet-5-5-medium(medium)", "isDefault": false },
29
30
  { "id": "claude-sonnet-5-5-low", "name": "Claude Sonnet 5.5 (Low)", "upstreamModelId": "claude-sonnet-5-5-low(low)", "isDefault": false },
30
31
  { "id": "claude-sonnet-5-5", "name": "Claude Sonnet 5.5 (Thinking)", "upstreamModelId": "claude-sonnet-5-5-high(high)", "isDefault": false },
32
+ { "id": "claude-opus-5-5-max", "name": "Claude Opus 5.5 (Max)", "upstreamModelId": "claude-opus-5-5-max(max)", "isDefault": false },
31
33
  { "id": "claude-opus-5-5-high", "name": "Claude Opus 5.5 (High)", "upstreamModelId": "claude-opus-5-5-high(high)", "isDefault": false },
32
34
  { "id": "claude-opus-5-5-medium", "name": "Claude Opus 5.5 (Medium)", "upstreamModelId": "claude-opus-5-5-medium(medium)", "isDefault": false },
33
35
  { "id": "claude-opus-5-5-low", "name": "Claude Opus 5.5 (Low)", "upstreamModelId": "claude-opus-5-5-low(low)", "isDefault": false },
@@ -91,9 +91,9 @@ export class AntigravityProvider extends BaseProvider {
91
91
  ];
92
92
  const reqHeaders = {
93
93
  "Content-Type": "application/json",
94
- "User-Agent": "antigravity/hub/2.31.2 darwin/arm64",
94
+ "User-Agent": "antigravity/hub/2.32.1 darwin/arm64",
95
95
  "X-Client-Name": "antigravity",
96
- "X-Client-Version": "2.31.2",
96
+ "X-Client-Version": "2.32.1",
97
97
  "x-request-source": "local",
98
98
  Accept: "application/json",
99
99
  ...(context.customHeaders || {}),
@@ -55,7 +55,7 @@ export async function loadCodeAssist(accessToken) {
55
55
  headers: {
56
56
  Authorization: `Bearer ${accessToken}`,
57
57
  "Content-Type": "application/json",
58
- "User-Agent": "antigravity/hub/2.31.2 darwin/arm64",
58
+ "User-Agent": "antigravity/hub/2.32.1 darwin/arm64",
59
59
  "x-request-source": "local",
60
60
  },
61
61
  body: JSON.stringify({ metadata: { ideType: 9, platform: getPlatformId(), pluginType: 2 } }),
@@ -80,7 +80,7 @@ export function onboardUser(accessToken, tierId) {
80
80
  const headers = {
81
81
  Authorization: `Bearer ${accessToken}`,
82
82
  "Content-Type": "application/json",
83
- "User-Agent": "antigravity/hub/2.31.2 darwin/arm64",
83
+ "User-Agent": "antigravity/hub/2.32.1 darwin/arm64",
84
84
  "x-request-source": "local",
85
85
  };
86
86
  (async () => {
@@ -1,5 +1,5 @@
1
- export const ANTIGRAVITY_IDE_VERSION = "2.31.2";
2
- export const ANTIGRAVITY_USER_AGENT = "antigravity/hub/2.31.2 darwin/arm64";
1
+ export const ANTIGRAVITY_IDE_VERSION = "2.32.1";
2
+ export const ANTIGRAVITY_USER_AGENT = "antigravity/hub/2.32.1 darwin/arm64";
3
3
  export const ANTIGRAVITY_LOAD_PROJECT_URL = "https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist";
4
4
  export const ANTIGRAVITY_QUOTA_MODELS_URL = "https://daily-cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels";
5
5
  export const ANTIGRAVITY_QUOTA_SUMMARY_URL = "https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary";
@@ -79,10 +79,12 @@ export const IMPORTANT_MODELS = [
79
79
  "gemini-3.1-pro-high",
80
80
  "gemini-pro-agent",
81
81
  "gemini-3.1-pro-low",
82
+ "claude-sonnet-5-5-max",
82
83
  "claude-sonnet-5-5-high",
83
84
  "claude-sonnet-5-5-medium",
84
85
  "claude-sonnet-5-5-low",
85
86
  "claude-sonnet-5-5",
87
+ "claude-opus-5-5-max",
86
88
  "claude-opus-5-5-high",
87
89
  "claude-opus-5-5-medium",
88
90
  "claude-opus-5-5-low",
@@ -7,7 +7,7 @@ export const metadata = {
7
7
  "Tokens (Daily)"
8
8
  ],
9
9
  id: "gemini",
10
- name: "Google Gemini",
10
+ name: "Google AI Studio",
11
11
  alias: "gemini",
12
12
  color: "#4285F4",
13
13
  image: "/assets/providers/gemini/icon.png",
@@ -75,7 +75,7 @@ function sanitizeGeminiOpenAiPayload(payload) {
75
75
  }
76
76
  export class GeminiProvider extends OpenAiCompatibleProvider {
77
77
  id = "gemini";
78
- name = "Google Gemini";
78
+ name = "Google AI Studio";
79
79
  defaultFormat = "openai";
80
80
  supportsQuota() {
81
81
  return true;
@@ -186,7 +186,7 @@ export class GeminiProvider extends OpenAiCompatibleProvider {
186
186
  const msg = err instanceof Error ? err.message : String(err);
187
187
  return {
188
188
  success: false,
189
- error: `Failed to connect to Google Gemini: ${msg}`,
189
+ error: `Failed to connect to Google AI Studio: ${msg}`,
190
190
  };
191
191
  }
192
192
  }
@@ -44,9 +44,9 @@ export class GeminiCliProvider extends OpenAiCompatibleProvider {
44
44
  ];
45
45
  const reqHeaders = {
46
46
  "Content-Type": "application/json",
47
- "User-Agent": "antigravity/hub/2.31.2 darwin/arm64",
47
+ "User-Agent": "antigravity/hub/2.32.1 darwin/arm64",
48
48
  "X-Client-Name": "antigravity",
49
- "X-Client-Version": "2.31.2",
49
+ "X-Client-Version": "2.32.1",
50
50
  "x-request-source": "local",
51
51
  Accept: "application/json",
52
52
  ...(context.customHeaders || {}),
@@ -181,8 +181,8 @@ export class ServerLifecycle {
181
181
  dbSettings = SettingsRepository.getEndpointSettings();
182
182
  }
183
183
  catch { }
184
- const port = Number(process.env.PORT) || dbSettings?.port || DEFAULT_PORT;
185
- const host = process.env.HOST || dbSettings?.host || DEFAULT_HOST;
184
+ const port = dbSettings?.port || Number(process.env.PORT) || DEFAULT_PORT;
185
+ const host = dbSettings?.host || process.env.HOST || DEFAULT_HOST;
186
186
  const { cmd, args, shell } = ProcessManager.resolveSpawnCommand();
187
187
  const dataDir = getDefaultDataDir();
188
188
  if (!fs.existsSync(dataDir)) {