exa-js 1.8.27 → 1.9.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.d.mts +1776 -454
- package/dist/index.d.ts +1776 -454
- package/dist/index.js +90 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -113
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -110,6 +110,20 @@ var WebsetEnrichmentsClient = class extends WebsetsBaseClient {
|
|
|
110
110
|
"DELETE"
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Update an Enrichment
|
|
115
|
+
* @param websetId The ID of the Webset
|
|
116
|
+
* @param id The ID of the Enrichment
|
|
117
|
+
* @param params The enrichment update parameters
|
|
118
|
+
* @returns Promise that resolves when the update is complete
|
|
119
|
+
*/
|
|
120
|
+
async update(websetId, id, params) {
|
|
121
|
+
return this.request(
|
|
122
|
+
`/v0/websets/${websetId}/enrichments/${id}`,
|
|
123
|
+
"PATCH",
|
|
124
|
+
params
|
|
125
|
+
);
|
|
126
|
+
}
|
|
113
127
|
/**
|
|
114
128
|
* Cancel a running Enrichment
|
|
115
129
|
* @param websetId The ID of the Webset
|
|
@@ -169,37 +183,18 @@ var CreateEnrichmentParametersFormat = /* @__PURE__ */ ((CreateEnrichmentParamet
|
|
|
169
183
|
CreateEnrichmentParametersFormat2["options"] = "options";
|
|
170
184
|
CreateEnrichmentParametersFormat2["email"] = "email";
|
|
171
185
|
CreateEnrichmentParametersFormat2["phone"] = "phone";
|
|
186
|
+
CreateEnrichmentParametersFormat2["url"] = "url";
|
|
172
187
|
return CreateEnrichmentParametersFormat2;
|
|
173
188
|
})(CreateEnrichmentParametersFormat || {});
|
|
174
189
|
var CreateImportParametersFormat = /* @__PURE__ */ ((CreateImportParametersFormat2) => {
|
|
175
190
|
CreateImportParametersFormat2["csv"] = "csv";
|
|
176
191
|
return CreateImportParametersFormat2;
|
|
177
192
|
})(CreateImportParametersFormat || {});
|
|
178
|
-
var
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return
|
|
182
|
-
})(
|
|
183
|
-
var CreateWebsetParametersSearchExcludeSource = /* @__PURE__ */ ((CreateWebsetParametersSearchExcludeSource2) => {
|
|
184
|
-
CreateWebsetParametersSearchExcludeSource2["import"] = "import";
|
|
185
|
-
CreateWebsetParametersSearchExcludeSource2["webset"] = "webset";
|
|
186
|
-
return CreateWebsetParametersSearchExcludeSource2;
|
|
187
|
-
})(CreateWebsetParametersSearchExcludeSource || {});
|
|
188
|
-
var ScopeSourceType = /* @__PURE__ */ ((ScopeSourceType2) => {
|
|
189
|
-
ScopeSourceType2["import"] = "import";
|
|
190
|
-
ScopeSourceType2["webset"] = "webset";
|
|
191
|
-
return ScopeSourceType2;
|
|
192
|
-
})(ScopeSourceType || {});
|
|
193
|
-
var CreateWebsetSearchParametersExcludeSource = /* @__PURE__ */ ((CreateWebsetSearchParametersExcludeSource2) => {
|
|
194
|
-
CreateWebsetSearchParametersExcludeSource2["import"] = "import";
|
|
195
|
-
CreateWebsetSearchParametersExcludeSource2["webset"] = "webset";
|
|
196
|
-
return CreateWebsetSearchParametersExcludeSource2;
|
|
197
|
-
})(CreateWebsetSearchParametersExcludeSource || {});
|
|
198
|
-
var CreateWebsetSearchParametersScopeSource = /* @__PURE__ */ ((CreateWebsetSearchParametersScopeSource2) => {
|
|
199
|
-
CreateWebsetSearchParametersScopeSource2["import"] = "import";
|
|
200
|
-
CreateWebsetSearchParametersScopeSource2["webset"] = "webset";
|
|
201
|
-
return CreateWebsetSearchParametersScopeSource2;
|
|
202
|
-
})(CreateWebsetSearchParametersScopeSource || {});
|
|
193
|
+
var WebsetImportSource = /* @__PURE__ */ ((WebsetImportSource2) => {
|
|
194
|
+
WebsetImportSource2["import"] = "import";
|
|
195
|
+
WebsetImportSource2["webset"] = "webset";
|
|
196
|
+
return WebsetImportSource2;
|
|
197
|
+
})(WebsetImportSource || {});
|
|
203
198
|
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
204
199
|
EventType2["webset_created"] = "webset.created";
|
|
205
200
|
EventType2["webset_deleted"] = "webset.deleted";
|
|
@@ -211,9 +206,13 @@ var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
|
211
206
|
EventType2["webset_search_updated"] = "webset.search.updated";
|
|
212
207
|
EventType2["import_created"] = "import.created";
|
|
213
208
|
EventType2["import_completed"] = "import.completed";
|
|
214
|
-
EventType2["import_processing"] = "import.processing";
|
|
215
209
|
EventType2["webset_item_created"] = "webset.item.created";
|
|
216
210
|
EventType2["webset_item_enriched"] = "webset.item.enriched";
|
|
211
|
+
EventType2["monitor_created"] = "monitor.created";
|
|
212
|
+
EventType2["monitor_updated"] = "monitor.updated";
|
|
213
|
+
EventType2["monitor_deleted"] = "monitor.deleted";
|
|
214
|
+
EventType2["monitor_run_created"] = "monitor.run.created";
|
|
215
|
+
EventType2["monitor_run_completed"] = "monitor.run.completed";
|
|
217
216
|
EventType2["webset_export_created"] = "webset.export.created";
|
|
218
217
|
EventType2["webset_export_completed"] = "webset.export.completed";
|
|
219
218
|
return EventType2;
|
|
@@ -266,15 +265,6 @@ var MonitorRunType = /* @__PURE__ */ ((MonitorRunType2) => {
|
|
|
266
265
|
MonitorRunType2["refresh"] = "refresh";
|
|
267
266
|
return MonitorRunType2;
|
|
268
267
|
})(MonitorRunType || {});
|
|
269
|
-
var PreviewWebsetResponseEnrichmentsFormat = /* @__PURE__ */ ((PreviewWebsetResponseEnrichmentsFormat2) => {
|
|
270
|
-
PreviewWebsetResponseEnrichmentsFormat2["text"] = "text";
|
|
271
|
-
PreviewWebsetResponseEnrichmentsFormat2["date"] = "date";
|
|
272
|
-
PreviewWebsetResponseEnrichmentsFormat2["number"] = "number";
|
|
273
|
-
PreviewWebsetResponseEnrichmentsFormat2["options"] = "options";
|
|
274
|
-
PreviewWebsetResponseEnrichmentsFormat2["email"] = "email";
|
|
275
|
-
PreviewWebsetResponseEnrichmentsFormat2["phone"] = "phone";
|
|
276
|
-
return PreviewWebsetResponseEnrichmentsFormat2;
|
|
277
|
-
})(PreviewWebsetResponseEnrichmentsFormat || {});
|
|
278
268
|
var UpdateMonitorStatus = /* @__PURE__ */ ((UpdateMonitorStatus2) => {
|
|
279
269
|
UpdateMonitorStatus2["enabled"] = "enabled";
|
|
280
270
|
UpdateMonitorStatus2["disabled"] = "disabled";
|
|
@@ -305,6 +295,7 @@ var WebsetEnrichmentFormat = /* @__PURE__ */ ((WebsetEnrichmentFormat2) => {
|
|
|
305
295
|
WebsetEnrichmentFormat2["options"] = "options";
|
|
306
296
|
WebsetEnrichmentFormat2["email"] = "email";
|
|
307
297
|
WebsetEnrichmentFormat2["phone"] = "phone";
|
|
298
|
+
WebsetEnrichmentFormat2["url"] = "url";
|
|
308
299
|
return WebsetEnrichmentFormat2;
|
|
309
300
|
})(WebsetEnrichmentFormat || {});
|
|
310
301
|
var WebsetItemSource = /* @__PURE__ */ ((WebsetItemSource2) => {
|
|
@@ -318,6 +309,16 @@ var WebsetItemEvaluationSatisfied = /* @__PURE__ */ ((WebsetItemEvaluationSatisf
|
|
|
318
309
|
WebsetItemEvaluationSatisfied2["unclear"] = "unclear";
|
|
319
310
|
return WebsetItemEvaluationSatisfied2;
|
|
320
311
|
})(WebsetItemEvaluationSatisfied || {});
|
|
312
|
+
var WebsetSearchExcludeSource = /* @__PURE__ */ ((WebsetSearchExcludeSource2) => {
|
|
313
|
+
WebsetSearchExcludeSource2["import"] = "import";
|
|
314
|
+
WebsetSearchExcludeSource2["webset"] = "webset";
|
|
315
|
+
return WebsetSearchExcludeSource2;
|
|
316
|
+
})(WebsetSearchExcludeSource || {});
|
|
317
|
+
var WebsetSearchScopeSource = /* @__PURE__ */ ((WebsetSearchScopeSource2) => {
|
|
318
|
+
WebsetSearchScopeSource2["import"] = "import";
|
|
319
|
+
WebsetSearchScopeSource2["webset"] = "webset";
|
|
320
|
+
return WebsetSearchScopeSource2;
|
|
321
|
+
})(WebsetSearchScopeSource || {});
|
|
321
322
|
var WebsetSearchStatus = /* @__PURE__ */ ((WebsetSearchStatus2) => {
|
|
322
323
|
WebsetSearchStatus2["created"] = "created";
|
|
323
324
|
WebsetSearchStatus2["pending"] = "pending";
|
|
@@ -1019,50 +1020,25 @@ function zodToJsonSchema(schema) {
|
|
|
1019
1020
|
|
|
1020
1021
|
// src/research/base.ts
|
|
1021
1022
|
var ResearchBaseClient = class {
|
|
1022
|
-
/**
|
|
1023
|
-
* Initialize a new Research base client
|
|
1024
|
-
* @param client The Exa client instance
|
|
1025
|
-
*/
|
|
1026
1023
|
constructor(client) {
|
|
1027
1024
|
this.client = client;
|
|
1028
1025
|
}
|
|
1029
|
-
/**
|
|
1030
|
-
* Make a request to the Research API (prefixes all paths with `/research`).
|
|
1031
|
-
* @param endpoint The endpoint path, beginning with a slash (e.g. "/tasks").
|
|
1032
|
-
* @param method The HTTP method. Defaults to "POST".
|
|
1033
|
-
* @param data Optional request body
|
|
1034
|
-
* @param params Optional query parameters
|
|
1035
|
-
* @returns The parsed JSON response
|
|
1036
|
-
*/
|
|
1037
1026
|
async request(endpoint, method = "POST", data, params) {
|
|
1038
1027
|
return this.client.request(
|
|
1039
|
-
`/research/
|
|
1028
|
+
`/research/v1${endpoint}`,
|
|
1040
1029
|
method,
|
|
1041
1030
|
data,
|
|
1042
1031
|
params
|
|
1043
1032
|
);
|
|
1044
1033
|
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Make a request to the Research API (prefixes all paths with `/research`).
|
|
1047
|
-
* @param endpoint The endpoint path, beginning with a slash (e.g. "/tasks").
|
|
1048
|
-
* @param method The HTTP method. Defaults to "POST".
|
|
1049
|
-
* @param data Optional request body
|
|
1050
|
-
* @param params Optional query parameters
|
|
1051
|
-
* @returns The parsed JSON response
|
|
1052
|
-
*/
|
|
1053
1034
|
async rawRequest(endpoint, method = "POST", data, params) {
|
|
1054
1035
|
return this.client.rawRequest(
|
|
1055
|
-
`/research/
|
|
1036
|
+
`/research/v1${endpoint}`,
|
|
1056
1037
|
method,
|
|
1057
1038
|
data,
|
|
1058
1039
|
params
|
|
1059
1040
|
);
|
|
1060
1041
|
}
|
|
1061
|
-
/**
|
|
1062
|
-
* Helper to build pagination parameters.
|
|
1063
|
-
* @param pagination The pagination parameters
|
|
1064
|
-
* @returns QueryParams object with pagination parameters
|
|
1065
|
-
*/
|
|
1066
1042
|
buildPaginationParams(pagination) {
|
|
1067
1043
|
const params = {};
|
|
1068
1044
|
if (!pagination) return params;
|
|
@@ -1077,26 +1053,34 @@ var ResearchClient = class extends ResearchBaseClient {
|
|
|
1077
1053
|
constructor(client) {
|
|
1078
1054
|
super(client);
|
|
1079
1055
|
}
|
|
1080
|
-
async
|
|
1081
|
-
const { instructions, model,
|
|
1082
|
-
let schema =
|
|
1056
|
+
async create(params) {
|
|
1057
|
+
const { instructions, model, outputSchema } = params;
|
|
1058
|
+
let schema = outputSchema;
|
|
1083
1059
|
if (schema && isZodSchema(schema)) {
|
|
1084
1060
|
schema = zodToJsonSchema(schema);
|
|
1085
1061
|
}
|
|
1086
1062
|
const payload = {
|
|
1087
1063
|
instructions,
|
|
1088
|
-
model: model ?? "exa-research"
|
|
1089
|
-
output: output ? {
|
|
1090
|
-
schema,
|
|
1091
|
-
inferSchema: output.inferSchema ?? true
|
|
1092
|
-
} : { inferSchema: true }
|
|
1064
|
+
model: model ?? "exa-research"
|
|
1093
1065
|
};
|
|
1094
|
-
|
|
1066
|
+
if (schema) {
|
|
1067
|
+
payload.outputSchema = schema;
|
|
1068
|
+
}
|
|
1069
|
+
return this.request("", "POST", payload);
|
|
1095
1070
|
}
|
|
1096
|
-
|
|
1071
|
+
get(researchId, options) {
|
|
1097
1072
|
if (options?.stream) {
|
|
1098
1073
|
const promise = async () => {
|
|
1099
|
-
const
|
|
1074
|
+
const params = { stream: "true" };
|
|
1075
|
+
if (options.events !== void 0) {
|
|
1076
|
+
params.events = options.events.toString();
|
|
1077
|
+
}
|
|
1078
|
+
const resp = await this.rawRequest(
|
|
1079
|
+
`/${researchId}`,
|
|
1080
|
+
"GET",
|
|
1081
|
+
void 0,
|
|
1082
|
+
params
|
|
1083
|
+
);
|
|
1100
1084
|
if (!resp.body) {
|
|
1101
1085
|
throw new Error("No response body for SSE stream");
|
|
1102
1086
|
}
|
|
@@ -1140,59 +1124,53 @@ var ResearchClient = class extends ResearchBaseClient {
|
|
|
1140
1124
|
};
|
|
1141
1125
|
return promise();
|
|
1142
1126
|
} else {
|
|
1143
|
-
|
|
1127
|
+
const params = { stream: "false" };
|
|
1128
|
+
if (options?.events !== void 0) {
|
|
1129
|
+
params.events = options.events.toString();
|
|
1130
|
+
}
|
|
1131
|
+
return this.request(
|
|
1132
|
+
`/${researchId}`,
|
|
1133
|
+
"GET",
|
|
1134
|
+
void 0,
|
|
1135
|
+
params
|
|
1136
|
+
);
|
|
1144
1137
|
}
|
|
1145
1138
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
const pollingInterval = 1e3;
|
|
1155
|
-
const maxPollingTime = 10 * 60 * 1e3;
|
|
1156
|
-
const maxConsecutiveFailures = 10;
|
|
1139
|
+
async list(options) {
|
|
1140
|
+
const params = this.buildPaginationParams(options);
|
|
1141
|
+
return this.request("", "GET", void 0, params);
|
|
1142
|
+
}
|
|
1143
|
+
async pollUntilFinished(researchId, options) {
|
|
1144
|
+
const pollInterval = options?.pollInterval ?? 1e3;
|
|
1145
|
+
const timeoutMs = options?.timeoutMs ?? 10 * 60 * 1e3;
|
|
1146
|
+
const maxConsecutiveFailures = 5;
|
|
1157
1147
|
const startTime = Date.now();
|
|
1158
1148
|
let consecutiveFailures = 0;
|
|
1159
1149
|
while (true) {
|
|
1160
1150
|
try {
|
|
1161
|
-
const
|
|
1151
|
+
const research = await this.get(researchId, {
|
|
1152
|
+
events: options?.events
|
|
1153
|
+
});
|
|
1162
1154
|
consecutiveFailures = 0;
|
|
1163
|
-
if (
|
|
1164
|
-
return
|
|
1155
|
+
if (research.status === "completed" || research.status === "failed" || research.status === "canceled") {
|
|
1156
|
+
return research;
|
|
1165
1157
|
}
|
|
1166
1158
|
} catch (err) {
|
|
1167
1159
|
consecutiveFailures += 1;
|
|
1168
1160
|
if (consecutiveFailures >= maxConsecutiveFailures) {
|
|
1169
1161
|
throw new Error(
|
|
1170
|
-
`Polling failed ${maxConsecutiveFailures} times in a row for
|
|
1162
|
+
`Polling failed ${maxConsecutiveFailures} times in a row for research ${researchId}: ${err}`
|
|
1171
1163
|
);
|
|
1172
1164
|
}
|
|
1173
1165
|
}
|
|
1174
|
-
if (Date.now() - startTime >
|
|
1166
|
+
if (Date.now() - startTime > timeoutMs) {
|
|
1175
1167
|
throw new Error(
|
|
1176
|
-
`Polling timeout:
|
|
1168
|
+
`Polling timeout: Research ${researchId} did not complete within ${timeoutMs}ms`
|
|
1177
1169
|
);
|
|
1178
1170
|
}
|
|
1179
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
1171
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
1180
1172
|
}
|
|
1181
1173
|
}
|
|
1182
|
-
/**
|
|
1183
|
-
* List research tasks
|
|
1184
|
-
* @param options Pagination options
|
|
1185
|
-
* @returns The paginated list of research tasks
|
|
1186
|
-
*/
|
|
1187
|
-
async listTasks(options) {
|
|
1188
|
-
const params = this.buildPaginationParams(options);
|
|
1189
|
-
return this.request(
|
|
1190
|
-
"/tasks",
|
|
1191
|
-
"GET",
|
|
1192
|
-
void 0,
|
|
1193
|
-
params
|
|
1194
|
-
);
|
|
1195
|
-
}
|
|
1196
1174
|
};
|
|
1197
1175
|
|
|
1198
1176
|
// src/index.ts
|
|
@@ -1622,10 +1600,6 @@ var index_default = Exa2;
|
|
|
1622
1600
|
export {
|
|
1623
1601
|
CreateEnrichmentParametersFormat,
|
|
1624
1602
|
CreateImportParametersFormat,
|
|
1625
|
-
CreateWebsetParametersImportSource,
|
|
1626
|
-
CreateWebsetParametersSearchExcludeSource,
|
|
1627
|
-
CreateWebsetSearchParametersExcludeSource,
|
|
1628
|
-
CreateWebsetSearchParametersScopeSource,
|
|
1629
1603
|
EventType,
|
|
1630
1604
|
EventsClient,
|
|
1631
1605
|
Exa2 as Exa,
|
|
@@ -1641,20 +1615,20 @@ export {
|
|
|
1641
1615
|
MonitorRunStatus,
|
|
1642
1616
|
MonitorRunType,
|
|
1643
1617
|
MonitorStatus,
|
|
1644
|
-
PreviewWebsetResponseEnrichmentsFormat,
|
|
1645
|
-
ResearchClient,
|
|
1646
|
-
ScopeSourceType,
|
|
1647
1618
|
UpdateMonitorStatus,
|
|
1648
1619
|
WebhookStatus,
|
|
1649
1620
|
WebsetEnrichmentFormat,
|
|
1650
1621
|
WebsetEnrichmentStatus,
|
|
1651
1622
|
WebsetEnrichmentsClient,
|
|
1623
|
+
WebsetImportSource,
|
|
1652
1624
|
WebsetItemEvaluationSatisfied,
|
|
1653
1625
|
WebsetItemSource,
|
|
1654
1626
|
WebsetItemsClient,
|
|
1655
1627
|
WebsetMonitorsClient,
|
|
1656
1628
|
WebsetSearchBehavior,
|
|
1657
1629
|
WebsetSearchCanceledReason,
|
|
1630
|
+
WebsetSearchExcludeSource,
|
|
1631
|
+
WebsetSearchScopeSource,
|
|
1658
1632
|
WebsetSearchStatus,
|
|
1659
1633
|
WebsetSearchesClient,
|
|
1660
1634
|
WebsetStatus,
|