-
Notifications
You must be signed in to change notification settings - Fork 234
Add support for custom LLM API providers, allowing users to configure and use alternative LLM backends instead of the default Claude Code settings. #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alfredolopez80
wants to merge
17
commits into
DevAgentForge:main
Choose a base branch
from
alfredolopez80:fix/electron-windows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add provider configuration modal UI for managing custom LLM API providers - Add backend support for providers list, save, delete operations via IPC handlers - Add runner integration to use custom provider environment variables (baseUrl, authToken, models) - Add Sidebar provider selector to switch between default Claude Code and custom providers - Add Zustand store actions for providers state management - Add comprehensive types for LlmProviderConfig, provider events, and client/server event extensions Features: - Configure custom API providers (name, baseUrl, authToken, models per tier) - Select active provider per session via dropdown in Sidebar - Custom providers override default ANTHROPIC_* environment variables - Full CRUD operations for provider configurations Custom Providers documentation added: CUSTOM_PROVIDERS.md
…ture - Resolve merge conflict in runner.ts combining: - Main branch: enhancedEnv, claudeCodePath from util.ts - Feature: custom provider support via getProviderEnv() - Merge order: enhancedEnv first, then custom provider env overrides
- Single instance lock to prevent multiple windows - Window lifecycle handlers with proper cleanup - Polling cleanup on window close - New throttle/debounce utilities for performance - File permissions 0o600 for providers.json Co-Authored-By: Claude <noreply@anthropic.com>
- FASE 2: Increase polling interval to 2000ms for better performance
- FASE 3: Add try-catch error handling in app.ready with dialog alerts
- FASE 4: Create WindowManager singleton class for window lifecycle
- Add app.on("activate") handler for Mac reactivation
- Fix preload path validation in initialization
Co-Authored-By: Claude <noreply@anthropic.com>
- Add include section to tsconfig.json for proper TypeScript compilation - Increase POLLING_INTERVAL from 500ms to 2000ms to reduce CPU usage - Update Makefile with run_dev and run_prod targets for better flexibility - Use NODE_ENV=production with direct electron binary path Co-Authored-By: Claude <noreply@anthropic.com>
- Add include section to tsconfig.json for proper TypeScript compilation - Update Makefile with run_dev and run_prod targets for better flexibility - Use NODE_ENV=production with direct electron binary path Co-Authored-By: Claude <noreply@anthropic.com>
- Add custom LLM providers support - Add URL validation in ProviderModal - Add Electron stability improvements - Add provider-config utilities Co-Authored-By: Claude <noreply@anthropic.com>
- Encrypt auth tokens using Electron nativeSafeStorage - Add decryptSensitiveData and encryptSensitiveData functions - Set restrictive file permissions (0o600) - Mitigate CWE-200 (Exposure of Sensitive Information) Co-Authored-By: Claude <noreply@anthropic.com>
- Add path sanitization to prevent CWE-22 (Path Traversal) - Improve SQL query parameterization - Validate cwd before creating session Co-Authored-By: Claude <noreply@anthropic.com>
- Add .claude/ directory to .gitignore - Add default-providers.ts with MiniMax default provider config - Include envOverrides for default provider settings Co-Authored-By: Claude <noreply@anthropic.com>
## New Modules - settings-manager.ts: Load and validate ~/.claude/settings.json with schema validation - unified-commands.ts: Parse slash commands (/help, /exit, /status, /clear) - unified-task-runner.ts: Task context management with system prompt stacking - orchestrator-agent.ts: Central coordinator for skills, hooks, and commands ## Security Improvements (Codex Audit) - Fix sanitizePath() to properly validate paths without destroying them - Add cwd re-validation in updateSession() and loadSessions() - Add schema validation for settings.json (CWE-20 compliance) - Deep copy in getRawSettings() to prevent mutation - Error handling in processInput() with structured events ## Permission System - Add PermissionMode type (secure/free) to types.ts - Implement permission-based tool execution in runner.ts - Add parseAllowedTools() and isToolAllowed() utilities - Support permissionMode in session creation and IPC handlers ## Architecture - Initialize orchestratorAgent in main.ts startup - Export initializeHandlers() for proper initialization order - Add database migration for permission_mode column Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
6 tasks
PHASE 1: API Key Security (Token Vault Architecture) - Add SafeProviderConfig type (no tokens in IPC) - Add ProviderSavePayload for secure token handling - Tokens NEVER leave main process except to subprocess - Add loadProvidersSafe(), saveProviderFromPayload(), getProviderEnvById() - Update runner.ts to use providerEnv instead of provider object - Fix safeStorage import in provider-config.ts PHASE 2: Theme System (Light/Dark Mode) - Add ThemeContext with localStorage persistence - Add ThemeSettings modal for color customization - Add theme toggle button in Sidebar - Add CSS variables and dark mode styles - Dynamic sidebar and workspace colors PHASE 3: Provider UX Improvements - Add default provider templates: Anthropic, MiniMax, OpenRouter, GLM, AWS Bedrock - Add descriptions for each provider - Add getDefaultProviderTemplates() for UI display Security: Tokens encrypted with Electron safeStorage, never sent to renderer Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix H2: Encryption failures now throw errors instead of silently storing plaintext tokens - Fix H1: Add URL validation for provider baseUrl to prevent SSRF attacks (CWE-918) - Add proper error handling in IPC provider.save handler - Improve decryption with legacy token migration warnings - Add GitHub Actions CI pipeline for lint and build verification Security: Token encryption now fails fast, refusing to store unencrypted credentials. SSRF prevention blocks internal IPs (127.x, 10.x, 172.16-31.x, 192.168.x, localhost). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix React hooks called after conditional returns (EventCard.tsx) - Add proper types and eslint-disable for unavoidable any types - Fix hooks rules violations by moving hooks before early returns - Add eslint-disable for valid setState-in-effect patterns - Clean up unused eslint-disable directives - Add proper IPC event types in main.ts and types.d.ts All 32 ESLint errors resolved. Only 4 non-blocking warnings remain. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
P0 Critical: - Add ENC:v1: prefix for deterministic encrypted token detection - Add CLAUDE_COWORK_ALLOW_LOCAL_PROVIDERS env var for localhost/dev P1 High Priority: - Add validateModelConfig() for provider models validation - Fix sanitizePath() to allow valid quote characters in paths - Add isValidHookConfig() for deep hook structure validation - Mark resetInstance() as @internal with test environment warning P2 Medium Priority: - Add IPC rate limiting (100 req/min per event type) - Add 5-minute timeout for pending permission requests - Make CI ESLint conditional (fail on main, warn on PRs) P3 Low Priority: - Refactor loadProviders with readProvidersFile() helper - Add JSDoc documentation to new functions - Fix ESLint config to ignore dist-electron/dist-react - Fix useMemo for messages in App.tsx - Allow hook exports in eslint react-refresh rule Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Partial progress on SDK integration: - Add settingSources to load ~/.claude/ configuration (user, project, local) - Implement getCustomAgents() to convert activeSkills to SDK AgentDefinition - Add getLocalPlugins() for loading enabled plugins from ~/.claude/plugins/ - Pass agents, plugins, and settingSources to SDK query() options UI fixes included: - Fix provider configuration flow (modal now pre-populates with selected provider) - Fix theme toggle icon (now shows action icon, not current state) - Optimize PromptInput performance with debounced height calculation Restrictions (WIP): - Agents/skills invocation (@agent, /skill) requires further SDK integration - Command routing still uses native SDK subagents instead of custom definitions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolved 3 conflicts: 1. src/electron/ipc-handlers.ts - Combined cleanupAllSessions() from upstream with initializeHandlers() - Now exports both functions for proper app lifecycle 2. src/electron/main.ts - Kept WindowManager architecture (better encapsulation) - Added cleanupAllSessions() calls on app quit events - Maintained single instance lock for preventing multiple windows 3. src/electron/test.ts - Combined both cleanup approaches (cleanupPolling + stopPolling) - Better error handling with try/catch in polling - activePollingInterval reference for reliable cleanup Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces custom LLM API provider support and a unified architecture with centralized settings management, orchestrator agent coordination, and significant security improvements.
Part 1: Custom LLM Providers (Original)
Add support for custom LLM API providers, allowing users to configure and use alternative LLM backends instead of the default Claude Code settings.
Features
Technical Changes
src/electron/libs/provider-config.ts: Provider configuration management modulesrc/electron/ipc-handlers.ts: Provider event handlerssrc/electron/libs/runner.ts: Integration of provider env vars into Claude executionsrc/ui/components/ProviderModal.tsx: Provider configuration UIsrc/ui/components/Sidebar.tsx: Provider selector dropdownsrc/ui/store/useAppStore.ts: Provider state managementsrc/electron/types.ts&src/ui/types.ts: Type definitions for providers and eventsDocumentation
CUSTOM_PROVIDERS.md: User guide for configuring custom providersPart 2: Unified Architecture & Security Improvements
New Modules
settings-manager.ts~/.claude/settings.jsonwith schema validationunified-commands.ts/help,/exit,/status,/clear)unified-task-runner.tsorchestrator-agent.tsSecurity Improvements (Codex Audit)
All findings from Codex security audit have been addressed:
cwdnot validated inupdateSession()sanitizePath()validationcwdnot validated on DB loadloadSessions()settings.jsonaccepted without schema validationvalidateSettings()with type checksgetRawSettings()shallow copy allowed mutationprocessInput()no error handlingPermission System
PermissionModetype:"secure"(require user approval) or"free"(auto-approve)parseAllowedTools()andisToolAllowed()utilities for tool restrictionscreateCanUseTool()factory for configurable permission handlingpermission_modecolumn to sessions tablePath Sanitization Fix (Critical Bug)
The original
sanitizePath()was destroying all paths with an aggressive regex. New implementation:normalize()+resolve()from Node.js path moduleArchitecture Changes
initializeHandlers()exported fromipc-handlers.tsfor proper startup sequenceorchestratorAgent.initialize()called during app ready event~/.claude/settings.jsonon startuppermissionModein session creation IPC eventsFiles Changed
New Files:
CLAUDE.md- Project documentationsrc/electron/libs/settings-manager.tssrc/electron/libs/unified-commands.tssrc/electron/libs/unified-task-runner.tssrc/electron/libs/orchestrator-agent.tssrc/electron/libs/default-providers.tsModified Files:
src/electron/types.ts- AddedPermissionModetypesrc/electron/libs/session-store.ts- Security fixes + permissionMode supportsrc/electron/libs/runner.ts- Permission system + provider integrationsrc/electron/ipc-handlers.ts- Orchestrator integration + provider handlerssrc/electron/main.ts- Initialization sequenceTest Plan
~/.claude/settings.jsonBreaking Changes
None. All changes are backward compatible:
permissionModedefaults to"secure"if not specifiedsettings.json🤖 Generated with Claude Code