How swordtraveller/codey works
Codey is an Electron desktop agent for conversation, project work, and coding. The main workflow runs from the renderer through the preload IPC bridge to the main-process development handler, which manages conversation history and context, invokes the agent and its tools, and persists results. Major documented branches include model selection, image input and web search, layered context management with Rhai customization and debugging, and encrypted conversation handover through an optional bridge service. The sampled excerpts establish key calls and IPC routes; several subsystem links are omitted where implementation wiring was not shown.
Main entry points: main/index.ts Electron main · agent.ts Agent · App.tsx Conversation UI · preload/index.ts IPC preload
Components 24
Desktop interface
- Conversation UI
src/renderer/src/App.tsx - Context debugger
src/renderer/src/ContextDebugApp.tsx - Renderer entry
src/renderer/src/main.tsx - IPC preload
src/preload/index.ts
Agent runtime
- Electron main
src/main/index.ts - Agent
src/main/agent.ts - Agent tools
src/main/tools.ts - Code sandbox
src/main/sandbox.ts - Project workspace
src/main/workspace.ts - Conversation store
src/main/conversation-store.ts - Model settings
src/main/model-config.ts - Image storage
src/main/image-store.ts
Context management
- Context manager
src/main/context.ts - Context settings
src/main/context-config.ts - Rhai strategy
src/main/rhai-strategy.ts - Rhai runner
native/rhai-runner/src/main.rs - Context debug API
src/main/index.ts
Conversation handover
- Handover client
handover/src/main.ts - Bridge API
bridge/server.mjs - Bridge state
bridge/server.mjs - Handover sync
src/main/bridge.ts
Other components
- User
- Model provider
- Remote device
Connections 24
- User → Conversation UI: uses
- Renderer entry → Conversation UI: renders
- Conversation UI → IPC preload: IPC requests
- Context debugger → IPC preload: debug IPC
- IPC preload → Electron main: forwards IPC
- Electron main → Agent: runs development
- Electron main → Project workspace: loads and saves
- Electron main → Conversation store: reads history
- Electron main → Model settings: resolves model
- Electron main → Context settings: resolves strategy
- Electron main → Context manager: prepares context
- Context manager → Rhai strategy: applies custom strategy
- Rhai strategy → Rhai runner: executes script
- Agent → Model provider: requests completion
- Agent → Agent tools: dispatches tools
- Agent tools → Code sandbox: runs code
- Agent → Image storage: uses attachments
- Electron main → Context debug API: serves debug actions
- Context debugger → Context debug API: requests overview and edits
- Electron main → Handover sync: syncs projects
- Handover sync → Bridge API: sends handover data
- Handover client → Bridge API: requests and fetches
- Bridge API → Bridge state: persists channel state
- Remote device → Handover client: pairs and views