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 ¶
- Variables
- type Module
- func (m *Module) Account(ctx context.Context, h agent.Host, in agent.Install) (agent.Account, error)
- func (m *Module) AfterInstall(ctx context.Context, h agent.Host, in agent.Install, key agent.SessionKey, ...) error
- func (m *Module) Bundle(_ context.Context, h agent.Host, in agent.Install, s agent.Summary) (agent.Bundle, error)
- func (m *Module) CanImport(from agent.ID) bool
- func (m *Module) Detect(_ context.Context, h agent.Host) (agent.Install, error)
- func (m *Module) Import(ctx context.Context, h agent.Host, in agent.Install, from agent.ID, ...) (agent.SessionID, error)
- func (m *Module) Integration(h agent.Host, in agent.Install) agent.Integration
- func (m *Module) List(_ context.Context, h agent.Host, in agent.Install) (agent.Listing, error)
- func (m *Module) Live(ctx context.Context, h agent.Host, in agent.Install, ids []agent.SessionID) (map[agent.SessionID]agent.LiveInfo, error)
- func (m *Module) Mark(ctx context.Context, h agent.Host, in agent.Install, s agent.Summary, ...) error
- func (m *Module) PlanMove(src, dst agent.Install, s agent.Summary, b agent.Bundle, p agent.Placement) (agent.MovePlan, error)
- func (m *Module) Profile(agent.Install) ir.Profile
- func (m *Module) Read(_ context.Context, h agent.Host, in agent.Install, s agent.Summary, ...) (ir.Segment, error)
- func (m *Module) Resume(in agent.Install, key agent.SessionKey, p agent.Placement, ...) agent.Command
- func (m *Module) Sanitize() agent.RewritePolicy
- func (*Module) Spec() agent.Spec
- func (m *Module) Stop(ctx context.Context, h agent.Host, in agent.Install, s agent.Summary, ...) error
- func (m *Module) Verify(_ context.Context, h agent.Host, mp agent.MovePlan, staged map[string]string, ...) error
- func (m *Module) Write(ctx context.Context, h agent.Host, in agent.Install, req ir.WriteRequest) (ir.WriteResult, error)
Constants ¶
This section is empty.
Variables ¶
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.
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 (*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) 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 ¶
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 ¶
List walks sessions/YYYY/MM/DD, newest first. Sub-agent threads are left out, as Codex's own pickers do.
func (*Module) Live ¶
func (m *Module) Live(ctx context.Context, h agent.Host, in agent.Install, ids []agent.SessionID) (map[agent.SessionID]agent.LiveInfo, error)
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 ¶
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 ¶
func (m *Module) Resume(in agent.Install, key agent.SessionKey, p agent.Placement, o agent.ResumeOptions) agent.Command
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) 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.