anygate 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +613 -613
- package/dist/{chunk-E2MV3GDX.js → chunk-CH5IEXJN.js} +47 -22
- package/dist/chunk-CH5IEXJN.js.map +1 -0
- package/dist/{chunk-VKROC37K.js → chunk-YYSUTRMV.js} +1 -1
- package/dist/chunk-YYSUTRMV.js.map +1 -0
- package/dist/cli.js +70 -3
- package/dist/cli.js.map +1 -1
- package/dist/{command-GJYPBC6E.js → command-QEYVYS7O.js} +4 -4
- package/dist/command-QEYVYS7O.js.map +1 -0
- package/dist/{provider-templates-TWR5XSYI.js → provider-templates-75KU6VA6.js} +2 -2
- package/dist/ui/dist/assets/index-BBg1LGms.js +5 -0
- package/dist/ui/dist/assets/index-CeN2cmwU.css +1 -0
- package/dist/ui/dist/index.html +3 -3
- package/package.json +94 -94
- package/dist/chunk-E2MV3GDX.js.map +0 -1
- package/dist/chunk-VKROC37K.js.map +0 -1
- package/dist/command-GJYPBC6E.js.map +0 -1
- package/dist/ui/dist/assets/index-BXZwvwW9.css +0 -1
- package/dist/ui/dist/assets/index-CRD31gqp.js +0 -5
- /package/dist/{provider-templates-TWR5XSYI.js.map → provider-templates-75KU6VA6.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/provider-templates.ts"],"sourcesContent":["// src/provider-templates.ts — builtin provider templates for anygate providers add\r\n\r\nexport type ProviderAuthType = 'api' | 'oauth' | 'none';\r\nexport type ProviderModelSource = 'api-list' | 'static-seed' | 'manual-only' | 'zen-go-api';\r\n\r\nexport interface ProviderTemplate {\r\n id: string;\r\n name: string;\r\n authType: ProviderAuthType;\r\n npm: string;\r\n defaultBaseUrl?: string;\r\n modelsPath?: string;\r\n signupUrl?: string;\r\n urlPlaceholder?: string;\r\n urlPrompt?: string;\r\n apiKeyOptional?: boolean;\r\n anonymousFreeModels?: boolean;\r\n /** Static headers this provider requires on every request (model listing and runtime). */\r\n headers?: Record<string, string>;\r\n modelSource: ProviderModelSource;\r\n staticModels?: Array<{ id: string; name: string }>;\r\n supported: boolean;\r\n addable?: boolean;\r\n hidden?: boolean;\r\n unsupportedReason?: string;\r\n /** True for providers that extract subscription tokens — carries account risk. */\r\n subscriptionRisk?: boolean;\r\n}\r\n\r\n/** Templates aligned with SDK packages shipped in package.json (API-key providers first). */\r\nexport const PROVIDER_TEMPLATES: ProviderTemplate[] = [\r\n {\r\n id: 'groq',\r\n name: 'Groq',\r\n authType: 'api',\r\n npm: '@ai-sdk/groq',\r\n defaultBaseUrl: 'https://api.groq.com/openai/v1',\r\n signupUrl: 'https://console.groq.com/keys',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'nvidia',\r\n name: 'Nvidia',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'https://integrate.api.nvidia.com/v1',\r\n signupUrl: 'https://build.nvidia.com',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'mistral',\r\n name: 'Mistral',\r\n authType: 'api',\r\n npm: '@ai-sdk/mistral',\r\n defaultBaseUrl: 'https://api.mistral.ai/v1',\r\n signupUrl: 'https://console.mistral.ai/api-keys',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'togetherai',\r\n name: 'Together AI',\r\n authType: 'api',\r\n npm: '@ai-sdk/togetherai',\r\n defaultBaseUrl: 'https://api.together.xyz/v1',\r\n signupUrl: 'https://api.together.xyz/settings/api-keys',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'cerebras',\r\n name: 'Cerebras',\r\n authType: 'api',\r\n npm: '@ai-sdk/cerebras',\r\n defaultBaseUrl: 'https://api.cerebras.ai/v1',\r\n signupUrl: 'https://cloud.cerebras.ai',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'deepinfra',\r\n name: 'DeepInfra',\r\n authType: 'api',\r\n npm: '@ai-sdk/deepinfra',\r\n defaultBaseUrl: 'https://api.deepinfra.com/v1/openai',\r\n signupUrl: 'https://deepinfra.com/dash/api_keys',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'deepseek',\r\n name: 'DeepSeek',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'https://api.deepseek.com/v1',\r\n signupUrl: 'https://platform.deepseek.com',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'zhipu',\r\n name: 'Zhipu AI (GLM)',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'https://open.bigmodel.cn/api/paas/v4',\r\n signupUrl: 'https://open.bigmodel.cn',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'moonshot',\r\n name: 'Moonshot (Kimi)',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'https://api.moonshot.cn/v1',\r\n signupUrl: 'https://platform.moonshot.cn',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'moonshot-global',\r\n name: 'Moonshot Global (kimi.ai)',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'https://api.moonshot.ai/v1',\r\n signupUrl: 'https://platform.kimi.ai',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'kimi-code',\r\n name: 'Kimi Code (Subscription Required)',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'https://api.kimi.com/coding/v1',\r\n modelSource: 'static-seed',\r\n staticModels: [\r\n { id: 'kimi-for-coding', name: 'Kimi Code K2.7 (Unified)' }\r\n ],\r\n supported: true,\r\n },\r\n {\r\n id: 'xai',\r\n name: 'xAI',\r\n authType: 'api',\r\n npm: '@ai-sdk/xai',\r\n defaultBaseUrl: 'https://api.x.ai/v1',\r\n signupUrl: 'https://console.x.ai',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'perplexity',\r\n name: 'Perplexity',\r\n authType: 'api',\r\n npm: '@ai-sdk/perplexity',\r\n defaultBaseUrl: 'https://api.perplexity.ai',\r\n signupUrl: 'https://www.perplexity.ai/settings/api',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'cohere',\r\n name: 'Cohere',\r\n authType: 'api',\r\n npm: '@ai-sdk/cohere',\r\n defaultBaseUrl: 'https://api.cohere.com/compatibility/v1',\r\n signupUrl: 'https://dashboard.cohere.com/api-keys',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'openai',\r\n name: 'OpenAI',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai',\r\n defaultBaseUrl: 'https://api.openai.com/v1',\r\n signupUrl: 'https://platform.openai.com/api-keys',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'google',\r\n name: 'Google Gemini',\r\n authType: 'api',\r\n npm: '@ai-sdk/google',\r\n defaultBaseUrl: 'https://generativelanguage.googleapis.com/v1beta/openai',\r\n signupUrl: 'https://aistudio.google.com/apikey',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'alibaba',\r\n name: 'Alibaba DashScope',\r\n authType: 'api',\r\n npm: '@ai-sdk/alibaba',\r\n defaultBaseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',\r\n signupUrl: 'https://dashscope.console.aliyun.com/apiKey',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'openrouter',\r\n name: 'OpenRouter',\r\n authType: 'api',\r\n npm: '@openrouter/ai-sdk-provider',\r\n defaultBaseUrl: 'https://openrouter.ai/api/v1',\r\n signupUrl: 'https://openrouter.ai/keys',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'kilo',\r\n name: 'Kilo Code',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'https://api.kilo.ai/api/gateway',\r\n modelsPath: '/models',\r\n signupUrl: 'https://app.kilo.ai',\r\n apiKeyOptional: true,\r\n anonymousFreeModels: true,\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'ollama',\r\n name: 'Ollama',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'http://127.0.0.1:11434/v1',\r\n urlPrompt: 'Ollama API Base URL:',\r\n apiKeyOptional: true,\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'lmstudio',\r\n name: 'LM Studio',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'http://127.0.0.1:1234/v1',\r\n urlPrompt: 'LM Studio API Base URL:',\r\n apiKeyOptional: true,\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'venice',\r\n name: 'Venice AI',\r\n authType: 'api',\r\n npm: 'venice-ai-sdk-provider',\r\n defaultBaseUrl: 'https://api.venice.ai/api/v1',\r\n signupUrl: 'https://venice.ai/settings/api',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'anthropic',\r\n name: 'Anthropic',\r\n authType: 'api',\r\n npm: '@ai-sdk/anthropic',\r\n defaultBaseUrl: 'https://api.anthropic.com',\r\n signupUrl: 'https://console.anthropic.com/settings/keys',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'bedrock',\r\n name: 'Amazon Bedrock',\r\n authType: 'api',\r\n npm: '@ai-sdk/amazon-bedrock',\r\n modelSource: 'manual-only',\r\n supported: false,\r\n unsupportedReason: 'Requires AWS credentials — use anygate providers import from OpenCode for now.',\r\n },\r\n {\r\n id: 'azure',\r\n name: 'Azure OpenAI',\r\n authType: 'api',\r\n npm: '@ai-sdk/azure',\r\n modelSource: 'manual-only',\r\n supported: false,\r\n unsupportedReason: 'Requires Azure deployment URLs — use anygate providers import from OpenCode for now.',\r\n },\r\n {\r\n id: 'vertex',\r\n name: 'Google Vertex AI',\r\n authType: 'none',\r\n npm: '@ai-sdk/google-vertex',\r\n modelSource: 'manual-only',\r\n supported: false,\r\n unsupportedReason: 'Uses gcloud Application Default Credentials — not supported via API key import.',\r\n },\r\n {\r\n id: 'opencode-cloud',\r\n name: 'OpenCode Zen / Go',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n signupUrl: 'https://opencode.ai/auth',\r\n modelSource: 'zen-go-api',\r\n supported: true,\r\n },\r\n {\r\n id: 'zen',\r\n name: 'OpenCode Zen',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n signupUrl: 'https://opencode.ai/auth',\r\n modelSource: 'zen-go-api',\r\n supported: true,\r\n addable: false,\r\n },\r\n {\r\n id: 'go',\r\n name: 'OpenCode Go',\r\n authType: 'api',\r\n npm: '@ai-sdk/openai-compatible',\r\n signupUrl: 'https://opencode.ai/auth',\r\n modelSource: 'zen-go-api',\r\n supported: true,\r\n addable: false,\r\n },\r\n // Subscription OAuth providers — Authorization Code + PKCE (browser redirect)\r\n // ⚠️ These extract tokens from paid subscriptions. Account risk — see plan docs.\r\n {\r\n id: 'claude-code',\r\n name: 'Claude Code (Anthropic subscription)',\r\n authType: 'oauth',\r\n npm: '@ai-sdk/anthropic',\r\n defaultBaseUrl: 'https://api.anthropic.com',\r\n signupUrl: 'https://claude.ai',\r\n modelSource: 'api-list',\r\n supported: true,\r\n hidden: true,\r\n subscriptionRisk: true,\r\n },\r\n {\r\n id: 'antigravity',\r\n name: 'Antigravity (Google Cloud Code Assist)',\r\n authType: 'oauth',\r\n npm: '@ai-sdk/openai-compatible',\r\n signupUrl: 'https://antigravity.google',\r\n modelSource: 'api-list',\r\n supported: true,\r\n hidden: true,\r\n subscriptionRisk: true,\r\n },\r\n // OAuth-gated subscription providers — device code or broker sign-in\r\n {\r\n id: 'xai-oauth',\r\n name: 'xAI Grok (SuperGrok)',\r\n authType: 'oauth',\r\n npm: '@ai-sdk/xai',\r\n signupUrl: 'https://x.ai',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'openai-oauth',\r\n name: 'OpenAI (ChatGPT)',\r\n authType: 'oauth',\r\n npm: '@ai-sdk/openai',\r\n signupUrl: 'https://chatgpt.com',\r\n modelSource: 'api-list',\r\n supported: true,\r\n },\r\n {\r\n id: 'github-copilot',\r\n name: 'GitHub Copilot',\r\n authType: 'oauth',\r\n npm: '@ai-sdk/openai-compatible',\r\n defaultBaseUrl: 'https://api.githubcopilot.com',\r\n modelsPath: '/models',\r\n signupUrl: 'https://github.com/features/copilot',\r\n modelSource: 'api-list',\r\n headers: { 'Editor-Version': 'vscode/1.85.1' },\r\n supported: true,\r\n },\r\n];\r\n\r\nexport function listSupportedTemplates(): ProviderTemplate[] {\r\n return PROVIDER_TEMPLATES\r\n .filter(t => t.supported && t.authType === 'api' && t.addable !== false && !t.hidden)\r\n .sort((a, b) => a.name.localeCompare(b.name));\r\n}\r\n\r\n/** Supported templates not yet present in the user's registry. */\r\nexport function listAddableTemplates(configuredIds: Iterable<string> = []): ProviderTemplate[] {\r\n const configured = new Set(configuredIds);\r\n return listSupportedTemplates().filter(t => {\r\n if (t.id === 'opencode-cloud') {\r\n return !configured.has('zen') && !configured.has('go');\r\n }\r\n return !configured.has(t.id);\r\n });\r\n}\r\n\r\nexport function listVisibleOAuthTemplates(configuredIds: Iterable<string> = []): ProviderTemplate[] {\r\n const configured = new Set(configuredIds);\r\n return PROVIDER_TEMPLATES\r\n .filter(t => t.authType === 'oauth' && t.supported && t.addable !== false && !t.hidden && !configured.has(t.id))\r\n .sort((a, b) => a.name.localeCompare(b.name));\r\n}\r\n\r\nexport function getTemplateById(id: string): ProviderTemplate | undefined {\r\n return PROVIDER_TEMPLATES.find(t => t.id === id);\r\n}\r\n\r\nexport function filterTemplates(templates: ProviderTemplate[], query: string): ProviderTemplate[] {\r\n const q = query.trim().toLowerCase();\r\n if (!q) return templates;\r\n return templates.filter(\r\n t =>\r\n t.id.toLowerCase().includes(q) ||\r\n t.name.toLowerCase().includes(q) ||\r\n t.npm.toLowerCase().includes(q),\r\n );\r\n}\r\n"],"mappings":";;;AA8BO,IAAM,qBAAyC;AAAA,EACpD;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,IAAI;AAA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I,aAAa;AACxC,SAAO,uBAAuB,EAAE,OAAO,OAAK;AAC1C,QAAI,EAAE,OAAO,kBAAkB;AAC7B,aAAO,CAAC,WAAW,IAAI,KAAK,KAAK,CAAC,WAAW,IAAI,IAAI;AAAA,IACvD;AACA,WAAO,CAAC,WAAW,IAAI,EAAE,EAAE;AAAA,EAC7B,CAAC;AACH;AAEO,SAAS,0BAA0B,gBAAkC,CAAC,GAAuB;AAClG,QAAM,aAAa,IAAI,IAAI,aAAa;AACxC,SAAO,mBACJ,OAAO,OAAK,EAAE,aAAa,WAAW,EAAE,aAAa,EAAE,YAAY,SAAS,CAAC,EAAE,UAAU,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC,EAC9G,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAChD;AAEO,SAAS,gBAAgB,IAA0C;AACxE,SAAO,mBAAmB,KAAK,OAAK,EAAE,OAAO,EAAE;AACjD;AAEO,SAAS,gBAAgB,WAA+B,OAAmC;AAChG,QAAM,IAAI,MAAM,KAAK,EAAE,YAAY;AACnC,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,UAAU;AAAA,IACf,OACE,EAAE,GAAG,YAAY,EAAE,SAAS,CAAC,KAC7B,EAAE,KAAK,YAAY,EAAE,SAAS,CAAC,KAC/B,EAAE,IAAI,YAAY,EAAE,SAAS,CAAC;AAAA,EAClC;AACF;","names":[]}
|
package/dist/cli.js
CHANGED
|
@@ -128,6 +128,7 @@ import {
|
|
|
128
128
|
readGlobalOpencodeCredential,
|
|
129
129
|
readOpencodeAuthFile,
|
|
130
130
|
recordLaunchSelection,
|
|
131
|
+
recordUsage,
|
|
131
132
|
refreshAllProviderModels,
|
|
132
133
|
refreshModelsDevCacheAsync,
|
|
133
134
|
refreshProviderModels,
|
|
@@ -168,14 +169,14 @@ import {
|
|
|
168
169
|
validateCustomEndpointUrl,
|
|
169
170
|
writeSecureLogLine,
|
|
170
171
|
zenRegistryStub
|
|
171
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-CH5IEXJN.js";
|
|
172
173
|
import {
|
|
173
174
|
filterTemplates,
|
|
174
175
|
getTemplateById,
|
|
175
176
|
listAddableTemplates,
|
|
176
177
|
listSupportedTemplates,
|
|
177
178
|
listVisibleOAuthTemplates
|
|
178
|
-
} from "./chunk-
|
|
179
|
+
} from "./chunk-YYSUTRMV.js";
|
|
179
180
|
|
|
180
181
|
// src/cli.ts
|
|
181
182
|
import pc15 from "picocolors";
|
|
@@ -8145,19 +8146,67 @@ async function handleCloudCodeForwardRequest(res, route, parsed, lowerUrl, log15
|
|
|
8145
8146
|
res.end();
|
|
8146
8147
|
return;
|
|
8147
8148
|
}
|
|
8149
|
+
let inputTokens2 = 0;
|
|
8150
|
+
let outputTokens2 = 0;
|
|
8151
|
+
const decoder = new TextDecoder();
|
|
8152
|
+
let buf = "";
|
|
8148
8153
|
for await (const chunk of upstream.body) {
|
|
8154
|
+
const text4 = decoder.decode(chunk, { stream: true });
|
|
8155
|
+
buf += text4;
|
|
8156
|
+
const lines = buf.split("\n");
|
|
8157
|
+
buf = lines.pop() ?? "";
|
|
8158
|
+
for (const line2 of lines) {
|
|
8159
|
+
const t = line2.startsWith("data: ") ? line2.slice(6).trim() : line2.trim();
|
|
8160
|
+
if (!t || t === "[DONE]") continue;
|
|
8161
|
+
try {
|
|
8162
|
+
const obj = JSON.parse(t);
|
|
8163
|
+
const u = obj.response?.usageMetadata;
|
|
8164
|
+
if (u) {
|
|
8165
|
+
inputTokens2 = u.promptTokenCount ?? inputTokens2;
|
|
8166
|
+
outputTokens2 = u.candidatesTokenCount ?? outputTokens2;
|
|
8167
|
+
}
|
|
8168
|
+
} catch {
|
|
8169
|
+
}
|
|
8170
|
+
}
|
|
8149
8171
|
res.write(chunk);
|
|
8150
8172
|
}
|
|
8151
8173
|
res.end();
|
|
8174
|
+
recordUsage({
|
|
8175
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8176
|
+
modelId: route.displayName,
|
|
8177
|
+
providerId: route.providerId,
|
|
8178
|
+
app: "Antigravity",
|
|
8179
|
+
inputTokens: inputTokens2,
|
|
8180
|
+
outputTokens: outputTokens2
|
|
8181
|
+
});
|
|
8152
8182
|
return;
|
|
8153
8183
|
}
|
|
8154
8184
|
const body = await upstream.text();
|
|
8185
|
+
let inputTokens = 0;
|
|
8186
|
+
let outputTokens = 0;
|
|
8187
|
+
try {
|
|
8188
|
+
const obj = JSON.parse(body);
|
|
8189
|
+
const u = obj.response?.usageMetadata;
|
|
8190
|
+
if (u) {
|
|
8191
|
+
inputTokens = u.promptTokenCount ?? 0;
|
|
8192
|
+
outputTokens = u.candidatesTokenCount ?? 0;
|
|
8193
|
+
}
|
|
8194
|
+
} catch {
|
|
8195
|
+
}
|
|
8155
8196
|
res.writeHead(200, {
|
|
8156
8197
|
"content-type": upstream.headers.get("content-type") ?? "application/json",
|
|
8157
8198
|
"content-length": String(Buffer.byteLength(body)),
|
|
8158
8199
|
"grpc-status": "0"
|
|
8159
8200
|
});
|
|
8160
8201
|
res.end(body);
|
|
8202
|
+
recordUsage({
|
|
8203
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8204
|
+
modelId: route.displayName,
|
|
8205
|
+
providerId: route.providerId,
|
|
8206
|
+
app: "Antigravity",
|
|
8207
|
+
inputTokens,
|
|
8208
|
+
outputTokens
|
|
8209
|
+
});
|
|
8161
8210
|
}
|
|
8162
8211
|
function emitThinkingDelta(res, route, responseId, text4, startSse) {
|
|
8163
8212
|
if (!text4) return;
|
|
@@ -8353,6 +8402,15 @@ async function handleStreamingRequest(res, route, providerOptions, parsed, log15
|
|
|
8353
8402
|
res.write(`data: ${JSON.stringify(chunk)}
|
|
8354
8403
|
|
|
8355
8404
|
`);
|
|
8405
|
+
recordUsage({
|
|
8406
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8407
|
+
modelId: route.displayName,
|
|
8408
|
+
npm: route.npm,
|
|
8409
|
+
providerId: route.providerId,
|
|
8410
|
+
app: "Antigravity",
|
|
8411
|
+
inputTokens: p16.totalUsage?.inputTokens ?? 0,
|
|
8412
|
+
outputTokens: p16.totalUsage?.outputTokens ?? 0
|
|
8413
|
+
});
|
|
8356
8414
|
} else if (p16.type === "error") {
|
|
8357
8415
|
const message = formatUpstreamError(p16.error);
|
|
8358
8416
|
log15(`[gateway] stream provider error: ${message}`);
|
|
@@ -8433,6 +8491,15 @@ async function handleUnaryRequest(res, route, providerOptions, parsed, _log, opt
|
|
|
8433
8491
|
responseId
|
|
8434
8492
|
};
|
|
8435
8493
|
respondJson(res, 200, { response, traceId: "gateway-trace", metadata: {} });
|
|
8494
|
+
recordUsage({
|
|
8495
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8496
|
+
modelId: route.displayName,
|
|
8497
|
+
npm: route.npm,
|
|
8498
|
+
providerId: route.providerId,
|
|
8499
|
+
app: "Antigravity",
|
|
8500
|
+
inputTokens: result.usage?.inputTokens ?? 0,
|
|
8501
|
+
outputTokens: result.usage?.outputTokens ?? 0
|
|
8502
|
+
});
|
|
8436
8503
|
}
|
|
8437
8504
|
|
|
8438
8505
|
// src/gateway/antigravity/launch-routes.ts
|
|
@@ -12802,7 +12869,7 @@ Error: ${parsed.error}
|
|
|
12802
12869
|
console.log("Usage: anygate ui [--trace]\n\nOpen the settings UI in your browser.");
|
|
12803
12870
|
return 0;
|
|
12804
12871
|
}
|
|
12805
|
-
const { runUiCommand } = await import("./command-
|
|
12872
|
+
const { runUiCommand } = await import("./command-QEYVYS7O.js");
|
|
12806
12873
|
return runUiCommand({ trace: parsed.trace });
|
|
12807
12874
|
}
|
|
12808
12875
|
if (parsed.command === "models") {
|