Instructions for AI agents working on this repository.
AgentCHAT is an Electron desktop app (React + TypeScript) that lets two AI agents have conversations with each other while a human operator can inject messages in real-time. Supports 14 AI providers including OpenAI, Anthropic, Google Gemini, OpenRouter, and local models (Ollama, Llama.cpp).
src/App.tsx- Main state orchestration, conversation loopsrc/services/AgentManager.ts- Agent message preparation, context windowingsrc/services/APIClient.ts- All 14 provider configs, request/response transformssrc/types/index.ts- All TypeScript interfaces and enumspackage.json- Scripts, dependencies, build config
Electron Main Process (src/main.cjs)
↕ IPC via preload.cjs
React Renderer (src/App.tsx)
├── AgentConfigPanel.tsx (agent + prompt config sidebar)
├── ConversationPanel.tsx (chat display + controls)
├── MessageBubble.tsx (individual messages)
├── StatusBar.tsx (status bar)
└── APIKeyModal.tsx (secure key entry)
↕
Services Layer
├── AgentManager.ts (message prep, context window, export)
└── APIClient.ts (14 providers, model fetching, API calls)
- Secure Storage: API keys encrypted via
electron-storewith per-install encryption key - IPC Bridge: All main/renderer communication through
preload.cjscontextBridge - Message Roles: SYSTEM, USER, ASSISTANT, OPERATOR (operator messages only visible to Agent 1)
- Context Window: Last 10 messages sent per API call, with role transformation per agent perspective
- Provider Abstraction: Each provider has
transformRequest()andtransformResponse()in APIClient
npm run electron:dev # Dev with hot reload
npm run build # TypeScript + Vite build
npm run lint # ESLint check
npm run dist:current # Package for current platformsrc/preload.cjssecurity model (context isolation, limited API surface)- Encrypted storage encryption key generation in
src/main.cjs - The IPC channel names (would break main/renderer communication)
- Functional React components only, with typed props
- Tailwind CSS utilities only (no CSS modules)
- PascalCase for components/services, camelCase for functions/variables
- All new providers must implement
transformRequestandtransformResponsein APIClient.ts
npm run lint # Linting
npm run build # Type check + build
npm run electron:dev # Manual testing with hot reload
npm run electron:preview # Production build preview