Documentation
¶
Overview ¶
Package codex captures OpenAI Codex CLI activity and injects MemSpace context through its SessionStart / UserPromptSubmit hooks.
Codex hooks do not see everything (there is no tool-failure hook, and new hooks run only after the user trusts them), so the source of truth is the rollout file Codex writes for every session. Hooks (SessionStart, Stop, SessionEnd) only trigger an incremental import, and SessionEnd records the end of the session, which the rollout does not. Without trusted hooks, `memspace client sync` still imports on its own.
Index ¶
- Constants
- type Adapter
- func (a *Adapter) Capabilities() []string
- func (a *Adapter) CodexHome() string
- func (a *Adapter) Detect(ctx context.Context) adapter.Detection
- func (a *Adapter) Doctor(ctx context.Context, opts adapter.InstallOptions) []adapter.Check
- func (a *Adapter) Enabled() bool
- func (a *Adapter) HooksPath() string
- func (a *Adapter) Install(ctx context.Context, opts adapter.InstallOptions) error
- func (a *Adapter) MCPCheck(ctx context.Context) adapter.Check
- func (a *Adapter) Name() string
- func (a *Adapter) NewImporter() *Importer
- func (a *Adapter) Normalize(raw []byte, now time.Time) ([]spool.Record, error)
- func (a *Adapter) RegisterMCP(ctx context.Context, opts adapter.MCPOptions) error
- func (a *Adapter) Uninstall(ctx context.Context, out io.Writer) error
- func (a *Adapter) UnregisterMCP(ctx context.Context) error
- type Importer
Constants ¶
const AgentType = "codex"
AgentType is the agent_type stored on sessions.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// Home overrides the Codex home (default $CODEX_HOME or ~/.codex).
Home string
// StateDir is MemSpace's client state dir (import cursors, cutoff).
StateDir string
}
Adapter implements adapter.Adapter for Codex.
func (*Adapter) Capabilities ¶
func (*Adapter) Enabled ¶
Enabled reports whether the Codex adapter is installed (the importer only runs then).
func (*Adapter) NewImporter ¶
NewImporter returns the rollout importer configured at install time.
func (*Adapter) Normalize ¶
Normalize handles a Codex hook invocation. Only SessionEnd produces an event; everything else is captured from the rollout by the importer.
func (*Adapter) RegisterMCP ¶
RegisterMCP adds MemSpace as a stdio MCP server running the bridge (`memspace mcp stdio`), which reads this device's credentials itself, so config.toml holds a command and no token.
type Importer ¶
type Importer struct {
CodexHome string
StateDir string
// Since skips rollout lines older than this (zero: import everything).
Since time.Time
// Reset ignores saved cursors (used by explicit backfills).
Reset bool
}
Importer incrementally converts Codex rollout files (<CODEX_HOME>/sessions/YYYY/MM/DD/rollout-*.jsonl) into MemSpace events.
Rollouts are append-only JSONL with a per-line ordinal, so each file keeps a byte-offset cursor and event IDs are derived from (session, ordinal): re-reading a line after a crash produces the same event ID and the server deduplicates it.