/** * Generate a synthetic OpenCode storage tree. * * OpenCode does not use one file per session — it writes an object graph, so * the fixture has to build the same four directories the importer reads: * * session//.json * message//.json * part//.json * project/.json * * Ids are zero-padded counters because the importer orders parts and messages * lexicographically by id — that ordering is load-bearing, so the fixtures have * to reproduce it rather than rely on directory order. */ export declare class OcBuilder { private readonly sid; private readonly root; private t; private msgN; private partN; private curMsg; private readonly messages; private readonly parts; private readonly models; private reuse; private summary; private title; constructor(root: string, opts?: { sessionId?: string; start?: number; }); private tick; /** * Ids must be unique across *every* builder, not just within one: parts live * at `part//`, a path that carries no session id, so two builders * numbering their messages from 1 would silently share a parts directory and * graft each other's tool calls onto the wrong run. */ private newMessage; private addPart; /** * Make the next step attach to the current message instead of opening a new * one. * * Real assistant turns are routinely several parts — reasoning, then a tool * call, then the reply — and a fixture of one part per message cannot tell a * correct part ordering from a broken one, because there is never more than * one part to order. */ same(): this; /** Assistant messages carry the token counters and the agent's own cost. */ private assistant; user(text: string): this; say(text: string, opts?: { model?: string; cost?: number; }): this; think(text: string): this; edit(filePath: string, oldString: string, newString: string, ok?: boolean): this; write(filePath: string, content: string): this; bash(command: string, output: string, opts?: { error?: string; }): this; compact(): this; /** An unmapped part type — must be recorded as drift, never dropped. */ weird(type: string): this; idle(minutes: number): this; withSummary(files: number, additions: number, deletions: number): this; withTitle(title: string): this; /** Writes the storage tree and returns the session record's path. */ writeTo(): string; /** * Write the same session into a SQLite database, the way OpenCode does now. * * The identity fields are **stripped out of the JSON and put into columns**, * which is precisely what the real 2026-02 migration did — so a fixture built * this way exercises the shim that puts them back rather than quietly handing * the importer a shape it never sees in the wild. * * `reversed` inserts messages and parts in descending id order and stamps * every part with one identical `time_created`, reproducing a migrated row: * the migration collapsed every pre-existing `part.time_created` onto the * migration instant, so anything that orders by that column scrambles the * timeline. Ordering must come from the id. */ writeDbTo(dbPath: string, opts?: { reversed?: boolean; }): string; } /** * Enough of OpenCode's schema to exercise the importer. * * Column names and types mirror the real database. `session_message` is here * with no rows because it is in the real one too, staged for a migration that * has not happened yet — the importer watches it as a tripwire, and a fixture * without it could not test that. */ export declare const OC_DB_SCHEMA = "\nCREATE TABLE IF NOT EXISTS project (\n id TEXT PRIMARY KEY, worktree TEXT NOT NULL, vcs TEXT, name TEXT,\n time_created INTEGER NOT NULL DEFAULT 0, time_updated INTEGER NOT NULL DEFAULT 0,\n sandboxes TEXT NOT NULL DEFAULT '[]');\nCREATE TABLE IF NOT EXISTS session (\n id TEXT PRIMARY KEY, project_id TEXT NOT NULL, parent_id TEXT,\n slug TEXT, directory TEXT, title TEXT, version TEXT,\n summary_additions INTEGER, summary_deletions INTEGER, summary_files INTEGER,\n summary_diffs TEXT,\n time_created INTEGER NOT NULL, time_updated INTEGER NOT NULL,\n agent TEXT, model TEXT, cost REAL DEFAULT 0 NOT NULL,\n tokens_input INTEGER DEFAULT 0 NOT NULL, tokens_output INTEGER DEFAULT 0 NOT NULL,\n tokens_reasoning INTEGER DEFAULT 0 NOT NULL,\n tokens_cache_read INTEGER DEFAULT 0 NOT NULL, tokens_cache_write INTEGER DEFAULT 0 NOT NULL);\nCREATE TABLE IF NOT EXISTS message (\n id TEXT PRIMARY KEY, session_id TEXT NOT NULL,\n time_created INTEGER NOT NULL, time_updated INTEGER NOT NULL, data TEXT NOT NULL);\nCREATE TABLE IF NOT EXISTS part (\n id TEXT PRIMARY KEY, message_id TEXT NOT NULL, session_id TEXT NOT NULL,\n time_created INTEGER NOT NULL, time_updated INTEGER NOT NULL, data TEXT NOT NULL);\nCREATE TABLE IF NOT EXISTS session_message (\n id TEXT PRIMARY KEY, session_id TEXT NOT NULL, message_id TEXT NOT NULL);\nCREATE INDEX IF NOT EXISTS part_session_idx ON part (session_id);\nCREATE INDEX IF NOT EXISTS message_session_idx ON message (session_id, time_created, id);\n";