import { tmpdir } from "node:os";
import { join } from "node:path";
// Single source of truth for the per-session turnText tempfile path the bin
// (`conversation-archive-ingest.mjs`) writes and the writer
// (`memory-ingest.ts` → `ingestConversationDocument`) reads. Both sides
// reconstruct the path from the same identity inputs so neither process
// trusts a path string carried across the LLM boundary.
//
// Task 468: the chat-archive path mirrors the document path's `extractCache`
// contract — the writer slices `:Section.body` from a non-LLM source of
// turnText. The bin is a separate Node process so the cache is a tempfile
// instead of an in-process Map.
export const TURN_TEXT_CACHE_DIR_PREFIX = "maxy-conversation-archive";
export function turnTextCachePath(inputs) {
    const { conversationIdentity, archiveSha256, sessionIndex } = inputs;
    if (!conversationIdentity || typeof conversationIdentity !== "string") {
        throw new Error("turnTextCachePath: conversationIdentity required");
    }
    if (!archiveSha256 || typeof archiveSha256 !== "string") {
        throw new Error("turnTextCachePath: archiveSha256 required");
    }
    if (!Number.isInteger(sessionIndex) || sessionIndex < 1) {
        throw new Error(`turnTextCachePath: sessionIndex must be integer >= 1 (got ${sessionIndex})`);
    }
    return join(tmpdir(), TURN_TEXT_CACHE_DIR_PREFIX, `${conversationIdentity}-${archiveSha256}`, `session-${sessionIndex}.txt`);
}
//# sourceMappingURL=turn-text-cache-path.js.map