# Full Configuration Example
# This file demonstrates all available configuration options

# Global application settings
global:
  # Working directory for storing data and results
  workspace: "./data"
  # Maximum number of times a task can be requeued after failure
  max_retries_requeued: 3
  # Optional HTTP proxy for all outbound HTTP requests. Supports http, https and socks5
  # Example: "http://127.0.0.1:7890" or "socks5://127.0.0.1:1080"
  proxy: ""
  # GitHub credentials configuration
  github_credentials:
    # GitHub session tokens (recommended for higher rate limits)
    sessions:
      - "your_github_session_here"
    # GitHub API tokens (optional, lower rate limits)
    tokens:
      - "your_github_token_here"
    # Load balancing strategy: round_robin or random
    strategy: "round_robin"
  # User-Agent list for web requests (rotated automatically)
  user_agents:
    - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
    - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
    - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"

# Pipeline stage configuration
pipeline:
  # Number of threads for each stage
  threads:
    search: 1 # Search stage threads (keep low due to rate limits)
    gather: 8 # Acquisition stage threads
    check: 4 # Validation stage threads
    inspect: 2 # API capability inspection threads
  # Queue sizes for each stage
  queue_sizes:
    search: 100000 # Search results queue
    gather: 200000 # Acquisition tasks queue
    check: 500000 # Validation tasks queue
    inspect: 1000000 # API capability inspection tasks queue

# System monitoring configuration
monitoring:
  # Monitoring update interval in seconds
  update_interval: 2.0
  # Error rate threshold (0.0 to 1.0)
  error_threshold: 0.1
  # Queue size warning threshold
  queue_threshold: 1000
  # Memory usage threshold in bytes (1GB)
  memory_threshold: 1073741824
  # Response time threshold in seconds
  response_threshold: 5.0

# Display configuration for different contexts
display:
  contexts:
    # System status display settings
    system:
      standard:
        title: "System Status"
        show_workers: true
        show_alerts: true
        show_performance: false
        show_newline_prefix: false
        width: 80
        max_alerts_per_level: 3
      compact:
        title: "System Status"
        show_workers: false
        show_alerts: false
        show_performance: false
        show_newline_prefix: false
        width: 80
        max_alerts_per_level: 3
      detailed:
        title: "Detailed System Status"
        show_workers: true
        show_alerts: true
        show_performance: true
        show_newline_prefix: true
        width: 80
        max_alerts_per_level: 3
    # Monitoring display settings
    monitoring:
      standard:
        title: "Pipeline Monitoring"
        show_workers: true
        show_alerts: true
        show_performance: true
        show_newline_prefix: false
        width: 80
        max_alerts_per_level: 3
      detailed:
        title: "Detailed Pipeline Monitoring"
        show_workers: true
        show_alerts: true
        show_performance: true
        show_newline_prefix: true
        width: 80
        max_alerts_per_level: 3
    # Task manager display settings
    task:
      standard:
        title: "Task Manager Status"
        show_workers: true
        show_alerts: false
        show_performance: false
        show_newline_prefix: false
        width: 80
        max_alerts_per_level: 3
      compact:
        title: "Task Manager Status"
        show_workers: false
        show_alerts: false
        show_performance: false
        show_newline_prefix: false
        width: 80
        max_alerts_per_level: 3
    # Application status display settings
    application:
      standard:
        title: "Application Status"
        show_workers: false
        show_alerts: true
        show_performance: false
        show_newline_prefix: false
        width: 80
        max_alerts_per_level: 3
      detailed:
        title: "Detailed Application Status"
        show_workers: true
        show_alerts: true
        show_performance: true
        show_newline_prefix: false
        width: 80
        max_alerts_per_level: 3
    # Main status display settings
    main:
      standard:
        title: "Pipeline Status"
        show_workers: true
        show_alerts: false
        show_performance: false
        show_newline_prefix: false
        width: 80
        max_alerts_per_level: 3

# Data persistence configuration
persistence:
  # Batch size for saving results
  batch_size: 50
  # Result save interval in seconds
  save_interval: 30
  # Queue state save interval in seconds
  queue_interval: 60
  # Periodic snapshot interval in seconds
  snapshot_interval: 300
  # Auto restore state on startup
  auto_restore: true
  # Shutdown timeout in seconds
  shutdown_timeout: 30
  # Output format, support txt or ndjson
  format: txt

# Dynamic worker manager configuration
worker:
  # Enable/disable dynamic worker management
  enabled: false
  # Minimum number of worker threads
  min_workers: 1
  # Maximum number of worker threads
  max_workers: 10
  # Target queue size for auto-scaling
  target_queue_size: 100
  # Thread pool adjustment interval in seconds
  adjustment_interval: 5.0
  # Queue size threshold for scaling up (0.0-1.0)
  scale_up_threshold: 0.8
  # Queue size threshold for scaling down (0.0-1.0)
  scale_down_threshold: 0.2
  # Enable worker adjustment recommendation logging
  log_recommendations: true

# Global rate limiting configuration
ratelimits:
  # GitHub API rate limits
  github_api:
    # Base rate in requests per second
    base_rate: 0.15
    # Maximum burst size
    burst_limit: 3
    # Enable adaptive rate limiting
    adaptive: true
  # GitHub Web scraping rate limits
  github_web:
    # Base rate in requests per second
    base_rate: 0.5
    # Maximum burst size
    burst_limit: 2
    # Enable adaptive rate limiting
    adaptive: true

# Provider task configurations
tasks:
  - name: openai
    enabled: true
    provider_type: openai # or openai_like
    use_api: false
    stages:
      search: true
      gather: true
      check: true
      inspect: true
    api:
      base_url: https://api.openai.com
      completion_path: /v1/chat/completions
      model_path: /v1/models
      default_model: gpt-4o-mini
      auth_key: Authorization
      extra_headers: {}
      api_version: ""
      timeout: 30
      retries: 3
    patterns:
      key_pattern: sk(?:-proj)?-[a-zA-Z0-9]{20}T3BlbkFJ[a-zA-Z0-9]{20}
      address_pattern: ""
      endpoint_pattern: ""
      model_pattern: ""
    conditions:
      - query: '"T3BlbkFJ"'
    rate_limit:
      base_rate: 1.0
      burst_limit: 5
      adaptive: true
      backoff_factor: 0.5
      recovery_factor: 1.1
      max_rate_multiplier: 2.0
      min_rate_multiplier: 0.1
    storage:
      directory: ""
      plan: ""
