8900 commited on
Commit
df97fbd
ยท
verified ยท
1 Parent(s): e0711a9

Update setup-hf-config.mjs

Browse files
Files changed (1) hide show
  1. setup-hf-config.mjs +30 -23
setup-hf-config.mjs CHANGED
@@ -8,7 +8,8 @@ var CONFIG_PATH = path.join(STATE_DIR, "openclaw.json");
8
  var SPACE_HOST = (process.env.SPACE_HOST || "").trim();
9
 
10
  console.log("[setup] Startingโ€ฆ HOME=" + HOME);
11
- console.log("[setup] โš ๏ธ Using OpenAI Codex OAuth (Official Method)");
 
12
 
13
  // โ€“ helpers โ€“
14
  function parseList(val) {
@@ -25,10 +26,10 @@ console.error("[setup] FATAL: set OPENCLAW_GATEWAY_TOKEN or OPENCLAW_GATEWAY_PAS
25
  process.exit(0);
26
  }
27
 
28
- // โ€“ default model (using OpenAI Codex for ChatGPT subscription) โ€“
29
  var defaultModel = envStr("OPENCLAW_HF_DEFAULT_MODEL") || "openai-codex/gpt-5.3-codex";
30
 
31
- // โ€“ dynamic provider key detection (for traditional API keys only) โ€“
32
  var EXCLUDE_PREFIXES = [
33
  "OPENCLAW_", "SPACE_", "SYSTEM_", "HF_",
34
  "NODE_", "PATH", "HOME", "USER", "PWD", "LANG", "LC_",
@@ -68,7 +69,7 @@ var trustedProxies = envProxies.length>0 ? envProxies : [
68
  "10.20.0.1","172.17.0.1"
69
  ];
70
 
71
- // โ€“ build config with proper OAuth support โ€“
72
  var config = {
73
  gateway: {
74
  auth: gatewayToken ? { mode:"token", token:gatewayToken } : { mode:"password", password:gatewayPassword },
@@ -79,11 +80,9 @@ agents: {
79
  defaults:{
80
  model: {
81
  primary: defaultModel,
82
- // Fallback to other free/cheap models if Codex is rate limited
83
  fallbacks: [
84
  "google/gemini-2.0-flash",
85
- "openrouter/auto",
86
- "anthropic/claude-3-haiku"
87
  ]
88
  }
89
  }
@@ -91,7 +90,7 @@ fallbacks: [
91
  env: { vars:{} }
92
  };
93
 
94
- // Add traditional API keys (if user has them)
95
  providerKeys.forEach(pk=>{
96
  config.env.vars[pk] = envStr(pk);
97
  });
@@ -121,9 +120,6 @@ req.write(data);
121
  req.end();
122
  });
123
  if(r && r.ok) console.log("[setup] Telegram: webhook registered -> "+webhookUrl);
124
- else {
125
- console.log("[setup] Telegram: auto-registration failed (HF outbound blocked)");
126
- }
127
  }
128
 
129
  config.channels = { telegram:{ enabled:true, accounts:{ main:{ botToken:token, apiRoot:"https://api.telegram.org" } } } };
@@ -142,20 +138,31 @@ fs.writeFileSync(CONFIG_PATH, JSON.stringify(config,null,2),"utf-8");
142
  console.log("[setup] Done! Configuration created.");
143
  console.log("[setup] auth = "+(gatewayToken?"token":"password"));
144
  console.log("[setup] default model = "+defaultModel);
145
- console.log("[setup] fallback models= 3");
146
  console.log("[setup] config = "+CONFIG_PATH);
147
  console.log("");
148
- console.log("[setup] โœ… OAuth Authentication Required:");
149
- console.log("[setup] This setup uses OpenAI Codex with ChatGPT OAuth (Official)");
150
- console.log("[setup] You need: Active ChatGPT Plus/Pro subscription ($20+/month)");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  console.log("");
152
- console.log("[setup] โš ๏ธ IMPORTANT: Run these commands on HF Space to complete setup:");
153
- console.log("[setup] $ openclaw onboard โ€“auth-choice openai-codex");
154
- console.log("[setup] $ openclaw models set openai-codex/gpt-5.3-codex");
 
 
155
  console.log("");
156
- console.log("[setup] Why OAuth instead of token extraction?");
157
- console.log("[setup] 1. OpenAI officially supports OAuth with third-party tools");
158
- console.log("[setup] 2. Session tokens extracted from browser donโ€™t have API scopes");
159
- console.log("[setup] 3. OAuth provides real, authorized API access");
160
- console.log("[setup] 4. This method is officially recommended and supported");
161
  })().catch(e=>{ console.error("[setup] Fatal: "+e.message); process.exit(0); });
 
8
  var SPACE_HOST = (process.env.SPACE_HOST || "").trim();
9
 
10
  console.log("[setup] Startingโ€ฆ HOME=" + HOME);
11
+ console.log("[setup] ๐ŸŽฏ Setting up OpenClaw with OpenAI Codex OAuth");
12
+ console.log("[setup] (Works with both FREE and PLUS ChatGPT accounts)");
13
 
14
  // โ€“ helpers โ€“
15
  function parseList(val) {
 
26
  process.exit(0);
27
  }
28
 
29
+ // โ€“ default model (ไฝฟ็”จ OpenAI Codex๏ผŒ้œ€่ฆ้€š่ฟ‡ OAuth ๆŽˆๆƒ) โ€“
30
  var defaultModel = envStr("OPENCLAW_HF_DEFAULT_MODEL") || "openai-codex/gpt-5.3-codex";
31
 
32
+ // โ€“ dynamic provider key detection โ€“
33
  var EXCLUDE_PREFIXES = [
34
  "OPENCLAW_", "SPACE_", "SYSTEM_", "HF_",
35
  "NODE_", "PATH", "HOME", "USER", "PWD", "LANG", "LC_",
 
69
  "10.20.0.1","172.17.0.1"
70
  ];
71
 
72
+ // โ€“ build config โ€“
73
  var config = {
74
  gateway: {
75
  auth: gatewayToken ? { mode:"token", token:gatewayToken } : { mode:"password", password:gatewayPassword },
 
80
  defaults:{
81
  model: {
82
  primary: defaultModel,
 
83
  fallbacks: [
84
  "google/gemini-2.0-flash",
85
+ "openrouter/auto"
 
86
  ]
87
  }
88
  }
 
90
  env: { vars:{} }
91
  };
92
 
93
+ // Add API keys
94
  providerKeys.forEach(pk=>{
95
  config.env.vars[pk] = envStr(pk);
96
  });
 
120
  req.end();
121
  });
122
  if(r && r.ok) console.log("[setup] Telegram: webhook registered -> "+webhookUrl);
 
 
 
123
  }
124
 
125
  config.channels = { telegram:{ enabled:true, accounts:{ main:{ botToken:token, apiRoot:"https://api.telegram.org" } } } };
 
138
  console.log("[setup] Done! Configuration created.");
139
  console.log("[setup] auth = "+(gatewayToken?"token":"password"));
140
  console.log("[setup] default model = "+defaultModel);
 
141
  console.log("[setup] config = "+CONFIG_PATH);
142
  console.log("");
143
+ console.log("โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—");
144
+ console.log("โ•‘ โœ… OpenClaw is ready for OAuth login! โ•‘");
145
+ console.log("โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•");
146
+ console.log("");
147
+ console.log("[setup] ๐Ÿ” NEXT STEP - Complete OAuth Authorization:");
148
+ console.log("[setup]");
149
+ console.log("[setup] When OpenClaw starts, it will print an OAuth link in the logs.");
150
+ console.log("[setup] Look for a URL like this in the logs:");
151
+ console.log("[setup] https://auth.openai.com/authorize?client_id=โ€ฆ&redirect_uri=โ€ฆ&code_challenge=โ€ฆ");
152
+ console.log("");
153
+ console.log("[setup] โš ๏ธ INSTRUCTIONS:");
154
+ console.log("[setup] 1๏ธโƒฃ ๅคๅˆถ้‚ฃไธชๅฎŒๆ•ด็š„ URL");
155
+ console.log("[setup] 2๏ธโƒฃ ๅœจๆ–ฐๆต่งˆๅ™จ็ช—ๅฃไธญๆ‰“ๅผ€๏ผˆ็”จไฝ ็š„ๆ‰‹ๆœบไนŸๅฏไปฅ๏ผ‰");
156
+ console.log("[setup] 3๏ธโƒฃ ็”จไฝ ็š„ ChatGPT ่ดฆๅท็™ปๅฝ•๏ผˆๅ…่ดน่ดฆๅทโœ… ๆˆ– Plus โœ… ้ƒฝๅฏไปฅ๏ผ‰");
157
+ console.log("[setup] 4๏ธโƒฃ ็‚นๅ‡ป \"Continue\" ๆˆ– \"Authorize\" ๆŒ‰้’ฎ");
158
+ console.log("[setup] 5๏ธโƒฃ ๆต่งˆๅ™จไผš้‡ๅฎšๅ‘ๅˆฐไธ€ไธช้”™่ฏฏ้กต้ข๏ผˆ่ฟ™ๆ˜ฏๆญฃๅธธ็š„๏ผ๏ผ‰");
159
+ console.log("[setup] 6๏ธโƒฃ ๅคๅˆถ้‡ๅฎšๅ‘ๅŽ็š„ๅฎŒๆ•ด URL๏ผˆๅŒ…ๅซ ?code=โ€ฆ ้ƒจๅˆ†๏ผ‰");
160
+ console.log("[setup] 7๏ธโƒฃ ็ฒ˜่ดดๅˆฐ OpenClaw ็š„ๆ—ฅๅฟ—ๆ็คบไธญๆˆ–ๆ ‡ๅ‡†่พ“ๅ…ฅ");
161
  console.log("");
162
+ console.log("[setup] ๐Ÿ’ก Why this works for FREE accounts:");
163
+ console.log("[setup] - OpenAI supports ChatGPT account OAuth");
164
+ console.log("[setup] - Free account can authenticate and use Codex");
165
+ console.log("[setup] - Just slower/limited than Plus (if you hit limits)");
166
+ console.log("[setup] - No payment required!");
167
  console.log("");
 
 
 
 
 
168
  })().catch(e=>{ console.error("[setup] Fatal: "+e.message); process.exit(0); });