Documentation
¶
Overview ¶
Package events defines domain events for the cdev system.
Package events defines all event types used in cdev.
Index ¶
- type BaseEvent
- func NewClaudeErrorEvent(err string, exitCode int) *BaseEvent
- func NewClaudeIdleEvent() *BaseEvent
- func NewClaudeLogEvent(line string, stream StreamType) *BaseEvent
- func NewClaudeLogEventWithParsed(line string, stream StreamType, parsed *ParsedClaudeMessage) *BaseEvent
- func NewClaudeMessageEvent(sessionID, msgType, role string, content []ClaudeMessageContent) *BaseEvent
- func NewClaudeMessageEventFull(payload ClaudeMessagePayload) *BaseEvent
- func NewClaudePermissionEvent(toolUseID, toolName, input, description string) *BaseEvent
- func NewClaudeSessionInfoEvent(sessionID, model, version string) *BaseEvent
- func NewClaudeStatusEvent(state ClaudeState, prompt string, pid int) *BaseEvent
- func NewClaudeStoppedEvent(exitCode int) *BaseEvent
- func NewClaudeWaitingEvent(toolUseID, toolName, input string) *BaseEvent
- func NewErrorEvent(code, message string, requestID string, details map[string]interface{}) *BaseEvent
- func NewEvent(eventType EventType, payload interface{}) *BaseEvent
- func NewEventWithContext(eventType EventType, payload interface{}, workspaceID, sessionID string) *BaseEvent
- func NewEventWithRequestID(eventType EventType, payload interface{}, requestID string) *BaseEvent
- func NewFileChangedEvent(path string, change FileChangeType, size int64) *BaseEvent
- func NewFileContentErrorEvent(path, errMsg string, requestID string) *BaseEvent
- func NewFileContentEvent(path, content string, size int64, truncated bool, requestID string) *BaseEvent
- func NewFileRenamedEvent(oldPath, newPath string) *BaseEvent
- func NewGitBranchChangedEvent(workspaceID, fromBranch, toBranch, sessionID string) *BaseEvent
- func NewGitDiffEvent(file, diff string, additions, deletions int, isStaged, isNewFile bool, ...) *BaseEvent
- func NewHeartbeatEvent(sequence int64, claudeStatus string, uptimeSeconds int64) *BaseEvent
- func NewPTYOutputEvent(cleanText, rawText, state string) *BaseEvent
- func NewPTYOutputEventWithSession(cleanText, rawText, state, sessionID string) *BaseEvent
- func NewPTYPermissionEvent(permType, target, description, preview string, options []PTYPromptOption) *BaseEvent
- func NewPTYPermissionEventWithSession(permType, target, description, preview, sessionID string, ...) *BaseEvent
- func NewPTYPermissionResolvedEvent(sessionID, workspaceID, resolvedBy, input string) *BaseEvent
- func NewPTYSpinnerEventWithSession(text, symbol, message, sessionID string) *BaseEvent
- func NewPTYStateEvent(state string, waitingForInput bool, promptType string) *BaseEvent
- func NewPTYStateEventWithSession(state string, waitingForInput bool, promptType, sessionID string) *BaseEvent
- func NewSessionEndEvent(sessionID, reason string) *BaseEvent
- func NewSessionIDFailedEvent(temporaryID, workspaceID, reason, message string) *BaseEvent
- func NewSessionIDResolvedEvent(temporaryID, realID, workspaceID, sessionFile string) *BaseEvent
- func NewSessionIDTimeoutEvent(temporaryID, workspaceID string, timeoutSeconds int, reason string) *BaseEvent
- func NewSessionJoinedEvent(joiningClientID, workspaceID, sessionID string, otherViewers []string) *BaseEvent
- func NewSessionLeftEvent(leavingClientID, workspaceID, sessionID string, remainingViewers []string) *BaseEvent
- func NewSessionStartEvent(sessionID, repoPath, repoName, agentVersion string) *BaseEvent
- func NewSessionStoppedEvent(workspaceID, sessionID string) *BaseEvent
- func NewStatusResponseEvent(payload StatusResponsePayload, requestID string) *BaseEvent
- func NewStreamReadCompleteEvent(sessionID string, messagesEmitted int, fileOffset, fileSize int64) *BaseEvent
- func NewWorkspaceRemovedEvent(id, name, path string) *BaseEvent
- func (e *BaseEvent) GetSessionID() string
- func (e *BaseEvent) GetWorkspaceID() string
- func (e *BaseEvent) SetAgentType(agentType string)
- func (e *BaseEvent) SetContext(workspaceID, sessionID string)
- func (e *BaseEvent) Timestamp() time.Time
- func (e *BaseEvent) ToJSON() ([]byte, error)
- func (e *BaseEvent) Type() EventType
- type ClaudeLogPayload
- type ClaudeMessageContent
- type ClaudeMessagePayload
- type ClaudePermissionPayload
- type ClaudeSessionInfoPayload
- type ClaudeState
- type ClaudeStatusPayload
- type ClaudeWaitingPayload
- type ErrorPayload
- type Event
- type EventType
- type FileChangeType
- type FileChangedPayload
- type FileContentPayload
- type GitBranchChangedPayload
- type GitDiffPayload
- type GitOperationCompletedPayload
- type GitStatusChangedPayload
- type HeartbeatPayload
- type ImageDimensions
- type ImageInfo
- type PTYOutputPayload
- type PTYPermissionPayload
- type PTYPermissionResolvedPayload
- type PTYPromptOption
- type PTYSpinnerPayload
- type PTYStatePayload
- type ParsedClaudeMessage
- type ParsedContentBlock
- type SessionEndPayload
- type SessionIDFailedPayload
- type SessionIDResolvedPayload
- type SessionIDTimeoutPayload
- type SessionJoinedPayload
- type SessionLeftPayload
- type SessionStartPayload
- type SessionStoppedPayload
- type StatusResponsePayload
- type StreamReadCompletePayload
- type StreamType
- type WorkspaceRemovedPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseEvent ¶
type BaseEvent struct {
EventType EventType `json:"event"`
EventTime time.Time `json:"timestamp"`
WorkspaceID string `json:"workspace_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
AgentType string `json:"agent_type,omitempty"`
Payload interface{} `json:"payload"`
RequestID string `json:"request_id,omitempty"`
}
BaseEvent contains common fields for all events.
func NewClaudeErrorEvent ¶
NewClaudeErrorEvent creates a new claude_status event with error state.
func NewClaudeIdleEvent ¶
func NewClaudeIdleEvent() *BaseEvent
NewClaudeIdleEvent creates a new claude_status event with idle state.
func NewClaudeLogEvent ¶
func NewClaudeLogEvent(line string, stream StreamType) *BaseEvent
NewClaudeLogEvent creates a new claude_log event.
func NewClaudeLogEventWithParsed ¶
func NewClaudeLogEventWithParsed(line string, stream StreamType, parsed *ParsedClaudeMessage) *BaseEvent
NewClaudeLogEventWithParsed creates a new claude_log event with parsed content.
func NewClaudeMessageEvent ¶
func NewClaudeMessageEvent(sessionID, msgType, role string, content []ClaudeMessageContent) *BaseEvent
NewClaudeMessageEvent creates a new claude_message event.
func NewClaudeMessageEventFull ¶
func NewClaudeMessageEventFull(payload ClaudeMessagePayload) *BaseEvent
NewClaudeMessageEventFull creates a new claude_message event with all fields.
func NewClaudePermissionEvent ¶
NewClaudePermissionEvent creates a new claude_permission event.
func NewClaudeSessionInfoEvent ¶
NewClaudeSessionInfoEvent creates a new claude_session_info event.
func NewClaudeStatusEvent ¶
func NewClaudeStatusEvent(state ClaudeState, prompt string, pid int) *BaseEvent
NewClaudeStatusEvent creates a new claude_status event.
func NewClaudeStoppedEvent ¶
NewClaudeStoppedEvent creates a new claude_status event with stopped state.
func NewClaudeWaitingEvent ¶
NewClaudeWaitingEvent creates a new claude_waiting event.
func NewErrorEvent ¶
func NewErrorEvent(code, message string, requestID string, details map[string]interface{}) *BaseEvent
NewErrorEvent creates a new error event.
func NewEventWithContext ¶
func NewEventWithContext(eventType EventType, payload interface{}, workspaceID, sessionID string) *BaseEvent
NewEventWithContext creates a new event with workspace and session context.
func NewEventWithRequestID ¶
NewEventWithRequestID creates a new event with a request ID for correlation.
func NewFileChangedEvent ¶
func NewFileChangedEvent(path string, change FileChangeType, size int64) *BaseEvent
NewFileChangedEvent creates a new file_changed event.
func NewFileContentErrorEvent ¶
NewFileContentErrorEvent creates a new file_content error response event.
func NewFileContentEvent ¶
func NewFileContentEvent(path, content string, size int64, truncated bool, requestID string) *BaseEvent
NewFileContentEvent creates a new file_content response event.
func NewFileRenamedEvent ¶
NewFileRenamedEvent creates a new file_changed event for renamed files.
func NewGitBranchChangedEvent ¶
NewGitBranchChangedEvent creates a new git_branch_changed event.
func NewGitDiffEvent ¶
func NewGitDiffEvent(file, diff string, additions, deletions int, isStaged, isNewFile bool, truncated bool) *BaseEvent
NewGitDiffEvent creates a new git_diff event.
func NewHeartbeatEvent ¶
NewHeartbeatEvent creates a new heartbeat event.
func NewPTYOutputEvent ¶
NewPTYOutputEvent creates a new PTY output event.
func NewPTYOutputEventWithSession ¶
NewPTYOutputEventWithSession creates a new PTY output event with session ID.
func NewPTYPermissionEvent ¶
func NewPTYPermissionEvent(permType, target, description, preview string, options []PTYPromptOption) *BaseEvent
NewPTYPermissionEvent creates a new PTY permission event.
func NewPTYPermissionEventWithSession ¶
func NewPTYPermissionEventWithSession(permType, target, description, preview, sessionID string, options []PTYPromptOption) *BaseEvent
NewPTYPermissionEventWithSession creates a new PTY permission event with session ID.
func NewPTYPermissionResolvedEvent ¶
NewPTYPermissionResolvedEvent creates a new pty_permission_resolved event.
func NewPTYSpinnerEventWithSession ¶
NewPTYSpinnerEventWithSession creates a new PTY spinner event with session ID.
func NewPTYStateEvent ¶
NewPTYStateEvent creates a new PTY state event.
func NewPTYStateEventWithSession ¶
func NewPTYStateEventWithSession(state string, waitingForInput bool, promptType, sessionID string) *BaseEvent
NewPTYStateEventWithSession creates a new PTY state event with session ID.
func NewSessionEndEvent ¶
NewSessionEndEvent creates a new session_end event.
func NewSessionIDFailedEvent ¶
NewSessionIDFailedEvent creates a new session_id_failed event.
func NewSessionIDResolvedEvent ¶
NewSessionIDResolvedEvent creates a new session_id_resolved event.
func NewSessionIDTimeoutEvent ¶
func NewSessionIDTimeoutEvent(temporaryID, workspaceID string, timeoutSeconds int, reason string) *BaseEvent
NewSessionIDTimeoutEvent creates a new session_id_timeout event.
func NewSessionJoinedEvent ¶
func NewSessionJoinedEvent(joiningClientID, workspaceID, sessionID string, otherViewers []string) *BaseEvent
NewSessionJoinedEvent creates a new session_joined event. Sent when a device joins a session that other devices are viewing.
func NewSessionLeftEvent ¶
func NewSessionLeftEvent(leavingClientID, workspaceID, sessionID string, remainingViewers []string) *BaseEvent
NewSessionLeftEvent creates a new session_left event. Sent when a device leaves a session that other devices are viewing.
func NewSessionStartEvent ¶
NewSessionStartEvent creates a new session_start event.
func NewSessionStoppedEvent ¶
NewSessionStoppedEvent creates a new session_stopped event. This is broadcast to all connected clients so they can update their UI (e.g., show "idle" instead of "active").
func NewStatusResponseEvent ¶
func NewStatusResponseEvent(payload StatusResponsePayload, requestID string) *BaseEvent
NewStatusResponseEvent creates a new status_response event.
func NewStreamReadCompleteEvent ¶
func NewStreamReadCompleteEvent(sessionID string, messagesEmitted int, fileOffset, fileSize int64) *BaseEvent
NewStreamReadCompleteEvent creates a new stream_read_complete event.
func NewWorkspaceRemovedEvent ¶
NewWorkspaceRemovedEvent creates a new workspace_removed event.
func (*BaseEvent) GetSessionID ¶
GetSessionID returns the session ID.
func (*BaseEvent) GetWorkspaceID ¶
GetWorkspaceID returns the workspace ID.
func (*BaseEvent) SetAgentType ¶
SetAgentType sets the agent/runtime type for this event (e.g., "claude", "codex").
func (*BaseEvent) SetContext ¶
SetContext sets the workspace and session context for an event.
type ClaudeLogPayload ¶
type ClaudeLogPayload struct {
Line string `json:"line"`
Stream StreamType `json:"stream"`
// Parsed is the structured content extracted from Claude CLI stream-json output.
// Only populated for valid JSON lines from stdout.
Parsed *ParsedClaudeMessage `json:"parsed,omitempty"`
}
ClaudeLogPayload is the payload for claude_log events. Enhanced to include parsed content for rich UI rendering.
type ClaudeMessageContent ¶
type ClaudeMessageContent struct {
// Type is the content type: "text", "thinking", "tool_use", "tool_result"
Type string `json:"type"`
// Text is the text content (for "text" and "thinking" types)
Text string `json:"text,omitempty"`
// ToolName is the tool being called (for "tool_use" type)
ToolName string `json:"tool_name,omitempty"`
// ToolID is the unique ID for this tool call (for "tool_use" type)
ToolID string `json:"tool_id,omitempty"`
// ToolInput is the parsed tool input (for "tool_use" type)
ToolInput map[string]interface{} `json:"tool_input,omitempty"`
// ToolUseID references the tool call (for "tool_result" type)
ToolUseID string `json:"tool_use_id,omitempty"`
// Content is the result content (for "tool_result" type)
Content string `json:"content,omitempty"`
// IsError indicates if the tool result is an error
IsError bool `json:"is_error,omitempty"`
// FilePath is the file path for Read tool results (for image tool_result)
FilePath string `json:"file_path,omitempty"`
// ImageInfo contains metadata for image tool results
ImageInfo *ImageInfo `json:"image_info,omitempty"`
}
ClaudeMessageContent represents a content block in a claude_message.
type ClaudeMessagePayload ¶
type ClaudeMessagePayload struct {
// SessionID is the Claude session ID
SessionID string `json:"session_id"`
// Type is the message type: "assistant", "user", "result"
Type string `json:"type"`
// Role is the message role: "assistant" or "user"
Role string `json:"role,omitempty"`
// Content contains the message content blocks
Content []ClaudeMessageContent `json:"content,omitempty"`
// Model is the model used (for assistant messages)
Model string `json:"model,omitempty"`
// StopReason indicates why the message ended
StopReason string `json:"stop_reason,omitempty"`
// IsContextCompaction is true when this is an auto-generated message
// created by Claude Code when the context window was maxed out and
// the conversation was compacted/summarized.
// iOS should display this differently (e.g., as a system notice).
IsContextCompaction bool `json:"is_context_compaction,omitempty"`
// Timestamp is when this message was created (ISO 8601 format)
Timestamp string `json:"timestamp,omitempty"`
}
ClaudeMessagePayload is the payload for claude_message events. This provides real-time structured messages for rich UI rendering.
type ClaudePermissionPayload ¶
type ClaudePermissionPayload struct {
ToolUseID string `json:"tool_use_id"`
ToolName string `json:"tool_name"`
Input string `json:"input"`
Description string `json:"description"`
}
ClaudePermissionPayload is the payload for claude_permission events.
type ClaudeSessionInfoPayload ¶
type ClaudeSessionInfoPayload struct {
SessionID string `json:"session_id"`
Model string `json:"model,omitempty"`
Version string `json:"version,omitempty"`
}
ClaudeSessionInfoPayload is the payload for claude_session_info events.
type ClaudeState ¶
type ClaudeState string
ClaudeState represents the current state of Claude CLI.
const ( ClaudeStateIdle ClaudeState = "idle" ClaudeStateRunning ClaudeState = "running" ClaudeStateWaiting ClaudeState = "waiting" ClaudeStateError ClaudeState = "error" ClaudeStateStopped ClaudeState = "stopped" )
type ClaudeStatusPayload ¶
type ClaudeStatusPayload struct {
State ClaudeState `json:"state"`
Prompt string `json:"prompt,omitempty"`
PID int `json:"pid,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
Error string `json:"error,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
}
ClaudeStatusPayload is the payload for claude_status events.
type ClaudeWaitingPayload ¶
type ClaudeWaitingPayload struct {
ToolUseID string `json:"tool_use_id"`
ToolName string `json:"tool_name"`
Input string `json:"input"`
}
ClaudeWaitingPayload is the payload for claude_waiting events.
type ErrorPayload ¶
type ErrorPayload struct {
Code string `json:"code"`
Message string `json:"message"`
RequestID string `json:"request_id,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
}
ErrorPayload is the payload for error events.
type Event ¶
type Event interface {
// Type returns the event type.
Type() EventType
// Timestamp returns when the event occurred.
Timestamp() time.Time
// ToJSON serializes the event to JSON.
ToJSON() ([]byte, error)
// GetWorkspaceID returns the workspace ID (may be empty).
GetWorkspaceID() string
// GetSessionID returns the session ID (may be empty).
GetSessionID() string
}
Event is the base interface for all events.
type EventType ¶
type EventType string
EventType represents the type of event.
const ( EventTypePTYOutput EventType = "pty_output" EventTypePTYPermission EventType = "pty_permission" EventTypePTYPermissionResolved EventType = "pty_permission_resolved" // Permission was responded to by a device EventTypePTYState EventType = "pty_state" EventTypePTYSpinner EventType = "pty_spinner" )
PTY-specific event types
const ( // Claude events EventTypeClaudeLog EventType = "claude_log" EventTypeClaudeMessage EventType = "claude_message" EventTypeClaudeStatus EventType = "claude_status" EventTypeClaudeWaiting EventType = "claude_waiting" EventTypeClaudePermission EventType = "claude_permission" EventTypeClaudeSessionInfo EventType = "claude_session_info" // File events EventTypeFileChanged EventType = "file_changed" // Git events EventTypeGitDiff EventType = "git_diff" EventTypeGitStatusChanged EventType = "git_status_changed" EventTypeGitOperationComplete EventType = "git_operation_completed" EventTypeGitBranchChanged EventType = "git_branch_changed" // Session events EventTypeSessionStart EventType = "session_start" EventTypeSessionEnd EventType = "session_end" EventTypeSessionStopped EventType = "session_stopped" // Session stopped (for multi-device sync) EventTypeSessionWatchChanged EventType = "session_watch_changed" EventTypeSessionJoined EventType = "session_joined" EventTypeSessionLeft EventType = "session_left" EventTypeSessionIDResolved EventType = "session_id_resolved" // Real session ID from .claude/projects EventTypeSessionIDTimeout EventType = "session_id_timeout" // Timeout waiting for real session ID EventTypeSessionIDFailed EventType = "session_id_failed" // Failed to get real session ID (user declined trust) // Workspace events EventTypeWorkspaceRemoved EventType = "workspace_removed" // Response events EventTypeStatusResponse EventType = "status_response" EventTypeFileContent EventType = "file_content" EventTypeError EventType = "error" // Connection events EventTypeHeartbeat EventType = "heartbeat" // Stream events EventTypeStreamReadComplete EventType = "stream_read_complete" // JSONL file reader caught up to end // Claude Hook events (from external Claude sessions via hooks) EventTypeClaudeHookSession EventType = "claude_hook_session" // SessionStart hook EventTypeClaudeHookPermission EventType = "claude_hook_permission" // Permission prompt notification EventTypeClaudeHookToolStart EventType = "claude_hook_tool_start" // PreToolUse hook EventTypeClaudeHookToolEnd EventType = "claude_hook_tool_end" // PostToolUse hook )
type FileChangeType ¶
type FileChangeType string
FileChangeType represents the type of file change.
const ( FileChangeCreated FileChangeType = "created" FileChangeModified FileChangeType = "modified" FileChangeDeleted FileChangeType = "deleted" FileChangeRenamed FileChangeType = "renamed" )
type FileChangedPayload ¶
type FileChangedPayload struct {
Path string `json:"path"`
Change FileChangeType `json:"change"`
Size int64 `json:"size,omitempty"`
OldPath string `json:"old_path,omitempty"`
}
FileChangedPayload is the payload for file_changed events.
type FileContentPayload ¶
type FileContentPayload struct {
Path string `json:"path"`
Content string `json:"content,omitempty"`
Encoding string `json:"encoding"`
Truncated bool `json:"truncated"`
Size int64 `json:"size"`
Error string `json:"error,omitempty"`
}
FileContentPayload is the payload for file_content response events.
type GitBranchChangedPayload ¶
type GitBranchChangedPayload struct {
FromBranch string `json:"from_branch"`
ToBranch string `json:"to_branch"`
SessionID string `json:"session_id,omitempty"`
}
GitBranchChangedPayload represents the payload for git_branch_changed events.
type GitDiffPayload ¶
type GitDiffPayload struct {
File string `json:"file"`
Diff string `json:"diff"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
IsStaged bool `json:"is_staged"`
IsNewFile bool `json:"is_new_file"`
Truncated bool `json:"is_truncated,omitempty"`
}
GitDiffPayload is the payload for git_diff events.
type GitOperationCompletedPayload ¶
type GitOperationCompletedPayload struct {
Operation string `json:"operation"` // stage, unstage, discard, commit, push, pull, checkout
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
// Operation-specific fields
SHA string `json:"sha,omitempty"` // for commit
Branch string `json:"branch,omitempty"` // for checkout
FilesAffected int `json:"files_affected,omitempty"` // for stage/unstage/discard/commit
CommitsPushed int `json:"commits_pushed,omitempty"` // for push
CommitsPulled int `json:"commits_pulled,omitempty"` // for pull
ConflictedFiles []string `json:"conflicted_files,omitempty"` // for pull with conflicts
}
GitOperationCompletedPayload represents the payload for git_operation_completed events.
type GitStatusChangedPayload ¶
type GitStatusChangedPayload struct {
Branch string `json:"branch"`
Ahead int `json:"ahead"`
Behind int `json:"behind"`
StagedCount int `json:"staged_count"`
UnstagedCount int `json:"unstaged_count"`
UntrackedCount int `json:"untracked_count"`
HasConflicts bool `json:"has_conflicts"`
ChangedFiles []string `json:"changed_files,omitempty"`
}
GitStatusChangedPayload represents the payload for git_status_changed events.
type HeartbeatPayload ¶
type HeartbeatPayload struct {
ServerTime string `json:"server_time"`
Sequence int64 `json:"sequence"`
ClaudeStatus string `json:"claude_status"`
Uptime int64 `json:"uptime_seconds"`
}
HeartbeatPayload is the payload for heartbeat events. Heartbeats are sent periodically to allow clients to detect connection issues at the application level (beyond WebSocket ping/pong frames).
type ImageDimensions ¶
type ImageDimensions struct {
// OriginalWidth is the original image width in pixels
OriginalWidth int `json:"original_width"`
// OriginalHeight is the original image height in pixels
OriginalHeight int `json:"original_height"`
// DisplayWidth is the scaled width for display (after resize for Claude)
DisplayWidth int `json:"display_width"`
// DisplayHeight is the scaled height for display (after resize for Claude)
DisplayHeight int `json:"display_height"`
}
ImageDimensions contains width/height info for images.
type ImageInfo ¶
type ImageInfo struct {
// Type is the MIME type (e.g., "image/jpeg")
Type string `json:"type"`
// OriginalSize is the file size in bytes
OriginalSize int64 `json:"original_size"`
// Dimensions contains the image dimensions
Dimensions *ImageDimensions `json:"dimensions,omitempty"`
}
ImageInfo contains metadata about an image from a Read tool result.
type PTYOutputPayload ¶
type PTYOutputPayload struct {
CleanText string `json:"clean_text"` // ANSI codes stripped
RawText string `json:"raw_text"` // Original with ANSI codes
State string `json:"state"` // "idle", "thinking", "permission", etc.
SessionID string `json:"session_id,omitempty"`
}
PTYOutputPayload represents processed terminal output.
type PTYPermissionPayload ¶
type PTYPermissionPayload struct {
ToolUseID string `json:"tool_use_id,omitempty"` // Claude's tool use ID (for hook bridge)
Type string `json:"type"` // "write_file", "edit_file", "bash_command"
Target string `json:"target"` // filename or command
Description string `json:"description"` // human-readable description
Preview string `json:"preview"` // content preview
Options []PTYPromptOption `json:"options"` // available choices
SessionID string `json:"session_id,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"` // workspace ID (for hook bridge)
}
PTYPermissionPayload represents a permission prompt from PTY mode.
type PTYPermissionResolvedPayload ¶
type PTYPermissionResolvedPayload struct {
ToolUseID string `json:"tool_use_id,omitempty"` // Claude's tool use ID (for hook bridge correlation)
SessionID string `json:"session_id"`
WorkspaceID string `json:"workspace_id,omitempty"`
ResolvedBy string `json:"resolved_by,omitempty"` // Client ID that resolved the permission
Input string `json:"input,omitempty"` // The input that was sent (e.g., "1", "enter")
Decision string `json:"decision,omitempty"` // "allow" or "deny" (for hook bridge)
}
PTYPermissionResolvedPayload represents that a permission prompt was responded to. This is broadcast to all devices so they can dismiss their permission popups.
type PTYPromptOption ¶
type PTYPromptOption struct {
Key string `json:"key"` // "1", "2", "n"
Label string `json:"label"` // "Yes", "Yes to all", "No"
Description string `json:"description,omitempty"` // optional extra info
Selected bool `json:"selected"` // true if this option has the cursor (❯)
}
PTYPromptOption represents a choice in a permission prompt.
type PTYSpinnerPayload ¶
type PTYSpinnerPayload struct {
Text string `json:"text"` // Full spinner text (e.g., "✶ Vibing…")
Symbol string `json:"symbol"` // Just the spinner symbol (e.g., "✶")
Message string `json:"message"` // Just the message (e.g., "Vibing…")
SessionID string `json:"session_id,omitempty"`
}
PTYSpinnerPayload represents spinner animation state (e.g., "✶ Vibing…").
type PTYStatePayload ¶
type PTYStatePayload struct {
State string `json:"state"`
WaitingForInput bool `json:"waiting_for_input"`
PromptType string `json:"prompt_type,omitempty"` // "write_file", "bash_command", etc.
SessionID string `json:"session_id,omitempty"`
}
PTYStatePayload represents PTY state change.
type ParsedClaudeMessage ¶
type ParsedClaudeMessage struct {
// Type is the message type: "assistant", "user", "result", "system", "init"
Type string `json:"type"`
// SessionID is the Claude session ID (present in most messages)
SessionID string `json:"session_id,omitempty"`
// Content is the array of content blocks in the message
Content []ParsedContentBlock `json:"content,omitempty"`
// StopReason indicates why Claude stopped (e.g., "end_turn", "tool_use")
// Empty string means still generating
StopReason string `json:"stop_reason,omitempty"`
// CostUSD is the cost in USD for result messages
CostUSD float64 `json:"cost_usd,omitempty"`
// DurationMS is the duration in milliseconds for result messages
DurationMS int64 `json:"duration_ms,omitempty"`
// OutputTokens is the number of tokens generated so far
// Use this to show "↓ 9.2k tokens" in UI
OutputTokens int `json:"output_tokens,omitempty"`
// IsThinking indicates Claude is in thinking/ideating mode
// True when content contains <thinking> tags or type="thinking" blocks
IsThinking bool `json:"is_thinking,omitempty"`
// IsContextCompaction is true when this is an auto-generated message
// created by Claude Code when the context window was maxed out.
// Content starts with "This session is being continued from a previous conversation"
IsContextCompaction bool `json:"is_context_compaction,omitempty"`
// Timestamp is the ISO 8601 timestamp from the Claude CLI JSONL output
Timestamp string `json:"timestamp,omitempty"`
// Model is the model used (e.g., "claude-opus-4-5-20251101")
Model string `json:"model,omitempty"`
}
ParsedClaudeMessage represents a parsed message from Claude CLI stream-json output.
type ParsedContentBlock ¶
type ParsedContentBlock struct {
// Type is the content type: "text", "thinking", "tool_use", "tool_result"
Type string `json:"type"`
// Text is the text content (for "text" and "thinking" types)
Text string `json:"text,omitempty"`
// ToolName is the tool being called (for "tool_use" type)
ToolName string `json:"tool_name,omitempty"`
// ToolID is the unique ID for this tool call (for "tool_use" type)
ToolID string `json:"tool_id,omitempty"`
// ToolInput is the raw JSON input for the tool (for "tool_use" type)
ToolInput string `json:"tool_input,omitempty"`
// FilePath is the file path for Read tool results (for image tool_result)
FilePath string `json:"file_path,omitempty"`
// ImageInfo contains metadata for image tool results
ImageInfo *ImageInfo `json:"image_info,omitempty"`
}
ParsedContentBlock represents a single content block from Claude's output.
type SessionEndPayload ¶
type SessionEndPayload struct {
SessionID string `json:"session_id"`
Reason string `json:"reason,omitempty"`
}
SessionEndPayload is the payload for session_end events.
type SessionIDFailedPayload ¶
type SessionIDFailedPayload struct {
TemporaryID string `json:"temporary_id"`
WorkspaceID string `json:"workspace_id"`
Reason string `json:"reason"` // "trust_declined", "claude_exited", "error"
Message string `json:"message,omitempty"`
}
SessionIDFailedPayload is the payload for session_id_failed events. Emitted when the user declines trust folder or Claude exits without creating a session.
type SessionIDResolvedPayload ¶
type SessionIDResolvedPayload struct {
TemporaryID string `json:"temporary_id"` // The temporary ID generated by cdev
RealID string `json:"real_id"` // The real session ID from Claude
WorkspaceID string `json:"workspace_id"`
SessionFile string `json:"session_file"` // Path to .jsonl file
}
SessionIDResolvedPayload is the payload for session_id_resolved events. Emitted when the real Claude session ID is detected from .claude/projects.
type SessionIDTimeoutPayload ¶
type SessionIDTimeoutPayload struct {
TemporaryID string `json:"temporary_id"`
WorkspaceID string `json:"workspace_id"`
TimeoutSeconds int `json:"timeout_seconds"`
Reason string `json:"reason"` // "timeout" or "cancelled"
}
SessionIDTimeoutPayload is the payload for session_id_timeout events. Emitted when the watcher times out waiting for a real session ID.
type SessionJoinedPayload ¶
type SessionJoinedPayload struct {
JoiningClientID string `json:"joining_client_id"`
OtherViewers []string `json:"other_viewers"`
ViewerCount int `json:"viewer_count"`
}
SessionJoinedPayload is the payload for session_joined events. Sent when a device joins a session that other devices are viewing.
type SessionLeftPayload ¶
type SessionLeftPayload struct {
LeavingClientID string `json:"leaving_client_id"`
RemainingViewers []string `json:"remaining_viewers"`
ViewerCount int `json:"viewer_count"`
}
SessionLeftPayload is the payload for session_left events. Sent when a device leaves a session that other devices are viewing.
type SessionStartPayload ¶
type SessionStartPayload struct {
SessionID string `json:"session_id"`
RepoPath string `json:"repo_path"`
RepoName string `json:"repo_name"`
AgentVersion string `json:"agent_version"`
}
SessionStartPayload is the payload for session_start events.
type SessionStoppedPayload ¶
type SessionStoppedPayload struct {
WorkspaceID string `json:"workspace_id"`
SessionID string `json:"session_id"`
}
SessionStoppedPayload is the payload for session_stopped events. Emitted when a session is stopped - allows all connected devices to sync their UI.
type StatusResponsePayload ¶
type StatusResponsePayload struct {
ClaudeState ClaudeState `json:"claude_state"`
ConnectedClients int `json:"connected_clients"`
RepoPath string `json:"repo_path"`
RepoName string `json:"repo_name"`
UptimeSeconds int64 `json:"uptime_seconds"`
AgentVersion string `json:"agent_version"`
WatcherEnabled bool `json:"watcher_enabled"`
GitEnabled bool `json:"git_enabled"`
}
StatusResponsePayload is the payload for status_response events.
type StreamReadCompletePayload ¶
type StreamReadCompletePayload struct {
SessionID string `json:"session_id"`
MessagesEmitted int `json:"messages_emitted"` // Number of messages read in this batch
FileOffset int64 `json:"file_offset"` // Current position in file
FileSize int64 `json:"file_size"` // Total file size when read
}
StreamReadCompletePayload represents the payload for stream_read_complete events. This is emitted when the JSONL file reader catches up to the current end of the file.
type StreamType ¶
type StreamType string
StreamType represents the output stream type.
const ( StreamStdout StreamType = "stdout" StreamStderr StreamType = "stderr" )
type WorkspaceRemovedPayload ¶
type WorkspaceRemovedPayload struct {
ID string `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
}
WorkspaceRemovedPayload represents the payload for workspace_removed events.