Documentation
¶
Overview ¶
Package codex provides an adapter for Codex CLI that reads session files with two-pass parsing optimization for large conversation files.
Index ¶
- func NewWatcher(root string) (<-chan adapter.Event, io.Closer, error)
- type Adapter
- func (a *Adapter) Capabilities() adapter.CapabilitySet
- func (a *Adapter) Detect(projectRoot string) (bool, error)
- func (a *Adapter) ID() string
- func (a *Adapter) Icon() string
- func (a *Adapter) Messages(sessionID string) ([]adapter.Message, error)
- func (a *Adapter) Name() string
- func (a *Adapter) SearchMessages(sessionID, query string, opts adapter.SearchOptions) ([]adapter.MessageMatch, error)
- func (a *Adapter) Sessions(projectRoot string) ([]adapter.Session, error)
- func (a *Adapter) Usage(sessionID string) (*adapter.UsageStats, error)
- func (a *Adapter) Watch(projectRoot string) (<-chan adapter.Event, io.Closer, error)
- func (a *Adapter) WatchScope() adapter.WatchScope
- type ContentBlock
- type EventMsgPayload
- type RawRecord
- type ReasoningSummary
- type ResponseItemBase
- type ResponseMessagePayload
- type ResponseReasoningPayload
- type ResponseToolCallPayload
- type ResponseToolOutputPayload
- type SessionMetaPayload
- type SessionMetadata
- type TokenCountInfo
- type TokenUsage
- type TurnContextPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements the adapter.Adapter interface for Codex CLI sessions.
func (*Adapter) Capabilities ¶
func (a *Adapter) Capabilities() adapter.CapabilitySet
Capabilities returns the supported features.
func (*Adapter) Messages ¶
Messages returns all messages for the given session. Uses caching with incremental parsing for append-only growth optimization.
func (*Adapter) SearchMessages ¶
func (a *Adapter) SearchMessages(sessionID, query string, opts adapter.SearchOptions) ([]adapter.MessageMatch, error)
SearchMessages searches message content within a session. Implements adapter.MessageSearcher interface.
func (*Adapter) Sessions ¶
Sessions returns all sessions for the given project, sorted by update time.
func (*Adapter) Usage ¶
func (a *Adapter) Usage(sessionID string) (*adapter.UsageStats, error)
Usage returns aggregate usage stats for the given session.
func (*Adapter) WatchScope ¶
func (a *Adapter) WatchScope() adapter.WatchScope
WatchScope returns Global because codex watches a global sessions directory (td-7a72b6f7).
type ContentBlock ¶
ContentBlock is a content fragment inside a message.
type EventMsgPayload ¶
type EventMsgPayload struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Info *TokenCountInfo `json:"info,omitempty"`
}
EventMsgPayload represents an event message.
type RawRecord ¶
type RawRecord struct {
Timestamp time.Time `json:"timestamp"`
Type string `json:"type"`
Payload json.RawMessage `json:"payload"`
}
RawRecord represents a single JSONL line in a Codex session file.
type ReasoningSummary ¶
ReasoningSummary holds summarized reasoning text.
type ResponseItemBase ¶
type ResponseItemBase struct {
Type string `json:"type"`
}
ResponseItemBase holds the response item type.
type ResponseMessagePayload ¶
type ResponseMessagePayload struct {
Type string `json:"type"`
Role string `json:"role"`
Content []ContentBlock `json:"content"`
}
ResponseMessagePayload represents a user or assistant message.
type ResponseReasoningPayload ¶
type ResponseReasoningPayload struct {
Type string `json:"type"`
Summary []ReasoningSummary `json:"summary"`
}
ResponseReasoningPayload represents reasoning metadata.
type ResponseToolCallPayload ¶
type ResponseToolCallPayload struct {
Type string `json:"type"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
CallID string `json:"call_id"`
}
ResponseToolCallPayload represents a tool call request.
type ResponseToolOutputPayload ¶
type ResponseToolOutputPayload struct {
Type string `json:"type"`
CallID string `json:"call_id"`
Output json.RawMessage `json:"output,omitempty"`
}
ResponseToolOutputPayload represents a tool call response.
type SessionMetaPayload ¶
type SessionMetaPayload struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
CWD string `json:"cwd"`
Source string `json:"source"`
}
SessionMetaPayload holds metadata about a Codex session.
type SessionMetadata ¶
type SessionMetadata struct {
Path string
SessionID string
CWD string
FirstMsg time.Time
LastMsg time.Time
MsgCount int
TotalTokens int
FirstUserMessage string // Content of the first user message (for title)
}
SessionMetadata aggregates metadata extracted from a session file.
type TokenCountInfo ¶
type TokenCountInfo struct {
TotalTokenUsage *TokenUsage `json:"total_token_usage"`
LastTokenUsage *TokenUsage `json:"last_token_usage"`
}
TokenCountInfo contains token usage stats.
type TokenUsage ¶
type TokenUsage struct {
InputTokens int `json:"input_tokens"`
CachedInputTokens int `json:"cached_input_tokens"`
OutputTokens int `json:"output_tokens"`
ReasoningOutputTokens int `json:"reasoning_output_tokens"`
TotalTokens int `json:"total_tokens"`
}
TokenUsage represents token usage metrics.
type TurnContextPayload ¶
type TurnContextPayload struct {
Model string `json:"model"`
}
TurnContextPayload carries model context per turn.