// Package protocol defines the messages exchanged over the websockets between // the browser UI, wxch-server and wxch-agent. Keeping one definition here means // the three sides cannot drift apart. package protocol import "encoding/json" // Msg is the single envelope used on every websocket. T selects the meaning; // only the fields relevant to that type are set. // // Terminal: open, in, out, resize, close, exit (Sid, D, Cols, Rows, Script) // RPC: rpc, rpc_event, rpc_result, update (ID, Method, Params, Data, OK, Err) // Inference: infer, infer_start, infer_chunk, // // infer_end, infer_cancel (ID, Method=path, Params=body, D, Status, Err) // // Telemetry: stats, hist (Agent, Data) // Other: agents (List) type Msg struct { T string `json:"t"` Sid string `json:"sid,omitempty"` Agent string `json:"agent,omitempty"` D string `json:"d,omitempty"` Cols int `json:"cols,omitempty"` Rows int `json:"rows,omitempty"` List []string `json:"list,omitempty"` Script string `json:"script,omitempty"` ID string `json:"id,omitempty"` Method string `json:"method,omitempty"` Params json.RawMessage `json:"params,omitempty"` Data json.RawMessage `json:"data,omitempty"` OK bool `json:"ok,omitempty"` Err string `json:"err,omitempty"` Status int `json:"status,omitempty"` }