exa-js 1.7.3 → 1.8.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/README.md +7 -8
- package/dist/index.d.mts +521 -136
- package/dist/index.d.ts +521 -136
- package/dist/index.js +192 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +188 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -242,10 +242,6 @@ var CreateEnrichmentParametersFormat = /* @__PURE__ */ ((CreateEnrichmentParamet
|
|
|
242
242
|
CreateEnrichmentParametersFormat2["phone"] = "phone";
|
|
243
243
|
return CreateEnrichmentParametersFormat2;
|
|
244
244
|
})(CreateEnrichmentParametersFormat || {});
|
|
245
|
-
var CreateWebsetSearchParametersBehaviour = /* @__PURE__ */ ((CreateWebsetSearchParametersBehaviour2) => {
|
|
246
|
-
CreateWebsetSearchParametersBehaviour2["override"] = "override";
|
|
247
|
-
return CreateWebsetSearchParametersBehaviour2;
|
|
248
|
-
})(CreateWebsetSearchParametersBehaviour || {});
|
|
249
245
|
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
250
246
|
EventType2["webset_created"] = "webset.created";
|
|
251
247
|
EventType2["webset_deleted"] = "webset.deleted";
|
|
@@ -261,6 +257,11 @@ var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
|
261
257
|
EventType2["webset_item_enriched"] = "webset.item.enriched";
|
|
262
258
|
return EventType2;
|
|
263
259
|
})(EventType || {});
|
|
260
|
+
var UpdateStreamStatus = /* @__PURE__ */ ((UpdateStreamStatus2) => {
|
|
261
|
+
UpdateStreamStatus2["open"] = "open";
|
|
262
|
+
UpdateStreamStatus2["closed"] = "closed";
|
|
263
|
+
return UpdateStreamStatus2;
|
|
264
|
+
})(UpdateStreamStatus || {});
|
|
264
265
|
var WebhookStatus = /* @__PURE__ */ ((WebhookStatus2) => {
|
|
265
266
|
WebhookStatus2["active"] = "active";
|
|
266
267
|
WebhookStatus2["inactive"] = "inactive";
|
|
@@ -289,6 +290,7 @@ var WebsetEnrichmentFormat = /* @__PURE__ */ ((WebsetEnrichmentFormat2) => {
|
|
|
289
290
|
})(WebsetEnrichmentFormat || {});
|
|
290
291
|
var WebsetItemSource = /* @__PURE__ */ ((WebsetItemSource2) => {
|
|
291
292
|
WebsetItemSource2["search"] = "search";
|
|
293
|
+
WebsetItemSource2["import"] = "import";
|
|
292
294
|
return WebsetItemSource2;
|
|
293
295
|
})(WebsetItemSource || {});
|
|
294
296
|
var WebsetItemEvaluationSatisfied = /* @__PURE__ */ ((WebsetItemEvaluationSatisfied2) => {
|
|
@@ -297,11 +299,6 @@ var WebsetItemEvaluationSatisfied = /* @__PURE__ */ ((WebsetItemEvaluationSatisf
|
|
|
297
299
|
WebsetItemEvaluationSatisfied2["unclear"] = "unclear";
|
|
298
300
|
return WebsetItemEvaluationSatisfied2;
|
|
299
301
|
})(WebsetItemEvaluationSatisfied || {});
|
|
300
|
-
var WebsetSearchCanceledReason = /* @__PURE__ */ ((WebsetSearchCanceledReason2) => {
|
|
301
|
-
WebsetSearchCanceledReason2["webset_deleted"] = "webset_deleted";
|
|
302
|
-
WebsetSearchCanceledReason2["webset_canceled"] = "webset_canceled";
|
|
303
|
-
return WebsetSearchCanceledReason2;
|
|
304
|
-
})(WebsetSearchCanceledReason || {});
|
|
305
302
|
var WebsetSearchStatus = /* @__PURE__ */ ((WebsetSearchStatus2) => {
|
|
306
303
|
WebsetSearchStatus2["created"] = "created";
|
|
307
304
|
WebsetSearchStatus2["running"] = "running";
|
|
@@ -309,6 +306,16 @@ var WebsetSearchStatus = /* @__PURE__ */ ((WebsetSearchStatus2) => {
|
|
|
309
306
|
WebsetSearchStatus2["canceled"] = "canceled";
|
|
310
307
|
return WebsetSearchStatus2;
|
|
311
308
|
})(WebsetSearchStatus || {});
|
|
309
|
+
var WebsetSearchBehavior = /* @__PURE__ */ ((WebsetSearchBehavior2) => {
|
|
310
|
+
WebsetSearchBehavior2["override"] = "override";
|
|
311
|
+
WebsetSearchBehavior2["append"] = "append";
|
|
312
|
+
return WebsetSearchBehavior2;
|
|
313
|
+
})(WebsetSearchBehavior || {});
|
|
314
|
+
var WebsetSearchCanceledReason = /* @__PURE__ */ ((WebsetSearchCanceledReason2) => {
|
|
315
|
+
WebsetSearchCanceledReason2["webset_deleted"] = "webset_deleted";
|
|
316
|
+
WebsetSearchCanceledReason2["webset_canceled"] = "webset_canceled";
|
|
317
|
+
return WebsetSearchCanceledReason2;
|
|
318
|
+
})(WebsetSearchCanceledReason || {});
|
|
312
319
|
|
|
313
320
|
// src/websets/searches.ts
|
|
314
321
|
var WebsetSearchesClient = class extends WebsetsBaseClient {
|
|
@@ -351,6 +358,94 @@ var WebsetSearchesClient = class extends WebsetsBaseClient {
|
|
|
351
358
|
}
|
|
352
359
|
};
|
|
353
360
|
|
|
361
|
+
// src/websets/streams.ts
|
|
362
|
+
var WebsetStreamRunsClient = class extends WebsetsBaseClient {
|
|
363
|
+
/**
|
|
364
|
+
* List all runs for a Stream
|
|
365
|
+
* @param streamId The ID of the Stream
|
|
366
|
+
* @param options Pagination options
|
|
367
|
+
* @returns The list of Stream runs
|
|
368
|
+
*/
|
|
369
|
+
async list(streamId, options) {
|
|
370
|
+
const params = this.buildPaginationParams(options);
|
|
371
|
+
return this.request(
|
|
372
|
+
`/v0/streams/${streamId}/runs`,
|
|
373
|
+
"GET",
|
|
374
|
+
void 0,
|
|
375
|
+
params
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Get a specific Stream run
|
|
380
|
+
* @param streamId The ID of the Stream
|
|
381
|
+
* @param runId The ID of the Stream run
|
|
382
|
+
* @returns The Stream run
|
|
383
|
+
*/
|
|
384
|
+
async get(streamId, runId) {
|
|
385
|
+
return this.request(
|
|
386
|
+
`/v0/streams/${streamId}/runs/${runId}`,
|
|
387
|
+
"GET"
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
var WebsetStreamsClient = class extends WebsetsBaseClient {
|
|
392
|
+
constructor(client) {
|
|
393
|
+
super(client);
|
|
394
|
+
this.runs = new WebsetStreamRunsClient(client);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Create a Stream
|
|
398
|
+
* @param params The stream parameters
|
|
399
|
+
* @returns The created Stream
|
|
400
|
+
*/
|
|
401
|
+
async create(params) {
|
|
402
|
+
return this.request("/v0/streams", "POST", params);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Get a Stream by ID
|
|
406
|
+
* @param id The ID of the Stream
|
|
407
|
+
* @returns The Stream
|
|
408
|
+
*/
|
|
409
|
+
async get(id) {
|
|
410
|
+
return this.request(`/v0/streams/${id}`, "GET");
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* List all Streams
|
|
414
|
+
* @param options Pagination and filtering options
|
|
415
|
+
* @returns The list of Streams
|
|
416
|
+
*/
|
|
417
|
+
async list(options) {
|
|
418
|
+
const params = {
|
|
419
|
+
cursor: options?.cursor,
|
|
420
|
+
limit: options?.limit,
|
|
421
|
+
websetId: options?.websetId
|
|
422
|
+
};
|
|
423
|
+
return this.request(
|
|
424
|
+
"/v0/streams",
|
|
425
|
+
"GET",
|
|
426
|
+
void 0,
|
|
427
|
+
params
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Update a Stream
|
|
432
|
+
* @param id The ID of the Stream
|
|
433
|
+
* @param params The stream update parameters (status, metadata)
|
|
434
|
+
* @returns The updated Stream
|
|
435
|
+
*/
|
|
436
|
+
async update(id, params) {
|
|
437
|
+
return this.request(`/v0/streams/${id}`, "PATCH", params);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Delete a Stream
|
|
441
|
+
* @param id The ID of the Stream
|
|
442
|
+
* @returns The deleted Stream
|
|
443
|
+
*/
|
|
444
|
+
async delete(id) {
|
|
445
|
+
return this.request(`/v0/streams/${id}`, "DELETE");
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
|
|
354
449
|
// src/websets/webhooks.ts
|
|
355
450
|
var WebsetWebhooksClient = class extends WebsetsBaseClient {
|
|
356
451
|
/**
|
|
@@ -499,6 +594,7 @@ var WebsetsClient = class extends WebsetsBaseClient {
|
|
|
499
594
|
this.items = new WebsetItemsClient(client);
|
|
500
595
|
this.searches = new WebsetSearchesClient(client);
|
|
501
596
|
this.enrichments = new WebsetEnrichmentsClient(client);
|
|
597
|
+
this.streams = new WebsetStreamsClient(client);
|
|
502
598
|
this.webhooks = new WebsetWebhooksClient(client);
|
|
503
599
|
}
|
|
504
600
|
/**
|
|
@@ -654,36 +750,66 @@ var ResearchBaseClient = class {
|
|
|
654
750
|
* @returns The parsed JSON response
|
|
655
751
|
*/
|
|
656
752
|
async request(endpoint, method = "POST", data, params) {
|
|
657
|
-
return this.client.request(
|
|
753
|
+
return this.client.request(
|
|
754
|
+
`/research/v0${endpoint}`,
|
|
755
|
+
method,
|
|
756
|
+
data,
|
|
757
|
+
params
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Helper to build pagination parameters.
|
|
762
|
+
* @param pagination The pagination parameters
|
|
763
|
+
* @returns QueryParams object with pagination parameters
|
|
764
|
+
*/
|
|
765
|
+
buildPaginationParams(pagination) {
|
|
766
|
+
const params = {};
|
|
767
|
+
if (!pagination) return params;
|
|
768
|
+
if (pagination.cursor) params.cursor = pagination.cursor;
|
|
769
|
+
if (pagination.limit) params.limit = pagination.limit;
|
|
770
|
+
return params;
|
|
658
771
|
}
|
|
659
772
|
};
|
|
660
773
|
|
|
774
|
+
// src/research/openapi.ts
|
|
775
|
+
var ResearchCreateTaskRequestDtoModel = /* @__PURE__ */ ((ResearchCreateTaskRequestDtoModel2) => {
|
|
776
|
+
ResearchCreateTaskRequestDtoModel2["exa_research"] = "exa-research";
|
|
777
|
+
ResearchCreateTaskRequestDtoModel2["exa_ultra"] = "exa-ultra";
|
|
778
|
+
return ResearchCreateTaskRequestDtoModel2;
|
|
779
|
+
})(ResearchCreateTaskRequestDtoModel || {});
|
|
780
|
+
var ResearchTaskDtoStatus = /* @__PURE__ */ ((ResearchTaskDtoStatus2) => {
|
|
781
|
+
ResearchTaskDtoStatus2["running"] = "running";
|
|
782
|
+
ResearchTaskDtoStatus2["completed"] = "completed";
|
|
783
|
+
ResearchTaskDtoStatus2["failed"] = "failed";
|
|
784
|
+
return ResearchTaskDtoStatus2;
|
|
785
|
+
})(ResearchTaskDtoStatus || {});
|
|
786
|
+
|
|
661
787
|
// src/research/client.ts
|
|
662
788
|
var ResearchClient = class extends ResearchBaseClient {
|
|
663
789
|
constructor(client) {
|
|
664
790
|
super(client);
|
|
665
791
|
}
|
|
666
792
|
/**
|
|
667
|
-
* Create a research task.
|
|
793
|
+
* Create a new research task.
|
|
668
794
|
*
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
* 2. `output`
|
|
674
|
-
* defines the exact structure you expect back, and guides the research conducted by the agent.
|
|
675
|
-
* `{ schema: JSONSchema }`.
|
|
676
|
-
* The agent's response will be validated against this schema.
|
|
795
|
+
* @param params Object containing:
|
|
796
|
+
* - model: The research model to use (e.g., ResearchModel.ExaResearch).
|
|
797
|
+
* - instructions: High-level guidance for the research agent.
|
|
798
|
+
* - output: An object with a `schema` property (JSONSchema) that defines the expected output structure.
|
|
677
799
|
*
|
|
678
|
-
* @
|
|
679
|
-
* @param output Object containing the expected output schema.
|
|
680
|
-
* @returns The ResearchTaskResponse returned by the API.
|
|
800
|
+
* @returns An object containing the unique ID of the created research task.
|
|
681
801
|
*/
|
|
682
|
-
async createTask(
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
802
|
+
async createTask(params) {
|
|
803
|
+
const { model, ...rest } = params;
|
|
804
|
+
const payload = {
|
|
805
|
+
model: model ?? "exa-research" /* exa_research */,
|
|
806
|
+
...rest
|
|
807
|
+
};
|
|
808
|
+
return this.request(
|
|
809
|
+
"/tasks",
|
|
810
|
+
"POST",
|
|
811
|
+
payload
|
|
812
|
+
);
|
|
687
813
|
}
|
|
688
814
|
/**
|
|
689
815
|
* Retrieve a research task by ID.
|
|
@@ -694,15 +820,28 @@ var ResearchClient = class extends ResearchBaseClient {
|
|
|
694
820
|
/**
|
|
695
821
|
* Poll a research task until completion or failure.
|
|
696
822
|
* Polls every 1 second with a maximum timeout of 10 minutes.
|
|
823
|
+
* Resilient to up to 10 consecutive polling failures.
|
|
697
824
|
*/
|
|
698
825
|
async pollTask(id) {
|
|
699
826
|
const pollingInterval = 1e3;
|
|
700
827
|
const maxPollingTime = 10 * 60 * 1e3;
|
|
828
|
+
const maxConsecutiveFailures = 10;
|
|
701
829
|
const startTime = Date.now();
|
|
830
|
+
let consecutiveFailures = 0;
|
|
702
831
|
while (true) {
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
832
|
+
try {
|
|
833
|
+
const task = await this.request(`/tasks/${id}`, "GET");
|
|
834
|
+
consecutiveFailures = 0;
|
|
835
|
+
if (task.status === "completed" || task.status === "failed") {
|
|
836
|
+
return task;
|
|
837
|
+
}
|
|
838
|
+
} catch (err) {
|
|
839
|
+
consecutiveFailures += 1;
|
|
840
|
+
if (consecutiveFailures >= maxConsecutiveFailures) {
|
|
841
|
+
throw new Error(
|
|
842
|
+
`Polling failed ${maxConsecutiveFailures} times in a row for task ${id}: ${err}`
|
|
843
|
+
);
|
|
844
|
+
}
|
|
706
845
|
}
|
|
707
846
|
if (Date.now() - startTime > maxPollingTime) {
|
|
708
847
|
throw new Error(
|
|
@@ -712,16 +851,22 @@ var ResearchClient = class extends ResearchBaseClient {
|
|
|
712
851
|
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
713
852
|
}
|
|
714
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* List research tasks
|
|
856
|
+
* @param options Pagination options
|
|
857
|
+
* @returns The paginated list of research tasks
|
|
858
|
+
*/
|
|
859
|
+
async listTasks(options) {
|
|
860
|
+
const params = this.buildPaginationParams(options);
|
|
861
|
+
return this.request(
|
|
862
|
+
"/tasks",
|
|
863
|
+
"GET",
|
|
864
|
+
void 0,
|
|
865
|
+
params
|
|
866
|
+
);
|
|
867
|
+
}
|
|
715
868
|
};
|
|
716
869
|
|
|
717
|
-
// src/research/types.ts
|
|
718
|
-
var ResearchStatus = /* @__PURE__ */ ((ResearchStatus2) => {
|
|
719
|
-
ResearchStatus2["in_progress"] = "in_progress";
|
|
720
|
-
ResearchStatus2["completed"] = "completed";
|
|
721
|
-
ResearchStatus2["failed"] = "failed";
|
|
722
|
-
return ResearchStatus2;
|
|
723
|
-
})(ResearchStatus || {});
|
|
724
|
-
|
|
725
870
|
// src/index.ts
|
|
726
871
|
var fetchImpl = typeof global !== "undefined" && global.fetch ? global.fetch : fetch;
|
|
727
872
|
var HeadersImpl = typeof global !== "undefined" && global.Headers ? global.Headers : Headers;
|
|
@@ -1134,13 +1279,14 @@ var Exa2 = class {
|
|
|
1134
1279
|
var index_default = Exa2;
|
|
1135
1280
|
export {
|
|
1136
1281
|
CreateEnrichmentParametersFormat,
|
|
1137
|
-
CreateWebsetSearchParametersBehaviour,
|
|
1138
1282
|
EventType,
|
|
1139
1283
|
Exa2 as Exa,
|
|
1140
1284
|
ExaError,
|
|
1141
1285
|
HttpStatusCode,
|
|
1142
1286
|
ResearchClient,
|
|
1143
|
-
|
|
1287
|
+
ResearchCreateTaskRequestDtoModel as ResearchModel,
|
|
1288
|
+
ResearchTaskDtoStatus as ResearchStatus,
|
|
1289
|
+
UpdateStreamStatus,
|
|
1144
1290
|
WebhookStatus,
|
|
1145
1291
|
WebsetEnrichmentFormat,
|
|
1146
1292
|
WebsetEnrichmentStatus,
|
|
@@ -1148,10 +1294,12 @@ export {
|
|
|
1148
1294
|
WebsetItemEvaluationSatisfied,
|
|
1149
1295
|
WebsetItemSource,
|
|
1150
1296
|
WebsetItemsClient,
|
|
1297
|
+
WebsetSearchBehavior,
|
|
1151
1298
|
WebsetSearchCanceledReason,
|
|
1152
1299
|
WebsetSearchStatus,
|
|
1153
1300
|
WebsetSearchesClient,
|
|
1154
1301
|
WebsetStatus,
|
|
1302
|
+
WebsetStreamsClient,
|
|
1155
1303
|
WebsetWebhooksClient,
|
|
1156
1304
|
WebsetsClient,
|
|
1157
1305
|
index_default as default
|