exa-js 2.15.1 → 2.16.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.d.mts +41 -14
- package/dist/index.d.ts +41 -14
- package/dist/index.js +80 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ type AgentConfidence = "low" | "medium" | "high";
|
|
|
22
22
|
type AgentEffort = "low" | "medium" | "high" | "xhigh" | "auto";
|
|
23
23
|
/**
|
|
24
24
|
* Identifier of an Exa Connect data provider, e.g. `"fiber_ai"`,
|
|
25
|
-
* `"financial_datasets"`, `"
|
|
25
|
+
* `"financial_datasets"`, `"similarweb"`, `"baselayer"`, `"affiliate"`,
|
|
26
26
|
* `"particle_news"`, or `"jinko"`.
|
|
27
27
|
*/
|
|
28
28
|
type AgentDataSourceProvider = string;
|
|
@@ -171,6 +171,36 @@ declare class AgentBaseClient {
|
|
|
171
171
|
*/
|
|
172
172
|
|
|
173
173
|
type WithBetaOptions<T> = T & AgentBetaOptions;
|
|
174
|
+
type AgentTerminalStatus = "completed" | "failed" | "cancelled";
|
|
175
|
+
type AgentTerminalRun = AgentRun & {
|
|
176
|
+
status: AgentTerminalStatus;
|
|
177
|
+
};
|
|
178
|
+
type AgentCompletedRun = AgentRun & {
|
|
179
|
+
status: "completed";
|
|
180
|
+
};
|
|
181
|
+
type AgentCompletedRunTyped<T> = AgentRunTyped<T> & {
|
|
182
|
+
status: "completed";
|
|
183
|
+
};
|
|
184
|
+
type AgentWaitOptions = {
|
|
185
|
+
pollInterval?: number;
|
|
186
|
+
timeoutMs?: number;
|
|
187
|
+
};
|
|
188
|
+
declare class AgentRunFailedError extends Error {
|
|
189
|
+
run: AgentRun & {
|
|
190
|
+
status: "failed";
|
|
191
|
+
};
|
|
192
|
+
constructor(run: AgentRun & {
|
|
193
|
+
status: "failed";
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
declare class AgentRunCancelledError extends Error {
|
|
197
|
+
run: AgentRun & {
|
|
198
|
+
status: "cancelled";
|
|
199
|
+
};
|
|
200
|
+
constructor(run: AgentRun & {
|
|
201
|
+
status: "cancelled";
|
|
202
|
+
});
|
|
203
|
+
}
|
|
174
204
|
declare class AgentRunEventsClient extends AgentBaseClient {
|
|
175
205
|
/**
|
|
176
206
|
* List stored events for an Agent run.
|
|
@@ -220,12 +250,12 @@ declare class AgentRunsClient extends AgentBaseClient {
|
|
|
220
250
|
/**
|
|
221
251
|
* Poll an Agent run until it reaches a terminal status.
|
|
222
252
|
*/
|
|
223
|
-
pollUntilFinished(runId: string, options?:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
253
|
+
pollUntilFinished(runId: string, options?: AgentWaitOptions): Promise<AgentTerminalRun>;
|
|
254
|
+
/**
|
|
255
|
+
* Create an Agent run and wait until it reaches a terminal status.
|
|
256
|
+
*/
|
|
257
|
+
createAndWait<T>(params: Omit<AgentCreateOptions<T>, "stream">, options?: AgentWaitOptions): Promise<AgentCompletedRunTyped<T>>;
|
|
258
|
+
createAndWait(params: CreateAgentRunParams, options?: AgentWaitOptions): Promise<AgentCompletedRun>;
|
|
229
259
|
}
|
|
230
260
|
declare class AgentClient {
|
|
231
261
|
/**
|
|
@@ -265,12 +295,9 @@ declare class AgentBetaRunsClient extends AgentRunsClient {
|
|
|
265
295
|
getAll(options?: WithBetaOptions<ListAgentRunsParams>): Promise<AgentRun[]>;
|
|
266
296
|
cancel(runId: string, options?: AgentBetaOptions): Promise<AgentRun>;
|
|
267
297
|
delete(runId: string, options?: AgentBetaOptions): Promise<DeletedAgentRun>;
|
|
268
|
-
pollUntilFinished(runId: string, options?: WithBetaOptions<
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}>): Promise<AgentRun & {
|
|
272
|
-
status: "completed" | "failed" | "cancelled";
|
|
273
|
-
}>;
|
|
298
|
+
pollUntilFinished(runId: string, options?: WithBetaOptions<AgentWaitOptions>): Promise<AgentTerminalRun>;
|
|
299
|
+
createAndWait<T>(params: WithBetaOptions<Omit<AgentCreateOptions<T>, "stream">>, options?: AgentWaitOptions): Promise<AgentCompletedRunTyped<T>>;
|
|
300
|
+
createAndWait(params: CreateAgentRunParams & AgentBetaOptions, options?: AgentWaitOptions): Promise<AgentCompletedRun>;
|
|
274
301
|
}
|
|
275
302
|
/**
|
|
276
303
|
* @deprecated Use AgentClient instead.
|
|
@@ -4372,4 +4399,4 @@ declare class Exa {
|
|
|
4372
4399
|
private parseSSEStream;
|
|
4373
4400
|
}
|
|
4374
4401
|
|
|
4375
|
-
export { AGENT_BETA_HEADER, AgentBetaClient, type AgentBetaOptions, AgentClient, type AgentConfidence, type AgentCostDollars, type AgentCreateOptions, type AgentDataSource, type AgentDataSourceProvider, type AgentEffort, type AgentError, type AgentEvent, type AgentGroundingCitation, type AgentGroundingEntry, type AgentInput, type AgentOutput, type AgentRun, AgentRunEventsClient, type AgentRunStatus, type AgentRunTyped, AgentRunsClient, type AgentStopReason, type AgentUsage, type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, BetaClient, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateAgentRunParams, type CreateAgentRunParamsTyped, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateSearchMonitorParams, type CreateSearchMonitorResponse, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type DeepObjectOutputSchema, type DeepOutputSchema, type DeepSearchOutput, type DeepSearchOutputGrounding, type DeepSearchOutputGroundingCitation, type DeepSearchOutputGroundingConfidence, type DeepSearchType, type DeepTextOutputSchema, type Default, type DeletedAgentRun, type EnrichmentResult, type Entity, type EntityCompanyProperties, type EntityCompanyPropertiesFinancials, type EntityCompanyPropertiesFundingRound, type EntityCompanyPropertiesHeadquarters, type EntityCompanyPropertiesWebTraffic, type EntityCompanyPropertiesWorkforce, type EntityDateRange, type EntityPersonProperties, type EntityPersonPropertiesCompanyRef, type EntityPersonPropertiesWorkHistoryEntry, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type GroundingCitation, type GroundingEntry, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListAgentRunEventsParams, type ListAgentRunEventsResponse, type ListAgentRunsParams, type ListAgentRunsResponse, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, type ListSearchMonitorRunsParams, type ListSearchMonitorRunsResponse, type ListSearchMonitorsParams, type ListSearchMonitorsResponse, type ListWebhookAttemptsResponse, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetItemsOptions, type ListWebsetsResponse, type LivecrawlOptions, type Monitor, type MonitorBehavior, type MonitorCadence, MonitorObject, type MonitorRun, MonitorRunObject, MonitorRunStatus, MonitorRunType, MonitorStatus, type PersonEntity, type PreviewWebsetParameters, type PreviewWebsetResponse, type RegularSearchOptions, type Research, type ResearchCreateParamsTyped, type ResearchCreateRequest, type ResearchCreateResponse, type ResearchDefinitionEvent, type ResearchEvent, type ResearchOperation, type ResearchOutputEvent, type ResearchPaperEntity, type ResearchPlanDefinitionEvent, type ResearchPlanOperationEvent, type ResearchPlanOutputEvent, type ResearchStatus, type ResearchStreamEvent, type ResearchStreamEventTyped, type ResearchTaskDefinitionEvent, type ResearchTaskOperationEvent, type ResearchTaskOutputEvent, type ResearchTyped, type SearchMonitor, type SearchMonitorRun, type SearchMonitorRunFailReason, type SearchMonitorRunOutput, type SearchMonitorRunStatus, SearchMonitorRunsClient, type SearchMonitorSearch, type SearchMonitorStatus, type SearchMonitorTrigger, type SearchMonitorWebhook, type SearchMonitorWebhookEvent, SearchMonitorsClient, type SearchResponse, type SearchResult, type SearchStreamChunk, type SectionTag, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type TriggerSearchMonitorResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateSearchMonitorParams, type UpdateWebhookParameters, type UpdateWebsetRequest, type VerbosityOptions, type WaitUntilCompletedOptions, type Webhook, type WebhookAttempt, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, WebsetExcludeSource, type WebsetHeadersLike, WebsetImportSource, type WebsetItem, type WebsetItemArticleProperties, type WebsetItemCompanyProperties, type WebsetItemCustomProperties, type WebsetItemEvaluation, WebsetItemEvaluationSatisfied, type WebsetItemPersonProperties, type WebsetItemResearchPaperProperties, WebsetItemSource, WebsetItemsClient, WebsetMonitorsClient, type WebsetSearch, WebsetSearchBehavior, WebsetSearchCanceledReason, WebsetSearchScopeSource, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|
|
4402
|
+
export { AGENT_BETA_HEADER, AgentBetaClient, type AgentBetaOptions, AgentClient, type AgentConfidence, type AgentCostDollars, type AgentCreateOptions, type AgentDataSource, type AgentDataSourceProvider, type AgentEffort, type AgentError, type AgentEvent, type AgentGroundingCitation, type AgentGroundingEntry, type AgentInput, type AgentOutput, type AgentRun, AgentRunCancelledError, AgentRunEventsClient, AgentRunFailedError, type AgentRunStatus, type AgentRunTyped, AgentRunsClient, type AgentStopReason, type AgentUsage, type AgentWaitOptions, type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, BetaClient, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateAgentRunParams, type CreateAgentRunParamsTyped, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateSearchMonitorParams, type CreateSearchMonitorResponse, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type DeepObjectOutputSchema, type DeepOutputSchema, type DeepSearchOutput, type DeepSearchOutputGrounding, type DeepSearchOutputGroundingCitation, type DeepSearchOutputGroundingConfidence, type DeepSearchType, type DeepTextOutputSchema, type Default, type DeletedAgentRun, type EnrichmentResult, type Entity, type EntityCompanyProperties, type EntityCompanyPropertiesFinancials, type EntityCompanyPropertiesFundingRound, type EntityCompanyPropertiesHeadquarters, type EntityCompanyPropertiesWebTraffic, type EntityCompanyPropertiesWorkforce, type EntityDateRange, type EntityPersonProperties, type EntityPersonPropertiesCompanyRef, type EntityPersonPropertiesWorkHistoryEntry, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type GroundingCitation, type GroundingEntry, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListAgentRunEventsParams, type ListAgentRunEventsResponse, type ListAgentRunsParams, type ListAgentRunsResponse, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, type ListSearchMonitorRunsParams, type ListSearchMonitorRunsResponse, type ListSearchMonitorsParams, type ListSearchMonitorsResponse, type ListWebhookAttemptsResponse, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetItemsOptions, type ListWebsetsResponse, type LivecrawlOptions, type Monitor, type MonitorBehavior, type MonitorCadence, MonitorObject, type MonitorRun, MonitorRunObject, MonitorRunStatus, MonitorRunType, MonitorStatus, type PersonEntity, type PreviewWebsetParameters, type PreviewWebsetResponse, type RegularSearchOptions, type Research, type ResearchCreateParamsTyped, type ResearchCreateRequest, type ResearchCreateResponse, type ResearchDefinitionEvent, type ResearchEvent, type ResearchOperation, type ResearchOutputEvent, type ResearchPaperEntity, type ResearchPlanDefinitionEvent, type ResearchPlanOperationEvent, type ResearchPlanOutputEvent, type ResearchStatus, type ResearchStreamEvent, type ResearchStreamEventTyped, type ResearchTaskDefinitionEvent, type ResearchTaskOperationEvent, type ResearchTaskOutputEvent, type ResearchTyped, type SearchMonitor, type SearchMonitorRun, type SearchMonitorRunFailReason, type SearchMonitorRunOutput, type SearchMonitorRunStatus, SearchMonitorRunsClient, type SearchMonitorSearch, type SearchMonitorStatus, type SearchMonitorTrigger, type SearchMonitorWebhook, type SearchMonitorWebhookEvent, SearchMonitorsClient, type SearchResponse, type SearchResult, type SearchStreamChunk, type SectionTag, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type TriggerSearchMonitorResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateSearchMonitorParams, type UpdateWebhookParameters, type UpdateWebsetRequest, type VerbosityOptions, type WaitUntilCompletedOptions, type Webhook, type WebhookAttempt, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, WebsetExcludeSource, type WebsetHeadersLike, WebsetImportSource, type WebsetItem, type WebsetItemArticleProperties, type WebsetItemCompanyProperties, type WebsetItemCustomProperties, type WebsetItemEvaluation, WebsetItemEvaluationSatisfied, type WebsetItemPersonProperties, type WebsetItemResearchPaperProperties, WebsetItemSource, WebsetItemsClient, WebsetMonitorsClient, type WebsetSearch, WebsetSearchBehavior, WebsetSearchCanceledReason, WebsetSearchScopeSource, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ type AgentConfidence = "low" | "medium" | "high";
|
|
|
22
22
|
type AgentEffort = "low" | "medium" | "high" | "xhigh" | "auto";
|
|
23
23
|
/**
|
|
24
24
|
* Identifier of an Exa Connect data provider, e.g. `"fiber_ai"`,
|
|
25
|
-
* `"financial_datasets"`, `"
|
|
25
|
+
* `"financial_datasets"`, `"similarweb"`, `"baselayer"`, `"affiliate"`,
|
|
26
26
|
* `"particle_news"`, or `"jinko"`.
|
|
27
27
|
*/
|
|
28
28
|
type AgentDataSourceProvider = string;
|
|
@@ -171,6 +171,36 @@ declare class AgentBaseClient {
|
|
|
171
171
|
*/
|
|
172
172
|
|
|
173
173
|
type WithBetaOptions<T> = T & AgentBetaOptions;
|
|
174
|
+
type AgentTerminalStatus = "completed" | "failed" | "cancelled";
|
|
175
|
+
type AgentTerminalRun = AgentRun & {
|
|
176
|
+
status: AgentTerminalStatus;
|
|
177
|
+
};
|
|
178
|
+
type AgentCompletedRun = AgentRun & {
|
|
179
|
+
status: "completed";
|
|
180
|
+
};
|
|
181
|
+
type AgentCompletedRunTyped<T> = AgentRunTyped<T> & {
|
|
182
|
+
status: "completed";
|
|
183
|
+
};
|
|
184
|
+
type AgentWaitOptions = {
|
|
185
|
+
pollInterval?: number;
|
|
186
|
+
timeoutMs?: number;
|
|
187
|
+
};
|
|
188
|
+
declare class AgentRunFailedError extends Error {
|
|
189
|
+
run: AgentRun & {
|
|
190
|
+
status: "failed";
|
|
191
|
+
};
|
|
192
|
+
constructor(run: AgentRun & {
|
|
193
|
+
status: "failed";
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
declare class AgentRunCancelledError extends Error {
|
|
197
|
+
run: AgentRun & {
|
|
198
|
+
status: "cancelled";
|
|
199
|
+
};
|
|
200
|
+
constructor(run: AgentRun & {
|
|
201
|
+
status: "cancelled";
|
|
202
|
+
});
|
|
203
|
+
}
|
|
174
204
|
declare class AgentRunEventsClient extends AgentBaseClient {
|
|
175
205
|
/**
|
|
176
206
|
* List stored events for an Agent run.
|
|
@@ -220,12 +250,12 @@ declare class AgentRunsClient extends AgentBaseClient {
|
|
|
220
250
|
/**
|
|
221
251
|
* Poll an Agent run until it reaches a terminal status.
|
|
222
252
|
*/
|
|
223
|
-
pollUntilFinished(runId: string, options?:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
253
|
+
pollUntilFinished(runId: string, options?: AgentWaitOptions): Promise<AgentTerminalRun>;
|
|
254
|
+
/**
|
|
255
|
+
* Create an Agent run and wait until it reaches a terminal status.
|
|
256
|
+
*/
|
|
257
|
+
createAndWait<T>(params: Omit<AgentCreateOptions<T>, "stream">, options?: AgentWaitOptions): Promise<AgentCompletedRunTyped<T>>;
|
|
258
|
+
createAndWait(params: CreateAgentRunParams, options?: AgentWaitOptions): Promise<AgentCompletedRun>;
|
|
229
259
|
}
|
|
230
260
|
declare class AgentClient {
|
|
231
261
|
/**
|
|
@@ -265,12 +295,9 @@ declare class AgentBetaRunsClient extends AgentRunsClient {
|
|
|
265
295
|
getAll(options?: WithBetaOptions<ListAgentRunsParams>): Promise<AgentRun[]>;
|
|
266
296
|
cancel(runId: string, options?: AgentBetaOptions): Promise<AgentRun>;
|
|
267
297
|
delete(runId: string, options?: AgentBetaOptions): Promise<DeletedAgentRun>;
|
|
268
|
-
pollUntilFinished(runId: string, options?: WithBetaOptions<
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}>): Promise<AgentRun & {
|
|
272
|
-
status: "completed" | "failed" | "cancelled";
|
|
273
|
-
}>;
|
|
298
|
+
pollUntilFinished(runId: string, options?: WithBetaOptions<AgentWaitOptions>): Promise<AgentTerminalRun>;
|
|
299
|
+
createAndWait<T>(params: WithBetaOptions<Omit<AgentCreateOptions<T>, "stream">>, options?: AgentWaitOptions): Promise<AgentCompletedRunTyped<T>>;
|
|
300
|
+
createAndWait(params: CreateAgentRunParams & AgentBetaOptions, options?: AgentWaitOptions): Promise<AgentCompletedRun>;
|
|
274
301
|
}
|
|
275
302
|
/**
|
|
276
303
|
* @deprecated Use AgentClient instead.
|
|
@@ -4372,4 +4399,4 @@ declare class Exa {
|
|
|
4372
4399
|
private parseSSEStream;
|
|
4373
4400
|
}
|
|
4374
4401
|
|
|
4375
|
-
export { AGENT_BETA_HEADER, AgentBetaClient, type AgentBetaOptions, AgentClient, type AgentConfidence, type AgentCostDollars, type AgentCreateOptions, type AgentDataSource, type AgentDataSourceProvider, type AgentEffort, type AgentError, type AgentEvent, type AgentGroundingCitation, type AgentGroundingEntry, type AgentInput, type AgentOutput, type AgentRun, AgentRunEventsClient, type AgentRunStatus, type AgentRunTyped, AgentRunsClient, type AgentStopReason, type AgentUsage, type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, BetaClient, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateAgentRunParams, type CreateAgentRunParamsTyped, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateSearchMonitorParams, type CreateSearchMonitorResponse, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type DeepObjectOutputSchema, type DeepOutputSchema, type DeepSearchOutput, type DeepSearchOutputGrounding, type DeepSearchOutputGroundingCitation, type DeepSearchOutputGroundingConfidence, type DeepSearchType, type DeepTextOutputSchema, type Default, type DeletedAgentRun, type EnrichmentResult, type Entity, type EntityCompanyProperties, type EntityCompanyPropertiesFinancials, type EntityCompanyPropertiesFundingRound, type EntityCompanyPropertiesHeadquarters, type EntityCompanyPropertiesWebTraffic, type EntityCompanyPropertiesWorkforce, type EntityDateRange, type EntityPersonProperties, type EntityPersonPropertiesCompanyRef, type EntityPersonPropertiesWorkHistoryEntry, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type GroundingCitation, type GroundingEntry, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListAgentRunEventsParams, type ListAgentRunEventsResponse, type ListAgentRunsParams, type ListAgentRunsResponse, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, type ListSearchMonitorRunsParams, type ListSearchMonitorRunsResponse, type ListSearchMonitorsParams, type ListSearchMonitorsResponse, type ListWebhookAttemptsResponse, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetItemsOptions, type ListWebsetsResponse, type LivecrawlOptions, type Monitor, type MonitorBehavior, type MonitorCadence, MonitorObject, type MonitorRun, MonitorRunObject, MonitorRunStatus, MonitorRunType, MonitorStatus, type PersonEntity, type PreviewWebsetParameters, type PreviewWebsetResponse, type RegularSearchOptions, type Research, type ResearchCreateParamsTyped, type ResearchCreateRequest, type ResearchCreateResponse, type ResearchDefinitionEvent, type ResearchEvent, type ResearchOperation, type ResearchOutputEvent, type ResearchPaperEntity, type ResearchPlanDefinitionEvent, type ResearchPlanOperationEvent, type ResearchPlanOutputEvent, type ResearchStatus, type ResearchStreamEvent, type ResearchStreamEventTyped, type ResearchTaskDefinitionEvent, type ResearchTaskOperationEvent, type ResearchTaskOutputEvent, type ResearchTyped, type SearchMonitor, type SearchMonitorRun, type SearchMonitorRunFailReason, type SearchMonitorRunOutput, type SearchMonitorRunStatus, SearchMonitorRunsClient, type SearchMonitorSearch, type SearchMonitorStatus, type SearchMonitorTrigger, type SearchMonitorWebhook, type SearchMonitorWebhookEvent, SearchMonitorsClient, type SearchResponse, type SearchResult, type SearchStreamChunk, type SectionTag, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type TriggerSearchMonitorResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateSearchMonitorParams, type UpdateWebhookParameters, type UpdateWebsetRequest, type VerbosityOptions, type WaitUntilCompletedOptions, type Webhook, type WebhookAttempt, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, WebsetExcludeSource, type WebsetHeadersLike, WebsetImportSource, type WebsetItem, type WebsetItemArticleProperties, type WebsetItemCompanyProperties, type WebsetItemCustomProperties, type WebsetItemEvaluation, WebsetItemEvaluationSatisfied, type WebsetItemPersonProperties, type WebsetItemResearchPaperProperties, WebsetItemSource, WebsetItemsClient, WebsetMonitorsClient, type WebsetSearch, WebsetSearchBehavior, WebsetSearchCanceledReason, WebsetSearchScopeSource, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|
|
4402
|
+
export { AGENT_BETA_HEADER, AgentBetaClient, type AgentBetaOptions, AgentClient, type AgentConfidence, type AgentCostDollars, type AgentCreateOptions, type AgentDataSource, type AgentDataSourceProvider, type AgentEffort, type AgentError, type AgentEvent, type AgentGroundingCitation, type AgentGroundingEntry, type AgentInput, type AgentOutput, type AgentRun, AgentRunCancelledError, AgentRunEventsClient, AgentRunFailedError, type AgentRunStatus, type AgentRunTyped, AgentRunsClient, type AgentStopReason, type AgentUsage, type AgentWaitOptions, type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, BetaClient, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateAgentRunParams, type CreateAgentRunParamsTyped, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateSearchMonitorParams, type CreateSearchMonitorResponse, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type DeepObjectOutputSchema, type DeepOutputSchema, type DeepSearchOutput, type DeepSearchOutputGrounding, type DeepSearchOutputGroundingCitation, type DeepSearchOutputGroundingConfidence, type DeepSearchType, type DeepTextOutputSchema, type Default, type DeletedAgentRun, type EnrichmentResult, type Entity, type EntityCompanyProperties, type EntityCompanyPropertiesFinancials, type EntityCompanyPropertiesFundingRound, type EntityCompanyPropertiesHeadquarters, type EntityCompanyPropertiesWebTraffic, type EntityCompanyPropertiesWorkforce, type EntityDateRange, type EntityPersonProperties, type EntityPersonPropertiesCompanyRef, type EntityPersonPropertiesWorkHistoryEntry, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type GroundingCitation, type GroundingEntry, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListAgentRunEventsParams, type ListAgentRunEventsResponse, type ListAgentRunsParams, type ListAgentRunsResponse, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, type ListSearchMonitorRunsParams, type ListSearchMonitorRunsResponse, type ListSearchMonitorsParams, type ListSearchMonitorsResponse, type ListWebhookAttemptsResponse, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetItemsOptions, type ListWebsetsResponse, type LivecrawlOptions, type Monitor, type MonitorBehavior, type MonitorCadence, MonitorObject, type MonitorRun, MonitorRunObject, MonitorRunStatus, MonitorRunType, MonitorStatus, type PersonEntity, type PreviewWebsetParameters, type PreviewWebsetResponse, type RegularSearchOptions, type Research, type ResearchCreateParamsTyped, type ResearchCreateRequest, type ResearchCreateResponse, type ResearchDefinitionEvent, type ResearchEvent, type ResearchOperation, type ResearchOutputEvent, type ResearchPaperEntity, type ResearchPlanDefinitionEvent, type ResearchPlanOperationEvent, type ResearchPlanOutputEvent, type ResearchStatus, type ResearchStreamEvent, type ResearchStreamEventTyped, type ResearchTaskDefinitionEvent, type ResearchTaskOperationEvent, type ResearchTaskOutputEvent, type ResearchTyped, type SearchMonitor, type SearchMonitorRun, type SearchMonitorRunFailReason, type SearchMonitorRunOutput, type SearchMonitorRunStatus, SearchMonitorRunsClient, type SearchMonitorSearch, type SearchMonitorStatus, type SearchMonitorTrigger, type SearchMonitorWebhook, type SearchMonitorWebhookEvent, SearchMonitorsClient, type SearchResponse, type SearchResult, type SearchStreamChunk, type SectionTag, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type TriggerSearchMonitorResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateSearchMonitorParams, type UpdateWebhookParameters, type UpdateWebsetRequest, type VerbosityOptions, type WaitUntilCompletedOptions, type Webhook, type WebhookAttempt, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, WebsetExcludeSource, type WebsetHeadersLike, WebsetImportSource, type WebsetItem, type WebsetItemArticleProperties, type WebsetItemCompanyProperties, type WebsetItemCustomProperties, type WebsetItemEvaluation, WebsetItemEvaluationSatisfied, type WebsetItemPersonProperties, type WebsetItemResearchPaperProperties, WebsetItemSource, WebsetItemsClient, WebsetMonitorsClient, type WebsetSearch, WebsetSearchBehavior, WebsetSearchCanceledReason, WebsetSearchScopeSource, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,9 @@ __export(index_exports, {
|
|
|
33
33
|
AGENT_BETA_HEADER: () => AGENT_BETA_HEADER,
|
|
34
34
|
AgentBetaClient: () => AgentBetaClient,
|
|
35
35
|
AgentClient: () => AgentClient,
|
|
36
|
+
AgentRunCancelledError: () => AgentRunCancelledError,
|
|
36
37
|
AgentRunEventsClient: () => AgentRunEventsClient,
|
|
38
|
+
AgentRunFailedError: () => AgentRunFailedError,
|
|
37
39
|
AgentRunsClient: () => AgentRunsClient,
|
|
38
40
|
BetaClient: () => BetaClient,
|
|
39
41
|
CreateEnrichmentParametersFormat: () => CreateEnrichmentParametersFormat,
|
|
@@ -82,7 +84,7 @@ var import_cross_fetch = __toESM(require("cross-fetch"));
|
|
|
82
84
|
// package.json
|
|
83
85
|
var package_default = {
|
|
84
86
|
name: "exa-js",
|
|
85
|
-
version: "2.
|
|
87
|
+
version: "2.16.0",
|
|
86
88
|
description: "Exa SDK for Node.js and the browser",
|
|
87
89
|
publishConfig: {
|
|
88
90
|
access: "public"
|
|
@@ -240,11 +242,51 @@ var AgentBaseClient = class {
|
|
|
240
242
|
};
|
|
241
243
|
|
|
242
244
|
// src/agent/client.ts
|
|
245
|
+
var DEFAULT_AGENT_POLL_INTERVAL_MS = 1e3;
|
|
246
|
+
var DEFAULT_AGENT_POLL_TIMEOUT_MS = 60 * 60 * 1e3;
|
|
247
|
+
var DEFAULT_AGENT_CREATE_AND_WAIT_TIMEOUT_MS = 2 * 60 * 1e3;
|
|
248
|
+
var TERMINAL_AGENT_RUN_STATUSES = /* @__PURE__ */ new Set([
|
|
249
|
+
"completed",
|
|
250
|
+
"failed",
|
|
251
|
+
"cancelled"
|
|
252
|
+
]);
|
|
253
|
+
var AgentRunFailedError = class extends Error {
|
|
254
|
+
constructor(run) {
|
|
255
|
+
super(run.error?.message ?? `Agent run ${run.id} failed`);
|
|
256
|
+
this.name = "AgentRunFailedError";
|
|
257
|
+
this.run = run;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var AgentRunCancelledError = class extends Error {
|
|
261
|
+
constructor(run) {
|
|
262
|
+
super(`Agent run ${run.id} was cancelled`);
|
|
263
|
+
this.name = "AgentRunCancelledError";
|
|
264
|
+
this.run = run;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
243
267
|
function headersForBetas(betas) {
|
|
244
268
|
const betaValues = betas?.filter(Boolean);
|
|
245
269
|
if (!betaValues?.length) return void 0;
|
|
246
270
|
return { "Exa-Beta": betaValues.join(",") };
|
|
247
271
|
}
|
|
272
|
+
function isTerminalAgentRunStatus(status) {
|
|
273
|
+
return TERMINAL_AGENT_RUN_STATUSES.has(status);
|
|
274
|
+
}
|
|
275
|
+
function ensureCompletedRun(run) {
|
|
276
|
+
if (run.status === "failed") {
|
|
277
|
+
throw new AgentRunFailedError(run);
|
|
278
|
+
}
|
|
279
|
+
if (run.status === "cancelled") {
|
|
280
|
+
throw new AgentRunCancelledError(run);
|
|
281
|
+
}
|
|
282
|
+
return run;
|
|
283
|
+
}
|
|
284
|
+
function createAndWaitPollOptions(options) {
|
|
285
|
+
return {
|
|
286
|
+
pollInterval: options?.pollInterval ?? DEFAULT_AGENT_POLL_INTERVAL_MS,
|
|
287
|
+
timeoutMs: options?.timeoutMs ?? DEFAULT_AGENT_CREATE_AND_WAIT_TIMEOUT_MS
|
|
288
|
+
};
|
|
289
|
+
}
|
|
248
290
|
function buildAgentRunPayload(params) {
|
|
249
291
|
const { stream, outputSchema, ...rest } = params;
|
|
250
292
|
let schema = outputSchema;
|
|
@@ -405,12 +447,12 @@ var AgentRunsClient = class extends AgentBaseClient {
|
|
|
405
447
|
* Poll an Agent run until it reaches a terminal status.
|
|
406
448
|
*/
|
|
407
449
|
async pollUntilFinished(runId, options) {
|
|
408
|
-
const pollInterval = options?.pollInterval ??
|
|
409
|
-
const timeoutMs = options?.timeoutMs ??
|
|
450
|
+
const pollInterval = options?.pollInterval ?? DEFAULT_AGENT_POLL_INTERVAL_MS;
|
|
451
|
+
const timeoutMs = options?.timeoutMs ?? DEFAULT_AGENT_POLL_TIMEOUT_MS;
|
|
410
452
|
const startTime = Date.now();
|
|
411
453
|
while (true) {
|
|
412
454
|
const run = await this.get(runId);
|
|
413
|
-
if (run.status
|
|
455
|
+
if (isTerminalAgentRunStatus(run.status)) {
|
|
414
456
|
return run;
|
|
415
457
|
}
|
|
416
458
|
if (Date.now() - startTime > timeoutMs) {
|
|
@@ -421,6 +463,18 @@ var AgentRunsClient = class extends AgentBaseClient {
|
|
|
421
463
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
422
464
|
}
|
|
423
465
|
}
|
|
466
|
+
async createAndWait(params, options) {
|
|
467
|
+
const { stream: _stream, ...createParams } = params;
|
|
468
|
+
const run = await this.create(
|
|
469
|
+
createParams
|
|
470
|
+
);
|
|
471
|
+
const runId = run.id;
|
|
472
|
+
const terminalRun = await this.pollUntilFinished(
|
|
473
|
+
runId,
|
|
474
|
+
createAndWaitPollOptions(options)
|
|
475
|
+
);
|
|
476
|
+
return ensureCompletedRun(terminalRun);
|
|
477
|
+
}
|
|
424
478
|
};
|
|
425
479
|
var AgentClient = class {
|
|
426
480
|
constructor(client) {
|
|
@@ -543,8 +597,8 @@ var AgentBetaRunsClient = class extends AgentRunsClient {
|
|
|
543
597
|
);
|
|
544
598
|
}
|
|
545
599
|
async pollUntilFinished(runId, options) {
|
|
546
|
-
const pollInterval = options?.pollInterval ??
|
|
547
|
-
const timeoutMs = options?.timeoutMs ??
|
|
600
|
+
const pollInterval = options?.pollInterval ?? DEFAULT_AGENT_POLL_INTERVAL_MS;
|
|
601
|
+
const timeoutMs = options?.timeoutMs ?? DEFAULT_AGENT_POLL_TIMEOUT_MS;
|
|
548
602
|
const startTime = Date.now();
|
|
549
603
|
const headers = headersForBetas(options?.betas);
|
|
550
604
|
while (true) {
|
|
@@ -555,7 +609,7 @@ var AgentBetaRunsClient = class extends AgentRunsClient {
|
|
|
555
609
|
void 0,
|
|
556
610
|
headers
|
|
557
611
|
);
|
|
558
|
-
if (run.status
|
|
612
|
+
if (isTerminalAgentRunStatus(run.status)) {
|
|
559
613
|
return run;
|
|
560
614
|
}
|
|
561
615
|
if (Date.now() - startTime > timeoutMs) {
|
|
@@ -566,6 +620,23 @@ var AgentBetaRunsClient = class extends AgentRunsClient {
|
|
|
566
620
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
567
621
|
}
|
|
568
622
|
}
|
|
623
|
+
async createAndWait(params, options) {
|
|
624
|
+
const {
|
|
625
|
+
betas,
|
|
626
|
+
stream: _stream,
|
|
627
|
+
...createParams
|
|
628
|
+
} = params;
|
|
629
|
+
const run = await this.create({
|
|
630
|
+
...createParams,
|
|
631
|
+
betas
|
|
632
|
+
});
|
|
633
|
+
const runId = run.id;
|
|
634
|
+
const terminalRun = await this.pollUntilFinished(runId, {
|
|
635
|
+
...createAndWaitPollOptions(options),
|
|
636
|
+
betas
|
|
637
|
+
});
|
|
638
|
+
return ensureCompletedRun(terminalRun);
|
|
639
|
+
}
|
|
569
640
|
};
|
|
570
641
|
var AgentBetaClient = class extends AgentClient {
|
|
571
642
|
constructor(clientOrAgent) {
|
|
@@ -2550,7 +2621,9 @@ var index_default = Exa2;
|
|
|
2550
2621
|
AGENT_BETA_HEADER,
|
|
2551
2622
|
AgentBetaClient,
|
|
2552
2623
|
AgentClient,
|
|
2624
|
+
AgentRunCancelledError,
|
|
2553
2625
|
AgentRunEventsClient,
|
|
2626
|
+
AgentRunFailedError,
|
|
2554
2627
|
AgentRunsClient,
|
|
2555
2628
|
BetaClient,
|
|
2556
2629
|
CreateEnrichmentParametersFormat,
|