codex

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 19 Imported by: 1 module, 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 is the OpenAI Codex module (CLI, IDE extension and desktop app share one store). Sessions ("threads") are append-only JSON-lines rollouts under $CODEX_HOME/sessions/YYYY/MM/DD/rollout-<local time>-<id>.jsonl. Codex also keeps SQLite indexes; hopsesh never touches them: Codex finds a copied-in rollout by id and indexes it itself.

Index

Constants

This section is empty.

Variables

View Source
var ErrBusy = errors.New("the Codex session is working right now; let it finish (or stop it with Esc), then try again")

ErrBusy means Codex is in the middle of a turn in that thread.

View Source
var ErrStillRunning = errors.New("the Codex session did not exit in time; quit it yourself (Ctrl+C twice, or /quit), then try again")

ErrStillRunning means a stopped thread's process did not exit in time.

Functions

This section is empty.

Types

type Module

type Module struct{}

Module is the Codex module.

func New

func New() *Module

New returns the module.

func (*Module) Account

func (m *Module) Account(ctx context.Context, h agent.Host, in agent.Install) (agent.Account, error)

Account identifies the Codex login on a machine through Codex itself (account/read), never by reading auth.json. ChatGPT logins are keyed by a hash of the account's email; an API key or another provider has no identity to compare.

func (*Module) AfterInstall

func (m *Module) AfterInstall(ctx context.Context, h agent.Host, in agent.Install, key agent.SessionKey, p agent.Placement) error

AfterInstall makes Codex's own session lists show a session hopsesh installed, under its name. Codex lists sessions from an index it fills once, so a rollout added later stays out of `codex resume` and the app until Codex reads it by id; hopsesh asks `codex app-server` to (thread/read), and to record the name (thread/name/set). Codex not installed here is not an error: it finds the session by id when resumed.

func (*Module) Bundle

func (m *Module) Bundle(_ context.Context, h agent.Host, in agent.Install, s agent.Summary) (agent.Bundle, error)

Bundle is the rollout, plus the rollout a forked thread's history starts in.

func (*Module) CanImport

func (m *Module) CanImport(from agent.ID) bool

CanImport reports that Codex's importer reads Claude Code sessions.

func (*Module) Detect

func (m *Module) Detect(_ context.Context, h agent.Host) (agent.Install, error)

Detect resolves CODEX_HOME and the codex binary.

func (*Module) Import

func (m *Module) Import(ctx context.Context, h agent.Host, in agent.Install, from agent.ID, path, cwd, title string) (agent.SessionID, error)

Import has Codex's own importer convert a Claude Code session file (externalAgentConfig/import) into a new thread.

func (*Module) Integration

func (m *Module) Integration(h agent.Host, in agent.Install) agent.Integration

Integration says Codex reads user skills from ~/.agents/skills, and approval rules from any .rules file under $CODEX_HOME/rules. hopsesh owns rules/hopsesh.rules outright (Codex rewrites default.rules itself).

func (*Module) List

func (m *Module) List(_ context.Context, h agent.Host, in agent.Install) (agent.Listing, error)

List walks sessions/YYYY/MM/DD, newest first. Sub-agent threads are left out, as Codex's own pickers do.

func (*Module) Live

Live probes the lock Codex holds on thread-writer-locks/<id>.lock while a thread is open (the file stays after Codex exits; only the lock means open).

func (*Module) Mark

func (m *Module) Mark(ctx context.Context, h agent.Host, in agent.Install, s agent.Summary, mk agent.Mark) error

Mark names the thread left behind "↪ moved to …" (or "continued in …"), which Codex's own thread list shows.

func (*Module) PlanMove

func (m *Module) PlanMove(src, dst agent.Install, s agent.Summary, b agent.Bundle, p agent.Placement) (agent.MovePlan, error)

PlanMove keeps every rollout at its relative path (Codex's index finds a thread by its file name, and an existing index row keeps its path). A keep-both copy gets a new id, which appears in the file name and inside many records.

func (*Module) Profile

func (m *Module) Profile(agent.Install) ir.Profile

Profile says Codex's own tool calls cannot be forged safely, so history arrives as text.

func (*Module) Read

func (m *Module) Read(_ context.Context, h agent.Host, in agent.Install, s agent.Summary, from ir.Cursor) (ir.Segment, error)

Read lifts a rollout into IR: the user's messages (not the context Codex injects), the agent's replies, and what ran, from Codex's structured item_completed records (falling back to raw function calls in rollouts that have none).

func (*Module) Resume

Resume is `codex resume <id> [prompt]` (or `codex fork <id>`), run in the thread's folder.

func (*Module) Sanitize

func (m *Module) Sanitize() agent.RewritePolicy

Sanitize is the policy for a move to a machine signed in to another account: Codex's encrypted reasoning and compaction are bound to the organization that produced them, and replaying them under another one makes the session fail to resume, so those records go (the conversation itself stays; Codex compacts again when it needs to).

func (*Module) Spec

func (*Module) Spec() agent.Spec

Spec declares Codex.

func (*Module) Stop

func (m *Module) Stop(ctx context.Context, h agent.Host, in agent.Install, s agent.Summary, grace time.Duration) error

Stop quits the Codex process that has the thread open. Codex installs no handler for SIGTERM, so it is sent only between turns (Codex writes every item to the rollout as it goes, so nothing finished is lost), and only to a process named codex that holds the thread's writer lock.

func (*Module) Verify

func (m *Module) Verify(_ context.Context, h agent.Host, mp agent.MovePlan, staged map[string]string, p agent.Placement) error

Verify checks that the staged rollout starts in the target folder, as the target thread.

func (*Module) Write

func (m *Module) Write(ctx context.Context, h agent.Host, in agent.Install, req ir.WriteRequest) (ir.WriteResult, error)

Write emits a legacy-mode rollout (no ordinals): session_meta, then each message as a response_item with its user_message/agent_message event (Codex titles threads from those events). Appends go only to rollouts in that mode.

Jump to

Keyboard shortcuts

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