82 lines
2.3 KiB
Go
82 lines
2.3 KiB
Go
package relay
|
|
|
|
import "encoding/json"
|
|
|
|
// Message is the base type for all WebSocket messages.
|
|
type Message struct {
|
|
Type string `json:"type"`
|
|
Raw json.RawMessage `json:"-"` // full original message
|
|
}
|
|
|
|
// --- Daemon → Server messages ---
|
|
|
|
type SessionStartedMsg struct {
|
|
Type string `json:"type"` // "session.started"
|
|
Session any `json:"session"`
|
|
}
|
|
|
|
type SessionEndedMsg struct {
|
|
Type string `json:"type"` // "session.ended"
|
|
SessionName string `json:"session_name"`
|
|
}
|
|
|
|
type HookEventMsg struct {
|
|
Type string `json:"type"` // "hook.event"
|
|
SessionName string `json:"session_name"`
|
|
Event any `json:"event"`
|
|
}
|
|
|
|
type PromptAckMsg struct {
|
|
Type string `json:"type"` // "prompt.ack"
|
|
SessionName string `json:"session_name"`
|
|
Status string `json:"status"` // "sent", "queued", "rejected"
|
|
Reason string `json:"reason,omitempty"`
|
|
}
|
|
|
|
type HeartbeatMsg struct {
|
|
Type string `json:"type"` // "heartbeat"
|
|
Sessions []string `json:"sessions"`
|
|
Timestamp string `json:"timestamp"`
|
|
}
|
|
|
|
// --- Server → Daemon messages ---
|
|
|
|
type PromptSendMsg struct {
|
|
Type string `json:"type"` // "prompt.send"
|
|
SessionName string `json:"session_name"`
|
|
Prompt string `json:"prompt"`
|
|
}
|
|
|
|
type SessionsListMsg struct {
|
|
Type string `json:"type"` // "sessions.list"
|
|
}
|
|
|
|
type SessionKillMsg struct {
|
|
Type string `json:"type"` // "session.kill"
|
|
SessionName string `json:"session_name"`
|
|
}
|
|
|
|
type SessionStartMsg struct {
|
|
Type string `json:"type"` // "session.start"
|
|
Name string `json:"name"`
|
|
Path string `json:"path"`
|
|
ClaudeArgs []string `json:"claude_args"`
|
|
}
|
|
|
|
// --- Permission messages (for future dashboard approval flow) ---
|
|
|
|
type PermissionRequestMsg struct {
|
|
Type string `json:"type"` // "permission.request"
|
|
SessionName string `json:"session_name"`
|
|
RequestID string `json:"request_id"`
|
|
ToolName string `json:"tool_name"`
|
|
ToolInput json.RawMessage `json:"tool_input"`
|
|
}
|
|
|
|
type PermissionRespondMsg struct {
|
|
Type string `json:"type"` // "permission.respond"
|
|
SessionName string `json:"session_name"`
|
|
RequestID string `json:"request_id"`
|
|
Decision string `json:"decision"` // "allow" or "deny"
|
|
Reason string `json:"reason,omitempty"`
|
|
}
|