This repository has been archived on 2026-05-07. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
ccrm/server/internal/ws/protocol.go

72 lines
1.7 KiB
Go

package ws
import "encoding/json"
// Message is the base type for parsing incoming WebSocket messages.
type Message struct {
Type string `json:"type"`
}
// --- Daemon → Server messages ---
type SessionStartedMsg struct {
Type string `json:"type"`
Session json.RawMessage `json:"session"`
}
type SessionEndedMsg struct {
Type string `json:"type"`
SessionName string `json:"session_name"`
}
type HookEventMsg struct {
Type string `json:"type"`
SessionName string `json:"session_name"`
Event json.RawMessage `json:"event"`
}
type PromptAckMsg struct {
Type string `json:"type"`
SessionName string `json:"session_name"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
}
type HeartbeatMsg struct {
Type string `json:"type"`
Sessions []string `json:"sessions"`
Timestamp string `json:"timestamp"`
}
// --- Server → Dashboard messages ---
type SessionUpdateMsg struct {
Type string `json:"type"` // "session.update"
Session any `json:"session"`
}
type EventNewMsg struct {
Type string `json:"type"` // "event.new"
SessionName string `json:"session_name"`
Event any `json:"event"`
}
type PromptAckDashboardMsg struct {
Type string `json:"type"` // "prompt.ack"
SessionName string `json:"session_name"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
}
// --- Dashboard → Server messages ---
type DashboardPromptSendMsg struct {
Type string `json:"type"` // "prompt.send"
SessionName string `json:"session_name"`
Prompt string `json:"prompt"`
}
type DashboardSessionKillMsg struct {
Type string `json:"type"` // "session.kill"
SessionName string `json:"session_name"`
}