Spaces:
Running
Running
chore: update startup script configuration for HuggingClip environment
Browse files
start.sh
CHANGED
|
@@ -292,13 +292,37 @@ cleanup() {
|
|
| 292 |
}
|
| 293 |
trap cleanup SIGTERM SIGINT
|
| 294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
# ββ Codex API key config βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 296 |
-
# Codex default auth mode is "chatgpt" (OAuth). Setting forced_login_method="api"
|
| 297 |
-
# makes it read OPENAI_API_KEY from env instead of prompting for browser login.
|
| 298 |
if [ -n "${OPENAI_API_KEY:-}" ]; then
|
| 299 |
mkdir -p /home/paperclip/.codex
|
| 300 |
-
cat > /home/paperclip/.codex/config.toml <<
|
| 301 |
forced_login_method = "api"
|
|
|
|
|
|
|
|
|
|
| 302 |
TOMLEOF
|
| 303 |
chmod 600 /home/paperclip/.codex/config.toml
|
| 304 |
chown -R paperclip:paperclip /home/paperclip/.codex
|
|
|
|
| 292 |
}
|
| 293 |
trap cleanup SIGTERM SIGINT
|
| 294 |
|
| 295 |
+
# ββ Claude Code credentials ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 296 |
+
# ANTHROPIC_AUTH_TOKEN may not reach the claude subprocess if Paperclip spawns
|
| 297 |
+
# with a restricted env. Writing ~/.claude/.credentials.json bypasses that β
|
| 298 |
+
# Claude Code reads OAuth tokens directly from the filesystem.
|
| 299 |
+
if [ -n "${ANTHROPIC_AUTH_TOKEN:-}" ]; then
|
| 300 |
+
mkdir -p /home/paperclip/.claude
|
| 301 |
+
python3 -c "
|
| 302 |
+
import json, os
|
| 303 |
+
creds = {
|
| 304 |
+
'claudeAiOauth': {
|
| 305 |
+
'accessToken': os.environ['ANTHROPIC_AUTH_TOKEN'],
|
| 306 |
+
'refreshToken': '',
|
| 307 |
+
'expiresAt': 9999999999999,
|
| 308 |
+
'scopes': ['user:inference']
|
| 309 |
+
}
|
| 310 |
+
}
|
| 311 |
+
with open('/home/paperclip/.claude/.credentials.json', 'w') as f:
|
| 312 |
+
json.dump(creds, f)
|
| 313 |
+
"
|
| 314 |
+
chmod 600 /home/paperclip/.claude/.credentials.json
|
| 315 |
+
chown -R paperclip:paperclip /home/paperclip/.claude
|
| 316 |
+
fi
|
| 317 |
+
|
| 318 |
# ββ Codex API key config βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
| 319 |
if [ -n "${OPENAI_API_KEY:-}" ]; then
|
| 320 |
mkdir -p /home/paperclip/.codex
|
| 321 |
+
cat > /home/paperclip/.codex/config.toml <<TOMLEOF
|
| 322 |
forced_login_method = "api"
|
| 323 |
+
|
| 324 |
+
[model_providers.openai]
|
| 325 |
+
experimental_bearer_token = "${OPENAI_API_KEY}"
|
| 326 |
TOMLEOF
|
| 327 |
chmod 600 /home/paperclip/.codex/config.toml
|
| 328 |
chown -R paperclip:paperclip /home/paperclip/.codex
|