{"version":3,"file":"agent/cache-config.mjs","sources":["../../../src/agent/cache-config.ts"],"sourcesContent":["import type { AgentOpt, CacheConfig } from '../types';\n\ntype CacheStrategy = NonNullable<CacheConfig['strategy']>;\n\nconst CACHE_STRATEGIES: readonly CacheStrategy[] = [\n  'read-only',\n  'read-write',\n  'write-only',\n];\n\nconst isValidCacheStrategy = (strategy: string): strategy is CacheStrategy =>\n  CACHE_STRATEGIES.some((value) => value === strategy);\n\nconst CACHE_STRATEGY_VALUES = CACHE_STRATEGIES.map(\n  (value) => `\"${value}\"`,\n).join(', ');\n\nexport function validateAgentCacheInput(cache: AgentOpt['cache']): void {\n  // Agent requires explicit IDs - don't allow auto-generation.\n  if (cache === true) {\n    throw new Error(\n      'cache: true requires an explicit cache ID. Please provide:\\n' +\n        'Example: cache: { id: \"my-cache-id\" }',\n    );\n  }\n\n  if (!cache || typeof cache !== 'object') {\n    return;\n  }\n\n  if (!cache.id) {\n    throw new Error(\n      'cache configuration requires an explicit id.\\n' +\n        'Example: cache: { id: \"my-cache-id\" }',\n    );\n  }\n\n  if (\n    cache.cacheDir !== undefined &&\n    (typeof cache.cacheDir !== 'string' || !cache.cacheDir.trim())\n  ) {\n    throw new Error(\n      'cache.cacheDir must be a non-empty string when provided.\\n' +\n        'Example: cache: { id: \"my-cache-id\", cacheDir: \"./my-cache-dir\" }',\n    );\n  }\n\n  const rawStrategy = cache.strategy as unknown;\n  if (rawStrategy !== undefined && typeof rawStrategy !== 'string') {\n    throw new Error(\n      `cache.strategy must be a string when provided, but received type ${typeof rawStrategy}`,\n    );\n  }\n\n  if (rawStrategy !== undefined && !isValidCacheStrategy(rawStrategy)) {\n    throw new Error(\n      `cache.strategy must be one of ${CACHE_STRATEGY_VALUES}, but received \"${rawStrategy}\"`,\n    );\n  }\n}\n"],"names":["CACHE_STRATEGIES","isValidCacheStrategy","strategy","value","CACHE_STRATEGY_VALUES","validateAgentCacheInput","cache","Error","undefined","rawStrategy"],"mappings":"AAIA,MAAMA,mBAA6C;IACjD;IACA;IACA;CACD;AAED,MAAMC,uBAAuB,CAACC,WAC5BF,iBAAiB,IAAI,CAAC,CAACG,QAAUA,UAAUD;AAE7C,MAAME,wBAAwBJ,iBAAiB,GAAG,CAChD,CAACG,QAAU,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,EACvB,IAAI,CAAC;AAEA,SAASE,wBAAwBC,KAAwB;IAE9D,IAAIA,AAAU,SAAVA,OACF,MAAM,IAAIC,MACR;IAKJ,IAAI,CAACD,SAAS,AAAiB,YAAjB,OAAOA,OACnB;IAGF,IAAI,CAACA,MAAM,EAAE,EACX,MAAM,IAAIC,MACR;IAKJ,IACED,AAAmBE,WAAnBF,MAAM,QAAQ,IACb,CAA0B,YAA1B,OAAOA,MAAM,QAAQ,IAAiB,CAACA,MAAM,QAAQ,CAAC,IAAI,EAAC,GAE5D,MAAM,IAAIC,MACR;IAKJ,MAAME,cAAcH,MAAM,QAAQ;IAClC,IAAIG,AAAgBD,WAAhBC,eAA6B,AAAuB,YAAvB,OAAOA,aACtC,MAAM,IAAIF,MACR,CAAC,iEAAiE,EAAE,OAAOE,aAAa;IAI5F,IAAIA,AAAgBD,WAAhBC,eAA6B,CAACR,qBAAqBQ,cACrD,MAAM,IAAIF,MACR,CAAC,8BAA8B,EAAEH,sBAAsB,gBAAgB,EAAEK,YAAY,CAAC,CAAC;AAG7F"}