feat(security): update role wrapper to support CLAUDE_API_KEY and OPENAI_API_KEY
This commit is contained in:
@@ -10,17 +10,23 @@ if [ ! -f "$ENV_FILE" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2. Extract API Key (securely)
|
||||
# 2. Extract API Keys (securely)
|
||||
# We use grep/sed to avoid sourcing the entire file (security best practice)
|
||||
API_KEY=$(grep "^OPENROUTER_API_KEY=" "$ENV_FILE" | cut -d'=' -f2-)
|
||||
OPENROUTER_KEY=$(grep "^OPENROUTER_API_KEY=" "$ENV_FILE" | cut -d'=' -f2-)
|
||||
CLAUDE_KEY=$(grep "^CLAUDE_API_KEY=" "$ENV_FILE" | cut -d'=' -f2-)
|
||||
OPENAI_KEY=$(grep "^OPENAI_API_KEY=" "$ENV_FILE" | cut -d'=' -f2-)
|
||||
|
||||
if [ -z "$API_KEY" ]; then
|
||||
echo "❌ Error: OPENROUTER_API_KEY not found in config."
|
||||
exit 1
|
||||
if [ -z "$OPENROUTER_KEY" ] && [ -z "$CLAUDE_KEY" ] && [ -z "$OPENAI_KEY" ]; then
|
||||
echo "❌ Error: No API keys (OpenRouter, Claude, or OpenAI) found in config."
|
||||
# We don't exit strictly if one is missing, but warn if ALL are missing.
|
||||
# However, roles might depend on specific ones.
|
||||
# For now, we proceed if at least one is there or just export what we have.
|
||||
fi
|
||||
|
||||
# 3. Export for the sub-process
|
||||
export OPENROUTER_API_KEY="$API_KEY"
|
||||
[ -n "$OPENROUTER_KEY" ] && export OPENROUTER_API_KEY="$OPENROUTER_KEY"
|
||||
[ -n "$CLAUDE_KEY" ] && export CLAUDE_API_KEY="$CLAUDE_KEY"
|
||||
[ -n "$OPENAI_KEY" ] && export OPENAI_API_KEY="$OPENAI_KEY"
|
||||
|
||||
# 4. Determine the target script
|
||||
ROLE_SCRIPT="$1"
|
||||
|
||||
Reference in New Issue
Block a user