{"version":3,"file":"web_search.cjs","names":[],"sources":["../../src/tools/web_search.ts"],"sourcesContent":["/**\n * xAI Web Search tool type constant.\n */\nexport const XAI_WEB_SEARCH_TOOL_TYPE = \"web_search\";\n\n/**\n * xAI's built-in web search tool interface.\n * Enables the model to search the web and browse pages for real-time information.\n *\n * This tool is part of xAI's agentic tool calling API.\n */\nexport interface XAIWebSearchTool {\n  /**\n   * The type of the tool. Must be \"web_search\".\n   */\n  type: typeof XAI_WEB_SEARCH_TOOL_TYPE;\n  /**\n   * Domains to exclusively include in the search (max 5).\n   * Cannot be used together with `excluded_domains`.\n   */\n  allowed_domains?: string[];\n  /**\n   * Domains to exclude from the search (max 5).\n   * Cannot be used together with `allowed_domains`.\n   */\n  excluded_domains?: string[];\n  /**\n   * Whether to enable image understanding.\n   * When enabled, the model can analyze images encountered during search.\n   */\n  enable_image_understanding?: boolean;\n}\n\n/**\n * Options for the xAI web search tool (camelCase).\n * All fields are camel-cased for the TypeScript API and are mapped to the\n * corresponding snake_case fields in the API request.\n */\nexport interface XAIWebSearchToolOptions {\n  /**\n   * Domains to exclusively include in the search (max 5).\n   * Cannot be used together with `excludedDomains`.\n   *\n   * @example [\"wikipedia.org\", \"github.com\"]\n   */\n  allowedDomains?: string[];\n  /**\n   * Domains to exclude from the search (max 5).\n   * Cannot be used together with `allowedDomains`.\n   *\n   * @example [\"example.com\"]\n   */\n  excludedDomains?: string[];\n  /**\n   * Whether to enable image understanding.\n   * When enabled, the model can analyze images encountered during search.\n   * Note: This increases token usage as images are processed.\n   *\n   * @default false\n   */\n  enableImageUnderstanding?: boolean;\n}\n\n/**\n * Creates an xAI web search tool.\n * Enables the model to search the web and browse pages for real-time information.\n *\n * This tool is executed server-side by the xAI API as part of the agentic\n * tool calling workflow.\n *\n * @param options - Configuration options for the web search tool\n * @returns An XAIWebSearchTool object to pass to the model\n *\n * @example Basic usage\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n *   model: \"grok-4-1-fast\",\n * });\n *\n * const webSearch = tools.xaiWebSearch();\n * const result = await llm.invoke(\"What are the latest AI developments?\", {\n *   tools: [webSearch],\n * });\n * ```\n *\n * @example With domain filtering\n * ```typescript\n * const webSearch = tools.xaiWebSearch({\n *   allowedDomains: [\"wikipedia.org\", \"arxiv.org\"],\n *   enableImageUnderstanding: true,\n * });\n * ```\n *\n * @example Excluding specific domains\n * ```typescript\n * const webSearch = tools.xaiWebSearch({\n *   excludedDomains: [\"example.com\"],\n * });\n * ```\n */\nexport function xaiWebSearch(\n  options: XAIWebSearchToolOptions = {}\n): XAIWebSearchTool {\n  const tool: XAIWebSearchTool = {\n    type: XAI_WEB_SEARCH_TOOL_TYPE,\n  };\n\n  if (options.allowedDomains !== undefined) {\n    tool.allowed_domains = options.allowedDomains;\n  }\n\n  if (options.excludedDomains !== undefined) {\n    tool.excluded_domains = options.excludedDomains;\n  }\n\n  if (options.enableImageUnderstanding !== undefined) {\n    tool.enable_image_understanding = options.enableImageUnderstanding;\n  }\n\n  return tool;\n}\n"],"mappings":";;;;AAGA,MAAa,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGxC,SAAgB,aACd,UAAmC,EAAE,EACnB;CAClB,MAAM,OAAyB,EAC7B,MAAM,0BACP;AAED,KAAI,QAAQ,mBAAmB,KAAA,EAC7B,MAAK,kBAAkB,QAAQ;AAGjC,KAAI,QAAQ,oBAAoB,KAAA,EAC9B,MAAK,mBAAmB,QAAQ;AAGlC,KAAI,QAAQ,6BAA6B,KAAA,EACvC,MAAK,6BAA6B,QAAQ;AAG5C,QAAO"}