@ai-sdk/gateway 4.0.141 → 4.0.143

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.
@@ -193,6 +193,8 @@ export interface TakoResultContent {
193
193
  total_matching?: number | null;
194
194
  export_pricing?: {
195
195
  baseline_usd: number;
196
+ /** @deprecated Always 0, and Tako will stop sending it. */
197
+ free_rows?: number;
196
198
  max_rows_ceiling: number;
197
199
  row_cpm_usd: number;
198
200
  /** USD per 1,000 premium records by class, added to row_cpm_usd when premium. */
@@ -296,179 +298,168 @@ export type TakoSearchOutput = TakoSearchError | TakoSearchResponse;
296
298
 
297
299
  const takoDataSourceInputSchema = () =>
298
300
  z.object({
299
- count: z
300
- .number()
301
- .optional()
302
- .describe(
303
- 'Maximum number of data results to return (1-20). When include_contents is true, each additional result adds its own data surcharge.',
304
- ),
305
- include_contents: z
306
- .boolean()
307
- .optional()
308
- .describe(
309
- 'Inline rows for each data result. This adds a data surcharge based on row count and dataset source. To estimate cost, search with include_contents disabled and inspect cards.content.export_pricing. This applies to every returned card; limit sources.data.count and sources.data.max_rows to control cost.',
310
- ),
311
- mode: z
312
- .enum(['inline', 'url'])
313
- .optional()
314
- .describe(
315
- 'Requested data delivery mode. Search card data is always inline.',
316
- ),
317
- content_format: z
318
- .enum(['card_json', 'csv', 'json_compact', 'json_records'])
319
- .optional()
320
- .describe('Serialization for inlined card data.'),
321
- max_rows: z
322
- .number()
323
- .optional()
324
- .describe(
325
- 'Maximum rows to inline per result. Omit to use the allowance in cards.content.export_pricing. A data surcharge applies per 1,000 exported rows; lower values reduce cost.',
326
- ),
327
- node_ids: z
328
- .array(z.string())
329
- .optional()
330
- .describe('Data Graph node IDs to prioritize. Maximum 20.'),
331
- strict: z
332
- .boolean()
333
- .optional()
334
- .describe(
335
- 'Only return cards matching node_ids. Requires a non-empty node_ids.',
336
- ),
301
+ count: z.describe(
302
+ z.optional(z.number()),
303
+ 'Maximum number of data results to return (1-20). When include_contents is true, each additional result adds its own data surcharge.',
304
+ ),
305
+ include_contents: z.describe(
306
+ z.optional(z.boolean()),
307
+ 'Inline rows for each data result. This adds a data surcharge based on row count and dataset source. To estimate cost, search with include_contents disabled and inspect cards.content.export_pricing. This applies to every returned card; limit sources.data.count and sources.data.max_rows to control cost.',
308
+ ),
309
+ mode: z.describe(
310
+ z.optional(z.enum(['inline', 'url'])),
311
+ 'Requested data delivery mode. Search card data is always inline.',
312
+ ),
313
+ content_format: z.describe(
314
+ z.optional(z.enum(['card_json', 'csv', 'json_compact', 'json_records'])),
315
+ 'Serialization for inlined card data.',
316
+ ),
317
+ max_rows: z.describe(
318
+ z.optional(z.number()),
319
+ 'Maximum rows to inline per result. Omit to use the allowance in cards.content.export_pricing. A data surcharge applies per 1,000 exported rows; lower values reduce cost.',
320
+ ),
321
+ node_ids: z.describe(
322
+ z.optional(z.array(z.string())),
323
+ 'Data Graph node IDs to prioritize. Maximum 20.',
324
+ ),
325
+ strict: z.describe(
326
+ z.optional(z.boolean()),
327
+ 'Only return cards matching node_ids. Requires a non-empty node_ids.',
328
+ ),
337
329
  });
338
330
 
339
331
  const takoWebSourceInputSchema = () =>
340
332
  z.object({
341
- count: z
342
- .number()
343
- .optional()
344
- .describe('Maximum number of web results to return (1-20).'),
345
- include_contents: z
346
- .boolean()
347
- .optional()
348
- .describe('Inline extracted web page text. This can add a data charge.'),
349
- category: z
350
- .enum(['finance', 'news', 'sports'])
351
- .optional()
352
- .describe('Optional web-result category filter.'),
353
- include_domains: z
354
- .array(z.string())
355
- .optional()
356
- .describe('Only return results from these bare domains.'),
357
- exclude_domains: z
358
- .array(z.string())
359
- .optional()
360
- .describe('Exclude results from these bare domains.'),
361
- snippet_max_chars: z
362
- .number()
363
- .optional()
364
- .describe('Maximum characters in each web-result snippet.'),
365
- highlights: z
366
- .boolean()
367
- .optional()
368
- .describe(
369
- 'Include highlighted passages in web results. Defaults to true in AI Gateway.',
370
- ),
371
- article_content_max_chars: z
372
- .number()
373
- .optional()
374
- .describe(
375
- 'Maximum extracted characters per web page when including contents.',
376
- ),
377
- published_after: z
378
- .string()
379
- .optional()
380
- .describe(
381
- 'Keep results published on or after this ISO date (YYYY-MM-DD).',
382
- ),
383
- published_before: z
384
- .string()
385
- .optional()
386
- .describe(
387
- 'Keep results published on or before this ISO date (YYYY-MM-DD).',
388
- ),
333
+ count: z.describe(
334
+ z.optional(z.number()),
335
+ 'Maximum number of web results to return (1-20).',
336
+ ),
337
+ include_contents: z.describe(
338
+ z.optional(z.boolean()),
339
+ 'Inline extracted web page text. This can add a data charge.',
340
+ ),
341
+ category: z.describe(
342
+ z.optional(z.enum(['finance', 'news', 'sports'])),
343
+ 'Optional web-result category filter.',
344
+ ),
345
+ include_domains: z.describe(
346
+ z.optional(z.array(z.string())),
347
+ 'Only return results from these bare domains.',
348
+ ),
349
+ exclude_domains: z.describe(
350
+ z.optional(z.array(z.string())),
351
+ 'Exclude results from these bare domains.',
352
+ ),
353
+ snippet_max_chars: z.describe(
354
+ z.optional(z.number()),
355
+ 'Maximum characters in each web-result snippet.',
356
+ ),
357
+ highlights: z.describe(
358
+ z.optional(z.boolean()),
359
+ 'Include highlighted passages in web results. Defaults to true in AI Gateway.',
360
+ ),
361
+ article_content_max_chars: z.describe(
362
+ z.optional(z.number()),
363
+ 'Maximum extracted characters per web page when including contents.',
364
+ ),
365
+ published_after: z.describe(
366
+ z.optional(z.string()),
367
+ 'Keep results published on or after this ISO date (YYYY-MM-DD).',
368
+ ),
369
+ published_before: z.describe(
370
+ z.optional(z.string()),
371
+ 'Keep results published on or before this ISO date (YYYY-MM-DD).',
372
+ ),
389
373
  });
390
374
 
391
375
  const takoSearchInputSchema = lazySchema(() =>
392
376
  zodSchema(
393
377
  z.object({
394
- query: z
395
- .string()
396
- .describe(
397
- 'Natural-language search query. Include the entity, metric, and time period. Quote a phrase to force it to one entity, for example "Tesla":PRODUCT price.',
398
- ),
399
- effort: z
400
- .enum(['deep', 'fast', 'instant'])
401
- .optional()
402
- .describe(
403
- 'Search effort. fast is the balanced default, instant favors cached results and low latency, and deep broadens retrieval with reranking at higher cost and latency.',
378
+ query: z.describe(
379
+ z.string(),
380
+ 'Natural-language search query. Include the entity, metric, and time period. Quote a phrase to force it to one entity, for example "Tesla":PRODUCT price.',
381
+ ),
382
+ effort: z.describe(
383
+ z.optional(z.enum(['deep', 'fast', 'instant'])),
384
+ 'Search effort. fast is the balanced default, instant favors cached results and low latency, and deep broadens retrieval with reranking at higher cost and latency.',
385
+ ),
386
+ sources: z.describe(
387
+ z.optional(
388
+ z.object({
389
+ data: z.optional(takoDataSourceInputSchema()),
390
+ web: z.optional(takoWebSourceInputSchema()),
391
+ }),
404
392
  ),
405
- sources: z
406
- .object({
407
- data: takoDataSourceInputSchema().optional(),
408
- web: takoWebSourceInputSchema().optional(),
409
- })
410
- .optional()
411
- .describe(
412
- 'Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched.',
393
+ 'Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched.',
394
+ ),
395
+ location: z.describe(
396
+ z.optional(
397
+ z.object({
398
+ latitude: z.describe(z.number(), 'Latitude between -90 and 90.'),
399
+ longitude: z.describe(
400
+ z.number(),
401
+ 'Longitude between -180 and 180.',
402
+ ),
403
+ }),
413
404
  ),
414
- location: z
415
- .object({
416
- latitude: z.number().describe('Latitude between -90 and 90.'),
417
- longitude: z.number().describe('Longitude between -180 and 180.'),
418
- })
419
- .optional()
420
- .describe('End-user coordinates for localized results.'),
421
- country_code: z
422
- .string()
423
- .optional()
424
- .describe("Two-letter ISO 3166-1 country code, such as 'US'."),
425
- locale: z.string().optional().describe("BCP-47 locale, such as 'en-US'."),
426
- timezone: z
427
- .string()
428
- .optional()
429
- .describe("IANA timezone, such as 'America/New_York'."),
430
- output_settings: z
431
- .object({
432
- image_dark_mode: z
433
- .boolean()
434
- .optional()
435
- .describe('Render card preview images in dark mode.'),
436
- force_refresh: z
437
- .boolean()
438
- .optional()
439
- .describe(
405
+ 'End-user coordinates for localized results.',
406
+ ),
407
+ country_code: z.describe(
408
+ z.optional(z.string()),
409
+ "Two-letter ISO 3166-1 country code, such as 'US'.",
410
+ ),
411
+ locale: z.describe(
412
+ z.optional(z.string()),
413
+ "BCP-47 locale, such as 'en-US'.",
414
+ ),
415
+ timezone: z.describe(
416
+ z.optional(z.string()),
417
+ "IANA timezone, such as 'America/New_York'.",
418
+ ),
419
+ output_settings: z.describe(
420
+ z.optional(
421
+ z.object({
422
+ image_dark_mode: z.describe(
423
+ z.optional(z.boolean()),
424
+ 'Render card preview images in dark mode.',
425
+ ),
426
+ force_refresh: z.describe(
427
+ z.optional(z.boolean()),
440
428
  'Instant-effort only. Request a refreshed instant result.',
441
429
  ),
442
- })
443
- .optional()
444
- .describe('Controls card rendering in the search response.'),
445
- include_related: z
446
- .number()
447
- .optional()
448
- .describe('Maximum related search suggestions to include (1-20).'),
430
+ }),
431
+ ),
432
+ 'Controls card rendering in the search response.',
433
+ ),
434
+ include_related: z.describe(
435
+ z.optional(z.number()),
436
+ 'Maximum related search suggestions to include (1-20).',
437
+ ),
449
438
  }),
450
439
  ),
451
440
  );
452
441
 
453
442
  const takoDatasetCellSchema = () =>
454
- z.union([z.boolean(), z.number(), z.string()]).nullable();
443
+ z.nullable(z.union([z.boolean(), z.number(), z.string()]));
455
444
 
456
445
  export const takoResultContentSchema = () =>
457
- z
458
- .object({
459
- content_format: z
460
- .enum(['card_json', 'csv', 'json_compact', 'json_records'])
461
- .nullish(),
462
- cost: z.number().optional(),
463
- data: z.string().nullish(),
464
- records: z.array(z.record(z.string(), takoDatasetCellSchema())).nullish(),
465
- dataset: z
466
- .object({
446
+ z.catchall(
447
+ z.object({
448
+ content_format: z.nullish(
449
+ z.enum(['card_json', 'csv', 'json_compact', 'json_records']),
450
+ ),
451
+ cost: z.optional(z.number()),
452
+ data: z.nullish(z.string()),
453
+ records: z.nullish(
454
+ z.array(z.record(z.string(), takoDatasetCellSchema())),
455
+ ),
456
+ dataset: z.nullish(
457
+ z.object({
467
458
  columns: z.array(
468
459
  z.object({
469
460
  name: z.string(),
470
461
  type: z.enum(['boolean', 'date', 'datetime', 'number', 'string']),
471
- unit: z.string().nullish(),
462
+ unit: z.nullish(z.string()),
472
463
  }),
473
464
  ),
474
465
  rows: z.array(z.array(takoDatasetCellSchema())),
@@ -478,157 +469,168 @@ export const takoResultContentSchema = () =>
478
469
  sources: z.array(
479
470
  z.object({
480
471
  name: z.string(),
481
- index: z.enum(['data', 'web']).optional(),
472
+ index: z.optional(z.enum(['data', 'web'])),
482
473
  }),
483
474
  ),
484
- provenance: z.enum(['query', 'web_extraction']).optional(),
485
- })
486
- .nullish(),
487
- card_data: z.object({}).passthrough().nullish(),
488
- card_data_schema: z.object({}).passthrough().nullish(),
489
- url: z.string().nullish(),
490
- expires_at: z.string().nullish(),
491
- total_rows: z.number().nullish(),
492
- truncated: z.boolean().optional(),
493
- premium_rows: z.record(z.string(), z.number()).nullish(),
494
- redacted_cells: z.record(z.string(), z.array(z.number())).nullish(),
495
- total_matching: z.number().nullish(),
496
- export_pricing: z
497
- .object({
498
- baseline_usd: z.number(),
499
- max_rows_ceiling: z.number(),
500
- row_cpm_usd: z.number(),
501
- premium_row_cpm_usd: z.record(z.string(), z.number()).nullish(),
502
- variable_cost_max_usd: z.number().nullish(),
503
- })
504
- .passthrough()
505
- .nullish(),
506
- manifest: z
507
- .array(
475
+ provenance: z.optional(z.enum(['query', 'web_extraction'])),
476
+ }),
477
+ ),
478
+ card_data: z.nullish(z.catchall(z.object({}), z.unknown())),
479
+ card_data_schema: z.nullish(z.catchall(z.object({}), z.unknown())),
480
+ url: z.nullish(z.string()),
481
+ expires_at: z.nullish(z.string()),
482
+ total_rows: z.nullish(z.number()),
483
+ truncated: z.optional(z.boolean()),
484
+ premium_rows: z.nullish(z.record(z.string(), z.number())),
485
+ redacted_cells: z.nullish(z.record(z.string(), z.array(z.number()))),
486
+ total_matching: z.nullish(z.number()),
487
+ export_pricing: z.nullish(
488
+ z.catchall(
489
+ z.object({
490
+ baseline_usd: z.number(),
491
+ free_rows: z.optional(z.number()),
492
+ max_rows_ceiling: z.number(),
493
+ row_cpm_usd: z.number(),
494
+ premium_row_cpm_usd: z.nullish(z.record(z.string(), z.number())),
495
+ variable_cost_max_usd: z.nullish(z.number()),
496
+ }),
497
+ z.unknown(),
498
+ ),
499
+ ),
500
+ manifest: z.nullish(
501
+ z.array(
508
502
  z.object({
509
- dtype: z
510
- .enum(['boolean', 'date', 'datetime', 'number', 'string'])
511
- .nullish(),
512
- entity: z.string().nullish(),
513
- metric: z.string().nullish(),
514
- name: z.string().nullish(),
515
- unit: z.string().nullish(),
503
+ dtype: z.nullish(
504
+ z.enum(['boolean', 'date', 'datetime', 'number', 'string']),
505
+ ),
506
+ entity: z.nullish(z.string()),
507
+ metric: z.nullish(z.string()),
508
+ name: z.nullish(z.string()),
509
+ unit: z.nullish(z.string()),
516
510
  }),
517
- )
518
- .nullish(),
519
- })
520
- .passthrough();
511
+ ),
512
+ ),
513
+ }),
514
+ z.unknown(),
515
+ );
521
516
 
522
517
  const takoCardSchema = () =>
523
- z
524
- .object({
525
- card_id: z.string().nullish(),
526
- title: z.string().nullish(),
527
- description: z.string().nullish(),
528
- semantic_description: z.string().nullish(),
529
- webpage_url: z.string().nullish(),
530
- image_url: z.string().nullish(),
531
- embed_url: z.string().nullish(),
532
- sources: z
533
- .array(
518
+ z.catchall(
519
+ z.object({
520
+ card_id: z.nullish(z.string()),
521
+ title: z.nullish(z.string()),
522
+ description: z.nullish(z.string()),
523
+ semantic_description: z.nullish(z.string()),
524
+ webpage_url: z.nullish(z.string()),
525
+ image_url: z.nullish(z.string()),
526
+ embed_url: z.nullish(z.string()),
527
+ sources: z.nullish(
528
+ z.array(
534
529
  z.object({
535
- source_name: z.string().nullish(),
536
- source_description: z.string().nullish(),
530
+ source_name: z.nullish(z.string()),
531
+ source_description: z.nullish(z.string()),
537
532
  source_index: z.enum(['data', 'web']),
538
- source_text: z.string().nullish(),
539
- url: z.string().nullish(),
533
+ source_text: z.nullish(z.string()),
534
+ url: z.nullish(z.string()),
540
535
  }),
541
- )
542
- .nullish(),
543
- methodologies: z
544
- .array(
536
+ ),
537
+ ),
538
+ methodologies: z.nullish(
539
+ z.array(
545
540
  z.object({
546
- methodology_name: z.string().nullable(),
547
- methodology_description: z.string().nullable(),
541
+ methodology_name: z.nullable(z.string()),
542
+ methodology_description: z.nullable(z.string()),
548
543
  }),
549
- )
550
- .nullish(),
551
- source_indexes: z.array(z.enum(['data', 'web'])).nullish(),
552
- card_type: z.string().nullish(),
553
- relevance: z.enum(['High', 'Low', 'Medium']).nullish(),
554
- relevance_score: z.number().nullish(),
555
- content: takoResultContentSchema().nullish(),
556
- exportable: z.boolean().optional(),
557
- nodes: z
558
- .array(
544
+ ),
545
+ ),
546
+ source_indexes: z.nullish(z.array(z.enum(['data', 'web']))),
547
+ card_type: z.nullish(z.string()),
548
+ relevance: z.nullish(z.enum(['High', 'Low', 'Medium'])),
549
+ relevance_score: z.nullish(z.number()),
550
+ content: z.nullish(takoResultContentSchema()),
551
+ exportable: z.optional(z.boolean()),
552
+ nodes: z.nullish(
553
+ z.array(
559
554
  z.object({
560
555
  id: z.string(),
561
556
  type: z.enum(['entity', 'metric']),
562
557
  name: z.string(),
563
- description: z.string().nullish(),
558
+ description: z.nullish(z.string()),
564
559
  }),
565
- )
566
- .nullish(),
567
- metric_definitions: z
568
- .array(z.object({ name: z.string(), definition: z.string() }))
569
- .nullish(),
570
- data_freshness: z
571
- .object({
572
- coverage_end: z.string().nullish(),
573
- data_as_of: z.string().nullish(),
574
- last_updated: z.string().nullish(),
575
- })
576
- .nullish(),
577
- placeholder: z
578
- .object({
579
- withheld_source: z.string(),
580
- reason: z.enum(['not_served', 'over_cap']).nullish(),
581
- })
582
- .passthrough()
583
- .nullish(),
584
- })
585
- .passthrough();
560
+ ),
561
+ ),
562
+ metric_definitions: z.nullish(
563
+ z.array(z.object({ name: z.string(), definition: z.string() })),
564
+ ),
565
+ data_freshness: z.nullish(
566
+ z.object({
567
+ coverage_end: z.nullish(z.string()),
568
+ data_as_of: z.nullish(z.string()),
569
+ last_updated: z.nullish(z.string()),
570
+ }),
571
+ ),
572
+ placeholder: z.nullish(
573
+ z.catchall(
574
+ z.object({
575
+ withheld_source: z.string(),
576
+ reason: z.nullish(z.enum(['not_served', 'over_cap'])),
577
+ }),
578
+ z.unknown(),
579
+ ),
580
+ ),
581
+ }),
582
+ z.unknown(),
583
+ );
586
584
 
587
585
  const takoWebResultSchema = () =>
588
- z
589
- .object({
586
+ z.catchall(
587
+ z.object({
590
588
  title: z.string(),
591
589
  url: z.string(),
592
- snippet: z.string().nullish(),
593
- source_name: z.string().nullish(),
594
- publish_date: z.string().nullish(),
595
- content: takoResultContentSchema().nullish(),
596
- })
597
- .passthrough();
590
+ snippet: z.nullish(z.string()),
591
+ source_name: z.nullish(z.string()),
592
+ publish_date: z.nullish(z.string()),
593
+ content: z.nullish(takoResultContentSchema()),
594
+ }),
595
+ z.unknown(),
596
+ );
598
597
 
599
598
  const takoSearchOutputSchema = lazySchema(() =>
600
599
  zodSchema(
601
600
  z.union([
602
- z
603
- .object({
601
+ z.catchall(
602
+ z.object({
604
603
  request_id: z.string(),
605
- cards: z.array(takoCardSchema()).optional(),
606
- web_results: z.array(takoWebResultSchema()).optional(),
607
- usage: z
608
- .object({
609
- total_cost_usd: z.number(),
610
- compute: z
611
- .object({ cost_usd: z.number() })
612
- .passthrough()
613
- .nullish(),
614
- data: z
615
- .object({
616
- cost_usd: z.number(),
617
- datasets: z.number(),
618
- data_points: z.number().nullish(),
619
- })
620
- .passthrough()
621
- .nullish(),
622
- variable_cost: z
623
- .object({ cost_usd: z.number() })
624
- .passthrough()
625
- .nullish(),
626
- })
627
- .passthrough()
628
- .nullish(),
629
- related: z.array(z.object({}).passthrough()).nullish(),
630
- })
631
- .passthrough(),
604
+ cards: z.optional(z.array(takoCardSchema())),
605
+ web_results: z.optional(z.array(takoWebResultSchema())),
606
+ usage: z.nullish(
607
+ z.catchall(
608
+ z.object({
609
+ total_cost_usd: z.number(),
610
+ compute: z.nullish(
611
+ z.catchall(z.object({ cost_usd: z.number() }), z.unknown()),
612
+ ),
613
+ data: z.nullish(
614
+ z.catchall(
615
+ z.object({
616
+ cost_usd: z.number(),
617
+ datasets: z.number(),
618
+ data_points: z.nullish(z.number()),
619
+ }),
620
+ z.unknown(),
621
+ ),
622
+ ),
623
+ variable_cost: z.nullish(
624
+ z.catchall(z.object({ cost_usd: z.number() }), z.unknown()),
625
+ ),
626
+ }),
627
+ z.unknown(),
628
+ ),
629
+ ),
630
+ related: z.nullish(z.array(z.catchall(z.object({}), z.unknown()))),
631
+ }),
632
+ z.unknown(),
633
+ ),
632
634
  gatewayToolErrorSchema(),
633
635
  ]),
634
636
  ),