@latten/adapter-codex
v0.1.0
Published
Adapter: parse Codex CLI session rollouts (~/.codex/sessions/**/*.jsonl) into a Latten Session. Reads token counts and hashes tool args/results on-device; the Session carries only counts and hashes, never raw prompts/code/output.
Maintainers
Readme
@latten/adapter-codex
See what your Codex sessions cost. Locally, in seconds.
This adapter parses Codex CLI rollouts (~/.codex/sessions/**/*.jsonl) into a
Latten session model, so the @latten/cost detectors can point at recoverable
spend — redundant round trips, stuck loops, uncached context — on your machine,
with nothing sent anywhere.
Install
npm install @latten/adapter-codex @latten/costUsage
Three lines to your last 24 hours:
import { readCodexSessions } from '@latten/adapter-codex'
import { detectStuckLoop } from '@latten/cost'
const sessions = await readCodexSessions({ sinceMs: Date.now() - 86_400_000 })
sessions.forEach((s) => console.log(s.sessionId, detectStuckLoop(s)))Need control? findCodexRollouts() and parseCodexRollout() are the pieces
readCodexSessions() is made of — bring your own file list, inject a price
function per model, or parse a single transcript string.
Prefer zero code? npx @latten/glow reads the same rollouts and shows your
usage across every coding agent in one view.
What it extracts
- Per-call token counts from Codex
token_countevents — input, output, and the cached portion split out, so cache misses are visible. - Model name per call (from the turn context), for accurate pricing.
- Tool calls (
shell,exec,web_search, …) with stable hashes of their arguments, and tool outputs hashed for equality checks. - Read-only discovery classification for common tools and shell commands, so
detectors never mistake
git statusfor real work. - Assistant text hashes for repeated-output loop detection.
Privacy model
The session files this adapter reads contain your prompts, code, and command output. None of that survives parsing:
- prompts and developer messages are dropped entirely, not even hashed;
- tool arguments, outputs, and assistant text are reduced to on-device SHA-256 hashes, used only for local equality checks;
- token counts and tool types are the only facts that leave the parser;
- pricing is injected by the caller — the parser never touches the network;
- malformed or partial JSONL lines are ignored.
This is the same values-never contract as every Latten package: types and counts, never values. The test suite asserts it — serialize a parsed session and the raw content is provably absent.
Part of the Latten session model
@latten/adapter-claude-code does the same for Claude Code transcripts, and
@latten/adapter-gemini covers Gemini CLI (honestly — see its README). One
session model, every agent your team runs.
You moved fast with AI. Latten helps you stay in control of it. See what your AI costs — and where your data goes: Latten turns the AI calls across your company into one live graph — cost, reach, and PII exposure, attributed and observed from real traffic. One prompt to your coding agent, a PR you review, live in minutes. latten.io
