Documentation
¶
Overview ¶
Package codex provides an idiomatic Go SDK for the Codex app-server.
The SDK spawns the `codex app-server` process (or uses a custom transport) and exposes a high-level facade for accounts, models, threads, turns, and streaming turn control. For lower-level access, you can reach the JSON-RPC client via (*Codex).Client().
Typical usage:
ctx := context.Background()
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelInfo}))
prompt := "Diagnose the test failure and propose a fix"
client, err := codex.New(ctx, codex.Options{Logger: logger})
if err != nil {
panic(err)
}
defer client.Close()
The constructor context is used for initialization only. Once New returns successfully, the spawned app-server lifetime is managed by Close.
thread, err := client.StartThread(ctx, codex.ThreadStartOptions{})
if err != nil {
panic(err)
}
result, err := thread.Run(ctx, prompt, nil)
if err != nil {
panic(err)
}
fmt.Println(result.FinalResponse)
For a running turn that needs steering or interruption, start a turn handle:
handle, err := thread.StartTurn(ctx, []codex.Input{codex.TextInput("Inspect the repo")}, nil)
if err != nil {
panic(err)
}
defer handle.Close()
_, err = handle.Steer(ctx, []codex.Input{codex.TextInput("Focus on tests")})
if err != nil {
panic(err)
}
result, err = handle.Run(ctx)
if err != nil {
panic(err)
}
Account, model, and thread lifecycle helpers cover common app-server calls:
account, err := client.Account(ctx, codex.AccountOptions{})
models, err := client.ListModels(ctx, codex.ListModelsOptions{})
threads, err := client.ListThreads(ctx, codex.ThreadListOptions{})
_ = account
_ = models
_ = threads
JSON-typed options (approval policies, sandbox policies, output schemas, etc.) accept any JSON-marshalable value. If you already have raw JSON, pass json.RawMessage or codex.MustJSON(...) to avoid double encoding.
For common values, prefer typed constants:
- codex.ApprovalPolicyNever / codex.ApprovalPolicyOnRequest / ...
- codex.SandboxModeReadOnly / codex.SandboxModeWorkspaceWrite / ...
- codex.ReasoningEffortLow / codex.ReasoningEffortMedium / ...
Retryable overload errors can be detected with codex.IsRetryable or codex.IsOverloaded. Both helpers work with wrapped errors.
Index ¶
- Constants
- Variables
- func IsOverloaded(err error) bool
- func IsRetryable(err error) bool
- type AccountOptions
- type ApprovalPolicy
- type AutoApproveHandler
- func (h AutoApproveHandler) AccountChatgptAuthTokensRefresh(ctx context.Context, params protocol.ChatgptAuthTokensRefreshParams) (*protocol.ChatgptAuthTokensRefreshResponse, error)
- func (h AutoApproveHandler) ApplyPatchApproval(ctx context.Context, params protocol.ApplyPatchApprovalParams) (*protocol.ApplyPatchApprovalResponse, error)
- func (h AutoApproveHandler) AttestationGenerate(ctx context.Context, params protocol.AttestationGenerateParams) (*protocol.AttestationGenerateResponse, error)
- func (h AutoApproveHandler) ExecCommandApproval(ctx context.Context, params protocol.ExecCommandApprovalParams) (*protocol.ExecCommandApprovalResponse, error)
- func (h AutoApproveHandler) ItemCommandExecutionRequestApproval(ctx context.Context, params protocol.CommandExecutionRequestApprovalParams) (*protocol.CommandExecutionRequestApprovalResponse, error)
- func (h AutoApproveHandler) ItemFileChangeRequestApproval(ctx context.Context, params protocol.FileChangeRequestApprovalParams) (*protocol.FileChangeRequestApprovalResponse, error)
- func (h AutoApproveHandler) ItemPermissionsRequestApproval(ctx context.Context, params protocol.PermissionsRequestApprovalParams) (*protocol.PermissionsRequestApprovalResponse, error)
- func (h AutoApproveHandler) ItemToolCall(ctx context.Context, params protocol.DynamicToolCallParams) (*protocol.DynamicToolCallResponse, error)
- func (h AutoApproveHandler) ItemToolRequestUserInput(ctx context.Context, params protocol.ToolRequestUserInputParams) (*protocol.ToolRequestUserInputResponse, error)
- func (h AutoApproveHandler) McpServerElicitationRequest(ctx context.Context, params protocol.McpServerElicitationRequestParams) (*protocol.McpServerElicitationRequestResponse, error)
- type Codex
- func (c *Codex) Account(ctx context.Context, opts AccountOptions) (*protocol.GetAccountResponse, error)
- func (c *Codex) ArchiveThread(ctx context.Context, threadID string) (*protocol.ThreadArchiveResponse, error)
- func (c *Codex) CancelLogin(ctx context.Context, loginID string) (*protocol.CancelLoginAccountResponse, error)
- func (c *Codex) Client() *rpc.Client
- func (c *Codex) Close() error
- func (c *Codex) CompactThread(ctx context.Context, threadID string, opts ThreadCompactOptions) (*protocol.ThreadCompactStartResponse, error)
- func (c *Codex) ForkThread(ctx context.Context, threadID string, opts ThreadForkOptions) (*Thread, protocol.ThreadForkResponse, error)
- func (c *Codex) ListModels(ctx context.Context, opts ListModelsOptions) (*protocol.ModelListResponse, error)
- func (c *Codex) ListThreads(ctx context.Context, opts ThreadListOptions) (*protocol.ThreadListResponse, error)
- func (c *Codex) Logout(ctx context.Context) (*protocol.LogoutAccountResponse, error)
- func (c *Codex) ReadThread(ctx context.Context, threadID string, opts ThreadReadOptions) (*protocol.ThreadReadResponse, error)
- func (c *Codex) ResumeThread(ctx context.Context, options ThreadResumeOptions) (*Thread, error)
- func (c *Codex) SetThreadName(ctx context.Context, threadID, name string) (*protocol.ThreadSetNameResponse, error)
- func (c *Codex) StartLogin(ctx context.Context, params protocol.LoginAccountParams) (*protocol.LoginAccountResponse, error)
- func (c *Codex) StartThread(ctx context.Context, options ThreadStartOptions) (*Thread, error)
- func (c *Codex) UnarchiveThread(ctx context.Context, threadID string) (*protocol.ThreadUnarchiveResponse, error)
- type Input
- type ListModelsOptions
- type Options
- type RawJSON
- type ReasoningEffort
- type SandboxMode
- type SpawnOptions
- type Thread
- func (t *Thread) Archive(ctx context.Context) (*protocol.ThreadArchiveResponse, error)
- func (t *Thread) Compact(ctx context.Context, opts ThreadCompactOptions) (*protocol.ThreadCompactStartResponse, error)
- func (t *Thread) Fork(ctx context.Context, opts ThreadForkOptions) (*Thread, protocol.ThreadForkResponse, error)
- func (t *Thread) ID() string
- func (t *Thread) Read(ctx context.Context, opts ThreadReadOptions) (*protocol.ThreadReadResponse, error)
- func (t *Thread) Run(ctx context.Context, prompt string, opts *TurnOptions) (*TurnResult, error)
- func (t *Thread) RunInputs(ctx context.Context, inputs []Input, opts *TurnOptions) (*TurnResult, error)
- func (t *Thread) RunStreamed(ctx context.Context, inputs []Input, opts *TurnOptions) (*TurnStream, error)
- func (t *Thread) SetName(ctx context.Context, name string) (*protocol.ThreadSetNameResponse, error)
- func (t *Thread) StartTurn(ctx context.Context, inputs []Input, opts *TurnOptions) (*TurnHandle, error)
- func (t *Thread) Unarchive(ctx context.Context) (*protocol.ThreadUnarchiveResponse, error)
- type ThreadCompactOptions
- type ThreadForkOptions
- type ThreadListOptions
- type ThreadReadOptions
- type ThreadResumeHistoryElem
- type ThreadResumeOptions
- type ThreadStartOptions
- type TurnHandle
- func (h *TurnHandle) Close()
- func (h *TurnHandle) Interrupt(ctx context.Context) (*protocol.TurnInterruptResponse, error)
- func (h *TurnHandle) Next(ctx context.Context) (rpc.Notification, error)
- func (h *TurnHandle) Run(ctx context.Context) (*TurnResult, error)
- func (h *TurnHandle) Steer(ctx context.Context, inputs []Input) (*protocol.TurnSteerResponse, error)
- func (h *TurnHandle) Stream() (*TurnStream, error)
- type TurnOptions
- type TurnResult
- type TurnStream
Constants ¶
const ( // InputTypeText represents a plain text input. InputTypeText = "text" // InputTypeImage represents a remote image input. InputTypeImage = "image" // InputTypeLocalImage represents a local image input. InputTypeLocalImage = "localImage" // InputTypeSkill represents a skill invocation input. InputTypeSkill = "skill" )
Variables ¶
var ErrOverloaded = errors.New("codex overloaded")
ErrOverloaded identifies retryable overload or server-busy failures.
Functions ¶
func IsOverloaded ¶
IsOverloaded reports whether err indicates an overload or server-busy failure.
func IsRetryable ¶
IsRetryable reports whether err is safe for SDK callers to retry.
Types ¶
type AccountOptions ¶
type AccountOptions struct {
// RefreshToken requests a proactive token refresh before account data is returned.
RefreshToken bool
}
AccountOptions configures an account/read request.
type ApprovalPolicy ¶
type ApprovalPolicy = string
ApprovalPolicy is a typed alias for common approval policy values.
const ( ApprovalPolicyNever ApprovalPolicy = "never" ApprovalPolicyOnFailure ApprovalPolicy = "on-failure" ApprovalPolicyOnRequest ApprovalPolicy = "on-request" ApprovalPolicyUntrusted ApprovalPolicy = "untrusted" )
type AutoApproveHandler ¶
AutoApproveHandler accepts every approval request it can. Logger controls approval logging. When nil, logs are discarded.
func (AutoApproveHandler) AccountChatgptAuthTokensRefresh ¶
func (h AutoApproveHandler) AccountChatgptAuthTokensRefresh(ctx context.Context, params protocol.ChatgptAuthTokensRefreshParams) (*protocol.ChatgptAuthTokensRefreshResponse, error)
AccountChatgptAuthTokensRefresh returns an error for auth refresh requests.
func (AutoApproveHandler) ApplyPatchApproval ¶
func (h AutoApproveHandler) ApplyPatchApproval(ctx context.Context, params protocol.ApplyPatchApprovalParams) (*protocol.ApplyPatchApprovalResponse, error)
ApplyPatchApproval approves legacy patch requests.
func (AutoApproveHandler) AttestationGenerate ¶
func (h AutoApproveHandler) AttestationGenerate(ctx context.Context, params protocol.AttestationGenerateParams) (*protocol.AttestationGenerateResponse, error)
AttestationGenerate returns an error for attestation generation requests.
func (AutoApproveHandler) ExecCommandApproval ¶
func (h AutoApproveHandler) ExecCommandApproval(ctx context.Context, params protocol.ExecCommandApprovalParams) (*protocol.ExecCommandApprovalResponse, error)
ExecCommandApproval approves legacy command requests.
func (AutoApproveHandler) ItemCommandExecutionRequestApproval ¶
func (h AutoApproveHandler) ItemCommandExecutionRequestApproval(ctx context.Context, params protocol.CommandExecutionRequestApprovalParams) (*protocol.CommandExecutionRequestApprovalResponse, error)
ItemCommandExecutionRequestApproval approves command execution requests.
func (AutoApproveHandler) ItemFileChangeRequestApproval ¶
func (h AutoApproveHandler) ItemFileChangeRequestApproval(ctx context.Context, params protocol.FileChangeRequestApprovalParams) (*protocol.FileChangeRequestApprovalResponse, error)
ItemFileChangeRequestApproval approves file change requests.
func (AutoApproveHandler) ItemPermissionsRequestApproval ¶
func (h AutoApproveHandler) ItemPermissionsRequestApproval(ctx context.Context, params protocol.PermissionsRequestApprovalParams) (*protocol.PermissionsRequestApprovalResponse, error)
ItemPermissionsRequestApproval approves permission escalation requests.
func (AutoApproveHandler) ItemToolCall ¶
func (h AutoApproveHandler) ItemToolCall(ctx context.Context, params protocol.DynamicToolCallParams) (*protocol.DynamicToolCallResponse, error)
ItemToolCall returns an error for dynamic tool calls.
func (AutoApproveHandler) ItemToolRequestUserInput ¶
func (h AutoApproveHandler) ItemToolRequestUserInput(ctx context.Context, params protocol.ToolRequestUserInputParams) (*protocol.ToolRequestUserInputResponse, error)
ItemToolRequestUserInput returns an error for tool user input prompts.
func (AutoApproveHandler) McpServerElicitationRequest ¶
func (h AutoApproveHandler) McpServerElicitationRequest(ctx context.Context, params protocol.McpServerElicitationRequestParams) (*protocol.McpServerElicitationRequestResponse, error)
McpServerElicitationRequest returns an error for MCP elicitation prompts.
type Codex ¶
type Codex struct {
// contains filtered or unexported fields
}
Codex is the main entrypoint for the Go SDK.
func (*Codex) Account ¶
func (c *Codex) Account(ctx context.Context, opts AccountOptions) (*protocol.GetAccountResponse, error)
Account returns account state from the app-server.
func (*Codex) ArchiveThread ¶
func (c *Codex) ArchiveThread(ctx context.Context, threadID string) (*protocol.ThreadArchiveResponse, error)
ArchiveThread archives a thread by id.
func (*Codex) CancelLogin ¶
func (c *Codex) CancelLogin(ctx context.Context, loginID string) (*protocol.CancelLoginAccountResponse, error)
CancelLogin cancels an in-progress account login flow.
func (*Codex) CompactThread ¶
func (c *Codex) CompactThread(ctx context.Context, threadID string, opts ThreadCompactOptions) (*protocol.ThreadCompactStartResponse, error)
CompactThread starts compaction for a thread by id.
func (*Codex) ForkThread ¶
func (c *Codex) ForkThread(ctx context.Context, threadID string, opts ThreadForkOptions) (*Thread, protocol.ThreadForkResponse, error)
ForkThread forks a thread by id and returns the newly forked thread.
func (*Codex) ListModels ¶
func (c *Codex) ListModels(ctx context.Context, opts ListModelsOptions) (*protocol.ModelListResponse, error)
ListModels returns available models from the app-server.
func (*Codex) ListThreads ¶
func (c *Codex) ListThreads(ctx context.Context, opts ThreadListOptions) (*protocol.ThreadListResponse, error)
ListThreads returns persisted threads visible to the app-server.
func (*Codex) ReadThread ¶
func (c *Codex) ReadThread(ctx context.Context, threadID string, opts ThreadReadOptions) (*protocol.ThreadReadResponse, error)
ReadThread reads a persisted thread by id.
func (*Codex) ResumeThread ¶
ResumeThread resumes an existing thread.
func (*Codex) SetThreadName ¶
func (c *Codex) SetThreadName(ctx context.Context, threadID, name string) (*protocol.ThreadSetNameResponse, error)
SetThreadName sets the display name for a thread by id.
func (*Codex) StartLogin ¶
func (c *Codex) StartLogin(ctx context.Context, params protocol.LoginAccountParams) (*protocol.LoginAccountResponse, error)
StartLogin starts an app-server account login flow using protocol login params.
func (*Codex) StartThread ¶
StartThread starts a new thread using the app-server.
func (*Codex) UnarchiveThread ¶
func (c *Codex) UnarchiveThread(ctx context.Context, threadID string) (*protocol.ThreadUnarchiveResponse, error)
UnarchiveThread unarchives a thread by id.
type Input ¶
type Input struct {
// Type must be one of the InputType* constants.
Type string `json:"type"`
Text string `json:"text,omitempty"`
TextElements []protocol.TextElement `json:"textElements,omitempty"`
URL string `json:"url,omitempty"`
Path string `json:"path,omitempty"`
Name string `json:"name,omitempty"`
}
Input represents a structured user input message.
func LocalImageInput ¶
LocalImageInput creates a local image input entry.
func MentionInput ¶
MentionInput creates a text input containing a single mention placeholder.
type ListModelsOptions ¶
type ListModelsOptions struct {
// Cursor continues listing after a previous response cursor.
Cursor string
// IncludeHidden includes models hidden from the default picker list.
IncludeHidden *bool
// Limit caps the number of models returned by the app-server.
Limit *int
}
ListModelsOptions configures a model/list request.
type Options ¶
type Options struct {
// Transport overrides the default stdio spawn.
Transport rpc.Transport
// Spawn controls how the default stdio process is launched.
Spawn SpawnOptions
// Logger receives SDK logs. If nil, logging is disabled.
Logger *slog.Logger
// ClientInfo identifies this SDK to the app-server.
ClientInfo protocol.ClientInfo
// ApprovalHandler handles server approval requests.
ApprovalHandler rpc.ServerRequestHandler
}
Options configures the Codex client.
type ReasoningEffort ¶
type ReasoningEffort = protocol.ReasoningEffort
ReasoningEffort is a typed alias for standard effort values.
const ( ReasoningEffortNone ReasoningEffort = "none" ReasoningEffortMinimal ReasoningEffort = "minimal" ReasoningEffortLow ReasoningEffort = "low" ReasoningEffortMedium ReasoningEffort = "medium" ReasoningEffortHigh ReasoningEffort = "high" ReasoningEffortXHigh ReasoningEffort = "xhigh" )
type SandboxMode ¶
type SandboxMode = protocol.SandboxMode
SandboxMode is a typed alias for simple sandbox mode values.
const ( SandboxModeReadOnly SandboxMode = protocol.SandboxModeReadOnly SandboxModeWorkspaceWrite SandboxMode = protocol.SandboxModeWorkspaceWrite SandboxModeDangerFullAccess SandboxMode = protocol.SandboxModeDangerFullAccess )
type SpawnOptions ¶
type SpawnOptions struct {
// CodexPath is the path to the codex binary (defaults to "codex").
CodexPath string
// ConfigOverrides are passed as --config key=value flags.
ConfigOverrides []string
// ExtraArgs are appended to the command line.
ExtraArgs []string
// Stderr captures stderr from the codex process (defaults to os.Stderr).
Stderr io.Writer
}
SpawnOptions configures the spawned codex app-server process.
type Thread ¶
type Thread struct {
// contains filtered or unexported fields
}
Thread represents an active conversation thread.
func (*Thread) Compact ¶
func (t *Thread) Compact(ctx context.Context, opts ThreadCompactOptions) (*protocol.ThreadCompactStartResponse, error)
Compact starts compaction for this thread.
func (*Thread) Fork ¶
func (t *Thread) Fork(ctx context.Context, opts ThreadForkOptions) (*Thread, protocol.ThreadForkResponse, error)
Fork forks this thread and returns the newly forked thread.
func (*Thread) Read ¶
func (t *Thread) Read(ctx context.Context, opts ThreadReadOptions) (*protocol.ThreadReadResponse, error)
Read reads this thread from the app-server.
func (*Thread) Run ¶
func (t *Thread) Run(ctx context.Context, prompt string, opts *TurnOptions) (*TurnResult, error)
Run sends a text prompt and waits for the turn to finish.
func (*Thread) RunInputs ¶
func (t *Thread) RunInputs(ctx context.Context, inputs []Input, opts *TurnOptions) (*TurnResult, error)
RunInputs sends structured inputs and waits for the turn to finish.
func (*Thread) RunStreamed ¶
func (t *Thread) RunStreamed(ctx context.Context, inputs []Input, opts *TurnOptions) (*TurnStream, error)
RunStreamed sends structured inputs and returns a streaming iterator. The iterator includes thread-scoped events and any notifications that omit threadId (for example account/session updates).
func (*Thread) StartTurn ¶
func (t *Thread) StartTurn(ctx context.Context, inputs []Input, opts *TurnOptions) (*TurnHandle, error)
StartTurn sends structured inputs and returns a handle for the running turn.
type ThreadCompactOptions ¶
type ThreadCompactOptions struct{}
ThreadCompactOptions configures a thread/compact/start request.
type ThreadForkOptions ¶
type ThreadForkOptions struct {
Model string
ModelProvider string
ServiceTier string
LastTurnID string
Cwd string
ApprovalPolicy any
Sandbox any
Config map[string]any
BaseInstructions string
DeveloperInstructions string
Ephemeral *bool
ExcludeTurns *bool
}
ThreadForkOptions configures a thread/fork request.
type ThreadListOptions ¶
type ThreadListOptions struct {
Archived *bool
Cursor string
Cwd any
Limit *int
ModelProviders []string
SearchTerm string
SortDirection any
SortKey any
SourceKinds []protocol.ThreadSourceKind
UseStateDBOnly *bool
}
ThreadListOptions configures a thread/list request.
type ThreadReadOptions ¶
type ThreadReadOptions struct {
IncludeTurns bool
}
ThreadReadOptions configures a thread/read request.
type ThreadResumeHistoryElem ¶
type ThreadResumeHistoryElem = json.RawMessage
ThreadResumeHistoryElem keeps the old unstable history field compilable for callers, but the current app-server protocol no longer accepts history-based thread resume.
type ThreadResumeOptions ¶
type ThreadResumeOptions struct {
// ThreadID resumes a persisted thread by id.
ThreadID string
// History is retained for source compatibility, but the current app-server
// protocol no longer supports history-based resume. Passing History returns an
// error from toParams.
History []ThreadResumeHistoryElem
// Path is retained for source compatibility, but the current app-server
// protocol no longer supports path-based resume. Passing Path returns an error
// from toParams.
Path string
Model string
ModelProvider string
ServiceTier string
Cwd string
// ApprovalPolicy is marshaled as JSON and sent as "approvalPolicy".
// Prefer ApprovalPolicy* constants for simple policies.
ApprovalPolicy any
// Sandbox is marshaled as JSON and sent as "sandbox".
// Prefer SandboxMode* constants for simple policies.
Sandbox any
Config map[string]any
BaseInstructions string
DeveloperInstructions string
}
ThreadResumeOptions configures a thread/resume request.
type ThreadStartOptions ¶
type ThreadStartOptions struct {
Model string
ModelProvider string
ServiceTier string
Cwd string
// ApprovalPolicy is marshaled as JSON and sent as "approvalPolicy".
// Prefer ApprovalPolicy* constants for simple policies.
ApprovalPolicy any
// SandboxPolicy is marshaled as JSON and sent as "sandbox".
// Prefer SandboxMode* constants for simple policies.
SandboxPolicy any
Config map[string]any
ServiceName string
BaseInstructions string
DeveloperInstructions string
Ephemeral *bool
// ExperimentalRawEvents is retained for source compatibility, but the current
// app-server protocol no longer supports this option. Setting it returns an
// error from toParams.
ExperimentalRawEvents bool
}
ThreadStartOptions configures a thread/start request.
type TurnHandle ¶
type TurnHandle struct {
// contains filtered or unexported fields
}
TurnHandle controls a running turn.
func (*TurnHandle) Close ¶
func (h *TurnHandle) Close()
Close releases the handle's notification subscription.
func (*TurnHandle) Interrupt ¶
func (h *TurnHandle) Interrupt(ctx context.Context) (*protocol.TurnInterruptResponse, error)
Interrupt interrupts the active turn.
func (*TurnHandle) Next ¶
func (h *TurnHandle) Next(ctx context.Context) (rpc.Notification, error)
Next returns the next notification for this turn and updates the handle state.
func (*TurnHandle) Run ¶
func (h *TurnHandle) Run(ctx context.Context) (*TurnResult, error)
Run waits for this turn to complete and returns its aggregated result.
func (*TurnHandle) Steer ¶
func (h *TurnHandle) Steer(ctx context.Context, inputs []Input) (*protocol.TurnSteerResponse, error)
Steer sends additional input to the active turn.
func (*TurnHandle) Stream ¶
func (h *TurnHandle) Stream() (*TurnStream, error)
Stream returns the handle's notification stream.
type TurnOptions ¶
type TurnOptions struct {
ClientUserMessageID string
Cwd string
// ApprovalPolicy is marshaled as JSON and sent as "approvalPolicy".
// Prefer ApprovalPolicy* constants for simple policies.
ApprovalPolicy any
// SandboxPolicy is marshaled as JSON and sent as "sandboxPolicy".
// Prefer SandboxMode* constants for simple policies.
SandboxPolicy any
Model string
ServiceTier string
// Effort is marshaled as JSON and sent as "effort".
// Prefer ReasoningEffort* constants for standard values.
Effort any
// Summary is marshaled as JSON and sent as "summary".
Summary any
// OutputSchema is marshaled as JSON and sent as "outputSchema".
OutputSchema any
// CollaborationMode is retained for source compatibility, but the current
// app-server protocol no longer supports this option. Setting it returns an
// error from buildTurnParams.
CollaborationMode any
}
TurnOptions configures a turn/start request.
type TurnResult ¶
type TurnResult struct {
TurnID string
Status string
ErrorMessage string
Notifications []rpc.Notification
// Items holds the raw JSON payloads for completed items.
Items []json.RawMessage
FinalResponse string
TokenUsage *protocol.ThreadTokenUsage
CreatedAt *time.Time
CompletedAt *time.Time
}
TurnResult aggregates notifications for a completed turn.
type TurnStream ¶
type TurnStream struct {
// contains filtered or unexported fields
}
TurnStream iterates notifications for a running turn. Notifications that omit threadId are still emitted to avoid dropping global events sent during the turn.
func (*TurnStream) Next ¶
func (s *TurnStream) Next(ctx context.Context) (rpc.Notification, error)
Next returns the next notification for this turn. Notifications without threadId are treated as belonging to the active stream.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
approvals
command
|
|
|
lifecycle
command
|
|
|
low_level_rpc
command
|
|
|
quickstart
command
|
|
|
streaming
command
|
|
|
structured_output
command
|
|
|
internal
|
|
|
codegen
command
|
|
|
Package rpc provides a minimal JSON-RPC client tailored to the Codex app-server.
|
Package rpc provides a minimal JSON-RPC client tailored to the Codex app-server. |