/** * Engine-specific session forking logic for the Duplicate feature. * * - Claude: uses --fork-session flag with --print mode * - Codex: copies the JSONL session file with a new UUID */ import type { InteractiveClaudeEngine } from "../engines/claude-interactive.js"; export interface ForkResult { engineSessionId: string; } export interface ForkCodexOpts { sourceSessionsRoot?: string; destinationSessionsRoot?: string; } /** * Optional interactive context for forking. When provided, the source session's * warm PTY is released first, and the fork itself is spawned in a PTY (no `-p`) * so the new turn bills as `cc_entrypoint=cli` rather than the Agent-SDK * headless pool. */ export interface InteractiveForkCtx { /** Jinn session id of the SOURCE session — used to release its warm PTY before forking. */ sourceJinnSessionId: string; /** The interactive engine — used to release the source PTY. */ engine: InteractiveClaudeEngine; /** claude binary path (defaults to "claude"). */ bin?: string; } export interface ForkClaudeOpts { engineSessionId: string; cwd: string; /** When set, the fork uses interactive (no -p) and releases the source PTY first. */ interactive?: InteractiveForkCtx; } /** * Fork a Claude Code CLI session using --fork-session. * Returns the new engine session ID from the fork. * * - Headless mode (default): runs `claude --resume --fork-session --print -p ...` * via execFileSync. Bills against the Agent-SDK credit pool. * - Interactive mode (when `opts.interactive` is set): releases the source PTY * first, then spawns `claude --resume --fork-session ""` in a PTY * (no `-p`) and polls the project's transcript directory for the new jsonl to * discover the new session id. Bills as `cc_entrypoint=cli`. */ export declare function forkClaudeSession(opts: ForkClaudeOpts): Promise; /** * Translate a cwd into the Claude project directory key. Claude Code slugifies * the cwd by replacing every non-alphanumeric character with "-" (so `~/.jinn` * → `…--jinn`, double-dash; spaces/underscores/unicode become "-" too). Must * match `findTranscriptForSession` in claude-interactive.ts — otherwise the * fork polls a non-existent directory and times out for any cwd containing a * dot (every COO/.jinn session). */ export declare function claudeProjectDir(cwd: string): string; /** * Fork a Codex CLI session by copying its JSONL file with a new UUID. * Explicit roots support Jinn's per-session CODEX_HOME overlays; the legacy * global Codex home remains the default and source fallback. * Returns the new engine session ID. */ export declare function forkCodexSession(engineSessionId: string, opts?: ForkCodexOpts): ForkResult; /** * Fork a Hermes ACP session using Hermes's own `session/fork` primitive. * * This keeps Jinn's duplicate semantics aligned with Hermes itself: the new * Jinn session points at a distinct Hermes session id whose transcript/history * was copied by Hermes's SessionManager, rather than merely copying Jinn's * registry rows or reusing the source Hermes id. */ export declare function forkHermesSession(engineSessionId: string, cwd: string): Promise; /** * Fork an engine session based on engine type. * * For Claude, `opts.interactive` routes the fork through a PTY * (no `-p`) so it bills as `cc_entrypoint=cli`. Codex and Hermes ignore it. */ export declare function forkEngineSession(engine: string, engineSessionId: string, cwd: string, opts?: { interactive?: InteractiveForkCtx; codex?: ForkCodexOpts; }): Promise; //# sourceMappingURL=fork.d.ts.map