mapigate 0.5.98 → 0.5.120

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 (86) hide show
  1. package/README.md +7 -1
  2. package/dist/core/adapters/anthropic/streamAnthropicToOpenAi.js +94 -13
  3. package/dist/core/adapters/anthropic/types.js +3 -1
  4. package/dist/core/adapters/anthropicAdapter.js +2 -2
  5. package/dist/core/adapters/helpers/toolCallRescue.js +224 -10
  6. package/dist/core/adapters/responsesAdapter.js +56 -3
  7. package/dist/core/resilience/index.js +5 -0
  8. package/dist/core/router/earliestResetComparator.js +14 -4
  9. package/dist/core/router/loadBalancer.js +27 -3
  10. package/dist/core/scanner/modelScanner.js +8 -1
  11. package/dist/core/scanner/payloadExtractor.js +8 -3
  12. package/dist/core/scanner/urlResolver.js +10 -2
  13. package/dist/core/usage/quotaService.js +3 -1
  14. package/dist/providers/catalog/xiaomi-tokenplan/metadata.js +6 -1
  15. package/dist/providers/catalog/xiaomi-tokenplan/provider.js +71 -1
  16. package/dist/providers/core/base/baseProvider.js +1 -0
  17. package/dist/providers/runtime/antigravity/executor.js +1 -1
  18. package/dist/providers/runtime/antigravity/metadata.js +4 -3
  19. package/dist/providers/runtime/antigravity/provider.js +2 -2
  20. package/dist/providers/runtime/antigravity/quota.js +9 -3
  21. package/dist/providers/runtime/antigravity/routes.js +2 -2
  22. package/dist/providers/runtime/antigravity/types.js +10 -2
  23. package/dist/providers/runtime/antigravity/weekly.js +1 -1
  24. package/dist/providers/runtime/codex/models.js +1 -6
  25. package/dist/providers/runtime/codex/routes.js +40 -24
  26. package/dist/providers/runtime/cursor/cursorChecksum.js +80 -0
  27. package/dist/providers/runtime/cursor/cursorModels.js +194 -0
  28. package/dist/providers/runtime/cursor/cursorProtobuf.js +193 -0
  29. package/dist/providers/runtime/cursor/cursorSession.js +118 -0
  30. package/dist/providers/runtime/cursor/cursorStreamer.js +250 -0
  31. package/dist/providers/runtime/cursor/cursorWire.js +243 -0
  32. package/dist/providers/runtime/cursor/executor.js +129 -0
  33. package/dist/providers/runtime/cursor/index.js +6 -0
  34. package/dist/providers/runtime/cursor/provider.js +34 -10
  35. package/dist/providers/runtime/cursor-api/auth.js +47 -102
  36. package/dist/providers/runtime/cursor-api/metadata.js +4 -4
  37. package/dist/providers/runtime/cursor-api/provider.js +58 -21
  38. package/dist/providers/runtime/gemini-cli/provider.js +2 -2
  39. package/dist/providers/runtime/kiro/executor.js +4 -2
  40. package/dist/providers/runtime/kiro/metadata.js +2 -2
  41. package/dist/providers/runtime/mimo/metadata.js +1 -0
  42. package/dist/providers/runtime/mimo/provider.js +56 -0
  43. package/dist/server/index.js +10 -1
  44. package/dist/server/proxy/executorHelpers.js +12 -2
  45. package/dist/server/proxy/singleModelExecutor.js +2 -0
  46. package/dist/server/proxy/streaming/sseStreamer.js +7 -2
  47. package/dist/server/routes/apiModels.js +60 -0
  48. package/dist/server/routes/apiProviders.js +50 -9
  49. package/dist/server/routes/apiServer.js +110 -0
  50. package/dist/server/routes/apiSettings.js +35 -7
  51. package/dist/server/routes/apiUsage.js +5 -3
  52. package/dist/shared/constants/quotaOrder.js +1 -0
  53. package/dist/storage/database.js +31 -0
  54. package/dist/storage/repositories/accountModelRepo.js +108 -0
  55. package/dist/storage/repositories/logRepo.js +71 -10
  56. package/dist/storage/repositories/providerRepo.js +69 -59
  57. package/dist/storage/repositories/requestDetailsRepo.js +8 -0
  58. package/dist/storage/repositories/settingsRepo.js +17 -0
  59. package/dist/storage/repositories/usageRepo.js +228 -72
  60. package/dist/web/assets/{CliToolsTab-DE48Y4QZ.js → CliToolsTab-BzhczMaa.js} +1 -1
  61. package/dist/web/assets/{CombosTab-dsZhV95u.js → CombosTab-Cz8KYH4M.js} +1 -1
  62. package/dist/web/assets/{ConfirmModal-BTwfpfgO.js → ConfirmModal-BU1PPpF0.js} +1 -1
  63. package/dist/web/assets/{ConsoleLogTab-DtUTPoi7.js → ConsoleLogTab-CFvXde1l.js} +1 -1
  64. package/dist/web/assets/EditAccountModal-CS2TR4bt.js +1 -0
  65. package/dist/web/assets/{EndpointTab-Ya1KYJSp.js → EndpointTab-DZCRpAbh.js} +1 -1
  66. package/dist/web/assets/{MitmTab-Bl-E-IDY.js → MitmTab-CTfwqdey.js} +1 -1
  67. package/dist/web/assets/{ModelAutocompleteInput-COe36ge6.js → ModelAutocompleteInput-CAi2R2s9.js} +1 -1
  68. package/dist/web/assets/ProviderDetailPage-Dv2LpFj_.js +6 -0
  69. package/dist/web/assets/{ProvidersTab-COC-cJXg.js → ProvidersTab-DwHMHdPu.js} +1 -1
  70. package/dist/web/assets/QuotaTab-DS1y9gGp.js +1 -0
  71. package/dist/web/assets/SettingsTab-DULcs9O4.js +1 -0
  72. package/dist/web/assets/UsageTab-DKBaBAeT.js +1 -0
  73. package/dist/web/assets/index-BisuNW2y.css +1 -0
  74. package/dist/web/assets/index-DPdrZakW.js +2 -0
  75. package/dist/web/assets/metadataRegistry-7DDoxaR3.js +1 -0
  76. package/dist/web/assets/{providersData-DRVJJUB4.js → providersData-Br5RocnM.js} +1 -1
  77. package/dist/web/index.html +2 -2
  78. package/package.json +1 -1
  79. package/dist/web/assets/EditAccountModal-65P5phzh.js +0 -1
  80. package/dist/web/assets/ProviderDetailPage-BnQ7kK6s.js +0 -6
  81. package/dist/web/assets/QuotaTab-DkRBaW79.js +0 -1
  82. package/dist/web/assets/SettingsTab-DPcPmPUd.js +0 -1
  83. package/dist/web/assets/UsageTab-Danjts5j.js +0 -1
  84. package/dist/web/assets/index-CeC7GeyM.js +0 -2
  85. package/dist/web/assets/index-YgSWkEbZ.css +0 -1
  86. package/dist/web/assets/metadataRegistry-Dxrq24qH.js +0 -1
@@ -3,6 +3,7 @@ import { getRegistryProvider } from "../../shared/constants/providerRegistry.js"
3
3
  import { ensureFreshCredentials } from "../usage/tokenHelper.js";
4
4
  import { ProviderRegistry } from "../../providers/core/registry.js";
5
5
  import { resolveCandidateUrls } from "./urlResolver.js";
6
+ import { AccountModelRepository } from "../../storage/repositories/accountModelRepo.js";
6
7
  export { resolveCandidateUrls } from "./urlResolver.js";
7
8
  export { extractModelsFromPayload } from "./payloadExtractor.js";
8
9
  /**
@@ -25,7 +26,7 @@ export async function scanProviderModels(options) {
25
26
  if (providerId) {
26
27
  dbProvider = ProviderRepository.getProviderById(providerId);
27
28
  if (!baseUrl) {
28
- baseUrl = dbProvider?.baseUrl || registryItem?.baseUrl;
29
+ baseUrl = dbProvider?.modelsUrl || registryItem?.modelsUrl || dbProvider?.baseUrl || registryItem?.baseUrl;
29
30
  }
30
31
  if (!format) {
31
32
  format = dbProvider?.format || registryItem?.format;
@@ -169,10 +170,16 @@ export async function scanProviderModels(options) {
169
170
  if (!discoveredEndpointUrl && probeRes.endpointUrl) {
170
171
  discoveredEndpointUrl = probeRes.endpointUrl;
171
172
  }
173
+ const accountModelIds = [];
172
174
  for (const m of probeRes.models || []) {
173
175
  if (!modelsById.has(m.id)) {
174
176
  modelsById.set(m.id, m);
175
177
  }
178
+ accountModelIds.push(m.id);
179
+ }
180
+ // Persist account-specific supported models if not an ad-hoc explicit key
181
+ if (account.id && account.id !== "explicit" && !account.id.startsWith("acc_virtual") && accountModelIds.length > 0) {
182
+ AccountModelRepository.setAccountModels(account.id, accountModelIds);
176
183
  }
177
184
  scannedAccounts.push({ id: account.id, name: account.name });
178
185
  }
@@ -141,9 +141,14 @@ export function extractModelsFromPayload(data, providerId) {
141
141
  if (typeof rawCtx === "number" && rawCtx > 0) {
142
142
  contextLength = rawCtx;
143
143
  }
144
- const isImageSupported = Array.isArray(rec.supportedInputTypes) &&
145
- rec.supportedInputTypes.includes("IMAGE");
146
- const isReasoning = id.includes("thinking") ||
144
+ const recCaps = rec.capabilities && typeof rec.capabilities === "object" ? rec.capabilities : undefined;
145
+ const isVisionFromCaps = typeof recCaps?.vision === "boolean" ? recCaps.vision : false;
146
+ const isReasoningFromCaps = typeof recCaps?.reasoning === "boolean" ? recCaps.reasoning : false;
147
+ const isImageSupported = isVisionFromCaps ||
148
+ (Array.isArray(rec.supportedInputTypes) &&
149
+ rec.supportedInputTypes.includes("IMAGE"));
150
+ const isReasoning = isReasoningFromCaps ||
151
+ id.includes("thinking") ||
147
152
  id.includes("r1") ||
148
153
  id.includes("reasoning") ||
149
154
  description?.toLowerCase().includes("reasoning");
@@ -117,14 +117,22 @@ export function resolveCandidateUrls(baseUrl, format, providerId, registryItem,
117
117
  cleanBase = cleanBase.slice(0, cleanBase.length - "/responses".length).replace(/\/+$/, "");
118
118
  lowerBase = cleanBase.toLowerCase();
119
119
  }
120
+ else if (lowerBase.endsWith("/usage")) {
121
+ cleanBase = cleanBase.slice(0, cleanBase.length - "/usage".length).replace(/\/+$/, "");
122
+ lowerBase = cleanBase.toLowerCase();
123
+ add(`${cleanBase}/models`);
124
+ }
120
125
  // 3. Ollama special endpoints
121
126
  if (isOllama) {
122
127
  add(`${cleanBase}/api/tags`);
123
128
  add(`${cleanBase}/v1/models`);
124
129
  add(`${cleanBase}/models`);
125
130
  }
126
- // 4. Registry validateUrl fallback if it points to /models or /api/tags
127
- if (registryItem?.validateUrl) {
131
+ // 4. Registry modelsUrl or validateUrl fallback if it points to /models or /api/tags
132
+ if (registryItem?.modelsUrl) {
133
+ add(registryItem.modelsUrl.trim());
134
+ }
135
+ else if (registryItem?.validateUrl) {
128
136
  const vUrl = registryItem.validateUrl.trim();
129
137
  const isExternalXiaomiBypass = isTokenPlan && !lowerBase.includes("xiaomimimo.com") && vUrl.toLowerCase().includes("xiaomimimo.com");
130
138
  if (!isExternalXiaomiBypass && (vUrl.toLowerCase().includes("/models") || vUrl.toLowerCase().includes("/api/tags"))) {
@@ -129,19 +129,21 @@ export class QuotaService {
129
129
  const quotas = [];
130
130
  if (rawResult.quotas) {
131
131
  for (const [key, bucket] of Object.entries(rawResult.quotas)) {
132
- // If antigravity, filter strictly to the 4 recognized summary buckets
132
+ // If antigravity, filter strictly to the recognized summary buckets
133
133
  if (account.providerId.toLowerCase() === "antigravity") {
134
134
  const allowedAntigravityKeys = [
135
135
  "gemini_session",
136
136
  "gemini_weekly",
137
137
  "claude_gpt_session",
138
138
  "claude_gpt_weekly",
139
+ "gemini_4_argon_weekly",
139
140
  ];
140
141
  const allowedLabels = [
141
142
  "gemini (5h)",
142
143
  "gemini (weekly)",
143
144
  "claude & gpt (5h)",
144
145
  "claude & gpt (weekly)",
146
+ "gemini 4 argon (weekly)",
145
147
  ];
146
148
  const isAllowed = allowedAntigravityKeys.includes(key.toLowerCase()) ||
147
149
  allowedLabels.includes((bucket.displayName || "").toLowerCase());
@@ -25,7 +25,8 @@ export const metadata = {
25
25
  "https://token-plan-sgp.xiaomimimo.com/v1/chat/completions"
26
26
  ],
27
27
  "validateUrl": "https://token-plan-sgp.xiaomimimo.com/v1/models",
28
- "format": "openai",
28
+ "format": "claude",
29
+ "rescueInlineTools": true,
29
30
  "defaultHeaders": {},
30
31
  "thinkingMode": "auto",
31
32
  "regions": [
@@ -43,6 +44,10 @@ export const metadata = {
43
44
  }
44
45
  ],
45
46
  "defaultRegion": "sgp",
47
+ "supportedFormats": [
48
+ { "value": "claude", "label": "Anthropic API (/anthropic/v1/messages) - Recommended" },
49
+ { "value": "openai", "label": "OpenAI API (/v1/chat/completions)" }
50
+ ],
46
51
  "hasProviderSpecificData": true,
47
52
  models
48
53
  };
@@ -2,10 +2,11 @@ import { OpenAiCompatibleProvider } from "../../core/base/openAiProvider.js";
2
2
  import { metadata } from "./metadata.js";
3
3
  import { getMimoUsage } from "../../runtime/mimo/quota.js";
4
4
  import { AnthropicAdapter } from "../../../core/adapters/anthropicAdapter.js";
5
+ import { rescueInlineToolCalls, createStreamToolCallRescuer, } from "../../../core/adapters/helpers/toolCallRescue.js";
5
6
  export class XiaomiTokenplanProvider extends OpenAiCompatibleProvider {
6
7
  id = metadata.id;
7
8
  name = metadata.name;
8
- defaultFormat = metadata.format || "openai";
9
+ defaultFormat = metadata.format || "claude";
9
10
  supportsQuota() {
10
11
  return true;
11
12
  }
@@ -27,6 +28,14 @@ export class XiaomiTokenplanProvider extends OpenAiCompatibleProvider {
27
28
  buildUrl(context) {
28
29
  const psd = context.account?.providerSpecificData || {};
29
30
  const region = psd.region || "sgp";
31
+ const customBase = context.provider?.baseUrl;
32
+ if (customBase && !customBase.includes("xiaomimimo.com")) {
33
+ const cleanBase = customBase.replace(/\/+$/, "");
34
+ if (context.targetFormat === "claude") {
35
+ return cleanBase.endsWith("/messages") ? cleanBase : `${cleanBase}/v1/messages`;
36
+ }
37
+ return cleanBase.endsWith("/chat/completions") ? cleanBase : `${cleanBase}/v1/chat/completions`;
38
+ }
30
39
  if (context.targetFormat === "claude") {
31
40
  return `https://token-plan-${region}.xiaomimimo.com/anthropic/v1/messages`;
32
41
  }
@@ -43,8 +52,69 @@ export class XiaomiTokenplanProvider extends OpenAiCompatibleProvider {
43
52
  if (!headers["anthropic-version"]) {
44
53
  headers["anthropic-version"] = "2023-06-01";
45
54
  }
55
+ if (!headers["anthropic-beta"]) {
56
+ headers["anthropic-beta"] = "claude-code-20250219,interleaved-thinking-2025-05-14";
57
+ }
58
+ if (!headers["user-agent"]) {
59
+ headers["user-agent"] = "claude-code/0.2.29 (external; x86_64)";
60
+ }
46
61
  }
47
62
  return headers;
48
63
  }
64
+ transformResponseChunk(chunk, context) {
65
+ if (!chunk?.choices?.length)
66
+ return chunk;
67
+ const choice = chunk.choices[0];
68
+ const delta = choice?.delta;
69
+ if (!delta?.content || typeof delta.content !== "string")
70
+ return chunk;
71
+ const ctx = context;
72
+ if (!ctx._toolRescuer) {
73
+ ctx._toolRescuer = createStreamToolCallRescuer();
74
+ }
75
+ const { calls, cleanText } = ctx._toolRescuer.feed(delta.content);
76
+ if (calls.length > 0) {
77
+ delta.tool_calls = calls.map((c, idx) => ({
78
+ index: idx,
79
+ id: `call_mimo_${Date.now()}_${idx}`,
80
+ type: "function",
81
+ function: {
82
+ name: c.name,
83
+ arguments: c.arguments,
84
+ },
85
+ }));
86
+ delta.content = cleanText || null;
87
+ if (choice.finish_reason === "stop") {
88
+ choice.finish_reason = "tool_calls";
89
+ }
90
+ return chunk;
91
+ }
92
+ delta.content = cleanText;
93
+ return chunk;
94
+ }
95
+ transformResponseBody(body, _context) {
96
+ if (!body || typeof body !== "object")
97
+ return body;
98
+ const choice = body.choices?.[0];
99
+ const msg = choice?.message;
100
+ if (msg?.content && typeof msg.content === "string" && msg.content.includes("<tool_call>")) {
101
+ const rescue = rescueInlineToolCalls(msg.content, new Set());
102
+ if (rescue.detected && rescue.calls && rescue.calls.length > 0) {
103
+ msg.tool_calls = rescue.calls.map((c, idx) => ({
104
+ id: `call_mimo_${Date.now()}_${idx}`,
105
+ type: "function",
106
+ function: {
107
+ name: c.name,
108
+ arguments: c.arguments,
109
+ },
110
+ }));
111
+ msg.content = rescue.cleanText || null;
112
+ if (choice.finish_reason === "stop" || !choice.finish_reason) {
113
+ choice.finish_reason = "tool_calls";
114
+ }
115
+ }
116
+ }
117
+ return body;
118
+ }
49
119
  }
50
120
  export default XiaomiTokenplanProvider;
@@ -92,6 +92,7 @@ export class BaseProvider {
92
92
  }
93
93
  if (psd.chatgptAccountId) {
94
94
  outgoingHeaders["chatgpt-account-id"] = psd.chatgptAccountId;
95
+ outgoingHeaders["ChatGPT-Account-Id"] = psd.chatgptAccountId;
95
96
  }
96
97
  if (isNoApiKey && !bearerToken) {
97
98
  delete outgoingHeaders["Authorization"];
@@ -319,7 +319,7 @@ export async function executeAntigravity(context, providerInstance) {
319
319
  const headers = {
320
320
  "Content-Type": "application/json",
321
321
  Authorization: `Bearer ${creds.accessToken}`,
322
- "User-Agent": "antigravity/hub/2.28.0 darwin/arm64",
322
+ "User-Agent": "antigravity/hub/2.29.0 darwin/arm64",
323
323
  Accept: isStreaming ? "text/event-stream" : "application/json",
324
324
  "x-request-source": "local",
325
325
  };
@@ -4,7 +4,8 @@ export const metadata = {
4
4
  "Gemini (5h)",
5
5
  "Gemini (Weekly)",
6
6
  "Claude & GPT (5h)",
7
- "Claude & GPT (Weekly)"
7
+ "Claude & GPT (Weekly)",
8
+ "Gemini 4 Argon (Weekly)"
8
9
  ],
9
10
  "id": "antigravity",
10
11
  "name": "Antigravity",
@@ -26,7 +27,7 @@ export const metadata = {
26
27
  "validateUrl": "",
27
28
  "format": "antigravity",
28
29
  "defaultHeaders": {
29
- "User-Agent": "antigravity/hub/2.28.0 darwin/arm64"
30
+ "User-Agent": "antigravity/hub/2.29.0 darwin/arm64"
30
31
  },
31
32
  "thinkingMode": "auto",
32
33
  "oauth": {
@@ -44,7 +45,7 @@ export const metadata = {
44
45
  "apiVersion": "v1internal",
45
46
  "loadCodeAssistEndpoint": "https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",
46
47
  "onboardUserEndpoint": "https://cloudcode-pa.googleapis.com/v1internal:onboardUser",
47
- "loadCodeAssistUserAgent": "antigravity/hub/2.28.0 darwin/arm64",
48
+ "loadCodeAssistUserAgent": "antigravity/hub/2.29.0 darwin/arm64",
48
49
  "refreshLeadMs": 300000
49
50
  },
50
51
  models
@@ -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.28.0 darwin/arm64",
94
+ "User-Agent": "antigravity/hub/2.29.0 darwin/arm64",
95
95
  "X-Client-Name": "antigravity",
96
- "X-Client-Version": "2.28.0",
96
+ "X-Client-Version": "2.29.0",
97
97
  "x-request-source": "local",
98
98
  Accept: "application/json",
99
99
  ...(context.customHeaders || {}),
@@ -109,14 +109,20 @@ export async function getAntigravityUsage(accessToken, providerSpecificData, opt
109
109
  try {
110
110
  const weeklyQuotas = await fetchAntigravityWeeklyQuota(accessToken, projectId, options);
111
111
  if (isFreeTier) {
112
- for (const k of ["gemini_weekly", "claude_gpt_weekly"]) {
112
+ for (const k of ["gemini_weekly", "claude_gpt_weekly", "gemini_4_argon_weekly"]) {
113
113
  if (weeklyQuotas[k])
114
114
  quotas[k] = weeklyQuotas[k];
115
115
  }
116
116
  }
117
117
  else {
118
118
  reconcileModelQuotasIntoWeekly(modelQuotas, weeklyQuotas);
119
- for (const key of ["gemini_session", "gemini_weekly", "claude_gpt_session", "claude_gpt_weekly"]) {
119
+ for (const key of [
120
+ "gemini_session",
121
+ "gemini_weekly",
122
+ "claude_gpt_session",
123
+ "claude_gpt_weekly",
124
+ "gemini_4_argon_weekly",
125
+ ]) {
120
126
  if (weeklyQuotas[key])
121
127
  quotas[key] = weeklyQuotas[key];
122
128
  }
@@ -136,7 +142,7 @@ export async function getAntigravityUsage(accessToken, providerSpecificData, opt
136
142
  }
137
143
  function reconcileModelQuotasIntoWeekly(modelQuotas, weeklyQuotas) {
138
144
  const entries = Object.entries(modelQuotas);
139
- const geminiModels = entries.filter(([k]) => k.startsWith("gemini-") && !k.includes("image"));
145
+ const geminiModels = entries.filter(([k]) => k.startsWith("gemini-") && !k.includes("image") && !k.includes("argon"));
140
146
  const claudeModels = entries.filter(([k]) => k.startsWith("claude-"));
141
147
  if (!weeklyQuotas.gemini_session && geminiModels.length > 0) {
142
148
  const rep = geminiModels.reduce((min, cur) => (cur[1].remainingPercentage ?? 100) < (min[1].remainingPercentage ?? 100) ? cur : min)[1];
@@ -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.28.0 darwin/arm64",
58
+ "User-Agent": "antigravity/hub/2.29.0 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.28.0 darwin/arm64",
83
+ "User-Agent": "antigravity/hub/2.29.0 darwin/arm64",
84
84
  "x-request-source": "local",
85
85
  };
86
86
  (async () => {
@@ -1,5 +1,5 @@
1
- export const ANTIGRAVITY_IDE_VERSION = "2.28.0";
2
- export const ANTIGRAVITY_USER_AGENT = "antigravity/hub/2.28.0 darwin/arm64";
1
+ export const ANTIGRAVITY_IDE_VERSION = "2.29.0";
2
+ export const ANTIGRAVITY_USER_AGENT = "antigravity/hub/2.29.0 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";
@@ -39,6 +39,10 @@ export const CLIENT_METADATA = {
39
39
  pluginType: PLUGIN_TYPE.GEMINI,
40
40
  };
41
41
  export const GROUP_CONFIGS = [
42
+ {
43
+ pattern: /argon/i,
44
+ weekly: { key: "gemini_4_argon_weekly", displayName: "Gemini 4 Argon (Weekly)" },
45
+ },
42
46
  {
43
47
  pattern: /gemini/i,
44
48
  weekly: { key: "gemini_weekly", displayName: "Gemini (Weekly)" },
@@ -51,6 +55,10 @@ export const GROUP_CONFIGS = [
51
55
  },
52
56
  ];
53
57
  export const IMPORTANT_MODELS = [
58
+ "gemini-4-argon-high",
59
+ "gemini-4-argon-medium",
60
+ "gemini-4-argon-low",
61
+ "gemini-4-argon",
54
62
  "gemini-3.8-flash-high",
55
63
  "gemini-3.8-flash-medium",
56
64
  "gemini-3.8-flash-low",
@@ -50,7 +50,7 @@ export function parseWeeklyQuotaSummary(data) {
50
50
  for (const config of GROUP_CONFIGS) {
51
51
  if (config.pattern.test(displayName)) {
52
52
  const target = isWeekly ? config.weekly : config.session;
53
- if (result[target.key])
53
+ if (!target || result[target.key])
54
54
  break;
55
55
  const total = isWeekly ? 3000 : 1000;
56
56
  const remaining = Math.round(total * remainingFraction);
@@ -17,8 +17,6 @@ export const models = [
17
17
  { "id": "gpt-5.6-luna[1m]", "name": "GPT 5.6 Luna (extended context)", "upstreamModelId": "gpt-5.6-luna", "isDefault": false },
18
18
  { "id": "gpt-5.6-luna-review", "name": "GPT 5.6 Luna Review", "upstreamModelId": "gpt-5.6-luna", "isDefault": false },
19
19
  { "id": "gpt-daybreak-blue-latest", "name": "GPT Daybreak Blue", "isDefault": false },
20
- { "id": "gpt-5.5-codex", "name": "GPT 5.5 Codex", "isDefault": false, "contextLength": 400000 },
21
- { "id": "codex-pro", "name": "Codex Pro", "isDefault": false, "contextLength": 400000 },
22
20
  { "id": "gpt-reserve", "name": "GPT Reserve", "isDefault": false },
23
21
  { "id": "codex-auto-review", "name": "Codex Auto Review", "upstreamModelId": "codex-auto-review", "isDefault": false },
24
22
  { "id": "gpt-image-2.5", "name": "GPT Image 2.5", "isDefault": false, "capabilities": ["text2img", "edit", "multiImage"], "kind": "image" },
@@ -26,8 +24,5 @@ export const models = [
26
24
  { "id": "gpt-image-2.5-sunburst", "name": "GPT Image 2.5 Sunburst", "isDefault": false, "capabilities": ["text2img", "edit", "multiImage"], "kind": "image" },
27
25
  { "id": "gpt-image-2", "name": "GPT Image 2", "isDefault": false, "capabilities": ["text2img", "edit", "multiImage"], "kind": "image" },
28
26
  { "id": "gpt-image-1.5", "name": "GPT Image 1.5", "isDefault": false, "capabilities": ["text2img", "edit", "multiImage"], "kind": "image" },
29
- { "id": "gpt-5.6-sol-image", "name": "GPT 5.6 Sol Image", "isDefault": false, "capabilities": ["text2img", "edit"], "kind": "image" },
30
- { "id": "gpt-5.6-terra-image", "name": "GPT 5.6 Terra Image", "isDefault": false, "capabilities": ["text2img", "edit"], "kind": "image" },
31
- { "id": "gpt-5.6-luna-image", "name": "GPT 5.6 Luna Image", "isDefault": false, "capabilities": ["text2img", "edit"], "kind": "image" },
32
- { "id": "gpt-5.3-image", "name": "GPT 5.3 Image", "isDefault": false, "capabilities": ["text2img", "edit"], "kind": "image" },
27
+ { "id": "gpt-6-sol-image", "name": "GPT 6.0 Sol Image", "isDefault": false, "capabilities": ["text2img", "edit"], "kind": "image" },
33
28
  ];
@@ -27,31 +27,47 @@ export function stopCodexProxy() {
27
27
  }
28
28
  export function startCodexProxy(appPort) {
29
29
  if (codexProxyServer)
30
- return;
31
- const server = http.createServer((req, res) => {
32
- const url = new URL(req.url || "/", "http://localhost");
33
- if (url.pathname !== "/callback" && url.pathname !== "/auth/callback") {
34
- res.writeHead(404);
35
- res.end("Not found");
36
- return;
30
+ return Promise.resolve();
31
+ return new Promise((resolve, reject) => {
32
+ const server = http.createServer((req, res) => {
33
+ const origin = req.headers["origin"];
34
+ if (origin && !/^http:\/\/(127\.0\.0\.1|localhost)(:\d+)?$/.test(origin)) {
35
+ res.writeHead(403, { "Content-Type": "text/plain" });
36
+ res.end("Forbidden: cross-origin requests blocked");
37
+ return;
38
+ }
39
+ const url = new URL(req.url || "/", "http://localhost");
40
+ if (url.pathname !== "/callback" && url.pathname !== "/auth/callback") {
41
+ res.writeHead(404);
42
+ res.end("Not found");
43
+ return;
44
+ }
45
+ const redirectUrl = `http://localhost:${appPort}/callback${url.search}`;
46
+ res.writeHead(302, { Location: redirectUrl });
47
+ res.end();
48
+ stopCodexProxy();
49
+ });
50
+ server.on("error", (err) => {
51
+ stopCodexProxy();
52
+ if (err.code === "EADDRINUSE") {
53
+ reject(new Error("Port 1455 is already in use by another process. Please close Codex CLI or conflicting tools."));
54
+ }
55
+ else {
56
+ reject(err);
57
+ }
58
+ });
59
+ try {
60
+ server.listen(1455, "127.0.0.1", () => {
61
+ codexProxyServer = server;
62
+ codexProxyTimeout = setTimeout(() => stopCodexProxy(), 5 * 60 * 1000);
63
+ resolve();
64
+ });
65
+ }
66
+ catch (err) {
67
+ stopCodexProxy();
68
+ reject(err);
37
69
  }
38
- const redirectUrl = `http://localhost:${appPort}/callback${url.search}`;
39
- res.writeHead(302, { Location: redirectUrl });
40
- res.end();
41
- stopCodexProxy();
42
- });
43
- server.on("error", () => {
44
- stopCodexProxy();
45
70
  });
46
- try {
47
- server.listen(1455, "127.0.0.1", () => {
48
- codexProxyServer = server;
49
- codexProxyTimeout = setTimeout(() => stopCodexProxy(), 5 * 60 * 1000);
50
- });
51
- }
52
- catch {
53
- stopCodexProxy();
54
- }
55
71
  }
56
72
  export const codexOAuthHandler = {
57
73
  id: "codex",
@@ -82,7 +98,7 @@ export const codexOAuthHandler = {
82
98
  .join("&");
83
99
  const authUrl = `${CODEX_AUTHORIZE_URL}?${queryString}`;
84
100
  const appPort = Number(params.appPort) || Number(process.env.PORT) || DEFAULT_PORT;
85
- startCodexProxy(appPort);
101
+ startCodexProxy(appPort).catch(() => { });
86
102
  return {
87
103
  authUrl,
88
104
  redirectUri: codexRedirect,
@@ -0,0 +1,80 @@
1
+ import crypto from "node:crypto";
2
+ const DNS_NAMESPACE_BYTES = Buffer.from("6ba7b8109dad11d180b400c04fd430c8", "hex");
3
+ export function generateHashed64Hex(input, salt = "") {
4
+ return crypto.createHash("sha256").update(input + salt).digest("hex");
5
+ }
6
+ export function generateSessionId(authToken) {
7
+ const hash = crypto.createHash("sha1").update(DNS_NAMESPACE_BYTES).update(authToken).digest();
8
+ hash[6] = (hash[6] & 0x0f) | 0x50; // Version 5
9
+ hash[8] = (hash[8] & 0x3f) | 0x80; // Variant RFC 4122
10
+ const hex = hash.subarray(0, 16).toString("hex");
11
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
12
+ }
13
+ export function generateCursorChecksum(machineId) {
14
+ const timestamp = Math.floor(Date.now() / 1000000);
15
+ const byteArray = new Uint8Array([
16
+ (timestamp >> 40) & 0xff,
17
+ (timestamp >> 32) & 0xff,
18
+ (timestamp >> 24) & 0xff,
19
+ (timestamp >> 16) & 0xff,
20
+ (timestamp >> 8) & 0xff,
21
+ timestamp & 0xff,
22
+ ]);
23
+ let t = 165;
24
+ for (let i = 0; i < byteArray.length; i++) {
25
+ byteArray[i] = ((byteArray[i] ^ t) + (i % 256)) & 0xff;
26
+ t = byteArray[i];
27
+ }
28
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
29
+ let encoded = "";
30
+ for (let i = 0; i < byteArray.length; i += 3) {
31
+ const a = byteArray[i];
32
+ const b = i + 1 < byteArray.length ? byteArray[i + 1] : 0;
33
+ const c = i + 2 < byteArray.length ? byteArray[i + 2] : 0;
34
+ encoded += alphabet[a >> 2];
35
+ encoded += alphabet[((a & 3) << 4) | (b >> 4)];
36
+ if (i + 1 < byteArray.length) {
37
+ encoded += alphabet[((b & 15) << 2) | (c >> 6)];
38
+ }
39
+ if (i + 2 < byteArray.length) {
40
+ encoded += alphabet[c & 63];
41
+ }
42
+ }
43
+ return `${encoded}${machineId}`;
44
+ }
45
+ export function buildCursorHeaders(accessToken, machineId, ghostMode = true) {
46
+ const cleanToken = accessToken.includes("::") ? accessToken.split("::")[1] : accessToken;
47
+ const effectiveMachineId = machineId || generateHashed64Hex(cleanToken, "machineId");
48
+ const sessionId = generateSessionId(cleanToken);
49
+ const clientKey = generateHashed64Hex(cleanToken);
50
+ const checksum = generateCursorChecksum(effectiveMachineId);
51
+ let os = "linux";
52
+ if (process.platform === "win32")
53
+ os = "windows";
54
+ else if (process.platform === "darwin")
55
+ os = "macos";
56
+ let arch = "x64";
57
+ if (process.arch === "arm64")
58
+ arch = "aarch64";
59
+ return {
60
+ authorization: `Bearer ${cleanToken}`,
61
+ "connect-accept-encoding": "gzip",
62
+ "connect-protocol-version": "1",
63
+ "content-type": "application/connect+proto",
64
+ "user-agent": "connect-es/1.6.1",
65
+ "x-amzn-trace-id": `Root=${crypto.randomUUID()}`,
66
+ "x-client-key": clientKey,
67
+ "x-cursor-checksum": checksum,
68
+ "x-cursor-client-version": "3.12.17",
69
+ "x-cursor-client-commit": "0fb762053c34788bb7760d5673f8a6d4c8589d50",
70
+ "x-cursor-client-type": "ide",
71
+ "x-cursor-client-os": os,
72
+ "x-cursor-client-arch": arch,
73
+ "x-cursor-client-device-type": "desktop",
74
+ "x-cursor-config-version": crypto.randomUUID(),
75
+ "x-cursor-timezone": Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC",
76
+ "x-ghost-mode": ghostMode ? "true" : "false",
77
+ "x-request-id": crypto.randomUUID(),
78
+ "x-session-id": sessionId,
79
+ };
80
+ }