codex

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 18 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 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

View Source
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 (a *Adapter) Capabilities() []string

func (*Adapter) CodexHome

func (a *Adapter) CodexHome() string

CodexHome returns the Codex state directory.

func (*Adapter) Detect

func (a *Adapter) Detect(ctx context.Context) adapter.Detection

func (*Adapter) Doctor

func (a *Adapter) Doctor(ctx context.Context, opts adapter.InstallOptions) []adapter.Check

func (*Adapter) Enabled

func (a *Adapter) Enabled() bool

Enabled reports whether the Codex adapter is installed (the importer only runs then).

func (*Adapter) HooksPath

func (a *Adapter) HooksPath() string

HooksPath is the user-level hooks file.

func (*Adapter) Install

func (a *Adapter) Install(ctx context.Context, opts adapter.InstallOptions) error

func (*Adapter) MCPCheck

func (a *Adapter) MCPCheck(ctx context.Context) adapter.Check

MCPCheck verifies that Codex runs MemSpace's stdio bridge.

func (*Adapter) Name

func (a *Adapter) Name() string

func (*Adapter) NewImporter

func (a *Adapter) NewImporter() *Importer

NewImporter returns the rollout importer configured at install time.

func (*Adapter) Normalize

func (a *Adapter) Normalize(raw []byte, now time.Time) ([]spool.Record, error)

Normalize handles a Codex hook invocation. Only SessionEnd produces an event; everything else is captured from the rollout by the importer.

func (*Adapter) RegisterMCP

func (a *Adapter) RegisterMCP(ctx context.Context, opts adapter.MCPOptions) error

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.

func (*Adapter) Uninstall

func (a *Adapter) Uninstall(ctx context.Context, out io.Writer) error

func (*Adapter) UnregisterMCP

func (a *Adapter) UnregisterMCP(ctx context.Context) error

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.

func (*Importer) Import

func (im *Importer) Import(ctx context.Context, sp *spool.Spool, heartbeat func()) (int, error)

Import processes new rollout lines. It stops early (without losing its place) when the spool is full.

func (*Importer) Name

func (im *Importer) Name() string

func (*Importer) Stats

func (im *Importer) Stats() (files int, lastImport time.Time)

Stats reports importer progress for doctor/status.

Jump to

Keyboard shortcuts

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