Merge remote-tracking branch 'origin/master' into gitea/feature/end
Resolved conflicts taking origin/master (v0.5.55) as canonical, with local features re-applied: - runtime log level (LOG_LEVEL env + dashboard Settings → Logging, applied immediately and persisted across restarts) - free/noAuth provider enable/disable toggle via providerStrategies.enabled - parallel model testing (Test All Models / Test Selected Keys)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { platform, arch } from "os";
|
||||
import { platform, arch, hostname } from "os";
|
||||
import { PROVIDERS, PROVIDER_OAUTH } from "./providers.js";
|
||||
import { ANTIGRAVITY_IDE_USER_AGENT } from "../providers/shared.js";
|
||||
import { createRequire } from "module";
|
||||
|
||||
// === Gemini CLI === derive từ registry gemini-cli.transport
|
||||
export const GEMINI_CLI_VERSION = PROVIDERS["gemini-cli"]?.cliVersion;
|
||||
@@ -59,7 +61,7 @@ export function getPlatformEnum() {
|
||||
}
|
||||
|
||||
export function getPlatformUserAgent() {
|
||||
return `antigravity/1.104.0 ${platform()}/${arch()}`;
|
||||
return ANTIGRAVITY_IDE_USER_AGENT;
|
||||
}
|
||||
|
||||
export const CLIENT_METADATA = {
|
||||
@@ -129,13 +131,22 @@ export const AG_DEFAULT_TOOLS = new Set([
|
||||
|
||||
// Antigravity chat/stream headers
|
||||
export const ANTIGRAVITY_HEADERS = {
|
||||
"User-Agent": `antigravity/1.107.0 ${platform()}/${arch()}`
|
||||
"User-Agent": ANTIGRAVITY_IDE_USER_AGENT
|
||||
};
|
||||
|
||||
// Cloud Code Assist API
|
||||
// Cloud Code Assist API endpoints differ by client ecosystem.
|
||||
export const CLOUD_CODE_API = {
|
||||
loadCodeAssist: "https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",
|
||||
onboardUser: "https://cloudcode-pa.googleapis.com/v1internal:onboardUser",
|
||||
"gemini-cli": {
|
||||
loadCodeAssist: "https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",
|
||||
onboardUser: "https://cloudcode-pa.googleapis.com/v1internal:onboardUser",
|
||||
},
|
||||
// Project discovery (loadCodeAssist/onboardUser) stays on PROD — the daily host
|
||||
// rejects these auth/onboarding calls. Only chat traffic uses the daily host
|
||||
// (see transport.apiEndpoint in registry/antigravity.js, set to bypass prod 429).
|
||||
antigravity: {
|
||||
loadCodeAssist: "https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",
|
||||
onboardUser: "https://cloudcode-pa.googleapis.com/v1internal:onboardUser",
|
||||
},
|
||||
};
|
||||
|
||||
export const LOAD_CODE_ASSIST_HEADERS = {
|
||||
@@ -145,6 +156,13 @@ export const LOAD_CODE_ASSIST_HEADERS = {
|
||||
"Client-Metadata": JSON.stringify({ ideType: IDE_TYPE.ANTIGRAVITY, platform: getPlatformEnum(), pluginType: PLUGIN_TYPE.GEMINI }),
|
||||
};
|
||||
|
||||
// Real Antigravity IDE doesn't send X-Goog-Api-Client/Client-Metadata on loadCodeAssist/onboardUser —
|
||||
// Google's backend fingerprints those and silently refuses to provision a cloudaicompanionProject.
|
||||
export const ANTIGRAVITY_LOAD_CODE_ASSIST_HEADERS = {
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": ANTIGRAVITY_IDE_USER_AGENT,
|
||||
};
|
||||
|
||||
export const LOAD_CODE_ASSIST_METADATA = {
|
||||
ideType: IDE_TYPE.ANTIGRAVITY,
|
||||
platform: getPlatformEnum(),
|
||||
@@ -165,17 +183,48 @@ export const OAUTH_ENDPOINTS = {
|
||||
google: { token: "https://oauth2.googleapis.com/token", auth: "https://accounts.google.com/o/oauth2/auth" },
|
||||
openai: { token: PROVIDER_OAUTH["codex"]?.tokenUrl, auth: PROVIDER_OAUTH["codex"]?.authorizeUrl },
|
||||
anthropic: { token: PROVIDER_OAUTH["claude"]?.tokenUrl, auth: "https://api.anthropic.com/v1/oauth/authorize" }, // ≠ claude.authorizeUrl (claude.ai login) — keep
|
||||
qwen: { token: PROVIDER_OAUTH["qwen"]?.tokenUrl, auth: PROVIDER_OAUTH["qwen"]?.deviceCodeUrl },
|
||||
iflow: { token: PROVIDER_OAUTH["iflow"]?.tokenUrl, auth: PROVIDER_OAUTH["iflow"]?.authorizeUrl },
|
||||
github: { token: PROVIDER_OAUTH["github"]?.tokenUrl, auth: PROVIDER_OAUTH["github"]?.authorizeUrl, deviceCode: PROVIDER_OAUTH["github"]?.deviceCodeUrl },
|
||||
};
|
||||
|
||||
// Generate Kimi OAuth custom headers
|
||||
export function buildKimiHeaders() {
|
||||
let _appVersion;
|
||||
function getAppPackageVersion() {
|
||||
if (_appVersion) return _appVersion;
|
||||
try {
|
||||
const require = createRequire(import.meta.url);
|
||||
_appVersion = require("../../package.json").version || "0.0.0";
|
||||
} catch {
|
||||
_appVersion = process.env.npm_package_version || "0.0.0";
|
||||
}
|
||||
return _appVersion;
|
||||
}
|
||||
|
||||
// Kimi Code OAuth / API headers (CLIProxyAPI internal/auth/kimi commonHeaders parity).
|
||||
// deviceId must stay stable per connection for the whole OAuth session.
|
||||
export function buildKimiHeaders(deviceId) {
|
||||
const osName = platform();
|
||||
const architecture = arch();
|
||||
let deviceModel = `${osName} ${architecture}`;
|
||||
if (osName === "darwin") deviceModel = `macOS ${architecture}`;
|
||||
else if (osName === "win32") deviceModel = `Windows ${architecture}`;
|
||||
else if (osName === "linux") deviceModel = `Linux ${architecture}`;
|
||||
|
||||
let deviceName = "unknown";
|
||||
try {
|
||||
deviceName = hostname() || "unknown";
|
||||
} catch {
|
||||
deviceName = "unknown";
|
||||
}
|
||||
|
||||
const resolvedId = (typeof deviceId === "string" && deviceId.trim())
|
||||
? deviceId.trim()
|
||||
: `kimi-${Date.now()}`;
|
||||
|
||||
return {
|
||||
"X-Msh-Platform": "9router",
|
||||
"X-Msh-Version": "2.1.2",
|
||||
"X-Msh-Device-Model": typeof process !== "undefined" ? `${process.platform} ${process.arch}` : "unknown",
|
||||
"X-Msh-Device-Id": `kimi-${Date.now()}`
|
||||
"X-Msh-Version": getAppPackageVersion(),
|
||||
"X-Msh-Device-Name": deviceName,
|
||||
"X-Msh-Device-Model": deviceModel,
|
||||
"X-Msh-Device-Id": resolvedId,
|
||||
};
|
||||
}
|
||||
|
||||
10
open-sse/config/grokCli.js
Normal file
10
open-sse/config/grokCli.js
Normal file
@@ -0,0 +1,10 @@
|
||||
export const GROK_CLI_VERSION = "0.2.99";
|
||||
export const GROK_CLI_MODEL = "grok-build";
|
||||
export const GROK_CLI_BASE_URL = "https://cli-chat-proxy.grok.com/v1";
|
||||
export const GROK_CLI_CLIENT_IDENTIFIER = "grok-shell";
|
||||
export const GROK_CLI_USER_AGENT = `grok-shell/${GROK_CLI_VERSION} (linux; x86_64)`;
|
||||
|
||||
export function supportsGrokCliReasoningEffort(model) {
|
||||
// ponytail: unknown models omit effort until live metadata reaches dispatch.
|
||||
return /^grok-4\.5(?:$|-)/.test(String(model || ""));
|
||||
}
|
||||
@@ -8,18 +8,24 @@
|
||||
* - `-agentic` model suffix detection + chunked-write system prompt
|
||||
* - reasoning / thinking trigger detection (Anthropic-Beta header,
|
||||
* Claude `thinking`, OpenAI `reasoning_effort`, AMP/Cursor magic tag)
|
||||
* - the `<thinking_mode>enabled</thinking_mode>` system-prompt injection
|
||||
* that turns Kiro reasoning on
|
||||
* - schema-specific native effort fields for supported GPT and Claude models
|
||||
* - legacy `<thinking_mode>` system-prompt injection for other models
|
||||
*
|
||||
* Kiro upstream does not advertise `-agentic` model IDs; they are a 9router
|
||||
* fiction. The suffix is stripped before the request leaves this process.
|
||||
*/
|
||||
|
||||
import { extractThinking } from "../translator/concerns/thinkingUnified.js";
|
||||
import { extractThinking, parseSuffix } from "../translator/concerns/thinkingUnified.js";
|
||||
import { effortToBudget } from "../translator/concerns/thinking.js";
|
||||
|
||||
export const KIRO_AGENTIC_SUFFIX = "-agentic";
|
||||
export const KIRO_THINKING_SUFFIX = "-thinking";
|
||||
export const KIRO_TOOL_NAME_MAX_LENGTH = 64;
|
||||
export const KIRO_TOOL_DESCRIPTION_MAX_LENGTH = 10237;
|
||||
export const KIRO_TOOL_ID_MAX_LENGTH = 64;
|
||||
export const KIRO_CODEWHISPERER_TARGET =
|
||||
"AmazonCodeWhispererStreamingService.GenerateAssistantResponse";
|
||||
export const KIRO_ENDPOINT_FALLBACK_STATUSES = new Set([401, 403, 404]);
|
||||
|
||||
// Public default CodeWhisperer profile ARNs (us-east-1), keyed by auth method.
|
||||
// Used when an account cannot resolve its own profileArn. Builder ID and social
|
||||
@@ -40,6 +46,39 @@ export function resolveDefaultProfileArn(authMethod) {
|
||||
|
||||
export const KIRO_THINKING_BUDGET_DEFAULT = 16000;
|
||||
|
||||
/**
|
||||
* Resolve a Kiro model after consuming the generic model(level) suffix.
|
||||
* The suffix is a 9router request override, not part of Kiro's upstream model id.
|
||||
*/
|
||||
export function resolveKiroModelIntent(model) {
|
||||
const { cleanModel, override } = parseSuffix(model);
|
||||
return {
|
||||
model: cleanModel,
|
||||
...resolveKiroModel(cleanModel),
|
||||
thinkingOverride: override,
|
||||
};
|
||||
}
|
||||
|
||||
/** Apply a parsed model(level) override without mutating the caller's body. */
|
||||
export function applyKiroThinkingOverride(body, override) {
|
||||
if (!override) return body;
|
||||
|
||||
const next = { ...body };
|
||||
if (override.mode === "budget") {
|
||||
delete next.output_config;
|
||||
delete next.reasoning_effort;
|
||||
delete next.reasoning;
|
||||
next.thinking = { type: "enabled", budget_tokens: override.budget };
|
||||
return next;
|
||||
}
|
||||
|
||||
next.output_config = {
|
||||
...(body.output_config || {}),
|
||||
effort: override.mode === "level" ? override.level : override.mode,
|
||||
};
|
||||
return next;
|
||||
}
|
||||
|
||||
export const KIRO_AGENTIC_SYSTEM_PROMPT = `
|
||||
# CRITICAL: CHUNKED WRITE PROTOCOL (MANDATORY)
|
||||
|
||||
@@ -109,6 +148,7 @@ export function resolveKiroThinkingBudget(body, headers, model) {
|
||||
const cfg = extractThinking(body);
|
||||
if (cfg) {
|
||||
if (cfg.mode === "none") return null;
|
||||
if (cfg.mode === "level" && cfg.level === "disabled") return null;
|
||||
if (cfg.mode === "budget") return cfg.budget;
|
||||
if (cfg.mode === "level") return effortToBudget(cfg.level) ?? KIRO_THINKING_BUDGET_DEFAULT;
|
||||
return KIRO_THINKING_BUDGET_DEFAULT;
|
||||
@@ -131,6 +171,86 @@ export function resolveKiroThinkingBudget(body, headers, model) {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function extractKiroEffortLevel(body) {
|
||||
const effort =
|
||||
body?.output_config?.effort ??
|
||||
body?.reasoning_effort ??
|
||||
(typeof body?.reasoning === "object" ? body.reasoning?.effort : null);
|
||||
if (typeof effort !== "string") return null;
|
||||
const normalized = effort.toLowerCase();
|
||||
if (normalized === "none" || normalized === "off" || normalized === "disabled") return null;
|
||||
if (normalized === "xhigh" || normalized === "max") return "high";
|
||||
if (["low", "medium", "high"].includes(normalized)) return normalized;
|
||||
return null;
|
||||
}
|
||||
|
||||
function extractKiroGptEffortLevel(body) {
|
||||
const effort =
|
||||
body?.output_config?.effort ??
|
||||
body?.reasoning_effort ??
|
||||
(typeof body?.reasoning === "object" ? body.reasoning?.effort : null);
|
||||
if (typeof effort !== "string") return null;
|
||||
const normalized = effort.toLowerCase();
|
||||
if (normalized === "max") return "xhigh";
|
||||
// Kiro CLI does not advertise an explicit GPT "none" wire value; omit it.
|
||||
if (["low", "medium", "high", "xhigh"].includes(normalized)) {
|
||||
return normalized;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function buildKiroAdditionalModelRequestFields(body, effortPath = "output_config") {
|
||||
const effort = effortPath === "reasoning"
|
||||
? extractKiroGptEffortLevel(body)
|
||||
: extractKiroEffortLevel(body);
|
||||
if (!effort) return undefined;
|
||||
if (effortPath === "reasoning") {
|
||||
// Mirrors Kiro CLI/KAS buildEffortRequestFields("reasoning") for GPT.
|
||||
return { reasoning: { effort } };
|
||||
}
|
||||
// Mirrors Kiro CLI/KAS buildEffortRequestFields("output_config").
|
||||
return {
|
||||
thinking: { type: "adaptive", display: "summarized" },
|
||||
output_config: { effort },
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveKiroEffortPath(model) {
|
||||
if (typeof model !== "string") return null;
|
||||
const normalized = model.toLowerCase().replace(/-/g, ".");
|
||||
if (/(?:^|[/.])gpt[/.]5[/.]6(?:[/.]|$)/.test(normalized)) {
|
||||
return "reasoning";
|
||||
}
|
||||
if (!normalized.includes("claude")) return null;
|
||||
const match = normalized.match(/(?:^|[/.])claude(?:[/.][a-z]+)*[/.](\d+)(?:[/.](\d+))?(?:[/.]|$)/);
|
||||
if (!match) return null;
|
||||
const [, majorText, minorText] = match;
|
||||
const major = Number(majorText);
|
||||
const minor = minorText === undefined ? null : Number(minorText);
|
||||
const dateSuffixMinor = minor !== null && minor >= 1000;
|
||||
// Kiro rejected additionalModelRequestFields on legacy 4.5 models in live smoke.
|
||||
// Default future Claude/Kiro models to supported so new model releases do not
|
||||
// need a code allowlist update.
|
||||
return major < 4 || (major === 4 && (minor === null || minor <= 5 || dateSuffixMinor))
|
||||
? null
|
||||
: "output_config";
|
||||
}
|
||||
|
||||
export function supportsKiroAdditionalModelRequestFields(model) {
|
||||
return resolveKiroEffortPath(model) !== null;
|
||||
}
|
||||
|
||||
export function usesKiroNativeGptEffort(body, model) {
|
||||
return resolveKiroEffortPath(model) === "reasoning"
|
||||
&& extractKiroGptEffortLevel(body) !== null;
|
||||
}
|
||||
|
||||
export function buildKiroAdditionalModelRequestFieldsForModel(body, model) {
|
||||
const effortPath = resolveKiroEffortPath(model);
|
||||
if (!effortPath) return undefined;
|
||||
return buildKiroAdditionalModelRequestFields(body, effortPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect whether an inbound request is asking for reasoning / thinking output.
|
||||
* Thin wrapper over resolveKiroThinkingBudget (single source of truth).
|
||||
|
||||
@@ -2,9 +2,8 @@ import { PROVIDERS } from "./providers.js";
|
||||
import REGISTRY from "../providers/registry/index.js";
|
||||
// PROVIDER_MODELS now built from providers/registry (transport + models co-located)
|
||||
import { PROVIDER_MODELS } from "../providers/index.js";
|
||||
import { modelQuotaFamily, modelStrip, modelTargetFormat } from "../providers/models/schema.js";
|
||||
import { modelQuotaFamily, modelStrip, modelTargetFormat, modelSupportedFormats, normalizeModelId } from "../providers/models/schema.js";
|
||||
import { CODEX_REVIEW_SUFFIX } from "../providers/models/helpers.js";
|
||||
|
||||
export { PROVIDER_MODELS };
|
||||
|
||||
|
||||
@@ -18,46 +17,82 @@ export function getDefaultModel(aliasOrId) {
|
||||
return models?.[0]?.id || null;
|
||||
}
|
||||
|
||||
// Providers whose registry uses dots in version numbers (e.g. "claude-sonnet-4.5").
|
||||
// For these, we tolerate clients sending dashes ("claude-sonnet-4-5") by normalizing
|
||||
// digit-hyphen-digit to digit-dot-digit before lookup. Other providers are left untouched.
|
||||
const DOT_VERSION_PROVIDERS = new Set(["kr", "kiro"]);
|
||||
|
||||
// Find a registry entry by id. For Kiro models, tolerates dash/dot version separators
|
||||
// ("claude-sonnet-4-5" ~= "claude-sonnet-4.5"). Other providers use exact match only.
|
||||
function findModel(models, modelId, aliasOrId) {
|
||||
if (!models) return undefined;
|
||||
const found = models.find(m => m.id === modelId);
|
||||
if (found) return found;
|
||||
if (!DOT_VERSION_PROVIDERS.has(aliasOrId)) return undefined;
|
||||
const normalized = normalizeModelId(modelId);
|
||||
if (normalized === modelId) return undefined;
|
||||
return models.find(m => m.id === normalized);
|
||||
}
|
||||
|
||||
export function isValidModel(aliasOrId, modelId, passthroughProviders = new Set()) {
|
||||
if (passthroughProviders.has(aliasOrId)) return true;
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
if (!models) return false;
|
||||
return models.some(m => m.id === modelId);
|
||||
return !!findModel(models, modelId, aliasOrId);
|
||||
}
|
||||
|
||||
export function findModelName(aliasOrId, modelId) {
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
if (!models) return modelId;
|
||||
const found = models.find(m => m.id === modelId);
|
||||
const found = findModel(models, modelId, aliasOrId);
|
||||
return found?.name || modelId;
|
||||
}
|
||||
|
||||
export function getModelTargetFormat(aliasOrId, modelId) {
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
if (!models) return null;
|
||||
return modelTargetFormat(models.find(m => m.id === modelId));
|
||||
return modelTargetFormat(findModel(models, modelId, aliasOrId));
|
||||
}
|
||||
|
||||
// Declared upstream formats for a model (registry `supportedFormats`). Drives the
|
||||
// per-model guard on the sourceFormat-matched transport; null when undeclared.
|
||||
export function getModelSupportedFormats(aliasOrId, modelId) {
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
if (!models) return null;
|
||||
return modelSupportedFormats(findModel(models, modelId, aliasOrId));
|
||||
}
|
||||
|
||||
export function getModelType(aliasOrId, modelId) {
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
if (!models) return null;
|
||||
const found = models.find(m => m.id === modelId);
|
||||
const found = findModel(models, modelId, aliasOrId);
|
||||
return found?.kind || found?.type || null;
|
||||
}
|
||||
|
||||
export function getModelUpstreamId(aliasOrId, modelId) {
|
||||
// Split off thinking suffix "(level)" so lookup hits the base id; re-append it to
|
||||
// the result so downstream applyThinking still sees the suffix (body.model is stripped separately).
|
||||
const sufMatch = typeof modelId === "string" ? modelId.match(/\([^()]+\)\s*$/) : null;
|
||||
const suffix = sufMatch ? sufMatch[0] : "";
|
||||
const baseId = suffix ? modelId.slice(0, sufMatch.index).trim() : modelId;
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
const found = models?.find(m => m.id === modelId);
|
||||
if (found?.upstreamModelId) return found.upstreamModelId;
|
||||
if (aliasOrId === "cx" && typeof modelId === "string" && modelId.endsWith(CODEX_REVIEW_SUFFIX)) {
|
||||
return modelId.slice(0, -CODEX_REVIEW_SUFFIX.length);
|
||||
const found = findModel(models, baseId, aliasOrId);
|
||||
const resolvedId = found?.upstreamModelId || found?.id;
|
||||
if (resolvedId) {
|
||||
const presetMatch = resolvedId.match(/\([^()]+\)\s*$/);
|
||||
const presetSuffix = presetMatch?.[0] || "";
|
||||
const resolvedBase = presetSuffix ? resolvedId.slice(0, presetMatch.index).trim() : resolvedId;
|
||||
return resolvedBase + (suffix || presetSuffix);
|
||||
}
|
||||
return modelId;
|
||||
if (aliasOrId === "cx" && typeof baseId === "string" && baseId.endsWith(CODEX_REVIEW_SUFFIX)) {
|
||||
return baseId.slice(0, -CODEX_REVIEW_SUFFIX.length) + suffix;
|
||||
}
|
||||
return baseId + suffix;
|
||||
}
|
||||
|
||||
export function getModelQuotaFamily(aliasOrId, modelId) {
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
return modelQuotaFamily(models?.find(m => m.id === modelId));
|
||||
return modelQuotaFamily(findModel(models, modelId, aliasOrId));
|
||||
}
|
||||
|
||||
// OAuth short aliases — derived from registry `alias` (single source). everything else: alias = id.
|
||||
@@ -79,5 +114,5 @@ export function getModelsByProviderId(providerId) {
|
||||
// Get strip list for a model entry (explicit opt-in only)
|
||||
// Returns array of content types to strip, e.g. ["image", "audio"]
|
||||
export function getModelStrip(alias, modelId) {
|
||||
return modelStrip(PROVIDER_MODELS[alias]?.find(m => m.id === modelId));
|
||||
return modelStrip(findModel(PROVIDER_MODELS[alias], modelId, alias));
|
||||
}
|
||||
|
||||
@@ -39,6 +39,15 @@ function envMs(name, def) {
|
||||
return Number.isFinite(n) && n > 0 ? n : def;
|
||||
}
|
||||
|
||||
function envUrl(name, def) {
|
||||
const raw = process.env[name]?.trim();
|
||||
return raw || def;
|
||||
}
|
||||
|
||||
// SearXNG endpoint used by the unauthenticated web-search provider.
|
||||
// Configure this for a separate Docker service or remote SearXNG instance.
|
||||
export const SEARXNG_URL = envUrl("SEARXNG_URL", "http://localhost:8888/search");
|
||||
|
||||
// Inter-chunk stall timeout (once tokens are flowing). Generous headroom so
|
||||
// slow reasoning models aren't aborted mid-stream. Env: STREAM_STALL_TIMEOUT_MS.
|
||||
export const STREAM_STALL_TIMEOUT_MS = envMs("STREAM_STALL_TIMEOUT_MS", 360 * 1000);
|
||||
@@ -56,6 +65,8 @@ export const GEMINI_NATIVE_TTS_FETCH_TIMEOUT_MS = envMs("GEMINI_NATIVE_TTS_FETCH
|
||||
export const DEFAULT_MAX_TOKENS = 64000;
|
||||
export const DEFAULT_MIN_TOKENS = 32000;
|
||||
|
||||
export const TOKEN_SAVER_HEADER = "x-9router-token-saver";
|
||||
|
||||
// Retry config for 429 responses (legacy - kept for backward compatibility)
|
||||
export const RETRY_CONFIG = {
|
||||
maxAttempts: 2,
|
||||
|
||||
@@ -33,6 +33,21 @@ const GEMINI_VOICES = [
|
||||
"Vindemiatrix", "Sadachbia", "Sadaltager", "Sulafat",
|
||||
].map((id) => ({ id, name: id, type: "tts" }));
|
||||
|
||||
// Xiaomi MiMo preset voices (from https://mimo.mi.com/docs/zh-CN/quick-start/usage-guide/audio/speech-synthesis-v2.5).
|
||||
// Voice id is passed via `audio.voice`; `mimo_default` = default (冰糖 on CN cluster, Mia elsewhere).
|
||||
// Voices are language-independent — the spoken language is a separate hint, not bound to the voice.
|
||||
const MIMO_VOICES = [
|
||||
{ id: "mimo_default", name: "mimo_default" },
|
||||
{ id: "冰糖", name: "冰糖" },
|
||||
{ id: "茉莉", name: "茉莉" },
|
||||
{ id: "苏打", name: "苏打" },
|
||||
{ id: "白桦", name: "白桦" },
|
||||
{ id: "Mia", name: "Mia" },
|
||||
{ id: "Chloe", name: "Chloe" },
|
||||
{ id: "Milo", name: "Milo" },
|
||||
{ id: "Dean", name: "Dean" },
|
||||
].map((v) => ({ type: "tts", ...v }));
|
||||
|
||||
// ── TTS Config (config-driven, single source of truth) ─────────────────────
|
||||
export const TTS_MODELS_CONFIG = {
|
||||
openai: {
|
||||
@@ -107,6 +122,14 @@ export const TTS_MODELS_CONFIG = {
|
||||
},
|
||||
allVoices: GEMINI_VOICES,
|
||||
},
|
||||
"xiaomi-mimo": {
|
||||
models: [
|
||||
{ id: "mimo-v2.5-tts", name: "MiMo V2.5 TTS", type: "tts" },
|
||||
],
|
||||
voices: {
|
||||
"mimo-v2.5-tts": MIMO_VOICES,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// ── Helper: get voices for a specific model ────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user