mapigate 0.5.133 → 0.5.141

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 (101) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/commands/logs.js +0 -1
  3. package/dist/core/adapters/anthropic/requestAnthropicToOpenAi.js +59 -11
  4. package/dist/core/adapters/anthropic/requestOpenAiToAnthropic.js +1 -1
  5. package/dist/core/adapters/anthropicAdapter.js +2 -2
  6. package/dist/core/adapters/helpers/toolCallRescue.js +1 -1
  7. package/dist/core/adapters/responsesAdapter.js +11 -0
  8. package/dist/core/capabilities/modelDictionary.js +1 -0
  9. package/dist/core/scanner/modelScanner.js +2 -1
  10. package/dist/core/scanner/payloadExtractor.js +1 -1
  11. package/dist/core/scanner/urlResolver.js +16 -0
  12. package/dist/core/tokenSaver/methods/rtk/autodetect.js +1 -1
  13. package/dist/core/tokenSaver/methods/rtk/filters/gitLog.js +1 -1
  14. package/dist/core/usage/pricing.js +98 -42
  15. package/dist/core/usage/tokenExtractor.js +59 -0
  16. package/dist/mitm/handlers/antigravity/config.js +22 -0
  17. package/dist/mitm/handlers/antigravity/modelInjector.js +2 -2
  18. package/dist/providers/catalog/commandcode/converter.js +215 -0
  19. package/dist/providers/catalog/commandcode/executor.js +305 -0
  20. package/dist/providers/catalog/commandcode/headers.js +76 -0
  21. package/dist/providers/catalog/commandcode/metadata.js +4 -1
  22. package/dist/providers/catalog/commandcode/ndjson.js +161 -0
  23. package/dist/providers/catalog/commandcode/provider.js +18 -35
  24. package/dist/providers/catalog/commandcode/routes.js +75 -0
  25. package/dist/providers/catalog/iflow/provider.js +1 -1
  26. package/dist/providers/catalog/iteracompute/metadata.js +154 -13
  27. package/dist/providers/catalog/iteracompute/provider.js +111 -0
  28. package/dist/providers/catalog/opencode-go/metadata.js +4 -2
  29. package/dist/providers/catalog/opencode-go/models.js +1 -0
  30. package/dist/providers/catalog/opencode-go/provider.js +114 -0
  31. package/dist/providers/catalog/opencode-go/quota.js +106 -0
  32. package/dist/providers/catalog/opencode-go/responses.js +301 -0
  33. package/dist/providers/catalog/opencode-go/responsesPayload.js +228 -0
  34. package/dist/providers/catalog/openrouter/metadata.js +1 -0
  35. package/dist/providers/catalog/sensenova/metadata.js +35 -0
  36. package/dist/providers/core/base/baseProvider.js +8 -3
  37. package/dist/providers/core/base/openAiProvider.js +3 -1
  38. package/dist/providers/generated/routesRegistry.generated.js +2 -0
  39. package/dist/providers/runtime/antigravity/executor.js +2 -2
  40. package/dist/providers/runtime/antigravity/metadata.js +2 -2
  41. package/dist/providers/runtime/antigravity/models.js +9 -0
  42. package/dist/providers/runtime/antigravity/provider.js +2 -2
  43. package/dist/providers/runtime/antigravity/routes.js +2 -2
  44. package/dist/providers/runtime/antigravity/schema.js +20 -2
  45. package/dist/providers/runtime/antigravity/types.js +10 -2
  46. package/dist/providers/runtime/codebuddy/provider.js +21 -6
  47. package/dist/providers/runtime/gemini/provider.js +77 -0
  48. package/dist/providers/runtime/gemini-cli/provider.js +2 -2
  49. package/dist/providers/runtime/github/routes.js +1 -1
  50. package/dist/providers/runtime/grok/provider.js +1 -1
  51. package/dist/providers/runtime/kiro/executor.js +7 -4
  52. package/dist/providers/runtime/kiro/models.js +11 -0
  53. package/dist/providers/runtime/kiro/provider.js +8 -8
  54. package/dist/providers/runtime/minimax/routes.js +0 -1
  55. package/dist/providers/runtime/opencode/tools.js +39 -17
  56. package/dist/providers/runtime/windsurf/routes.js +0 -2
  57. package/dist/providers/runtime/xkiro/quota.js +4 -1
  58. package/dist/server/proxy/executorHelpers.js +1 -1
  59. package/dist/server/proxy/index.js +1 -1
  60. package/dist/server/proxy/pipeline.js +12 -6
  61. package/dist/server/proxy/proxyDispatcher.js +136 -17
  62. package/dist/server/proxy/responseHandlers.js +2 -18
  63. package/dist/server/proxy/singleModelExecutor.js +15 -3
  64. package/dist/server/proxy/streaming/sseStreamer.js +3 -10
  65. package/dist/server/routes/apiMitm.js +1 -1
  66. package/dist/server/routes/apiModels.js +17 -12
  67. package/dist/server/utils/consoleLogBuffer.js +3 -3
  68. package/dist/shared/constants/index.js +2 -2
  69. package/dist/shared/logger.js +2 -2
  70. package/dist/shared/utils/dnsResolver.js +69 -27
  71. package/dist/storage/repositories/logRepo.js +3 -23
  72. package/dist/storage/repositories/requestDetailsRepo.js +1 -1
  73. package/dist/storage/repositories/usageRepo.js +136 -74
  74. package/dist/web/assets/{CliToolsTab-D4DkK7Rn.js → CliToolsTab-rKSWLJC3.js} +1 -1
  75. package/dist/web/assets/CombosTab-D1_cfssh.js +1 -0
  76. package/dist/web/assets/{ConfirmModal-CuQ7ARxt.js → ConfirmModal-OWeauwYv.js} +1 -1
  77. package/dist/web/assets/{ConsoleLogTab-B2sfhYZW.js → ConsoleLogTab-rZe8zCb_.js} +1 -1
  78. package/dist/web/assets/{EditAccountModal-BusNJLvX.js → EditAccountModal-CAg-yIOn.js} +1 -1
  79. package/dist/web/assets/{EndpointTab-DQCezUA9.js → EndpointTab-B-Jb4wAG.js} +1 -1
  80. package/dist/web/assets/{MitmTab-DxEuD0DW.js → MitmTab-5dKeNi4T.js} +5 -5
  81. package/dist/web/assets/{ModelAutocompleteInput-CgJ2FlEf.js → ModelAutocompleteInput-CoinzdsW.js} +1 -1
  82. package/dist/web/assets/ProviderDetailPage-D-fodBhz.js +6 -0
  83. package/dist/web/assets/ProvidersTab-yzmb4w0D.js +1 -0
  84. package/dist/web/assets/{QuotaTab-CvXGyICr.js → QuotaTab-BXevQzen.js} +1 -1
  85. package/dist/web/assets/{SettingsTab-D7YF7rTP.js → SettingsTab-LkByv4Sg.js} +1 -1
  86. package/dist/web/assets/UsageTab-Hr8XPZD4.js +1 -0
  87. package/dist/web/assets/index-CKuvklEr.js +2 -0
  88. package/dist/web/assets/{index-BisuNW2y.css → index-HnsyZg0I.css} +1 -1
  89. package/dist/web/assets/metadataRegistry-NuDSSkP9.js +1 -0
  90. package/dist/web/assets/providers/openrouter/icon.png +0 -0
  91. package/dist/web/assets/providersData-DS1-ETBi.js +1 -0
  92. package/dist/web/index.html +2 -2
  93. package/package.json +9 -1
  94. package/dist/web/assets/CombosTab-X1C_OmzI.js +0 -1
  95. package/dist/web/assets/ProviderDetailPage-DMA1DVSN.js +0 -6
  96. package/dist/web/assets/ProvidersTab-pZoM69s4.js +0 -1
  97. package/dist/web/assets/UsageTab-B0YCftIJ.js +0 -1
  98. package/dist/web/assets/index-DTRst7wN.js +0 -2
  99. package/dist/web/assets/metadataRegistry-BPZSXiBy.js +0 -1
  100. package/dist/web/assets/providers/openrouter/openrouter.png +0 -0
  101. package/dist/web/assets/providersData-Bsv7o5VV.js +0 -1
@@ -0,0 +1,161 @@
1
+ export function createCommandCodeStreamState(model, requestId) {
2
+ return {
3
+ responseId: `chatcmpl-${requestId || Date.now()}`,
4
+ created: Math.floor(Date.now() / 1000),
5
+ model: model || "commandcode",
6
+ chunkIndex: 0,
7
+ toolIndex: 0,
8
+ toolIndexById: new Map(),
9
+ finishReason: null,
10
+ usage: null,
11
+ };
12
+ }
13
+ function mapFinishReason(reason) {
14
+ if (reason === "tool-calls" || reason === "tool_calls")
15
+ return "tool_calls";
16
+ if (reason === "length" || reason === "max_tokens")
17
+ return "length";
18
+ return "stop";
19
+ }
20
+ function makeChunk(state, delta, finishReason = null) {
21
+ return {
22
+ id: state.responseId,
23
+ object: "chat.completion.chunk",
24
+ created: state.created,
25
+ model: state.model,
26
+ choices: [{ index: 0, delta, finish_reason: finishReason }],
27
+ };
28
+ }
29
+ export function parseCommandCodeError(event) {
30
+ const errVal = event?.error ?? event?.message ?? "CommandCode upstream error";
31
+ const message = typeof errVal === "object" && errVal !== null
32
+ ? errVal.message || errVal.error || JSON.stringify(errVal)
33
+ : String(errVal);
34
+ let statusCode = Number(errVal?.statusCode || errVal?.status || event?.statusCode || 0);
35
+ if (!Number.isInteger(statusCode) || statusCode < 400 || statusCode > 599) {
36
+ const lower = message.toLowerCase();
37
+ if (lower.includes("rate limit") || lower.includes("too many requests"))
38
+ statusCode = 429;
39
+ else if (lower.includes("unauthorized") || lower.includes("invalid api key"))
40
+ statusCode = 401;
41
+ else if (lower.includes("payment required") || lower.includes("billing") || lower.includes("insufficient credits"))
42
+ statusCode = 402;
43
+ else if (lower.includes("quota") || lower.includes("forbidden"))
44
+ statusCode = 403;
45
+ else
46
+ statusCode = 503;
47
+ }
48
+ return { statusCode, message };
49
+ }
50
+ export class CommandCodeUpstreamError extends Error {
51
+ statusCode;
52
+ constructor(statusCode, message) {
53
+ super(`[CommandCode error: ${message}]`);
54
+ this.statusCode = statusCode;
55
+ }
56
+ }
57
+ export function commandCodeLineToOpenAiChunks(line, state) {
58
+ const trimmed = line.trim();
59
+ if (!trimmed)
60
+ return [];
61
+ const json = trimmed.startsWith("data:") ? trimmed.slice(5).trim() : trimmed;
62
+ if (!json || json === "[DONE]")
63
+ return [];
64
+ let event;
65
+ try {
66
+ event = JSON.parse(json);
67
+ }
68
+ catch {
69
+ return [];
70
+ }
71
+ if (!event || typeof event !== "object" || !event.type)
72
+ return [];
73
+ if (event.model && !state.model)
74
+ state.model = event.model;
75
+ switch (event.type) {
76
+ case "text-delta": {
77
+ const text = event.text || event.delta || "";
78
+ if (!text)
79
+ return [];
80
+ const delta = state.chunkIndex === 0 ? { role: "assistant", content: text } : { content: text };
81
+ state.chunkIndex++;
82
+ return [makeChunk(state, delta)];
83
+ }
84
+ case "reasoning-delta": {
85
+ const text = event.text || "";
86
+ if (!text)
87
+ return [];
88
+ const delta = state.chunkIndex === 0
89
+ ? { role: "assistant", reasoning_content: text }
90
+ : { reasoning_content: text };
91
+ state.chunkIndex++;
92
+ return [makeChunk(state, delta)];
93
+ }
94
+ case "tool-input-start": {
95
+ const id = event.id || event.toolCallId || `call_${state.toolIndex}`;
96
+ let idx = state.toolIndexById.get(id);
97
+ if (idx == null) {
98
+ idx = state.toolIndex++;
99
+ state.toolIndexById.set(id, idx);
100
+ }
101
+ const delta = {
102
+ ...(state.chunkIndex === 0 ? { role: "assistant" } : {}),
103
+ tool_calls: [{ index: idx, id, type: "function", function: { name: event.toolName || "", arguments: "" } }],
104
+ };
105
+ state.chunkIndex++;
106
+ return [makeChunk(state, delta)];
107
+ }
108
+ case "tool-input-delta": {
109
+ const id = event.id || event.toolCallId;
110
+ const idx = state.toolIndexById.get(id);
111
+ if (idx == null)
112
+ return [];
113
+ return [makeChunk(state, { tool_calls: [{ index: idx, function: { arguments: event.delta || event.inputTextDelta || "" } }] })];
114
+ }
115
+ case "tool-call": {
116
+ const id = event.toolCallId;
117
+ if (state.toolIndexById.has(id))
118
+ return [];
119
+ const idx = state.toolIndex++;
120
+ state.toolIndexById.set(id, idx);
121
+ const argsStr = typeof event.input === "string" ? event.input : JSON.stringify(event.input ?? {});
122
+ const delta = {
123
+ ...(state.chunkIndex === 0 ? { role: "assistant" } : {}),
124
+ tool_calls: [{ index: idx, id, type: "function", function: { name: event.toolName || "", arguments: argsStr } }],
125
+ };
126
+ state.chunkIndex++;
127
+ return [makeChunk(state, delta)];
128
+ }
129
+ case "finish-step":
130
+ state.finishReason = mapFinishReason(event.finishReason);
131
+ if (event.usage)
132
+ state.usage = event.usage;
133
+ return [];
134
+ case "finish": {
135
+ const finishReason = state.finishReason || mapFinishReason(event.finishReason || "stop");
136
+ const chunk = makeChunk(state, {}, finishReason);
137
+ const raw = event.totalUsage || state.usage;
138
+ if (raw && typeof raw === "object") {
139
+ const input = Number(raw.inputTokens) || 0;
140
+ const output = Number(raw.outputTokens) || 0;
141
+ const total = typeof raw.totalTokens === "number" ? raw.totalTokens : input + output;
142
+ const cached = Number(raw.inputTokenDetails?.cacheReadTokens) || 0;
143
+ const cacheCreate = Number(raw.inputTokenDetails?.cacheWriteTokens) || 0;
144
+ chunk.usage = {
145
+ prompt_tokens: input,
146
+ completion_tokens: output,
147
+ total_tokens: total,
148
+ ...(cached > 0 ? { prompt_tokens_details: { cached_tokens: cached } } : {}),
149
+ ...(cacheCreate > 0 ? { cache_creation_input_tokens: cacheCreate } : {}),
150
+ };
151
+ }
152
+ return [chunk];
153
+ }
154
+ case "error": {
155
+ const { statusCode, message } = parseCommandCodeError(event);
156
+ throw new CommandCodeUpstreamError(statusCode, message);
157
+ }
158
+ default:
159
+ return [];
160
+ }
161
+ }
@@ -1,10 +1,16 @@
1
+ import crypto from "node:crypto";
1
2
  import { OpenAiCompatibleProvider } from "../../core/base/openAiProvider.js";
2
3
  import { metadata } from "./metadata.js";
3
- import crypto from "node:crypto";
4
+ import { executeCommandCode } from "./executor.js";
5
+ import { buildCommandCodeHeaders } from "./headers.js";
6
+ import { buildCommandCodePayload } from "./converter.js";
4
7
  export class CommandcodeProvider extends OpenAiCompatibleProvider {
5
8
  id = metadata.id;
6
9
  name = metadata.name;
7
- defaultFormat = metadata.format || "openai";
10
+ defaultFormat = metadata.format || "commandcode";
11
+ async execute(context) {
12
+ return await executeCommandCode(context);
13
+ }
8
14
  async probeModels(context) {
9
15
  const token = (context.apiKey || context.account?.rawApiKey || "").trim();
10
16
  if (!token) {
@@ -15,42 +21,19 @@ export class CommandcodeProvider extends OpenAiCompatibleProvider {
15
21
  }
16
22
  const timeoutMs = context.timeoutMs || 8000;
17
23
  const url = "https://api.commandcode.ai/alpha/generate";
18
- const body = {
19
- threadId: crypto.randomUUID(),
20
- memory: "",
21
- config: {
22
- workingDir: process.cwd(),
23
- date: new Date().toISOString().slice(0, 10),
24
- environment: process.platform,
25
- structure: [],
26
- isGitRepo: false,
27
- currentBranch: "",
28
- mainBranch: "",
29
- gitStatus: "",
30
- recentCommits: [],
31
- },
32
- params: {
33
- model: "claude-3-5-sonnet-20241022",
34
- messages: [{ role: "user", content: [{ type: "text", text: "ping" }] }],
35
- stream: true,
36
- max_tokens: 1,
37
- },
38
- };
24
+ const body = buildCommandCodePayload("deepseek/deepseek-v4-pro", {
25
+ messages: [{ role: "user", content: "ping" }],
26
+ max_tokens: 1,
27
+ }, crypto.randomUUID());
39
28
  try {
40
29
  const res = await fetch(url, {
41
30
  method: "POST",
42
- headers: {
43
- "Content-Type": "application/json",
44
- Authorization: token.startsWith("Bearer ") ? token : `Bearer ${token}`,
45
- "User-Agent": "cli",
46
- "x-session-id": crypto.randomUUID(),
47
- "x-command-code-version": "1.88.0",
48
- "x-cli-environment": "production",
49
- "x-cli-surface": "cli",
50
- "x-taste-learning": "false",
51
- Accept: "text/event-stream",
52
- ...(context.customHeaders || {}),
53
- },
31
+ headers: buildCommandCodeHeaders({
32
+ apiKey: token,
33
+ sessionId: body.threadId,
34
+ accept: "text/event-stream",
35
+ customHeaders: context.customHeaders,
36
+ }),
54
37
  body: JSON.stringify(body),
55
38
  signal: AbortSignal.timeout(timeoutMs),
56
39
  });
@@ -0,0 +1,75 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { OAuthHandlerRegistry } from "../../core/oauthRegistry.js";
5
+ export function getCommandCodeCandidatePaths() {
6
+ const home = os.homedir();
7
+ const paths = [path.join(home, ".commandcode", "auth.json")];
8
+ if (process.platform === "win32") {
9
+ const appData = process.env.APPDATA || path.join(home, "AppData", "Roaming");
10
+ paths.push(path.join(appData, "commandcode", "auth.json"));
11
+ }
12
+ return paths;
13
+ }
14
+ export async function autoImportCommandCode() {
15
+ const candidates = getCommandCodeCandidatePaths();
16
+ let authPath = null;
17
+ for (const candidate of candidates) {
18
+ try {
19
+ await fs.promises.access(candidate, fs.constants.R_OK);
20
+ authPath = candidate;
21
+ break;
22
+ }
23
+ catch {
24
+ // try next candidate
25
+ }
26
+ }
27
+ if (!authPath) {
28
+ return {
29
+ found: false,
30
+ error: `Command Code auth file not found. Checked:\n${candidates.join("\n")}\n\nRun 'commandcode login' in your terminal first.`,
31
+ };
32
+ }
33
+ let auth;
34
+ try {
35
+ const raw = await fs.promises.readFile(authPath, "utf8");
36
+ auth = JSON.parse(raw);
37
+ }
38
+ catch {
39
+ return {
40
+ found: false,
41
+ error: "auth.json is not valid JSON. Please run 'commandcode login' again.",
42
+ };
43
+ }
44
+ const apiKey = typeof auth?.apiKey === "string" ? auth.apiKey.trim() : "";
45
+ if (!apiKey) {
46
+ return {
47
+ found: false,
48
+ error: "No apiKey found in ~/.commandcode/auth.json. Please run 'commandcode login'.",
49
+ };
50
+ }
51
+ return {
52
+ found: true,
53
+ apiKey,
54
+ userId: auth.userId || null,
55
+ userName: auth.userName || null,
56
+ keyName: auth.keyName || null,
57
+ authenticatedAt: auth.authenticatedAt || null,
58
+ source: authPath,
59
+ };
60
+ }
61
+ export const commandCodeOAuthHandler = {
62
+ id: "commandcode",
63
+ autoImport: autoImportCommandCode,
64
+ };
65
+ export function registerRoutes(router) {
66
+ OAuthHandlerRegistry.register("commandcode", commandCodeOAuthHandler);
67
+ router.get("/commandcode/auto-import", async (_req, res) => {
68
+ try {
69
+ res.json(await autoImportCommandCode());
70
+ }
71
+ catch (err) {
72
+ res.status(500).json({ found: false, error: err?.message || "Command Code auto-import failed" });
73
+ }
74
+ });
75
+ }
@@ -42,7 +42,7 @@ export class IflowProvider extends OpenAiCompatibleProvider {
42
42
  };
43
43
  }
44
44
  }
45
- catch (err) {
45
+ catch {
46
46
  // Fall back to API key verification
47
47
  }
48
48
  }
@@ -7,16 +7,17 @@ export const metadata = {
7
7
  color: "#6366F1",
8
8
  iconBg: "#ffffff",
9
9
  image: "/assets/providers/iteracompute/icon.svg",
10
- website: "https://iteracompute.com",
10
+ website: "https://platform.iteracompute.com",
11
11
  notice: {
12
- apiKeyUrl: "https://iteracompute.com",
13
- text: "OpenAI-compatible gateway with 30M free monthly tokens (160k TPM) for Qwen, DeepSeek V4, and GLM models."
12
+ apiKeyUrl: "https://platform.iteracompute.com",
13
+ text: "OpenAI-compatible gateway with 30M free monthly tokens (160k TPM) for Auto, Qwen, DeepSeek, and GLM models. Documentation: https://platform.iteracompute.com/docs.html"
14
14
  },
15
15
  category: "freeTier",
16
16
  authType: "apikey",
17
17
  authModes: ["apikey"],
18
18
  baseUrl: "https://api.iteracompute.com/v1",
19
19
  baseUrls: ["https://api.iteracompute.com/v1"],
20
+ modelsUrl: "https://api.iteracompute.com/v1/models",
20
21
  validateUrl: "https://api.iteracompute.com/v1/models",
21
22
  format: "openai",
22
23
  defaultHeaders: {
@@ -24,33 +25,173 @@ export const metadata = {
24
25
  },
25
26
  thinkingMode: "auto",
26
27
  models: [
28
+ {
29
+ id: "Auto",
30
+ name: "Auto (Free 30M/mo)",
31
+ isDefault: true,
32
+ capabilities: ["tools", "reasoning", "vision"],
33
+ contextLength: 262144
34
+ },
27
35
  {
28
36
  id: "qwen/qwen3.8-27b",
29
37
  name: "Qwen 3.8 27B",
30
- isDefault: true,
31
- capabilities: ["tools"],
32
- contextLength: 128000
38
+ isDefault: false,
39
+ capabilities: ["tools", "reasoning", "vision"],
40
+ contextLength: 262144
41
+ },
42
+ {
43
+ id: "deepseek/deepseek-v4.1-flash",
44
+ name: "DeepSeek V4.1 Flash",
45
+ isDefault: false,
46
+ capabilities: ["tools", "reasoning"],
47
+ contextLength: 1048576
33
48
  },
34
49
  {
35
- id: "deepseek/deepseek-v4-flash",
36
- name: "DeepSeek V4 Flash",
50
+ id: "deepseek/deepseek-v4.1-flash-1017",
51
+ name: "DeepSeek V4.1 Flash 1017",
37
52
  isDefault: false,
38
- capabilities: ["tools"],
53
+ capabilities: ["tools", "reasoning", "vision"],
39
54
  contextLength: 1048576
40
55
  },
41
56
  {
42
- id: "deepseek/deepseek-v4-pro",
43
- name: "DeepSeek V4 Pro",
57
+ id: "deepseek/deepseek-v4-pro-0813",
58
+ name: "DeepSeek V4 Pro 0813",
44
59
  isDefault: false,
45
- capabilities: ["tools"],
60
+ capabilities: ["tools", "reasoning"],
46
61
  contextLength: 1048576
47
62
  },
48
63
  {
49
64
  id: "z-ai/glm-5.3-flash",
50
65
  name: "GLM 5.3 Flash",
51
66
  isDefault: false,
52
- capabilities: ["tools", "vision"],
67
+ capabilities: ["tools", "reasoning", "vision"],
68
+ contextLength: 1048576
69
+ },
70
+ {
71
+ id: "z-ai/glm-5.3",
72
+ name: "GLM 5.3",
73
+ isDefault: false,
74
+ capabilities: ["tools", "reasoning"],
75
+ contextLength: 1048576
76
+ },
77
+ {
78
+ id: "z-ai/glm-5.2",
79
+ name: "GLM 5.2",
80
+ isDefault: false,
81
+ capabilities: ["tools", "reasoning"],
82
+ contextLength: 1048576
83
+ },
84
+ {
85
+ id: "moonshotai/kimi-k2.5",
86
+ name: "Kimi K2.5",
87
+ isDefault: false,
88
+ capabilities: ["tools", "reasoning", "vision"],
89
+ contextLength: 262144
90
+ },
91
+ {
92
+ id: "moonshotai/kimi-k2.6",
93
+ name: "Kimi K2.6",
94
+ isDefault: false,
95
+ capabilities: ["tools", "reasoning", "vision"],
96
+ contextLength: 262144
97
+ },
98
+ {
99
+ id: "moonshotai/kimi-k2.7-code",
100
+ name: "Kimi K2.7 Code",
101
+ isDefault: false,
102
+ capabilities: ["tools", "reasoning"],
103
+ contextLength: 262144
104
+ },
105
+ {
106
+ id: "moonshotai/kimi-k3",
107
+ name: "Kimi K3",
108
+ isDefault: false,
109
+ capabilities: ["tools", "reasoning", "vision"],
53
110
  contextLength: 1048576
111
+ },
112
+ {
113
+ id: "moonshotai/kimi-k3.1-pro",
114
+ name: "Kimi K3.1 Pro",
115
+ isDefault: false,
116
+ capabilities: ["tools", "reasoning", "vision"],
117
+ contextLength: 917504
118
+ },
119
+ {
120
+ id: "minimax/minimax-m2.5",
121
+ name: "MiniMax M2.5",
122
+ isDefault: false,
123
+ capabilities: ["reasoning"],
124
+ contextLength: 204800
125
+ },
126
+ {
127
+ id: "minimax/minimax-m2.7",
128
+ name: "MiniMax M2.7",
129
+ isDefault: false,
130
+ capabilities: ["tools", "reasoning"],
131
+ contextLength: 204800
132
+ },
133
+ {
134
+ id: "minimax/minimax-m3",
135
+ name: "MiniMax M3",
136
+ isDefault: false,
137
+ capabilities: ["tools", "reasoning", "vision"],
138
+ contextLength: 1048576
139
+ },
140
+ {
141
+ id: "qwen/qwen3.8-flash",
142
+ name: "Qwen 3.8 Flash",
143
+ isDefault: false,
144
+ capabilities: ["tools", "reasoning", "vision"],
145
+ contextLength: 1048576
146
+ },
147
+ {
148
+ id: "qwen/qwen3.8-max",
149
+ name: "Qwen 3.8 Max",
150
+ isDefault: false,
151
+ capabilities: ["tools", "reasoning", "vision"],
152
+ contextLength: 1048576
153
+ },
154
+ {
155
+ id: "gemini/gemini-3.8-flash",
156
+ name: "Gemini 3.8 Flash",
157
+ isDefault: false,
158
+ capabilities: ["tools", "reasoning", "vision"],
159
+ contextLength: 1048576
160
+ },
161
+ {
162
+ id: "gemini/gemini-4-argon",
163
+ name: "Gemini 4 Argon",
164
+ isDefault: false,
165
+ capabilities: ["tools", "reasoning", "vision"],
166
+ contextLength: 1048576
167
+ },
168
+ {
169
+ id: "anthropic/claude-sonnet-5-5",
170
+ name: "Claude Sonnet 5.5",
171
+ isDefault: false,
172
+ capabilities: ["tools", "reasoning", "vision"],
173
+ contextLength: 1000000
174
+ },
175
+ {
176
+ id: "anthropic/claude-haiku-5-5",
177
+ name: "Claude Haiku 5.5",
178
+ isDefault: false,
179
+ capabilities: ["tools", "reasoning", "vision"],
180
+ contextLength: 1000000
181
+ },
182
+ {
183
+ id: "openai/gpt-6-luna",
184
+ name: "GPT-6 Luna",
185
+ isDefault: false,
186
+ capabilities: ["tools", "reasoning", "vision"],
187
+ contextLength: 1050000
188
+ },
189
+ {
190
+ id: "openai/gpt-6.1-sol",
191
+ name: "GPT-6.1 Sol",
192
+ isDefault: false,
193
+ capabilities: ["tools", "reasoning", "vision"],
194
+ contextLength: 1050000
54
195
  }
55
196
  ],
56
197
  passthroughModels: true
@@ -11,5 +11,116 @@ export class IteracomputeProvider extends OpenAiCompatibleProvider {
11
11
  async fetchQuota(context) {
12
12
  return await getIteracomputeUsage(context);
13
13
  }
14
+ async probeModels(context) {
15
+ const token = (context.apiKey || context.account?.rawApiKey || context.account?.apiKey || "").trim();
16
+ const timeoutMs = context.timeoutMs || 8000;
17
+ const probeUrl = "https://api.iteracompute.com/v1/models";
18
+ const reqHeaders = {
19
+ Accept: "application/json",
20
+ ...(metadata.defaultHeaders || {}),
21
+ ...(context.customHeaders || {}),
22
+ };
23
+ if (token) {
24
+ reqHeaders["Authorization"] = token.startsWith("Bearer ") ? token : `Bearer ${token}`;
25
+ }
26
+ try {
27
+ const res = await fetch(probeUrl, {
28
+ method: "GET",
29
+ headers: reqHeaders,
30
+ signal: AbortSignal.timeout(timeoutMs),
31
+ });
32
+ if (res.status === 401 || res.status === 403) {
33
+ let errDetail = "";
34
+ try {
35
+ const errJson = await res.json();
36
+ errDetail = errJson?.error?.message || errJson?.message || errJson?.detail || "";
37
+ }
38
+ catch {
39
+ const errText = await res.text().catch(() => "");
40
+ if (errText && !errText.includes("<html") && errText.length < 200) {
41
+ errDetail = errText.trim();
42
+ }
43
+ }
44
+ return {
45
+ success: false,
46
+ error: errDetail
47
+ ? `Authentication failed (HTTP ${res.status}): ${errDetail}`
48
+ : `Authentication failed (HTTP ${res.status}) for account "${context.account?.name || this.name}". Please verify your IteraCompute API key.`,
49
+ authError: errDetail || "Invalid API key",
50
+ };
51
+ }
52
+ if (res.ok || res.status === 200) {
53
+ const payload = await res.json();
54
+ const rawList = Array.isArray(payload?.data) ? payload.data : [];
55
+ if (rawList.length > 0) {
56
+ const scanned = rawList.map((m) => {
57
+ const p = m.model_disclosure?.model_parameters;
58
+ return {
59
+ id: m.id,
60
+ name: m.name || m.id,
61
+ contextLength: m.context_window || p?.limits?.context_tokens || 128000,
62
+ capabilities: {
63
+ tools: Boolean(p?.features?.tools || m.tools || m.id?.includes("code") || m.id?.includes("flash") || m.id?.includes("27b") || m.id === "Auto"),
64
+ reasoning: Boolean(p?.features?.reasoning || m.reasoning?.supported || m.id?.includes("reason") || m.id?.includes("pro") || m.id === "Auto"),
65
+ vision: Boolean(p?.features?.vision || m.id?.includes("vision") || m.id?.includes("image") || m.id?.includes("glm") || m.id === "Auto"),
66
+ audio: false,
67
+ },
68
+ };
69
+ });
70
+ return {
71
+ success: true,
72
+ endpointUrl: probeUrl,
73
+ models: scanned,
74
+ count: scanned.length,
75
+ };
76
+ }
77
+ }
78
+ // Upstream catalog unavailable (e.g. 503 "provider catalog unavailable"):
79
+ // Gracefully fall back to pre-configured models so valid accounts remain connected
80
+ const fallbackModels = metadata.models.map((m) => ({
81
+ id: m.id,
82
+ name: m.name,
83
+ contextLength: m.contextLength || 128000,
84
+ capabilities: {
85
+ tools: Boolean(m.capabilities?.includes("tools")),
86
+ reasoning: Boolean(m.capabilities?.includes("reasoning")),
87
+ vision: Boolean(m.capabilities?.includes("vision")),
88
+ audio: false,
89
+ },
90
+ }));
91
+ return {
92
+ success: true,
93
+ endpointUrl: probeUrl,
94
+ models: fallbackModels,
95
+ count: fallbackModels.length,
96
+ };
97
+ }
98
+ catch (err) {
99
+ const msg = err instanceof Error ? err.message : String(err);
100
+ if (token) {
101
+ const fallbackModels = metadata.models.map((m) => ({
102
+ id: m.id,
103
+ name: m.name,
104
+ contextLength: m.contextLength || 128000,
105
+ capabilities: {
106
+ tools: Boolean(m.capabilities?.includes("tools")),
107
+ reasoning: Boolean(m.capabilities?.includes("reasoning")),
108
+ vision: Boolean(m.capabilities?.includes("vision")),
109
+ audio: false,
110
+ },
111
+ }));
112
+ return {
113
+ success: true,
114
+ endpointUrl: probeUrl,
115
+ models: fallbackModels,
116
+ count: fallbackModels.length,
117
+ };
118
+ }
119
+ return {
120
+ success: false,
121
+ error: `Failed to connect to IteraCompute (${probeUrl}): ${msg}`,
122
+ };
123
+ }
124
+ }
14
125
  }
15
126
  export default IteracomputeProvider;
@@ -1,5 +1,6 @@
1
1
  import { models } from "./models.js";
2
2
  export const metadata = {
3
+ quotaOrder: ["Rolling", "Weekly", "Monthly"],
3
4
  "id": "opencode-go",
4
5
  "name": "OpenCode Go",
5
6
  "alias": "opencode-go",
@@ -15,11 +16,12 @@ export const metadata = {
15
16
  "apiKeyUrl": "https://opencode.ai/auth"
16
17
  },
17
18
  "category": "apikey",
18
- "baseUrl": "https://opencode.ai/zen/go/v1/chat/completions",
19
+ "baseUrl": "https://opencode.ai/inference/go/openai/v1/chat/completions",
19
20
  "baseUrls": [
20
- "https://opencode.ai/zen/go/v1/chat/completions"
21
+ "https://opencode.ai/inference/go/openai/v1/chat/completions"
21
22
  ],
22
23
  "validateUrl": "",
24
+ "modelsUrl": "https://opencode.ai/inference/go/v1/models",
23
25
  "format": "openai",
24
26
  "defaultHeaders": {},
25
27
  "thinkingMode": "auto",
@@ -42,4 +42,5 @@ export const models = [
42
42
  { "id": "gpt-6-luna", "name": "GPT 6 Luna", "isDefault": false },
43
43
  { "id": "muse-spark-1.2-contributor", "name": "Muse Spark 1.2 Contributor", "isDefault": false },
44
44
  { "id": "muse-spark-1.3-contributor", "name": "Muse Spark 1.3 Contributor", "isDefault": false },
45
+ { "id": "claude-haiku-5-5", "name": "Claude Haiku 5.5", "isDefault": false },
45
46
  ];