/** * An agent's own session (a Claude Code transcript, a Codex rollout, a Cursor chat, an OpenCode * session) as files, so `runpane handoff` can carry it to another machine or fork it on this one. * The stores are each tool's internal format; this module only finds, copies and forks them, and * prefers each tool's own commands to editing files. OpenCode keeps sessions in a database, so its * session travels as the file `opencode export` writes and `opencode import` reads. */ export type NativeAgent = 'claude' | 'codex' | 'cursor' | 'opencode'; interface StoreFile { absolute: string; /** Path relative to the user's home folder, with forward slashes: where the copy goes on the destination. */ home: string; bytes: number; } export interface NativeSession { agent: NativeAgent; id: string; /** The store's folder under the home folder: `.claude`, `.codex` or `.cursor`. */ storeDir: string; /** The session's main file, then any files that belong to it (Claude subagent transcripts, a Cursor chat's folder). */ files: StoreFile[]; /** A Cursor chat's own folder, which is the whole session. */ folder?: string; /** OpenCode: the one file is an export, which the destination brings in with `opencode import`. */ exported?: true; } export declare function isNativeAgent(value: string | undefined): value is NativeAgent; /** * The files of one session on this machine, or undefined when the store has none. Throws when * the id is ambiguous (two copies in one store), which the agent itself cannot resume either. * `cwd` is where an OpenCode export runs. */ export declare function locateNativeSession(agent: NativeAgent, id: string, cwd: string, env?: NodeJS.ProcessEnv): Promise; /** * How many messages another copy of an OpenCode session (`opencode export` output) has that this * export lacks: more than none means that copy was continued after this one was taken. A copy * runpane can't read counts as all of its messages missing, since nothing in it can be matched. */ export declare function openCodeMessagesMissing(exported: string, other: string): number; /** * A short, distinctive phrase from the last complete user or assistant message in the session, * for checking that the resumed agent shows its history. Undefined when the store is not text * this module can read (a compressed rollout, a Cursor chat). */ export declare function lastMessageSnippet(session: NativeSession): string | undefined; /** Whether a screen shows the snippet, ignoring line wrapping and spacing. */ export declare function screenShows(screen: string, snippet: string): boolean; interface FileStamp { absolute: string; bytes: number; modifiedMs: number; /** sha256 of the file's content when it was stamped. */ sha256: string; } export declare function sha256(content: Buffer): string; /** How the original looked before a fork, to prove the fork left it untouched (continuity check 4). */ export type OriginalSnapshot = { kind: 'files'; stamps: FileStamp[]; folder?: string; listing?: string[]; } | { kind: 'export'; id: string; cwd: string; text: string; }; export declare function snapshotOriginal(session: NativeSession, cwd: string): Promise; /** How the original compares with its snapshot. */ export interface OriginalComparison { /** Files whose earlier content changed, files new in a Cursor chat folder, or the session's export. */ changed: string[]; /** Files that only grew: everything they held at the snapshot is still there, byte for byte. */ appended: string[]; } /** * What happened to the original since the snapshot. Any change to a file fails, unless * `appendOnly`: the sender is the running agent, so its own turn (the one running this handoff) * keeps appending to its transcript. Then a file may grow, as long as every byte it held at the * snapshot is unchanged; it is reported in `appended`, not `changed`. */ export declare function originalChanges(snapshot: OriginalSnapshot, options?: { appendOnly?: boolean; }): Promise; export declare function forkNativeSession(session: NativeSession, cwd: string, env?: NodeJS.ProcessEnv): Promise; /** * Why a Cursor session can't be continued by a second agent on the same machine: a copy of its * chat folder under a new id still writes to the original chat once it is used (QA saw it). */ export declare const CURSOR_NO_FORK = "Cursor has no fork command, and a copied Cursor chat still writes to the original chat once it is used, so a second Cursor agent on this machine can't continue your session without changing it"; export {}; //# sourceMappingURL=nativeSession.d.ts.map