All communication between the Electron main process and the React renderer goes through src/preload.cjs via contextBridge.exposeInMainWorld('electronAPI', ...).
Stores an encrypted API key for a provider.
- Parameters:
provider(string from VALID_PROVIDERS list),key(string) - Returns:
{ success: boolean, error?: string } - IPC Channel:
store-api-key - Validation: Provider checked against allowlist of 21 valid provider names
Retrieves a stored API key. Checks environment variables first, then falls back to encrypted store.
- Parameters:
provider(string) - Returns:
{ success: boolean, key?: string, error?: string } - IPC Channel:
get-api-key - Env Fallback: Maps provider name to env var (e.g.,
anthropic->ANTHROPIC_API_KEY)
Removes a stored API key.
- Parameters:
provider(string) - Returns:
{ success: boolean, error?: string } - IPC Channel:
delete-api-key
Opens a native save dialog and writes conversation content to a file.
- Parameters:
content(string, Markdown formatted) - Returns:
{ success: boolean, filePath?: string, cancelled?: boolean, error?: string } - IPC Channel:
save-conversation - Default filename:
AgentCHAT-YYYY-MM-DD.md
The orchestration layer between the React UI and the API client.
Gets a response from an AI provider for a given agent, preparing messages with role transformation and context windowing (last 10 messages).
Fetches available models for a provider. Uses cached results when available, falls back to hardcoded model lists.
Returns the default model string for a provider.
Saves an API key through the Electron IPC bridge.
Retrieves an API key through the Electron IPC bridge.
Converts a message array into a formatted Markdown document with agent names and timestamps.
Handles all HTTP communication with AI providers.
sendMessage(provider, messages, model, maxTokens, temperature, additionalParams): Promise<APIResponse>
Sends a chat completion request to the specified provider.
- Timeout: 60 seconds (AbortController)
- additionalParams:
presence_penalty,frequency_penalty,top_p,top_k,reasoning_effort,localServerConfig - Internal fields (
localServerConfig,provider,model,apiKey) are stripped before sending to third-party APIs
Fetches model lists from provider APIs. Providers with dynamic endpoints (OpenRouter, OpenAI, Gemini, DeepSeek, Groq, Together, Mistral, Ollama) are queried live. Others return static lists.
Sends a minimal test message to verify provider connectivity and API key validity.
| Provider | Base URL | Auth Header |
|---|---|---|
| OpenRouter | https://openrouter.ai/api/v1/chat/completions |
Authorization: Bearer |
| OpenAI | https://api.openai.com/v1/chat/completions |
Authorization: Bearer |
| Anthropic | https://api.anthropic.com/v1/messages |
x-api-key |
| Gemini | https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent |
x-goog-api-key |
| DeepSeek | https://api.deepseek.com/v1/chat/completions |
Authorization: Bearer |
| Groq | https://api.groq.com/openai/v1/chat/completions |
Authorization: Bearer |
| HuggingFace | https://api-inference.huggingface.co/models/{model} |
Authorization: Bearer |
| Meta/Replicate | https://api.replicate.com/v1/predictions |
Authorization: Token |
| Mistral | https://api.mistral.ai/v1/chat/completions |
Authorization: Bearer |
| Pi.ai | https://api.pi.ai/v1/chat |
X-API-Key |
| Together | https://api.together.xyz/v1/chat/completions |
Authorization: Bearer |
| xAI | https://api.x.ai/v1/chat/completions |
Authorization: Bearer |
| Ollama | http://localhost:11434/api/chat |
None |
| Llama.cpp | http://localhost:8080/v1/chat/completions |
None |
All types live in src/types/index.ts.
- APIProvider:
openrouter,openai,anthropic,gemini,deepseek,groq,huggingface,meta,mistral,pi,together,xai,ollama,llamacpp - MessageRole:
system,user,assistant,operator - ConversationState:
idle,running,paused,error
- AgentConfig:
id,name,provider,model,persona,temperature,maxTokens,presencePenalty?,frequencyPenalty?,topP?,topK?,reasoningEffort?,localServerConfig? - Message:
id,role,content,timestamp,agentId?,provider?,model?,isOperatorMessage? - Conversation:
id,title,messages,createdAt,updatedAt,agents(tuple of 2),systemPrompt,initialPrompt - APIResponse:
success,data?,error?,usage?
See ARCHITECTURE.md for system design. See DEVELOPMENT.md for adding new providers.