exa-js 2.18.1 → 2.21.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.
package/dist/index.js CHANGED
@@ -44,9 +44,13 @@ __export(index_exports, {
44
44
  AgentRunEventsClient: () => AgentRunEventsClient,
45
45
  AgentRunFailedError: () => AgentRunFailedError,
46
46
  AgentRunsClient: () => AgentRunsClient,
47
+ AnthropicTools: () => AnthropicTools,
47
48
  BetaClient: () => BetaClient,
48
49
  CreateEnrichmentParametersFormat: () => CreateEnrichmentParametersFormat,
49
50
  CreateImportParametersFormat: () => CreateImportParametersFormat,
51
+ DEFAULT_GET_CONTENTS_TOOL_DESCRIPTION: () => DEFAULT_GET_CONTENTS_TOOL_DESCRIPTION,
52
+ DEFAULT_WEB_SEARCH_TOOL_DESCRIPTION: () => DEFAULT_WEB_SEARCH_TOOL_DESCRIPTION,
53
+ DYNAMIC_HIGHLIGHTS_BETA: () => DYNAMIC_HIGHLIGHTS_BETA,
50
54
  EventType: () => EventType,
51
55
  EventsClient: () => EventsClient,
52
56
  Exa: () => Exa2,
@@ -62,8 +66,11 @@ __export(index_exports, {
62
66
  MonitorRunStatus: () => MonitorRunStatus,
63
67
  MonitorRunType: () => MonitorRunType,
64
68
  MonitorStatus: () => MonitorStatus,
69
+ OpenAIResponsesTools: () => OpenAIResponsesTools,
70
+ OpenAITools: () => OpenAITools,
65
71
  SearchMonitorRunsClient: () => SearchMonitorRunsClient,
66
72
  SearchMonitorsClient: () => SearchMonitorsClient,
73
+ ToolRegistry: () => ToolRegistry,
67
74
  UpdateMonitorStatus: () => UpdateMonitorStatus,
68
75
  WebhookStatus: () => WebhookStatus,
69
76
  WebsetEnrichmentFormat: () => WebsetEnrichmentFormat,
@@ -83,6 +90,8 @@ __export(index_exports, {
83
90
  WebsetStatus: () => WebsetStatus,
84
91
  WebsetWebhooksClient: () => WebsetWebhooksClient,
85
92
  WebsetsClient: () => WebsetsClient,
93
+ createGetContentsTool: () => createGetContentsTool,
94
+ createWebSearchTool: () => createWebSearchTool,
86
95
  default: () => index_default
87
96
  });
88
97
  module.exports = __toCommonJS(index_exports);
@@ -91,7 +100,7 @@ var import_cross_fetch = __toESM(require("cross-fetch"));
91
100
  // package.json
92
101
  var package_default = {
93
102
  name: "exa-js",
94
- version: "2.18.1",
103
+ version: "2.21.0",
95
104
  description: "Exa SDK for Node.js and the browser",
96
105
  publishConfig: {
97
106
  access: "public"
@@ -132,6 +141,7 @@ var package_default = {
132
141
  },
133
142
  license: "MIT",
134
143
  devDependencies: {
144
+ "@anthropic-ai/sdk": "^0.115.0",
135
145
  "@types/node": "~22.14.0",
136
146
  "cross-env": "~7.0.3",
137
147
  "openapi-typescript": "~7.6.1",
@@ -563,6 +573,10 @@ var AgentMonitorsClient = class extends AgentMonitorsBaseClient {
563
573
  }
564
574
  };
565
575
 
576
+ // src/agent/types.ts
577
+ var AGENT_BETA_HEADER = "agent-2026-05-07";
578
+ var AGENT_MAX_EFFORT_BETA = "agent-max-effort-2026-07-27";
579
+
566
580
  // src/agent/client.ts
567
581
  var DEFAULT_AGENT_POLL_INTERVAL_MS = 1e3;
568
582
  var DEFAULT_AGENT_POLL_TIMEOUT_MS = 60 * 60 * 1e3;
@@ -904,6 +918,19 @@ var AgentBetaRunsClient = class extends AgentRunsClient {
904
918
  headersForBetas(options?.betas)
905
919
  );
906
920
  }
921
+ /**
922
+ * Stop a running Agent run, completing it early with the results
923
+ * gathered so far. Only supported for `max` effort runs.
924
+ */
925
+ async stop(runId, options) {
926
+ return this.request(
927
+ `/${runId}/stop`,
928
+ "POST",
929
+ void 0,
930
+ void 0,
931
+ headersForBetas(options?.betas ?? [AGENT_MAX_EFFORT_BETA])
932
+ );
933
+ }
907
934
  async delete(runId, options) {
908
935
  return this.request(
909
936
  `/${runId}`,
@@ -2387,14 +2414,412 @@ var WebsetsClient = class extends WebsetsBaseClient {
2387
2414
  }
2388
2415
  };
2389
2416
 
2390
- // src/agent/types.ts
2391
- var AGENT_BETA_HEADER = "agent-2026-05-07";
2392
- var AGENT_MAX_EFFORT_BETA = "agent-max-effort-2026-07-27";
2417
+ // src/tools/core.ts
2418
+ var import_zod2 = require("zod");
2419
+ var DEFAULT_WEB_SEARCH_TOOL_DESCRIPTION = "Search the web for up-to-date, relevant information. Describe the ideal page rather than listing keywords.";
2420
+ var DEFAULT_GET_CONTENTS_TOOL_DESCRIPTION = "Read the full contents of web pages you already have URLs for, such as pages returned by a search or mentioned by the user.";
2421
+ function formatResults(response, emptyMessage) {
2422
+ const formatted = response.results.map((result) => {
2423
+ const lines = [
2424
+ `Title: ${result.title || "N/A"}`,
2425
+ `URL: ${result.url || "N/A"}`,
2426
+ `Published: ${result.publishedDate || "N/A"}`,
2427
+ `Author: ${result.author || "N/A"}`
2428
+ ];
2429
+ if (result.summary) {
2430
+ lines.push(`Summary: ${result.summary}`);
2431
+ }
2432
+ if (result.highlights && result.highlights.length > 0) {
2433
+ lines.push(`Highlights:
2434
+ ${result.highlights.join("\n")}`);
2435
+ } else if (result.text) {
2436
+ lines.push(`Text: ${result.text}`);
2437
+ }
2438
+ return lines.join("\n");
2439
+ }).join("\n\n---\n\n");
2440
+ return formatted || emptyMessage;
2441
+ }
2442
+ function formatSearchResponse(response) {
2443
+ return formatResults(response, "No search results found.");
2444
+ }
2445
+ function formatContentsResponse(response) {
2446
+ return formatResults(response, "No contents found.");
2447
+ }
2448
+ function registerTool(registry, tool) {
2449
+ registry.register(tool);
2450
+ return tool;
2451
+ }
2452
+ function createTool(registry, params) {
2453
+ const tool = {
2454
+ name: params.name,
2455
+ description: params.description,
2456
+ inputSchema: params.inputSchema,
2457
+ jsonSchema: params.jsonSchema,
2458
+ execute: params.execute,
2459
+ format: params.format,
2460
+ definition: params.definition,
2461
+ async run(args) {
2462
+ try {
2463
+ const parsed = params.inputSchema.parse(args);
2464
+ const result = await params.execute(parsed);
2465
+ return params.format(result);
2466
+ } catch (error) {
2467
+ const message = error instanceof Error ? error.message : String(error);
2468
+ return `Error: ${message}`;
2469
+ }
2470
+ }
2471
+ };
2472
+ return registerTool(registry, tool);
2473
+ }
2474
+ function createWebSearchTool(exa, registry, config = {}) {
2475
+ const {
2476
+ name = "web_search",
2477
+ description = DEFAULT_WEB_SEARCH_TOOL_DESCRIPTION,
2478
+ ...searchOptions
2479
+ } = config;
2480
+ const inputSchema = import_zod2.z.object({
2481
+ query: import_zod2.z.string().describe(
2482
+ "Natural language search query. Should be a semantically rich description of the ideal page, not just keywords."
2483
+ )
2484
+ });
2485
+ const jsonSchema = zodToJsonSchema(inputSchema);
2486
+ delete jsonSchema.$schema;
2487
+ return createTool(registry, {
2488
+ name,
2489
+ description,
2490
+ inputSchema,
2491
+ jsonSchema,
2492
+ definition: {
2493
+ name,
2494
+ description,
2495
+ parameters: jsonSchema
2496
+ },
2497
+ execute: ({ query }) => {
2498
+ const options = {
2499
+ type: "auto",
2500
+ numResults: 10,
2501
+ contents: { highlights: true },
2502
+ ...searchOptions
2503
+ };
2504
+ return exa.search(query, options);
2505
+ },
2506
+ format: formatSearchResponse
2507
+ });
2508
+ }
2509
+ function createGetContentsTool(exa, registry, config = {}) {
2510
+ const {
2511
+ name = "get_contents",
2512
+ description = DEFAULT_GET_CONTENTS_TOOL_DESCRIPTION,
2513
+ ...contentsOptions
2514
+ } = config;
2515
+ const inputSchema = import_zod2.z.object({
2516
+ urls: import_zod2.z.array(import_zod2.z.string()).describe(
2517
+ "Absolute URLs of the pages to read, including the scheme. Pass several URLs to read them in a single call."
2518
+ )
2519
+ });
2520
+ const jsonSchema = zodToJsonSchema(inputSchema);
2521
+ delete jsonSchema.$schema;
2522
+ return createTool(registry, {
2523
+ name,
2524
+ description,
2525
+ inputSchema,
2526
+ jsonSchema,
2527
+ definition: {
2528
+ name,
2529
+ description,
2530
+ parameters: jsonSchema
2531
+ },
2532
+ execute: ({ urls }) => exa.getContents(urls, contentsOptions),
2533
+ format: formatContentsResponse
2534
+ });
2535
+ }
2536
+ var ToolRegistry = class {
2537
+ constructor() {
2538
+ this.registry = /* @__PURE__ */ new Map();
2539
+ }
2540
+ register(tool) {
2541
+ this.registry.set(tool.name, tool);
2542
+ }
2543
+ resolve(tools) {
2544
+ return tools ? new Map(tools.map((tool) => [tool.name, tool])) : new Map(this.registry);
2545
+ }
2546
+ };
2547
+ function getTool(tools, name) {
2548
+ return tools.get(name);
2549
+ }
2550
+ function unknownToolError(name) {
2551
+ return `Error: unknown tool "${name}"`;
2552
+ }
2553
+
2554
+ // src/tools/anthropic.ts
2555
+ var AnthropicTools = class {
2556
+ constructor(exa, registry) {
2557
+ this.exa = exa;
2558
+ this.registry = registry;
2559
+ }
2560
+ /** Anthropic `web_search` tool. Defaults to `auto` + highlights. */
2561
+ webSearch(config) {
2562
+ return runnable(createWebSearchTool(this.exa, this.registry, config));
2563
+ }
2564
+ /** Anthropic `get_contents` tool for reading pages by URL. */
2565
+ getContents(config) {
2566
+ return runnable(createGetContentsTool(this.exa, this.registry, config));
2567
+ }
2568
+ /**
2569
+ * Run the `tool_use` blocks in an assistant message and return the matching
2570
+ * `tool_result` blocks. Every `tool_use` block is answered so the follow-up
2571
+ * request never omits a required result: a block whose name doesn't match a
2572
+ * known tool gets an `Error: unknown tool "<name>"` result. When handling
2573
+ * some tools yourself, replace those error results with your own before
2574
+ * sending the next request.
2575
+ */
2576
+ async handleToolUse(message, options) {
2577
+ const tools = this.registry.resolve(options?.tools);
2578
+ const blocks = (message.content ?? []).filter(isAnthropicToolUse);
2579
+ return Promise.all(
2580
+ blocks.map(async (block) => {
2581
+ const tool = getTool(tools, block.name);
2582
+ return {
2583
+ type: "tool_result",
2584
+ tool_use_id: block.id,
2585
+ content: tool ? await tool.run(block.input) : unknownToolError(block.name)
2586
+ };
2587
+ })
2588
+ );
2589
+ }
2590
+ };
2591
+ function isAnthropicToolUse(value) {
2592
+ if (!value || typeof value !== "object") return false;
2593
+ const block = value;
2594
+ return block.type === "tool_use" && typeof block.id === "string" && typeof block.name === "string";
2595
+ }
2596
+ function runnable(tool) {
2597
+ const definition = {
2598
+ type: "custom",
2599
+ name: tool.name,
2600
+ description: tool.description,
2601
+ input_schema: tool.jsonSchema,
2602
+ parse: (input) => tool.inputSchema.parse(input),
2603
+ run: (args) => tool.run(args)
2604
+ };
2605
+ Object.defineProperties(definition, {
2606
+ parse: { enumerable: false },
2607
+ run: { enumerable: false }
2608
+ });
2609
+ Object.defineProperties(
2610
+ definition,
2611
+ Object.fromEntries(
2612
+ Object.entries(tool).filter(([key]) => !["name", "description"].includes(key)).map(([key, value]) => [
2613
+ key,
2614
+ { value, enumerable: false, configurable: true }
2615
+ ])
2616
+ )
2617
+ );
2618
+ Object.defineProperty(definition, "type", {
2619
+ value: "custom",
2620
+ enumerable: false,
2621
+ configurable: true
2622
+ });
2623
+ Object.defineProperty(definition, "definition", {
2624
+ value: {
2625
+ name: tool.name,
2626
+ description: tool.description,
2627
+ input_schema: tool.jsonSchema
2628
+ },
2629
+ enumerable: false
2630
+ });
2631
+ return definition;
2632
+ }
2633
+
2634
+ // src/tools/openai.ts
2635
+ function runnable2(tool) {
2636
+ const functionDefinition = {
2637
+ ...tool.definition,
2638
+ parse: (input) => JSON.parse(input),
2639
+ function: (args) => tool.run(args)
2640
+ };
2641
+ Object.defineProperties(functionDefinition, {
2642
+ parse: { enumerable: false },
2643
+ function: { enumerable: false }
2644
+ });
2645
+ const definition = {
2646
+ type: "function",
2647
+ function: functionDefinition
2648
+ };
2649
+ Object.defineProperties(
2650
+ definition,
2651
+ Object.fromEntries(
2652
+ Object.entries(tool).filter(([key]) => !["name", "description"].includes(key)).map(([key, value]) => [
2653
+ key,
2654
+ { value, enumerable: false, configurable: true }
2655
+ ])
2656
+ )
2657
+ );
2658
+ Object.defineProperties(definition, {
2659
+ name: {
2660
+ value: tool.name,
2661
+ enumerable: false,
2662
+ configurable: true
2663
+ },
2664
+ description: {
2665
+ value: tool.description,
2666
+ enumerable: false,
2667
+ configurable: true
2668
+ }
2669
+ });
2670
+ Object.defineProperty(definition, "definition", {
2671
+ value: {
2672
+ type: "function",
2673
+ function: {
2674
+ name: tool.name,
2675
+ description: tool.description,
2676
+ parameters: tool.jsonSchema
2677
+ }
2678
+ },
2679
+ enumerable: false,
2680
+ configurable: true
2681
+ });
2682
+ return definition;
2683
+ }
2684
+ var OpenAIResponsesTools = class {
2685
+ constructor(exa, registry, handleResponses) {
2686
+ this.exa = exa;
2687
+ this.registry = registry;
2688
+ this.handleResponses = handleResponses;
2689
+ }
2690
+ /** Responses API `web_search` tool. Defaults to `auto` + highlights. */
2691
+ webSearch(config) {
2692
+ return responsesRunnable(
2693
+ createWebSearchTool(this.exa, this.registry, config)
2694
+ );
2695
+ }
2696
+ /** Responses API `get_contents` tool for reading pages by URL. */
2697
+ getContents(config) {
2698
+ return responsesRunnable(
2699
+ createGetContentsTool(this.exa, this.registry, config)
2700
+ );
2701
+ }
2702
+ /**
2703
+ * Run the function calls in a Responses API response (or output item array)
2704
+ * and return `function_call_output` items. Every function call is answered
2705
+ * so the follow-up request never omits a required output: a call whose name
2706
+ * doesn't match a known tool gets an `Error: unknown tool "<name>"` output.
2707
+ * When handling some tools yourself, replace those error outputs with your
2708
+ * own results before sending the next request.
2709
+ */
2710
+ async handleToolCalls(responseOrOutputItems, options) {
2711
+ return this.handleResponses(responseOrOutputItems, options);
2712
+ }
2713
+ };
2714
+ function responsesRunnable(tool) {
2715
+ const definition = {
2716
+ type: "function",
2717
+ name: tool.name,
2718
+ description: tool.description,
2719
+ parameters: tool.jsonSchema,
2720
+ strict: false
2721
+ };
2722
+ Object.defineProperties(
2723
+ definition,
2724
+ Object.fromEntries(
2725
+ Object.entries(tool).filter(([key]) => !["name", "description"].includes(key)).map(([key, value]) => [
2726
+ key,
2727
+ { value, enumerable: false, configurable: true }
2728
+ ])
2729
+ )
2730
+ );
2731
+ Object.defineProperty(definition, "definition", {
2732
+ value: {
2733
+ ...tool.definition,
2734
+ type: "function",
2735
+ parameters: tool.jsonSchema,
2736
+ strict: false
2737
+ },
2738
+ enumerable: false
2739
+ });
2740
+ return definition;
2741
+ }
2742
+ var OpenAITools = class {
2743
+ constructor(exa, registry) {
2744
+ this.exa = exa;
2745
+ this.registry = registry;
2746
+ this.responses = new OpenAIResponsesTools(
2747
+ exa,
2748
+ registry,
2749
+ (responseOrOutputItems, options) => this.handleResponsesToolCalls(responseOrOutputItems, options)
2750
+ );
2751
+ }
2752
+ /** Chat Completions `web_search` tool. Defaults to `auto` + highlights. */
2753
+ webSearch(config) {
2754
+ return runnable2(createWebSearchTool(this.exa, this.registry, config));
2755
+ }
2756
+ /** Chat Completions `get_contents` tool for reading pages by URL. */
2757
+ getContents(config) {
2758
+ return runnable2(createGetContentsTool(this.exa, this.registry, config));
2759
+ }
2760
+ async handleToolCalls(assistantMessage, options) {
2761
+ if (isResponsesInput(assistantMessage)) {
2762
+ return this.handleResponsesToolCalls(assistantMessage, options);
2763
+ }
2764
+ return this.handleChatToolCalls(assistantMessage, options);
2765
+ }
2766
+ async handleChatToolCalls(assistantMessage, options) {
2767
+ const tools = this.registry.resolve(options?.tools);
2768
+ const calls = (assistantMessage.tool_calls ?? []).filter(isOpenAIToolCall);
2769
+ return Promise.all(
2770
+ calls.map(async (call) => {
2771
+ const tool = getTool(tools, call.function.name);
2772
+ return {
2773
+ role: "tool",
2774
+ tool_call_id: call.id,
2775
+ content: tool ? await tool.run(parseArguments(call.function.arguments)) : unknownToolError(call.function.name)
2776
+ };
2777
+ })
2778
+ );
2779
+ }
2780
+ async handleResponsesToolCalls(responseOrOutputItems, options) {
2781
+ const tools = this.registry.resolve(options?.tools);
2782
+ const rawItems = !Array.isArray(responseOrOutputItems) && "output" in responseOrOutputItems ? responseOrOutputItems.output ?? [] : responseOrOutputItems;
2783
+ const items = rawItems.filter(isResponsesFunctionCall);
2784
+ return Promise.all(
2785
+ items.map(async (call) => {
2786
+ const tool = getTool(tools, call.name);
2787
+ return {
2788
+ type: "function_call_output",
2789
+ call_id: call.call_id,
2790
+ output: tool ? await tool.run(parseArguments(call.arguments)) : unknownToolError(call.name)
2791
+ };
2792
+ })
2793
+ );
2794
+ }
2795
+ };
2796
+ function parseArguments(argumentsText) {
2797
+ try {
2798
+ return JSON.parse(argumentsText);
2799
+ } catch {
2800
+ return argumentsText;
2801
+ }
2802
+ }
2803
+ function isOpenAIToolCall(value) {
2804
+ if (!value || typeof value !== "object") return false;
2805
+ const call = value;
2806
+ return typeof call.id === "string" && !!call.function && typeof call.function.name === "string" && typeof call.function.arguments === "string";
2807
+ }
2808
+ function isResponsesFunctionCall(value) {
2809
+ if (!value || typeof value !== "object") return false;
2810
+ const call = value;
2811
+ return call.type === "function_call" && typeof call.call_id === "string" && typeof call.name === "string" && typeof call.arguments === "string";
2812
+ }
2813
+ function isResponsesInput(value) {
2814
+ if (Array.isArray(value)) return value.some(isResponsesFunctionCall);
2815
+ return "output" in value;
2816
+ }
2393
2817
 
2394
2818
  // src/index.ts
2395
2819
  var fetchImpl = typeof global !== "undefined" && global.fetch ? global.fetch : import_cross_fetch.default;
2396
2820
  var HeadersImpl = typeof global !== "undefined" && global.Headers ? global.Headers : import_cross_fetch.Headers;
2397
2821
  var DEFAULT_MAX_CHARACTERS = 1e4;
2822
+ var DYNAMIC_HIGHLIGHTS_BETA = "dynamic-highlights-2026-08-28";
2398
2823
  var NON_JSON_BODY_SNIPPET_LENGTH = 500;
2399
2824
  async function readResponseBody(response) {
2400
2825
  const text = await response.text();
@@ -2412,6 +2837,40 @@ function truncateResponseBody(text) {
2412
2837
  return collapsed.length > NON_JSON_BODY_SNIPPET_LENGTH ? `${collapsed.slice(0, NON_JSON_BODY_SNIPPET_LENGTH)}\u2026` : collapsed;
2413
2838
  }
2414
2839
  var Exa2 = class {
2840
+ /**
2841
+ * Constructs the Exa API client.
2842
+ * @param {string} apiKey - The API key for authentication.
2843
+ * @param {string} [baseURL] - The base URL of the Exa API.
2844
+ */
2845
+ constructor(apiKey, baseURL = "https://api.exa.ai") {
2846
+ this.toolRegistry = new ToolRegistry();
2847
+ this.baseURL = baseURL;
2848
+ if (!apiKey) {
2849
+ apiKey = process.env.EXA_API_KEY;
2850
+ if (!apiKey) {
2851
+ throw new ExaError(
2852
+ "API key must be provided as an argument or as an environment variable (EXA_API_KEY)",
2853
+ 401 /* Unauthorized */
2854
+ );
2855
+ }
2856
+ }
2857
+ this.headers = new HeadersImpl({
2858
+ "x-api-key": apiKey,
2859
+ "Content-Type": "application/json",
2860
+ "User-Agent": `exa-node ${package_default.version}`
2861
+ });
2862
+ this.websets = new WebsetsClient(this);
2863
+ this.research = new ResearchClient(this);
2864
+ this.monitors = new SearchMonitorsClient(this);
2865
+ this.agent = new AgentClient(this);
2866
+ this.beta = new BetaClient(this.agent);
2867
+ this.tools = {
2868
+ webSearch: (options) => createWebSearchTool(this, this.toolRegistry, options),
2869
+ getContents: (options) => createGetContentsTool(this, this.toolRegistry, options)
2870
+ };
2871
+ this.openai = new OpenAITools(this, this.toolRegistry);
2872
+ this.anthropic = new AnthropicTools(this, this.toolRegistry);
2873
+ }
2415
2874
  /**
2416
2875
  * Helper method to separate out the contents-specific options from the rest.
2417
2876
  */
@@ -2463,6 +2922,7 @@ var Exa2 = class {
2463
2922
  buildSearchRequestBody(query, options) {
2464
2923
  const requestOptions = { ...options ?? {} };
2465
2924
  delete requestOptions.stream;
2925
+ delete requestOptions.betas;
2466
2926
  if (options === void 0 || !("contents" in options)) {
2467
2927
  return {
2468
2928
  query,
@@ -2476,33 +2936,6 @@ var Exa2 = class {
2476
2936
  }
2477
2937
  return { query, ...requestOptions };
2478
2938
  }
2479
- /**
2480
- * Constructs the Exa API client.
2481
- * @param {string} apiKey - The API key for authentication.
2482
- * @param {string} [baseURL] - The base URL of the Exa API.
2483
- */
2484
- constructor(apiKey, baseURL = "https://api.exa.ai") {
2485
- this.baseURL = baseURL;
2486
- if (!apiKey) {
2487
- apiKey = process.env.EXA_API_KEY;
2488
- if (!apiKey) {
2489
- throw new ExaError(
2490
- "API key must be provided as an argument or as an environment variable (EXA_API_KEY)",
2491
- 401 /* Unauthorized */
2492
- );
2493
- }
2494
- }
2495
- this.headers = new HeadersImpl({
2496
- "x-api-key": apiKey,
2497
- "Content-Type": "application/json",
2498
- "User-Agent": `exa-node ${package_default.version}`
2499
- });
2500
- this.websets = new WebsetsClient(this);
2501
- this.research = new ResearchClient(this);
2502
- this.monitors = new SearchMonitorsClient(this);
2503
- this.agent = new AgentClient(this);
2504
- this.beta = new BetaClient(this.agent);
2505
- }
2506
2939
  /**
2507
2940
  * Makes a request to the Exa API.
2508
2941
  * @param {string} endpoint - The API endpoint to call.
@@ -2643,11 +3076,9 @@ var Exa2 = class {
2643
3076
  400 /* BadRequest */
2644
3077
  );
2645
3078
  }
2646
- return await this.request(
2647
- "/search",
2648
- "POST",
2649
- this.buildSearchRequestBody(query, options)
2650
- );
3079
+ const body = this.buildSearchRequestBody(query, options);
3080
+ const betaHeaders = headersForBetas(options?.betas);
3081
+ return betaHeaders ? await this.request("/search", "POST", body, void 0, betaHeaders) : await this.request("/search", "POST", body);
2651
3082
  }
2652
3083
  /**
2653
3084
  * Stream a search response as an async generator of OpenAI-style chat completion chunks.
@@ -2754,11 +3185,13 @@ var Exa2 = class {
2754
3185
  } else {
2755
3186
  requestUrls = urls.map((result) => result.url);
2756
3187
  }
3188
+ const { betas, ...contentsOptions } = options ?? {};
2757
3189
  const payload = {
2758
3190
  urls: requestUrls,
2759
- ...options
3191
+ ...contentsOptions
2760
3192
  };
2761
- return await this.request("/contents", "POST", payload);
3193
+ const betaHeaders = headersForBetas(betas);
3194
+ return betaHeaders ? await this.request("/contents", "POST", payload, void 0, betaHeaders) : await this.request("/contents", "POST", payload);
2762
3195
  }
2763
3196
  async answer(query, options) {
2764
3197
  if (options?.stream) {
@@ -2963,9 +3396,13 @@ var index_default = Exa2;
2963
3396
  AgentRunEventsClient,
2964
3397
  AgentRunFailedError,
2965
3398
  AgentRunsClient,
3399
+ AnthropicTools,
2966
3400
  BetaClient,
2967
3401
  CreateEnrichmentParametersFormat,
2968
3402
  CreateImportParametersFormat,
3403
+ DEFAULT_GET_CONTENTS_TOOL_DESCRIPTION,
3404
+ DEFAULT_WEB_SEARCH_TOOL_DESCRIPTION,
3405
+ DYNAMIC_HIGHLIGHTS_BETA,
2969
3406
  EventType,
2970
3407
  EventsClient,
2971
3408
  Exa,
@@ -2981,8 +3418,11 @@ var index_default = Exa2;
2981
3418
  MonitorRunStatus,
2982
3419
  MonitorRunType,
2983
3420
  MonitorStatus,
3421
+ OpenAIResponsesTools,
3422
+ OpenAITools,
2984
3423
  SearchMonitorRunsClient,
2985
3424
  SearchMonitorsClient,
3425
+ ToolRegistry,
2986
3426
  UpdateMonitorStatus,
2987
3427
  WebhookStatus,
2988
3428
  WebsetEnrichmentFormat,
@@ -3001,6 +3441,8 @@ var index_default = Exa2;
3001
3441
  WebsetSearchesClient,
3002
3442
  WebsetStatus,
3003
3443
  WebsetWebhooksClient,
3004
- WebsetsClient
3444
+ WebsetsClient,
3445
+ createGetContentsTool,
3446
+ createWebSearchTool
3005
3447
  });
3006
3448
  //# sourceMappingURL=index.js.map