@yourgpt/llm-sdk 2.0.1 → 2.0.2-beta.2

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 (55) hide show
  1. package/dist/adapters/index.d.mts +27 -4
  2. package/dist/adapters/index.d.ts +27 -4
  3. package/dist/adapters/index.js +395 -25
  4. package/dist/adapters/index.js.map +1 -1
  5. package/dist/adapters/index.mjs +395 -25
  6. package/dist/adapters/index.mjs.map +1 -1
  7. package/dist/index.d.mts +24 -5
  8. package/dist/index.d.ts +24 -5
  9. package/dist/index.js +20 -4
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +20 -4
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/providers/anthropic/index.d.mts +1 -2
  14. package/dist/providers/anthropic/index.d.ts +1 -2
  15. package/dist/providers/anthropic/index.js +108 -12
  16. package/dist/providers/anthropic/index.js.map +1 -1
  17. package/dist/providers/anthropic/index.mjs +108 -12
  18. package/dist/providers/anthropic/index.mjs.map +1 -1
  19. package/dist/providers/azure/index.d.mts +1 -2
  20. package/dist/providers/azure/index.d.ts +1 -2
  21. package/dist/providers/azure/index.js.map +1 -1
  22. package/dist/providers/azure/index.mjs.map +1 -1
  23. package/dist/providers/google/index.d.mts +1 -2
  24. package/dist/providers/google/index.d.ts +1 -2
  25. package/dist/providers/google/index.js +61 -2
  26. package/dist/providers/google/index.js.map +1 -1
  27. package/dist/providers/google/index.mjs +61 -2
  28. package/dist/providers/google/index.mjs.map +1 -1
  29. package/dist/providers/ollama/index.d.mts +8 -3
  30. package/dist/providers/ollama/index.d.ts +8 -3
  31. package/dist/providers/ollama/index.js +227 -17
  32. package/dist/providers/ollama/index.js.map +1 -1
  33. package/dist/providers/ollama/index.mjs +227 -17
  34. package/dist/providers/ollama/index.mjs.map +1 -1
  35. package/dist/providers/openai/index.d.mts +1 -2
  36. package/dist/providers/openai/index.d.ts +1 -2
  37. package/dist/providers/openai/index.js +57 -3
  38. package/dist/providers/openai/index.js.map +1 -1
  39. package/dist/providers/openai/index.mjs +57 -3
  40. package/dist/providers/openai/index.mjs.map +1 -1
  41. package/dist/providers/openrouter/index.d.mts +56 -3
  42. package/dist/providers/openrouter/index.d.ts +56 -3
  43. package/dist/providers/openrouter/index.js +90 -276
  44. package/dist/providers/openrouter/index.js.map +1 -1
  45. package/dist/providers/openrouter/index.mjs +89 -277
  46. package/dist/providers/openrouter/index.mjs.map +1 -1
  47. package/dist/providers/xai/index.d.mts +1 -2
  48. package/dist/providers/xai/index.d.ts +1 -2
  49. package/dist/providers/xai/index.js.map +1 -1
  50. package/dist/providers/xai/index.mjs.map +1 -1
  51. package/dist/{base-DdxolpKP.d.mts → types-C_f95PKp.d.mts} +434 -3
  52. package/dist/{base-DdxolpKP.d.ts → types-C_f95PKp.d.ts} +434 -3
  53. package/package.json +1 -1
  54. package/dist/types-Ck25ZYma.d.mts +0 -323
  55. package/dist/types-Dsz8SpdB.d.ts +0 -323
package/dist/index.d.mts CHANGED
@@ -1,8 +1,6 @@
1
- import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as ActionDefinition, d as ToolDefinition, e as AgentLoopConfig, K as KnowledgeBaseConfig, L as LLMAdapter, D as DoneEventMessage, f as StreamEvent, g as ToolCallInfo, h as TokenUsageRaw, M as Message, i as ToolResponse } from './base-DdxolpKP.mjs';
2
- export { P as AdapterFactory, o as AssistantMessage, O as ChatCompletionRequest, C as CoreMessage, N as DEFAULT_CAPABILITIES, l as DoGenerateParams, m as DoGenerateResult, E as ErrorChunk, F as FilePart, B as FinishChunk, J as FinishReason, u as GenerateStep, I as ImagePart, Q as LLMConfig, j as LanguageModel, k as ModelCapabilities, R as ResponseOptions, w as StreamChunk, v as StreamPart, n as SystemMessage, x as TextDeltaChunk, r as TextPart, H as TokenUsage, s as ToolCall, y as ToolCallChunk, Y as ToolExecution, V as ToolLocation, p as ToolMessage, t as ToolResult, z as ToolResultChunk, W as UnifiedToolCall, X as UnifiedToolResult, q as UserContentPart, U as UserMessage } from './base-DdxolpKP.mjs';
1
+ import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as AIProvider, d as ActionDefinition, e as ToolDefinition, f as AgentLoopConfig, K as KnowledgeBaseConfig, W as WebSearchConfig, L as LLMAdapter, D as DoneEventMessage, g as StreamEvent, h as ToolCallInfo, i as TokenUsageRaw, M as Message, j as ToolResponse } from './types-C_f95PKp.mjs';
2
+ export { Q as AdapterFactory, Z as AnthropicProviderConfig, a4 as AnthropicTool, a6 as AnthropicToolResult, a5 as AnthropicToolUse, p as AssistantMessage, a0 as AzureProviderConfig, X as BaseProviderConfig, P as ChatCompletionRequest, ai as Citation, C as CoreMessage, O as DEFAULT_CAPABILITIES, m as DoGenerateParams, n as DoGenerateResult, H as ErrorChunk, F as FilePart, E as FinishChunk, N as FinishReason, ab as GeminiFunctionCall, aa as GeminiFunctionDeclaration, ac as GeminiFunctionResponse, v as GenerateStep, _ as GoogleProviderConfig, I as ImagePart, ad as LLMConfig, k as LanguageModel, l as ModelCapabilities, a2 as OllamaModelOptions, a1 as OllamaProviderConfig, Y as OpenAIProviderConfig, a7 as OpenAITool, a8 as OpenAIToolCall, a9 as OpenAIToolResult, V as ProviderCapabilities, a3 as ProviderFormatter, R as ResponseOptions, x as StreamChunk, w as StreamPart, o as SystemMessage, y as TextDeltaChunk, s as TextPart, J as TokenUsage, t as ToolCall, z as ToolCallChunk, ah as ToolExecution, ae as ToolLocation, q as ToolMessage, u as ToolResult, B as ToolResultChunk, af as UnifiedToolCall, ag as UnifiedToolResult, r as UserContentPart, U as UserMessage, $ as XAIProviderConfig } from './types-C_f95PKp.mjs';
3
3
  import { z } from 'zod';
4
- import { A as AIProvider } from './types-Ck25ZYma.mjs';
5
- export { a as AnthropicProviderConfig, e as AnthropicTool, g as AnthropicToolResult, f as AnthropicToolUse, b as AzureProviderConfig, B as BaseProviderConfig, l as GeminiFunctionCall, k as GeminiFunctionDeclaration, m as GeminiFunctionResponse, G as GoogleProviderConfig, c as OllamaProviderConfig, O as OpenAIProviderConfig, h as OpenAITool, i as OpenAIToolCall, j as OpenAIToolResult, P as ProviderCapabilities, d as ProviderFormatter, X as XAIProviderConfig } from './types-Ck25ZYma.mjs';
6
4
  import * as hono from 'hono';
7
5
  import { Hono } from 'hono';
8
6
 
@@ -108,6 +106,13 @@ interface ToolConfig<TParams extends z.ZodType, TResult = unknown> {
108
106
  parameters: TParams;
109
107
  /** Function to execute when the tool is called */
110
108
  execute: (params: z.infer<TParams>, context: ToolContext) => Promise<TResult>;
109
+ /**
110
+ * Hide this tool's execution from the chat UI.
111
+ * When true, tool calls and results won't be displayed to the user,
112
+ * but the tool will still execute normally.
113
+ * @default false
114
+ */
115
+ hidden?: boolean;
111
116
  }
112
117
  /**
113
118
  * Create a type-safe tool definition
@@ -186,6 +191,11 @@ interface RuntimeConfigWithAdapter {
186
191
  debug?: boolean;
187
192
  /** Custom context data passed to all tool handlers */
188
193
  toolContext?: Record<string, unknown>;
194
+ /**
195
+ * Enable native web search for the provider.
196
+ * Set to true for defaults, or pass WebSearchConfig for customization.
197
+ */
198
+ webSearch?: boolean | WebSearchConfig;
189
199
  }
190
200
  /**
191
201
  * Runtime configuration with AIProvider
@@ -220,6 +230,11 @@ interface RuntimeConfigWithProvider {
220
230
  debug?: boolean;
221
231
  /** Custom context data passed to all tool handlers */
222
232
  toolContext?: Record<string, unknown>;
233
+ /**
234
+ * Enable native web search for the provider.
235
+ * Set to true for defaults, or pass WebSearchConfig for customization.
236
+ */
237
+ webSearch?: boolean | WebSearchConfig;
223
238
  }
224
239
  /**
225
240
  * Runtime configuration - provide either a provider instance or a custom adapter
@@ -848,6 +863,10 @@ declare class Runtime {
848
863
  * Get the current model ID
849
864
  */
850
865
  getModel(): string;
866
+ /**
867
+ * Get web search configuration from runtime config
868
+ */
869
+ private getWebSearchConfig;
851
870
  /**
852
871
  * Process a chat request with tool support (Vercel AI SDK pattern)
853
872
  *
@@ -1305,4 +1324,4 @@ declare function generateThreadId(): string;
1305
1324
  */
1306
1325
  declare function generateToolCallId(): string;
1307
1326
 
1308
- export { AIProvider, ActionDefinition, type ActionRequest, AgentLoopConfig, type AgentLoopOptions, type ChatRequest, type CollectedResult, type CopilotChatResponse, DEFAULT_MAX_ITERATIONS, DoneEventMessage, GenerateResult, type GenerateResultData, GenerateTextParams, GenerateTextResult, LLMAdapter, Message, type RequestContext, Runtime, type RuntimeConfig, StreamEvent, StreamResult, type StreamResultOptions, StreamTextParams, StreamTextResult, TokenUsageRaw, Tool, ToolCallInfo, ToolContext, ToolDefinition, ToolResponse, createEventStream, createExpressHandler, createExpressMiddleware, createHonoApp, createNextHandler, createNodeHandler, createRuntime, createSSEHeaders, createSSEResponse, createStreamResult, createTextStreamHeaders, createTextStreamResponse, formatSSEData, formatToolsForAnthropic, formatToolsForGoogle, formatToolsForOpenAI, generateMessageId, generateText, generateThreadId, generateToolCallId, pipeSSEToResponse, pipeTextToResponse, runAgentLoop, streamText, tool };
1327
+ export { AIProvider, ActionDefinition, type ActionRequest, AgentLoopConfig, type AgentLoopOptions, type ChatRequest, type CollectedResult, type CopilotChatResponse, DEFAULT_MAX_ITERATIONS, DoneEventMessage, GenerateResult, type GenerateResultData, GenerateTextParams, GenerateTextResult, LLMAdapter, Message, type RequestContext, Runtime, type RuntimeConfig, StreamEvent, StreamResult, type StreamResultOptions, StreamTextParams, StreamTextResult, TokenUsageRaw, Tool, ToolCallInfo, ToolContext, ToolDefinition, ToolResponse, WebSearchConfig, createEventStream, createExpressHandler, createExpressMiddleware, createHonoApp, createNextHandler, createNodeHandler, createRuntime, createSSEHeaders, createSSEResponse, createStreamResult, createTextStreamHeaders, createTextStreamResponse, formatSSEData, formatToolsForAnthropic, formatToolsForGoogle, formatToolsForOpenAI, generateMessageId, generateText, generateThreadId, generateToolCallId, pipeSSEToResponse, pipeTextToResponse, runAgentLoop, streamText, tool };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as ActionDefinition, d as ToolDefinition, e as AgentLoopConfig, K as KnowledgeBaseConfig, L as LLMAdapter, D as DoneEventMessage, f as StreamEvent, g as ToolCallInfo, h as TokenUsageRaw, M as Message, i as ToolResponse } from './base-DdxolpKP.js';
2
- export { P as AdapterFactory, o as AssistantMessage, O as ChatCompletionRequest, C as CoreMessage, N as DEFAULT_CAPABILITIES, l as DoGenerateParams, m as DoGenerateResult, E as ErrorChunk, F as FilePart, B as FinishChunk, J as FinishReason, u as GenerateStep, I as ImagePart, Q as LLMConfig, j as LanguageModel, k as ModelCapabilities, R as ResponseOptions, w as StreamChunk, v as StreamPart, n as SystemMessage, x as TextDeltaChunk, r as TextPart, H as TokenUsage, s as ToolCall, y as ToolCallChunk, Y as ToolExecution, V as ToolLocation, p as ToolMessage, t as ToolResult, z as ToolResultChunk, W as UnifiedToolCall, X as UnifiedToolResult, q as UserContentPart, U as UserMessage } from './base-DdxolpKP.js';
1
+ import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as AIProvider, d as ActionDefinition, e as ToolDefinition, f as AgentLoopConfig, K as KnowledgeBaseConfig, W as WebSearchConfig, L as LLMAdapter, D as DoneEventMessage, g as StreamEvent, h as ToolCallInfo, i as TokenUsageRaw, M as Message, j as ToolResponse } from './types-C_f95PKp.js';
2
+ export { Q as AdapterFactory, Z as AnthropicProviderConfig, a4 as AnthropicTool, a6 as AnthropicToolResult, a5 as AnthropicToolUse, p as AssistantMessage, a0 as AzureProviderConfig, X as BaseProviderConfig, P as ChatCompletionRequest, ai as Citation, C as CoreMessage, O as DEFAULT_CAPABILITIES, m as DoGenerateParams, n as DoGenerateResult, H as ErrorChunk, F as FilePart, E as FinishChunk, N as FinishReason, ab as GeminiFunctionCall, aa as GeminiFunctionDeclaration, ac as GeminiFunctionResponse, v as GenerateStep, _ as GoogleProviderConfig, I as ImagePart, ad as LLMConfig, k as LanguageModel, l as ModelCapabilities, a2 as OllamaModelOptions, a1 as OllamaProviderConfig, Y as OpenAIProviderConfig, a7 as OpenAITool, a8 as OpenAIToolCall, a9 as OpenAIToolResult, V as ProviderCapabilities, a3 as ProviderFormatter, R as ResponseOptions, x as StreamChunk, w as StreamPart, o as SystemMessage, y as TextDeltaChunk, s as TextPart, J as TokenUsage, t as ToolCall, z as ToolCallChunk, ah as ToolExecution, ae as ToolLocation, q as ToolMessage, u as ToolResult, B as ToolResultChunk, af as UnifiedToolCall, ag as UnifiedToolResult, r as UserContentPart, U as UserMessage, $ as XAIProviderConfig } from './types-C_f95PKp.js';
3
3
  import { z } from 'zod';
4
- import { A as AIProvider } from './types-Dsz8SpdB.js';
5
- export { a as AnthropicProviderConfig, e as AnthropicTool, g as AnthropicToolResult, f as AnthropicToolUse, b as AzureProviderConfig, B as BaseProviderConfig, l as GeminiFunctionCall, k as GeminiFunctionDeclaration, m as GeminiFunctionResponse, G as GoogleProviderConfig, c as OllamaProviderConfig, O as OpenAIProviderConfig, h as OpenAITool, i as OpenAIToolCall, j as OpenAIToolResult, P as ProviderCapabilities, d as ProviderFormatter, X as XAIProviderConfig } from './types-Dsz8SpdB.js';
6
4
  import * as hono from 'hono';
7
5
  import { Hono } from 'hono';
8
6
 
@@ -108,6 +106,13 @@ interface ToolConfig<TParams extends z.ZodType, TResult = unknown> {
108
106
  parameters: TParams;
109
107
  /** Function to execute when the tool is called */
110
108
  execute: (params: z.infer<TParams>, context: ToolContext) => Promise<TResult>;
109
+ /**
110
+ * Hide this tool's execution from the chat UI.
111
+ * When true, tool calls and results won't be displayed to the user,
112
+ * but the tool will still execute normally.
113
+ * @default false
114
+ */
115
+ hidden?: boolean;
111
116
  }
112
117
  /**
113
118
  * Create a type-safe tool definition
@@ -186,6 +191,11 @@ interface RuntimeConfigWithAdapter {
186
191
  debug?: boolean;
187
192
  /** Custom context data passed to all tool handlers */
188
193
  toolContext?: Record<string, unknown>;
194
+ /**
195
+ * Enable native web search for the provider.
196
+ * Set to true for defaults, or pass WebSearchConfig for customization.
197
+ */
198
+ webSearch?: boolean | WebSearchConfig;
189
199
  }
190
200
  /**
191
201
  * Runtime configuration with AIProvider
@@ -220,6 +230,11 @@ interface RuntimeConfigWithProvider {
220
230
  debug?: boolean;
221
231
  /** Custom context data passed to all tool handlers */
222
232
  toolContext?: Record<string, unknown>;
233
+ /**
234
+ * Enable native web search for the provider.
235
+ * Set to true for defaults, or pass WebSearchConfig for customization.
236
+ */
237
+ webSearch?: boolean | WebSearchConfig;
223
238
  }
224
239
  /**
225
240
  * Runtime configuration - provide either a provider instance or a custom adapter
@@ -848,6 +863,10 @@ declare class Runtime {
848
863
  * Get the current model ID
849
864
  */
850
865
  getModel(): string;
866
+ /**
867
+ * Get web search configuration from runtime config
868
+ */
869
+ private getWebSearchConfig;
851
870
  /**
852
871
  * Process a chat request with tool support (Vercel AI SDK pattern)
853
872
  *
@@ -1305,4 +1324,4 @@ declare function generateThreadId(): string;
1305
1324
  */
1306
1325
  declare function generateToolCallId(): string;
1307
1326
 
1308
- export { AIProvider, ActionDefinition, type ActionRequest, AgentLoopConfig, type AgentLoopOptions, type ChatRequest, type CollectedResult, type CopilotChatResponse, DEFAULT_MAX_ITERATIONS, DoneEventMessage, GenerateResult, type GenerateResultData, GenerateTextParams, GenerateTextResult, LLMAdapter, Message, type RequestContext, Runtime, type RuntimeConfig, StreamEvent, StreamResult, type StreamResultOptions, StreamTextParams, StreamTextResult, TokenUsageRaw, Tool, ToolCallInfo, ToolContext, ToolDefinition, ToolResponse, createEventStream, createExpressHandler, createExpressMiddleware, createHonoApp, createNextHandler, createNodeHandler, createRuntime, createSSEHeaders, createSSEResponse, createStreamResult, createTextStreamHeaders, createTextStreamResponse, formatSSEData, formatToolsForAnthropic, formatToolsForGoogle, formatToolsForOpenAI, generateMessageId, generateText, generateThreadId, generateToolCallId, pipeSSEToResponse, pipeTextToResponse, runAgentLoop, streamText, tool };
1327
+ export { AIProvider, ActionDefinition, type ActionRequest, AgentLoopConfig, type AgentLoopOptions, type ChatRequest, type CollectedResult, type CopilotChatResponse, DEFAULT_MAX_ITERATIONS, DoneEventMessage, GenerateResult, type GenerateResultData, GenerateTextParams, GenerateTextResult, LLMAdapter, Message, type RequestContext, Runtime, type RuntimeConfig, StreamEvent, StreamResult, type StreamResultOptions, StreamTextParams, StreamTextResult, TokenUsageRaw, Tool, ToolCallInfo, ToolContext, ToolDefinition, ToolResponse, WebSearchConfig, createEventStream, createExpressHandler, createExpressMiddleware, createHonoApp, createNextHandler, createNodeHandler, createRuntime, createSSEHeaders, createSSEResponse, createStreamResult, createTextStreamHeaders, createTextStreamResponse, formatSSEData, formatToolsForAnthropic, formatToolsForGoogle, formatToolsForOpenAI, generateMessageId, generateText, generateThreadId, generateToolCallId, pipeSSEToResponse, pipeTextToResponse, runAgentLoop, streamText, tool };
package/dist/index.js CHANGED
@@ -8,7 +8,8 @@ function tool(config) {
8
8
  return {
9
9
  description: config.description,
10
10
  parameters: config.parameters,
11
- execute: config.execute
11
+ execute: config.execute,
12
+ hidden: config.hidden
12
13
  };
13
14
  }
14
15
  function toolToJsonSchema(toolDef) {
@@ -1252,7 +1253,8 @@ var Runtime = class {
1252
1253
  actions: allActions.length > 0 ? allActions : void 0,
1253
1254
  systemPrompt: request.systemPrompt || this.config.systemPrompt,
1254
1255
  config: request.config,
1255
- signal
1256
+ signal,
1257
+ webSearch: this.getWebSearchConfig()
1256
1258
  };
1257
1259
  const stream = this.adapter.stream(completionRequest);
1258
1260
  for await (const event of stream) {
@@ -1560,6 +1562,15 @@ var Runtime = class {
1560
1562
  }
1561
1563
  return this.adapter.model;
1562
1564
  }
1565
+ /**
1566
+ * Get web search configuration from runtime config
1567
+ */
1568
+ getWebSearchConfig() {
1569
+ if ("webSearch" in this.config) {
1570
+ return this.config.webSearch;
1571
+ }
1572
+ return void 0;
1573
+ }
1563
1574
  /**
1564
1575
  * Process a chat request with tool support (Vercel AI SDK pattern)
1565
1576
  *
@@ -1632,7 +1643,8 @@ var Runtime = class {
1632
1643
  actions: this.convertToolsToActions(allTools),
1633
1644
  systemPrompt,
1634
1645
  config: request.config,
1635
- signal
1646
+ signal,
1647
+ webSearch: this.getWebSearchConfig()
1636
1648
  };
1637
1649
  const stream = this.adapter.stream(completionRequest);
1638
1650
  for await (const event of stream) {
@@ -1683,6 +1695,9 @@ var Runtime = class {
1683
1695
  }
1684
1696
  yield event;
1685
1697
  break;
1698
+ case "citation":
1699
+ yield event;
1700
+ break;
1686
1701
  case "error":
1687
1702
  yield event;
1688
1703
  return;
@@ -1923,7 +1938,8 @@ var Runtime = class {
1923
1938
  actions: this.convertToolsToActions(allTools),
1924
1939
  systemPrompt,
1925
1940
  config: request.config,
1926
- signal
1941
+ signal,
1942
+ webSearch: this.getWebSearchConfig()
1927
1943
  };
1928
1944
  try {
1929
1945
  const result = await this.adapter.complete(completionRequest);