Skip to content

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):

  1. ~/.mydeskbot/.env (Local user environment file)
  2. 工作区/.mydeskbot/.env (Workspace MyDeskBot environment file)
  3. 工作区/.env (Workspace environment file)
  4. process.env (System environment variables)

Configuration File Locations

Global Configuration

File PathPurposeDescription
~/.mydeskbot/.envLocal user environment variablesStore API keys and personal settings

Project Configuration

File PathPurposeExample
工作区/.mydeskbot/.envWorkspace-level environment variablesProject-specific settings
工作区/.envWorkspace root environment variablesDatabase connections, etc.

Usage Scenarios

Scenario 1: Configuring AI Model API Keys

Step 1: Add keys to ~/.mydeskbot/.env

bash
# ~/.mydeskbot/.env
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GROQ_API_KEY=gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Step 2: Use secrets template in configuration file

yaml
# ~/.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 .env files, the environment variable name does not need the secrets. prefix; simply use OPENAI_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

bash
# ~/.ssh/config
Host production-server
    HostName 192.168.1.100
    User deploy
    Port 22
    IdentityFile ~/.ssh/id_rsa

Step 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

bash
# 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:11434

System Configuration

bash
# 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

bash
# Ensure .gitignore contains the following
.env
.env.*
.env.local
!.env.example

2. Use .env.example as Template

bash
# .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_here

3. Use Explicit Naming Conventions

bash
# Good naming
OPENAI_API_KEY=sk-proj-xxx
ANTHROPIC_API_KEY=sk-ant-xxx

# Avoid using
API_KEY=...
TOKEN=...
PASSWORD=...

4. Environment Separation

bash
# 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:

  1. Check file paths are correct
bash
cat ~/.mydeskbot/.env
cat `工作区/.env`
  1. Confirm environment variable format is correct (no extra spaces or quotes)
bash
# Correct
OPENAI_API_KEY=sk-proj-xxx

# Incorrect
OPENAI_API_KEY = sk-proj-xxx
OPENAI_API_KEY="sk-proj-xxx"
  1. 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:

  1. ~/.mydeskbot/.env
  2. 工作区/.mydeskbot/.env
  3. 工作区/.env
  4. process.env

Appendix: Complete Configuration Examples

Complete ~/.mydeskbot/.env Example

bash
# 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=1

Complete Project .env Example

bash
# Add project-specific environment variables here if needed

By using environment variables appropriately, you can securely manage sensitive information and easily switch configurations between different environments.