Documentation
¶
Overview ¶
Package appserver is a second client of the session's private Codex app-server: JSON-RPC 2.0 over a Dialer (WebSocket over the unix socket per research §3.6, with a newline JSON-RPC fallback). It initializes with experimentalApi, resumes each thread (thread/resume with excludeTurns) so it receives that thread's notifications, writes thread/settings/update so the Codex footer shows the routed model, and surfaces thread/settings/updated notifications so the router can tell its own echo from a manual /model pin.
Index ¶
Constants ¶
const ( MethodInitialize = "initialize" MethodInitialized = "initialized" MethodResume = "thread/resume" MethodSettingsUpdate = "thread/settings/update" MethodSettingsUpdated = "thread/settings/updated" )
JSON-RPC method names used.
Variables ¶
var ErrClosed = errors.New("appserver: connection closed")
ErrClosed is returned by calls made on, or pending at, a closed connection.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
Initialize(ctx context.Context) error
Resume(ctx context.Context, threadID string) error
UpdateSettings(ctx context.Context, threadID string, s Settings) error
Updates() <-chan SettingsUpdated
Close() error
}
API is what the launcher uses; Client implements it.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a JSON-RPC client over one Conn. A caller's ctx that ends while its call waits for the write slot or the reply abandons only that call; it does not interrupt a write in progress. A write that does not finish within writeTimeout closes the connection, because a partly written message leaves the stream unusable.
func (*Client) Close ¶
Close closes the connection, fails pending calls with ErrClosed and waits for the client's goroutines to stop. It returns the first error from closing the connection.
func (*Client) Initialize ¶
Initialize performs the initialize handshake with experimentalApi enabled (thread/settings/update is experimental) and sends initialized.
func (*Client) Resume ¶
Resume subscribes this client to a thread's turn and settings notifications with thread/resume {threadId, excludeTurns: true}; the app-server sends them only to clients that resumed the thread. A thread that cannot be resumed, such as one without a rollout (-32600 "no rollout found"), comes back as an *RPCError the caller may ignore: settings writes to it still work.
func (*Client) UpdateSettings ¶
UpdateSettings sets the thread's model and effort for subsequent turns. An empty field is omitted, which leaves that setting unchanged.
func (*Client) Updates ¶
func (c *Client) Updates() <-chan SettingsUpdated
Updates yields thread/settings/updated notifications in arrival order. It is closed when the connection ends.
type Conn ¶
type Conn interface {
Read(ctx context.Context) ([]byte, error)
Write(ctx context.Context, msg []byte) error
Close() error
}
Conn is one message-oriented connection to the app-server. Cancelling the ctx of a Read or Write may close the connection.
type SettingsUpdated ¶
SettingsUpdated is a thread/settings/updated notification.