exa-js 2.22.2 → 2.24.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.mjs CHANGED
@@ -4,7 +4,7 @@ import fetch2, { Headers } from "cross-fetch";
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "exa-js",
7
- version: "2.22.2",
7
+ version: "2.24.0",
8
8
  description: "Exa SDK for Node.js and the browser",
9
9
  publishConfig: {
10
10
  access: "public"
@@ -672,6 +672,13 @@ var AgentRunsClient = class extends AgentBaseClient {
672
672
  async cancel(runId) {
673
673
  return this.request(`/${runId}/cancel`, "POST");
674
674
  }
675
+ /**
676
+ * Stop a running Agent run, completing it early with the results
677
+ * gathered so far. Only supported for `ultra` effort runs.
678
+ */
679
+ async stop(runId) {
680
+ return this.request(`/${runId}/stop`, "POST");
681
+ }
675
682
  /**
676
683
  * Delete a stored Agent run.
677
684
  */
@@ -824,7 +831,7 @@ var AgentBetaRunsClient = class extends AgentRunsClient {
824
831
  }
825
832
  /**
826
833
  * Stop a running Agent run, completing it early with the results
827
- * gathered so far. Only supported for `max` effort runs.
834
+ * gathered so far. Only supported for `ultra` effort runs.
828
835
  */
829
836
  async stop(runId, options) {
830
837
  return this.request(
@@ -2324,6 +2331,8 @@ var WebsetsClient = class extends WebsetsBaseClient {
2324
2331
  import { z } from "zod";
2325
2332
  var DEFAULT_WEB_SEARCH_TOOL_DESCRIPTION = "Search the web for up-to-date, relevant information. Describe the ideal page rather than listing keywords.";
2326
2333
  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.";
2334
+ var SEARCH_OBJECTIVE_TOOL_DESCRIPTION = "Goal for this search turn; say which documents should rank first, which should be excluded, and what specific facts or figures to pull from them.";
2335
+ var MAX_OBJECTIVE_LENGTH = 4096;
2327
2336
  function formatResults(response, emptyMessage) {
2328
2337
  const formatted = response.results.map((result) => {
2329
2338
  const lines = [
@@ -2377,6 +2386,17 @@ function createTool(registry, params) {
2377
2386
  };
2378
2387
  return registerTool(registry, tool);
2379
2388
  }
2389
+ var AdvertisedRequiredOptional = class extends z.ZodOptional {
2390
+ isOptional() {
2391
+ return false;
2392
+ }
2393
+ };
2394
+ function advertisedRequired(inner) {
2395
+ return new AdvertisedRequiredOptional({
2396
+ innerType: inner,
2397
+ typeName: z.ZodFirstPartyTypeKind.ZodOptional
2398
+ });
2399
+ }
2380
2400
  function createWebSearchTool(exa, registry, config = {}) {
2381
2401
  const {
2382
2402
  name = "web_search",
@@ -2386,7 +2406,15 @@ function createWebSearchTool(exa, registry, config = {}) {
2386
2406
  const inputSchema = z.object({
2387
2407
  query: z.string().describe(
2388
2408
  "Natural language search query. Should be a semantically rich description of the ideal page, not just keywords."
2389
- )
2409
+ ),
2410
+ // Length limits are validated but not advertised: strict tool use on some
2411
+ // providers rejects `minLength`/`maxLength` in the schema.
2412
+ objective: advertisedRequired(
2413
+ z.string().trim().refine((value) => value.length > 0, "objective must not be empty").refine(
2414
+ (value) => value.length <= MAX_OBJECTIVE_LENGTH,
2415
+ `objective must be at most ${MAX_OBJECTIVE_LENGTH} characters`
2416
+ )
2417
+ ).describe(SEARCH_OBJECTIVE_TOOL_DESCRIPTION)
2390
2418
  });
2391
2419
  const jsonSchema = zodToJsonSchema(inputSchema);
2392
2420
  delete jsonSchema.$schema;
@@ -2400,12 +2428,13 @@ function createWebSearchTool(exa, registry, config = {}) {
2400
2428
  description,
2401
2429
  parameters: jsonSchema
2402
2430
  },
2403
- execute: ({ query }) => {
2431
+ execute: ({ query, objective }) => {
2404
2432
  const options = {
2405
2433
  type: "auto",
2406
2434
  numResults: 10,
2407
2435
  contents: { highlights: true },
2408
- ...searchOptions
2436
+ ...searchOptions,
2437
+ ...objective !== void 0 && { objective }
2409
2438
  };
2410
2439
  return exa.search(query, options);
2411
2440
  },
@@ -3328,6 +3357,7 @@ export {
3328
3357
  MonitorStatus,
3329
3358
  OpenAIResponsesTools,
3330
3359
  OpenAITools,
3360
+ SEARCH_OBJECTIVE_TOOL_DESCRIPTION,
3331
3361
  SearchMonitorRunsClient,
3332
3362
  SearchMonitorsClient,
3333
3363
  ToolRegistry,