{"version":3,"file":"fileManifest.cjs","sources":["../../../src/utils/fileManifest.ts"],"sourcesContent":["// src/utils/fileManifest.ts\n//\n// Utility for building a lightweight [Conversation Files] context block\n// from a file manifest. Injected into the compaction windowed view so the\n// LLM retains awareness of ALL conversation files, even when old messages\n// (with full file content) are behind the summary.\n\nimport type { FileManifestEntry } from '@/types/graph';\n\n/**\n * Prefix marker for the file manifest block.\n * Used to detect and deduplicate manifest messages across turns.\n */\nexport const FILE_MANIFEST_PREFIX = '[Conversation Files]';\n\n/**\n * Builds a compact text block listing all files in the conversation.\n * Each entry costs ~10-15 tokens, so 10 files ≈ 100-150 tokens total.\n *\n * The block includes retrieval hints so the LLM knows how to fetch\n * full content on demand (via file_search or content_tool).\n *\n * @param manifest - Array of file metadata entries\n * @returns Formatted text block, or empty string if manifest is empty/undefined\n */\nexport function buildFileManifestBlock(\n  manifest: FileManifestEntry[] | undefined\n): string {\n  if (!manifest || manifest.length === 0) {\n    return '';\n  }\n\n  const lines = manifest.map((entry) => {\n    const parts: string[] = [`- ${entry.filename}`];\n    if (entry.contentId) {\n      parts.push(`(content_id: ${entry.contentId})`);\n    }\n    if (entry.source) {\n      parts.push(`[${entry.source}]`);\n    }\n    return parts.join(' ');\n  });\n\n  return [\n    FILE_MANIFEST_PREFIX,\n    'The following files have been shared in this conversation.',\n    'Use file_search or content_tool read (with content_id) to retrieve full content when needed.',\n    '',\n    ...lines,\n  ].join('\\n');\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AAIA;;;AAGG;AACI,MAAM,oBAAoB,GAAG;AAEpC;;;;;;;;;AASG;AACG,SAAU,sBAAsB,CACpC,QAAyC,EAAA;IAEzC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;AACtC,QAAA,OAAO,EAAE;IACX;IAEA,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,KAAI;QACnC,MAAM,KAAK,GAAa,CAAC,CAAA,EAAA,EAAK,KAAK,CAAC,QAAQ,CAAA,CAAE,CAAC;AAC/C,QAAA,IAAI,KAAK,CAAC,SAAS,EAAE;YACnB,KAAK,CAAC,IAAI,CAAC,CAAA,aAAA,EAAgB,KAAK,CAAC,SAAS,CAAA,CAAA,CAAG,CAAC;QAChD;AACA,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE;YAChB,KAAK,CAAC,IAAI,CAAC,CAAA,CAAA,EAAI,KAAK,CAAC,MAAM,CAAA,CAAA,CAAG,CAAC;QACjC;AACA,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;AACxB,IAAA,CAAC,CAAC;IAEF,OAAO;QACL,oBAAoB;QACpB,4DAA4D;QAC5D,8FAA8F;QAC9F,EAAE;AACF,QAAA,GAAG,KAAK;AACT,KAAA,CAAC,IAAI,CAAC,IAAI,CAAC;AACd;;;;;"}