Skip to main content

Crate agent_session

Crate agent_session 

Source
Expand description

Portable session IR, parsers, discovery, and process matching for local AI coding-agent transcripts.

The crate currently normalizes Claude Code, Codex, and Gemini CLI sessions. It intentionally stops at session data and process/session correlation; UI, database storage, eBPF collection, and OpenTelemetry export belong in applications that consume this crate.

Structs§

AgentSession
A parsed agent session with metadata, token usage, and tool invocations.
LiveProcessCandidate
A live process candidate for session matching.
ProcessKey
Unique identifier for a process (pid + start time).
ProcessTree
A tree of related processes.
SessionCache
Cache for discovered and parsed sessions.
SessionCandidate
A candidate session file discovered on disk.
SessionDirStat
Statistics about a session directory.
SessionProcessInput
Input for session-to-process matching.
SessionProcessMatch
A match between a session and a process.
SessionProcessMatcher
Stateful matcher for correlating sessions with live processes.
SessionProcessMatches
Collection of session-to-process matches.
TokenUsage
Token usage statistics for a model or session.

Constants§

AGENT_CLAUDE
AGENT_CODEX
AGENT_GEMINI
SOURCE_SESSION_PROCESS_MATCH
TRACE_EBPF_FILE
TRACE_PROC_FD
TRACE_RECENT_CWD
TRACE_STICKY_BINDING

Functions§

agent_source_for_path
Detect which agent a session file belongs to based on its path.
codex_exec_prompt
Extract the prompt from a Codex exec command.
count_session_dirs
Count sessions and bytes per agent directory.
discover_session_files
Discover all session files in the user’s home directory.
discover_session_files_in_home
Discover session files under a specific home directory.
fixture_session_path
Generate a fixture session path for testing.
is_codex_cli_entrypoint
Check if a target path is the Codex CLI entrypoint.
normalize_session_log_path
Canonicalize a session log path.
parse_session_content
Parse session content given raw content string.
parse_session_file
Parse a session file from a candidate.
parse_session_path
Parse a session file by path, detecting the agent type automatically.
session_log_path_from_str
Extract a session log path from a string (e.g., from /proc/fd).