codexapp

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const AgentID = "codex-app"

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentMessageDelta

type AgentMessageDelta struct {
	ThreadID string `json:"threadId"`
	TurnID   string `json:"turnId"`
	ItemID   string `json:"itemId"`
	Delta    string `json:"delta"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conn Conn) *Client

func Start

func Start(ctx context.Context, opts ProcessOptions) (*Client, error)

func (*Client) Call

func (c *Client) Call(ctx context.Context, method string, params any, out any) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) Err

func (c *Client) Err() error

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context, params InitializeParams) (InitializeResponse, error)

func (*Client) InterruptTurn added in v0.2.0

func (c *Client) InterruptTurn(ctx context.Context, params TurnInterruptParams) (TurnInterruptResponse, error)

func (*Client) Notify

func (c *Client) Notify(ctx context.Context, method string, params any) error

func (*Client) ResumeThread

func (c *Client) ResumeThread(ctx context.Context, params ThreadResumeParams) (ThreadResumeResponse, error)

func (*Client) StartThread

func (c *Client) StartThread(ctx context.Context, params ThreadStartParams) (ThreadStartResponse, error)

func (*Client) StartTurn

func (c *Client) StartTurn(ctx context.Context, params TurnStartParams) (TurnStartResponse, error)

func (*Client) SubscribeTurn added in v0.1.17

func (c *Client) SubscribeTurn(threadID, turnID string) *TurnSubscription

SubscribeTurn starts the turn's queue with what arrived for it so far. Close the subscription when done with the turn.

type ClientInfo

type ClientInfo struct {
	Name    string  `json:"name"`
	Title   *string `json:"title"`
	Version string  `json:"version"`
}

type Conn

type Conn interface {
	io.ReadWriteCloser
	SetWriteDeadline(t time.Time) error
}

Conn is the app-server's stdio; writes take a deadline so a wedged server fails the write instead of stalling its caller.

type ContextCompactedNotification added in v0.2.0

type ContextCompactedNotification struct {
	ThreadID string `json:"threadId"`
	TurnID   string `json:"turnId"`
}

type DecodeFailure added in v0.2.1

type DecodeFailure struct {
	ThreadID string
	TurnID   string
	Err      error
}

DecodeFailure stands for params of a known notification the client could not decode; the IDs are what could be read of its thread and turn.

type ErrorNotification added in v0.2.0

type ErrorNotification struct {
	ThreadID  string    `json:"threadId"`
	TurnID    string    `json:"turnId"`
	Error     TurnError `json:"error"`
	WillRetry bool      `json:"willRetry"`
}

type FileChangePatchUpdated added in v0.1.5

type FileChangePatchUpdated struct {
	ThreadID string             `json:"threadId"`
	TurnID   string             `json:"turnId"`
	ItemID   string             `json:"itemId"`
	Changes  []FileUpdateChange `json:"changes"`
}

type FileUpdateChange added in v0.1.5

type FileUpdateChange struct {
	Path string          `json:"path"`
	Diff string          `json:"diff"`
	Kind json.RawMessage `json:"kind"`
}

type InitializeCapabilities

type InitializeCapabilities struct {
	ExperimentalAPI           bool     `json:"experimentalApi"`
	OptOutNotificationMethods []string `json:"optOutNotificationMethods,omitempty"`
}

type InitializeParams

type InitializeParams struct {
	ClientInfo   ClientInfo              `json:"clientInfo"`
	Capabilities *InitializeCapabilities `json:"capabilities"`
}

type InitializeResponse

type InitializeResponse struct {
	UserAgent      string `json:"userAgent"`
	CodexHome      string `json:"codexHome"`
	PlatformFamily string `json:"platformFamily"`
	PlatformOS     string `json:"platformOs"`
}

type ItemNotification added in v0.1.5

type ItemNotification struct {
	ThreadID string          `json:"threadId"`
	TurnID   string          `json:"turnId"`
	Item     json.RawMessage `json:"item"`
}

type Notification

type Notification struct {
	Method string
	Params any
}

type ProcessOptions

type ProcessOptions struct {
	Path   string
	Args   []string
	Stderr io.Writer
}

type ReasoningTextDelta added in v0.1.5

type ReasoningTextDelta struct {
	ThreadID string `json:"threadId"`
	TurnID   string `json:"turnId"`
	ItemID   string `json:"itemId"`
	Delta    string `json:"delta"`
}

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

func NewRuntime

func NewRuntime(opts RuntimeOptions) *Runtime

func (*Runtime) Available added in v0.2.0

func (*Runtime) Close

func (r *Runtime) Close() error

func (*Runtime) DisplayName added in v0.2.0

func (r *Runtime) DisplayName() string

func (*Runtime) ID added in v0.2.0

func (r *Runtime) ID() string

func (*Runtime) Interrupt

func (r *Runtime) Interrupt(ctx context.Context, session externalagents.ExternalSession) error

func (*Runtime) Models added in v0.2.0

func (r *Runtime) Models(context.Context) []string

func (*Runtime) ResumeSession

func (*Runtime) Send

type RuntimeOptions

type RuntimeOptions struct {
	Path    string
	Enabled bool
	Stderr  io.Writer
	Client  *Client
}

type TextElement

type TextElement struct{}

type Thread

type Thread struct {
	ID            string  `json:"id"`
	SessionID     string  `json:"sessionId"`
	ForkedFromID  *string `json:"forkedFromId"`
	Preview       string  `json:"preview"`
	Ephemeral     bool    `json:"ephemeral"`
	ModelProvider string  `json:"modelProvider"`
	CreatedAt     int64   `json:"createdAt"`
	UpdatedAt     int64   `json:"updatedAt"`
	Status        any     `json:"status"`
	Path          *string `json:"path"`
	CWD           string  `json:"cwd"`
	CLIVersion    string  `json:"cliVersion"`
	Name          *string `json:"name"`
}

type ThreadResumeParams

type ThreadResumeParams struct {
	ThreadID          string `json:"threadId"`
	Model             string `json:"model,omitempty"`
	ModelProvider     string `json:"modelProvider,omitempty"`
	CWD               string `json:"cwd,omitempty"`
	ApprovalPolicy    string `json:"approvalPolicy,omitempty"`
	ApprovalsReviewer string `json:"approvalsReviewer,omitempty"`
	Sandbox           string `json:"sandbox,omitempty"`
}

type ThreadResumeResponse

type ThreadResumeResponse = ThreadStartResponse

type ThreadStartParams

type ThreadStartParams struct {
	Model             string `json:"model,omitempty"`
	ModelProvider     string `json:"modelProvider,omitempty"`
	CWD               string `json:"cwd,omitempty"`
	ApprovalPolicy    string `json:"approvalPolicy,omitempty"`
	ApprovalsReviewer string `json:"approvalsReviewer,omitempty"`
	Sandbox           string `json:"sandbox,omitempty"`
	Ephemeral         *bool  `json:"ephemeral,omitempty"`
}

type ThreadStartResponse

type ThreadStartResponse struct {
	Thread          Thread  `json:"thread"`
	Model           string  `json:"model"`
	ModelProvider   string  `json:"modelProvider"`
	ServiceTier     *string `json:"serviceTier"`
	CWD             string  `json:"cwd"`
	ApprovalPolicy  string  `json:"approvalPolicy"`
	Sandbox         any     `json:"sandbox"`
	ReasoningEffort *string `json:"reasoningEffort"`
}

type ToolOutputDelta added in v0.1.5

type ToolOutputDelta struct {
	ThreadID string `json:"threadId"`
	TurnID   string `json:"turnId"`
	ItemID   string `json:"itemId"`
	Delta    string `json:"delta"`
}

type Turn

type Turn struct {
	ID        string     `json:"id"`
	ThreadID  string     `json:"threadId,omitempty"`
	Status    TurnStatus `json:"status"`
	Error     *TurnError `json:"error,omitempty"`
	StartedAt int64      `json:"startedAt,omitempty"`
}

type TurnCompleted

type TurnCompleted struct {
	ThreadID string `json:"threadId"`
	Turn     Turn   `json:"turn"`
}

type TurnError added in v0.2.0

type TurnError struct {
	Message           string  `json:"message"`
	AdditionalDetails *string `json:"additionalDetails,omitempty"`
}

type TurnInterruptParams added in v0.2.0

type TurnInterruptParams struct {
	ThreadID string `json:"threadId"`
	TurnID   string `json:"turnId"`
}

type TurnInterruptResponse added in v0.2.0

type TurnInterruptResponse struct{}

type TurnStartParams

type TurnStartParams struct {
	ThreadID          string      `json:"threadId"`
	Input             []UserInput `json:"input"`
	CWD               string      `json:"cwd,omitempty"`
	ApprovalPolicy    string      `json:"approvalPolicy,omitempty"`
	ApprovalsReviewer string      `json:"approvalsReviewer,omitempty"`
	Model             string      `json:"model,omitempty"`
	Effort            string      `json:"effort,omitempty"`
	Summary           string      `json:"summary,omitempty"`
	OutputSchema      any         `json:"outputSchema,omitempty"`
}

type TurnStartResponse

type TurnStartResponse struct {
	Turn Turn `json:"turn"`
}

type TurnStarted added in v0.2.0

type TurnStarted struct {
	ThreadID string `json:"threadId"`
	Turn     Turn   `json:"turn"`
}

type TurnStatus added in v0.2.0

type TurnStatus string
const (
	TurnStatusCompleted   TurnStatus = "completed"
	TurnStatusInterrupted TurnStatus = "interrupted"
	TurnStatusFailed      TurnStatus = "failed"
	TurnStatusInProgress  TurnStatus = "inProgress"
)

type TurnSubscription added in v0.2.1

type TurnSubscription struct {
	// contains filtered or unexported fields
}

TurnSubscription is one turn's queue, filled by the read loop and drained by Next.

func (*TurnSubscription) Close added in v0.2.1

func (s *TurnSubscription) Close()

Close ends the subscription and forgets its turn; later notifications of the turn are backlogged until turnBacklogTTL drops them.

func (*TurnSubscription) Next added in v0.2.1

Next returns the turn's next notification; false once the subscription ended and is drained, or ctx is done.

type UserInput

type UserInput struct {
	Type         string        `json:"type"`
	Text         string        `json:"text,omitempty"`
	TextElements []TextElement `json:"text_elements,omitempty"`
	URL          string        `json:"url,omitempty"`
	Path         string        `json:"path,omitempty"`
	Name         string        `json:"name,omitempty"`
}

func TextInput

func TextInput(text string) UserInput

Jump to

Keyboard shortcuts

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