ai.matey.frontend 0.2.0 → 0.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 (44) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/cjs/adapters/anthropic.js +156 -16
  3. package/dist/cjs/adapters/anthropic.js.map +1 -1
  4. package/dist/cjs/adapters/chrome-ai.js +58 -0
  5. package/dist/cjs/adapters/chrome-ai.js.map +1 -1
  6. package/dist/cjs/adapters/gemini.js +57 -0
  7. package/dist/cjs/adapters/gemini.js.map +1 -1
  8. package/dist/cjs/adapters/generic.js +56 -4
  9. package/dist/cjs/adapters/generic.js.map +1 -1
  10. package/dist/cjs/adapters/mistral.js +59 -0
  11. package/dist/cjs/adapters/mistral.js.map +1 -1
  12. package/dist/cjs/adapters/ollama.js +59 -0
  13. package/dist/cjs/adapters/ollama.js.map +1 -1
  14. package/dist/cjs/adapters/openai.js +199 -32
  15. package/dist/cjs/adapters/openai.js.map +1 -1
  16. package/dist/esm/adapters/anthropic.js +156 -16
  17. package/dist/esm/adapters/anthropic.js.map +1 -1
  18. package/dist/esm/adapters/chrome-ai.js +58 -0
  19. package/dist/esm/adapters/chrome-ai.js.map +1 -1
  20. package/dist/esm/adapters/gemini.js +57 -0
  21. package/dist/esm/adapters/gemini.js.map +1 -1
  22. package/dist/esm/adapters/generic.js +56 -4
  23. package/dist/esm/adapters/generic.js.map +1 -1
  24. package/dist/esm/adapters/mistral.js +59 -0
  25. package/dist/esm/adapters/mistral.js.map +1 -1
  26. package/dist/esm/adapters/ollama.js +59 -0
  27. package/dist/esm/adapters/ollama.js.map +1 -1
  28. package/dist/esm/adapters/openai.js +199 -32
  29. package/dist/esm/adapters/openai.js.map +1 -1
  30. package/dist/types/adapters/anthropic.d.ts +254 -8
  31. package/dist/types/adapters/anthropic.d.ts.map +1 -1
  32. package/dist/types/adapters/chrome-ai.d.ts +95 -0
  33. package/dist/types/adapters/chrome-ai.d.ts.map +1 -1
  34. package/dist/types/adapters/gemini.d.ts +170 -0
  35. package/dist/types/adapters/gemini.d.ts.map +1 -1
  36. package/dist/types/adapters/generic.d.ts +56 -4
  37. package/dist/types/adapters/generic.d.ts.map +1 -1
  38. package/dist/types/adapters/mistral.d.ts +143 -0
  39. package/dist/types/adapters/mistral.d.ts.map +1 -1
  40. package/dist/types/adapters/ollama.d.ts +132 -0
  41. package/dist/types/adapters/ollama.d.ts.map +1 -1
  42. package/dist/types/adapters/openai.d.ts +252 -8
  43. package/dist/types/adapters/openai.d.ts.map +1 -1
  44. package/package.json +2 -3
@@ -10,7 +10,50 @@ import type { FrontendAdapter, AdapterMetadata } from 'ai.matey.types';
10
10
  import type { IRChatRequest, IRChatResponse, IRChatStream } from 'ai.matey.types';
11
11
  import type { StreamConversionOptions } from 'ai.matey.types';
12
12
  /**
13
- * Anthropic message content block.
13
+ * Anthropic content block type supporting text, images, and tool usage.
14
+ *
15
+ * Claude uses a structured content block format where each piece of content
16
+ * is represented as an object with a discriminated `type` field. This enables
17
+ * multimodal messages mixing text, images, and tool interactions.
18
+ *
19
+ * @see AnthropicMessage
20
+ * @see https://docs.anthropic.com/en/api/messages
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // Text block
25
+ * const text: AnthropicContentBlock = {
26
+ * type: 'text',
27
+ * text: 'Hello, Claude!'
28
+ * };
29
+ *
30
+ * // Image from URL
31
+ * const imageUrl: AnthropicContentBlock = {
32
+ * type: 'image',
33
+ * source: {
34
+ * type: 'url',
35
+ * url: 'https://example.com/photo.jpg'
36
+ * }
37
+ * };
38
+ *
39
+ * // Base64 image
40
+ * const imageB64: AnthropicContentBlock = {
41
+ * type: 'image',
42
+ * source: {
43
+ * type: 'base64',
44
+ * media_type: 'image/jpeg',
45
+ * data: '/9j/4AAQSkZJRg...'
46
+ * }
47
+ * };
48
+ *
49
+ * // Tool use request
50
+ * const toolUse: AnthropicContentBlock = {
51
+ * type: 'tool_use',
52
+ * id: 'toolu_123',
53
+ * name: 'get_weather',
54
+ * input: { location: 'San Francisco' }
55
+ * };
56
+ * ```
14
57
  */
15
58
  export type AnthropicContentBlock = {
16
59
  type: 'text';
@@ -30,49 +73,191 @@ export type AnthropicContentBlock = {
30
73
  id: string;
31
74
  name: string;
32
75
  input: Record<string, unknown>;
76
+ } | {
77
+ type: 'tool_result';
78
+ tool_use_id: string;
79
+ content: string | {
80
+ type: 'text';
81
+ text: string;
82
+ }[];
83
+ is_error?: boolean;
33
84
  };
34
85
  /**
35
- * Anthropic message.
86
+ * Anthropic message structure in a conversation.
87
+ *
88
+ * Claude messages support only 'user' and 'assistant' roles. System messages
89
+ * are handled separately via the `system` parameter at the request level.
90
+ * Content can be a simple string or an array of structured blocks.
91
+ *
92
+ * @see AnthropicContentBlock
93
+ * @see AnthropicRequest
36
94
  */
37
95
  export interface AnthropicMessage {
96
+ /** Message role - only 'user' or 'assistant' (system is separate) */
38
97
  role: 'user' | 'assistant';
98
+ /** Message content - simple string or array of content blocks for multimodal */
39
99
  content: string | AnthropicContentBlock[];
40
100
  }
41
101
  /**
42
- * Anthropic Messages API request.
102
+ * Anthropic Messages API request structure.
103
+ *
104
+ * Defines all parameters for making a request to Claude via Anthropic's Messages API.
105
+ * Key differences from OpenAI: system message is a separate parameter (not in messages),
106
+ * max_tokens is required, and supports top_k sampling parameter.
107
+ *
108
+ * @see AnthropicMessage
109
+ * @see AnthropicResponse
110
+ * @see https://docs.anthropic.com/en/api/messages
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const request: AnthropicRequest = {
115
+ * model: 'claude-3-5-sonnet-20241022',
116
+ * max_tokens: 1024,
117
+ * messages: [
118
+ * { role: 'user', content: 'Hello, Claude!' }
119
+ * ],
120
+ * system: 'You are a helpful assistant.',
121
+ * temperature: 0.7
122
+ * };
123
+ * ```
43
124
  */
44
125
  export interface AnthropicRequest {
126
+ /** Model ID (e.g., 'claude-3-5-sonnet-20241022', 'claude-3-opus-20240229') */
45
127
  model: string;
128
+ /** Array of conversation messages (user and assistant only) */
46
129
  messages: AnthropicMessage[];
130
+ /** System prompt/instructions (separate from messages array) */
47
131
  system?: string;
132
+ /** Maximum tokens to generate - REQUIRED by Anthropic API */
48
133
  max_tokens: number;
134
+ /** Sampling temperature 0-1. Higher = more random. Default 1 */
49
135
  temperature?: number;
136
+ /** Nucleus sampling parameter 0-1. Alternative to temperature */
50
137
  top_p?: number;
138
+ /** Top-K sampling parameter. Only sample from top K tokens */
51
139
  top_k?: number;
140
+ /** Stop sequences - generation stops when encountered */
52
141
  stop_sequences?: string[];
142
+ /** Enable streaming responses via Server-Sent Events */
53
143
  stream?: boolean;
144
+ /** Optional metadata for tracking and abuse prevention */
54
145
  metadata?: {
146
+ /** User identifier for abuse monitoring */
55
147
  user_id?: string;
56
148
  };
149
+ /** Tools Claude may use */
150
+ tools?: Array<{
151
+ name: string;
152
+ description?: string;
153
+ input_schema: Record<string, unknown>;
154
+ }>;
155
+ /** Controls how Claude uses tools */
156
+ tool_choice?: {
157
+ type: 'auto';
158
+ } | {
159
+ type: 'any';
160
+ } | {
161
+ type: 'none';
162
+ } | {
163
+ type: 'tool';
164
+ name: string;
165
+ };
57
166
  }
58
167
  /**
59
- * Anthropic Messages API response.
168
+ * Anthropic Messages API response structure.
169
+ *
170
+ * Contains the complete response from Claude including the generated content,
171
+ * stop reason, and token usage. Content is always returned as an array of
172
+ * structured blocks, even for simple text responses.
173
+ *
174
+ * @see AnthropicRequest
175
+ * @see AnthropicContentBlock
176
+ * @see https://docs.anthropic.com/en/api/messages
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * const response: AnthropicResponse = {
181
+ * id: 'msg_123',
182
+ * type: 'message',
183
+ * role: 'assistant',
184
+ * content: [
185
+ * { type: 'text', text: 'Hello! How can I help you today?' }
186
+ * ],
187
+ * model: 'claude-3-5-sonnet-20241022',
188
+ * stop_reason: 'end_turn',
189
+ * usage: {
190
+ * input_tokens: 12,
191
+ * output_tokens: 8
192
+ * }
193
+ * };
194
+ * ```
60
195
  */
61
196
  export interface AnthropicResponse {
197
+ /** Unique identifier for this message */
62
198
  id: string;
199
+ /** Object type - always 'message' for Messages API */
63
200
  type: 'message';
201
+ /** Role of the responder - always 'assistant' */
64
202
  role: 'assistant';
203
+ /** Array of content blocks (even for simple text responses) */
65
204
  content: AnthropicContentBlock[];
205
+ /** Model that generated the response */
66
206
  model: string;
207
+ /** Reason generation stopped: 'end_turn' (natural), 'max_tokens', 'stop_sequence', 'tool_use', or null */
67
208
  stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | null;
209
+ /** The actual stop sequence matched (if stop_reason is 'stop_sequence') */
68
210
  stop_sequence?: string | null;
211
+ /** Token usage statistics */
69
212
  usage: {
213
+ /** Number of tokens in the input/prompt */
70
214
  input_tokens: number;
215
+ /** Number of tokens in the output/completion */
71
216
  output_tokens: number;
72
217
  };
73
218
  }
74
219
  /**
75
- * Anthropic SSE stream event.
220
+ * Anthropic streaming event types via Server-Sent Events.
221
+ *
222
+ * Claude uses a more complex streaming protocol than OpenAI, with distinct
223
+ * events for different stages: message start, content block start/delta/stop,
224
+ * and message completion. This enables fine-grained control over streaming
225
+ * display and supports tool use streaming.
226
+ *
227
+ * Event flow:
228
+ * 1. `message_start` - Stream begins with metadata
229
+ * 2. `content_block_start` - Each content block (text/tool) starts
230
+ * 3. `content_block_delta` - Incremental content for the block
231
+ * 4. `content_block_stop` - Block is complete
232
+ * 5. `message_delta` - Final metadata (stop reason, usage)
233
+ * 6. `message_stop` - Stream ends
234
+ *
235
+ * @see AnthropicRequest
236
+ * @see AnthropicResponse
237
+ * @see https://docs.anthropic.com/en/api/messages-streaming
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * // Message start event
242
+ * const start: AnthropicStreamEvent = {
243
+ * type: 'message_start',
244
+ * message: { id: 'msg_123', model: 'claude-3-5-sonnet-20241022' }
245
+ * };
246
+ *
247
+ * // Text delta event
248
+ * const delta: AnthropicStreamEvent = {
249
+ * type: 'content_block_delta',
250
+ * index: 0,
251
+ * delta: { type: 'text_delta', text: 'Hello' }
252
+ * };
253
+ *
254
+ * // Completion event
255
+ * const done: AnthropicStreamEvent = {
256
+ * type: 'message_delta',
257
+ * delta: { stop_reason: 'end_turn' },
258
+ * usage: { output_tokens: 42 }
259
+ * };
260
+ * ```
76
261
  */
77
262
  export type AnthropicStreamEvent = {
78
263
  type: 'message_start';
@@ -118,17 +303,78 @@ export type AnthropicStreamEvent = {
118
303
  export declare class AnthropicFrontendAdapter implements FrontendAdapter<AnthropicRequest, AnthropicResponse, AnthropicStreamEvent> {
119
304
  readonly metadata: AdapterMetadata;
120
305
  /**
121
- * Convert Anthropic request to Universal IR.
306
+ * Convert Anthropic Messages API request to Universal IR format.
307
+ *
308
+ * This method transforms an Anthropic-formatted request into the standardized
309
+ * Intermediate Representation (IR) format. It handles Anthropic's unique system
310
+ * message format (separate from messages array) by converting it to IR's
311
+ * in-messages format, and maps Anthropic-specific parameters like top_k.
312
+ *
313
+ * @param request - Anthropic Messages API request
314
+ * @returns Promise resolving to IR chat request
315
+ * @throws {AdapterConversionError} If conversion fails
316
+ *
317
+ * @example
318
+ * ```typescript
319
+ * const adapter = new AnthropicFrontendAdapter();
320
+ * const irRequest = await adapter.toIR({
321
+ * model: 'claude-3-5-sonnet-20241022',
322
+ * max_tokens: 1024,
323
+ * messages: [{ role: 'user', content: 'Hello!' }],
324
+ * system: 'You are a helpful assistant'
325
+ * });
326
+ * ```
122
327
  */
123
328
  toIR(request: AnthropicRequest): Promise<IRChatRequest>;
124
329
  /**
125
- * Convert Universal IR response to Anthropic format.
330
+ * Convert Universal IR response back to Anthropic Messages API format.
331
+ *
332
+ * This method transforms the standardized IR response into the format
333
+ * expected by Anthropic's Messages API. It handles message conversion,
334
+ * stop reason mapping, and usage statistics formatting specific to
335
+ * Anthropic's response structure.
336
+ *
337
+ * @param response - Universal IR chat response
338
+ * @returns Promise resolving to Anthropic Messages API response
339
+ * @throws {AdapterConversionError} If conversion fails
340
+ *
341
+ * @example
342
+ * ```typescript
343
+ * const adapter = new AnthropicFrontendAdapter();
344
+ * const anthropicResponse = await adapter.fromIR(irResponse);
345
+ * console.log(anthropicResponse.content[0].text);
346
+ * ```
126
347
  */
127
348
  fromIR(response: IRChatResponse): Promise<AnthropicResponse>;
128
349
  /**
129
- * Convert Universal IR stream to Anthropic SSE format.
350
+ * Convert Universal IR stream to Anthropic Server-Sent Events (SSE) format.
351
+ *
352
+ * This async generator method transforms a stream of IR chunks into
353
+ * Anthropic-formatted streaming events. It handles stream mode conversion,
354
+ * tracks message metadata, and emits properly formatted SSE events
355
+ * compatible with Anthropic's streaming API including message_start,
356
+ * content_block_delta, and message_stop events.
357
+ *
358
+ * @param stream - Universal IR chat stream
359
+ * @param options - Optional stream conversion options (stream mode, etc.)
360
+ * @yields Anthropic-formatted streaming events
361
+ * @throws {AdapterConversionError} If stream conversion fails
362
+ *
363
+ * @example
364
+ * ```typescript
365
+ * const adapter = new AnthropicFrontendAdapter();
366
+ * for await (const event of adapter.fromIRStream(irStream)) {
367
+ * if (event.type === 'content_block_delta') {
368
+ * console.log(event.delta.text);
369
+ * }
370
+ * }
371
+ * ```
130
372
  */
131
373
  fromIRStream(stream: IRChatStream, options?: StreamConversionOptions): AsyncGenerator<AnthropicStreamEvent, void, undefined>;
374
+ /**
375
+ * Convert Anthropic tool_choice to IR toolChoice.
376
+ */
377
+ private convertToolChoiceToIR;
132
378
  /**
133
379
  * Convert Anthropic message to IR message.
134
380
  */
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/adapters/anthropic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,YAAY,EAGb,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAQ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YAAY,CACjB,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,uBAAuB,GAChC,cAAc,CAAC,oBAAoB,EAAE,IAAI,EAAE,SAAS,CAAC;IAqIxD;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAkB7B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAwD/B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAuD5B;;OAEG;IACH,OAAO,CAAC,eAAe;CAcxB"}
@@ -8,18 +8,113 @@
8
8
  import type { FrontendAdapter, AdapterMetadata } from 'ai.matey.types';
9
9
  import type { IRChatRequest, IRChatResponse, IRStreamChunk } from 'ai.matey.types';
10
10
  import type { StreamConversionOptions } from 'ai.matey.types';
11
+ /**
12
+ * Chrome AI request structure for browser-based AI.
13
+ *
14
+ * Chrome's built-in AI uses a simple prompt-based format without message arrays.
15
+ * Only available in Chrome 129+ with AI features enabled.
16
+ *
17
+ * @see ChromeAIResponse
18
+ * @see https://developer.chrome.com/docs/ai/built-in
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const request: ChromeAIRequest = {
23
+ * prompt: 'Explain quantum computing',
24
+ * temperature: 0.7,
25
+ * topK: 40
26
+ * };
27
+ * ```
28
+ */
11
29
  export interface ChromeAIRequest {
30
+ /** Text prompt (no message array format) */
12
31
  prompt: string;
32
+ /** Sampling temperature parameter */
13
33
  temperature?: number;
34
+ /** Top-K sampling parameter */
14
35
  topK?: number;
15
36
  }
37
+ /**
38
+ * Chrome AI response structure.
39
+ *
40
+ * Simple text-only response from Chrome's built-in AI. No usage statistics
41
+ * or additional metadata since it runs locally in the browser.
42
+ *
43
+ * @see ChromeAIRequest
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const response: ChromeAIResponse = {
48
+ * text: 'Quantum computing uses quantum mechanics...'
49
+ * };
50
+ * ```
51
+ */
16
52
  export interface ChromeAIResponse {
53
+ /** Generated text response */
17
54
  text: string;
18
55
  }
19
56
  export declare class ChromeAIFrontendAdapter implements FrontendAdapter<ChromeAIRequest, ChromeAIResponse> {
20
57
  readonly metadata: AdapterMetadata;
58
+ /**
59
+ * Convert Chrome AI request to Universal IR format.
60
+ *
61
+ * This method transforms a Chrome AI-formatted request into the standardized
62
+ * Intermediate Representation (IR) format. Chrome AI uses a simple prompt-based
63
+ * format, so this converts the single prompt string into a user message within
64
+ * the IR message array structure.
65
+ *
66
+ * @param request - Chrome AI request with prompt and optional parameters
67
+ * @returns Promise resolving to IR chat request
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const adapter = new ChromeAIFrontendAdapter();
72
+ * const irRequest = await adapter.toIR({
73
+ * prompt: 'What is the capital of France?',
74
+ * temperature: 0.7,
75
+ * topK: 40
76
+ * });
77
+ * ```
78
+ */
21
79
  toIR(request: ChromeAIRequest): Promise<IRChatRequest>;
80
+ /**
81
+ * Convert Universal IR response back to Chrome AI format.
82
+ *
83
+ * This method transforms the standardized IR response into the format
84
+ * expected by Chrome AI's interface. It extracts the text content from
85
+ * the IR message and returns it in Chrome AI's simple `{ text }` format.
86
+ *
87
+ * @param response - Universal IR chat response
88
+ * @returns Promise resolving to Chrome AI response
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const adapter = new ChromeAIFrontendAdapter();
93
+ * const chromeResponse = await adapter.fromIR(irResponse);
94
+ * console.log(chromeResponse.text);
95
+ * ```
96
+ */
22
97
  fromIR(response: IRChatResponse): Promise<ChromeAIResponse>;
98
+ /**
99
+ * Convert Universal IR stream to Chrome AI streaming format.
100
+ *
101
+ * This async generator method transforms a stream of IR chunks into
102
+ * Chrome AI's simple text streaming format. It yields raw text strings
103
+ * (no JSON wrapping, no SSE format) and supports stream mode conversion
104
+ * through options (delta, full, or text-only modes).
105
+ *
106
+ * @param stream - Universal IR chat stream
107
+ * @param options - Optional stream conversion options (stream mode, etc.)
108
+ * @yields Raw text strings
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const adapter = new ChromeAIFrontendAdapter();
113
+ * for await (const textChunk of adapter.fromIRStream(irStream)) {
114
+ * console.log(textChunk); // Raw text like "Hello" or " world"
115
+ * }
116
+ * ```
117
+ */
23
118
  fromIRStream(stream: AsyncGenerator<IRStreamChunk>, options?: StreamConversionOptions): AsyncGenerator<string>;
24
119
  }
25
120
  //# sourceMappingURL=chrome-ai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chrome-ai.d.ts","sourceRoot":"","sources":["../../../src/adapters/chrome-ai.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAG9D,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,uBAAwB,YAAW,eAAe,CAAC,eAAe,EAAE,gBAAgB,CAAC;IAChG,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAWhC;IAEF,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAetD,MAAM,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAMpD,YAAY,CACjB,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,EACrC,OAAO,CAAC,EAAE,uBAAuB,GAChC,cAAc,CAAC,MAAM,CAAC;CAU1B"}
1
+ {"version":3,"file":"chrome-ai.d.ts","sourceRoot":"","sources":["../../../src/adapters/chrome-ai.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAG9D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IAEf,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,uBAAwB,YAAW,eAAe,CAAC,eAAe,EAAE,gBAAgB,CAAC;IAChG,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAWhC;IAEF;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAetD;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAM3D;;;;;;;;;;;;;;;;;;;OAmBG;IACI,YAAY,CACjB,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,EACrC,OAAO,CAAC,EAAE,uBAAuB,GAChC,cAAc,CAAC,MAAM,CAAC;CAU1B"}
@@ -9,8 +9,43 @@
9
9
  import type { FrontendAdapter, AdapterMetadata } from 'ai.matey.types';
10
10
  import type { IRChatRequest, IRChatResponse, IRStreamChunk } from 'ai.matey.types';
11
11
  import type { StreamConversionOptions } from 'ai.matey.types';
12
+ /**
13
+ * Gemini content structure for messages.
14
+ *
15
+ * Google Gemini uses a unique `parts` array format where each message contains
16
+ * an array of content parts. Each part can be text or inline data (images).
17
+ * Role is either 'user' or 'model' (Gemini calls the assistant 'model').
18
+ *
19
+ * @see GeminiRequest
20
+ * @see https://ai.google.dev/api/rest/v1/Content
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // Text-only message
25
+ * const textContent: GeminiContent = {
26
+ * role: 'user',
27
+ * parts: [{ text: 'Hello, Gemini!' }]
28
+ * };
29
+ *
30
+ * // Multimodal message with image
31
+ * const multimodalContent: GeminiContent = {
32
+ * role: 'user',
33
+ * parts: [
34
+ * { text: 'What is in this image?' },
35
+ * {
36
+ * inlineData: {
37
+ * mimeType: 'image/jpeg',
38
+ * data: 'base64-encoded-image-data...'
39
+ * }
40
+ * }
41
+ * ]
42
+ * };
43
+ * ```
44
+ */
12
45
  export interface GeminiContent {
46
+ /** Message role - 'user' or 'model' (Gemini's term for assistant) */
13
47
  role: 'user' | 'model';
48
+ /** Array of content parts - can mix text and inline data (images) */
14
49
  parts: Array<{
15
50
  text: string;
16
51
  } | {
@@ -20,36 +55,171 @@ export interface GeminiContent {
20
55
  };
21
56
  }>;
22
57
  }
58
+ /**
59
+ * Google Gemini API request structure.
60
+ *
61
+ * Defines parameters for making a request to Google's Gemini API. Key differences
62
+ * from other providers: uses `contents` (plural) for messages, `systemInstruction`
63
+ * for system prompts, and generation parameters in a nested `generationConfig` object.
64
+ * Temperature range is 0-1 (not 0-2 like some other providers).
65
+ *
66
+ * @see GeminiContent
67
+ * @see GeminiResponse
68
+ * @see https://ai.google.dev/api/rest/v1/models/generateContent
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const request: GeminiRequest = {
73
+ * contents: [
74
+ * {
75
+ * role: 'user',
76
+ * parts: [{ text: 'Explain quantum computing' }]
77
+ * }
78
+ * ],
79
+ * systemInstruction: {
80
+ * parts: [{ text: 'You are a helpful physics teacher.' }]
81
+ * },
82
+ * generationConfig: {
83
+ * temperature: 0.7,
84
+ * maxOutputTokens: 1024
85
+ * }
86
+ * };
87
+ * ```
88
+ */
23
89
  export interface GeminiRequest {
90
+ /** Array of conversation contents (user and model messages) */
24
91
  contents: GeminiContent[];
92
+ /** System instruction/prompt (separate from contents) */
25
93
  systemInstruction?: {
26
94
  parts: Array<{
27
95
  text: string;
28
96
  }>;
29
97
  };
98
+ /** Generation parameters nested in config object */
30
99
  generationConfig?: {
100
+ /** Sampling temperature 0-1 (Gemini uses 0-1, not 0-2) */
31
101
  temperature?: number;
102
+ /** Nucleus sampling parameter 0-1 */
32
103
  topP?: number;
104
+ /** Top-K sampling parameter */
33
105
  topK?: number;
106
+ /** Maximum tokens to generate */
34
107
  maxOutputTokens?: number;
108
+ /** Stop sequences - generation stops when encountered */
35
109
  stopSequences?: string[];
36
110
  };
37
111
  }
112
+ /**
113
+ * Google Gemini API response structure.
114
+ *
115
+ * Contains the response from Gemini including generated content, finish reason,
116
+ * and token usage. Gemini can return multiple candidates (alternative completions)
117
+ * though typically only one is returned. Finish reasons include safety-related
118
+ * stops unique to Gemini.
119
+ *
120
+ * @see GeminiRequest
121
+ * @see GeminiContent
122
+ * @see https://ai.google.dev/api/rest/v1/GenerateContentResponse
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * const response: GeminiResponse = {
127
+ * candidates: [
128
+ * {
129
+ * content: {
130
+ * role: 'model',
131
+ * parts: [{ text: 'Quantum computing uses quantum mechanics...' }]
132
+ * },
133
+ * finishReason: 'STOP'
134
+ * }
135
+ * ],
136
+ * usageMetadata: {
137
+ * promptTokenCount: 15,
138
+ * candidatesTokenCount: 120,
139
+ * totalTokenCount: 135
140
+ * }
141
+ * };
142
+ * ```
143
+ */
38
144
  export interface GeminiResponse {
145
+ /** Array of candidate responses (usually just one) */
39
146
  candidates: Array<{
147
+ /** Generated content from the model */
40
148
  content: GeminiContent;
149
+ /** Reason generation stopped: 'STOP' (natural), 'MAX_TOKENS', 'SAFETY', 'RECITATION', 'OTHER' */
41
150
  finishReason: 'STOP' | 'MAX_TOKENS' | 'SAFETY' | 'RECITATION' | 'OTHER';
42
151
  }>;
152
+ /** Token usage statistics */
43
153
  usageMetadata?: {
154
+ /** Number of tokens in the prompt */
44
155
  promptTokenCount: number;
156
+ /** Number of tokens in all candidates */
45
157
  candidatesTokenCount: number;
158
+ /** Total tokens used (prompt + candidates) */
46
159
  totalTokenCount: number;
47
160
  };
48
161
  }
49
162
  export declare class GeminiFrontendAdapter implements FrontendAdapter<GeminiRequest, GeminiResponse> {
50
163
  readonly metadata: AdapterMetadata;
164
+ /**
165
+ * Convert Google Gemini API request to Universal IR format.
166
+ *
167
+ * This method transforms a Gemini-formatted request into the standardized
168
+ * Intermediate Representation (IR) format. It handles Gemini's unique
169
+ * content structure (parts array), converts 'model' role to 'assistant',
170
+ * and adjusts temperature values (Gemini uses 0-1, IR uses 0-2).
171
+ *
172
+ * @param request - Google Gemini API request
173
+ * @returns Promise resolving to IR chat request
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * const adapter = new GeminiFrontendAdapter();
178
+ * const irRequest = await adapter.toIR({
179
+ * contents: [{ role: 'user', parts: [{ text: 'Hello!' }] }],
180
+ * generationConfig: { temperature: 0.7 }
181
+ * });
182
+ * ```
183
+ */
51
184
  toIR(request: GeminiRequest): Promise<IRChatRequest>;
185
+ /**
186
+ * Convert Universal IR response back to Google Gemini API format.
187
+ *
188
+ * This method transforms the standardized IR response into the format
189
+ * expected by Gemini's API. It converts 'assistant' role back to 'model',
190
+ * structures content as parts array, and maps finish reasons to Gemini's
191
+ * specific format (STOP, MAX_TOKENS, OTHER).
192
+ *
193
+ * @param response - Universal IR chat response
194
+ * @returns Promise resolving to Gemini API response
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * const adapter = new GeminiFrontendAdapter();
199
+ * const geminiResponse = await adapter.fromIR(irResponse);
200
+ * console.log(geminiResponse.candidates[0].content.parts[0].text);
201
+ * ```
202
+ */
52
203
  fromIR(response: IRChatResponse): Promise<GeminiResponse>;
204
+ /**
205
+ * Convert Universal IR stream to Google Gemini Server-Sent Events format.
206
+ *
207
+ * This async generator method transforms a stream of IR chunks into
208
+ * Gemini-formatted SSE responses. It yields Server-Sent Event strings
209
+ * with the "data: " prefix containing JSON candidates with parts array.
210
+ *
211
+ * @param stream - Universal IR chat stream
212
+ * @param _options - Optional stream conversion options (currently unused)
213
+ * @yields Server-Sent Event formatted strings
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const adapter = new GeminiFrontendAdapter();
218
+ * for await (const sseData of adapter.fromIRStream(irStream)) {
219
+ * console.log(sseData); // "data: {...}\n\n"
220
+ * }
221
+ * ```
222
+ */
53
223
  fromIRStream(stream: AsyncGenerator<IRStreamChunk>, _options?: StreamConversionOptions): AsyncGenerator<string>;
54
224
  }
55
225
  //# sourceMappingURL=gemini.d.ts.map