Skip to main content

Fast local search for OpenClaw session transcript JSONL files.

Project description

openclaw-session-grep

openclaw-session-grep is a small CLI for quickly searching local OpenClaw session and transcript files. It is meant for finding prior conversations, tool usage, errors, expensive model runs, channel-specific history, and session labels without manually opening JSONL files.

It stays deliberately narrow: fast transcript search with useful filters, not an analytics database.

Install

pipx install openclaw-session-grep

For local development:

python -m venv .venv
. .venv/bin/activate
python -m pip install -e ".[dev]"

Where It Searches

By default, the CLI searches these locations if they exist:

  • $OPENCLAW_SESSION_DIR
  • $OPENCLAW_TRANSCRIPT_DIR
  • ~/.openclaw/sessions
  • ~/.openclaw/transcripts
  • ~/.openclaw

OPENCLAW_SESSION_DIR and OPENCLAW_TRANSCRIPT_DIR may contain multiple paths separated with your platform path separator. You can also pass --path one or more times to search specific files or directories.

Candidate files currently use these extensions: .jsonl, .json, .log, and .ndjson.

Examples

openclaw-session-grep "morning briefing"
openclaw-session-grep "timeout" --channel telegram --last 7d
openclaw-session-grep "message tool" --agent main --json
openclaw-session-grep "network\\s+timeout" --regex --tool-only
openclaw-session-grep --tool shell --summary
openclaw-session-grep "briefing" --context 2 --open

Filters

  • --agent main
  • --channel telegram
  • --last 7d, --last 24h, --since 2026-04-10T00:00:00Z, --until ...
  • --model gpt-5.4
  • --tool message
  • --session alpha
  • --type assistant|user|tool|system
  • --tool-only

Search is case-insensitive by default. Use --case-sensitive to change that, and --regex to treat the query as a Python regular expression.

Output Modes

Default terminal output includes timestamp, session, agent, channel, optional tool name, and a short excerpt.

Other modes:

openclaw-session-grep "timeout" --json
openclaw-session-grep "timeout" --markdown
openclaw-session-grep "timeout" --count-only
openclaw-session-grep "timeout" --summary

Use --usage to include usage/cost fields when present in the transcript record. Use --open to include path:line references.

Transcript Format

OpenClaw transcript schemas may vary, so the parser is intentionally tolerant. It reads newline-delimited JSON and extracts common fields such as:

  • timestamp: timestamp, time, created_at, createdAt, ts
  • session: session_key, sessionKey, session, label, conversation_id
  • agent: agent, agent_id, agentId, role
  • channel: channel, source, transport
  • message type: type, kind, role
  • model: model, model_name, modelName
  • tool: tool, tool_name, toolName, tool.name, function.name, first tool_calls[]
  • usage/cost: usage, cost, token_usage, tokenUsage

Malformed JSON lines are treated as plain text records so older logs can still be searched.

Performance Notes

The utility streams candidate files by path, then loads one transcript file at a time to support context records around each hit. That keeps memory bounded by the largest single transcript file rather than the whole transcript directory.

For large stores, pass a narrower --path, combine structured filters, or use --limit when you only need the first few hits.

Known Limitations

  • There is no persistent index; every invocation scans files.
  • Date filters skip records without timestamps instead of rejecting them.
  • Tool and structured filters are exact matches.
  • JSON object files that are not line-delimited are not recursively unpacked as full transcript arrays yet.

Development

python -m pip install -e ".[dev]"
python -m unittest discover -s tests

Sample fixtures live in tests/fixtures.

Releases

Tagged releases use GitHub Actions:

  • v* tags build and publish distributions to PyPI using PyPI trusted publishing.
  • The Homebrew workflow updates pfrederiksen/homebrew-tap with a formula that installs from the PyPI source distribution.

Do not commit PyPI tokens. Configure PyPI trusted publishing for this repository, or store credentials as GitHub Actions secrets if you choose a different release strategy.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openclaw_session_grep-0.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openclaw_session_grep-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file openclaw_session_grep-0.1.0.tar.gz.

File metadata

  • Download URL: openclaw_session_grep-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openclaw_session_grep-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4c75134c605197f93a57daf7d61a1bbc85c8eedbbea6467fbe41f44f1a7fd0a1
MD5 f403484ec1f1fd692ee9cfba7655ccba
BLAKE2b-256 502ed879d8dc3a96738bba866ddea474adf1c124589b9a30ce58dd19bf37971a

See more details on using hashes here.

File details

Details for the file openclaw_session_grep-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openclaw_session_grep-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8817525b074b60b0c2067e8026f1a46c9a4875a5f03dd4720e7b481e8a53ee43
MD5 f6468b3337305d3a717adcdffe8bba36
BLAKE2b-256 8703a48ab1713bbbed2f5b913444e2c173d1a2ae0ce9f8a05fd706ef30dc03d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page