8900 commited on
Update setup-hf-config.mjs
Browse files- setup-hf-config.mjs +28 -32
setup-hf-config.mjs
CHANGED
|
@@ -35,18 +35,10 @@ var googleKey = env("GOOGLE_API_KEY") || env("GEMINI_API_KEY");
|
|
| 35 |
var groqKey = env("GROQ_API_KEY");
|
| 36 |
var openrouterKey = env("OPENROUTER_API_KEY");
|
| 37 |
var telegramToken = env("TELEGRAM_BOT_TOKEN");
|
| 38 |
-
|
| 39 |
-
// -- Telegram reverse proxy --
|
| 40 |
-
// Set TELEGRAM_API_ROOT in Space Variables to your proxy base URL.
|
| 41 |
-
// Format: https://your-proxy.example.com (no trailing slash, no /bot path)
|
| 42 |
-
// Example providers:
|
| 43 |
-
// - https://api.telegram.org (official, default)
|
| 44 |
-
// - https://telegram.your-domain.com (self-hosted gramjs/telegram-bot-api mirror)
|
| 45 |
-
// If not set, falls back to official Telegram API (will fail on HF free tier).
|
| 46 |
-
var telegramApiRoot = env("TELEGRAM_API_ROOT");
|
| 47 |
|
| 48 |
var DEFAULT_HF_PROXY_IPS = [
|
| 49 |
-
"10.16.4.123", "10.16.7.92",
|
| 50 |
"10.16.34.155", "10.16.43.133",
|
| 51 |
"10.20.1.9", "10.20.1.222",
|
| 52 |
"10.20.26.157", "10.20.31.87",
|
|
@@ -84,6 +76,7 @@ if (useTokenAuth || usePasswordAuth) {
|
|
| 84 |
}
|
| 85 |
}
|
| 86 |
|
|
|
|
| 87 |
if (!config.gateway.controlUi) config.gateway.controlUi = {};
|
| 88 |
config.gateway.controlUi.dangerouslyDisableDeviceAuth = true;
|
| 89 |
config.gateway.controlUi.allowInsecureAuth = true;
|
|
@@ -94,25 +87,29 @@ if (allowedOrigins.length > 0) {
|
|
| 94 |
|
| 95 |
config.gateway.trustedProxies = trustedProxies;
|
| 96 |
|
| 97 |
-
// -- providers --
|
| 98 |
if (!config.providers) config.providers = {};
|
| 99 |
|
| 100 |
if (anthropicKey) {
|
| 101 |
if (!config.providers.anthropic) config.providers.anthropic = {};
|
| 102 |
config.providers.anthropic.apiKey = anthropicKey;
|
| 103 |
}
|
|
|
|
| 104 |
if (googleKey) {
|
| 105 |
if (!config.providers.gemini) config.providers.gemini = {};
|
| 106 |
config.providers.gemini.apiKey = googleKey;
|
| 107 |
}
|
|
|
|
| 108 |
if (groqKey) {
|
| 109 |
if (!config.providers.groq) config.providers.groq = {};
|
| 110 |
config.providers.groq.apiKey = groqKey;
|
| 111 |
}
|
|
|
|
| 112 |
if (openaiKey) {
|
| 113 |
if (!config.providers.openai) config.providers.openai = {};
|
| 114 |
config.providers.openai.apiKey = openaiKey;
|
| 115 |
}
|
|
|
|
| 116 |
if (openrouterKey) {
|
| 117 |
if (!config.providers.openrouter) config.providers.openrouter = {};
|
| 118 |
config.providers.openrouter.apiKey = openrouterKey;
|
|
@@ -136,26 +133,17 @@ if (fallbacks.length > 0) {
|
|
| 136 |
config.agents.defaults.model.fallbacks = fallbacks;
|
| 137 |
}
|
| 138 |
|
| 139 |
-
// -- Telegram
|
| 140 |
if (!config.channels) config.channels = {};
|
| 141 |
if (!config.channels.telegram) config.channels.telegram = {};
|
| 142 |
|
| 143 |
-
if (telegramToken) {
|
|
|
|
|
|
|
| 144 |
config.channels.telegram.enabled = true;
|
| 145 |
if (!config.channels.telegram.accounts) config.channels.telegram.accounts = {};
|
| 146 |
if (!config.channels.telegram.accounts.main) config.channels.telegram.accounts.main = {};
|
| 147 |
-
|
| 148 |
config.channels.telegram.accounts.main.botToken = telegramToken;
|
| 149 |
-
|
| 150 |
-
if (telegramApiRoot) {
|
| 151 |
-
config.channels.telegram.accounts.main.apiRoot = telegramApiRoot;
|
| 152 |
-
console.log("[openclaw-hf-setup-v2] Telegram proxy: " + telegramApiRoot);
|
| 153 |
-
} else {
|
| 154 |
-
console.warn("[openclaw-hf-setup-v2] TELEGRAM_API_ROOT not set." +
|
| 155 |
-
" Telegram will use official API and may fail on HF free tier.");
|
| 156 |
-
}
|
| 157 |
-
} else {
|
| 158 |
-
config.channels.telegram.enabled = false;
|
| 159 |
}
|
| 160 |
|
| 161 |
// -- write --
|
|
@@ -170,14 +158,22 @@ try {
|
|
| 170 |
// -- summary --
|
| 171 |
var authKind = useTokenAuth ? "token" : (usePasswordAuth ? "password" : "none");
|
| 172 |
var active = [];
|
| 173 |
-
if (anthropicKey)
|
| 174 |
-
if (googleKey)
|
| 175 |
-
if (groqKey)
|
| 176 |
-
if (openaiKey)
|
| 177 |
-
if (openrouterKey)
|
| 178 |
-
if (telegramToken) active.push("telegram"
|
| 179 |
-
|
| 180 |
-
console.log("[openclaw-hf-setup
|
| 181 |
" providers=[" + active.join(",") + "]" +
|
| 182 |
" proxies=" + trustedProxies.length +
|
| 183 |
" model=" + defaultModel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
var groqKey = env("GROQ_API_KEY");
|
| 36 |
var openrouterKey = env("OPENROUTER_API_KEY");
|
| 37 |
var telegramToken = env("TELEGRAM_BOT_TOKEN");
|
| 38 |
+
var disableTelegram = env("DISABLE_TELEGRAM") === "1";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
var DEFAULT_HF_PROXY_IPS = [
|
| 41 |
+
"10.16.4.123", "10.16.7.92", "10.16.18.232",
|
| 42 |
"10.16.34.155", "10.16.43.133",
|
| 43 |
"10.20.1.9", "10.20.1.222",
|
| 44 |
"10.20.26.157", "10.20.31.87",
|
|
|
|
| 76 |
}
|
| 77 |
}
|
| 78 |
|
| 79 |
+
// -- gateway controlUi --
|
| 80 |
if (!config.gateway.controlUi) config.gateway.controlUi = {};
|
| 81 |
config.gateway.controlUi.dangerouslyDisableDeviceAuth = true;
|
| 82 |
config.gateway.controlUi.allowInsecureAuth = true;
|
|
|
|
| 87 |
|
| 88 |
config.gateway.trustedProxies = trustedProxies;
|
| 89 |
|
| 90 |
+
// -- providers: write API keys so gateway can read them --
|
| 91 |
if (!config.providers) config.providers = {};
|
| 92 |
|
| 93 |
if (anthropicKey) {
|
| 94 |
if (!config.providers.anthropic) config.providers.anthropic = {};
|
| 95 |
config.providers.anthropic.apiKey = anthropicKey;
|
| 96 |
}
|
| 97 |
+
|
| 98 |
if (googleKey) {
|
| 99 |
if (!config.providers.gemini) config.providers.gemini = {};
|
| 100 |
config.providers.gemini.apiKey = googleKey;
|
| 101 |
}
|
| 102 |
+
|
| 103 |
if (groqKey) {
|
| 104 |
if (!config.providers.groq) config.providers.groq = {};
|
| 105 |
config.providers.groq.apiKey = groqKey;
|
| 106 |
}
|
| 107 |
+
|
| 108 |
if (openaiKey) {
|
| 109 |
if (!config.providers.openai) config.providers.openai = {};
|
| 110 |
config.providers.openai.apiKey = openaiKey;
|
| 111 |
}
|
| 112 |
+
|
| 113 |
if (openrouterKey) {
|
| 114 |
if (!config.providers.openrouter) config.providers.openrouter = {};
|
| 115 |
config.providers.openrouter.apiKey = openrouterKey;
|
|
|
|
| 133 |
config.agents.defaults.model.fallbacks = fallbacks;
|
| 134 |
}
|
| 135 |
|
| 136 |
+
// -- Telegram --
|
| 137 |
if (!config.channels) config.channels = {};
|
| 138 |
if (!config.channels.telegram) config.channels.telegram = {};
|
| 139 |
|
| 140 |
+
if (disableTelegram || !telegramToken) {
|
| 141 |
+
config.channels.telegram.enabled = false;
|
| 142 |
+
} else {
|
| 143 |
config.channels.telegram.enabled = true;
|
| 144 |
if (!config.channels.telegram.accounts) config.channels.telegram.accounts = {};
|
| 145 |
if (!config.channels.telegram.accounts.main) config.channels.telegram.accounts.main = {};
|
|
|
|
| 146 |
config.channels.telegram.accounts.main.botToken = telegramToken;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
}
|
| 148 |
|
| 149 |
// -- write --
|
|
|
|
| 158 |
// -- summary --
|
| 159 |
var authKind = useTokenAuth ? "token" : (usePasswordAuth ? "password" : "none");
|
| 160 |
var active = [];
|
| 161 |
+
if (anthropicKey) active.push("anthropic");
|
| 162 |
+
if (googleKey) active.push("gemini");
|
| 163 |
+
if (groqKey) active.push("groq");
|
| 164 |
+
if (openaiKey) active.push("openai");
|
| 165 |
+
if (openrouterKey) active.push("openrouter");
|
| 166 |
+
if (telegramToken && !disableTelegram) active.push("telegram");
|
| 167 |
+
|
| 168 |
+
console.log("[openclaw-hf-setup] auth=" + authKind +
|
| 169 |
" providers=[" + active.join(",") + "]" +
|
| 170 |
" proxies=" + trustedProxies.length +
|
| 171 |
" model=" + defaultModel);
|
| 172 |
+
|
| 173 |
+
if (authKind === "none") {
|
| 174 |
+
console.warn("[openclaw-hf-setup] WARNING: set OPENCLAW_GATEWAY_TOKEN in Secrets.");
|
| 175 |
+
}
|
| 176 |
+
if (telegramToken && !disableTelegram) {
|
| 177 |
+
console.warn("[openclaw-hf-setup] NOTE: Telegram needs outbound access to api.telegram.org." +
|
| 178 |
+
" If errors appear, set DISABLE_TELEGRAM=1 in Space Variables.");
|
| 179 |
+
}
|