Help us shape the future of Go! Take the 2026 Go Developer Survey

ipc

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeUnknownServer = "unknown_server"
	ErrorCodeInputRequired = "input_required"
)
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 EphemeralServer added in v1.0.0

type EphemeralServer struct {
	Server config.ServerConfig `json:"server"`
}

EphemeralServer carries a transient server definition to be registered by the daemon for the current runtime lifetime only.

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"`             // "ping", "list_servers", "list_tools", "call_tool", "tool_schema", "diagnose_server", "prepare_credential_transition", "reload_server", "shutdown"
	CWD    string `json:"cwd,omitempty"`    // caller working directory
	Server string `json:"server,omitempty"` // target server name
	// Transition identifies a fail-closed OAuth credential lifecycle operation.
	Transition string          `json:"transition,omitempty"`
	Tool       string          `json:"tool,omitempty"` // target tool name
	Args       json.RawMessage `json:"args,omitempty"` // tool arguments
	// ArgsFromJSON distinguishes lossless positional/stdin JSON from shell
	// flags, which cannot represent every valid JSON Schema composition.
	ArgsFromJSON bool `json:"args_from_json,omitempty"`
	// InputResponses and RequestState resume a 2026-07-28 multi-round-trip
	// request. RequestState is opaque and must be echoed without interpretation.
	InputResponses json.RawMessage `json:"input_responses,omitempty"`
	RequestState   string          `json:"request_state,omitempty"`
	Cache          *time.Duration  `json:"cache,omitempty"` // cache TTL override
	Verbose        bool            `json:"verbose,omitempty"`
	// IncludeSchemas asks list_tools for a deterministic full catalog rather
	// than the compact discovery view.
	IncludeSchemas bool `json:"include_schemas,omitempty"`
	// IncludeHidden asks daemon responses (currently list_servers) to include
	// otherwise hidden runtime-only servers.
	IncludeHidden bool             `json:"include_hidden,omitempty"`
	Ephemeral     *EphemeralServer `json:"ephemeral,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
	ErrorCode string `json:"error_code,omitempty"` // stable machine-readable error classification
}

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