@providerprotocol/ai 0.0.14 → 0.0.16

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.
@@ -1,4 +1,4 @@
1
- import { b as Provider } from '../provider-Bi0nyNhA.js';
1
+ import { b as Provider } from '../provider-vTZ74u-w.js';
2
2
 
3
3
  /**
4
4
  * Provider-specific parameters for Google Gemini API requests.
@@ -79,6 +79,50 @@ interface GoogleLLMParams {
79
79
  * When set, the cached content is prepended to the request.
80
80
  */
81
81
  cachedContent?: string;
82
+ /**
83
+ * Built-in tools for server-side execution.
84
+ *
85
+ * Use the tool helper constructors from the `tools` namespace:
86
+ * - `tools.googleSearch()` - Google Search grounding
87
+ * - `tools.codeExecution()` - Python code execution
88
+ * - `tools.urlContext()` - URL fetching and analysis
89
+ * - `tools.googleMaps()` - Google Maps grounding
90
+ * - `tools.fileSearch()` - Document RAG search
91
+ *
92
+ * Note: File Search cannot be combined with other built-in tools.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * import { google, tools } from 'provider-protocol/google';
97
+ *
98
+ * const model = llm({
99
+ * model: google('gemini-2.5-flash'),
100
+ * params: {
101
+ * builtInTools: [
102
+ * tools.googleSearch(),
103
+ * tools.codeExecution(),
104
+ * ],
105
+ * },
106
+ * });
107
+ * ```
108
+ */
109
+ builtInTools?: GoogleBuiltInTool[];
110
+ /**
111
+ * Tool configuration for retrieval (e.g., user location for Maps).
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * const params: GoogleLLMParams = {
116
+ * builtInTools: [tools.googleMaps()],
117
+ * toolConfig: {
118
+ * retrievalConfig: {
119
+ * latLng: { latitude: 40.758896, longitude: -73.985130 },
120
+ * },
121
+ * },
122
+ * };
123
+ * ```
124
+ */
125
+ toolConfig?: GoogleToolConfig;
82
126
  }
83
127
  /**
84
128
  * Configuration for extended thinking/reasoning in Gemini 3+ models.
@@ -106,9 +150,10 @@ interface GoogleContent {
106
150
  * Union type for all possible content part types in Google messages.
107
151
  *
108
152
  * Parts can contain text, inline images, function calls (from model),
109
- * or function responses (from user providing tool results).
153
+ * function responses (from user providing tool results), or code execution
154
+ * results (from built-in code execution tool).
110
155
  */
111
- type GooglePart = GoogleTextPart | GoogleImagePart | GoogleFunctionCallPart | GoogleFunctionResponsePart;
156
+ type GooglePart = GoogleTextPart | GoogleImagePart | GoogleFunctionCallPart | GoogleFunctionResponsePart | GoogleExecutableCodePart | GoogleCodeExecutionResultPart;
112
157
  /**
113
158
  * Text content part.
114
159
  */
@@ -160,6 +205,36 @@ interface GoogleFunctionResponsePart {
160
205
  response: Record<string, unknown>;
161
206
  };
162
207
  }
208
+ /**
209
+ * Executable code part generated by the model.
210
+ *
211
+ * Contains code that was written by the model for execution
212
+ * via the built-in code execution tool.
213
+ */
214
+ interface GoogleExecutableCodePart {
215
+ /** Executable code details. */
216
+ executableCode: {
217
+ /** Programming language of the code. */
218
+ language: 'PYTHON' | 'LANGUAGE_UNSPECIFIED';
219
+ /** The code to execute. */
220
+ code: string;
221
+ };
222
+ }
223
+ /**
224
+ * Code execution result part from built-in code execution.
225
+ *
226
+ * Contains the output from executing code via the code execution tool.
227
+ * Always follows an ExecutableCode part.
228
+ */
229
+ interface GoogleCodeExecutionResultPart {
230
+ /** Code execution result details. */
231
+ codeExecutionResult: {
232
+ /** Execution outcome. */
233
+ outcome: 'OUTCOME_UNSPECIFIED' | 'OUTCOME_OK' | 'OUTCOME_FAILED' | 'OUTCOME_DEADLINE_EXCEEDED';
234
+ /** Execution output (stdout on success, stderr on failure). */
235
+ output: string;
236
+ };
237
+ }
163
238
  /**
164
239
  * Tool definition containing function declarations.
165
240
  *
@@ -191,6 +266,39 @@ interface GoogleFunctionDeclaration {
191
266
  required?: string[];
192
267
  };
193
268
  }
269
+ /**
270
+ * Request body for creating a cached content entry.
271
+ *
272
+ * @see {@link https://ai.google.dev/api/caching Google Caching API docs}
273
+ */
274
+ interface GoogleCacheCreateRequest {
275
+ /** Model to use with this cache (format: models/{model}) */
276
+ model: string;
277
+ /** Optional display name for the cache (max 128 chars) */
278
+ displayName?: string;
279
+ /** Content to cache (immutable after creation) */
280
+ contents?: GoogleContent[];
281
+ /** System instruction to cache (text-only, immutable after creation) */
282
+ systemInstruction?: {
283
+ role?: 'user';
284
+ parts: Array<{
285
+ text: string;
286
+ }>;
287
+ };
288
+ /** Tool declarations to cache (immutable after creation) */
289
+ tools?: GoogleTool[];
290
+ /** Tool configuration to cache (immutable after creation) */
291
+ toolConfig?: {
292
+ functionCallingConfig?: {
293
+ mode?: 'AUTO' | 'ANY' | 'NONE' | 'VALIDATED';
294
+ allowedFunctionNames?: string[];
295
+ };
296
+ };
297
+ /** Absolute expiration time (RFC 3339 format, mutually exclusive with ttl) */
298
+ expireTime?: string;
299
+ /** Time-to-live duration (e.g., "300s", "3600s", mutually exclusive with expireTime) */
300
+ ttl?: string;
301
+ }
194
302
  /**
195
303
  * Response from creating or retrieving a cached content entry.
196
304
  */
@@ -232,6 +340,319 @@ interface GoogleCacheListResponse {
232
340
  /** Token for fetching the next page of results */
233
341
  nextPageToken?: string;
234
342
  }
343
+ /**
344
+ * Google Gemini-specific HTTP headers for API requests.
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * const headers: GoogleHeaders = {
349
+ * 'x-goog-api-client': 'myapp/1.0.0',
350
+ * };
351
+ * ```
352
+ */
353
+ interface GoogleHeaders {
354
+ /** Client identification header for partners and libraries. */
355
+ 'x-goog-api-client'?: string;
356
+ /** Quota project ID for Vertex AI billing. */
357
+ 'x-goog-user-project'?: string;
358
+ [key: string]: string | undefined;
359
+ }
360
+ /**
361
+ * Google Search grounding tool for real-time web information.
362
+ *
363
+ * Enables Gemini to search the web using Google Search for up-to-date information.
364
+ * Results are returned with grounding metadata including sources and citations.
365
+ *
366
+ * Pricing:
367
+ * - Gemini 2.x and earlier: $35 per 1,000 grounded prompts
368
+ * - Gemini 3.x: $14 per 1,000 search queries
369
+ *
370
+ * @example
371
+ * ```typescript
372
+ * const tool: GoogleSearchTool = {
373
+ * googleSearch: {},
374
+ * };
375
+ * ```
376
+ */
377
+ interface GoogleSearchTool {
378
+ /** Empty object to enable Google Search grounding */
379
+ googleSearch: Record<string, never>;
380
+ }
381
+ /**
382
+ * Code execution tool for running Python in a sandbox.
383
+ *
384
+ * Enables Gemini to write and execute Python code in a secure environment.
385
+ * Supports data analysis, calculations, and visualization.
386
+ *
387
+ * No additional cost - standard token pricing applies.
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * const tool: GoogleCodeExecutionTool = {
392
+ * codeExecution: {},
393
+ * };
394
+ * ```
395
+ */
396
+ interface GoogleCodeExecutionTool {
397
+ /** Empty object to enable code execution */
398
+ codeExecution: Record<string, never>;
399
+ }
400
+ /**
401
+ * URL context tool for fetching and processing URLs.
402
+ *
403
+ * Enables Gemini to fetch and analyze content from URLs.
404
+ * Supports text, images, and PDF documents.
405
+ *
406
+ * Limits:
407
+ * - Maximum 20 URLs per request
408
+ * - Maximum 34MB content per URL
409
+ *
410
+ * @example
411
+ * ```typescript
412
+ * const tool: GoogleUrlContextTool = {
413
+ * urlContext: {},
414
+ * };
415
+ * ```
416
+ */
417
+ interface GoogleUrlContextTool {
418
+ /** Empty object to enable URL context */
419
+ urlContext: Record<string, never>;
420
+ }
421
+ /**
422
+ * Google Maps grounding tool for location-based queries.
423
+ *
424
+ * Enables Gemini to search for places, businesses, and locations
425
+ * using Google Maps data.
426
+ *
427
+ * Pricing: $25 per 1,000 grounded prompts.
428
+ *
429
+ * Note: Not supported in Gemini 3 models.
430
+ *
431
+ * @example
432
+ * ```typescript
433
+ * const tool: GoogleMapsTool = {
434
+ * googleMaps: {
435
+ * enableWidget: true,
436
+ * },
437
+ * };
438
+ * ```
439
+ */
440
+ interface GoogleMapsTool {
441
+ /** Google Maps configuration */
442
+ googleMaps: {
443
+ /** Return widget context token for Places widget */
444
+ enableWidget?: boolean;
445
+ };
446
+ }
447
+ /**
448
+ * File search (RAG) tool for document retrieval.
449
+ *
450
+ * Enables Gemini to search through uploaded documents
451
+ * using semantic search on FileSearchStore.
452
+ *
453
+ * Pricing:
454
+ * - Embeddings at indexing: $0.15 per 1M tokens
455
+ * - Storage and query embeddings: Free
456
+ *
457
+ * Note: Cannot be combined with other built-in tools.
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * const tool: GoogleFileSearchTool = {
462
+ * fileSearch: {
463
+ * fileSearchStoreNames: ['fileSearchStores/abc123'],
464
+ * },
465
+ * };
466
+ * ```
467
+ */
468
+ interface GoogleFileSearchTool {
469
+ /** File search configuration */
470
+ fileSearch: {
471
+ /** FileSearchStore names to query */
472
+ fileSearchStoreNames: string[];
473
+ /** AIP-160 filter syntax for metadata filtering */
474
+ metadataFilter?: string;
475
+ };
476
+ }
477
+ /**
478
+ * Union type for all Google built-in tools.
479
+ *
480
+ * Note: Google's built-in tools use a different structure than function tools.
481
+ * They are passed directly in the tools array alongside functionDeclarations.
482
+ */
483
+ type GoogleBuiltInTool = GoogleSearchTool | GoogleCodeExecutionTool | GoogleUrlContextTool | GoogleMapsTool | GoogleFileSearchTool;
484
+ /**
485
+ * Tool configuration for retrieval (e.g., user location for Maps).
486
+ */
487
+ interface GoogleToolConfig {
488
+ /** Retrieval configuration */
489
+ retrievalConfig?: {
490
+ /** User location for "near me" queries */
491
+ latLng?: {
492
+ /** User latitude */
493
+ latitude: number;
494
+ /** User longitude */
495
+ longitude: number;
496
+ };
497
+ };
498
+ }
499
+ /**
500
+ * Grounding metadata returned with search/maps results.
501
+ */
502
+ interface GoogleGroundingMetadata {
503
+ /** Web search queries executed */
504
+ webSearchQueries?: string[];
505
+ /** Search entry point with rendered HTML */
506
+ searchEntryPoint?: {
507
+ renderedContent: string;
508
+ };
509
+ /** Grounding chunks (sources) */
510
+ groundingChunks?: Array<{
511
+ web?: {
512
+ uri: string;
513
+ title: string;
514
+ };
515
+ maps?: {
516
+ uri: string;
517
+ placeId: string;
518
+ title: string;
519
+ };
520
+ }>;
521
+ /** Grounding supports (citations) */
522
+ groundingSupports?: Array<{
523
+ segment: {
524
+ startIndex: number;
525
+ endIndex: number;
526
+ text: string;
527
+ };
528
+ groundingChunkIndices: number[];
529
+ confidenceScores: number[];
530
+ }>;
531
+ /** Google Maps widget context token */
532
+ googleMapsWidgetContextToken?: string;
533
+ }
534
+ /**
535
+ * Code execution result in response.
536
+ */
537
+ interface GoogleCodeExecutionResult {
538
+ /** Execution outcome */
539
+ outcome: 'OUTCOME_OK' | 'OUTCOME_FAILED' | 'OUTCOME_DEADLINE_EXCEEDED';
540
+ /** Execution output (stdout) */
541
+ output: string;
542
+ }
543
+ /**
544
+ * Creates a Google Search grounding tool configuration.
545
+ *
546
+ * Enables Gemini to search the web using Google Search for up-to-date information.
547
+ *
548
+ * @returns A Google Search tool configuration object
549
+ *
550
+ * @example
551
+ * ```typescript
552
+ * const search = googleSearchTool();
553
+ * ```
554
+ */
555
+ declare function googleSearchTool(): GoogleSearchTool;
556
+ /**
557
+ * Creates a code execution tool configuration.
558
+ *
559
+ * Enables Gemini to write and execute Python code in a sandbox.
560
+ *
561
+ * @returns A code execution tool configuration object
562
+ *
563
+ * @example
564
+ * ```typescript
565
+ * const codeExec = codeExecutionTool();
566
+ * ```
567
+ */
568
+ declare function codeExecutionTool(): GoogleCodeExecutionTool;
569
+ /**
570
+ * Creates a URL context tool configuration.
571
+ *
572
+ * Enables Gemini to fetch and analyze content from URLs.
573
+ *
574
+ * @returns A URL context tool configuration object
575
+ *
576
+ * @example
577
+ * ```typescript
578
+ * const urlCtx = urlContextTool();
579
+ * ```
580
+ */
581
+ declare function urlContextTool(): GoogleUrlContextTool;
582
+ /**
583
+ * Creates a Google Maps grounding tool configuration.
584
+ *
585
+ * Enables Gemini to search for places using Google Maps data.
586
+ *
587
+ * Note: Not supported in Gemini 3 models.
588
+ *
589
+ * @param options - Optional configuration
590
+ * @returns A Google Maps tool configuration object
591
+ *
592
+ * @example
593
+ * ```typescript
594
+ * const maps = googleMapsTool();
595
+ *
596
+ * // With widget enabled
597
+ * const mapsWithWidget = googleMapsTool({ enableWidget: true });
598
+ * ```
599
+ */
600
+ declare function googleMapsTool(options?: {
601
+ enableWidget?: boolean;
602
+ }): GoogleMapsTool;
603
+ /**
604
+ * Creates a file search (RAG) tool configuration.
605
+ *
606
+ * Enables Gemini to search through uploaded documents.
607
+ *
608
+ * Note: Cannot be combined with other built-in tools.
609
+ *
610
+ * @param options - File search configuration
611
+ * @returns A file search tool configuration object
612
+ *
613
+ * @example
614
+ * ```typescript
615
+ * const fileSearch = fileSearchTool({
616
+ * fileSearchStoreNames: ['fileSearchStores/abc123'],
617
+ * });
618
+ * ```
619
+ */
620
+ declare function fileSearchTool(options: {
621
+ fileSearchStoreNames: string[];
622
+ metadataFilter?: string;
623
+ }): GoogleFileSearchTool;
624
+ /**
625
+ * Namespace object containing all Google tool helper constructors.
626
+ *
627
+ * Provides a convenient way to create built-in tool configurations.
628
+ *
629
+ * @example
630
+ * ```typescript
631
+ * import { google, tools } from 'provider-protocol/google';
632
+ *
633
+ * const model = llm({
634
+ * model: google('gemini-2.5-flash'),
635
+ * params: {
636
+ * builtInTools: [
637
+ * tools.googleSearch(),
638
+ * tools.codeExecution(),
639
+ * ],
640
+ * },
641
+ * });
642
+ * ```
643
+ */
644
+ declare const tools: {
645
+ /** Creates a Google Search grounding tool configuration */
646
+ googleSearch: typeof googleSearchTool;
647
+ /** Creates a code execution tool configuration */
648
+ codeExecution: typeof codeExecutionTool;
649
+ /** Creates a URL context tool configuration */
650
+ urlContext: typeof urlContextTool;
651
+ /** Creates a Google Maps grounding tool configuration */
652
+ googleMaps: typeof googleMapsTool;
653
+ /** Creates a file search (RAG) tool configuration */
654
+ fileSearch: typeof fileSearchTool;
655
+ };
235
656
 
236
657
  /**
237
658
  * @fileoverview Google Gemini caching utilities.
@@ -365,6 +786,58 @@ declare function list(options: CacheListOptions): Promise<GoogleCacheListRespons
365
786
  * ```
366
787
  */
367
788
  declare function update(name: string, updateRequest: GoogleCacheUpdateRequest, apiKey: string): Promise<GoogleCacheResponse>;
789
+ /**
790
+ * Deletes a cached content entry.
791
+ *
792
+ * @param name - The cache name (format: "cachedContents/{id}")
793
+ * @param apiKey - API key for authentication
794
+ *
795
+ * @example
796
+ * ```typescript
797
+ * await google.cache.delete('cachedContents/abc123', apiKey);
798
+ * ```
799
+ */
800
+ declare function deleteCache(name: string, apiKey: string): Promise<void>;
801
+ /**
802
+ * Cache utilities namespace.
803
+ *
804
+ * Provides functions for creating and managing Google Gemini cached content
805
+ * entries. Use cached content to reduce costs and latency when repeatedly
806
+ * sending the same context (system instructions, large documents, etc.)
807
+ * across multiple requests.
808
+ *
809
+ * @example
810
+ * ```typescript
811
+ * import { google } from '@anthropic/provider-protocol';
812
+ *
813
+ * // Create a cache
814
+ * const cache = await google.cache.create({
815
+ * apiKey: process.env.GOOGLE_API_KEY,
816
+ * model: 'gemini-3-flash-preview',
817
+ * systemInstruction: 'You are an expert assistant...',
818
+ * contents: [{ role: 'user', parts: [{ text: largeDocument }] }],
819
+ * ttl: '3600s',
820
+ * });
821
+ *
822
+ * // Use cache.name in requests via params.cachedContent
823
+ * const response = await model.complete({
824
+ * messages: [userMessage('Summarize the document')],
825
+ * params: { cachedContent: cache.name },
826
+ * });
827
+ *
828
+ * // Manage caches
829
+ * const caches = await google.cache.list({ apiKey });
830
+ * await google.cache.update(cache.name, { ttl: '7200s' }, apiKey);
831
+ * await google.cache.delete(cache.name, apiKey);
832
+ * ```
833
+ */
834
+ declare const cache: {
835
+ create: typeof create;
836
+ get: typeof get;
837
+ list: typeof list;
838
+ update: typeof update;
839
+ delete: typeof deleteCache;
840
+ };
368
841
 
369
842
  /**
370
843
  * Google Gemini provider for the Unified Provider Protocol (UPP).
@@ -435,4 +908,4 @@ declare const google: Provider<unknown> & {
435
908
  };
436
909
  };
437
910
 
438
- export { type GoogleLLMParams, google };
911
+ export { type CacheCreateOptions, type CacheListOptions, type GoogleBuiltInTool, type GoogleCacheCreateRequest, type GoogleCacheListResponse, type GoogleCacheResponse, type GoogleCacheUpdateRequest, type GoogleCodeExecutionResult, type GoogleCodeExecutionTool, type GoogleFileSearchTool, type GoogleGroundingMetadata, type GoogleHeaders, type GoogleLLMParams, type GoogleMapsTool, type GoogleSearchTool, type GoogleToolConfig, type GoogleUrlContextTool, cache, google, tools };
@@ -21,7 +21,7 @@ import {
21
21
  // src/providers/google/transform.ts
22
22
  function transformRequest(request, modelId) {
23
23
  const params = request.params ?? {};
24
- const { cachedContent, ...generationParams } = params;
24
+ const { cachedContent, builtInTools, toolConfig, ...generationParams } = params;
25
25
  const googleRequest = {
26
26
  contents: transformMessages(request.messages)
27
27
  };
@@ -46,12 +46,20 @@ function transformRequest(request, modelId) {
46
46
  if (Object.keys(generationConfig).length > 0) {
47
47
  googleRequest.generationConfig = generationConfig;
48
48
  }
49
+ const tools2 = [];
49
50
  if (request.tools && request.tools.length > 0) {
50
- googleRequest.tools = [
51
- {
52
- functionDeclarations: request.tools.map(transformTool)
53
- }
54
- ];
51
+ tools2.push({
52
+ functionDeclarations: request.tools.map(transformTool)
53
+ });
54
+ }
55
+ if (builtInTools && builtInTools.length > 0) {
56
+ tools2.push(...builtInTools);
57
+ }
58
+ if (tools2.length > 0) {
59
+ googleRequest.tools = tools2;
60
+ }
61
+ if (toolConfig) {
62
+ googleRequest.toolConfig = toolConfig;
55
63
  }
56
64
  if (cachedContent) {
57
65
  googleRequest.cachedContent = cachedContent;
@@ -190,6 +198,14 @@ function transformResponse(data) {
190
198
  args: fc.functionCall.args,
191
199
  thoughtSignature: fc.thoughtSignature
192
200
  });
201
+ } else if ("codeExecutionResult" in part) {
202
+ const codeResult = part;
203
+ if (codeResult.codeExecutionResult.output) {
204
+ textContent.push({ type: "text", text: `
205
+ \`\`\`
206
+ ${codeResult.codeExecutionResult.output}\`\`\`
207
+ ` });
208
+ }
193
209
  }
194
210
  }
195
211
  const message = new AssistantMessage(
@@ -269,6 +285,20 @@ function transformStreamChunk(chunk, state) {
269
285
  argumentsJson: JSON.stringify(fc.functionCall.args)
270
286
  }
271
287
  });
288
+ } else if ("codeExecutionResult" in part) {
289
+ const codeResult = part;
290
+ if (codeResult.codeExecutionResult.output) {
291
+ const outputText = `
292
+ \`\`\`
293
+ ${codeResult.codeExecutionResult.output}\`\`\`
294
+ `;
295
+ state.content += outputText;
296
+ events.push({
297
+ type: "text_delta",
298
+ index: 0,
299
+ delta: { text: outputText }
300
+ });
301
+ }
272
302
  }
273
303
  }
274
304
  if (candidate.finishReason) {
@@ -499,7 +529,7 @@ async function create(options) {
499
529
  displayName,
500
530
  contents,
501
531
  systemInstruction,
502
- tools,
532
+ tools: tools2,
503
533
  ttl,
504
534
  expireTime
505
535
  } = options;
@@ -517,8 +547,8 @@ async function create(options) {
517
547
  parts: [{ text: systemInstruction }]
518
548
  };
519
549
  }
520
- if (tools && tools.length > 0) {
521
- requestBody.tools = tools;
550
+ if (tools2 && tools2.length > 0) {
551
+ requestBody.tools = tools2;
522
552
  }
523
553
  if (ttl) {
524
554
  requestBody.ttl = ttl;
@@ -531,8 +561,7 @@ async function create(options) {
531
561
  body: JSON.stringify(requestBody)
532
562
  });
533
563
  if (!response.ok) {
534
- const error = await response.text();
535
- throw new Error(`Failed to create cache: ${response.status} ${error}`);
564
+ throw await normalizeHttpError(response, "google", "llm");
536
565
  }
537
566
  return response.json();
538
567
  }
@@ -541,8 +570,7 @@ async function get(name, apiKey) {
541
570
  const url = `https://generativelanguage.googleapis.com/v1beta/${cacheName}?key=${apiKey}`;
542
571
  const response = await fetch(url, { method: "GET" });
543
572
  if (!response.ok) {
544
- const error = await response.text();
545
- throw new Error(`Failed to get cache: ${response.status} ${error}`);
573
+ throw await normalizeHttpError(response, "google", "llm");
546
574
  }
547
575
  return response.json();
548
576
  }
@@ -553,8 +581,7 @@ async function list(options) {
553
581
  if (pageToken) params.set("pageToken", pageToken);
554
582
  const response = await fetch(`${CACHE_API_BASE}?${params}`, { method: "GET" });
555
583
  if (!response.ok) {
556
- const error = await response.text();
557
- throw new Error(`Failed to list caches: ${response.status} ${error}`);
584
+ throw await normalizeHttpError(response, "google", "llm");
558
585
  }
559
586
  return response.json();
560
587
  }
@@ -567,8 +594,7 @@ async function update(name, updateRequest, apiKey) {
567
594
  body: JSON.stringify(updateRequest)
568
595
  });
569
596
  if (!response.ok) {
570
- const error = await response.text();
571
- throw new Error(`Failed to update cache: ${response.status} ${error}`);
597
+ throw await normalizeHttpError(response, "google", "llm");
572
598
  }
573
599
  return response.json();
574
600
  }
@@ -577,8 +603,7 @@ async function deleteCache(name, apiKey) {
577
603
  const url = `https://generativelanguage.googleapis.com/v1beta/${cacheName}?key=${apiKey}`;
578
604
  const response = await fetch(url, { method: "DELETE" });
579
605
  if (!response.ok) {
580
- const error = await response.text();
581
- throw new Error(`Failed to delete cache: ${response.status} ${error}`);
606
+ throw await normalizeHttpError(response, "google", "llm");
582
607
  }
583
608
  }
584
609
  var cache = {
@@ -589,6 +614,41 @@ var cache = {
589
614
  delete: deleteCache
590
615
  };
591
616
 
617
+ // src/providers/google/types.ts
618
+ function googleSearchTool() {
619
+ return { googleSearch: {} };
620
+ }
621
+ function codeExecutionTool() {
622
+ return { codeExecution: {} };
623
+ }
624
+ function urlContextTool() {
625
+ return { urlContext: {} };
626
+ }
627
+ function googleMapsTool(options) {
628
+ return {
629
+ googleMaps: {
630
+ ...options?.enableWidget !== void 0 && { enableWidget: options.enableWidget }
631
+ }
632
+ };
633
+ }
634
+ function fileSearchTool(options) {
635
+ return {
636
+ fileSearch: options
637
+ };
638
+ }
639
+ var tools = {
640
+ /** Creates a Google Search grounding tool configuration */
641
+ googleSearch: googleSearchTool,
642
+ /** Creates a code execution tool configuration */
643
+ codeExecution: codeExecutionTool,
644
+ /** Creates a URL context tool configuration */
645
+ urlContext: urlContextTool,
646
+ /** Creates a Google Maps grounding tool configuration */
647
+ googleMaps: googleMapsTool,
648
+ /** Creates a file search (RAG) tool configuration */
649
+ fileSearch: fileSearchTool
650
+ };
651
+
592
652
  // src/providers/google/index.ts
593
653
  var baseProvider = createProvider({
594
654
  name: "google",
@@ -599,6 +659,8 @@ var baseProvider = createProvider({
599
659
  });
600
660
  var google = Object.assign(baseProvider, { cache });
601
661
  export {
602
- google
662
+ cache,
663
+ google,
664
+ tools
603
665
  };
604
666
  //# sourceMappingURL=index.js.map