exa-js 2.21.0 → 2.22.1

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.21.0",
7
+ version: "2.22.1",
8
8
  description: "Exa SDK for Node.js and the browser",
9
9
  publishConfig: {
10
10
  access: "public"
@@ -214,13 +214,13 @@ var AgentMonitorsBaseClient = class {
214
214
  };
215
215
 
216
216
  // src/agent/monitors/client.ts
217
- var DEFAULT_SNAPSHOT_POLL_INTERVAL_MS = 2e3;
218
- var DEFAULT_SNAPSHOT_POLL_TIMEOUT_MS = 60 * 60 * 1e3;
219
- var AgentMonitorSnapshotFailedError = class extends Error {
220
- constructor(snapshot) {
221
- super(snapshot.error ?? `Agent monitor snapshot ${snapshot.id} failed`);
222
- this.name = "AgentMonitorSnapshotFailedError";
223
- this.snapshot = snapshot;
217
+ var DEFAULT_BACKTEST_POLL_INTERVAL_MS = 2e3;
218
+ var DEFAULT_BACKTEST_POLL_TIMEOUT_MS = 60 * 60 * 1e3;
219
+ var AgentMonitorBacktestFailedError = class extends Error {
220
+ constructor(backtest) {
221
+ super(backtest.error ?? `Agent monitor backtest ${backtest.id} failed`);
222
+ this.name = "AgentMonitorBacktestFailedError";
223
+ this.backtest = backtest;
224
224
  }
225
225
  };
226
226
  var AgentMonitorEntitiesClient = class extends AgentMonitorsBaseClient {
@@ -330,66 +330,66 @@ var AgentMonitorChangesClient = class extends AgentMonitorsBaseClient {
330
330
  return changes;
331
331
  }
332
332
  };
333
- var AgentMonitorSnapshotsClient = class extends AgentMonitorsBaseClient {
333
+ var AgentMonitorBacktestsClient = class extends AgentMonitorsBaseClient {
334
334
  /**
335
- * Start an async, stateless snapshot of entities × fields over an explicit
336
- * past news window — no monitor is created. Returns a `running` job; poll
337
- * with `get` (or use `createAndWait`) for the result.
335
+ * Start an async backtest of entities × fields over an explicit past news
336
+ * window. Returns a `running` job; poll with `get` (or use `createAndWait`)
337
+ * for the result.
338
338
  */
339
339
  async create(params) {
340
340
  const { betas, ...payload } = params;
341
341
  return this.request(
342
- "/snapshot",
342
+ "/backtest",
343
343
  betas,
344
344
  "POST",
345
345
  payload
346
346
  );
347
347
  }
348
348
  /**
349
- * Poll a snapshot job for its status and, once completed, its result.
349
+ * Poll a backtest job for its status and, once completed, its result.
350
350
  * Jobs expire and read as 404 after `expiresAt`.
351
351
  */
352
- async get(snapshotId, options) {
352
+ async get(backtestId, options) {
353
353
  return this.request(
354
- `/snapshot/${snapshotId}`,
354
+ `/backtest/${backtestId}`,
355
355
  options.betas,
356
356
  "GET"
357
357
  );
358
358
  }
359
359
  /**
360
- * Poll a snapshot job until it reaches a terminal status.
360
+ * Poll a backtest job until it reaches a terminal status.
361
361
  */
362
- async pollUntilFinished(snapshotId, options) {
363
- const pollInterval = options.pollInterval ?? DEFAULT_SNAPSHOT_POLL_INTERVAL_MS;
364
- const timeoutMs = options.timeoutMs ?? DEFAULT_SNAPSHOT_POLL_TIMEOUT_MS;
362
+ async pollUntilFinished(backtestId, options) {
363
+ const pollInterval = options.pollInterval ?? DEFAULT_BACKTEST_POLL_INTERVAL_MS;
364
+ const timeoutMs = options.timeoutMs ?? DEFAULT_BACKTEST_POLL_TIMEOUT_MS;
365
365
  const startTime = Date.now();
366
366
  while (true) {
367
- const snapshot = await this.get(snapshotId, { betas: options.betas });
368
- if (snapshot.status !== "running") {
369
- return snapshot;
367
+ const backtest = await this.get(backtestId, { betas: options.betas });
368
+ if (backtest.status !== "running") {
369
+ return backtest;
370
370
  }
371
371
  if (Date.now() - startTime > timeoutMs) {
372
372
  throw new Error(
373
- `Polling timeout: Agent monitor snapshot ${snapshotId} did not complete within ${timeoutMs}ms`
373
+ `Polling timeout: Agent monitor backtest ${backtestId} did not complete within ${timeoutMs}ms`
374
374
  );
375
375
  }
376
376
  await new Promise((resolve) => setTimeout(resolve, pollInterval));
377
377
  }
378
378
  }
379
379
  /**
380
- * Start a snapshot and wait for its result. Throws
381
- * AgentMonitorSnapshotFailedError if the snapshot fails.
380
+ * Start a backtest and wait for its result. Throws
381
+ * AgentMonitorBacktestFailedError if the backtest fails.
382
382
  */
383
383
  async createAndWait(params, options) {
384
- const snapshot = await this.create(params);
385
- const terminalSnapshot = snapshot.status === "running" ? await this.pollUntilFinished(snapshot.id, {
384
+ const backtest = await this.create(params);
385
+ const terminalBacktest = backtest.status === "running" ? await this.pollUntilFinished(backtest.id, {
386
386
  ...options,
387
387
  betas: params.betas
388
- }) : snapshot;
389
- if (terminalSnapshot.status === "failed") {
390
- throw new AgentMonitorSnapshotFailedError(terminalSnapshot);
388
+ }) : backtest;
389
+ if (terminalBacktest.status === "failed") {
390
+ throw new AgentMonitorBacktestFailedError(terminalBacktest);
391
391
  }
392
- return terminalSnapshot;
392
+ return terminalBacktest;
393
393
  }
394
394
  };
395
395
  var AgentMonitorsClient = class extends AgentMonitorsBaseClient {
@@ -397,7 +397,7 @@ var AgentMonitorsClient = class extends AgentMonitorsBaseClient {
397
397
  super(client);
398
398
  this.entities = new AgentMonitorEntitiesClient(client);
399
399
  this.changes = new AgentMonitorChangesClient(client);
400
- this.snapshots = new AgentMonitorSnapshotsClient(client);
400
+ this.backtests = new AgentMonitorBacktestsClient(client);
401
401
  }
402
402
  /**
403
403
  * Create an Agent Monitor from its entities, fields, and cadence.
@@ -2789,6 +2789,7 @@ var Exa2 = class {
2789
2789
  livecrawl,
2790
2790
  livecrawlTimeout,
2791
2791
  maxAgeHours,
2792
+ snapshotAsOf,
2792
2793
  // DEPRECATED FIELD: preserve legacy `context` only for backward compatibility.
2793
2794
  context,
2794
2795
  ...rest
@@ -2817,6 +2818,8 @@ var Exa2 = class {
2817
2818
  if (livecrawlTimeout !== void 0)
2818
2819
  contentsOptions.livecrawlTimeout = livecrawlTimeout;
2819
2820
  if (maxAgeHours !== void 0) contentsOptions.maxAgeHours = maxAgeHours;
2821
+ if (snapshotAsOf !== void 0)
2822
+ contentsOptions.snapshotAsOf = snapshotAsOf;
2820
2823
  if (context !== void 0) contentsOptions.context = context;
2821
2824
  return {
2822
2825
  contentsOptions,
@@ -3290,10 +3293,10 @@ export {
3290
3293
  AGENT_MONITORS_BETA_HEADER,
3291
3294
  AgentBetaClient,
3292
3295
  AgentClient,
3296
+ AgentMonitorBacktestFailedError,
3297
+ AgentMonitorBacktestsClient,
3293
3298
  AgentMonitorChangesClient,
3294
3299
  AgentMonitorEntitiesClient,
3295
- AgentMonitorSnapshotFailedError,
3296
- AgentMonitorSnapshotsClient,
3297
3300
  AgentMonitorsClient,
3298
3301
  AgentRunCancelledError,
3299
3302
  AgentRunEventsClient,