Commit Graph

10 Commits

  • fix(ai,coding-agent): make pi-ai browser-safe and move OAuth runtime exports
    - add browser smoke bundling check to root check + pre-commit
    
    - lazy-load Bedrock provider registration to avoid browser graph traversal
    
    - remove top-level OAuth runtime exports from @mariozechner/pi-ai
    
    - add @mariozechner/pi-ai/oauth subpath export and update coding-agent imports
    
    - move proxy dispatcher init to coding-agent CLI (Node-only)
    
    - document Bedrock/OAuth browser limitations
    
    closes #1814
  • feat(coding-agent): support per-model overrides in models.json
    Add modelOverrides field to provider config that allows customizing
    individual built-in models without replacing the entire provider.
    
    Example:
      {
        "providers": {
          "openrouter": {
            "modelOverrides": {
              "anthropic/claude-sonnet-4": {
                "compat": { "openRouterRouting": { "only": ["amazon-bedrock"] } }
              }
            }
          }
        }
      }
    
    Overrides are deep-merged with built-in model definitions. Supports:
    - name, reasoning, input, contextWindow, maxTokens
    - Partial cost overrides (e.g. only change input cost)
    - headers (merged with existing)
    - compat settings (merged with existing)
    
    Works alongside baseUrl overrides on the same provider.
    
    closes #1062
  • Support shell command execution for API key resolution in models.json (#762)
    * Support shell command execution for API key resolution in models.json
    
    Add ! prefix support to apiKey field in models.json to execute shell commands
    and use stdout as the API key. This allows users to store API keys in secure
    credential managers like macOS Keychain, 1Password, Bitwarden, or HashiCorp Vault.
    
    Example: "apiKey": "!security find-generic-password -ws 'anthropic'"
    
    The apiKey field now supports three formats:
    - !command - executes shell command, uses trimmed stdout
    - ENV_VAR_NAME - uses environment variable value
    - literal - uses value directly
    
    fixes #697
    
    * feat(coding-agent): cache API key command results for process lifetime
    
    Shell commands (! prefix) are now executed once and cached. Environment
    variables and literal values are not cached, so changes are picked up.
    
    Addresses review feedback on #762.
    
    ---------
    
    Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
  • Enhance provider override to support baseUrl-only mode
    Builds on #406 to support simpler proxy use case:
    - Override just baseUrl to route built-in provider through proxy
    - All built-in models preserved, no need to redefine them
    - Full replacement still works when models array is provided
  • Allow models.json to override built-in providers (#406)
    * Allow models.json to override built-in providers
    
    When a provider is defined in models.json with the same name as a
    built-in provider (e.g., 'anthropic', 'google'), the built-in models
    for that provider are completely replaced by the custom definition.
    
    This enables users to:
    - Use custom base URLs (proxies, self-hosted endpoints)
    - Define a subset of models they want available
    - Customize model configurations for built-in providers
    
    Example usage in ~/.pi/agent/models.json:
    {
      "providers": {
        "anthropic": {
          "baseUrl": "https://my-proxy.example.com/v1",
          "apiKey": "ANTHROPIC_API_KEY",
          "api": "anthropic-messages",
          "models": [...]
        }
      }
    }
    
    * Refactor model-registry for readability
    
    - Extract CustomModelsResult type and emptyCustomModelsResult helper
    - Extract loadBuiltInModels method with clear skip logic
    - Simplify loadModels with destructuring and ternary
    - Reduce repetition in error handling paths
    
    * Refactor model-registry tests for readability
    
    - Extract providerConfig() helper to hide irrelevant model fields
    - Extract writeModelsJson() helper for file writing
    - Extract getModelsForProvider() helper for filtering
    - Move modelsJsonPath to beforeEach
    
    Reduces test file from 262 to 130 lines while maintaining same coverage.