Documentation
¶
Overview ¶
Package codex captures sessions from the Codex CLI's native hooks and JSONL rollouts.
Index ¶
- Constants
- type Provider
- func (p *Provider) AnnouncePromptSubmit(reminder string) error
- func (p *Provider) AnnounceSessionStart(msg trace.SessionStartMessage) error
- func (p *Provider) AnnounceToUser(msg string) error
- func (p *Provider) CaptureFileSnapshot(store *state.Store, input *trace.HookInput) error
- func (p *Provider) CleanupAfterEdit(store *state.Store, input *trace.HookInput)
- func (p *Provider) CopySessionData(store *state.Store, loc trace.SessionLocation) error
- func (p *Provider) HooksInstalled(repoRoot string) (bool, error)
- func (p *Provider) InstallHooks(repoRoot string) error
- func (p *Provider) InstallHooksForTraceRun(repoRoot string) error
- func (p *Provider) IsCommandTool(toolName string) bool
- func (p *Provider) IsFileWritingTool(toolName string) bool
- func (p *Provider) Name() string
- func (p *Provider) NewSkillLoads(store *state.Store, input *trace.HookInput) []string
- func (p *Provider) ParseSession(ctx context.Context, opts *trace.ParseOpts) (*aicodingsession.Evidence, error)
- func (p *Provider) PastedImages(raw map[string][]json.RawMessage) []trace.PastedImage
- func (p *Provider) ReadHookInput(r io.Reader) (*trace.HookInput, error)
- func (p *Provider) ReplaceSpecCopies(raw map[string][]json.RawMessage, sources pointer.Sources) pointer.Report
- func (p *Provider) ResolveBeforeContent(store *state.Store, input *trace.HookInput, _ []byte) []byte
- func (p *Provider) SessionSkills(opts *trace.ParseOpts) ([]trace.SkillUse, []string, error)
- func (p *Provider) SettingsFile(repoRoot string) string
- func (p *Provider) SkillRoots(repoRoot string) skill.Roots
- func (p *Provider) SupportsPromptReminder() bool
- func (p *Provider) SupportsSessionStartBanner() bool
- func (p *Provider) SupportsSessionStartInstruction() bool
- func (p *Provider) UninstallHooks(repoRoot string) error
Constants ¶
const Name = "codex"
Name is the identifier stored in session records and evidence.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct{}
Provider connects Codex to Trace. It holds no session state.
func (*Provider) AnnouncePromptSubmit ¶
AnnouncePromptSubmit adds the reminder to the model's context.
func (*Provider) AnnounceSessionStart ¶
func (p *Provider) AnnounceSessionStart(msg trace.SessionStartMessage) error
AnnounceSessionStart sends the banner and instruction in one hook response.
func (*Provider) AnnounceToUser ¶
AnnounceToUser shows the session link and gives the model context to repeat it.
func (*Provider) CaptureFileSnapshot ¶
CaptureFileSnapshot reads the file at input.FilePath and stores its content under the store's snapshots/ directory so the post-tool-use handler can compute line-range diffs after the edit. A missing file (a patch creating a new file) is treated as a non-error; other read errors (permission denied, I/O failures) are surfaced.
func (*Provider) CleanupAfterEdit ¶
CleanupAfterEdit removes the per-edit snapshot. Safe to call when no snapshot was ever taken.
func (*Provider) CopySessionData ¶
CopySessionData refreshes a private transcript copy atomically. A missing transcript leaves the previous copy intact. Only Codex session storage is read.
func (*Provider) HooksInstalled ¶
HooksInstalled reports whether .codex/hooks.json holds any Chainloop hook. User-authored hooks are ignored.
func (*Provider) InstallHooks ¶
InstallHooks adds Chainloop hooks to .codex/hooks.json.
func (*Provider) InstallHooksForTraceRun ¶
InstallHooksForTraceRun installs every hook except SessionEnd; trace run drives end-of-session itself.
func (*Provider) IsCommandTool ¶
IsCommandTool returns true if the named tool runs a shell command.
func (*Provider) IsFileWritingTool ¶
IsFileWritingTool returns true if the named tool modifies files on disk.
func (*Provider) NewSkillLoads ¶
NewSkillLoads recognizes newly completed loads in the live rollout. It validates storage and session identity before returning any skill folder. Pending tool calls are rescanned so a result in the next hook can pair with its original call. The offset counts completed uses, not pending calls.
func (*Provider) ParseSession ¶
func (p *Provider) ParseSession(ctx context.Context, opts *trace.ParseOpts) (*aicodingsession.Evidence, error)
ParseSession reads only the private rollout copy. Unknown record types stay in the raw transcript, because the Codex rollout format can evolve.
func (*Provider) PastedImages ¶
func (p *Provider) PastedImages(raw map[string][]json.RawMessage) []trace.PastedImage
PastedImages extracts each distinct user image from native or normalized rollouts. The digest identifies the model-visible bytes, not a file path.
func (*Provider) ReadHookInput ¶
ReadHookInput reads and parses the Codex hook JSON from the given reader.
func (*Provider) ReplaceSpecCopies ¶
func (p *Provider) ReplaceSpecCopies(raw map[string][]json.RawMessage, sources pointer.Sources) pointer.Report
ReplaceSpecCopies replaces exact source copies only after material storage. Results and native duplicates use the same digest mapping as viewer messages.
func (*Provider) ResolveBeforeContent ¶
func (p *Provider) ResolveBeforeContent(store *state.Store, input *trace.HookInput, _ []byte) []byte
ResolveBeforeContent returns the snapshot saved by CaptureFileSnapshot. The "after" argument is unused for Codex — we always rely on the pre-edit snapshot — but is part of the interface for providers that reconstruct from edits instead of snapshots.
func (*Provider) SessionSkills ¶
SessionSkills reads the private rollout copy, never the current agent file.
func (*Provider) SettingsFile ¶
SettingsFile returns the absolute path to .codex/hooks.json for the given repo.
func (*Provider) SkillRoots ¶
SkillRoots classifies the filesystem-backed skill scopes known to Codex.
func (*Provider) SupportsPromptReminder ¶
SupportsPromptReminder reports whether Codex accepts context at each prompt.
func (*Provider) SupportsSessionStartBanner ¶
SupportsSessionStartBanner reports whether Codex shows systemMessage to the user.
func (*Provider) SupportsSessionStartInstruction ¶
SupportsSessionStartInstruction reports whether Codex accepts startup context.
func (*Provider) UninstallHooks ¶
UninstallHooks removes Chainloop hooks from .codex/hooks.json.