An adapter is everything the core needs to know about one harness:

interface HarnessAdapter {
  readonly harness: string; // "pi", "claude", "codex", …
  // { sessionId, cwd, messages: [{ id, role, text }] }, active path only
  read(file: string): Effect<Transcript, TranscriptError, FileSystem>;
  // find a session's transcript on disk
  locate(sessionId: string): Effect<string | undefined, never, FileSystem>;
  launch(input: { prompt: string; cwd: string; args?: readonly string[]; thread?: string }): Effect<{ sessionId: string }, LaunchFailed, ChildProcessSpawner>;
}
  • read normalizes a native transcript. It returns only the active path: both Pi and Claude Code store a conversation as a tree of records linked by parent ids, and branches you abandoned aren’t part of the conversation. Codex session files are append-only, so there’s no tree to walk. Unreadable lines are skipped, because a harness may be partway through writing.
  • locate finds a transcript from its session id.
  • launch starts a fresh session whose first prompt is exactly prompt (the rendered seed), waits for it to exit, and returns the new session id. An import-only adapter can make launch fail with LaunchFailed.

Built in

Pi (pi)Claude Code (claude)Codex (codex)
Transcript~/.pi/agent/sessions/*/*_<id>.jsonl~/.claude/projects/*/<id>.jsonl~/.codex/sessions/YYYY/MM/DD/rollout-…-<id>.jsonl
Tree linksid / parentId on type: "message" recordsuuid / parentUuid; skips isMeta and isSidechainnone: session_meta, then response_items; compacted marks a compaction
Rolesuser, assistant, toolResult → tooluser, assistant, tool results → tooluser, assistant, tool calls → assistant, tool output → tool, injected <…> context → system
Launchpi -p --mode json; the first JSON line is the session recordclaude -p --output-format json; the result has session_idcodex exec --json --skip-git-repo-check -; the session id is the event stream’s thread_id

In every case the prompt is sent on stdin, so a long seed never hits argument-length limits.

Bringing your own harness

Implement HarnessAdapter and pass it wherever the library takes an adapter:

import { Effect } from "effect";
import { LaunchFailed, importTranscript, launchChild, type HarnessAdapter } from "@techsavvyash/threads";
 
const myHarness: HarnessAdapter = {
  harness: "my-harness",
  read: (file) => readMyTranscript(file), // Effect<Transcript, TranscriptError, FileSystem>
  locate: (sessionId) => Effect.succeed(`/sessions/${sessionId}.jsonl`),
  launch: ({ prompt, cwd }) =>
    Effect.tryPromise({
      try: () => startMySession(prompt, cwd),
      catch: (e) => new LaunchFailed({ message: String(e) })
    })
};
 
// Inside an Effect that has ThreadStore and the platform services provided (see the library page):
yield* importTranscript(myHarness, "/sessions/abc.jsonl");
yield* launchChild(myHarness, childId, { cwd: process.cwd() });

The CLI, the plugins and the visualiser launch only the built-in pi, claude and codex adapters by name. Your own adapter works through the library.

The source harness and the target harness can differ. A thread captured from Pi can be launched in Claude Code, and the reverse, because the seed is harness-neutral text.