@techsavvyash/messages is a provider-neutral format for agent conversations. A conversation is a Thread plus its Messages, and each message holds typed blocks: text, reasoning, tool calls and results, file changes, web searches and attachments. Use it when you need to keep a conversation in a form no single harness owns, or move one between Claude Code and Codex. The adapters parse each harness’s native JSONL into the format and emit it back out, and they report what they skipped or dropped.

It’s clanker’s messages package from dough-quiver, ported into dough. The format and the adapters behave as they did there, with one change: records are checked with Effect schemas, so a thread or message with an invalid nested field is rejected, and skipped when a store reads it back. Clanker’s guards only checked the top level. The internals run on Effect 4, with Promise functions for code that isn’t on Effect.

npm install @techsavvyash/messages

effect comes with it. Import it yourself only if you use the Effect API.

Example

Read a Codex rollout, keep it in a store, and write it out as a Claude Code session:

import { readFile } from "node:fs/promises";
import { JsonlMessageStore, emitClaudeSession, messageText, parseCodexRollout } from "@techsavvyash/messages";
 
const parsed = parseCodexRollout(await readFile("rollout.jsonl", "utf8"));
console.log(parsed.report); // { skipped: { ... }, notes: [...] }
 
const store = new JsonlMessageStore(".messages");
await store.putThread(parsed.thread);
for (const message of parsed.messages) await store.appendMessage(message);
 
const messages = await store.getMessages(parsed.thread.id);
console.log(messages.map(messageText));
 
const session = emitClaudeSession(parsed.thread, messages, { cwd: "/repo" });
// session.lines: one Claude Code session line each, ready to write to
// ~/.claude/projects/<claudeProjectDirName("/repo")>/<session.sessionId>.jsonl

The format

type Thread = {
  v: 1;
  id: string;
  agentId?: string;
  parentThreadId?: string; // sidechain and subagent threads point at their parent
  originMessageId?: string; // and at the message they were spawned from
  title?: string;
  createdAt: string; // ISO 8601
  metadata?: JsonObject; // cwd, gitBranch, model, originator, cliVersion, ...
};
 
type Message = {
  v: 1;
  id: string; // ours; the source's id is provenance.sourceId
  threadId: string;
  turnId?: string;
  parentId?: string; // kept from tree-shaped sources (Claude's parentUuid)
  role: "user" | "assistant" | "system" | "tool";
  ts: string; // ISO 8601
  runId?: string;
  content: Block[];
  usage?: { inputTokens?: number; outputTokens?: number; cacheReadTokens?: number };
  provenance?: Provenance; // provider, channel ("live" | "session-file"), sessionId, sourceId, sidechain
  raw?: JsonValue; // the original source record, when the adapter is asked to keep it
};
 
type Block =
  | { type: "text"; text: string }
  | { type: "reasoning"; text?: string; redacted?: boolean }
  | { type: "tool_call"; callId: string; name: string; input: JsonValue }
  | { type: "tool_result"; callId: string; output: JsonValue; isError?: boolean }
  | { type: "file_change"; callId?: string; path?: string; patch?: string }
  | { type: "web_search"; callId?: string; query: string; results?: JsonValue }
  | { type: "attachment"; mediaType?: string; uri?: string; data?: string }
  | { type: "unknown"; sourceType: string; raw: JsonValue };
  • Helpers: MESSAGE_FORMAT_VERSION (1), newMessageId(), messageText(message) (the text blocks joined with newlines), and the guards isThread and isMessage.
  • Schemas: ThreadSchema, MessageSchema and BlockSchema are Effect schemas. They check nested blocks and optional fields, so a message with a non-string text fails isMessage.

Stores

A MessageStore has five methods, all returning Promises:

MethodWhat it does
putThread(thread)Store a thread. Writing the same id again replaces it
getThread(id)The thread, or undefined
listThreads(filter?)Threads, filtered by agentId and parentThreadId
appendMessage(message)Add a message to its thread
getMessages(threadId, options?)Messages in append order. afterId returns those after a message, limit caps the count. An unknown afterId returns []
  • MemoryMessageStore: for tests and short runs.
  • JsonlMessageStore(directory): appends to threads.jsonl and messages.jsonl in the directory, creating it on the first write. The last write of a thread wins. A line that isn’t a valid thread or message is skipped on read, and the files are never rewritten.

Dough’s gateway is meant to inject its own database-backed MessageStore. This package doesn’t wire one in.

Adapters

FunctionDirection
parseClaudeSession(input, options?)Claude Code session JSONL to a thread, its messages, and children (sidechain threads)
parseCodexRollout(input, options?)Codex rollout JSONL to a thread and its messages
emitClaudeSession(thread, messages, options?)Canonical messages to Claude Code session lines
emitCodexRollout(thread, messages, options?)Canonical messages to Codex rollout lines, with fileName and dateDir
  • Parse: input is a string or an iterable of lines. Options are threadId, agentId, runId and keepRaw (keep each source line as raw). The result’s report counts every source line that didn’t become a message, keyed by type, so nothing is dropped silently.
  • Emit: options include sessionId (generated if omitted) and cwd. A tool call with no result gets a placeholder result, so the transcript stays valid for the API. The report lists what was dropped and why. link stamps a sesh field that records where the session came from, which is how sesh finds the turns added after a handoff.
  • Paths: claudeProjectDirName(cwd), codexRolloutFileName(startedAt, sessionId) and codexRolloutDateDir(startedAt) give the names each harness uses on disk.

Effect API

  • Adapters: parseClaudeSessionEffect, parseCodexRolloutEffect, emitClaudeSessionEffect and emitCodexRolloutEffect defer the work and fail with a typed MessageError (operation, cause). messagesPromise has the same four as Promises.
  • Stores: MemoryMessageStoreEffect and JsonlMessageStoreEffect are the Effect stores. Each Promise store exposes its Effect store as store.effects. effectMessageStore(promiseStore) and promiseMessageStore(effectStore) convert between the two.
import { Effect } from "effect";
import { JsonlMessageStoreEffect, parseCodexRolloutEffect } from "@techsavvyash/messages";
 
const store = new JsonlMessageStoreEffect(".messages");
const program = parseCodexRolloutEffect(rolloutText).pipe(
  Effect.tap((parsed) => store.putThread(parsed.thread)),
  Effect.tap((parsed) => Effect.forEach(parsed.messages, store.appendMessage))
);
  • Sesh is built on this format: it parses a session with these adapters and emits it for the other harness.
  • Threads has its own Claude Code and Codex adapters. They pull out text for orchestration, where this package keeps the structured blocks and can write transcripts back. Neither package depends on the other.
  • Bus and Pad don’t use it.