8900 commited on
Update setup-hf-config.mjs
Browse files- setup-hf-config.mjs +26 -15
setup-hf-config.mjs
CHANGED
|
@@ -38,7 +38,7 @@ if (!gatewayToken && !gatewayPassword) {
|
|
| 38 |
process.exit(1);
|
| 39 |
}
|
| 40 |
|
| 41 |
-
// ✅ 默认模型
|
| 42 |
const defaultModel =
|
| 43 |
(process.env.OPENCLAW_HF_DEFAULT_MODEL || "").trim() ||
|
| 44 |
"huggingface/deepseek-ai/DeepSeek-R1";
|
|
@@ -53,23 +53,24 @@ const envVars = {
|
|
| 53 |
TELEGRAM_BOT_TOKEN: process.env.TELEGRAM_BOT_TOKEN?.trim(),
|
| 54 |
};
|
| 55 |
|
| 56 |
-
// TELEGRAM_API_ROOT
|
| 57 |
let telegramApiRoot = (process.env.TELEGRAM_API_ROOT || "https://api.telegram.org").trim();
|
| 58 |
if (telegramApiRoot.endsWith("/bot")) {
|
| 59 |
telegramApiRoot = telegramApiRoot.slice(0, -4);
|
| 60 |
}
|
| 61 |
telegramApiRoot = telegramApiRoot.replace(/\/$/, "");
|
| 62 |
|
| 63 |
-
// proxies(
|
| 64 |
-
const
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
| 73 |
|
| 74 |
// ====================== 加载已有配置 ======================
|
| 75 |
let config = {};
|
|
@@ -84,7 +85,7 @@ try {
|
|
| 84 |
// ====================== Gateway ======================
|
| 85 |
config.gateway = config.gateway || {};
|
| 86 |
|
| 87 |
-
// Auth
|
| 88 |
if (gatewayToken) {
|
| 89 |
config.gateway.auth = {
|
| 90 |
mode: "token",
|
|
@@ -97,12 +98,21 @@ if (gatewayToken) {
|
|
| 97 |
};
|
| 98 |
}
|
| 99 |
|
| 100 |
-
// UI
|
| 101 |
config.gateway.controlUi = config.gateway.controlUi || {};
|
| 102 |
config.gateway.controlUi.dangerouslyDisableDeviceAuth = true;
|
| 103 |
|
| 104 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
|
|
|
| 106 |
config.gateway.trustedProxies = trustedProxies;
|
| 107 |
|
| 108 |
// ====================== Agents ======================
|
|
@@ -150,4 +160,5 @@ console.log("[openclaw-hf-setup] ✅ Ready");
|
|
| 150 |
console.log(`[openclaw-hf-setup] Auth: ${gatewayToken ? "token" : "password"}`);
|
| 151 |
console.log(`[openclaw-hf-setup] Model: ${defaultModel}`);
|
| 152 |
console.log(`[openclaw-hf-setup] Proxies: ${trustedProxies.length}`);
|
|
|
|
| 153 |
console.log(`[openclaw-hf-setup] Telegram: ${envVars.TELEGRAM_BOT_TOKEN ? "enabled" : "disabled"}`);
|
|
|
|
| 38 |
process.exit(1);
|
| 39 |
}
|
| 40 |
|
| 41 |
+
// ✅ 默认模型
|
| 42 |
const defaultModel =
|
| 43 |
(process.env.OPENCLAW_HF_DEFAULT_MODEL || "").trim() ||
|
| 44 |
"huggingface/deepseek-ai/DeepSeek-R1";
|
|
|
|
| 53 |
TELEGRAM_BOT_TOKEN: process.env.TELEGRAM_BOT_TOKEN?.trim(),
|
| 54 |
};
|
| 55 |
|
| 56 |
+
// TELEGRAM_API_ROOT
|
| 57 |
let telegramApiRoot = (process.env.TELEGRAM_API_ROOT || "https://api.telegram.org").trim();
|
| 58 |
if (telegramApiRoot.endsWith("/bot")) {
|
| 59 |
telegramApiRoot = telegramApiRoot.slice(0, -4);
|
| 60 |
}
|
| 61 |
telegramApiRoot = telegramApiRoot.replace(/\/$/, "");
|
| 62 |
|
| 63 |
+
// ====================== proxies(修复 bug) ======================
|
| 64 |
+
const envProxies = parseList(process.env.OPENCLAW_GATEWAY_TRUSTED_PROXIES);
|
| 65 |
+
|
| 66 |
+
const trustedProxies = envProxies.length > 0 ? envProxies : [
|
| 67 |
+
"10.16.4.123",
|
| 68 |
+
"10.16.34.155",
|
| 69 |
+
"10.20.1.9",
|
| 70 |
+
"10.20.1.222",
|
| 71 |
+
"10.20.26.157",
|
| 72 |
+
"10.20.31.87"
|
| 73 |
+
];
|
| 74 |
|
| 75 |
// ====================== 加载已有配置 ======================
|
| 76 |
let config = {};
|
|
|
|
| 85 |
// ====================== Gateway ======================
|
| 86 |
config.gateway = config.gateway || {};
|
| 87 |
|
| 88 |
+
// Auth
|
| 89 |
if (gatewayToken) {
|
| 90 |
config.gateway.auth = {
|
| 91 |
mode: "token",
|
|
|
|
| 98 |
};
|
| 99 |
}
|
| 100 |
|
| 101 |
+
// UI
|
| 102 |
config.gateway.controlUi = config.gateway.controlUi || {};
|
| 103 |
config.gateway.controlUi.dangerouslyDisableDeviceAuth = true;
|
| 104 |
|
| 105 |
+
// ====================== ✅ 关键修复:allowedOrigins ======================
|
| 106 |
+
const allowedOriginsEnv = parseList(process.env.OPENCLAW_CONTROL_UI_ALLOWED_ORIGINS);
|
| 107 |
+
|
| 108 |
+
if (allowedOriginsEnv.length > 0) {
|
| 109 |
+
config.gateway.controlUi.allowedOrigins = allowedOriginsEnv;
|
| 110 |
+
} else {
|
| 111 |
+
// HF Spaces 必须,否则 gateway 启动失败
|
| 112 |
+
config.gateway.controlUi.allowedOrigins = ["*"];
|
| 113 |
+
}
|
| 114 |
|
| 115 |
+
// ====================== proxies ======================
|
| 116 |
config.gateway.trustedProxies = trustedProxies;
|
| 117 |
|
| 118 |
// ====================== Agents ======================
|
|
|
|
| 160 |
console.log(`[openclaw-hf-setup] Auth: ${gatewayToken ? "token" : "password"}`);
|
| 161 |
console.log(`[openclaw-hf-setup] Model: ${defaultModel}`);
|
| 162 |
console.log(`[openclaw-hf-setup] Proxies: ${trustedProxies.length}`);
|
| 163 |
+
console.log(`[openclaw-hf-setup] Origins: ${config.gateway.controlUi.allowedOrigins.join(",")}`);
|
| 164 |
console.log(`[openclaw-hf-setup] Telegram: ${envVars.TELEGRAM_BOT_TOKEN ? "enabled" : "disabled"}`);
|