@langchain/xai 1.2.2-dev-1768440391024 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/chat_models/completions.cjs +1 -1
  3. package/dist/chat_models/completions.cjs.map +1 -1
  4. package/dist/chat_models/completions.d.cts +5 -0
  5. package/dist/chat_models/completions.d.cts.map +1 -1
  6. package/dist/chat_models/completions.d.ts +5 -0
  7. package/dist/chat_models/completions.d.ts.map +1 -1
  8. package/dist/chat_models/completions.js +1 -1
  9. package/dist/chat_models/completions.js.map +1 -1
  10. package/dist/chat_models/responses-types.d.cts +37 -7
  11. package/dist/chat_models/responses-types.d.cts.map +1 -1
  12. package/dist/chat_models/responses-types.d.ts +37 -7
  13. package/dist/chat_models/responses-types.d.ts.map +1 -1
  14. package/dist/chat_models/responses.cjs +5 -0
  15. package/dist/chat_models/responses.cjs.map +1 -1
  16. package/dist/chat_models/responses.d.cts +2 -1
  17. package/dist/chat_models/responses.d.cts.map +1 -1
  18. package/dist/chat_models/responses.d.ts +2 -1
  19. package/dist/chat_models/responses.d.ts.map +1 -1
  20. package/dist/chat_models/responses.js +5 -0
  21. package/dist/chat_models/responses.js.map +1 -1
  22. package/dist/tools/code_execution.cjs +52 -0
  23. package/dist/tools/code_execution.cjs.map +1 -0
  24. package/dist/tools/code_execution.d.cts +64 -0
  25. package/dist/tools/code_execution.d.cts.map +1 -0
  26. package/dist/tools/code_execution.d.ts +64 -0
  27. package/dist/tools/code_execution.d.ts.map +1 -0
  28. package/dist/tools/code_execution.js +50 -0
  29. package/dist/tools/code_execution.js.map +1 -0
  30. package/dist/tools/collections_search.cjs +60 -0
  31. package/dist/tools/collections_search.cjs.map +1 -0
  32. package/dist/tools/collections_search.d.cts +90 -0
  33. package/dist/tools/collections_search.d.cts.map +1 -0
  34. package/dist/tools/collections_search.d.ts +90 -0
  35. package/dist/tools/collections_search.d.ts.map +1 -0
  36. package/dist/tools/collections_search.js +58 -0
  37. package/dist/tools/collections_search.js.map +1 -0
  38. package/dist/tools/index.cjs +11 -1
  39. package/dist/tools/index.cjs.map +1 -1
  40. package/dist/tools/index.d.cts +10 -1
  41. package/dist/tools/index.d.cts.map +1 -1
  42. package/dist/tools/index.d.ts +10 -1
  43. package/dist/tools/index.d.ts.map +1 -1
  44. package/dist/tools/index.js +12 -2
  45. package/dist/tools/index.js.map +1 -1
  46. package/dist/tools/live_search.cjs +14 -0
  47. package/dist/tools/live_search.cjs.map +1 -1
  48. package/dist/tools/live_search.d.cts +14 -1
  49. package/dist/tools/live_search.d.cts.map +1 -1
  50. package/dist/tools/live_search.d.ts +14 -1
  51. package/dist/tools/live_search.d.ts.map +1 -1
  52. package/dist/tools/live_search.js +14 -1
  53. package/dist/tools/live_search.js.map +1 -1
  54. package/dist/tools/web_search.cjs +57 -0
  55. package/dist/tools/web_search.cjs.map +1 -0
  56. package/dist/tools/web_search.d.cts +104 -0
  57. package/dist/tools/web_search.d.cts.map +1 -0
  58. package/dist/tools/web_search.d.ts +104 -0
  59. package/dist/tools/web_search.d.ts.map +1 -0
  60. package/dist/tools/web_search.js +55 -0
  61. package/dist/tools/web_search.js.map +1 -0
  62. package/dist/tools/x_search.cjs +63 -0
  63. package/dist/tools/x_search.cjs.map +1 -0
  64. package/dist/tools/x_search.d.cts +145 -0
  65. package/dist/tools/x_search.d.cts.map +1 -0
  66. package/dist/tools/x_search.d.ts +145 -0
  67. package/dist/tools/x_search.d.ts.map +1 -0
  68. package/dist/tools/x_search.js +61 -0
  69. package/dist/tools/x_search.js.map +1 -0
  70. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":["xaiLiveSearch","tools"],"sources":["../../src/tools/index.d.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nexport declare const tools: {\n xaiLiveSearch: typeof xaiLiveSearch;\n};\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;cACqBC;wBACKD;AAD1B,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":["xaiLiveSearch","xaiWebSearch","xaiXSearch","xaiCodeExecution","xaiCollectionsSearch","tools","XAILiveSearchTool","XAILiveSearchToolOptions","XAIWebSearchTool","XAIWebSearchToolOptions","XAIXSearchTool","XAIXSearchToolOptions","XAICodeExecutionTool","XAICollectionsSearchTool","XAICollectionsSearchToolOptions","XAI_LIVE_SEARCH_TOOL_TYPE","XAI_LIVE_SEARCH_TOOL_NAME","XAI_WEB_SEARCH_TOOL_TYPE","XAI_X_SEARCH_TOOL_TYPE","XAI_CODE_EXECUTION_TOOL_TYPE","XAI_COLLECTIONS_SEARCH_TOOL_TYPE"],"sources":["../../src/tools/index.d.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nimport { xaiWebSearch } from \"./web_search.js\";\nimport { xaiXSearch } from \"./x_search.js\";\nimport { xaiCodeExecution } from \"./code_execution.js\";\nimport { xaiCollectionsSearch } from \"./collections_search.js\";\nexport declare const tools: {\n /** @deprecated Use xaiWebSearch and xaiXSearch instead */\n xaiLiveSearch: typeof xaiLiveSearch;\n xaiWebSearch: typeof xaiWebSearch;\n xaiXSearch: typeof xaiXSearch;\n xaiCodeExecution: typeof xaiCodeExecution;\n xaiCollectionsSearch: typeof xaiCollectionsSearch;\n};\nexport type { XAILiveSearchTool, XAILiveSearchToolOptions, } from \"./live_search.js\";\nexport type { XAIWebSearchTool, XAIWebSearchToolOptions, } from \"./web_search.js\";\nexport type { XAIXSearchTool, XAIXSearchToolOptions } from \"./x_search.js\";\nexport type { XAICodeExecutionTool } from \"./code_execution.js\";\nexport type { XAICollectionsSearchTool, XAICollectionsSearchToolOptions, } from \"./collections_search.js\";\nexport { XAI_LIVE_SEARCH_TOOL_TYPE, XAI_LIVE_SEARCH_TOOL_NAME, } from \"./live_search.js\";\nexport { XAI_WEB_SEARCH_TOOL_TYPE } from \"./web_search.js\";\nexport { XAI_X_SEARCH_TOOL_TYPE } from \"./x_search.js\";\nexport { XAI_CODE_EXECUTION_TOOL_TYPE } from \"./code_execution.js\";\nexport { XAI_COLLECTIONS_SEARCH_TOOL_TYPE } from \"./collections_search.js\";\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;cAKqBK;;EAAAA,aAOpB,EAAA,OALyBL,aAKzB;EALyBA,YAAAA,EAAAA,OACDC,YADCD;EACDC,UAAAA,EAAAA,OACFC,UADED;EACFC,gBAAAA,EAAAA,OACMC,gBADND;EACMC,oBAAAA,EAAAA,OACIC,oBADJD;CACIC"}
@@ -1,8 +1,17 @@
1
- import { xaiLiveSearch } from "./live_search.js";
1
+ import { XAILiveSearchTool, XAILiveSearchToolOptions, XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch } from "./live_search.js";
2
+ import { XAIWebSearchTool, XAIWebSearchToolOptions, XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch } from "./web_search.js";
3
+ import { XAIXSearchTool, XAIXSearchToolOptions, XAI_X_SEARCH_TOOL_TYPE, xaiXSearch } from "./x_search.js";
4
+ import { XAICodeExecutionTool, XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution } from "./code_execution.js";
5
+ import { XAICollectionsSearchTool, XAICollectionsSearchToolOptions, XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch } from "./collections_search.js";
2
6
 
3
7
  //#region src/tools/index.d.ts
4
8
  declare const tools: {
9
+ /** @deprecated Use xaiWebSearch and xaiXSearch instead */
5
10
  xaiLiveSearch: typeof xaiLiveSearch;
11
+ xaiWebSearch: typeof xaiWebSearch;
12
+ xaiXSearch: typeof xaiXSearch;
13
+ xaiCodeExecution: typeof xaiCodeExecution;
14
+ xaiCollectionsSearch: typeof xaiCollectionsSearch;
6
15
  };
7
16
  //#endregion
8
17
  export { tools };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["xaiLiveSearch","tools"],"sources":["../../src/tools/index.d.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nexport declare const tools: {\n xaiLiveSearch: typeof xaiLiveSearch;\n};\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;cACqBC;wBACKD;AAD1B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["xaiLiveSearch","xaiWebSearch","xaiXSearch","xaiCodeExecution","xaiCollectionsSearch","tools","XAILiveSearchTool","XAILiveSearchToolOptions","XAIWebSearchTool","XAIWebSearchToolOptions","XAIXSearchTool","XAIXSearchToolOptions","XAICodeExecutionTool","XAICollectionsSearchTool","XAICollectionsSearchToolOptions","XAI_LIVE_SEARCH_TOOL_TYPE","XAI_LIVE_SEARCH_TOOL_NAME","XAI_WEB_SEARCH_TOOL_TYPE","XAI_X_SEARCH_TOOL_TYPE","XAI_CODE_EXECUTION_TOOL_TYPE","XAI_COLLECTIONS_SEARCH_TOOL_TYPE"],"sources":["../../src/tools/index.d.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nimport { xaiWebSearch } from \"./web_search.js\";\nimport { xaiXSearch } from \"./x_search.js\";\nimport { xaiCodeExecution } from \"./code_execution.js\";\nimport { xaiCollectionsSearch } from \"./collections_search.js\";\nexport declare const tools: {\n /** @deprecated Use xaiWebSearch and xaiXSearch instead */\n xaiLiveSearch: typeof xaiLiveSearch;\n xaiWebSearch: typeof xaiWebSearch;\n xaiXSearch: typeof xaiXSearch;\n xaiCodeExecution: typeof xaiCodeExecution;\n xaiCollectionsSearch: typeof xaiCollectionsSearch;\n};\nexport type { XAILiveSearchTool, XAILiveSearchToolOptions, } from \"./live_search.js\";\nexport type { XAIWebSearchTool, XAIWebSearchToolOptions, } from \"./web_search.js\";\nexport type { XAIXSearchTool, XAIXSearchToolOptions } from \"./x_search.js\";\nexport type { XAICodeExecutionTool } from \"./code_execution.js\";\nexport type { XAICollectionsSearchTool, XAICollectionsSearchToolOptions, } from \"./collections_search.js\";\nexport { XAI_LIVE_SEARCH_TOOL_TYPE, XAI_LIVE_SEARCH_TOOL_NAME, } from \"./live_search.js\";\nexport { XAI_WEB_SEARCH_TOOL_TYPE } from \"./web_search.js\";\nexport { XAI_X_SEARCH_TOOL_TYPE } from \"./x_search.js\";\nexport { XAI_CODE_EXECUTION_TOOL_TYPE } from \"./code_execution.js\";\nexport { XAI_COLLECTIONS_SEARCH_TOOL_TYPE } from \"./collections_search.js\";\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;cAKqBK;;EAAAA,aAOpB,EAAA,OALyBL,aAKzB;EALyBA,YAAAA,EAAAA,OACDC,YADCD;EACDC,UAAAA,EAAAA,OACFC,UADED;EACFC,gBAAAA,EAAAA,OACMC,gBADND;EACMC,oBAAAA,EAAAA,OACIC,oBADJD;CACIC"}
@@ -1,7 +1,17 @@
1
- import { xaiLiveSearch } from "./live_search.js";
1
+ import { XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch } from "./live_search.js";
2
+ import { XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch } from "./web_search.js";
3
+ import { XAI_X_SEARCH_TOOL_TYPE, xaiXSearch } from "./x_search.js";
4
+ import { XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution } from "./code_execution.js";
5
+ import { XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch } from "./collections_search.js";
2
6
 
3
7
  //#region src/tools/index.ts
4
- const tools = { xaiLiveSearch };
8
+ const tools = {
9
+ xaiLiveSearch,
10
+ xaiWebSearch,
11
+ xaiXSearch,
12
+ xaiCodeExecution,
13
+ xaiCollectionsSearch
14
+ };
5
15
 
6
16
  //#endregion
7
17
  export { tools };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\n\nexport const tools = {\n xaiLiveSearch,\n};\n"],"mappings":";;;AAEA,MAAa,QAAQ,EACnB,cACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nimport { xaiWebSearch } from \"./web_search.js\";\nimport { xaiXSearch } from \"./x_search.js\";\nimport { xaiCodeExecution } from \"./code_execution.js\";\nimport { xaiCollectionsSearch } from \"./collections_search.js\";\n\nexport const tools = {\n /** @deprecated Use xaiWebSearch and xaiXSearch instead */\n xaiLiveSearch,\n xaiWebSearch,\n xaiXSearch,\n xaiCodeExecution,\n xaiCollectionsSearch,\n};\n\n// Re-export types for convenience\nexport type {\n XAILiveSearchTool,\n XAILiveSearchToolOptions,\n} from \"./live_search.js\";\nexport type {\n XAIWebSearchTool,\n XAIWebSearchToolOptions,\n} from \"./web_search.js\";\nexport type { XAIXSearchTool, XAIXSearchToolOptions } from \"./x_search.js\";\nexport type { XAICodeExecutionTool } from \"./code_execution.js\";\nexport type {\n XAICollectionsSearchTool,\n XAICollectionsSearchToolOptions,\n} from \"./collections_search.js\";\n\n// Re-export tool type constants\nexport {\n XAI_LIVE_SEARCH_TOOL_TYPE,\n XAI_LIVE_SEARCH_TOOL_NAME,\n} from \"./live_search.js\";\nexport { XAI_WEB_SEARCH_TOOL_TYPE } from \"./web_search.js\";\nexport { XAI_X_SEARCH_TOOL_TYPE } from \"./x_search.js\";\nexport { XAI_CODE_EXECUTION_TOOL_TYPE } from \"./code_execution.js\";\nexport { XAI_COLLECTIONS_SEARCH_TOOL_TYPE } from \"./collections_search.js\";\n"],"mappings":";;;;;;;AAMA,MAAa,QAAQ;CAEnB;CACA;CACA;CACA;CACA;AACD"}
@@ -43,6 +43,19 @@ function mapToolSourceToSearchSource(source) {
43
43
  *
44
44
  * This tool is executed server-side by the xAI API.
45
45
  *
46
+ * @deprecated The Live Search API was deprecated by xAI on December 15, 2025.
47
+ * Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.
48
+ *
49
+ * @example Migration to new tools:
50
+ * ```typescript
51
+ * // Old (deprecated):
52
+ * const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });
53
+ *
54
+ * // New (recommended):
55
+ * const webSearch = tools.xaiWebSearch({ allowedDomains: ["example.com"] });
56
+ * const xSearch = tools.xaiXSearch({ allowedXHandles: ["elonmusk"] });
57
+ * ```
58
+ *
46
59
  * @example
47
60
  * ```typescript
48
61
  * import { ChatXAI, tools } from "@langchain/xai";
@@ -75,6 +88,7 @@ function xaiLiveSearch(options = {}) {
75
88
  }
76
89
 
77
90
  //#endregion
91
+ exports.XAI_LIVE_SEARCH_TOOL_NAME = XAI_LIVE_SEARCH_TOOL_NAME;
78
92
  exports.XAI_LIVE_SEARCH_TOOL_TYPE = XAI_LIVE_SEARCH_TOOL_TYPE;
79
93
  exports.xaiLiveSearch = xaiLiveSearch;
80
94
  //# sourceMappingURL=live_search.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"live_search.cjs","names":["source: XAISearchToolSource","_exhaustive: never","options: XAILiveSearchToolOptions"],"sources":["../../src/tools/live_search.ts"],"sourcesContent":["import type { XAISearchParameters, XAISearchSource } from \"../live_search.js\";\n\n/**\n * xAI's deprecated live_search tool type.\n */\nexport const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\n\nexport type XAISearchToolSource =\n | XAIWebSearchToolSource\n | XAINewsSearchToolSource\n | XAIXSearchToolSource\n | XAIRssSearchToolSource;\n\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n\nfunction mapToolSourceToSearchSource(\n source: XAISearchToolSource\n): XAISearchSource {\n switch (source.type) {\n case \"web\":\n return {\n type: \"web\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.allowedWebsites !== undefined && {\n allowed_websites: source.allowedWebsites,\n }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"news\":\n return {\n type: \"news\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"x\":\n return {\n type: \"x\",\n ...(source.includedXHandles !== undefined && {\n included_x_handles: source.includedXHandles,\n }),\n ...(source.excludedXHandles !== undefined && {\n excluded_x_handles: source.excludedXHandles,\n }),\n ...(source.postFavoriteCount !== undefined && {\n post_favorite_count: source.postFavoriteCount,\n }),\n ...(source.postViewCount !== undefined && {\n post_view_count: source.postViewCount,\n }),\n };\n case \"rss\":\n return {\n type: \"rss\",\n links: source.links,\n };\n default: {\n const _exhaustive: never = source;\n return _exhaustive;\n }\n }\n}\n\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport function xaiLiveSearch(\n options: XAILiveSearchToolOptions = {}\n): XAILiveSearchTool {\n return {\n type: XAI_LIVE_SEARCH_TOOL_TYPE,\n name: XAI_LIVE_SEARCH_TOOL_NAME,\n mode: options?.mode,\n max_search_results: options?.maxSearchResults,\n from_date: options?.fromDate,\n to_date: options?.toDate,\n return_citations: options?.returnCitations,\n sources: options?.sources?.map(mapToolSourceToSearchSource),\n } satisfies XAILiveSearchTool;\n}\n"],"mappings":";;;;;AAKA,MAAa,4BAA4B;AACzC,MAAa,4BAA4B;AAgHzC,SAAS,4BACPA,QACiB;AACjB,SAAQ,OAAO,MAAf;EACE,KAAK,MACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,oBAAoB,UAAa,EAC1C,kBAAkB,OAAO,gBAC1B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,OACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,IACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,sBAAsB,UAAa,EAC5C,qBAAqB,OAAO,kBAC7B;GACD,GAAI,OAAO,kBAAkB,UAAa,EACxC,iBAAiB,OAAO,cACzB;EACF;EACH,KAAK,MACH,QAAO;GACL,MAAM;GACN,OAAO,OAAO;EACf;EACH,SAAS;GACP,MAAMC,cAAqB;AAC3B,UAAO;EACR;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BD,SAAgB,cACdC,UAAoC,CAAE,GACnB;AACnB,QAAO;EACL,MAAM;EACN,MAAM;EACN,MAAM,SAAS;EACf,oBAAoB,SAAS;EAC7B,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,kBAAkB,SAAS;EAC3B,SAAS,SAAS,SAAS,IAAI,4BAA4B;CAC5D;AACF"}
1
+ {"version":3,"file":"live_search.cjs","names":["source: XAISearchToolSource","_exhaustive: never","options: XAILiveSearchToolOptions"],"sources":["../../src/tools/live_search.ts"],"sourcesContent":["import type { XAISearchParameters, XAISearchSource } from \"../live_search.js\";\n\n/**\n * xAI's deprecated live_search tool type.\n */\nexport const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\n\nexport type XAISearchToolSource =\n | XAIWebSearchToolSource\n | XAINewsSearchToolSource\n | XAIXSearchToolSource\n | XAIRssSearchToolSource;\n\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n\nfunction mapToolSourceToSearchSource(\n source: XAISearchToolSource\n): XAISearchSource {\n switch (source.type) {\n case \"web\":\n return {\n type: \"web\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.allowedWebsites !== undefined && {\n allowed_websites: source.allowedWebsites,\n }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"news\":\n return {\n type: \"news\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"x\":\n return {\n type: \"x\",\n ...(source.includedXHandles !== undefined && {\n included_x_handles: source.includedXHandles,\n }),\n ...(source.excludedXHandles !== undefined && {\n excluded_x_handles: source.excludedXHandles,\n }),\n ...(source.postFavoriteCount !== undefined && {\n post_favorite_count: source.postFavoriteCount,\n }),\n ...(source.postViewCount !== undefined && {\n post_view_count: source.postViewCount,\n }),\n };\n case \"rss\":\n return {\n type: \"rss\",\n links: source.links,\n };\n default: {\n const _exhaustive: never = source;\n return _exhaustive;\n }\n }\n}\n\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @deprecated The Live Search API was deprecated by xAI on December 15, 2025.\n * Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.\n *\n * @example Migration to new tools:\n * ```typescript\n * // Old (deprecated):\n * const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });\n *\n * // New (recommended):\n * const webSearch = tools.xaiWebSearch({ allowedDomains: [\"example.com\"] });\n * const xSearch = tools.xaiXSearch({ allowedXHandles: [\"elonmusk\"] });\n * ```\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport function xaiLiveSearch(\n options: XAILiveSearchToolOptions = {}\n): XAILiveSearchTool {\n return {\n type: XAI_LIVE_SEARCH_TOOL_TYPE,\n name: XAI_LIVE_SEARCH_TOOL_NAME,\n mode: options?.mode,\n max_search_results: options?.maxSearchResults,\n from_date: options?.fromDate,\n to_date: options?.toDate,\n return_citations: options?.returnCitations,\n sources: options?.sources?.map(mapToolSourceToSearchSource),\n } satisfies XAILiveSearchTool;\n}\n"],"mappings":";;;;;AAKA,MAAa,4BAA4B;AACzC,MAAa,4BAA4B;AAgHzC,SAAS,4BACPA,QACiB;AACjB,SAAQ,OAAO,MAAf;EACE,KAAK,MACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,oBAAoB,UAAa,EAC1C,kBAAkB,OAAO,gBAC1B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,OACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,IACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,sBAAsB,UAAa,EAC5C,qBAAqB,OAAO,kBAC7B;GACD,GAAI,OAAO,kBAAkB,UAAa,EACxC,iBAAiB,OAAO,cACzB;EACF;EACH,KAAK,MACH,QAAO;GACL,MAAM;GACN,OAAO,OAAO;EACf;EACH,SAAS;GACP,MAAMC,cAAqB;AAC3B,UAAO;EACR;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCD,SAAgB,cACdC,UAAoC,CAAE,GACnB;AACnB,QAAO;EACL,MAAM;EACN,MAAM;EACN,MAAM,SAAS;EACf,oBAAoB,SAAS;EAC7B,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,kBAAkB,SAAS;EAC3B,SAAS,SAAS,SAAS,IAAI,4BAA4B;CAC5D;AACF"}
@@ -112,6 +112,19 @@ interface XAILiveSearchToolOptions {
112
112
  *
113
113
  * This tool is executed server-side by the xAI API.
114
114
  *
115
+ * @deprecated The Live Search API was deprecated by xAI on December 15, 2025.
116
+ * Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.
117
+ *
118
+ * @example Migration to new tools:
119
+ * ```typescript
120
+ * // Old (deprecated):
121
+ * const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });
122
+ *
123
+ * // New (recommended):
124
+ * const webSearch = tools.xaiWebSearch({ allowedDomains: ["example.com"] });
125
+ * const xSearch = tools.xaiXSearch({ allowedXHandles: ["elonmusk"] });
126
+ * ```
127
+ *
115
128
  * @example
116
129
  * ```typescript
117
130
  * import { ChatXAI, tools } from "@langchain/xai";
@@ -132,5 +145,5 @@ interface XAILiveSearchToolOptions {
132
145
  */
133
146
  declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;
134
147
  //#endregion
135
- export { XAILiveSearchTool, xaiLiveSearch };
148
+ export { XAILiveSearchTool, XAILiveSearchToolOptions, XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch };
136
149
  //# sourceMappingURL=live_search.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"live_search.d.cts","names":["XAISearchParameters","XAI_LIVE_SEARCH_TOOL_TYPE","XAI_LIVE_SEARCH_TOOL_NAME","XAILiveSearchTool","XAIWebSearchToolSource","XAINewsSearchToolSource","XAIXSearchToolSource","XAIRssSearchToolSource","XAISearchToolSource","XAILiveSearchToolOptions","xaiLiveSearch"],"sources":["../../src/tools/live_search.d.ts"],"sourcesContent":["import type { XAISearchParameters } from \"../live_search.js\";\n/**\n * xAI's deprecated live_search tool type.\n */\nexport declare const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport declare const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\nexport type XAISearchToolSource = XAIWebSearchToolSource | XAINewsSearchToolSource | XAIXSearchToolSource | XAIRssSearchToolSource;\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;\n//# sourceMappingURL=live_search.d.ts.map"],"mappings":";;;;;;AAIA;AACqBE,cADAD,yBAAAA,GACyB,iCAAA;AAK7BE,cALID,yBAAAA,GAKa,aAAA;;;;AAA4B;AAiB7CE,UAjBAD,iBAAAA,SAA0BH,mBAiBJ,CAAA;EAWtBK;AAUjB;AAWA;EAIYG,IAAAA,EAAAA,OAjDKN,yBAiDc;EAAGE;;;;AAAgG;AAOlI;EA2DwBM,IAAAA,EAAAA,OA5GPT,yBA4G+BQ;;;;;;UAtG/BL,sBAAAA;;;;;;;;;;;UAWAC,uBAAAA;;;;;;;;;;UAUAC,oBAAAA;;;;;;;;;;;UAWAC,sBAAAA;;;;KAILC,mBAAAA,GAAsBJ,yBAAyBC,0BAA0BC,uBAAuBC;;;;;;;UAO3FE,wBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCHD;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BUE,aAAAA,WAAwBD,2BAA2BN"}
1
+ {"version":3,"file":"live_search.d.cts","names":["XAISearchParameters","XAI_LIVE_SEARCH_TOOL_TYPE","XAI_LIVE_SEARCH_TOOL_NAME","XAILiveSearchTool","XAIWebSearchToolSource","XAINewsSearchToolSource","XAIXSearchToolSource","XAIRssSearchToolSource","XAISearchToolSource","XAILiveSearchToolOptions","xaiLiveSearch"],"sources":["../../src/tools/live_search.d.ts"],"sourcesContent":["import type { XAISearchParameters } from \"../live_search.js\";\n/**\n * xAI's deprecated live_search tool type.\n */\nexport declare const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport declare const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\nexport type XAISearchToolSource = XAIWebSearchToolSource | XAINewsSearchToolSource | XAIXSearchToolSource | XAIRssSearchToolSource;\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @deprecated The Live Search API was deprecated by xAI on December 15, 2025.\n * Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.\n *\n * @example Migration to new tools:\n * ```typescript\n * // Old (deprecated):\n * const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });\n *\n * // New (recommended):\n * const webSearch = tools.xaiWebSearch({ allowedDomains: [\"example.com\"] });\n * const xSearch = tools.xaiXSearch({ allowedXHandles: [\"elonmusk\"] });\n * ```\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;\n//# sourceMappingURL=live_search.d.ts.map"],"mappings":";;;;;;AAIA;AACqBE,cADAD,yBAAAA,GACyB,iCAAA;AAK7BE,cALID,yBAAAA,GAKa,aAAA;;;;AAA4B;AAiB7CE,UAjBAD,iBAAAA,SAA0BH,mBAiBJ,CAAA;EAWtBK;AAUjB;AAWA;EAIYG,IAAAA,EAAAA,OAjDKN,yBAiDc;EAAGE;;;;AAAgG;AAOlI;EAwEwBM,IAAAA,EAAAA,OAzHPT,yBAyH+BQ;;;;;;UAnH/BL,sBAAAA;;;;;;;;;;;UAWAC,uBAAAA;;;;;;;;;;UAUAC,oBAAAA;;;;;;;;;;;UAWAC,sBAAAA;;;;KAILC,mBAAAA,GAAsBJ,yBAAyBC,0BAA0BC,uBAAuBC;;;;;;;UAO3FE,wBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuCUE,aAAAA,WAAwBD,2BAA2BN"}
@@ -112,6 +112,19 @@ interface XAILiveSearchToolOptions {
112
112
  *
113
113
  * This tool is executed server-side by the xAI API.
114
114
  *
115
+ * @deprecated The Live Search API was deprecated by xAI on December 15, 2025.
116
+ * Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.
117
+ *
118
+ * @example Migration to new tools:
119
+ * ```typescript
120
+ * // Old (deprecated):
121
+ * const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });
122
+ *
123
+ * // New (recommended):
124
+ * const webSearch = tools.xaiWebSearch({ allowedDomains: ["example.com"] });
125
+ * const xSearch = tools.xaiXSearch({ allowedXHandles: ["elonmusk"] });
126
+ * ```
127
+ *
115
128
  * @example
116
129
  * ```typescript
117
130
  * import { ChatXAI, tools } from "@langchain/xai";
@@ -132,5 +145,5 @@ interface XAILiveSearchToolOptions {
132
145
  */
133
146
  declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;
134
147
  //#endregion
135
- export { XAILiveSearchTool, xaiLiveSearch };
148
+ export { XAILiveSearchTool, XAILiveSearchToolOptions, XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch };
136
149
  //# sourceMappingURL=live_search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"live_search.d.ts","names":["XAISearchParameters","XAI_LIVE_SEARCH_TOOL_TYPE","XAI_LIVE_SEARCH_TOOL_NAME","XAILiveSearchTool","XAIWebSearchToolSource","XAINewsSearchToolSource","XAIXSearchToolSource","XAIRssSearchToolSource","XAISearchToolSource","XAILiveSearchToolOptions","xaiLiveSearch"],"sources":["../../src/tools/live_search.d.ts"],"sourcesContent":["import type { XAISearchParameters } from \"../live_search.js\";\n/**\n * xAI's deprecated live_search tool type.\n */\nexport declare const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport declare const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\nexport type XAISearchToolSource = XAIWebSearchToolSource | XAINewsSearchToolSource | XAIXSearchToolSource | XAIRssSearchToolSource;\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;\n//# sourceMappingURL=live_search.d.ts.map"],"mappings":";;;;;;AAIA;AACqBE,cADAD,yBAAAA,GACyB,iCAAA;AAK7BE,cALID,yBAAAA,GAKa,aAAA;;;;AAA4B;AAiB7CE,UAjBAD,iBAAAA,SAA0BH,mBAiBJ,CAAA;EAWtBK;AAUjB;AAWA;EAIYG,IAAAA,EAAAA,OAjDKN,yBAiDc;EAAGE;;;;AAAgG;AAOlI;EA2DwBM,IAAAA,EAAAA,OA5GPT,yBA4G+BQ;;;;;;UAtG/BL,sBAAAA;;;;;;;;;;;UAWAC,uBAAAA;;;;;;;;;;UAUAC,oBAAAA;;;;;;;;;;;UAWAC,sBAAAA;;;;KAILC,mBAAAA,GAAsBJ,yBAAyBC,0BAA0BC,uBAAuBC;;;;;;;UAO3FE,wBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCHD;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BUE,aAAAA,WAAwBD,2BAA2BN"}
1
+ {"version":3,"file":"live_search.d.ts","names":["XAISearchParameters","XAI_LIVE_SEARCH_TOOL_TYPE","XAI_LIVE_SEARCH_TOOL_NAME","XAILiveSearchTool","XAIWebSearchToolSource","XAINewsSearchToolSource","XAIXSearchToolSource","XAIRssSearchToolSource","XAISearchToolSource","XAILiveSearchToolOptions","xaiLiveSearch"],"sources":["../../src/tools/live_search.d.ts"],"sourcesContent":["import type { XAISearchParameters } from \"../live_search.js\";\n/**\n * xAI's deprecated live_search tool type.\n */\nexport declare const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport declare const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\nexport type XAISearchToolSource = XAIWebSearchToolSource | XAINewsSearchToolSource | XAIXSearchToolSource | XAIRssSearchToolSource;\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @deprecated The Live Search API was deprecated by xAI on December 15, 2025.\n * Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.\n *\n * @example Migration to new tools:\n * ```typescript\n * // Old (deprecated):\n * const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });\n *\n * // New (recommended):\n * const webSearch = tools.xaiWebSearch({ allowedDomains: [\"example.com\"] });\n * const xSearch = tools.xaiXSearch({ allowedXHandles: [\"elonmusk\"] });\n * ```\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;\n//# sourceMappingURL=live_search.d.ts.map"],"mappings":";;;;;;AAIA;AACqBE,cADAD,yBAAAA,GACyB,iCAAA;AAK7BE,cALID,yBAAAA,GAKa,aAAA;;;;AAA4B;AAiB7CE,UAjBAD,iBAAAA,SAA0BH,mBAiBJ,CAAA;EAWtBK;AAUjB;AAWA;EAIYG,IAAAA,EAAAA,OAjDKN,yBAiDc;EAAGE;;;;AAAgG;AAOlI;EAwEwBM,IAAAA,EAAAA,OAzHPT,yBAyH+BQ;;;;;;UAnH/BL,sBAAAA;;;;;;;;;;;UAWAC,uBAAAA;;;;;;;;;;UAUAC,oBAAAA;;;;;;;;;;;UAWAC,sBAAAA;;;;KAILC,mBAAAA,GAAsBJ,yBAAyBC,0BAA0BC,uBAAuBC;;;;;;;UAO3FE,wBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuCUE,aAAAA,WAAwBD,2BAA2BN"}
@@ -42,6 +42,19 @@ function mapToolSourceToSearchSource(source) {
42
42
  *
43
43
  * This tool is executed server-side by the xAI API.
44
44
  *
45
+ * @deprecated The Live Search API was deprecated by xAI on December 15, 2025.
46
+ * Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.
47
+ *
48
+ * @example Migration to new tools:
49
+ * ```typescript
50
+ * // Old (deprecated):
51
+ * const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });
52
+ *
53
+ * // New (recommended):
54
+ * const webSearch = tools.xaiWebSearch({ allowedDomains: ["example.com"] });
55
+ * const xSearch = tools.xaiXSearch({ allowedXHandles: ["elonmusk"] });
56
+ * ```
57
+ *
45
58
  * @example
46
59
  * ```typescript
47
60
  * import { ChatXAI, tools } from "@langchain/xai";
@@ -74,5 +87,5 @@ function xaiLiveSearch(options = {}) {
74
87
  }
75
88
 
76
89
  //#endregion
77
- export { XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch };
90
+ export { XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch };
78
91
  //# sourceMappingURL=live_search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"live_search.js","names":["source: XAISearchToolSource","_exhaustive: never","options: XAILiveSearchToolOptions"],"sources":["../../src/tools/live_search.ts"],"sourcesContent":["import type { XAISearchParameters, XAISearchSource } from \"../live_search.js\";\n\n/**\n * xAI's deprecated live_search tool type.\n */\nexport const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\n\nexport type XAISearchToolSource =\n | XAIWebSearchToolSource\n | XAINewsSearchToolSource\n | XAIXSearchToolSource\n | XAIRssSearchToolSource;\n\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n\nfunction mapToolSourceToSearchSource(\n source: XAISearchToolSource\n): XAISearchSource {\n switch (source.type) {\n case \"web\":\n return {\n type: \"web\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.allowedWebsites !== undefined && {\n allowed_websites: source.allowedWebsites,\n }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"news\":\n return {\n type: \"news\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"x\":\n return {\n type: \"x\",\n ...(source.includedXHandles !== undefined && {\n included_x_handles: source.includedXHandles,\n }),\n ...(source.excludedXHandles !== undefined && {\n excluded_x_handles: source.excludedXHandles,\n }),\n ...(source.postFavoriteCount !== undefined && {\n post_favorite_count: source.postFavoriteCount,\n }),\n ...(source.postViewCount !== undefined && {\n post_view_count: source.postViewCount,\n }),\n };\n case \"rss\":\n return {\n type: \"rss\",\n links: source.links,\n };\n default: {\n const _exhaustive: never = source;\n return _exhaustive;\n }\n }\n}\n\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport function xaiLiveSearch(\n options: XAILiveSearchToolOptions = {}\n): XAILiveSearchTool {\n return {\n type: XAI_LIVE_SEARCH_TOOL_TYPE,\n name: XAI_LIVE_SEARCH_TOOL_NAME,\n mode: options?.mode,\n max_search_results: options?.maxSearchResults,\n from_date: options?.fromDate,\n to_date: options?.toDate,\n return_citations: options?.returnCitations,\n sources: options?.sources?.map(mapToolSourceToSearchSource),\n } satisfies XAILiveSearchTool;\n}\n"],"mappings":";;;;AAKA,MAAa,4BAA4B;AACzC,MAAa,4BAA4B;AAgHzC,SAAS,4BACPA,QACiB;AACjB,SAAQ,OAAO,MAAf;EACE,KAAK,MACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,oBAAoB,UAAa,EAC1C,kBAAkB,OAAO,gBAC1B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,OACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,IACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,sBAAsB,UAAa,EAC5C,qBAAqB,OAAO,kBAC7B;GACD,GAAI,OAAO,kBAAkB,UAAa,EACxC,iBAAiB,OAAO,cACzB;EACF;EACH,KAAK,MACH,QAAO;GACL,MAAM;GACN,OAAO,OAAO;EACf;EACH,SAAS;GACP,MAAMC,cAAqB;AAC3B,UAAO;EACR;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BD,SAAgB,cACdC,UAAoC,CAAE,GACnB;AACnB,QAAO;EACL,MAAM;EACN,MAAM;EACN,MAAM,SAAS;EACf,oBAAoB,SAAS;EAC7B,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,kBAAkB,SAAS;EAC3B,SAAS,SAAS,SAAS,IAAI,4BAA4B;CAC5D;AACF"}
1
+ {"version":3,"file":"live_search.js","names":["source: XAISearchToolSource","_exhaustive: never","options: XAILiveSearchToolOptions"],"sources":["../../src/tools/live_search.ts"],"sourcesContent":["import type { XAISearchParameters, XAISearchSource } from \"../live_search.js\";\n\n/**\n * xAI's deprecated live_search tool type.\n */\nexport const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\n\nexport type XAISearchToolSource =\n | XAIWebSearchToolSource\n | XAINewsSearchToolSource\n | XAIXSearchToolSource\n | XAIRssSearchToolSource;\n\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n\nfunction mapToolSourceToSearchSource(\n source: XAISearchToolSource\n): XAISearchSource {\n switch (source.type) {\n case \"web\":\n return {\n type: \"web\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.allowedWebsites !== undefined && {\n allowed_websites: source.allowedWebsites,\n }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"news\":\n return {\n type: \"news\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"x\":\n return {\n type: \"x\",\n ...(source.includedXHandles !== undefined && {\n included_x_handles: source.includedXHandles,\n }),\n ...(source.excludedXHandles !== undefined && {\n excluded_x_handles: source.excludedXHandles,\n }),\n ...(source.postFavoriteCount !== undefined && {\n post_favorite_count: source.postFavoriteCount,\n }),\n ...(source.postViewCount !== undefined && {\n post_view_count: source.postViewCount,\n }),\n };\n case \"rss\":\n return {\n type: \"rss\",\n links: source.links,\n };\n default: {\n const _exhaustive: never = source;\n return _exhaustive;\n }\n }\n}\n\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @deprecated The Live Search API was deprecated by xAI on December 15, 2025.\n * Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.\n *\n * @example Migration to new tools:\n * ```typescript\n * // Old (deprecated):\n * const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });\n *\n * // New (recommended):\n * const webSearch = tools.xaiWebSearch({ allowedDomains: [\"example.com\"] });\n * const xSearch = tools.xaiXSearch({ allowedXHandles: [\"elonmusk\"] });\n * ```\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport function xaiLiveSearch(\n options: XAILiveSearchToolOptions = {}\n): XAILiveSearchTool {\n return {\n type: XAI_LIVE_SEARCH_TOOL_TYPE,\n name: XAI_LIVE_SEARCH_TOOL_NAME,\n mode: options?.mode,\n max_search_results: options?.maxSearchResults,\n from_date: options?.fromDate,\n to_date: options?.toDate,\n return_citations: options?.returnCitations,\n sources: options?.sources?.map(mapToolSourceToSearchSource),\n } satisfies XAILiveSearchTool;\n}\n"],"mappings":";;;;AAKA,MAAa,4BAA4B;AACzC,MAAa,4BAA4B;AAgHzC,SAAS,4BACPA,QACiB;AACjB,SAAQ,OAAO,MAAf;EACE,KAAK,MACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,oBAAoB,UAAa,EAC1C,kBAAkB,OAAO,gBAC1B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,OACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,IACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,sBAAsB,UAAa,EAC5C,qBAAqB,OAAO,kBAC7B;GACD,GAAI,OAAO,kBAAkB,UAAa,EACxC,iBAAiB,OAAO,cACzB;EACF;EACH,KAAK,MACH,QAAO;GACL,MAAM;GACN,OAAO,OAAO;EACf;EACH,SAAS;GACP,MAAMC,cAAqB;AAC3B,UAAO;EACR;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCD,SAAgB,cACdC,UAAoC,CAAE,GACnB;AACnB,QAAO;EACL,MAAM;EACN,MAAM;EACN,MAAM,SAAS;EACf,oBAAoB,SAAS;EAC7B,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,kBAAkB,SAAS;EAC3B,SAAS,SAAS,SAAS,IAAI,4BAA4B;CAC5D;AACF"}
@@ -0,0 +1,57 @@
1
+
2
+ //#region src/tools/web_search.ts
3
+ /**
4
+ * xAI Web Search tool type constant.
5
+ */
6
+ const XAI_WEB_SEARCH_TOOL_TYPE = "web_search";
7
+ /**
8
+ * Creates an xAI web search tool.
9
+ * Enables the model to search the web and browse pages for real-time information.
10
+ *
11
+ * This tool is executed server-side by the xAI API as part of the agentic
12
+ * tool calling workflow.
13
+ *
14
+ * @param options - Configuration options for the web search tool
15
+ * @returns An XAIWebSearchTool object to pass to the model
16
+ *
17
+ * @example Basic usage
18
+ * ```typescript
19
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
20
+ *
21
+ * const llm = new ChatXAIResponses({
22
+ * model: "grok-4-1-fast",
23
+ * });
24
+ *
25
+ * const webSearch = tools.xaiWebSearch();
26
+ * const result = await llm.invoke("What are the latest AI developments?", {
27
+ * tools: [webSearch],
28
+ * });
29
+ * ```
30
+ *
31
+ * @example With domain filtering
32
+ * ```typescript
33
+ * const webSearch = tools.xaiWebSearch({
34
+ * allowedDomains: ["wikipedia.org", "arxiv.org"],
35
+ * enableImageUnderstanding: true,
36
+ * });
37
+ * ```
38
+ *
39
+ * @example Excluding specific domains
40
+ * ```typescript
41
+ * const webSearch = tools.xaiWebSearch({
42
+ * excludedDomains: ["example.com"],
43
+ * });
44
+ * ```
45
+ */
46
+ function xaiWebSearch(options = {}) {
47
+ const tool = { type: XAI_WEB_SEARCH_TOOL_TYPE };
48
+ if (options.allowedDomains !== void 0) tool.allowed_domains = options.allowedDomains;
49
+ if (options.excludedDomains !== void 0) tool.excluded_domains = options.excludedDomains;
50
+ if (options.enableImageUnderstanding !== void 0) tool.enable_image_understanding = options.enableImageUnderstanding;
51
+ return tool;
52
+ }
53
+
54
+ //#endregion
55
+ exports.XAI_WEB_SEARCH_TOOL_TYPE = XAI_WEB_SEARCH_TOOL_TYPE;
56
+ exports.xaiWebSearch = xaiWebSearch;
57
+ //# sourceMappingURL=web_search.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web_search.cjs","names":["options: XAIWebSearchToolOptions","tool: XAIWebSearchTool"],"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,aACdA,UAAmC,CAAE,GACnB;CAClB,MAAMC,OAAyB,EAC7B,MAAM,yBACP;AAED,KAAI,QAAQ,mBAAmB,QAC7B,KAAK,kBAAkB,QAAQ;AAGjC,KAAI,QAAQ,oBAAoB,QAC9B,KAAK,mBAAmB,QAAQ;AAGlC,KAAI,QAAQ,6BAA6B,QACvC,KAAK,6BAA6B,QAAQ;AAG5C,QAAO;AACR"}
@@ -0,0 +1,104 @@
1
+ //#region src/tools/web_search.d.ts
2
+ /**
3
+ * xAI Web Search tool type constant.
4
+ */
5
+ declare const XAI_WEB_SEARCH_TOOL_TYPE = "web_search";
6
+ /**
7
+ * xAI's built-in web search tool interface.
8
+ * Enables the model to search the web and browse pages for real-time information.
9
+ *
10
+ * This tool is part of xAI's agentic tool calling API.
11
+ */
12
+ interface XAIWebSearchTool {
13
+ /**
14
+ * The type of the tool. Must be "web_search".
15
+ */
16
+ type: typeof XAI_WEB_SEARCH_TOOL_TYPE;
17
+ /**
18
+ * Domains to exclusively include in the search (max 5).
19
+ * Cannot be used together with `excluded_domains`.
20
+ */
21
+ allowed_domains?: string[];
22
+ /**
23
+ * Domains to exclude from the search (max 5).
24
+ * Cannot be used together with `allowed_domains`.
25
+ */
26
+ excluded_domains?: string[];
27
+ /**
28
+ * Whether to enable image understanding.
29
+ * When enabled, the model can analyze images encountered during search.
30
+ */
31
+ enable_image_understanding?: boolean;
32
+ }
33
+ /**
34
+ * Options for the xAI web search tool (camelCase).
35
+ * All fields are camel-cased for the TypeScript API and are mapped to the
36
+ * corresponding snake_case fields in the API request.
37
+ */
38
+ interface XAIWebSearchToolOptions {
39
+ /**
40
+ * Domains to exclusively include in the search (max 5).
41
+ * Cannot be used together with `excludedDomains`.
42
+ *
43
+ * @example ["wikipedia.org", "github.com"]
44
+ */
45
+ allowedDomains?: string[];
46
+ /**
47
+ * Domains to exclude from the search (max 5).
48
+ * Cannot be used together with `allowedDomains`.
49
+ *
50
+ * @example ["example.com"]
51
+ */
52
+ excludedDomains?: string[];
53
+ /**
54
+ * Whether to enable image understanding.
55
+ * When enabled, the model can analyze images encountered during search.
56
+ * Note: This increases token usage as images are processed.
57
+ *
58
+ * @default false
59
+ */
60
+ enableImageUnderstanding?: boolean;
61
+ }
62
+ /**
63
+ * Creates an xAI web search tool.
64
+ * Enables the model to search the web and browse pages for real-time information.
65
+ *
66
+ * This tool is executed server-side by the xAI API as part of the agentic
67
+ * tool calling workflow.
68
+ *
69
+ * @param options - Configuration options for the web search tool
70
+ * @returns An XAIWebSearchTool object to pass to the model
71
+ *
72
+ * @example Basic usage
73
+ * ```typescript
74
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
75
+ *
76
+ * const llm = new ChatXAIResponses({
77
+ * model: "grok-4-1-fast",
78
+ * });
79
+ *
80
+ * const webSearch = tools.xaiWebSearch();
81
+ * const result = await llm.invoke("What are the latest AI developments?", {
82
+ * tools: [webSearch],
83
+ * });
84
+ * ```
85
+ *
86
+ * @example With domain filtering
87
+ * ```typescript
88
+ * const webSearch = tools.xaiWebSearch({
89
+ * allowedDomains: ["wikipedia.org", "arxiv.org"],
90
+ * enableImageUnderstanding: true,
91
+ * });
92
+ * ```
93
+ *
94
+ * @example Excluding specific domains
95
+ * ```typescript
96
+ * const webSearch = tools.xaiWebSearch({
97
+ * excludedDomains: ["example.com"],
98
+ * });
99
+ * ```
100
+ */
101
+ declare function xaiWebSearch(options?: XAIWebSearchToolOptions): XAIWebSearchTool;
102
+ //#endregion
103
+ export { XAIWebSearchTool, XAIWebSearchToolOptions, XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch };
104
+ //# sourceMappingURL=web_search.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web_search.d.cts","names":["XAI_WEB_SEARCH_TOOL_TYPE","XAIWebSearchTool","XAIWebSearchToolOptions","xaiWebSearch"],"sources":["../../src/tools/web_search.d.ts"],"sourcesContent":["/**\n * xAI Web Search tool type constant.\n */\nexport declare const XAI_WEB_SEARCH_TOOL_TYPE = \"web_search\";\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 * 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 * 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 declare function xaiWebSearch(options?: XAIWebSearchToolOptions): XAIWebSearchTool;\n//# sourceMappingURL=web_search.d.ts.map"],"mappings":";;AAGA;AAOA;AA0BiBE,cAjCIF,wBAAAA,GAiCmB,YAAA;AA+DxC;;;;;;UAzFiBC,gBAAAA;;;;eAIAD;;;;;;;;;;;;;;;;;;;;;;UAsBAE,uBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+DOC,YAAAA,WAAuBD,0BAA0BD"}
@@ -0,0 +1,104 @@
1
+ //#region src/tools/web_search.d.ts
2
+ /**
3
+ * xAI Web Search tool type constant.
4
+ */
5
+ declare const XAI_WEB_SEARCH_TOOL_TYPE = "web_search";
6
+ /**
7
+ * xAI's built-in web search tool interface.
8
+ * Enables the model to search the web and browse pages for real-time information.
9
+ *
10
+ * This tool is part of xAI's agentic tool calling API.
11
+ */
12
+ interface XAIWebSearchTool {
13
+ /**
14
+ * The type of the tool. Must be "web_search".
15
+ */
16
+ type: typeof XAI_WEB_SEARCH_TOOL_TYPE;
17
+ /**
18
+ * Domains to exclusively include in the search (max 5).
19
+ * Cannot be used together with `excluded_domains`.
20
+ */
21
+ allowed_domains?: string[];
22
+ /**
23
+ * Domains to exclude from the search (max 5).
24
+ * Cannot be used together with `allowed_domains`.
25
+ */
26
+ excluded_domains?: string[];
27
+ /**
28
+ * Whether to enable image understanding.
29
+ * When enabled, the model can analyze images encountered during search.
30
+ */
31
+ enable_image_understanding?: boolean;
32
+ }
33
+ /**
34
+ * Options for the xAI web search tool (camelCase).
35
+ * All fields are camel-cased for the TypeScript API and are mapped to the
36
+ * corresponding snake_case fields in the API request.
37
+ */
38
+ interface XAIWebSearchToolOptions {
39
+ /**
40
+ * Domains to exclusively include in the search (max 5).
41
+ * Cannot be used together with `excludedDomains`.
42
+ *
43
+ * @example ["wikipedia.org", "github.com"]
44
+ */
45
+ allowedDomains?: string[];
46
+ /**
47
+ * Domains to exclude from the search (max 5).
48
+ * Cannot be used together with `allowedDomains`.
49
+ *
50
+ * @example ["example.com"]
51
+ */
52
+ excludedDomains?: string[];
53
+ /**
54
+ * Whether to enable image understanding.
55
+ * When enabled, the model can analyze images encountered during search.
56
+ * Note: This increases token usage as images are processed.
57
+ *
58
+ * @default false
59
+ */
60
+ enableImageUnderstanding?: boolean;
61
+ }
62
+ /**
63
+ * Creates an xAI web search tool.
64
+ * Enables the model to search the web and browse pages for real-time information.
65
+ *
66
+ * This tool is executed server-side by the xAI API as part of the agentic
67
+ * tool calling workflow.
68
+ *
69
+ * @param options - Configuration options for the web search tool
70
+ * @returns An XAIWebSearchTool object to pass to the model
71
+ *
72
+ * @example Basic usage
73
+ * ```typescript
74
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
75
+ *
76
+ * const llm = new ChatXAIResponses({
77
+ * model: "grok-4-1-fast",
78
+ * });
79
+ *
80
+ * const webSearch = tools.xaiWebSearch();
81
+ * const result = await llm.invoke("What are the latest AI developments?", {
82
+ * tools: [webSearch],
83
+ * });
84
+ * ```
85
+ *
86
+ * @example With domain filtering
87
+ * ```typescript
88
+ * const webSearch = tools.xaiWebSearch({
89
+ * allowedDomains: ["wikipedia.org", "arxiv.org"],
90
+ * enableImageUnderstanding: true,
91
+ * });
92
+ * ```
93
+ *
94
+ * @example Excluding specific domains
95
+ * ```typescript
96
+ * const webSearch = tools.xaiWebSearch({
97
+ * excludedDomains: ["example.com"],
98
+ * });
99
+ * ```
100
+ */
101
+ declare function xaiWebSearch(options?: XAIWebSearchToolOptions): XAIWebSearchTool;
102
+ //#endregion
103
+ export { XAIWebSearchTool, XAIWebSearchToolOptions, XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch };
104
+ //# sourceMappingURL=web_search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web_search.d.ts","names":["XAI_WEB_SEARCH_TOOL_TYPE","XAIWebSearchTool","XAIWebSearchToolOptions","xaiWebSearch"],"sources":["../../src/tools/web_search.d.ts"],"sourcesContent":["/**\n * xAI Web Search tool type constant.\n */\nexport declare const XAI_WEB_SEARCH_TOOL_TYPE = \"web_search\";\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 * 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 * 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 declare function xaiWebSearch(options?: XAIWebSearchToolOptions): XAIWebSearchTool;\n//# sourceMappingURL=web_search.d.ts.map"],"mappings":";;AAGA;AAOA;AA0BiBE,cAjCIF,wBAAAA,GAiCmB,YAAA;AA+DxC;;;;;;UAzFiBC,gBAAAA;;;;eAIAD;;;;;;;;;;;;;;;;;;;;;;UAsBAE,uBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+DOC,YAAAA,WAAuBD,0BAA0BD"}