Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mubit-ai/codaph/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Codaph provides two direct capture adapters for running Codex agents and capturing their sessions in real-time:codaph run— Uses Codex SDK (@openai/codex-sdk) for programmatic agent executioncodaph exec— Wrapscodex exec --jsonCLI output for streaming capture
.codaph mirror and Mubit cloud as the agent runs.
Most users should use
codaph push to import agent history after running agents normally. Direct capture is for advanced workflows requiring inline capture.Codex SDK Adapter (codaph run)
Overview
The Codex SDK adapter uses the@openai/codex-sdk npm package to run agents programmatically and capture events.
Source: src/lib/adapter-codex-sdk.ts:58
Installation
Usage
--cwd <path>— Working directory for agent execution--model <name>— Codex model to use--resume <threadId>— Resume existing thread--mubit— Enable Mubit cloud sync (default ifMUBIT_API_KEYset)--local-only— Disable Mubit, write only to local mirror
How It Works
- Initialize SDK: Detects
codexbinary path viaCODAPH_CODEX_PATHorwhich codex - Start thread: Creates new thread or resumes existing via
resumeThreadId - Stream events: Listens to
runStreamed()async iterator - Ingest pipeline: Each event flows through:
- Redaction (
src/lib/security.ts:26) — strips sensitive data - Canonicalization (
src/lib/core-types.ts:130) — addseventId,actorId, timestamps - Mirror write (
src/lib/mirror-jsonl.ts:74) — appends to local JSONL - Mubit write (
src/lib/memory-mubit.ts:143) — pushes to cloud (if enabled)
- Redaction (
- Extract response: Captures final agent message from
item.completedevent
Example Session
Architecture
src/lib/adapter-codex-sdk.ts:73
Codex Path Detection
The adapter resolves the Codex binary path:src/lib/adapter-codex-sdk.ts:18
Priority:
CODAPH_CODEX_PATHenvironment variableCODEX_PATHenvironment variablewhich codex(orwhere codexon Windows)
Codex Exec Adapter (codaph exec)
Overview
The Codex exec adapter wrapscodex exec --json and parses its streaming JSON output.
Source: src/lib/adapter-codex-exec.ts:50
Usage
--cwd <path>— Working directory for agent execution--model <name>— Codex model to use--resume <threadId>— Resume existing thread--mubit— Enable Mubit cloud sync--local-only— Disable Mubit
How It Works
- Build args: Constructs
codex execcommand with--jsonflag - Spawn process: Launches
codex execas child process - Parse JSON lines: Reads stdout line-by-line using
readline.createInterface - Ingest events: Each valid JSON line flows through the same pipeline as SDK adapter
- Handle errors: Stderr captured and logged; non-zero exit codes throw error
Command Construction
src/lib/adapter-codex-exec.ts:32
Generated command:
JSON Line Parsing
src/lib/adapter-codex-exec.ts:17
Each line must:
- Be valid JSON
- Have a
typefield (event type)
Event Stream Processing
src/lib/adapter-codex-exec.ts:85
Common Options
Both adapters support:Working directory for agent execution (defaults to current directory)
Codex model name (e.g.,
codex-base, codex-plus)Resume existing thread by thread ID
Enable Mubit cloud sync (default if
MUBIT_API_KEY set)Disable Mubit, write only to local
.codaph mirrorOverride Mubit API key for this session
Event Types Captured
Both adapters capture these event types:prompt.submitted— Initial promptthread.started— Thread created (capturesthread_id)item.started— Agent starts processingitem.streaming— Streaming response chunksitem.completed— Agent completes response (captures final text)tool.started— Tool execution beginstool.completed— Tool execution completeserror— Errors during execution
When to Use Each Adapter
| Scenario | Use |
|---|---|
| One-off agent run with capture | codaph exec (simpler, wraps CLI) |
| Programmatic agent execution | codaph run (SDK-based, more control) |
| Existing Codex workflow | codaph push (import history after) |
| Custom integrations | Import adapters in your own code |
Example: Custom Integration
Troubleshooting
”codex command not found”
Ensure Codex is installed and in your PATH:“Mubit write failed”
Check Mubit configuration:Invalid JSON in exec output
Ifcodex exec --json outputs invalid JSON, events are logged as errors but capture continues. Check:
Related
codaph push— Import agent history (recommended for most users)- Ingest Pipeline — Event processing flow
- Redaction — Sensitive data filtering
- Mubit Memory — Cloud memory engine
Implementation
Sources:- SDK adapter:
src/lib/adapter-codex-sdk.ts:58 - Exec adapter:
src/lib/adapter-codex-exec.ts:50 - Ingest pipeline:
src/lib/ingest-pipeline.ts:14 - Core types:
src/lib/core-types.ts:18
test/lib-adapter-codex-sdk.test.tstest/lib-adapter-codex-exec.test.ts