Documentation
¶
Overview ¶
Package client implements the interactive Client for multi-turn conversations with the agent.
The client package provides a stateful, bidirectional interface to the Codex CLI that maintains session state across multiple exchanges. Unlike the one-shot Query() function, Client enables:
- Multi-turn conversations with persistent context
- Interruption of the agent's processing
- Dynamic configuration changes (model, permissions)
- Hook system integration for tool permission management
The Client uses the protocol package for bidirectional control message handling and manages its own goroutines for message reading and routing.
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) GetMCPStatus(ctx context.Context) (*mcp.Status, error)
- func (c *Client) GetServerInfo() map[string]any
- func (c *Client) Interrupt(ctx context.Context) error
- func (c *Client) ListModels(ctx context.Context) ([]model.Info, error)
- func (c *Client) Query(ctx context.Context, prompt string, sessionID ...string) error
- func (c *Client) ReceiveMessages(ctx context.Context) iter.Seq2[message.Message, error]
- func (c *Client) ReceiveResponse(ctx context.Context) iter.Seq2[message.Message, error]
- func (c *Client) RewindFiles(ctx context.Context, userMessageID string) error
- func (c *Client) SetModel(ctx context.Context, model *string) error
- func (c *Client) SetPermissionMode(ctx context.Context, mode string) error
- func (c *Client) Start(ctx context.Context, options *config.Options) error
- func (c *Client) StartWithPrompt(ctx context.Context, prompt string, options *config.Options) error
- func (c *Client) StartWithStream(ctx context.Context, messages iter.Seq[message.StreamingMessage], ...) error
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
}
Client implements the interactive client interface.
func (*Client) GetMCPStatus ¶
GetMCPStatus queries the CLI for live MCP server connection status.
func (*Client) GetServerInfo ¶
GetServerInfo returns server initialization info.
func (*Client) ListModels ¶
ListModels queries the CLI for available models.
func (*Client) ReceiveMessages ¶
ReceiveMessages returns an iterator that yields messages indefinitely.
func (*Client) ReceiveResponse ¶
ReceiveResponse returns an iterator that yields messages until a ResultMessage.
func (*Client) RewindFiles ¶
RewindFiles rewinds tracked files to their state at a specific user message.
func (*Client) SetPermissionMode ¶
SetPermissionMode changes the permission mode during conversation.