Documentation
¶
Index ¶
- func TitleFromMessage(text, fallback string) string
- type AppServer
- func (s *AppServer) Done() <-chan struct{}
- func (s *AppServer) InputEvents() <-chan UserInputEvent
- func (s *AppServer) Notify(ctx context.Context, method string, params interface{}) error
- func (s *AppServer) ReplyUserInput(id int64, answers interface{}) error
- func (s *AppServer) Request(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
- func (s *AppServer) Stderr() string
- func (s *AppServer) Stop()
- func (s *AppServer) Subscribe(threadID string) <-chan CodexEvent
- func (s *AppServer) Unsubscribe(threadID string)
- type Client
- func (c *Client) BaseURL() string
- func (c *Client) CreateSession(ctx context.Context, directory string) (*Session, error)
- func (c *Client) GetSession(ctx context.Context, sessionID string) (*Session, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) ListMessages(ctx context.Context, sessionID string) ([]MessageResponse, error)
- func (c *Client) ListProviders(ctx context.Context) ([]Provider, []string, error)
- func (c *Client) ListSessions(ctx context.Context) ([]Session, error)
- func (c *Client) ReplyQuestion(ctx context.Context, requestID string, answers [][]string) error
- func (c *Client) SendMessageEvents(ctx context.Context, sessionID, text, providerID, modelID, agent string) <-chan StreamEvent
- func (c *Client) ServerProcess() interface{ ... }
- type CodexEvent
- type MessageInfo
- type MessageResponse
- type Model
- type ModelRef
- type Part
- type Provider
- type QuestionInfo
- type QuestionRequest
- type Session
- type SessionTime
- type StreamEvent
- type UserInputEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TitleFromMessage ¶
Types ¶
type AppServer ¶
type AppServer struct {
// contains filtered or unexported fields
}
AppServer manages a `codex app-server` child process and speaks the Codex App Server Protocol (JSON-RPC over stdio) with it.
func NewAppServer ¶
NewAppServer spawns `codex app-server`, initializes the JSON-RPC protocol, and returns a ready AppServer.
func (*AppServer) Done ¶
func (s *AppServer) Done() <-chan struct{}
Done returns a channel that is closed when the read loop exits.
func (*AppServer) InputEvents ¶
func (s *AppServer) InputEvents() <-chan UserInputEvent
InputEvents returns a channel that receives user-input requests from the app-server. Only one caller should read from this channel at a time.
func (*AppServer) ReplyUserInput ¶
ReplyUserInput sends the user's answer for a deferred item/tool/requestUserInput request back to the app-server.
func (*AppServer) Request ¶
func (s *AppServer) Request(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
Request sends a JSON-RPC request and waits for the matching response.
func (*AppServer) Stop ¶
func (s *AppServer) Stop()
Stop kills the app-server process and cleans up goroutines.
func (*AppServer) Subscribe ¶
func (s *AppServer) Subscribe(threadID string) <-chan CodexEvent
Subscribe registers a channel to receive CodexEvents for the given threadID.
func (*AppServer) Unsubscribe ¶
Unsubscribe removes the listener for threadID and closes its channel.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements Backend by communicating with a persistent `codex app-server` process over JSON-RPC stdio.
func (*Client) CreateSession ¶
func (*Client) GetSession ¶
func (*Client) ListMessages ¶
func (*Client) ListProviders ¶
func (*Client) ReplyQuestion ¶
func (*Client) SendMessageEvents ¶
func (c *Client) SendMessageEvents(ctx context.Context, sessionID, text, providerID, modelID, agent string) <-chan StreamEvent
func (*Client) ServerProcess ¶
func (c *Client) ServerProcess() interface { Stop() Done() <-chan struct{} }
ServerProcess returns the managed process for lifecycle control.
type CodexEvent ¶
type CodexEvent struct {
Method string
Params json.RawMessage
ThreadID string
TurnID string
ItemID string
Delta string
Message string
Status string
}
CodexEvent is a parsed notification from the Codex app-server.
type MessageInfo ¶
type MessageResponse ¶
type MessageResponse struct {
Info MessageInfo `json:"info"`
Parts []Part `json:"parts"`
}
type QuestionInfo ¶
type QuestionRequest ¶
type QuestionRequest struct {
ID string `json:"id"`
SessionID string `json:"sessionID"`
Questions []QuestionInfo `json:"questions"`
}
type Session ¶
type Session struct {
ID string `json:"id"`
Title string `json:"title"`
Directory string `json:"directory"`
Model *ModelRef `json:"model"`
Time SessionTime `json:"time"`
}
type SessionTime ¶
type StreamEvent ¶
type StreamEvent struct {
Text string
Question *QuestionRequest
}
type UserInputEvent ¶
type UserInputEvent struct {
ID int64
Params json.RawMessage
}
UserInputEvent is emitted when the app-server asks for user input via item/tool/requestUserInput.