codexrpc

package
v0.0.0-...-6c5c7c9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func StartProcess

func StartProcess(ctx context.Context, cfg ProcessConfig) (*Client, error)

func (*Client) Call

func (c *Client) Call(ctx context.Context, method string, params any, out any) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) HandleRequest

func (c *Client) HandleRequest(method string, fn func(ctx context.Context, req Request) (any, *RPCError))

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context, info ClientInfo, experimental bool) (string, error)

func (*Client) Notify

func (c *Client) Notify(ctx context.Context, method string, params any) error

func (*Client) OnNotification

func (c *Client) OnNotification(fn func(method string, params json.RawMessage))

type ClientInfo

type ClientInfo struct {
	Name    string `json:"name"`
	Title   string `json:"title,omitempty"`
	Version string `json:"version"`
}

type InitializeCapabilities

type InitializeCapabilities struct {
	ExperimentalAPI bool `json:"experimentalApi,omitempty"`
}

type Notification

type Notification struct {
	Method string          `json:"method"`
	Params json.RawMessage `json:"params,omitempty"`
}

type ProcessConfig

type ProcessConfig struct {
	Command string
	Args    []string
	Env     []string
	// OnStderr is called for each line of stderr output from the process.
	// If nil, stderr is silently discarded.
	OnStderr func(line string)
	// OnProcessExit is called when the process exits with its exit error (nil if exit code 0).
	OnProcessExit func(err error)
}

type RPCError

type RPCError struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

type Request

type Request struct {
	ID     json.RawMessage `json:"id,omitempty"`
	Method string          `json:"method"`
	Params json.RawMessage `json:"params,omitempty"`
}

type Response

type Response struct {
	ID     json.RawMessage `json:"id"`
	Result json.RawMessage `json:"result,omitempty"`
	Error  *RPCError       `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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