omp packages

@agntn/sessions0.2.0

Read normalized AI coding sessions across harnesses.

GitHub Actions Published 2 days ago MIT ~495 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

@agntn/sessions

npm version npm downloads license Ask DeepWiki

๐Ÿ“š Read conversations from twelve AI coding harnesses through one TypeScript API. Your agent can read them too.

Why?

The conversation you need is in another harness. Of course it is. @agntn/sessions reads each native store where it already sits and returns the same Session, Message and Block shapes. Build your viewer, export, or index without collecting parsers as a side hobby.

โœจ Features

  • ๐Ÿงฉ Twelve harnesses, one shape. Stop juggling twelve session formats.
  • ๐Ÿค– Agents included. Three read-only tools, written once and wired into five hosts.
  • ๐Ÿ“– Bounded reads. Continue where you left off, even in the middle of a block.
  • ๐Ÿ“ Directory filter. Match a working directory and everything below it with cwd.
  • ๐Ÿšฆ Honest errors. Tool results keep the harness's own isError. No flag means unknown, not success.
  • ๐Ÿ›‘ Visible stops. A Pi, OMP, Vibe or Hermes turn that ended early says so: [stop error] Connection error.
  • ๐Ÿงพ No paying twice. knownToolResults swaps output you already read for digest references.

๐Ÿ“ฆ Install

pnpm add @agntn/sessions

You'll need Node.js 26 or later.

๐Ÿš€ First call

Want to see what happened in the last day? Run this:

npx @agntn/sessions list --last-hours 24
Sources: claude. Last activity: since=2026-11-24T16:41:41.269Z (inclusive). Reuse these bounds instead of lastHours when paging.
claude	7f3c2a10-5b8e-4d21-9c6a-0e4f1b2d3a91	4 messages	2026-11-25T16:02:40.935Z	/work/shop	Why is CI red again?

After a local install, pnpm exec sessions gives you the bare sessions command below. Or run pnpm add -g @agntn/sessions once and keep it around.

sessions read claude 7f3c2a10-5b8e-4d21-9c6a-0e4f1b2d3a91
[2026-11-25T15:59:40.935Z] user
Why is CI red again?

[2026-11-25T16:00:40.935Z] assistant
[tool_call Bash toolu_1] {"command":"pnpm test"}

[2026-11-25T16:01:40.935Z] user
[tool_result toolu_1 isError=true] FAIL test/cart.test.ts > applies the discount
expected 90 to be 81

[2026-11-25T16:02:40.935Z] assistant
The discount gets applied twice. Fixing `applyDiscount`.

No key and no config. It reads what's already on disk. And yes, CI had a point.

๐Ÿง  Library

import { create } from "@agntn/sessions";

const reader = create("claude");
if (reader.available()) {
  for (const session of await reader.list()) {
    console.log(session.id, session.updatedAt, session.messages.length);
  }
}

And you're off. Moved your archive? Pass create("claude", { path: "/custom/claude/projects" }). Spread over a few folders? paths reads them all. Mind the archive size, though. list() hauls every message into memory. For big ones, listSourceSessions and readSourceSession read a page at a time. Only after the newest messages? readSourceSessionTail skips the paging.

More in the public exports, window types, session contract and message types.

๐Ÿ—‚๏ธ Which harnesses?

Harness Source name
Claude Code claude
Codex codex
Gemini CLI gemini
Grok grok
Hermes Agent hermes
Mastra mastra
Mistral Vibe vibe
OMP omp
OpenBot openbot
OpenClaw openclaw
OpenCode opencode
Pi pi

OpenBot keeps no tool calls. Each message's context names the providerSessionId instead, so hand it to the codex or claude reader. Vibe subagent runs show up as sessions of their own. Overrides and parsers live in the source registry.

๐Ÿค– Agent tools

Three read-only tools, the same in MCP, Pi, OMP, the AI SDK and the CLI:

Tool What you get
sessions_sources Supported harnesses and local data availability
sessions_list Session IDs, message counts, last activity, working directories, owners, and snippets, newest first
sessions_read A bounded message window from one exact session ID

One call with { "lastHours": 24 } covers every available harness. Read the interesting conversation, not the whole haystack. Same prompt in four repos? Four identical snippets. A fine collection of mystery twins. Filter with { "cwd": "/work/project" }. Sessions without a recorded directory never match.

MCP

{
  "mcpServers": {
    "sessions": {
      "command": "npx",
      "args": [
        "-y",
        "-p",
        "@agntn/sessions",
        "-p",
        "@modelcontextprotocol/server",
        "sessions",
        "mcp"
      ]
    }
  }
}

The server speaks stdio and works with 2025 and 2026 MCP clients. For your own transport, take createMcpServer() from @agntn/sessions/mcp. Running sessions mcp locally? Add @modelcontextprotocol/server yourself. Library users don't have to carry a server they never start.

Pi and OMP

pi install npm:@agntn/sessions
omp install @agntn/sessions

Both load the same tool definitions as MCP and the CLI.

AI SDK

One import gives your generateText loop all three session tools. No wrappers.

pnpm add @agntn/sessions ai @ai-sdk/anthropic
import { anthropic } from "@ai-sdk/anthropic";
import { sessionsAiTools } from "@agntn/sessions/ai";
import { generateText, isStepCount } from "ai";

const { text } = await generateText({
  model: anthropic("claude-sonnet-5-5"),
  tools: sessionsAiTools,
  stopWhen: isStepCount(5),
  prompt: "What was I working on yesterday?",
});

Your model can catch up on yesterday's conversations with other models. It gets the same text an MCP client reads. All three tools only read, so none waits for approval.

CLI

sessions list --source pi --last-hours 24 --limit 5
sessions read pi SESSION_ID --max-chars 4000
sessions list --sources '["pi","codex"]' --json

Your terminal prints exactly what the model gets from the tool. Agent says a session doesn't exist? Check it yourself with the same call. Prefer structured details? Pass --json.

Long sessions

Copy the returned position to continue, and set maxChars to fit your budget. since and until cut a time window. Pass knownToolResults to swap tool output you already read for digest references. Every limit is in the tool schemas.

Just catching up? Set fromEnd for the last limit messages, oldest first. No counting, no offset arithmetic, and a session that's still growing can't move the tail on you.

A failed command buried in a 17 MB transcript? Skip the scrolling with errorsOnly and countOnly, then jump straight to it. roles and toolNames cut a read down the same way.

Session text can contain private data. Only connect clients you trust with it.

๐Ÿšซ Just the reader

No database of its own, no sync cursors, watchers, search, analytics or long-term agent memory. Your application owns storage, indexing, rendering and export. Reading a conversation also doesn't resume it in the original harness.

๐Ÿ› ๏ธ Development

pnpm install --frozen-lockfile
pnpm build
node dist/cli.mjs --help
pnpm fmt        # Format and apply lint fixes
pnpm lint       # Check lint and formatting
pnpm typecheck  # Check the library and extensions
pnpm test:run   # Run the fixture and integration tests

Adding a harness? Start with the adapter contract and parser tests. Keep native format quirks in the adapter, not in your caller.

๐Ÿ’› Thanks

Built with support from Claude for Open Source and Codex for Open Source. More room to build things like this. Much appreciated.

๐Ÿ“„ License

MIT