ipc

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitOK       = 0
	ExitToolErr  = 1
	ExitUsageErr = 2
	ExitInternal = 3
)

Exit codes.

Variables

This section is empty.

Functions

func SocketPath

func SocketPath() string

SocketPath returns the daemon socket path (convenience re-export).

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client sends requests to the daemon over a Unix socket.

func NewClient

func NewClient(socketPath, nonce string) *Client

NewClient creates a new IPC client.

func (*Client) Send

func (c *Client) Send(req *Request) (*Response, error)

Send sends a request to the daemon and returns the response.

type Handler

type Handler func(ctx context.Context, req *Request) *Response

Handler processes an IPC request and returns a response.

type Request

type Request struct {
	Nonce   string          `json:"nonce"`            // daemon nonce for auth
	Type    string          `json:"type"`             // "list_servers", "list_tools", "call_tool", "tool_schema", "shutdown"
	Server  string          `json:"server,omitempty"` // target server name
	Tool    string          `json:"tool,omitempty"`   // target tool name
	Args    json.RawMessage `json:"args,omitempty"`   // tool arguments
	Cache   *time.Duration  `json:"cache,omitempty"`  // cache TTL override
	Verbose bool            `json:"verbose,omitempty"`
}

Request is sent from the CLI to the daemon over the Unix socket.

type Response

type Response struct {
	Content  []byte `json:"content"`          // raw output for stdout
	ExitCode int    `json:"exit_code"`        // 0=ok, 1=tool error, 2=usage error, 3=internal error
	Stderr   string `json:"stderr,omitempty"` // error message for stderr
}

Response is sent from the daemon back to the CLI.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server listens for IPC connections on a Unix socket.

func NewServer

func NewServer(socketPath, nonce string, handler Handler) *Server

NewServer creates a new IPC server.

func (*Server) Start

func (s *Server) Start() error

Start begins listening for connections. It removes any stale socket file first.

func (*Server) Stop

func (s *Server) Stop()

Stop closes the listener and waits for in-flight connections.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL