//#region src/tools/live_search.ts
/**
* xAI's deprecated live_search tool type.
*/
const XAI_LIVE_SEARCH_TOOL_TYPE = "live_search_deprecated_20251215";
const XAI_LIVE_SEARCH_TOOL_NAME = "live_search";
function mapToolSourceToSearchSource(source) {
	switch (source.type) {
		case "web": return {
			type: "web",
			...source.country !== void 0 && { country: source.country },
			...source.allowedWebsites !== void 0 && { allowed_websites: source.allowedWebsites },
			...source.excludedWebsites !== void 0 && { excluded_websites: source.excludedWebsites },
			...source.safeSearch !== void 0 && { safe_search: source.safeSearch }
		};
		case "news": return {
			type: "news",
			...source.country !== void 0 && { country: source.country },
			...source.excludedWebsites !== void 0 && { excluded_websites: source.excludedWebsites },
			...source.safeSearch !== void 0 && { safe_search: source.safeSearch }
		};
		case "x": return {
			type: "x",
			...source.includedXHandles !== void 0 && { included_x_handles: source.includedXHandles },
			...source.excludedXHandles !== void 0 && { excluded_x_handles: source.excludedXHandles },
			...source.postFavoriteCount !== void 0 && { post_favorite_count: source.postFavoriteCount },
			...source.postViewCount !== void 0 && { post_view_count: source.postViewCount }
		};
		case "rss": return {
			type: "rss",
			links: source.links
		};
		default: {
			const _exhaustive = source;
			return _exhaustive;
		}
	}
}
/**
* Creates an xAI built-in live search tool.
* Enables the model to search the web for real-time information.
*
* This tool is executed server-side by the xAI API.
*
* @deprecated The Live Search API was deprecated by xAI on December 15, 2025.
* Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.
*
* @example Migration to new tools:
* ```typescript
* // Old (deprecated):
* const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });
*
* // New (recommended):
* const webSearch = tools.xaiWebSearch({ allowedDomains: ["example.com"] });
* const xSearch = tools.xaiXSearch({ allowedXHandles: ["elonmusk"] });
* ```
*
* @example
* ```typescript
* import { ChatXAI, tools } from "@langchain/xai";
*
* const llm = new ChatXAI({
*   model: "grok-beta",
* });
*
* const searchTool = tools.xaiLiveSearch({
*   maxSearchResults: 5,
*   fromDate: "2024-01-01",
*   returnCitations: true
* });
*
* const llmWithSearch = llm.bindTools([searchTool]);
* const result = await llmWithSearch.invoke("What happened in tech today?");
* ```
*/
function xaiLiveSearch(options = {}) {
	return {
		type: XAI_LIVE_SEARCH_TOOL_TYPE,
		name: XAI_LIVE_SEARCH_TOOL_NAME,
		mode: options?.mode,
		max_search_results: options?.maxSearchResults,
		from_date: options?.fromDate,
		to_date: options?.toDate,
		return_citations: options?.returnCitations,
		sources: options?.sources?.map(mapToolSourceToSearchSource)
	};
}

//#endregion
export { XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch };
//# sourceMappingURL=live_search.js.map