@ai-sdk/gateway 3.0.179 → 3.0.180

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.
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ __export(index_exports, {
36
36
  module.exports = __toCommonJS(index_exports);
37
37
 
38
38
  // src/gateway-provider.ts
39
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
39
+ var import_provider_utils20 = require("@ai-sdk/provider-utils");
40
40
 
41
41
  // src/errors/as-gateway-error.ts
42
42
  var import_provider = require("@ai-sdk/provider");
@@ -2145,6 +2145,210 @@ var perplexitySearchToolFactory = (0, import_provider_utils18.createProviderTool
2145
2145
  });
2146
2146
  var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
2147
2147
 
2148
+ // src/tool/tako-search.ts
2149
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
2150
+ var import_zod4 = require("zod");
2151
+ var takoDataSourceInputSchema = import_zod4.z.object({
2152
+ count: import_zod4.z.number().optional().describe("Maximum number of data cards to return (1-20)."),
2153
+ include_contents: import_zod4.z.boolean().optional().describe("Inline underlying card data. This can add a data charge."),
2154
+ mode: import_zod4.z.enum(["inline", "url"]).optional().describe(
2155
+ "Requested data delivery mode. Search card data is always inline."
2156
+ ),
2157
+ content_format: import_zod4.z.enum(["card_json", "csv", "json_compact", "json_records"]).optional().describe("Serialization for inlined card data."),
2158
+ max_rows: import_zod4.z.number().optional().describe("Maximum rows for inlined card data."),
2159
+ node_ids: import_zod4.z.array(import_zod4.z.string()).optional().describe("Data Graph node IDs to prioritize. Maximum 20."),
2160
+ strict: import_zod4.z.boolean().optional().describe(
2161
+ "Only return cards matching node_ids. Requires a non-empty node_ids."
2162
+ )
2163
+ });
2164
+ var takoWebSourceInputSchema = import_zod4.z.object({
2165
+ count: import_zod4.z.number().optional().describe("Maximum number of web results to return (1-20)."),
2166
+ include_contents: import_zod4.z.boolean().optional().describe("Inline extracted web page text. This can add a data charge."),
2167
+ category: import_zod4.z.enum(["finance", "news", "sports"]).optional().describe("Optional web-result category filter."),
2168
+ include_domains: import_zod4.z.array(import_zod4.z.string()).optional().describe("Only return results from these bare domains."),
2169
+ exclude_domains: import_zod4.z.array(import_zod4.z.string()).optional().describe("Exclude results from these bare domains."),
2170
+ snippet_max_chars: import_zod4.z.number().optional().describe("Maximum characters in each web-result snippet."),
2171
+ highlights: import_zod4.z.boolean().optional().describe(
2172
+ "Include highlighted passages in web results. Defaults to true in AI Gateway."
2173
+ ),
2174
+ article_content_max_chars: import_zod4.z.number().optional().describe(
2175
+ "Maximum extracted characters per web page when including contents."
2176
+ ),
2177
+ published_after: import_zod4.z.string().optional().describe("Keep results published on or after this ISO date (YYYY-MM-DD)."),
2178
+ published_before: import_zod4.z.string().optional().describe(
2179
+ "Keep results published on or before this ISO date (YYYY-MM-DD)."
2180
+ )
2181
+ });
2182
+ var takoSearchInputSchema = (0, import_provider_utils19.lazySchema)(
2183
+ () => (0, import_provider_utils19.zodSchema)(
2184
+ import_zod4.z.object({
2185
+ query: import_zod4.z.string().describe(
2186
+ '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.'
2187
+ ),
2188
+ effort: import_zod4.z.enum(["deep", "fast", "instant"]).optional().describe(
2189
+ "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."
2190
+ ),
2191
+ sources: import_zod4.z.object({
2192
+ data: takoDataSourceInputSchema.optional(),
2193
+ web: takoWebSourceInputSchema.optional()
2194
+ }).optional().describe(
2195
+ "Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched."
2196
+ ),
2197
+ location: import_zod4.z.object({
2198
+ latitude: import_zod4.z.number().describe("Latitude between -90 and 90."),
2199
+ longitude: import_zod4.z.number().describe("Longitude between -180 and 180.")
2200
+ }).optional().describe("End-user coordinates for localized results."),
2201
+ country_code: import_zod4.z.string().optional().describe("Two-letter ISO 3166-1 country code, such as 'US'."),
2202
+ locale: import_zod4.z.string().optional().describe("BCP-47 locale, such as 'en-US'."),
2203
+ timezone: import_zod4.z.string().optional().describe("IANA timezone, such as 'America/New_York'."),
2204
+ output_settings: import_zod4.z.object({
2205
+ image_dark_mode: import_zod4.z.boolean().optional().describe("Render card preview images in dark mode."),
2206
+ force_refresh: import_zod4.z.boolean().optional().describe(
2207
+ "Instant-effort only. Request a refreshed instant result."
2208
+ )
2209
+ }).optional().describe("Controls card rendering in the search response."),
2210
+ include_related: import_zod4.z.number().optional().describe("Maximum related search suggestions to include (1-20).")
2211
+ })
2212
+ )
2213
+ );
2214
+ var takoDatasetCellSchema = import_zod4.z.union([import_zod4.z.boolean(), import_zod4.z.number(), import_zod4.z.string()]).nullable();
2215
+ var takoResultContentSchema = import_zod4.z.object({
2216
+ content_format: import_zod4.z.enum(["card_json", "csv", "json_compact", "json_records"]).nullish(),
2217
+ cost: import_zod4.z.number().optional(),
2218
+ data: import_zod4.z.string().nullish(),
2219
+ records: import_zod4.z.array(import_zod4.z.record(import_zod4.z.string(), takoDatasetCellSchema)).nullish(),
2220
+ dataset: import_zod4.z.object({
2221
+ columns: import_zod4.z.array(
2222
+ import_zod4.z.object({
2223
+ name: import_zod4.z.string(),
2224
+ type: import_zod4.z.enum(["boolean", "date", "datetime", "number", "string"]),
2225
+ unit: import_zod4.z.string().nullish()
2226
+ })
2227
+ ),
2228
+ rows: import_zod4.z.array(import_zod4.z.array(takoDatasetCellSchema)),
2229
+ total_rows: import_zod4.z.number(),
2230
+ truncated: import_zod4.z.boolean(),
2231
+ ref: import_zod4.z.string(),
2232
+ sources: import_zod4.z.array(
2233
+ import_zod4.z.object({
2234
+ name: import_zod4.z.string(),
2235
+ index: import_zod4.z.enum(["data", "web"]).optional()
2236
+ })
2237
+ ),
2238
+ provenance: import_zod4.z.enum(["query", "web_extraction"]).optional()
2239
+ }).nullish(),
2240
+ card_data: import_zod4.z.object({}).passthrough().nullish(),
2241
+ card_data_schema: import_zod4.z.object({}).passthrough().nullish(),
2242
+ url: import_zod4.z.string().nullish(),
2243
+ expires_at: import_zod4.z.string().nullish(),
2244
+ total_rows: import_zod4.z.number().nullish(),
2245
+ truncated: import_zod4.z.boolean().optional(),
2246
+ export_pricing: import_zod4.z.object({
2247
+ baseline_usd: import_zod4.z.number(),
2248
+ free_rows: import_zod4.z.number(),
2249
+ max_rows_ceiling: import_zod4.z.number(),
2250
+ row_cpm_usd: import_zod4.z.number()
2251
+ }).nullish(),
2252
+ manifest: import_zod4.z.array(
2253
+ import_zod4.z.object({
2254
+ dtype: import_zod4.z.enum(["boolean", "date", "datetime", "number", "string"]).nullish(),
2255
+ entity: import_zod4.z.string().nullish(),
2256
+ metric: import_zod4.z.string().nullish(),
2257
+ name: import_zod4.z.string().nullish(),
2258
+ unit: import_zod4.z.string().nullish()
2259
+ })
2260
+ ).nullish()
2261
+ }).passthrough();
2262
+ var takoCardSchema = import_zod4.z.object({
2263
+ card_id: import_zod4.z.string().nullish(),
2264
+ title: import_zod4.z.string().nullish(),
2265
+ description: import_zod4.z.string().nullish(),
2266
+ semantic_description: import_zod4.z.string().nullish(),
2267
+ webpage_url: import_zod4.z.string().nullish(),
2268
+ image_url: import_zod4.z.string().nullish(),
2269
+ embed_url: import_zod4.z.string().nullish(),
2270
+ sources: import_zod4.z.array(
2271
+ import_zod4.z.object({
2272
+ source_name: import_zod4.z.string().nullish(),
2273
+ source_description: import_zod4.z.string().nullish(),
2274
+ source_index: import_zod4.z.enum(["data", "web"]),
2275
+ source_text: import_zod4.z.string().nullish(),
2276
+ url: import_zod4.z.string().nullish()
2277
+ })
2278
+ ).nullish(),
2279
+ methodologies: import_zod4.z.array(
2280
+ import_zod4.z.object({
2281
+ methodology_name: import_zod4.z.string().nullable(),
2282
+ methodology_description: import_zod4.z.string().nullable()
2283
+ })
2284
+ ).nullish(),
2285
+ source_indexes: import_zod4.z.array(import_zod4.z.enum(["data", "web"])).nullish(),
2286
+ card_type: import_zod4.z.string().nullish(),
2287
+ relevance: import_zod4.z.enum(["High", "Low", "Medium"]).nullish(),
2288
+ content: takoResultContentSchema.nullish(),
2289
+ exportable: import_zod4.z.boolean().optional(),
2290
+ relevance_score: import_zod4.z.number().nullish(),
2291
+ nodes: import_zod4.z.array(
2292
+ import_zod4.z.object({
2293
+ id: import_zod4.z.string(),
2294
+ type: import_zod4.z.enum(["entity", "metric"]),
2295
+ name: import_zod4.z.string(),
2296
+ description: import_zod4.z.string().nullish()
2297
+ })
2298
+ ).nullish(),
2299
+ metric_definitions: import_zod4.z.array(import_zod4.z.object({ name: import_zod4.z.string(), definition: import_zod4.z.string() })).nullish(),
2300
+ data_freshness: import_zod4.z.object({
2301
+ coverage_end: import_zod4.z.string().nullish(),
2302
+ data_as_of: import_zod4.z.string().nullish(),
2303
+ last_updated: import_zod4.z.string().nullish()
2304
+ }).nullish()
2305
+ }).passthrough();
2306
+ var takoWebResultSchema = import_zod4.z.object({
2307
+ title: import_zod4.z.string(),
2308
+ url: import_zod4.z.string(),
2309
+ snippet: import_zod4.z.string().nullish(),
2310
+ source_name: import_zod4.z.string().nullish(),
2311
+ publish_date: import_zod4.z.string().nullish(),
2312
+ content: takoResultContentSchema.nullish(),
2313
+ citation_number: import_zod4.z.number().nullish()
2314
+ }).passthrough();
2315
+ var takoSearchOutputSchema = (0, import_provider_utils19.lazySchema)(
2316
+ () => (0, import_provider_utils19.zodSchema)(
2317
+ import_zod4.z.union([
2318
+ import_zod4.z.object({
2319
+ request_id: import_zod4.z.string(),
2320
+ cards: import_zod4.z.array(takoCardSchema).optional(),
2321
+ web_results: import_zod4.z.array(takoWebResultSchema).optional(),
2322
+ usage: import_zod4.z.object({
2323
+ total_cost_usd: import_zod4.z.number(),
2324
+ compute: import_zod4.z.object({ cost_usd: import_zod4.z.number() }).nullish(),
2325
+ data: import_zod4.z.object({ cost_usd: import_zod4.z.number(), datasets: import_zod4.z.number() }).nullish()
2326
+ }).nullish(),
2327
+ related: import_zod4.z.array(import_zod4.z.object({}).passthrough()).nullish()
2328
+ }).passthrough(),
2329
+ import_zod4.z.object({
2330
+ error: import_zod4.z.enum([
2331
+ "api_error",
2332
+ "configuration_error",
2333
+ "execution_error",
2334
+ "invalid_input",
2335
+ "rate_limit",
2336
+ "timeout",
2337
+ "unknown_tool"
2338
+ ]),
2339
+ statusCode: import_zod4.z.number().optional(),
2340
+ message: import_zod4.z.string()
2341
+ })
2342
+ ])
2343
+ )
2344
+ );
2345
+ var takoSearchToolFactory = (0, import_provider_utils19.createProviderToolFactoryWithOutputSchema)({
2346
+ id: "gateway.tako_search",
2347
+ inputSchema: takoSearchInputSchema,
2348
+ outputSchema: takoSearchOutputSchema
2349
+ });
2350
+ var takoSearch = (config = {}) => takoSearchToolFactory(config);
2351
+
2148
2352
  // src/gateway-tools.ts
2149
2353
  var gatewayTools = {
2150
2354
  /**
@@ -2171,7 +2375,16 @@ var gatewayTools = {
2171
2375
  * Provides ranked search results with advanced filtering options including
2172
2376
  * domain, language, date range, and recency filters.
2173
2377
  */
2174
- perplexitySearch
2378
+ perplexitySearch,
2379
+ /**
2380
+ * Search the web and Tako's curated knowledge graph in one call for
2381
+ * token-efficient web excerpts and structured data results grounded in
2382
+ * premium sources, each with an embed-ready visualization.
2383
+ *
2384
+ * Supports effort, per-source web and data controls, localization, and inline
2385
+ * contents for agents that need to reason over underlying data.
2386
+ */
2387
+ takoSearch
2175
2388
  };
2176
2389
 
2177
2390
  // src/vercel-environment.ts
@@ -2183,7 +2396,7 @@ async function getVercelRequestId() {
2183
2396
  }
2184
2397
 
2185
2398
  // src/version.ts
2186
- var VERSION = true ? "3.0.179" : "0.0.0-test";
2399
+ var VERSION = true ? "3.0.180" : "0.0.0-test";
2187
2400
 
2188
2401
  // src/gateway-provider.ts
2189
2402
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
@@ -2193,11 +2406,11 @@ function createGatewayProvider(options = {}) {
2193
2406
  let metadataCache = null;
2194
2407
  const cacheRefreshMillis = (_a11 = options.metadataCacheRefreshMillis) != null ? _a11 : 1e3 * 60 * 5;
2195
2408
  let lastFetchTime = 0;
2196
- const baseURL = (_b11 = (0, import_provider_utils19.withoutTrailingSlash)(options.baseURL)) != null ? _b11 : "https://ai-gateway.vercel.sh/v3/ai";
2409
+ const baseURL = (_b11 = (0, import_provider_utils20.withoutTrailingSlash)(options.baseURL)) != null ? _b11 : "https://ai-gateway.vercel.sh/v3/ai";
2197
2410
  const getHeaders = async () => {
2198
2411
  try {
2199
2412
  const auth = await getGatewayAuthToken(options);
2200
- return (0, import_provider_utils19.withUserAgentSuffix)(
2413
+ return (0, import_provider_utils20.withUserAgentSuffix)(
2201
2414
  {
2202
2415
  Authorization: `Bearer ${auth.token}`,
2203
2416
  "ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
@@ -2216,19 +2429,19 @@ function createGatewayProvider(options = {}) {
2216
2429
  }
2217
2430
  };
2218
2431
  const createO11yHeaders = () => {
2219
- const deploymentId = (0, import_provider_utils19.loadOptionalSetting)({
2432
+ const deploymentId = (0, import_provider_utils20.loadOptionalSetting)({
2220
2433
  settingValue: void 0,
2221
2434
  environmentVariableName: "VERCEL_DEPLOYMENT_ID"
2222
2435
  });
2223
- const environment = (0, import_provider_utils19.loadOptionalSetting)({
2436
+ const environment = (0, import_provider_utils20.loadOptionalSetting)({
2224
2437
  settingValue: void 0,
2225
2438
  environmentVariableName: "VERCEL_ENV"
2226
2439
  });
2227
- const region = (0, import_provider_utils19.loadOptionalSetting)({
2440
+ const region = (0, import_provider_utils20.loadOptionalSetting)({
2228
2441
  settingValue: void 0,
2229
2442
  environmentVariableName: "VERCEL_REGION"
2230
2443
  });
2231
- const projectId = (0, import_provider_utils19.loadOptionalSetting)({
2444
+ const projectId = (0, import_provider_utils20.loadOptionalSetting)({
2232
2445
  settingValue: void 0,
2233
2446
  environmentVariableName: "VERCEL_PROJECT_ID"
2234
2447
  });
@@ -2394,7 +2607,7 @@ function createGatewayProvider(options = {}) {
2394
2607
  }
2395
2608
  var gateway = createGatewayProvider();
2396
2609
  async function getGatewayAuthToken(options) {
2397
- const apiKey = (0, import_provider_utils19.loadOptionalSetting)({
2610
+ const apiKey = (0, import_provider_utils20.loadOptionalSetting)({
2398
2611
  settingValue: options.apiKey,
2399
2612
  environmentVariableName: "AI_GATEWAY_API_KEY"
2400
2613
  });