Skip to content

Claude/custom provider connection 011o7 p9 an2oat gcc hyj n8msk - #4652

Closed
zrmzur24 wants to merge 3 commits into
anomalyco:devfrom
zrmzur24:claude/custom-provider-connection-011o7P9AN2oatGCCHyjN8msk
Closed

zrmzur24 wants to merge 3 commits into
anomalyco:devfrom
zrmzur24:claude/custom-provider-connection-011o7P9AN2oatGCCHyjN8msk

Conversation

@zrmzur24

Copy link
Copy Markdown

No description provided.

claude and others added 3 commits November 23, 2025 09:01
…m providers

This commit implements comprehensive corporate networking support for custom AI provider connections:

Features:
- Auto-detection of proxy settings from environment variables and system settings (Windows registry, macOS scutil, Linux gsettings)
- Interactive proxy authentication prompts (browser-like experience)
- Support for custom CA certificate bundles with multiple certificates
- Client certificate authentication (mutual TLS)
- Secure credential caching (in-memory, 1-hour TTL)
- Cross-platform compatibility (Windows, macOS, Linux)

Implementation:
- proxy-detection.ts: Auto-detect proxy from env vars, system settings, and interactive prompts
- proxy-auth.ts: Handle 407 Proxy Auth Required responses with interactive credential prompts
- corporate-fetch.ts: Main integration point combining proxy, TLS, and authentication
- CORPORATE_INTEGRATION_EXAMPLE.md: Integration guide and configuration examples
- CORPORATE_PROXY_FEATURE_SUMMARY.md: Feature overview and usage documentation

Dependencies:
- Added [email protected] for full Node.js-compatible HTTP client with proxy support

Configuration schema extensions (to be integrated):
- proxy: Auto-detect or explicit proxy URL
- proxyAuth: Username/password for proxy authentication
- tls.ca: Single file or array of CA certificate files (supports bundles)
- tls.cert/key: Client certificate for mutual TLS
- tls.rejectUnauthorized: Certificate validation control

Environment variables supported:
- HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY (standard proxy vars)
- NODE_EXTRA_CA_CERTS (standard certificate var)
- Custom vars via {env:VAR} substitution

Next steps:
- Integrate into packages/opencode/src/provider/provider.ts getSDK() function
- Update packages/opencode/src/config/config.ts provider options schema
…er system

This commit completes the integration of corporate networking features into the main provider system.

Changes to config.ts:
- Extended provider options schema to include proxy, proxyAuth, and tls configuration
- Added support for proxy: "auto" | string | false
- Added proxyAuth with username/password (supports {env:VAR} substitution)
- Added tls configuration for CA certificates (single file or array), client certificates, and validation control
- All new options are optional and backward compatible

Changes to provider.ts:
- Modified getSDK() function to detect when corporate networking is needed
- When proxy or tls options are present, uses createCorporateFetch() instead of standard fetch
- Preserves existing timeout-wrapped fetch for providers without corporate networking requirements
- Enables interactive proxy authentication prompts
- Backward compatible with existing provider configurations

Features now available:
✅ Auto-detect proxy from HTTP_PROXY/HTTPS_PROXY environment variables and system settings
✅ Interactive proxy authentication prompts (browser-like experience)
✅ Support for CA certificate bundles with multiple certificates
✅ Client certificate authentication (mutual TLS)
✅ Configurable certificate validation
✅ Full backward compatibility

Usage example:
```jsonc
{
  "provider": {
    "corporate-ai": {
      "npm": "@ai-sdk/openai-compatible",
      "api": "https://ai.company.com/v1",
      "options": {
        "apiKey": "{env:CORPORATE_AI_KEY}",
        "proxy": "auto",
        "tls": {
          "ca": "/etc/ssl/certs/corporate-ca-bundle.crt"
        }
      }
    }
  }
}
```

Related files:
- proxy-detection.ts: Auto-detection logic
- proxy-auth.ts: Interactive authentication
- corporate-fetch.ts: Main integration point
- CORPORATE_INTEGRATION_EXAMPLE.md: Integration guide
- CORPORATE_PROXY_FEATURE_SUMMARY.md: Feature documentation
@zrmzur24 zrmzur24 closed this Nov 23, 2025
@github-actions github-actions Bot mentioned this pull request Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants