codexitem

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 7 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 codexitem decodes Codex items, the units of a Codex session (a user message, an agent message, a command, a file change, a tool call), from both of Codex's encodings — the rollout file's item_completed events and the app-server's item notifications — into one normalized Item, so the stored transcript and a live stream map them identically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Path     string
	Kind     string // add, delete, update
	MovePath string // update with a move
	Diff     string // the unified diff; for add and delete, the file's content
}

Change is one file of a file change.

type Item

type Item struct {
	ID            string
	TurnID        string
	Kind          Kind
	Status        Status
	StartedAtMs   int64
	CompletedAtMs int64
	LineTS        string // rollout: the line's timestamp, as written (fallback for a missing completed_at_ms)

	Parts []string // user: the text of each content part, in order
	Text  string   // agent: the message text (rollout: the parts' text joined with no separator)

	Command  string // command: the script (see scriptOfArgv / scriptOfString)
	CWD      string
	Output   string // command: aggregated output; mcpTool: result text
	ExitCode *int

	Changes []Change // fileChange, sorted by Path

	Server    string          // mcpTool
	Tool      string          // mcpTool, collabTool (e.g. spawnAgent)
	Arguments json.RawMessage // mcpTool
	Error     string          // mcpTool: the error message, if any

	Query string // webSearch
	Path  string // imageView

	Prompt            string   // collabTool
	ReceiverThreadIDs []string // collabTool
	AgentThreadID     string   // subAgentActivity
	AgentPath         string   // subAgentActivity
	ActivityKind      string   // subAgentActivity: started, interacted, interrupted, completed
}

Item is a decoded Codex item. Only the fields of its Kind are set.

func DecodeDaemon

func DecodeDaemon(method string, params []byte) (Item, bool)

DecodeDaemon decodes an app-server item/started or item/completed notification's params; ok is false for other methods and for an item it can't read or that has no ID.

func DecodeRollout

func DecodeRollout(line []byte) (Item, bool)

DecodeRollout decodes one rollout line; ok is true for an event_msg item_completed line whose item it can read (Kind other included) and that has an ID.

func (Item) Failed

func (it Item) Failed() bool

Failed reports whether the item ended in failure: a failed or declined status, a non-zero exit code, or an MCP error.

type Kind

type Kind string

Kind is what an item is.

const (
	KindUser       Kind = "user"
	KindAgent      Kind = "agent"
	KindCommand    Kind = "command"
	KindFileChange Kind = "fileChange"
	KindMCPTool    Kind = "mcpTool"
	KindWebSearch  Kind = "webSearch"
	KindImageView  Kind = "imageView"
	KindCollabTool Kind = "collabTool"
	KindSubAgent   Kind = "subAgentActivity"
	KindOther      Kind = "other" // reasoning, compaction, plans, dynamic tools, other extensions
)

type Status

type Status string

Status is an item's state; Codex's own values, empty for items without one.

const (
	StatusInProgress Status = "inProgress"
	StatusCompleted  Status = "completed"
	StatusFailed     Status = "failed"
	StatusDeclined   Status = "declined"
)

Jump to

Keyboard shortcuts

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