@yourgpt/llm-sdk 2.1.4-alpha.1 → 2.1.4-alpha.3

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 (57) hide show
  1. package/dist/adapters/index.d.mts +4 -2
  2. package/dist/adapters/index.d.ts +4 -2
  3. package/dist/base-5n-UuPfS.d.mts +768 -0
  4. package/dist/base-Di31iy_8.d.ts +768 -0
  5. package/dist/fallback/index.d.mts +96 -0
  6. package/dist/fallback/index.d.ts +96 -0
  7. package/dist/fallback/index.js +284 -0
  8. package/dist/fallback/index.mjs +280 -0
  9. package/dist/index.d.mts +62 -3
  10. package/dist/index.d.ts +62 -3
  11. package/dist/index.js +117 -2
  12. package/dist/index.mjs +116 -3
  13. package/dist/providers/anthropic/index.d.mts +3 -1
  14. package/dist/providers/anthropic/index.d.ts +3 -1
  15. package/dist/providers/azure/index.d.mts +3 -1
  16. package/dist/providers/azure/index.d.ts +3 -1
  17. package/dist/providers/google/index.d.mts +3 -1
  18. package/dist/providers/google/index.d.ts +3 -1
  19. package/dist/providers/ollama/index.d.mts +4 -2
  20. package/dist/providers/ollama/index.d.ts +4 -2
  21. package/dist/providers/openai/index.d.mts +3 -1
  22. package/dist/providers/openai/index.d.ts +3 -1
  23. package/dist/providers/openrouter/index.d.mts +3 -1
  24. package/dist/providers/openrouter/index.d.ts +3 -1
  25. package/dist/providers/xai/index.d.mts +3 -1
  26. package/dist/providers/xai/index.d.ts +3 -1
  27. package/dist/types-BQl1suAv.d.mts +212 -0
  28. package/dist/types-C0vLXzuw.d.ts +355 -0
  29. package/dist/types-CNL8ZRne.d.ts +212 -0
  30. package/dist/types-CR8mi9I0.d.mts +417 -0
  31. package/dist/types-CR8mi9I0.d.ts +417 -0
  32. package/dist/types-VDgiUvH2.d.mts +355 -0
  33. package/dist/yourgpt/index.d.mts +77 -0
  34. package/dist/yourgpt/index.d.ts +77 -0
  35. package/dist/yourgpt/index.js +167 -0
  36. package/dist/yourgpt/index.mjs +164 -0
  37. package/package.json +12 -1
  38. package/dist/adapters/index.js.map +0 -1
  39. package/dist/adapters/index.mjs.map +0 -1
  40. package/dist/index.js.map +0 -1
  41. package/dist/index.mjs.map +0 -1
  42. package/dist/providers/anthropic/index.js.map +0 -1
  43. package/dist/providers/anthropic/index.mjs.map +0 -1
  44. package/dist/providers/azure/index.js.map +0 -1
  45. package/dist/providers/azure/index.mjs.map +0 -1
  46. package/dist/providers/google/index.js.map +0 -1
  47. package/dist/providers/google/index.mjs.map +0 -1
  48. package/dist/providers/ollama/index.js.map +0 -1
  49. package/dist/providers/ollama/index.mjs.map +0 -1
  50. package/dist/providers/openai/index.js.map +0 -1
  51. package/dist/providers/openai/index.mjs.map +0 -1
  52. package/dist/providers/openrouter/index.js.map +0 -1
  53. package/dist/providers/openrouter/index.mjs.map +0 -1
  54. package/dist/providers/xai/index.js.map +0 -1
  55. package/dist/providers/xai/index.mjs.map +0 -1
  56. package/dist/types-COAOEe_y.d.mts +0 -1460
  57. package/dist/types-COAOEe_y.d.ts +0 -1460
@@ -0,0 +1,768 @@
1
+ import { t as TokenUsage } from './types-CR8mi9I0.mjs';
2
+
3
+ /**
4
+ * Stream event types for llm-sdk
5
+ * These types are used internally by the SDK for streaming responses
6
+ */
7
+ /**
8
+ * Stream event types
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";
11
+ /**
12
+ * Base event interface
13
+ */
14
+ interface BaseEvent {
15
+ type: StreamEventType;
16
+ }
17
+ /**
18
+ * Message started streaming
19
+ */
20
+ interface MessageStartEvent extends BaseEvent {
21
+ type: "message:start";
22
+ id: string;
23
+ }
24
+ /**
25
+ * Message content delta (incremental update)
26
+ */
27
+ interface MessageDeltaEvent extends BaseEvent {
28
+ type: "message:delta";
29
+ content: string;
30
+ }
31
+ /**
32
+ * Message finished streaming
33
+ */
34
+ interface MessageEndEvent extends BaseEvent {
35
+ type: "message:end";
36
+ }
37
+ /**
38
+ * Thinking/reasoning started (for models like Claude, DeepSeek)
39
+ */
40
+ interface ThinkingStartEvent extends BaseEvent {
41
+ type: "thinking:start";
42
+ }
43
+ /**
44
+ * Thinking content delta
45
+ */
46
+ interface ThinkingDeltaEvent extends BaseEvent {
47
+ type: "thinking:delta";
48
+ content: string;
49
+ }
50
+ /**
51
+ * Thinking finished
52
+ */
53
+ interface ThinkingEndEvent extends BaseEvent {
54
+ type: "thinking:end";
55
+ }
56
+ /**
57
+ * Action/tool execution started
58
+ */
59
+ interface ActionStartEvent extends BaseEvent {
60
+ type: "action:start";
61
+ id: string;
62
+ name: string;
63
+ /** Whether this tool should be hidden from UI */
64
+ hidden?: boolean;
65
+ }
66
+ /**
67
+ * Action arguments (streaming)
68
+ */
69
+ interface ActionArgsEvent extends BaseEvent {
70
+ type: "action:args";
71
+ id: string;
72
+ args: string;
73
+ }
74
+ /**
75
+ * Action execution completed
76
+ */
77
+ interface ActionEndEvent extends BaseEvent {
78
+ type: "action:end";
79
+ id: string;
80
+ name?: string;
81
+ result?: unknown;
82
+ error?: string;
83
+ }
84
+ /**
85
+ * Error event
86
+ */
87
+ interface ErrorEvent extends BaseEvent {
88
+ type: "error";
89
+ message: string;
90
+ code?: string;
91
+ }
92
+ /**
93
+ * Tool call information
94
+ */
95
+ interface ToolCallInfo {
96
+ id: string;
97
+ name: string;
98
+ args: Record<string, unknown>;
99
+ /** Whether this tool should be hidden from UI */
100
+ hidden?: boolean;
101
+ }
102
+ /**
103
+ * Assistant message with tool calls
104
+ */
105
+ interface AssistantToolMessage {
106
+ role: "assistant";
107
+ content: string | null;
108
+ tool_calls: Array<{
109
+ id: string;
110
+ type: "function";
111
+ function: {
112
+ name: string;
113
+ arguments: string;
114
+ };
115
+ }>;
116
+ }
117
+ /**
118
+ * Tool calls event - client should execute and send results
119
+ */
120
+ interface ToolCallsEvent extends BaseEvent {
121
+ type: "tool_calls";
122
+ toolCalls: ToolCallInfo[];
123
+ assistantMessage: AssistantToolMessage;
124
+ }
125
+ /**
126
+ * Tool result event
127
+ */
128
+ interface ToolResultEvent extends BaseEvent {
129
+ type: "tool:result";
130
+ id: string;
131
+ name: string;
132
+ result: ToolResponse;
133
+ }
134
+ /**
135
+ * Loop iteration event
136
+ */
137
+ interface LoopIterationEvent extends BaseEvent {
138
+ type: "loop:iteration";
139
+ iteration: number;
140
+ maxIterations: number;
141
+ }
142
+ /**
143
+ * Loop complete event
144
+ */
145
+ interface LoopCompleteEvent extends BaseEvent {
146
+ type: "loop:complete";
147
+ iterations: number;
148
+ aborted?: boolean;
149
+ maxIterationsReached?: boolean;
150
+ }
151
+ /**
152
+ * Citation from web search (unified format for all providers)
153
+ */
154
+ interface Citation {
155
+ /** Unique citation index (1-based) */
156
+ index: number;
157
+ /** Source URL */
158
+ url: string;
159
+ /** Page title */
160
+ title: string;
161
+ /** Cited text snippet (optional) */
162
+ citedText?: string;
163
+ /** Source domain (extracted from URL) */
164
+ domain?: string;
165
+ /** Favicon URL (generated from domain) */
166
+ favicon?: string;
167
+ }
168
+ /**
169
+ * Citation event - web search returned citations
170
+ */
171
+ interface CitationEvent extends BaseEvent {
172
+ type: "citation";
173
+ citations: Citation[];
174
+ }
175
+ /**
176
+ * Message format for done event (API format with snake_case)
177
+ */
178
+ interface DoneEventMessage {
179
+ role: "assistant" | "tool";
180
+ content: string | null;
181
+ tool_calls?: Array<{
182
+ id: string;
183
+ type: "function";
184
+ function: {
185
+ name: string;
186
+ arguments: string;
187
+ };
188
+ }>;
189
+ tool_call_id?: string;
190
+ }
191
+ /**
192
+ * Token usage (snake_case for API compatibility)
193
+ */
194
+ interface TokenUsageRaw {
195
+ prompt_tokens: number;
196
+ completion_tokens: number;
197
+ total_tokens?: number;
198
+ }
199
+ /**
200
+ * Stream completed
201
+ */
202
+ interface DoneEvent extends BaseEvent {
203
+ type: "done";
204
+ requiresAction?: boolean;
205
+ messages?: DoneEventMessage[];
206
+ /** Token usage (server-side only, stripped before sending to client) */
207
+ usage?: TokenUsageRaw;
208
+ /** Session ID — present when storage adapter created a session for this request */
209
+ threadId?: string;
210
+ }
211
+ /**
212
+ * Union of all stream events
213
+ */
214
+ type StreamEvent = MessageStartEvent | MessageDeltaEvent | MessageEndEvent | ThinkingStartEvent | ThinkingDeltaEvent | ThinkingEndEvent | ActionStartEvent | ActionArgsEvent | ActionEndEvent | ToolCallsEvent | ToolResultEvent | CitationEvent | LoopIterationEvent | LoopCompleteEvent | ErrorEvent | DoneEvent;
215
+ /**
216
+ * LLM configuration
217
+ */
218
+ interface LLMConfig {
219
+ temperature?: number;
220
+ maxTokens?: number;
221
+ }
222
+ /**
223
+ * Tool call format (OpenAI style)
224
+ */
225
+ interface ToolCall {
226
+ id: string;
227
+ type: "function";
228
+ function: {
229
+ name: string;
230
+ arguments: string;
231
+ };
232
+ }
233
+ /**
234
+ * Message role
235
+ */
236
+ type MessageRole = "system" | "user" | "assistant" | "tool";
237
+ /**
238
+ * Message attachment
239
+ */
240
+ interface MessageAttachment {
241
+ type: "image" | "file" | "audio" | "video";
242
+ data?: string;
243
+ url?: string;
244
+ mimeType: string;
245
+ filename?: string;
246
+ }
247
+ /**
248
+ * Message metadata
249
+ */
250
+ interface MessageMetadata {
251
+ thinking?: string;
252
+ attachments?: MessageAttachment[];
253
+ toolName?: string;
254
+ [key: string]: unknown;
255
+ }
256
+ /**
257
+ * Message type (simplified for llm-sdk)
258
+ */
259
+ interface Message {
260
+ id: string;
261
+ thread_id?: string;
262
+ role: MessageRole;
263
+ content: string | null;
264
+ tool_calls?: ToolCall[];
265
+ tool_call_id?: string;
266
+ metadata?: MessageMetadata;
267
+ created_at?: Date;
268
+ }
269
+ /**
270
+ * Action parameter definition
271
+ */
272
+ interface ActionParameter {
273
+ type: string;
274
+ description?: string;
275
+ required?: boolean;
276
+ enum?: string[];
277
+ items?: ActionParameter;
278
+ properties?: Record<string, ActionParameter>;
279
+ }
280
+ /**
281
+ * Action definition for tool calling
282
+ */
283
+ interface ActionDefinition<TParams = Record<string, unknown>> {
284
+ name: string;
285
+ description: string;
286
+ parameters?: Record<string, ActionParameter>;
287
+ handler: (params: TParams) => unknown | Promise<unknown>;
288
+ }
289
+ /**
290
+ * Tool location (server or client)
291
+ */
292
+ type ToolLocation = "server" | "client";
293
+ /**
294
+ * Tool execution status
295
+ */
296
+ type ToolExecutionStatus = "pending" | "executing" | "completed" | "error";
297
+ /**
298
+ * Tool response
299
+ */
300
+ interface ToolResponse<T = unknown> {
301
+ success: boolean;
302
+ data?: T;
303
+ error?: string;
304
+ /** Internal: AI response mode override */
305
+ _aiResponseMode?: AIResponseMode;
306
+ /** Internal: AI content for multimodal response (images, etc.) */
307
+ _aiContent?: AIContent[];
308
+ /** Internal: AI context string override */
309
+ _aiContext?: string;
310
+ }
311
+ /**
312
+ * Tool context passed to handlers
313
+ */
314
+ interface ToolContext {
315
+ userId?: string;
316
+ threadId?: string;
317
+ [key: string]: unknown;
318
+ }
319
+ /**
320
+ * AI response mode for tool results
321
+ */
322
+ type AIResponseMode = "none" | "brief" | "full";
323
+ /**
324
+ * AI content structure
325
+ */
326
+ interface AIContent {
327
+ type?: "text" | "image";
328
+ text?: string;
329
+ mediaType?: string;
330
+ data?: string;
331
+ summary?: string;
332
+ details?: string;
333
+ }
334
+ /**
335
+ * JSON Schema for tool input
336
+ */
337
+ interface ToolInputSchema {
338
+ type: "object";
339
+ properties?: Record<string, unknown>;
340
+ required?: string[];
341
+ }
342
+ /**
343
+ * Tool definition
344
+ */
345
+ interface ToolDefinition<TParams = Record<string, unknown>> {
346
+ name: string;
347
+ description: string;
348
+ location: ToolLocation;
349
+ /** Optional logical category for tool search and selective loading. */
350
+ category?: string;
351
+ /** Optional group label for related tools. */
352
+ group?: string;
353
+ title?: string | ((args: TParams) => string);
354
+ inputSchema?: ToolInputSchema;
355
+ handler?: (params: TParams, context?: ToolContext) => unknown | Promise<unknown>;
356
+ render?: (props: unknown) => unknown;
357
+ available?: boolean;
358
+ /**
359
+ * Hide this tool's execution from the chat UI.
360
+ * When true, tool calls and results won't be displayed to the user,
361
+ * but the tool will still execute normally.
362
+ * @default false
363
+ */
364
+ hidden?: boolean;
365
+ needsApproval?: boolean;
366
+ approvalMessage?: string | ((params: TParams) => string);
367
+ /** AI response mode for this tool (none, brief, full) */
368
+ aiResponseMode?: AIResponseMode;
369
+ /** AI context string or function to generate context */
370
+ aiContext?: string | ((result: ToolResponse, args: Record<string, unknown>) => string);
371
+ /** Hint that this tool should be loaded lazily when dynamic selection is active. */
372
+ deferLoading?: boolean;
373
+ /** Named profiles this tool belongs to (for example "coding" or "search"). */
374
+ profiles?: string[];
375
+ /** Extra keywords used by lightweight tool search/ranking. */
376
+ searchKeywords?: string[];
377
+ }
378
+ interface ToolProfile {
379
+ include?: string[];
380
+ exclude?: string[];
381
+ }
382
+ interface OpenAIToolSelectionHints {
383
+ /**
384
+ * "single" forces the selected tool when exactly one tool remains after selection.
385
+ * Otherwise the adapter falls back to automatic tool choice.
386
+ */
387
+ toolChoice?: "auto" | "required" | "single";
388
+ /** Set false to disable parallel tool calls on OpenAI-compatible providers. */
389
+ parallelToolCalls?: boolean;
390
+ }
391
+ interface AnthropicToolSelectionHints {
392
+ /**
393
+ * "single" forces the selected tool when exactly one tool remains after selection.
394
+ * Otherwise the adapter falls back to Anthropic's automatic tool choice.
395
+ */
396
+ toolChoice?: "auto" | "any" | "single";
397
+ /** Disable parallel tool use when supported by the Anthropic API. */
398
+ disableParallelToolUse?: boolean;
399
+ }
400
+ interface ToolNativeProviderHints {
401
+ openai?: OpenAIToolSelectionHints;
402
+ anthropic?: AnthropicToolSelectionHints;
403
+ }
404
+ interface OpenAIProviderToolOptions {
405
+ toolChoice?: "auto" | "required" | {
406
+ type: "function";
407
+ name: string;
408
+ };
409
+ parallelToolCalls?: boolean;
410
+ nativeToolSearch?: {
411
+ enabled: boolean;
412
+ useResponsesApi?: boolean;
413
+ };
414
+ }
415
+ interface AnthropicProviderToolOptions {
416
+ toolChoice?: "auto" | "any" | {
417
+ type: "tool";
418
+ name: string;
419
+ };
420
+ disableParallelToolUse?: boolean;
421
+ nativeToolSearch?: {
422
+ enabled: boolean;
423
+ variant: "bm25" | "regex";
424
+ };
425
+ }
426
+ interface ProviderToolRuntimeOptions {
427
+ openai?: OpenAIProviderToolOptions;
428
+ anthropic?: AnthropicProviderToolOptions;
429
+ }
430
+ /**
431
+ * Web search configuration for native provider search
432
+ *
433
+ * Enables native web search for supported providers:
434
+ * - Anthropic: Uses Claude's built-in web search tool
435
+ * - OpenAI: Uses GPT's web search preview
436
+ * - Google: Uses Gemini's Google Search grounding
437
+ *
438
+ * @example
439
+ * ```typescript
440
+ * const runtime = createRuntime({
441
+ * provider: createAnthropic({ apiKey: '...' }),
442
+ * model: 'claude-sonnet-4-20250514',
443
+ * webSearch: true, // Enable with defaults
444
+ * });
445
+ *
446
+ * // Or with configuration
447
+ * const runtime = createRuntime({
448
+ * provider: createOpenAI({ apiKey: '...' }),
449
+ * model: 'gpt-4o',
450
+ * webSearch: {
451
+ * maxUses: 5,
452
+ * allowedDomains: ['docs.anthropic.com', 'openai.com'],
453
+ * },
454
+ * });
455
+ * ```
456
+ */
457
+ interface WebSearchConfig {
458
+ /** Maximum number of search uses per request (default: unlimited) */
459
+ maxUses?: number;
460
+ /** Only search these domains (provider-specific support) */
461
+ allowedDomains?: string[];
462
+ /** Exclude these domains from search (provider-specific support) */
463
+ blockedDomains?: string[];
464
+ /** User location for localized results (Anthropic only) */
465
+ userLocation?: {
466
+ type: "approximate";
467
+ city?: string;
468
+ region?: string;
469
+ country?: string;
470
+ timezone?: string;
471
+ };
472
+ }
473
+ /**
474
+ * Unified tool call format
475
+ */
476
+ interface UnifiedToolCall {
477
+ id: string;
478
+ name: string;
479
+ input: Record<string, unknown>;
480
+ }
481
+ /**
482
+ * Unified tool result format
483
+ */
484
+ interface UnifiedToolResult {
485
+ toolCallId: string;
486
+ content: string;
487
+ success: boolean;
488
+ error?: string;
489
+ }
490
+ /**
491
+ * Tool execution state
492
+ */
493
+ interface ToolExecution {
494
+ id: string;
495
+ name: string;
496
+ args: Record<string, unknown>;
497
+ status: ToolExecutionStatus;
498
+ result?: ToolResponse;
499
+ }
500
+ /**
501
+ * Knowledge base provider
502
+ */
503
+ type KnowledgeBaseProvider = "pinecone" | "qdrant" | "weaviate" | "custom";
504
+ /**
505
+ * Knowledge base configuration
506
+ */
507
+ interface KnowledgeBaseConfig {
508
+ id: string;
509
+ name?: string;
510
+ provider: KnowledgeBaseProvider;
511
+ apiKey?: string;
512
+ index?: string;
513
+ }
514
+
515
+ /**
516
+ * Request-level LLM configuration overrides
517
+ */
518
+ interface RequestLLMConfig {
519
+ model?: string;
520
+ temperature?: number;
521
+ maxTokens?: number;
522
+ }
523
+ /**
524
+ * Chat completion request
525
+ */
526
+ interface ChatCompletionRequest {
527
+ /** Conversation messages */
528
+ messages: Message[];
529
+ /**
530
+ * Raw provider-formatted messages (for agent loop with tool calls)
531
+ * When provided, these are used instead of converting from Message[]
532
+ * This allows passing messages with tool_calls and tool role
533
+ */
534
+ rawMessages?: Array<Record<string, unknown>>;
535
+ /** Available actions/tools */
536
+ actions?: ActionDefinition[];
537
+ /** Full tool definitions for provider-native tool search / deferred loading paths. */
538
+ toolDefinitions?: ToolDefinition[];
539
+ /** System prompt */
540
+ systemPrompt?: string;
541
+ /** LLM configuration overrides */
542
+ config?: RequestLLMConfig;
543
+ /** Abort signal for cancellation */
544
+ signal?: AbortSignal;
545
+ /**
546
+ * Enable native web search for the provider.
547
+ * When true or configured, the provider's native search is enabled.
548
+ */
549
+ webSearch?: boolean | WebSearchConfig;
550
+ /** Optional provider-specific tool policy hints derived from runtime selection. */
551
+ providerToolOptions?: ProviderToolRuntimeOptions;
552
+ /** Enable adapter-level provider payload logging. */
553
+ debug?: boolean;
554
+ }
555
+ /**
556
+ * Non-streaming completion result
557
+ */
558
+ interface CompletionResult {
559
+ /** Text content */
560
+ content: string;
561
+ /** Tool calls */
562
+ toolCalls: Array<{
563
+ id: string;
564
+ name: string;
565
+ args: Record<string, unknown>;
566
+ }>;
567
+ /** Thinking content (if extended thinking enabled) */
568
+ thinking?: string;
569
+ /** Token usage for billing/tracking */
570
+ usage?: TokenUsage;
571
+ /** Raw provider response for debugging */
572
+ rawResponse: Record<string, unknown>;
573
+ }
574
+ /**
575
+ * Base LLM adapter interface
576
+ */
577
+ interface LLMAdapter {
578
+ /** Provider name */
579
+ readonly provider: string;
580
+ /** Model name */
581
+ readonly model: string;
582
+ /**
583
+ * Stream a chat completion
584
+ */
585
+ stream(request: ChatCompletionRequest): AsyncGenerator<StreamEvent>;
586
+ /**
587
+ * Non-streaming chat completion (for debugging/comparison)
588
+ */
589
+ complete?(request: ChatCompletionRequest): Promise<CompletionResult>;
590
+ }
591
+ /**
592
+ * Adapter factory function type
593
+ */
594
+ type AdapterFactory = (config: LLMConfig) => LLMAdapter;
595
+ /**
596
+ * Convert messages to provider format (simple text only)
597
+ */
598
+ declare function formatMessages(messages: Message[], systemPrompt?: string): Array<{
599
+ role: string;
600
+ content: string;
601
+ }>;
602
+ /**
603
+ * Convert actions to OpenAI tool format
604
+ */
605
+ declare function formatTools(actions: ActionDefinition[]): Array<{
606
+ type: "function";
607
+ function: {
608
+ name: string;
609
+ description: string;
610
+ parameters: object;
611
+ };
612
+ }>;
613
+ /**
614
+ * Content block types for multimodal messages
615
+ */
616
+ type AnthropicContentBlock = {
617
+ type: "text";
618
+ text: string;
619
+ } | {
620
+ type: "image";
621
+ source: {
622
+ type: "base64";
623
+ media_type: string;
624
+ data: string;
625
+ } | {
626
+ type: "url";
627
+ url: string;
628
+ };
629
+ } | {
630
+ type: "document";
631
+ source: {
632
+ type: "base64";
633
+ media_type: string;
634
+ data: string;
635
+ } | {
636
+ type: "url";
637
+ url: string;
638
+ };
639
+ };
640
+ type OpenAIContentBlock = {
641
+ type: "text";
642
+ text: string;
643
+ } | {
644
+ type: "image_url";
645
+ image_url: {
646
+ url: string;
647
+ detail?: "low" | "high" | "auto";
648
+ };
649
+ };
650
+ /**
651
+ * Check if a message has image attachments
652
+ * Supports both new format (metadata.attachments) and legacy (attachments)
653
+ */
654
+ declare function hasImageAttachments(message: Message): boolean;
655
+ /**
656
+ * Check if a message has media attachments (images or PDFs)
657
+ */
658
+ declare function hasMediaAttachments(message: Message): boolean;
659
+ /**
660
+ * Convert MessageAttachment to Anthropic image content block
661
+ *
662
+ * Anthropic format:
663
+ * {
664
+ * type: "image",
665
+ * source: {
666
+ * type: "base64",
667
+ * media_type: "image/png",
668
+ * data: "base64data..."
669
+ * }
670
+ * }
671
+ */
672
+ declare function attachmentToAnthropicImage(attachment: MessageAttachment): AnthropicContentBlock | null;
673
+ /**
674
+ * Convert MessageAttachment to OpenAI image_url content block
675
+ *
676
+ * OpenAI format:
677
+ * {
678
+ * type: "image_url",
679
+ * image_url: {
680
+ * url: "data:image/png;base64,..."
681
+ * }
682
+ * }
683
+ */
684
+ declare function attachmentToOpenAIImage(attachment: MessageAttachment): OpenAIContentBlock | null;
685
+ /**
686
+ * Convert MessageAttachment (PDF) to Anthropic document content block
687
+ *
688
+ * Anthropic format:
689
+ * {
690
+ * type: "document",
691
+ * source: {
692
+ * type: "base64",
693
+ * media_type: "application/pdf",
694
+ * data: "base64data..."
695
+ * }
696
+ * }
697
+ */
698
+ declare function attachmentToAnthropicDocument(attachment: MessageAttachment): AnthropicContentBlock | null;
699
+ /**
700
+ * Convert a Message to Anthropic multimodal content blocks
701
+ */
702
+ declare function messageToAnthropicContent(message: Message): string | AnthropicContentBlock[];
703
+ /**
704
+ * Convert a Message to OpenAI multimodal content blocks
705
+ */
706
+ declare function messageToOpenAIContent(message: Message): string | OpenAIContentBlock[];
707
+ /**
708
+ * Anthropic content block types (extended for tools)
709
+ */
710
+ type AnthropicToolUseBlock = {
711
+ type: "tool_use";
712
+ id: string;
713
+ name: string;
714
+ input: Record<string, unknown>;
715
+ };
716
+ type AnthropicToolResultBlock = {
717
+ type: "tool_result";
718
+ tool_use_id: string;
719
+ content: string;
720
+ };
721
+ type AnthropicMessageContent = string | Array<AnthropicContentBlock | AnthropicToolUseBlock | AnthropicToolResultBlock>;
722
+ /**
723
+ * Format messages for Anthropic with full tool support
724
+ * Handles: text, images, tool_use, and tool_result
725
+ *
726
+ * Key differences from OpenAI:
727
+ * - tool_calls become tool_use blocks in assistant content
728
+ * - tool results become tool_result blocks in user content
729
+ */
730
+ declare function formatMessagesForAnthropic(messages: Message[], systemPrompt?: string): {
731
+ system: string;
732
+ messages: Array<{
733
+ role: "user" | "assistant";
734
+ content: AnthropicMessageContent;
735
+ }>;
736
+ };
737
+ /**
738
+ * OpenAI message format with tool support
739
+ */
740
+ type OpenAIMessage = {
741
+ role: "system";
742
+ content: string;
743
+ } | {
744
+ role: "user";
745
+ content: string | OpenAIContentBlock[];
746
+ } | {
747
+ role: "assistant";
748
+ content: string | null;
749
+ tool_calls?: Array<{
750
+ id: string;
751
+ type: "function";
752
+ function: {
753
+ name: string;
754
+ arguments: string;
755
+ };
756
+ }>;
757
+ } | {
758
+ role: "tool";
759
+ content: string;
760
+ tool_call_id: string;
761
+ };
762
+ /**
763
+ * Format messages for OpenAI with full tool support
764
+ * Handles: text, images, tool_calls, and tool results
765
+ */
766
+ declare function formatMessagesForOpenAI(messages: Message[], systemPrompt?: string): OpenAIMessage[];
767
+
768
+ export { type ActionDefinition as A, type AnthropicContentBlock as B, type ChatCompletionRequest as C, type DoneEventMessage as D, type OpenAIContentBlock as E, type KnowledgeBaseConfig as K, type LLMAdapter as L, type Message as M, type OpenAIToolSelectionHints as O, type ProviderToolRuntimeOptions as P, type StreamEvent as S, type ToolDefinition as T, type UnifiedToolCall as U, type WebSearchConfig as W, type ToolProfile as a, type ToolCallInfo as b, type TokenUsageRaw as c, type ToolResponse as d, type AdapterFactory as e, type LLMConfig as f, type ToolLocation as g, type UnifiedToolResult as h, type ToolExecution as i, type AnthropicToolSelectionHints as j, type ToolNativeProviderHints as k, type OpenAIProviderToolOptions as l, type AnthropicProviderToolOptions as m, type Citation as n, type CompletionResult as o, formatMessages as p, formatTools as q, formatMessagesForAnthropic as r, formatMessagesForOpenAI as s, messageToAnthropicContent as t, messageToOpenAIContent as u, hasImageAttachments as v, hasMediaAttachments as w, attachmentToAnthropicImage as x, attachmentToAnthropicDocument as y, attachmentToOpenAIImage as z };