codex

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: Apache-2.0 Imports: 14 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

This section is empty.

Variables

This section is empty.

Functions

func IsThreadNotFoundError

func IsThreadNotFoundError(err error) bool

Types

type Adapter

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

func NewAdapter

func NewAdapter(options AdapterOptions) (*Adapter, error)

func (*Adapter) Start

func (a *Adapter) Start(ctx context.Context, request StartRequest) (*Session, error)

type AdapterOptions

type AdapterOptions struct {
	ProcessManager provider.AgentCLIProcessManager
}

type ApprovalOption

type ApprovalOption struct {
	ID          string
	Label       string
	RawDecision string
}

type ApprovalRequest

type ApprovalRequest struct {
	RequestID RequestID
	ThreadID  string
	TurnID    string
	Kind      ApprovalRequestKind
	Options   []ApprovalOption
	Payload   map[string]any
}

type ApprovalRequestKind

type ApprovalRequestKind string
const (
	ApprovalRequestKindCommandExecution ApprovalRequestKind = "command_execution"
	ApprovalRequestKindFileChange       ApprovalRequestKind = "file_change"
)

type Event

type Event struct {
	Type         EventType
	ToolCall     *ToolCallRequest
	Approval     *ApprovalRequest
	UserInput    *UserInputRequest
	TokenUsage   *TokenUsageEvent
	RateLimit    *provider.CLIRateLimit
	Output       *OutputEvent
	Turn         *TurnEvent
	ThreadStatus *ThreadStatusEvent
	Thread       *ThreadEvent
	Compaction   *ThreadCompactionEvent
	Plan         *TurnPlanEvent
	Diff         *TurnDiffEvent
	Reasoning    *ReasoningEvent
}

type EventType

type EventType string
const (
	EventTypeToolCallRequested  EventType = "tool_call_requested"
	EventTypeApprovalRequested  EventType = "approval_requested"
	EventTypeUserInputRequested EventType = "user_input_requested"
	// #nosec G101 -- event type identifier, not a credential.
	EventTypeTokenUsageUpdated EventType = "token_usage_updated"
	EventTypeRateLimitUpdated  EventType = "rate_limit_updated"
	EventTypeOutputProduced    EventType = "output_produced"
	EventTypeThreadStarted     EventType = "thread_started"
	EventTypeThreadCompacted   EventType = "thread_compacted"
	EventTypeTurnPlanUpdated   EventType = "turn_plan_updated"
	EventTypeTurnDiffUpdated   EventType = "turn_diff_updated"
	EventTypeReasoningUpdated  EventType = "reasoning_updated"
	EventTypeTurnStarted       EventType = "turn_started"
	EventTypeTurnCompleted     EventType = "turn_completed"
	EventTypeTurnInterrupted   EventType = "turn_interrupted"
	EventTypeTurnFailed        EventType = "turn_failed"
	EventTypeThreadStatus      EventType = "thread_status"
)

type InitializeParams

type InitializeParams struct {
	ClientName    string
	ClientVersion string
	ClientTitle   string
}

type OutputEvent

type OutputEvent struct {
	ThreadID string
	TurnID   string
	ItemID   string
	Stream   string
	Command  string
	Text     string
	Phase    string
	Snapshot bool
}

type RPCError

type RPCError struct {
	Method  string
	Code    int
	Message string
}

func (*RPCError) Error

func (e *RPCError) Error() string

type ReasoningEvent

type ReasoningEvent struct {
	ThreadID     string
	TurnID       string
	ItemID       string
	Kind         ReasoningKind
	Delta        string
	SummaryIndex *int
	ContentIndex *int
}

type ReasoningKind

type ReasoningKind string
const (
	ReasoningKindSummaryPart ReasoningKind = "summary_part_added"
	ReasoningKindSummaryText ReasoningKind = "summary_text_delta"
	ReasoningKindText        ReasoningKind = "text_delta"
)

type RequestID

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

func ParseRequestIDString

func ParseRequestIDString(raw string) (RequestID, error)

func (RequestID) MarshalJSON

func (id RequestID) MarshalJSON() ([]byte, error)

func (RequestID) String

func (id RequestID) String() string

type Session

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

func (*Session) Diagnostic

func (s *Session) Diagnostic() SessionDiagnostic

func (*Session) Err

func (s *Session) Err() error

func (*Session) Events

func (s *Session) Events() <-chan Event

func (*Session) RespondApproval

func (s *Session) RespondApproval(_ context.Context, request ApprovalRequest, decision string) error

func (*Session) RespondToolCall

func (s *Session) RespondToolCall(ctx context.Context, request ToolCallRequest, result ToolCallResult) error

func (*Session) RespondUserInput

func (s *Session) RespondUserInput(_ context.Context, request UserInputRequest, answers map[string]any) error

func (*Session) SendPrompt

func (s *Session) SendPrompt(ctx context.Context, prompt string) (TurnStartResult, error)

func (*Session) StartTurn

func (s *Session) StartTurn(ctx context.Context, config TurnConfig, prompt string) (TurnStartResult, error)

func (*Session) Stop

func (s *Session) Stop(ctx context.Context) error

func (*Session) ThreadID

func (s *Session) ThreadID() string

func (*Session) ThreadStatus

func (s *Session) ThreadStatus() *ThreadStatusEvent

type SessionDiagnostic

type SessionDiagnostic struct {
	PID      int
	ThreadID string
	Error    string
	Stderr   string
}

type StartRequest

type StartRequest struct {
	Process    provider.AgentCLIProcessSpec
	Initialize InitializeParams
	Thread     ThreadStartParams
	Turn       TurnConfig
}

type ThreadCompactionEvent

type ThreadCompactionEvent struct {
	ThreadID string
	TurnID   string
}

type ThreadEvent

type ThreadEvent struct {
	ThreadID    string
	Status      string
	ActiveFlags []string
}

type ThreadStartParams

type ThreadStartParams struct {
	ResumeThreadID         string
	WorkingDirectory       string
	Model                  string
	ModelProvider          string
	ServiceName            string
	BaseInstructions       string
	DeveloperInstructions  string
	ApprovalPolicy         any
	Sandbox                any
	Ephemeral              *bool
	ExperimentalRawEvents  bool
	PersistExtendedHistory bool
}

type ThreadStatusEvent

type ThreadStatusEvent struct {
	ThreadID    string
	Status      string
	ActiveFlags []string
}

type TokenUsageEvent

type TokenUsageEvent struct {
	ThreadID               string
	TurnID                 string
	TotalInputTokens       int64
	TotalOutputTokens      int64
	TotalCachedInputTokens int64
	TotalReasoningTokens   int64
	LastInputTokens        int64
	LastOutputTokens       int64
	LastCachedInputTokens  int64
	LastReasoningTokens    int64
	TotalTokens            int64
	LastTokens             int64
	ModelContextWindow     *int64
}

type ToolCallContentItem

type ToolCallContentItem struct {
	Type     ToolCallContentType
	Text     string
	ImageURL string
}

type ToolCallContentType

type ToolCallContentType string
const (
	ToolCallContentTypeText  ToolCallContentType = toolCallTextOutputType
	ToolCallContentTypeImage ToolCallContentType = toolCallImageOutputType
)

type ToolCallRequest

type ToolCallRequest struct {
	RequestID RequestID
	ThreadID  string
	TurnID    string
	CallID    string
	Tool      string
	Arguments json.RawMessage
}

type ToolCallResult

type ToolCallResult struct {
	Success      bool
	ContentItems []ToolCallContentItem
}

type TurnConfig

type TurnConfig struct {
	WorkingDirectory string
	Title            string
	ApprovalPolicy   any
	SandboxPolicy    any
}

type TurnDiffEvent

type TurnDiffEvent struct {
	ThreadID string
	TurnID   string
	Diff     string
}

type TurnError

type TurnError struct {
	Message           string
	AdditionalDetails string
}

type TurnEvent

type TurnEvent struct {
	ThreadID string
	TurnID   string
	Status   string
	Error    *TurnError
}

type TurnPlanEvent

type TurnPlanEvent struct {
	ThreadID    string
	TurnID      string
	Explanation *string
	Plan        []TurnPlanStep
}

type TurnPlanStep

type TurnPlanStep struct {
	Step   string
	Status string
}

type TurnStartResult

type TurnStartResult struct {
	TurnID string
}

type UserInputRequest

type UserInputRequest struct {
	RequestID RequestID
	ThreadID  string
	TurnID    string
	Payload   map[string]any
}

Jump to

Keyboard shortcuts

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