fix: Codex 自动压缩不触发 —— 接管时链接模型目录(绝对路径)进 config.toml (hot 1.5.83)

This commit is contained in:
mac
2026-08-16 12:45:32 +08:00
parent e9a261482c
commit 1b687c01e9
50 changed files with 10885 additions and 1161 deletions
+38
View File
@@ -0,0 +1,38 @@
// 多模态网关凭据只允许在打包时注入,不写进仓库或路由分组配置。
const fs = require("fs");
const path = require("path");
const DEFAULT_BASE_URL = "https://api.tokendun.com";
const DEFAULT_MODEL = "MiniMax-M3";
function readJson(file) {
try {
return JSON.parse(fs.readFileSync(file, "utf-8"));
} catch {
return null;
}
}
function configFiles() {
const files = [];
if (process.env.TD_MULTIMODAL_GATEWAY_CONFIG) files.push(process.env.TD_MULTIMODAL_GATEWAY_CONFIG);
// 热更新目录不随完整安装包携带 resources;将凭据放在 userData 后可被热更新代码稳定读取。
try {
const { app } = require("electron");
if (app && app.getPath) files.push(path.join(app.getPath("userData"), "multimodal-gateway.json"));
} catch {}
if (process.resourcesPath) files.push(path.join(process.resourcesPath, "multimodal-gateway.json"));
files.push(path.join(__dirname, "..", "..", "resources", "multimodal-gateway.json"));
return Array.from(new Set(files));
}
function gatewayConfig() {
const fileConfig = configFiles().map(readJson).find(Boolean) || {};
const baseUrl = String(process.env.TD_MULTIMODAL_GATEWAY_URL || fileConfig.baseUrl || DEFAULT_BASE_URL).trim();
const key = String(process.env.TD_MULTIMODAL_GATEWAY_KEY || fileConfig.key || "").trim();
const model = String(process.env.TD_MULTIMODAL_MODEL || fileConfig.model || DEFAULT_MODEL).trim();
const sttModel = String(process.env.TD_MULTIMODAL_STT_MODEL || fileConfig.sttModel || "").trim();
return { baseUrl, key, model, sttModel };
}
module.exports = { gatewayConfig };