import { basename, join } from 'node:path';
import { getShortcutForkTraceDir } from '../../constants.js';
/**
 * Resolves the directory where a forked agent's JSONL trace should be
 * written. Defaults to a per-session `.fork-traces/<session-id>/` folder
 * alongside the session JSONL, so /trace can later discover and render the
 * fork traces alongside the parent session. The `SHORTCUT_FORK_TRACE_DIR`
 * env var overrides this for manual dumps and tests.
 */
/** Compute the fork-trace directory for a session, honoring the SHORTCUT_FORK_TRACE_DIR override. */
export function resolveForkTraceDir(sessionDir, sessionFile) {
    const overrideDir = getShortcutForkTraceDir();
    if (overrideDir)
        return overrideDir;
    const baseDir = join(sessionDir, '.fork-traces');
    if (!sessionFile)
        return baseDir;
    return join(baseDir, basename(sessionFile, '.jsonl'));
}
//# sourceMappingURL=fork-trace-paths.js.map