appserver

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package appserver owns the Codex stdio RPC connection and its child process. Callers interpret lifecycle notifications and provide presentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Input

func Input(text string) []map[string]any

Types

type Client

type Client struct {
	Input    io.WriteCloser
	Output   io.ReadCloser
	Messages chan Message

	Done        chan error
	Diagnostics Diagnostics
	// contains filtered or unexported fields
}

func Start

func Start(cmd *exec.Cmd) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Initialize

func (c *Client) Initialize() (string, error)

func (*Client) Respond

func (c *Client) Respond(id jsontext.Value, result any) error

Respond answers a server-originated request using its original JSON-RPC ID.

func (*Client) Send

func (c *Client) Send(method string, params any, request bool) (string, error)

func (*Client) Shutdown

func (c *Client) Shutdown() error

EOF is Codex's graceful shutdown signal. Allow its thread/background-task owners to drain before falling back to forced cleanup.

type Diagnostics

type Diagnostics struct {
	sync.Mutex
	Text []byte
}

Diagnostics never share the RPC stream or write through the terminal painter.

func (*Diagnostics) Write

func (d *Diagnostics) Write(p []byte) (int, error)

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Message

type Message struct {
	ID     jsontext.Value `json:"id,omitempty"`
	Method string         `json:"method,omitempty"`
	Params jsontext.Value `json:"params,omitzero"`
	Result jsontext.Value `json:"result,omitempty"`
	Error  *Error         `json:"error,omitempty"`
}

Wire subset from codex-rs/app-server-protocol/src/protocol/{common,v2}.rs at 86be5320; exercised against codex-cli 0.157.1. initialize is not version negotiation. Unknown notifications are ignored, not inferred from their text.

Jump to

Keyboard shortcuts

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