Architecture Overview
The event system consists of multiple interconnected components:Event Types
Service Events (Global)
Service events track the lifecycle and operations of the Cipher instance:Cipher Lifecycle
cipher:started
- Cipher instance startedcipher:stopped
- Cipher instance stoppedcipher:error
- Critical error occurred
Service Management
cipher:serviceStarted
- Individual service initializedcipher:serviceError
- Service encountered an errorcipher:allServicesReady
- All services are ready
Tool Operations
cipher:toolRegistered
- Tool registered successfullycipher:toolUnregistered
- Tool unregisteredcipher:toolError
- Tool execution error
MCP Connections
cipher:mcpClientConnected
- MCP client connectedcipher:mcpClientDisconnected
- MCP client disconnectedcipher:mcpClientError
- MCP connection error
Memory Operations
cipher:memoryOperationStarted
- Memory operation initiatedcipher:memoryOperationCompleted
- Memory operation completedcipher:memoryOperationFailed
- Memory operation failed
Vector Store
cipher:vectorStoreConnected
- Vector store connectedcipher:vectorStoreDisconnected
- Vector store disconnectedcipher:vectorStoreError
- Vector store error
LLM Providers
cipher:llmProviderRegistered
- LLM provider registeredcipher:llmProviderError
- LLM provider error
Session Events (Conversation-Scoped)
Session events track individual conversation interactions:Session Lifecycle
session:created
- New session createdsession:activated
- Session activatedsession:deactivated
- Session deactivatedsession:expired
- Session expiredsession:deleted
- Session deleted
Tool Execution
tool:executionStarted
- Tool execution startedtool:executionCompleted
- Tool execution completedtool:executionFailed
- Tool execution failed
LLM Interactions
llm:thinking
- LLM processing startedllm:responseStarted
- LLM response generation startedllm:responseCompleted
- LLM response completedllm:responseError
- LLM response error
Memory Operations
memory:stored
- Memory item storedmemory:retrieved
- Memory items retrievedmemory:searched
- Memory search performed
Conversation Management
conversation:messageAdded
- Message added to conversationconversation:messageUpdated
- Message updatedconversation:cleared
- Conversation cleared
Context Management
context:updated
- Context updatedcontext:truncated
- Context truncated
Configuration
Environment Variables
The event system supports environment variables for configuration:YAML Configuration
Event system settings can be configured in yourcipher.yml
under the eventPersistence
section:
enabled
: Enable/disable event persistence (default: true)storageType
: Storage backend type - ‘file’ or ‘memory’ (default: ‘file’)filePath
: Path for file storage (default: ’./data/events’)maxEvents
: Maximum number of events to store (optional)rotationSize
: File size before rotation in bytes (optional)retentionDays
: Number of days to retain events (optional)
- Environment variables take highest priority
- YAML configuration is used as fallback
- Default values are used if neither is specified
Event Schema
JSON Schema
Events are stored in JSONL format (events-YYYY-MM-DD.jsonl
) with this structure: