@yourgpt/llm-sdk 2.1.5 → 2.1.6

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 (41) hide show
  1. package/dist/adapters/index.d.mts +11 -37
  2. package/dist/adapters/index.d.ts +11 -37
  3. package/dist/adapters/index.js +41 -192
  4. package/dist/adapters/index.mjs +42 -192
  5. package/dist/{base-5n-UuPfS.d.mts → base-D-U61JaB.d.mts} +22 -2
  6. package/dist/{base-Di31iy_8.d.ts → base-iGi9Va6Z.d.ts} +22 -2
  7. package/dist/fallback/index.d.mts +3 -3
  8. package/dist/fallback/index.d.ts +3 -3
  9. package/dist/index.d.mts +5 -5
  10. package/dist/index.d.ts +5 -5
  11. package/dist/index.js +96 -76
  12. package/dist/index.mjs +96 -76
  13. package/dist/providers/anthropic/index.d.mts +2 -2
  14. package/dist/providers/anthropic/index.d.ts +2 -2
  15. package/dist/providers/azure/index.d.mts +2 -2
  16. package/dist/providers/azure/index.d.ts +2 -2
  17. package/dist/providers/azure/index.js +4 -2
  18. package/dist/providers/azure/index.mjs +4 -2
  19. package/dist/providers/google/index.d.mts +2 -2
  20. package/dist/providers/google/index.d.ts +2 -2
  21. package/dist/providers/google/index.js +527 -339
  22. package/dist/providers/google/index.mjs +527 -339
  23. package/dist/providers/ollama/index.d.mts +3 -3
  24. package/dist/providers/ollama/index.d.ts +3 -3
  25. package/dist/providers/openai/index.d.mts +2 -2
  26. package/dist/providers/openai/index.d.ts +2 -2
  27. package/dist/providers/openai/index.js +34 -11
  28. package/dist/providers/openai/index.mjs +34 -11
  29. package/dist/providers/openrouter/index.d.mts +2 -2
  30. package/dist/providers/openrouter/index.d.ts +2 -2
  31. package/dist/providers/openrouter/index.js +34 -11
  32. package/dist/providers/openrouter/index.mjs +34 -11
  33. package/dist/providers/xai/index.d.mts +2 -2
  34. package/dist/providers/xai/index.d.ts +2 -2
  35. package/dist/providers/xai/index.js +355 -46
  36. package/dist/providers/xai/index.mjs +355 -46
  37. package/dist/{types-CNL8ZRne.d.ts → types-38yolWJn.d.ts} +1 -1
  38. package/dist/{types-C0vLXzuw.d.ts → types-BctsnC3g.d.ts} +1 -1
  39. package/dist/{types-BQl1suAv.d.mts → types-D4YfrQJR.d.mts} +1 -1
  40. package/dist/{types-VDgiUvH2.d.mts → types-DRqxMIjF.d.mts} +1 -1
  41. package/package.json +1 -1
@@ -336,11 +336,13 @@ function formatMessagesForOpenAI(messages, systemPrompt) {
336
336
  content: messageToOpenAIContent(msg)
337
337
  });
338
338
  } else if (msg.role === "assistant") {
339
+ const hasToolCalls = msg.tool_calls && msg.tool_calls.length > 0;
339
340
  const assistantMsg = {
340
341
  role: "assistant",
341
- content: msg.content
342
+ // Gemini/xAI (OpenAI-compatible) reject content: "" on assistant messages with tool_calls
343
+ content: hasToolCalls ? msg.content || null : msg.content
342
344
  };
343
- if (msg.tool_calls && msg.tool_calls.length > 0) {
345
+ if (hasToolCalls) {
344
346
  assistantMsg.tool_calls = msg.tool_calls;
345
347
  }
346
348
  formatted.push(assistantMsg);
@@ -367,11 +369,18 @@ function generateToolCallId() {
367
369
  }
368
370
 
369
371
  // src/adapters/openai.ts
370
- var OpenAIAdapter = class {
372
+ var OpenAIAdapter = class _OpenAIAdapter {
371
373
  constructor(config) {
372
- this.provider = "openai";
373
374
  this.config = config;
374
375
  this.model = config.model || "gpt-4o";
376
+ this.provider = _OpenAIAdapter.resolveProviderName(config.baseUrl);
377
+ }
378
+ static resolveProviderName(baseUrl) {
379
+ if (!baseUrl) return "openai";
380
+ if (baseUrl.includes("generativelanguage.googleapis.com")) return "google";
381
+ if (baseUrl.includes("x.ai")) return "xai";
382
+ if (baseUrl.includes("azure")) return "azure";
383
+ return "openai";
375
384
  }
376
385
  async getClient() {
377
386
  if (!this.client) {
@@ -533,6 +542,9 @@ var OpenAIAdapter = class {
533
542
  let messages;
534
543
  if (request.rawMessages && request.rawMessages.length > 0) {
535
544
  const processedMessages = request.rawMessages.map((msg) => {
545
+ if (msg.role === "assistant" && Array.isArray(msg.tool_calls) && msg.tool_calls.length > 0 && msg.content === "") {
546
+ return { ...msg, content: null };
547
+ }
536
548
  const hasAttachments = msg.attachments && Array.isArray(msg.attachments) && msg.attachments.length > 0;
537
549
  if (hasAttachments) {
538
550
  const content = [];
@@ -654,15 +666,18 @@ var OpenAIAdapter = class {
654
666
  args: currentToolCall.arguments
655
667
  };
656
668
  }
669
+ const tcExtraContent = toolCall.extra_content;
657
670
  currentToolCall = {
658
671
  id: toolCall.id,
659
672
  name: toolCall.function?.name || "",
660
- arguments: toolCall.function?.arguments || ""
673
+ arguments: toolCall.function?.arguments || "",
674
+ ...tcExtraContent ? { extra_content: tcExtraContent } : {}
661
675
  };
662
676
  yield {
663
677
  type: "action:start",
664
678
  id: currentToolCall.id,
665
- name: currentToolCall.name
679
+ name: currentToolCall.name,
680
+ ...currentToolCall.extra_content ? { extra_content: currentToolCall.extra_content } : {}
666
681
  };
667
682
  } else if (currentToolCall && toolCall.function?.arguments) {
668
683
  currentToolCall.arguments += toolCall.function.arguments;
@@ -696,7 +711,7 @@ var OpenAIAdapter = class {
696
711
  yield {
697
712
  type: "error",
698
713
  message: error instanceof Error ? error.message : "Unknown error",
699
- code: "OPENAI_ERROR"
714
+ code: `${this.provider.toUpperCase()}_ERROR`
700
715
  };
701
716
  }
702
717
  }
@@ -707,12 +722,19 @@ var OpenAIAdapter = class {
707
722
  const client = await this.getClient();
708
723
  let messages;
709
724
  if (request.rawMessages && request.rawMessages.length > 0) {
710
- messages = request.rawMessages;
711
- if (request.systemPrompt && !messages.some((message2) => message2.role === "system")) {
725
+ const sanitized = request.rawMessages.map((msg) => {
726
+ if (msg.role === "assistant" && Array.isArray(msg.tool_calls) && msg.tool_calls.length > 0 && msg.content === "") {
727
+ return { ...msg, content: null };
728
+ }
729
+ return msg;
730
+ });
731
+ if (request.systemPrompt && !sanitized.some((message2) => message2.role === "system")) {
712
732
  messages = [
713
733
  { role: "system", content: request.systemPrompt },
714
- ...messages
734
+ ...sanitized
715
735
  ];
736
+ } else {
737
+ messages = sanitized;
716
738
  }
717
739
  } else {
718
740
  messages = formatMessagesForOpenAI(
@@ -754,7 +776,8 @@ var OpenAIAdapter = class {
754
776
  } catch {
755
777
  return {};
756
778
  }
757
- })()
779
+ })(),
780
+ ...toolCall.extra_content ? { extra_content: toolCall.extra_content } : {}
758
781
  })) ?? [],
759
782
  usage: response.usage ? {
760
783
  promptTokens: response.usage.prompt_tokens,
@@ -1985,187 +2008,14 @@ function extractDomain3(url) {
1985
2008
 
1986
2009
  // src/adapters/xai.ts
1987
2010
  var XAI_BASE_URL = "https://api.x.ai/v1";
1988
- var XAIAdapter = class {
1989
- constructor(config) {
1990
- this.provider = "xai";
1991
- this.config = config;
1992
- this.model = config.model || "grok-2";
1993
- }
1994
- async getClient() {
1995
- if (!this.client) {
1996
- const { default: OpenAI } = await import('openai');
1997
- this.client = new OpenAI({
1998
- apiKey: this.config.apiKey,
1999
- baseURL: this.config.baseUrl || XAI_BASE_URL
2000
- });
2001
- }
2002
- return this.client;
2003
- }
2004
- async *stream(request) {
2005
- const client = await this.getClient();
2006
- let messages;
2007
- if (request.rawMessages && request.rawMessages.length > 0) {
2008
- const processedMessages = request.rawMessages.map((msg) => {
2009
- const hasAttachments = msg.attachments && Array.isArray(msg.attachments) && msg.attachments.length > 0;
2010
- if (hasAttachments) {
2011
- const content = [];
2012
- if (msg.content) {
2013
- content.push({ type: "text", text: msg.content });
2014
- }
2015
- for (const attachment of msg.attachments) {
2016
- if (attachment.type === "image") {
2017
- let imageUrl = attachment.data;
2018
- if (!imageUrl.startsWith("data:")) {
2019
- imageUrl = `data:${attachment.mimeType || "image/png"};base64,${attachment.data}`;
2020
- }
2021
- content.push({
2022
- type: "image_url",
2023
- image_url: { url: imageUrl, detail: "auto" }
2024
- });
2025
- }
2026
- }
2027
- return { ...msg, content, attachments: void 0 };
2028
- }
2029
- return msg;
2030
- });
2031
- if (request.systemPrompt) {
2032
- const hasSystem = processedMessages.some((m) => m.role === "system");
2033
- if (!hasSystem) {
2034
- messages = [
2035
- { role: "system", content: request.systemPrompt },
2036
- ...processedMessages
2037
- ];
2038
- } else {
2039
- messages = processedMessages;
2040
- }
2041
- } else {
2042
- messages = processedMessages;
2043
- }
2044
- } else {
2045
- messages = formatMessagesForOpenAI(
2046
- request.messages,
2047
- request.systemPrompt
2048
- );
2049
- }
2050
- const tools = request.actions?.length ? formatTools(request.actions) : void 0;
2051
- const messageId = generateMessageId();
2052
- yield { type: "message:start", id: messageId };
2053
- try {
2054
- const payload = {
2055
- model: request.config?.model || this.model,
2056
- messages,
2057
- tools,
2058
- temperature: request.config?.temperature ?? this.config.temperature,
2059
- max_tokens: request.config?.maxTokens ?? this.config.maxTokens,
2060
- stream: true
2061
- };
2062
- logProviderPayload("xai", "request payload", payload, request.debug);
2063
- const stream = await client.chat.completions.create(payload);
2064
- let currentToolCall = null;
2065
- for await (const chunk of stream) {
2066
- logProviderPayload("xai", "stream chunk", chunk, request.debug);
2067
- if (request.signal?.aborted) {
2068
- break;
2069
- }
2070
- const delta = chunk.choices[0]?.delta;
2071
- if (delta?.content) {
2072
- yield { type: "message:delta", content: delta.content };
2073
- }
2074
- if (delta?.tool_calls) {
2075
- for (const toolCall of delta.tool_calls) {
2076
- if (toolCall.id) {
2077
- if (currentToolCall) {
2078
- yield {
2079
- type: "action:args",
2080
- id: currentToolCall.id,
2081
- args: currentToolCall.arguments
2082
- };
2083
- }
2084
- currentToolCall = {
2085
- id: toolCall.id,
2086
- name: toolCall.function?.name || "",
2087
- arguments: toolCall.function?.arguments || ""
2088
- };
2089
- yield {
2090
- type: "action:start",
2091
- id: currentToolCall.id,
2092
- name: currentToolCall.name
2093
- };
2094
- } else if (currentToolCall && toolCall.function?.arguments) {
2095
- currentToolCall.arguments += toolCall.function.arguments;
2096
- }
2097
- }
2098
- }
2099
- if (chunk.choices[0]?.finish_reason) {
2100
- if (currentToolCall) {
2101
- yield {
2102
- type: "action:args",
2103
- id: currentToolCall.id,
2104
- args: currentToolCall.arguments
2105
- };
2106
- }
2107
- }
2108
- }
2109
- yield { type: "message:end" };
2110
- yield { type: "done" };
2111
- } catch (error) {
2112
- yield {
2113
- type: "error",
2114
- message: error instanceof Error ? error.message : "Unknown error",
2115
- code: "XAI_ERROR"
2116
- };
2117
- }
2118
- }
2119
- /**
2120
- * Non-streaming completion (optional, for debugging)
2121
- */
2122
- async complete(request) {
2123
- const client = await this.getClient();
2124
- let messages;
2125
- if (request.rawMessages && request.rawMessages.length > 0) {
2126
- messages = request.rawMessages;
2127
- if (request.systemPrompt) {
2128
- const hasSystem = messages.some((m) => m.role === "system");
2129
- if (!hasSystem) {
2130
- messages = [
2131
- { role: "system", content: request.systemPrompt },
2132
- ...messages
2133
- ];
2134
- }
2135
- }
2136
- } else {
2137
- messages = formatMessagesForOpenAI(
2138
- request.messages,
2139
- request.systemPrompt
2140
- );
2141
- }
2142
- const tools = request.actions?.length ? formatTools(request.actions) : void 0;
2143
- const payload = {
2144
- model: request.config?.model || this.model,
2145
- messages,
2146
- tools,
2147
- temperature: request.config?.temperature ?? this.config.temperature,
2148
- max_tokens: request.config?.maxTokens ?? this.config.maxTokens
2149
- };
2150
- logProviderPayload("xai", "request payload", payload, request.debug);
2151
- const response = await client.chat.completions.create(payload);
2152
- logProviderPayload("xai", "response payload", response, request.debug);
2153
- const choice = response.choices[0];
2154
- const message = choice?.message;
2155
- const toolCalls = (message?.tool_calls || []).map((tc) => ({
2156
- id: tc.id,
2157
- name: tc.function.name,
2158
- args: JSON.parse(tc.function.arguments || "{}")
2159
- }));
2160
- return {
2161
- content: message?.content || "",
2162
- toolCalls,
2163
- rawResponse: response
2164
- };
2165
- }
2166
- };
2167
2011
  function createXAIAdapter(config) {
2168
- return new XAIAdapter(config);
2012
+ return createOpenAIAdapter({
2013
+ apiKey: config.apiKey,
2014
+ model: config.model || "grok-3",
2015
+ baseUrl: config.baseUrl || XAI_BASE_URL,
2016
+ temperature: config.temperature,
2017
+ maxTokens: config.maxTokens
2018
+ });
2169
2019
  }
2170
2020
 
2171
2021
  // src/adapters/azure.ts
@@ -2363,6 +2213,6 @@ function createAzureAdapter(config) {
2363
2213
  return new AzureAdapter(config);
2364
2214
  }
2365
2215
 
2366
- export { AnthropicAdapter, AzureAdapter, GoogleAdapter, OllamaAdapter, OpenAIAdapter, XAIAdapter, attachmentToAnthropicDocument, attachmentToAnthropicImage, attachmentToOpenAIImage, createAnthropicAdapter, createAzureAdapter, createGoogleAdapter, createOllamaAdapter, createOpenAIAdapter, createXAIAdapter, formatMessages, formatMessagesForAnthropic, formatMessagesForOpenAI, formatTools, hasImageAttachments, hasMediaAttachments, messageToAnthropicContent, messageToOpenAIContent };
2216
+ export { AnthropicAdapter, AzureAdapter, GoogleAdapter, OllamaAdapter, OpenAIAdapter, attachmentToAnthropicDocument, attachmentToAnthropicImage, attachmentToOpenAIImage, createAnthropicAdapter, createAzureAdapter, createGoogleAdapter, createOllamaAdapter, createOpenAIAdapter, createXAIAdapter, formatMessages, formatMessagesForAnthropic, formatMessagesForOpenAI, formatTools, hasImageAttachments, hasMediaAttachments, messageToAnthropicContent, messageToOpenAIContent };
2367
2217
  //# sourceMappingURL=index.mjs.map
2368
2218
  //# sourceMappingURL=index.mjs.map
@@ -7,7 +7,7 @@ import { t as TokenUsage } from './types-CR8mi9I0.mjs';
7
7
  /**
8
8
  * Stream event types
9
9
  */
10
- type StreamEventType = "message:start" | "message:delta" | "message:end" | "thinking:start" | "thinking:delta" | "thinking:end" | "action:start" | "action:args" | "action:end" | "tool_calls" | "tool:result" | "citation" | "loop:iteration" | "loop:complete" | "error" | "done";
10
+ type StreamEventType = "message:start" | "message:delta" | "message:end" | "thinking:start" | "thinking:delta" | "thinking:end" | "action:start" | "action:args" | "action:end" | "tool_calls" | "tool:result" | "citation" | "loop:iteration" | "loop:complete" | "error" | "thread:created" | "done";
11
11
  /**
12
12
  * Base event interface
13
13
  */
@@ -62,6 +62,8 @@ interface ActionStartEvent extends BaseEvent {
62
62
  name: string;
63
63
  /** Whether this tool should be hidden from UI */
64
64
  hidden?: boolean;
65
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature) */
66
+ extra_content?: Record<string, unknown>;
65
67
  }
66
68
  /**
67
69
  * Action arguments (streaming)
@@ -98,6 +100,8 @@ interface ToolCallInfo {
98
100
  args: Record<string, unknown>;
99
101
  /** Whether this tool should be hidden from UI */
100
102
  hidden?: boolean;
103
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature) */
104
+ extra_content?: Record<string, unknown>;
101
105
  }
102
106
  /**
103
107
  * Assistant message with tool calls
@@ -112,6 +116,8 @@ interface AssistantToolMessage {
112
116
  name: string;
113
117
  arguments: string;
114
118
  };
119
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature) */
120
+ extra_content?: Record<string, unknown>;
115
121
  }>;
116
122
  }
117
123
  /**
@@ -185,6 +191,8 @@ interface DoneEventMessage {
185
191
  name: string;
186
192
  arguments: string;
187
193
  };
194
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature) */
195
+ extra_content?: Record<string, unknown>;
188
196
  }>;
189
197
  tool_call_id?: string;
190
198
  }
@@ -196,6 +204,14 @@ interface TokenUsageRaw {
196
204
  completion_tokens: number;
197
205
  total_tokens?: number;
198
206
  }
207
+ /**
208
+ * Thread/session created — emitted early in the stream, before any message events,
209
+ * so the client can adopt the threadId without waiting for the done chunk.
210
+ */
211
+ interface ThreadCreatedEvent extends BaseEvent {
212
+ type: "thread:created";
213
+ threadId: string;
214
+ }
199
215
  /**
200
216
  * Stream completed
201
217
  */
@@ -211,7 +227,7 @@ interface DoneEvent extends BaseEvent {
211
227
  /**
212
228
  * Union of all stream events
213
229
  */
214
- type StreamEvent = MessageStartEvent | MessageDeltaEvent | MessageEndEvent | ThinkingStartEvent | ThinkingDeltaEvent | ThinkingEndEvent | ActionStartEvent | ActionArgsEvent | ActionEndEvent | ToolCallsEvent | ToolResultEvent | CitationEvent | LoopIterationEvent | LoopCompleteEvent | ErrorEvent | DoneEvent;
230
+ type StreamEvent = MessageStartEvent | MessageDeltaEvent | MessageEndEvent | ThinkingStartEvent | ThinkingDeltaEvent | ThinkingEndEvent | ActionStartEvent | ActionArgsEvent | ActionEndEvent | ToolCallsEvent | ToolResultEvent | CitationEvent | LoopIterationEvent | LoopCompleteEvent | ErrorEvent | ThreadCreatedEvent | DoneEvent;
215
231
  /**
216
232
  * LLM configuration
217
233
  */
@@ -229,6 +245,8 @@ interface ToolCall {
229
245
  name: string;
230
246
  arguments: string;
231
247
  };
248
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature in extra_content.google) */
249
+ extra_content?: Record<string, unknown>;
232
250
  }
233
251
  /**
234
252
  * Message role
@@ -563,6 +581,8 @@ interface CompletionResult {
563
581
  id: string;
564
582
  name: string;
565
583
  args: Record<string, unknown>;
584
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature in extra_content.google) */
585
+ extra_content?: Record<string, unknown>;
566
586
  }>;
567
587
  /** Thinking content (if extended thinking enabled) */
568
588
  thinking?: string;
@@ -7,7 +7,7 @@ import { t as TokenUsage } from './types-CR8mi9I0.js';
7
7
  /**
8
8
  * Stream event types
9
9
  */
10
- type StreamEventType = "message:start" | "message:delta" | "message:end" | "thinking:start" | "thinking:delta" | "thinking:end" | "action:start" | "action:args" | "action:end" | "tool_calls" | "tool:result" | "citation" | "loop:iteration" | "loop:complete" | "error" | "done";
10
+ type StreamEventType = "message:start" | "message:delta" | "message:end" | "thinking:start" | "thinking:delta" | "thinking:end" | "action:start" | "action:args" | "action:end" | "tool_calls" | "tool:result" | "citation" | "loop:iteration" | "loop:complete" | "error" | "thread:created" | "done";
11
11
  /**
12
12
  * Base event interface
13
13
  */
@@ -62,6 +62,8 @@ interface ActionStartEvent extends BaseEvent {
62
62
  name: string;
63
63
  /** Whether this tool should be hidden from UI */
64
64
  hidden?: boolean;
65
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature) */
66
+ extra_content?: Record<string, unknown>;
65
67
  }
66
68
  /**
67
69
  * Action arguments (streaming)
@@ -98,6 +100,8 @@ interface ToolCallInfo {
98
100
  args: Record<string, unknown>;
99
101
  /** Whether this tool should be hidden from UI */
100
102
  hidden?: boolean;
103
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature) */
104
+ extra_content?: Record<string, unknown>;
101
105
  }
102
106
  /**
103
107
  * Assistant message with tool calls
@@ -112,6 +116,8 @@ interface AssistantToolMessage {
112
116
  name: string;
113
117
  arguments: string;
114
118
  };
119
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature) */
120
+ extra_content?: Record<string, unknown>;
115
121
  }>;
116
122
  }
117
123
  /**
@@ -185,6 +191,8 @@ interface DoneEventMessage {
185
191
  name: string;
186
192
  arguments: string;
187
193
  };
194
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature) */
195
+ extra_content?: Record<string, unknown>;
188
196
  }>;
189
197
  tool_call_id?: string;
190
198
  }
@@ -196,6 +204,14 @@ interface TokenUsageRaw {
196
204
  completion_tokens: number;
197
205
  total_tokens?: number;
198
206
  }
207
+ /**
208
+ * Thread/session created — emitted early in the stream, before any message events,
209
+ * so the client can adopt the threadId without waiting for the done chunk.
210
+ */
211
+ interface ThreadCreatedEvent extends BaseEvent {
212
+ type: "thread:created";
213
+ threadId: string;
214
+ }
199
215
  /**
200
216
  * Stream completed
201
217
  */
@@ -211,7 +227,7 @@ interface DoneEvent extends BaseEvent {
211
227
  /**
212
228
  * Union of all stream events
213
229
  */
214
- type StreamEvent = MessageStartEvent | MessageDeltaEvent | MessageEndEvent | ThinkingStartEvent | ThinkingDeltaEvent | ThinkingEndEvent | ActionStartEvent | ActionArgsEvent | ActionEndEvent | ToolCallsEvent | ToolResultEvent | CitationEvent | LoopIterationEvent | LoopCompleteEvent | ErrorEvent | DoneEvent;
230
+ type StreamEvent = MessageStartEvent | MessageDeltaEvent | MessageEndEvent | ThinkingStartEvent | ThinkingDeltaEvent | ThinkingEndEvent | ActionStartEvent | ActionArgsEvent | ActionEndEvent | ToolCallsEvent | ToolResultEvent | CitationEvent | LoopIterationEvent | LoopCompleteEvent | ErrorEvent | ThreadCreatedEvent | DoneEvent;
215
231
  /**
216
232
  * LLM configuration
217
233
  */
@@ -229,6 +245,8 @@ interface ToolCall {
229
245
  name: string;
230
246
  arguments: string;
231
247
  };
248
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature in extra_content.google) */
249
+ extra_content?: Record<string, unknown>;
232
250
  }
233
251
  /**
234
252
  * Message role
@@ -563,6 +581,8 @@ interface CompletionResult {
563
581
  id: string;
564
582
  name: string;
565
583
  args: Record<string, unknown>;
584
+ /** Provider-specific metadata (e.g. Gemini 3 thought_signature in extra_content.google) */
585
+ extra_content?: Record<string, unknown>;
566
586
  }>;
567
587
  /** Thinking content (if extended thinking enabled) */
568
588
  thinking?: string;
@@ -1,6 +1,6 @@
1
- import { L as LLMAdapter } from '../base-5n-UuPfS.mjs';
2
- import { F as FallbackChainConfig, c as FallbackFailure, R as RoutingStore } from '../types-BQl1suAv.mjs';
3
- export { d as FallbackInfo, b as RetryBackoff, e as RetryInfo, a as RoutingStrategy } from '../types-BQl1suAv.mjs';
1
+ import { L as LLMAdapter } from '../base-D-U61JaB.mjs';
2
+ import { F as FallbackChainConfig, c as FallbackFailure, R as RoutingStore } from '../types-D4YfrQJR.mjs';
3
+ export { d as FallbackInfo, b as RetryBackoff, e as RetryInfo, a as RoutingStrategy } from '../types-D4YfrQJR.mjs';
4
4
  import '../types-CR8mi9I0.mjs';
5
5
  import 'zod';
6
6
 
@@ -1,6 +1,6 @@
1
- import { L as LLMAdapter } from '../base-Di31iy_8.js';
2
- import { F as FallbackChainConfig, c as FallbackFailure, R as RoutingStore } from '../types-CNL8ZRne.js';
3
- export { d as FallbackInfo, b as RetryBackoff, e as RetryInfo, a as RoutingStrategy } from '../types-CNL8ZRne.js';
1
+ import { L as LLMAdapter } from '../base-iGi9Va6Z.js';
2
+ import { F as FallbackChainConfig, c as FallbackFailure, R as RoutingStore } from '../types-38yolWJn.js';
3
+ export { d as FallbackInfo, b as RetryBackoff, e as RetryInfo, a as RoutingStrategy } from '../types-38yolWJn.js';
4
4
  import '../types-CR8mi9I0.js';
5
5
  import 'zod';
6
6
 
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, d as StorageAdapter, e as StorageMessage } from './types-CR8mi9I0.mjs';
2
2
  export { A as AssistantMessage, C as CoreMessage, w as DEFAULT_CAPABILITIES, D as DoGenerateParams, f as DoGenerateResult, E as ErrorChunk, F as FilePart, s as FinishChunk, u as FinishReason, m as GenerateStep, I as ImagePart, L as LanguageModel, M as ModelCapabilities, R as ResponseOptions, v as StorageFile, o as StreamChunk, n as StreamPart, g as SystemMessage, p as TextDeltaChunk, j as TextPart, t as TokenUsage, k as ToolCall, q as ToolCallChunk, h as ToolMessage, l as ToolResult, r as ToolResultChunk, i as UserContentPart, U as UserMessage } from './types-CR8mi9I0.mjs';
3
3
  import { z } from 'zod';
4
- import { A as ActionDefinition, T as ToolDefinition, a as ToolProfile, K as KnowledgeBaseConfig, W as WebSearchConfig, L as LLMAdapter, D as DoneEventMessage, S as StreamEvent, b as ToolCallInfo, c as TokenUsageRaw, P as ProviderToolRuntimeOptions, M as Message, d as ToolResponse } from './base-5n-UuPfS.mjs';
5
- export { e as AdapterFactory, m as AnthropicProviderToolOptions, j as AnthropicToolSelectionHints, C as ChatCompletionRequest, n as Citation, f as LLMConfig, l as OpenAIProviderToolOptions, O as OpenAIToolSelectionHints, i as ToolExecution, g as ToolLocation, k as ToolNativeProviderHints, U as UnifiedToolCall, h as UnifiedToolResult } from './base-5n-UuPfS.mjs';
6
- import { A as AIProvider } from './types-VDgiUvH2.mjs';
7
- export { a as AnthropicProviderConfig, f as AnthropicTool, h as AnthropicToolResult, g as AnthropicToolUse, b as AzureProviderConfig, B as BaseProviderConfig, m as GeminiFunctionCall, l as GeminiFunctionDeclaration, n as GeminiFunctionResponse, G as GoogleProviderConfig, d as OllamaModelOptions, c as OllamaProviderConfig, O as OpenAIProviderConfig, i as OpenAITool, j as OpenAIToolCall, k as OpenAIToolResult, P as ProviderCapabilities, e as ProviderFormatter, X as XAIProviderConfig } from './types-VDgiUvH2.mjs';
4
+ import { A as ActionDefinition, T as ToolDefinition, a as ToolProfile, K as KnowledgeBaseConfig, W as WebSearchConfig, L as LLMAdapter, D as DoneEventMessage, S as StreamEvent, b as ToolCallInfo, c as TokenUsageRaw, P as ProviderToolRuntimeOptions, M as Message, d as ToolResponse } from './base-D-U61JaB.mjs';
5
+ export { e as AdapterFactory, m as AnthropicProviderToolOptions, j as AnthropicToolSelectionHints, C as ChatCompletionRequest, n as Citation, f as LLMConfig, l as OpenAIProviderToolOptions, O as OpenAIToolSelectionHints, i as ToolExecution, g as ToolLocation, k as ToolNativeProviderHints, U as UnifiedToolCall, h as UnifiedToolResult } from './base-D-U61JaB.mjs';
6
+ import { A as AIProvider } from './types-DRqxMIjF.mjs';
7
+ export { a as AnthropicProviderConfig, f as AnthropicTool, h as AnthropicToolResult, g as AnthropicToolUse, b as AzureProviderConfig, B as BaseProviderConfig, m as GeminiFunctionCall, l as GeminiFunctionDeclaration, n as GeminiFunctionResponse, G as GoogleProviderConfig, d as OllamaModelOptions, c as OllamaProviderConfig, O as OpenAIProviderConfig, i as OpenAITool, j as OpenAIToolCall, k as OpenAIToolResult, P as ProviderCapabilities, e as ProviderFormatter, X as XAIProviderConfig } from './types-DRqxMIjF.mjs';
8
8
  import * as hono from 'hono';
9
9
  import { Hono } from 'hono';
10
- export { F as FallbackChainConfig, c as FallbackFailure, d as FallbackInfo, b as RetryBackoff, e as RetryInfo, R as RoutingStore, a as RoutingStrategy } from './types-BQl1suAv.mjs';
10
+ export { F as FallbackChainConfig, c as FallbackFailure, d as FallbackInfo, b as RetryBackoff, e as RetryInfo, R as RoutingStore, a as RoutingStrategy } from './types-D4YfrQJR.mjs';
11
11
 
12
12
  /**
13
13
  * generateText - Generate text using a language model
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, d as StorageAdapter, e as StorageMessage } from './types-CR8mi9I0.js';
2
2
  export { A as AssistantMessage, C as CoreMessage, w as DEFAULT_CAPABILITIES, D as DoGenerateParams, f as DoGenerateResult, E as ErrorChunk, F as FilePart, s as FinishChunk, u as FinishReason, m as GenerateStep, I as ImagePart, L as LanguageModel, M as ModelCapabilities, R as ResponseOptions, v as StorageFile, o as StreamChunk, n as StreamPart, g as SystemMessage, p as TextDeltaChunk, j as TextPart, t as TokenUsage, k as ToolCall, q as ToolCallChunk, h as ToolMessage, l as ToolResult, r as ToolResultChunk, i as UserContentPart, U as UserMessage } from './types-CR8mi9I0.js';
3
3
  import { z } from 'zod';
4
- import { A as ActionDefinition, T as ToolDefinition, a as ToolProfile, K as KnowledgeBaseConfig, W as WebSearchConfig, L as LLMAdapter, D as DoneEventMessage, S as StreamEvent, b as ToolCallInfo, c as TokenUsageRaw, P as ProviderToolRuntimeOptions, M as Message, d as ToolResponse } from './base-Di31iy_8.js';
5
- export { e as AdapterFactory, m as AnthropicProviderToolOptions, j as AnthropicToolSelectionHints, C as ChatCompletionRequest, n as Citation, f as LLMConfig, l as OpenAIProviderToolOptions, O as OpenAIToolSelectionHints, i as ToolExecution, g as ToolLocation, k as ToolNativeProviderHints, U as UnifiedToolCall, h as UnifiedToolResult } from './base-Di31iy_8.js';
6
- import { A as AIProvider } from './types-C0vLXzuw.js';
7
- export { a as AnthropicProviderConfig, f as AnthropicTool, h as AnthropicToolResult, g as AnthropicToolUse, b as AzureProviderConfig, B as BaseProviderConfig, m as GeminiFunctionCall, l as GeminiFunctionDeclaration, n as GeminiFunctionResponse, G as GoogleProviderConfig, d as OllamaModelOptions, c as OllamaProviderConfig, O as OpenAIProviderConfig, i as OpenAITool, j as OpenAIToolCall, k as OpenAIToolResult, P as ProviderCapabilities, e as ProviderFormatter, X as XAIProviderConfig } from './types-C0vLXzuw.js';
4
+ import { A as ActionDefinition, T as ToolDefinition, a as ToolProfile, K as KnowledgeBaseConfig, W as WebSearchConfig, L as LLMAdapter, D as DoneEventMessage, S as StreamEvent, b as ToolCallInfo, c as TokenUsageRaw, P as ProviderToolRuntimeOptions, M as Message, d as ToolResponse } from './base-iGi9Va6Z.js';
5
+ export { e as AdapterFactory, m as AnthropicProviderToolOptions, j as AnthropicToolSelectionHints, C as ChatCompletionRequest, n as Citation, f as LLMConfig, l as OpenAIProviderToolOptions, O as OpenAIToolSelectionHints, i as ToolExecution, g as ToolLocation, k as ToolNativeProviderHints, U as UnifiedToolCall, h as UnifiedToolResult } from './base-iGi9Va6Z.js';
6
+ import { A as AIProvider } from './types-BctsnC3g.js';
7
+ export { a as AnthropicProviderConfig, f as AnthropicTool, h as AnthropicToolResult, g as AnthropicToolUse, b as AzureProviderConfig, B as BaseProviderConfig, m as GeminiFunctionCall, l as GeminiFunctionDeclaration, n as GeminiFunctionResponse, G as GoogleProviderConfig, d as OllamaModelOptions, c as OllamaProviderConfig, O as OpenAIProviderConfig, i as OpenAITool, j as OpenAIToolCall, k as OpenAIToolResult, P as ProviderCapabilities, e as ProviderFormatter, X as XAIProviderConfig } from './types-BctsnC3g.js';
8
8
  import * as hono from 'hono';
9
9
  import { Hono } from 'hono';
10
- export { F as FallbackChainConfig, c as FallbackFailure, d as FallbackInfo, b as RetryBackoff, e as RetryInfo, R as RoutingStore, a as RoutingStrategy } from './types-CNL8ZRne.js';
10
+ export { F as FallbackChainConfig, c as FallbackFailure, d as FallbackInfo, b as RetryBackoff, e as RetryInfo, R as RoutingStore, a as RoutingStrategy } from './types-38yolWJn.js';
11
11
 
12
12
  /**
13
13
  * generateText - Generate text using a language model