mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
fix(grok-cli): align Grok Build with current subscription protocol (#2590)
This commit is contained in:
@@ -8,6 +8,8 @@ import { getModelsByProviderId } from "open-sse/config/providerModels.js";
|
||||
import { resolveKiroModels } from "open-sse/services/kiroModels.js";
|
||||
import { resolveKimchiModels } from "open-sse/services/kimchiModels.js";
|
||||
import { resolveQoderModels } from "open-sse/services/qoderModels.js";
|
||||
import { resolveGrokCliModels } from "open-sse/services/grokCliModels.js";
|
||||
import { resolveConnectionProxyConfig } from "@/lib/network/connectionProxy";
|
||||
|
||||
const GEMINI_CLI_MODELS_URL = "https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels";
|
||||
|
||||
@@ -369,6 +371,35 @@ const PROVIDER_MODELS_CONFIG = {
|
||||
errorLabel: "Failed to fetch Gemini CLI models"
|
||||
})
|
||||
},
|
||||
"grok-cli": {
|
||||
customResolver: async (connection) => {
|
||||
const proxy = await resolveConnectionProxyConfig(connection.providerSpecificData || {});
|
||||
const result = await resolveGrokCliModels({
|
||||
...connection,
|
||||
connectionId: connection.id,
|
||||
}, {
|
||||
log: console,
|
||||
proxyOptions: {
|
||||
connectionProxyEnabled: proxy.connectionProxyEnabled === true,
|
||||
connectionProxyUrl: proxy.connectionProxyUrl || "",
|
||||
connectionNoProxy: proxy.connectionNoProxy || "",
|
||||
vercelRelayUrl: proxy.vercelRelayUrl || "",
|
||||
strictProxy: proxy.strictProxy === true,
|
||||
},
|
||||
onCredentialsRefreshed: async (refreshed) => {
|
||||
await updateProviderCredentials(connection.id, {
|
||||
...refreshed,
|
||||
existingProviderSpecificData: connection.providerSpecificData || {},
|
||||
});
|
||||
},
|
||||
});
|
||||
if (result.models.length) return result;
|
||||
return {
|
||||
models: getStaticProviderModels("grok-cli"),
|
||||
warning: result.warning || "Grok CLI returned no live models; using static catalog.",
|
||||
};
|
||||
},
|
||||
},
|
||||
"ollama-local": {
|
||||
customResolver: async (connection) => {
|
||||
const url = `${resolveOllamaLocalHost(connection)}/api/tags`;
|
||||
|
||||
@@ -12,7 +12,9 @@ import { resolveKimchiModels } from "open-sse/services/kimchiModels.js";
|
||||
import { resolveQoderModels } from "open-sse/services/qoderModels.js";
|
||||
import { resolveCopilotModels } from "open-sse/services/copilotModels.js";
|
||||
import { resolveClinepassModels } from "open-sse/services/clinepassModels.js";
|
||||
import { resolveGrokCliModels } from "open-sse/services/grokCliModels.js";
|
||||
import { updateProviderCredentials } from "@/sse/services/tokenRefresh";
|
||||
import { resolveConnectionProxyConfig } from "@/lib/network/connectionProxy";
|
||||
import { capabilitiesFromServiceKind, getCapabilitiesForModel } from "open-sse/providers/capabilities.js";
|
||||
|
||||
// Per-provider live model resolvers. Each receives a connection record and
|
||||
@@ -71,7 +73,30 @@ const LIVE_MODEL_RESOLVERS = {
|
||||
apiKey: conn.apiKey,
|
||||
});
|
||||
return result?.models?.length ? { models: result.models } : null;
|
||||
}
|
||||
},
|
||||
"grok-cli": async (conn) => {
|
||||
const proxy = await resolveConnectionProxyConfig(conn.providerSpecificData || {});
|
||||
const result = await resolveGrokCliModels({
|
||||
...conn,
|
||||
connectionId: conn.id,
|
||||
}, {
|
||||
log: console,
|
||||
proxyOptions: {
|
||||
connectionProxyEnabled: proxy.connectionProxyEnabled === true,
|
||||
connectionProxyUrl: proxy.connectionProxyUrl || "",
|
||||
connectionNoProxy: proxy.connectionNoProxy || "",
|
||||
vercelRelayUrl: proxy.vercelRelayUrl || "",
|
||||
strictProxy: proxy.strictProxy === true,
|
||||
},
|
||||
onCredentialsRefreshed: async (refreshed) => {
|
||||
await updateProviderCredentials(conn.id, {
|
||||
...refreshed,
|
||||
existingProviderSpecificData: conn.providerSpecificData || {},
|
||||
});
|
||||
},
|
||||
});
|
||||
return result?.models?.length ? { models: result.models } : null;
|
||||
},
|
||||
};
|
||||
|
||||
const parseOpenAIStyleModels = (data) => {
|
||||
|
||||
Reference in New Issue
Block a user