Documentation
¶
Overview ¶
Package events provides a generic EventBus for pub/sub communication. It implements the core.EventPublisher interface and can be used with any project that imports seed/core.
Index ¶
- Constants
- func AgentMessageEvent(category, message string, extra map[string]interface{}) map[string]interface{}
- func AskUserRequestEvent(requestID, question, clientID string) map[string]interface{}
- func CompactionEvent(strategy string, messagesBefore, messagesAfter, tokensSaved int) map[string]interface{}
- func ErrorEvent(message string, err error) map[string]interface{}
- func FileChangedEvent(filePath, action string, content string) map[string]interface{}
- func FileContentChangedEvent(filePath string, modTime int64, size int64) map[string]interface{}
- func MetricsUpdateEvent(totalTokens, contextTokens, maxContextTokens, iteration int, totalCost float64) map[string]interface{}
- func QueryCompletedEvent(query, response string, tokensUsed int, cost float64, duration time.Duration) map[string]interface{}
- func QueryProgressEvent(message string, iteration int, tokensUsed int) map[string]interface{}
- func QueryStartedEvent(query, provider, model string) map[string]interface{}
- func SecurityApprovalRequestEvent(requestID, toolName, riskLevel, reasoning string, extras map[string]string) map[string]interface{}
- func SecurityPromptRequestEvent(requestID, prompt string, defaultResponse bool, extras map[string]string) map[string]interface{}
- func SecurityPromptResponseEvent(requestID, response bool) map[string]interface{}
- func StreamChunkEvent(chunk string, contentType string) map[string]interface{}
- func SubagentActivityEvent(toolCallID, toolName, phase, message string, details map[string]interface{}) map[string]interface{}
- func TodoUpdateEvent(todos []map[string]interface{}) map[string]interface{}
- func ToolEndEvent(toolCallID, toolName, status, result, errorMessage string, ...) map[string]interface{}
- func ToolExecutionEvent(toolName, action string, details map[string]interface{}) map[string]interface{}
- func ToolStartEvent(toolName, toolCallID, arguments, displayName, persona string, isSubagent bool, ...) map[string]interface{}
- func ValidationEvent(filePath string, diagnostics []map[string]interface{}) map[string]interface{}
- func WorkspaceChangedEvent(daemonRoot, workspaceRoot, previousWorkspaceRoot string) map[string]interface{}
- type EventBus
- type UIEvent
Constants ¶
const ( EventTypeQueryStarted = "query_started" EventTypeQueryCompleted = "query_completed" EventTypeError = "error" EventTypeToolStart = "tool_start" EventTypeToolEnd = "tool_end" EventTypeStreamChunk = "stream_chunk" EventTypeMetricsUpdate = "metrics_update" EventTypeCompaction = "compaction" )
Generic event types used by the core package. These are the only event types any consumer of seed/core needs to handle. (They match the constants in core/interfaces.go.)
const ( EventTypeQueryProgress = "query_progress" EventTypeToolExecution = "tool_execution" EventTypeSubagentActivity = "subagent_activity" EventTypeTodoUpdate = "todo_update" EventTypeFileChanged = "file_changed" EventTypeFileContentChanged = "file_content_changed" EventTypeValidation = "validation" EventTypeSecurityApprovalRequest = "security_approval_request" EventTypeSecurityPromptRequest = "security_prompt_request" EventTypeAskUserRequest = "ask_user_request" EventTypeAgentMessage = "agent_message" EventTypeWorkspaceChanged = "workspace_changed" EventTypeSessionTerminated = "session_terminated" )
Sprout-specific event types. These are used by the sprout application and are not part of the generic seed/core contract. External consumers of seed/core do not need to handle these.
Variables ¶
This section is empty.
Functions ¶
func AgentMessageEvent ¶
func AgentMessageEvent(category, message string, extra map[string]interface{}) map[string]interface{}
AgentMessageEvent creates an agent system message event. category: "info", "warning", "error", "tool_log", "thought"
func AskUserRequestEvent ¶
AskUserRequestEvent creates an ask_user request event for the webui
func CompactionEvent ¶
func CompactionEvent(strategy string, messagesBefore, messagesAfter, tokensSaved int) map[string]interface{}
CompactionEvent creates a compaction event with strategy name, message count delta, and estimated tokens saved.
func ErrorEvent ¶
ErrorEvent creates an error event
func FileChangedEvent ¶
FileChangedEvent creates a file changed event
func FileContentChangedEvent ¶
FileContentChangedEvent creates an event indicating a file's content on disk has changed while it was open in the editor
func MetricsUpdateEvent ¶
func MetricsUpdateEvent(totalTokens, contextTokens, maxContextTokens, iteration int, totalCost float64) map[string]interface{}
MetricsUpdateEvent creates a metrics update event
func QueryCompletedEvent ¶
func QueryCompletedEvent(query, response string, tokensUsed int, cost float64, duration time.Duration) map[string]interface{}
QueryCompletedEvent creates a query completed event
func QueryProgressEvent ¶
QueryProgressEvent creates a query progress event
func QueryStartedEvent ¶
QueryStartedEvent creates a query started event
func SecurityApprovalRequestEvent ¶
func SecurityApprovalRequestEvent(requestID, toolName, riskLevel, reasoning string, extras map[string]string) map[string]interface{}
SecurityApprovalRequestEvent creates a security approval request event for the webui
func SecurityPromptRequestEvent ¶
func SecurityPromptRequestEvent(requestID, prompt string, defaultResponse bool, extras map[string]string) map[string]interface{}
SecurityPromptRequestEvent creates a security prompt request event for the webui
func SecurityPromptResponseEvent ¶
SecurityPromptResponseEvent creates a security prompt response event
func StreamChunkEvent ¶
StreamChunkEvent creates a stream chunk event with content type
func SubagentActivityEvent ¶
func SubagentActivityEvent(toolCallID, toolName, phase, message string, details map[string]interface{}) map[string]interface{}
SubagentActivityEvent creates a structured subagent activity event. phase is typically "spawn", "output", or "complete".
func TodoUpdateEvent ¶
TodoUpdateEvent creates a todo update event
func ToolEndEvent ¶
func ToolEndEvent(toolCallID, toolName, status, result, errorMessage string, duration time.Duration) map[string]interface{}
ToolEndEvent creates a tool end event with result and status
func ToolExecutionEvent ¶
func ToolExecutionEvent(toolName, action string, details map[string]interface{}) map[string]interface{}
ToolExecutionEvent creates a tool execution event
func ToolStartEvent ¶
func ToolStartEvent(toolName, toolCallID, arguments, displayName, persona string, isSubagent bool, subagentType string, toolIndex int) map[string]interface{}
ToolStartEvent creates a tool start event with rich metadata
func ValidationEvent ¶
ValidationEvent creates a validation event
func WorkspaceChangedEvent ¶
func WorkspaceChangedEvent(daemonRoot, workspaceRoot, previousWorkspaceRoot string) map[string]interface{}
WorkspaceChangedEvent creates a workspace changed event
Types ¶
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus manages event distribution between CLI and Web UI
func (*EventBus) Publish ¶
Publish broadcasts an event to all subscribers. Critical events (security approvals, prompts) are never silently dropped — if the channel is full, they replace the oldest event to make room.
func (*EventBus) Unsubscribe ¶
Unsubscribe removes a subscriber from the event bus