client

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

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

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 New

func New() *Client

New creates a new interactive client.

func (*Client) Close

func (c *Client) Close() error

Close terminates the session and cleans up resources.

func (*Client) GetMCPStatus

func (c *Client) GetMCPStatus(ctx context.Context) (*mcp.Status, error)

GetMCPStatus queries the CLI for live MCP server connection status.

func (*Client) GetServerInfo

func (c *Client) GetServerInfo() map[string]any

GetServerInfo returns server initialization info.

func (*Client) Interrupt

func (c *Client) Interrupt(ctx context.Context) error

Interrupt sends an interrupt signal to stop current processing.

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context) ([]model.Info, error)

ListModels queries the CLI for available models.

func (*Client) Query

func (c *Client) Query(ctx context.Context, prompt string, sessionID ...string) error

Query sends a user prompt to the agent.

func (*Client) ReceiveMessages

func (c *Client) ReceiveMessages(ctx context.Context) iter.Seq2[message.Message, error]

ReceiveMessages returns an iterator that yields messages indefinitely.

func (*Client) ReceiveResponse

func (c *Client) ReceiveResponse(ctx context.Context) iter.Seq2[message.Message, error]

ReceiveResponse returns an iterator that yields messages until a ResultMessage.

func (*Client) RewindFiles

func (c *Client) RewindFiles(ctx context.Context, userMessageID string) error

RewindFiles rewinds tracked files to their state at a specific user message.

func (*Client) SetModel

func (c *Client) SetModel(ctx context.Context, model *string) error

SetModel changes the AI model during conversation.

func (*Client) SetPermissionMode

func (c *Client) SetPermissionMode(ctx context.Context, mode string) error

SetPermissionMode changes the permission mode during conversation.

func (*Client) Start

func (c *Client) Start(ctx context.Context, options *config.Options) error

Start establishes a connection to the Codex CLI.

func (*Client) StartWithPrompt

func (c *Client) StartWithPrompt(
	ctx context.Context,
	prompt string,
	options *config.Options,
) error

StartWithPrompt establishes a connection and immediately sends an initial prompt.

func (*Client) StartWithStream

func (c *Client) StartWithStream(
	ctx context.Context,
	messages iter.Seq[message.StreamingMessage],
	options *config.Options,
) error

StartWithStream establishes a connection and streams initial messages.

Jump to

Keyboard shortcuts

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