Environment Variables Configuration
MyDeskBot provides a flexible and secure configuration management system through environment variables, supporting various scenarios for local development.
Environment Variable Priority
MyDeskBot searches for environment variables in following priority order (from highest to lowest):
~/.mydeskbot/.env(Local user environment file)工作区/.mydeskbot/.env(Workspace MyDeskBot environment file)工作区/.env(Workspace environment file)process.env(System environment variables)
Configuration File Locations
Global Configuration
| File Path | Purpose | Description |
|---|---|---|
~/.mydeskbot/.env | Local user environment variables | Store API keys and personal settings |
Project Configuration
| File Path | Purpose | Example |
|---|---|---|
工作区/.mydeskbot/.env | Workspace-level environment variables | Project-specific settings |
工作区/.env | Workspace root environment variables | Database connections, etc. |
Usage Scenarios
Scenario 1: Configuring AI Model API Keys
Step 1: Add keys to ~/.mydeskbot/.env
# ~/.mydeskbot/.env
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GROQ_API_KEY=gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxStep 2: Use secrets template in configuration file
# ~/.mydeskbot/config.yaml or `工作区/.mydeskbot/config.yaml`
models:
- name: GPT-4
provider: openai
model: gpt-4
apiKey: ${{ secrets.OPENAI_API_KEY }}
- name: Claude 3 Sonnet
provider: anthropic
model: claude-3-sonnet-20240229
apiKey: ${{ secrets.ANTHROPIC_API_KEY }}Note:
secrets.is a prefix identifier in the configuration file, indicating to MyDeskBot that this is a secret to be read from environment variables. In.envfiles, the environment variable name does not need thesecrets.prefix; simply useOPENAI_API_KEY.
Step 3: Reload configuration to use configured models
Scenario 2: Configuring SSH Server Connections
Note: SSH configuration is primarily done through ~/.ssh/config. MyDeskBot's remoteCommandExecution tool only uses process.env.SSH_AUTH_SOCK for SSH agent authentication when no password or key path is specified.
Step 1: Configure servers in ~/.ssh/config
# ~/.ssh/config
Host production-server
HostName 192.168.1.100
User deploy
Port 22
IdentityFile ~/.ssh/id_rsaStep 2: Manage servers using natural language
"Check system status and running services on production-server."
The tool will automatically use your SSH configuration, including SSH_AUTH_SOCK environment variable if needed.
Common Environment Variables
AI Model Providers
# OpenAI
OPENAI_API_KEY=sk-proj-...
# Anthropic
ANTHROPIC_API_KEY=sk-ant-...
# Groq
GROQ_API_KEY=gsk_...
# Google
GOOGLE_API_KEY=AIzaSy...
# Cohere
COHERE_API_KEY=...
# Together AI
TOGETHER_API_KEY=...
# Hugging Face
HUGGINGFACE_API_KEY=hf_...
# Ollama (local)
OLLAMA_API_BASE=http://localhost:11434System Configuration
# MyDeskBot system variables
CONTINUE_GLOBAL_DIR=/path/to/custom/global/dir
CONTROL_PLANE_ENV=local|staging|test|production
NODE_ENV=development|production|test
CONTINUE_DEVELOPMENT=true|false
# Debugging
VERBOSE_FETCH=1
DEBUG=*Security Best Practices
1. Never Commit .env Files
# Ensure .gitignore contains the following
.env
.env.*
.env.local
!.env.example2. Use .env.example as Template
# .env.example
# Copy this file to .env and fill in actual values
# AI Models
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here3. Use Explicit Naming Conventions
# Good naming
OPENAI_API_KEY=sk-proj-xxx
ANTHROPIC_API_KEY=sk-ant-xxx
# Avoid using
API_KEY=...
TOKEN=...
PASSWORD=...4. Environment Separation
# Development environment uses local models
# ~/.mydeskbot/.env (development)
OLLAMA_API_BASE=http://localhost:11434
# Production environment uses cloud services
# ~/.mydeskbot/.env (production)
ANTHROPIC_API_KEY=sk-ant-...Troubleshooting
Issue 1: Environment Variables Not Taking Effect
Symptoms: MyDeskBot prompts that API key cannot be found
Solutions:
- Check file paths are correct
cat ~/.mydeskbot/.env
cat `工作区/.env`- Confirm environment variable format is correct (no extra spaces or quotes)
# Correct
OPENAI_API_KEY=sk-proj-xxx
# Incorrect
OPENAI_API_KEY = sk-proj-xxx
OPENAI_API_KEY="sk-proj-xxx"- Reload configuration to make changes take effect
Issue 2: Unclear Key Source
Symptoms: Not sure which environment variable value is being used
Solutions:
Check environment variable priority and confirm current key source:
~/.mydeskbot/.env工作区/.mydeskbot/.env工作区/.envprocess.env
Appendix: Complete Configuration Examples
Complete ~/.mydeskbot/.env Example
# MyDeskBot system configuration
CONTINUE_GLOBAL_DIR=/Users/username/.mydeskbot
NODE_ENV=development
# AI model API keys
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GROQ_API_KEY=gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Local Ollama
OLLAMA_API_BASE=http://localhost:11434
# Debugging
VERBOSE_FETCH=1Complete Project .env Example
# Add project-specific environment variables here if neededBy using environment variables appropriately, you can securely manage sensitive information and easily switch configurations between different environments.