Overview
The history sync modules import past agent sessions from local history files into the Codaph mirror and memory stores. Each provider has a dedicated sync function.Codex History Sync
syncCodexHistory
Imports Codex session history from~/.codex/sessions/.
Project root path to match against session CWDs
Additional project paths to match (for multi-root workspaces)
Ingest pipeline for event processing
Repository ID (auto-generated if not provided)
Actor ID to assign to imported events
Custom path to Codex sessions directory (defaults to
~/.codex/sessions)Custom mirror root (defaults to
.codaph in project)Progress callback invoked periodically during sync
Total JSONL files scanned
Files that matched the project path
Total events imported
Unique sessions imported
Claude Code History Sync
syncClaudeHistory
Imports Claude Code history from~/.claude/projects/.
Project root path to match
Additional project paths
Ingest pipeline
Repository ID
Actor ID for events
Custom Claude projects directory (defaults to
~/.claude/projects)Mirror root directory
Progress callback
Total files scanned
Files matching project
Events imported
Sessions imported
Gemini CLI History Sync
syncGeminiHistory
Imports Gemini CLI history from~/.gemini/history/ and ~/.gemini/tmp/.
Project root path
Additional project paths
Ingest pipeline
Repository ID
Actor ID
Custom Gemini history directory (defaults to
~/.gemini/history)Mirror root
Progress callback
Files scanned
Files matched
Events imported
Sessions imported
Common Patterns
Incremental Sync
All sync functions maintain state to avoid re-importing:- File-level tracking: Uses size and mtime to detect unchanged files
- Line/entry cursors: Resumes from last processed line
- State persistence: Stores sync state in
.codaph/index/{repoId}/{provider}-history-sync.json
Project Matching
History files are matched against the project using:- CWD extraction: Reads session working directory from history metadata
- Path normalization: Resolves symlinks and canonicalizes paths
- Multi-root support: Matches against all configured project paths
Event Projection
Each provider transforms native history format to Codaph events:| Provider | Source Format | Projected Events |
|---|---|---|
| Codex | session_meta, response_item, event_msg | thread.started, prompt.submitted, item.completed |
| Claude | user, assistant messages | prompt.submitted, item.completed (reasoning, messages) |
| Gemini | Tool calls, message pairs | prompt.submitted, item.completed (messages, file changes) |