package main import ( "fmt" ) const ( // socketFileName is the Unix socket of the daemon in the data // directory. socketFileName = "onechat.sock" // socketRequestBytes is the most bytes of one request line of a client. socketRequestBytes = 16 << 20 // socketPathBytes is the longest path of a Unix socket on Linux. socketPathBytes = 107 // terminalSource is the source of the user messages from the clients of // the socket. terminalSource = "terminal" ) // checkSocketPath makes sure that path fits in the address of a Unix socket. func checkSocketPath(path string) error { if len(path) > socketPathBytes { return fmt.Errorf("socket path %s is longer than %d bytes: set ONECHAT_DIR to a shorter path", path, socketPathBytes) } return nil } // SocketRequest is one line from a client: "send" with the text of a user // message, "interrupt", or "stop" with the name of a subagent in Text. type SocketRequest struct { Type string `json:"type"` Text string `json:"text,omitempty"` }