{"version":3,"file":"anthropic.cjs","sources":["../../../../src/tools/search/anthropic.ts"],"sourcesContent":["import type {\n  AnthropicTextBlockParam,\n  AnthropicWebSearchResultBlockParam,\n} from '@/llm/anthropic/types';\nimport type { SearchResultData, ProcessedOrganic } from './types';\nimport { getAttribution } from './utils';\n\n/**\n * Coerces Anthropic web search results to the SearchResultData format\n * @param results - Array of Anthropic web search results\n * @param turn - The turn number to associate with these results\n * @returns SearchResultData with minimal ProcessedOrganic items\n */\nexport function coerceAnthropicSearchResults({\n  results,\n  turn = 0,\n}: {\n  results: (AnthropicTextBlockParam | AnthropicWebSearchResultBlockParam)[];\n  turn?: number;\n}): SearchResultData {\n  const organic: ProcessedOrganic[] = results\n    .filter((result) => result.type === 'web_search_result')\n    .map((result, index) => ({\n      link: result.url,\n      position: index + 1,\n      title: result.title,\n      date: result.page_age ?? undefined,\n      attribution: getAttribution(result.url),\n    }));\n\n  return {\n    turn,\n    organic,\n  };\n}\n\n/**\n * Helper function to check if an object is an Anthropic web search result\n */\nexport function isAnthropicWebSearchResult(\n  obj: unknown\n): obj is AnthropicWebSearchResultBlockParam {\n  return (\n    typeof obj === 'object' &&\n    obj !== null &&\n    'type' in obj &&\n    obj.type === 'web_search_result' &&\n    'url' in obj &&\n    typeof (obj as Record<string, unknown>).url === 'string'\n  );\n}\n"],"names":["getAttribution"],"mappings":";;;;AAOA;;;;;AAKG;AACG,SAAU,4BAA4B,CAAC,EAC3C,OAAO,EACP,IAAI,GAAG,CAAC,GAIT,EAAA;IACC,MAAM,OAAO,GAAuB;SACjC,MAAM,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,KAAK,mBAAmB;SACtD,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,MAAM;QACvB,IAAI,EAAE,MAAM,CAAC,GAAG;QAChB,QAAQ,EAAE,KAAK,GAAG,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC,KAAK;AACnB,QAAA,IAAI,EAAE,MAAM,CAAC,QAAQ,IAAI,SAAS;AAClC,QAAA,WAAW,EAAEA,oBAAc,CAAC,MAAM,CAAC,GAAG,CAAC;AACxC,KAAA,CAAC,CAAC;IAEL,OAAO;QACL,IAAI;QACJ,OAAO;KACR;AACH;AAEA;;AAEG;AACG,SAAU,0BAA0B,CACxC,GAAY,EAAA;AAEZ,IAAA,QACE,OAAO,GAAG,KAAK,QAAQ;AACvB,QAAA,GAAG,KAAK,IAAI;AACZ,QAAA,MAAM,IAAI,GAAG;QACb,GAAG,CAAC,IAAI,KAAK,mBAAmB;AAChC,QAAA,KAAK,IAAI,GAAG;AACZ,QAAA,OAAQ,GAA+B,CAAC,GAAG,KAAK,QAAQ;AAE5D;;;;;"}