← All @molecule/* packages · App templates
@molecule/api-agent-transcript-autodetectProvider bond · agent-transcript · API (Node) · v1.0.0 · Apache-2.0
Picks the reader that recognizes a transcript and delegates to it; bundles the Claude Code, Codex and Molecule IDE readers
npm install @molecule/api-agent-transcript-autodetectnpm · Source on GitHub · Implements @molecule/api-agent-transcript
@molecule/api-agent-transcript-autodetect is a provider bond on the API (Node) side: it implements the agent-transcript core interface (@molecule/api-agent-transcript) with a concrete vendor or library behind it.
Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.
import { readdirSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
import { readTranscript, setProvider } from '@molecule/api-agent-transcript'
import { provider } from '@molecule/api-agent-transcript-autodetect'
setProvider(provider)
const dir = 'transcripts/my-post'
const sessions = readdirSync(dir).map((f) =>
readTranscript({ text: readFileSync(join(dir, f), 'utf8'), fileName: f }),
)Works with: @molecule/api-agent-transcript
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
The transcript reader to bond when files can come from more than one harness.
Implements @molecule/api-agent-transcript by trying each bundled reader's
detect() and delegating to the first that recognizes the file: Claude Code
(/export text, session .jsonl), Codex CLI (Markdown export, rollout
.jsonl) and the Molecule IDE (stored conversation JSON). createReader()
composes any other list, including readers of your own.
import { readdirSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
import { readTranscript, setProvider } from '@molecule/api-agent-transcript'
import { provider } from '@molecule/api-agent-transcript-autodetect'
setProvider(provider)
const dir = 'transcripts/my-post'
const sessions = readdirSync(dir).map((f) =>
readTranscript({ text: readFileSync(join(dir, f), 'utf8'), fileName: f }),
)
provider
npm install @molecule/api-agent-transcript-autodetect @molecule/api-agent-transcript @molecule/api-agent-transcript-claude-code @molecule/api-agent-transcript-codex @molecule/api-agent-transcript-molecule-ide
createReader(readers)Compose readers: the first whose detect() accepts the input reads it.
function createReader(readers: readonly AgentTranscriptReader[]): AgentTranscriptReader
readers — The readers to try, in order.Returns: One reader over all of them.
providerReads any Claude Code, Codex CLI or Molecule IDE transcript.
const provider: AgentTranscriptReader
Implements @molecule/api-agent-transcript interface.
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/api-agent-transcript'
import { provider } from '@molecule/api-agent-transcript-autodetect'
export function setupAgentTranscriptAutodetect(): void {
setProvider(provider)
}
Peer dependencies:
@molecule/api-agent-transcript ^1.0.0@molecule/api-agent-transcript
@molecule/api-agent-transcript-claude-code
@molecule/api-agent-transcript-codex
@molecule/api-agent-transcript-molecule-ide
A file no reader recognizes throws, naming the file and the readers
tried — it is never read as an empty session. Check canReadTranscript()
first to skip non-transcript files (a README beside the exports).
Order matters only for a file two readers would both accept; the bundled readers accept disjoint formats.