package ws import "encoding/json" // ── Client → Server messages ── // MsgType enumerates known message types. type MsgType string const ( MsgStart MsgType = "start" // Begin recording session MsgStop MsgType = "stop" // End recording session MsgPaste MsgType = "paste" // Re-paste a history item ) // ClientMsg is a JSON control message from the phone. type ClientMsg struct { Type MsgType `json:"type"` Text string `json:"text,omitempty"` // Only for "paste" } // ── Server → Client messages ── const ( MsgPartial MsgType = "partial" // Interim ASR result MsgFinal MsgType = "final" // Final ASR result MsgPasted MsgType = "pasted" // Paste confirmed MsgError MsgType = "error" // Error notification ) // ServerMsg is a JSON message sent to the phone. type ServerMsg struct { Type MsgType `json:"type"` Text string `json:"text,omitempty"` Message string `json:"message,omitempty"` // For errors } func (m ServerMsg) Bytes() []byte { b, _ := json.Marshal(m) return b }