codex

package
v0.83.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 13 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

Overview

Package codex provides an adapter for Codex CLI that reads session files with two-pass parsing optimization for large conversation files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWatcher

func NewWatcher(root string) (<-chan adapter.Event, io.Closer, error)

NewWatcher creates a watcher for Codex session changes. Only watches root and month directories to reduce FD count (td-0f0e68). fsnotify on macOS propagates events from subdirectories.

Types

type Adapter

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

Adapter implements the adapter.Adapter interface for Codex CLI sessions.

func New

func New() *Adapter

New creates a new Codex adapter.

func (*Adapter) Capabilities

func (a *Adapter) Capabilities() adapter.CapabilitySet

Capabilities returns the supported features.

func (*Adapter) Detect

func (a *Adapter) Detect(projectRoot string) (bool, error)

Detect checks if Codex sessions exist for the given project.

func (*Adapter) ID

func (a *Adapter) ID() string

ID returns the adapter identifier.

func (*Adapter) Icon

func (a *Adapter) Icon() string

Icon returns the adapter icon for badge display.

func (*Adapter) Messages

func (a *Adapter) Messages(sessionID string) ([]adapter.Message, error)

Messages returns all messages for the given session. Uses caching with incremental parsing for append-only growth optimization.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the human-readable adapter name.

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

func (a *Adapter) Sessions(projectRoot string) ([]adapter.Session, error)

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) Watch

func (a *Adapter) Watch(projectRoot string) (<-chan adapter.Event, io.Closer, error)

Watch returns a channel that emits events when session data changes.

func (*Adapter) WatchScope

func (a *Adapter) WatchScope() adapter.WatchScope

WatchScope returns Global because codex watches a global sessions directory (td-7a72b6f7).

type ContentBlock

type ContentBlock struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

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

type ReasoningSummary struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

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.

Jump to

Keyboard shortcuts

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