@ai-sdk/xai 2.0.47 → 2.0.48

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.
package/dist/index.mjs CHANGED
@@ -1845,28 +1845,29 @@ var XaiResponsesLanguageModel = class {
1845
1845
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
1846
1846
  const part = event.item;
1847
1847
  if (part.type === "web_search_call" || part.type === "x_search_call" || part.type === "code_interpreter_call" || part.type === "code_execution_call" || part.type === "view_image_call" || part.type === "view_x_video_call" || part.type === "custom_tool_call") {
1848
- if (!seenToolCalls.has(part.id)) {
1848
+ const webSearchSubTools = [
1849
+ "web_search",
1850
+ "web_search_with_snippets",
1851
+ "browse_page"
1852
+ ];
1853
+ const xSearchSubTools = [
1854
+ "x_user_search",
1855
+ "x_keyword_search",
1856
+ "x_semantic_search",
1857
+ "x_thread_fetch"
1858
+ ];
1859
+ let toolName = (_e = part.name) != null ? _e : "";
1860
+ if (webSearchSubTools.includes((_f = part.name) != null ? _f : "") || part.type === "web_search_call") {
1861
+ toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1862
+ } else if (xSearchSubTools.includes((_g = part.name) != null ? _g : "") || part.type === "x_search_call") {
1863
+ toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1864
+ } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
1865
+ toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1866
+ }
1867
+ const toolInput = part.type === "custom_tool_call" ? (_h = part.input) != null ? _h : "" : (_i = part.arguments) != null ? _i : "";
1868
+ const shouldEmit = part.type === "custom_tool_call" ? event.type === "response.output_item.done" : !seenToolCalls.has(part.id);
1869
+ if (shouldEmit && !seenToolCalls.has(part.id)) {
1849
1870
  seenToolCalls.add(part.id);
1850
- const webSearchSubTools = [
1851
- "web_search",
1852
- "web_search_with_snippets",
1853
- "browse_page"
1854
- ];
1855
- const xSearchSubTools = [
1856
- "x_user_search",
1857
- "x_keyword_search",
1858
- "x_semantic_search",
1859
- "x_thread_fetch"
1860
- ];
1861
- let toolName = (_e = part.name) != null ? _e : "";
1862
- if (webSearchSubTools.includes((_f = part.name) != null ? _f : "") || part.type === "web_search_call") {
1863
- toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1864
- } else if (xSearchSubTools.includes((_g = part.name) != null ? _g : "") || part.type === "x_search_call") {
1865
- toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1866
- } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
1867
- toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1868
- }
1869
- const toolInput = part.type === "custom_tool_call" ? (_h = part.input) != null ? _h : "" : (_i = part.arguments) != null ? _i : "";
1870
1871
  controller.enqueue({
1871
1872
  type: "tool-input-start",
1872
1873
  id: part.id,
@@ -1901,12 +1902,12 @@ var XaiResponsesLanguageModel = class {
1901
1902
  type: "text-start",
1902
1903
  id: blockId
1903
1904
  });
1905
+ controller.enqueue({
1906
+ type: "text-delta",
1907
+ id: blockId,
1908
+ delta: contentPart.text
1909
+ });
1904
1910
  }
1905
- controller.enqueue({
1906
- type: "text-delta",
1907
- id: blockId,
1908
- delta: contentPart.text
1909
- });
1910
1911
  }
1911
1912
  if (contentPart.annotations) {
1912
1913
  for (const annotation of contentPart.annotations) {
@@ -2024,7 +2025,7 @@ var xaiTools = {
2024
2025
  };
2025
2026
 
2026
2027
  // src/version.ts
2027
- var VERSION = true ? "2.0.47" : "0.0.0-test";
2028
+ var VERSION = true ? "2.0.48" : "0.0.0-test";
2028
2029
 
2029
2030
  // src/xai-provider.ts
2030
2031
  var xaiErrorStructure = {