8 // socketFileName is the Unix socket of the daemon in the data
10 socketFileName = "onechat.sock"
12 // socketRequestBytes is the most bytes of one request line of a client.
13 socketRequestBytes = 16 << 20
15 // socketPathBytes is the longest path of a Unix socket on Linux.
18 // terminalSource is the source of the user messages from the clients of
20 terminalSource = "terminal"
23 // checkSocketPath makes sure that path fits in the address of a Unix socket.
24 func checkSocketPath(path string) error {
25 if len(path) > socketPathBytes {
26 return fmt.Errorf("socket path %s is longer than %d bytes: set ONECHAT_DIR to a shorter path", path, socketPathBytes)
32 // SocketRequest is one line from a client: "send" with the text of a user
33 // message, "interrupt", "stop" with the name of a subagent in Text, or
34 // "whatsapp" with the text after /whatsapp of a WhatsApp command, or "backup"
35 // with the absolute output path in Text. The backup answer is a "backup" event
36 // with the path and size, or an "error" event. An "image" request has an
37 // absolute Path and the caption in Text.
38 type SocketRequest struct {
39 Type string `json:"type"`
40 Text string `json:"text,omitempty"`
41 Path string `json:"path,omitempty"`