exa-js 1.10.2 → 2.0.2

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.ts CHANGED
@@ -1549,14 +1549,16 @@ interface components {
1549
1549
  type: "person";
1550
1550
  };
1551
1551
  PreviewWebsetParameters: {
1552
- /** @description Entity used to inform the decomposition.
1553
- *
1554
- * It is not required to provide it, we automatically detect the entity from all the information provided in the query. Only use this when you need more fine control. */
1555
- entity?: components["schemas"]["Entity"];
1556
- /** @description Natural language search query describing what you are looking for.
1557
- *
1558
- * Be specific and descriptive about your requirements, characteristics, and any constraints that help narrow down the results. */
1559
- query: string;
1552
+ search: {
1553
+ /** @description Entity used to inform the decomposition.
1554
+ *
1555
+ * It is not required to provide it, we automatically detect the entity from all the information provided in the query. Only use this when you need more fine control. */
1556
+ entity?: components["schemas"]["Entity"];
1557
+ /** @description Natural language search query describing what you are looking for.
1558
+ *
1559
+ * Be specific and descriptive about your requirements, characteristics, and any constraints that help narrow down the results. */
1560
+ query: string;
1561
+ };
1560
1562
  };
1561
1563
  PreviewWebsetResponse: {
1562
1564
  /** @description Detected enrichments from the query. */
@@ -1734,6 +1736,12 @@ interface components {
1734
1736
  createdAt: string;
1735
1737
  /** @description The Enrichments to apply to the Webset Items. */
1736
1738
  enrichments: components["schemas"]["WebsetEnrichment"][];
1739
+ /** @description The Excludes sources (existing imports or websets) that apply to all operations within this Webset. Any results found within these sources will be omitted across all search and import operations. */
1740
+ excludes?: {
1741
+ id: string;
1742
+ /** @enum {string} */
1743
+ source: WebsetExcludeSource;
1744
+ }[];
1737
1745
  /** @description The external identifier for the webset */
1738
1746
  externalId: string | null;
1739
1747
  /** @description The unique identifier for the webset */
@@ -1762,8 +1770,6 @@ interface components {
1762
1770
  * @enum {string}
1763
1771
  */
1764
1772
  status: WebsetStatus;
1765
- /** @description The Streams for the Webset. */
1766
- streams: unknown[];
1767
1773
  /** @description The title of the webset */
1768
1774
  title: string | null;
1769
1775
  /**
@@ -2965,10 +2971,33 @@ declare class ExaError extends Error {
2965
2971
  constructor(message: string, statusCode: number, timestamp?: string, path?: string);
2966
2972
  }
2967
2973
 
2968
- declare const isBeta = false;
2969
2974
  /**
2970
- * Search options for performing a search query.
2975
+ * Options for retrieving page contents
2976
+ * @typedef {Object} ContentsOptions
2977
+ * @property {TextContentsOptions | boolean} [text] - Options for retrieving text contents.
2978
+ * @property {SummaryContentsOptions | boolean} [summary] - Options for retrieving summary.
2979
+ * @property {LivecrawlOptions} [livecrawl] - Options for livecrawling contents. Default is "never" for neural/auto search, "fallback" for keyword search.
2980
+ * @property {number} [livecrawlTimeout] - The timeout for livecrawling. Max and default is 10000ms.
2981
+ * @property {boolean} [filterEmptyResults] - If true, filters out results with no contents. Default is true.
2982
+ * @property {number} [subpages] - The number of subpages to return for each result, where each subpage is derived from an internal link for the result.
2983
+ * @property {string | string[]} [subpageTarget] - Text used to match/rank subpages in the returned subpage list. You could use "about" to get *about* page for websites. Note that this is a fuzzy matcher.
2984
+ * @property {ExtrasOptions} [extras] - Miscelleneous data derived from results
2985
+ */
2986
+ type ContentsOptions = {
2987
+ text?: TextContentsOptions | true;
2988
+ summary?: SummaryContentsOptions | true;
2989
+ livecrawl?: LivecrawlOptions;
2990
+ context?: ContextOptions | true;
2991
+ livecrawlTimeout?: number;
2992
+ filterEmptyResults?: boolean;
2993
+ subpages?: number;
2994
+ subpageTarget?: string | string[];
2995
+ extras?: ExtrasOptions;
2996
+ };
2997
+ /**
2998
+ * Options for performing a search query
2971
2999
  * @typedef {Object} SearchOptions
3000
+ * @property {ContentsOptions | boolean} [contents] - Options for retrieving page contents for each result returned. Default is { text: { maxCharacters: 10_000 } }.
2972
3001
  * @property {number} [numResults] - Number of search results to return. Default 10. Max 10 for basic plans.
2973
3002
  * @property {string[]} [includeDomains] - List of domains to include in the search.
2974
3003
  * @property {string[]} [excludeDomains] - List of domains to exclude in the search.
@@ -2983,6 +3012,7 @@ declare const isBeta = false;
2983
3012
  * @property {string} [userLocation] - The two-letter ISO country code of the user, e.g. US.
2984
3013
  */
2985
3014
  type BaseSearchOptions = {
3015
+ contents?: ContentsOptions;
2986
3016
  numResults?: number;
2987
3017
  includeDomains?: string[];
2988
3018
  excludeDomains?: string[];
@@ -3020,31 +3050,6 @@ type ExtrasOptions = {
3020
3050
  links?: number;
3021
3051
  imageLinks?: number;
3022
3052
  };
3023
- /**
3024
- * Search options for performing a search query.
3025
- * @typedef {Object} ContentsOptions
3026
- * @property {TextContentsOptions | boolean} [text] - Options for retrieving text contents.
3027
- * @property {HighlightsContentsOptions | boolean} [highlights] - Options for retrieving highlights. NOTE: For search type "deep", only "true" is allowed. "query", "numSentences" and "highlightsPerUrl" will not be respected;
3028
- * @property {SummaryContentsOptions | boolean} [summary] - Options for retrieving summary.
3029
- * @property {LivecrawlOptions} [livecrawl] - Options for livecrawling contents. Default is "never" for neural/auto search, "fallback" for keyword search.
3030
- * @property {number} [livecrawlTimeout] - The timeout for livecrawling. Max and default is 10000ms.
3031
- * @property {boolean} [filterEmptyResults] - If true, filters out results with no contents. Default is true.
3032
- * @property {number} [subpages] - The number of subpages to return for each result, where each subpage is derived from an internal link for the result.
3033
- * @property {string | string[]} [subpageTarget] - Text used to match/rank subpages in the returned subpage list. You could use "about" to get *about* page for websites. Note that this is a fuzzy matcher.
3034
- * @property {ExtrasOptions} [extras] - Miscelleneous data derived from results
3035
- */
3036
- type ContentsOptions = {
3037
- text?: TextContentsOptions | true;
3038
- highlights?: HighlightsContentsOptions | true;
3039
- summary?: SummaryContentsOptions | true;
3040
- livecrawl?: LivecrawlOptions;
3041
- context?: ContextOptions | true;
3042
- livecrawlTimeout?: number;
3043
- filterEmptyResults?: boolean;
3044
- subpages?: number;
3045
- subpageTarget?: string | string[];
3046
- extras?: ExtrasOptions;
3047
- } & (typeof isBeta extends true ? {} : {});
3048
3053
  /**
3049
3054
  * Options for livecrawling contents
3050
3055
  * @typedef {string} LivecrawlOptions
@@ -3060,20 +3065,6 @@ type TextContentsOptions = {
3060
3065
  maxCharacters?: number;
3061
3066
  includeHtmlTags?: boolean;
3062
3067
  };
3063
- /**
3064
- * Options for retrieving highlights from page.
3065
- * NOTE: For search type "deep", these options will not be respected. Highlights will be generated with respect
3066
- * to your initial query, and may vary in quantity and length.
3067
- * @typedef {Object} HighlightsContentsOptions
3068
- * @property {string} [query] - The query string to use for highlights search.
3069
- * @property {number} [numSentences] - The number of sentences to return for each highlight.
3070
- * @property {number} [highlightsPerUrl] - The number of highlights to return for each URL.
3071
- */
3072
- type HighlightsContentsOptions = {
3073
- query?: string;
3074
- numSentences?: number;
3075
- highlightsPerUrl?: number;
3076
- };
3077
3068
  /**
3078
3069
  * Options for retrieving summary from page.
3079
3070
  * @typedef {Object} SummaryContentsOptions
@@ -3104,15 +3095,6 @@ type ContextOptions = {
3104
3095
  type TextResponse = {
3105
3096
  text: string;
3106
3097
  };
3107
- /**
3108
- * @typedef {Object} HighlightsResponse
3109
- * @property {string[]} highlights - The highlights as an array of strings.
3110
- * @property {number[]} highlightScores - The corresponding scores as an array of floats, 0 to 1
3111
- */
3112
- type HighlightsResponse = {
3113
- highlights: string[];
3114
- highlightScores: number[];
3115
- };
3116
3098
  /**
3117
3099
  * @typedef {Object} SummaryResponse
3118
3100
  * @property {string} summary - The generated summary of the page content.
@@ -3141,22 +3123,20 @@ type SubpagesResponse<T extends ContentsOptions> = {
3141
3123
  type Default<T extends {}, U> = [keyof T] extends [never] ? U : T;
3142
3124
  /**
3143
3125
  * @typedef {Object} ContentsResultComponent
3144
- * Depending on 'ContentsOptions', this yields a combination of 'TextResponse', 'HighlightsResponse', 'SummaryResponse', or an empty object.
3126
+ * Depending on 'ContentsOptions', this yields a combination of 'TextResponse', 'SummaryResponse', or an empty object.
3145
3127
  *
3146
3128
  * @template T - A type extending from 'ContentsOptions'.
3147
3129
  */
3148
- type ContentsResultComponent<T extends ContentsOptions> = Default<(T["text"] extends object | true ? TextResponse : {}) & (T["highlights"] extends object | true ? HighlightsResponse : {}) & (T["summary"] extends object | true ? SummaryResponse : {}) & (T["subpages"] extends number ? SubpagesResponse<T> : {}) & (T["extras"] extends object ? ExtrasResponse : {}), TextResponse>;
3130
+ type ContentsResultComponent<T extends ContentsOptions> = (T["text"] extends object | true ? TextResponse : {}) & (T["summary"] extends object | true ? SummaryResponse : {}) & (T["subpages"] extends number ? SubpagesResponse<T> : {}) & (T["extras"] extends object ? ExtrasResponse : {});
3149
3131
  /**
3150
3132
  * Represents the cost breakdown related to contents retrieval. Fields are optional because
3151
3133
  * only non-zero costs are included.
3152
3134
  * @typedef {Object} CostDollarsContents
3153
3135
  * @property {number} [text] - The cost in dollars for retrieving text.
3154
- * @property {number} [highlights] - The cost in dollars for retrieving highlights.
3155
3136
  * @property {number} [summary] - The cost in dollars for retrieving summary.
3156
3137
  */
3157
3138
  type CostDollarsContents = {
3158
3139
  text?: number;
3159
- highlights?: number;
3160
3140
  summary?: number;
3161
3141
  };
3162
3142
  /**
@@ -3209,7 +3189,6 @@ type SearchResult<T extends ContentsOptions> = {
3209
3189
  * @typedef {Object} SearchResponse
3210
3190
  * @property {Result[]} results - The list of search results.
3211
3191
  * @property {string} [context] - The context for the search.
3212
- * @property {string} [autopromptString] - The autoprompt string, if applicable.
3213
3192
  * @property {string} [autoDate] - The autoprompt date, if applicable.
3214
3193
  * @property {string} requestId - The request ID for the search.
3215
3194
  * @property {CostDollars} [costDollars] - The cost breakdown for this request.
@@ -3217,7 +3196,6 @@ type SearchResult<T extends ContentsOptions> = {
3217
3196
  type SearchResponse<T extends ContentsOptions> = {
3218
3197
  results: SearchResult<T>[];
3219
3198
  context?: string;
3220
- autopromptString?: string;
3221
3199
  autoDate?: string;
3222
3200
  requestId: string;
3223
3201
  statuses?: Array<Status>;
@@ -3341,13 +3319,55 @@ declare class Exa {
3341
3319
  rawRequest(endpoint: string, method?: string, body?: Record<string, unknown>, queryParams?: Record<string, string | number | boolean | string[] | undefined>): Promise<Response>;
3342
3320
  /**
3343
3321
  * Performs a search with an Exa prompt-engineered query.
3322
+ * By default, returns text contents. Use contents: false to opt-out.
3323
+ *
3324
+ * @param {string} query - The query string.
3325
+ * @returns {Promise<SearchResponse<{ text: { maxCharacters: 10_000 } }>>} A list of relevant search results with text contents.
3326
+ */
3327
+ search(query: string): Promise<SearchResponse<{
3328
+ text: {
3329
+ maxCharacters: 10_000;
3330
+ };
3331
+ }>>;
3332
+ /**
3333
+ * Performs a search without contents.
3334
+ *
3335
+ * @param {string} query - The query string.
3336
+ * @param {RegularSearchOptions & { contents: false }} options - Search options with contents explicitly disabled
3337
+ * @returns {Promise<SearchResponse<{}>>} A list of relevant search results without contents.
3338
+ */
3339
+ search(query: string, options: RegularSearchOptions & {
3340
+ contents: false | null | undefined;
3341
+ }): Promise<SearchResponse<{}>>;
3342
+ /**
3343
+ * Performs a search with specific contents.
3344
+ *
3345
+ * @param {string} query - The query string.
3346
+ * @param {RegularSearchOptions & { contents: T }} options - Search options with specific contents
3347
+ * @returns {Promise<SearchResponse<T>>} A list of relevant search results with requested contents.
3348
+ */
3349
+ search<T extends ContentsOptions>(query: string, options: RegularSearchOptions & {
3350
+ contents: T;
3351
+ }): Promise<SearchResponse<T>>;
3352
+ /**
3353
+ * Performs a search with an Exa prompt-engineered query.
3354
+ * When no contents option is specified, returns text contents by default.
3344
3355
  *
3345
3356
  * @param {string} query - The query string.
3346
- * @param {RegularSearchOptions} [options] - Additional search options
3347
- * @returns {Promise<SearchResponse<{}>>} A list of relevant search results.
3357
+ * @param {Omit<RegularSearchOptions, 'contents'>} options - Search options without contents
3358
+ * @returns {Promise<SearchResponse<{ text: true }>>} A list of relevant search results with text contents.
3348
3359
  */
3349
- search(query: string, options?: RegularSearchOptions): Promise<SearchResponse<{}>>;
3360
+ search(query: string, options: Omit<RegularSearchOptions, "contents">): Promise<SearchResponse<{
3361
+ text: true;
3362
+ }>>;
3350
3363
  /**
3364
+ * @deprecated Use `search()` instead. The search method now returns text contents by default.
3365
+ *
3366
+ * Migration examples:
3367
+ * - `searchAndContents(query)` → `search(query)`
3368
+ * - `searchAndContents(query, { text: true })` → `search(query, { contents: { text: true } })`
3369
+ * - `searchAndContents(query, { summary: true })` → `search(query, { contents: { summary: true } })`
3370
+ *
3351
3371
  * Performs a search with an Exa prompt-engineered query and returns the contents of the documents.
3352
3372
  *
3353
3373
  * @param {string} query - The query string.
@@ -3357,12 +3377,55 @@ declare class Exa {
3357
3377
  searchAndContents<T extends ContentsOptions>(query: string, options?: RegularSearchOptions & T): Promise<SearchResponse<T>>;
3358
3378
  /**
3359
3379
  * Finds similar links to the provided URL.
3380
+ * By default, returns text contents. Use contents: false to opt-out.
3381
+ *
3382
+ * @param {string} url - The URL for which to find similar links.
3383
+ * @returns {Promise<SearchResponse<{ text: { maxCharacters: 10_000 } }>>} A list of similar search results with text contents.
3384
+ */
3385
+ findSimilar(url: string): Promise<SearchResponse<{
3386
+ text: {
3387
+ maxCharacters: 10_000;
3388
+ };
3389
+ }>>;
3390
+ /**
3391
+ * Finds similar links to the provided URL without contents.
3392
+ *
3393
+ * @param {string} url - The URL for which to find similar links.
3394
+ * @param {FindSimilarOptions & { contents: false }} options - Options with contents explicitly disabled
3395
+ * @returns {Promise<SearchResponse<{}>>} A list of similar search results without contents.
3396
+ */
3397
+ findSimilar(url: string, options: FindSimilarOptions & {
3398
+ contents: false | null | undefined;
3399
+ }): Promise<SearchResponse<{}>>;
3400
+ /**
3401
+ * Finds similar links to the provided URL with specific contents.
3402
+ *
3403
+ * @param {string} url - The URL for which to find similar links.
3404
+ * @param {FindSimilarOptions & { contents: T }} options - Options with specific contents
3405
+ * @returns {Promise<SearchResponse<T>>} A list of similar search results with requested contents.
3406
+ */
3407
+ findSimilar<T extends ContentsOptions>(url: string, options: FindSimilarOptions & {
3408
+ contents: T;
3409
+ }): Promise<SearchResponse<T>>;
3410
+ /**
3411
+ * Finds similar links to the provided URL.
3412
+ * When no contents option is specified, returns text contents by default.
3413
+ *
3360
3414
  * @param {string} url - The URL for which to find similar links.
3361
- * @param {FindSimilarOptions} [options] - Additional options for finding similar links.
3362
- * @returns {Promise<SearchResponse<{}>>} A list of similar search results.
3415
+ * @param {Omit<FindSimilarOptions, 'contents'>} options - Options without contents
3416
+ * @returns {Promise<SearchResponse<{ text: true }>>} A list of similar search results with text contents.
3363
3417
  */
3364
- findSimilar(url: string, options?: FindSimilarOptions): Promise<SearchResponse<{}>>;
3418
+ findSimilar(url: string, options: Omit<FindSimilarOptions, "contents">): Promise<SearchResponse<{
3419
+ text: true;
3420
+ }>>;
3365
3421
  /**
3422
+ * @deprecated Use `findSimilar()` instead. The findSimilar method now returns text contents by default.
3423
+ *
3424
+ * Migration examples:
3425
+ * - `findSimilarAndContents(url)` → `findSimilar(url)`
3426
+ * - `findSimilarAndContents(url, { text: true })` → `findSimilar(url, { contents: { text: true } })`
3427
+ * - `findSimilarAndContents(url, { summary: true })` → `findSimilar(url, { contents: { summary: true } })`
3428
+ *
3366
3429
  * Finds similar links to the provided URL and returns the contents of the documents.
3367
3430
  * @param {string} url - The URL for which to find similar links.
3368
3431
  * @param {FindSimilarOptions & T} [options] - Additional options for finding similar links + contents.
@@ -3442,4 +3505,4 @@ declare class Exa {
3442
3505
  private parseSSEStream;
3443
3506
  }
3444
3507
 
3445
- export { type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type Default, type EnrichmentResult, type Entity, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, 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 SearchResponse, type SearchResult, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateWebhookParameters, type UpdateWebsetRequest, 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 };
3508
+ export { type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type Default, type EnrichmentResult, type Entity, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, 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 SearchResponse, type SearchResult, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateWebhookParameters, type UpdateWebsetRequest, 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
@@ -74,7 +74,7 @@ var import_cross_fetch = __toESM(require("cross-fetch"));
74
74
  // package.json
75
75
  var package_default = {
76
76
  name: "exa-js",
77
- version: "1.10.2",
77
+ version: "2.0.2",
78
78
  description: "Exa SDK for Node.js and the browser",
79
79
  publishConfig: {
80
80
  access: "public"
@@ -98,8 +98,9 @@ var package_default = {
98
98
  "build-fast": "tsup src/index.ts --format cjs,esm",
99
99
  build: "tsup",
100
100
  test: "vitest run",
101
+ "test:unit": "vitest run --config vitest.unit.config.ts",
102
+ "test:integration": "vitest run --config vitest.integration.config.ts",
101
103
  typecheck: "tsc --noEmit",
102
- "typecheck:src": "tsc --noEmit src/**/*.ts",
103
104
  "typecheck:examples": "tsc --noEmit examples/**/*.ts",
104
105
  "generate:types:websets": "openapi-typescript https://raw.githubusercontent.com/exa-labs/openapi-spec/refs/heads/master/exa-websets-spec.yaml --enum --root-types --alphabetize --root-types-no-schema-prefix --output ./src/websets/openapi.ts && npm run format:websets",
105
106
  format: 'prettier --write "src/**/*.ts" "examples/**/*.ts"',
@@ -1329,6 +1330,7 @@ var WebsetsClient = class extends WebsetsBaseClient {
1329
1330
  // src/index.ts
1330
1331
  var fetchImpl = typeof global !== "undefined" && global.fetch ? global.fetch : import_cross_fetch.default;
1331
1332
  var HeadersImpl = typeof global !== "undefined" && global.Headers ? global.Headers : import_cross_fetch.Headers;
1333
+ var DEFAULT_MAX_CHARACTERS = 1e4;
1332
1334
  var Exa2 = class {
1333
1335
  /**
1334
1336
  * Helper method to separate out the contents-specific options from the rest.
@@ -1336,7 +1338,6 @@ var Exa2 = class {
1336
1338
  extractContentsOptions(options) {
1337
1339
  const {
1338
1340
  text,
1339
- highlights,
1340
1341
  summary,
1341
1342
  subpages,
1342
1343
  subpageTarget,
@@ -1347,7 +1348,7 @@ var Exa2 = class {
1347
1348
  ...rest
1348
1349
  } = options;
1349
1350
  const contentsOptions = {};
1350
- if (text === void 0 && summary === void 0 && highlights === void 0 && extras === void 0) {
1351
+ if (text === void 0 && summary === void 0 && extras === void 0) {
1351
1352
  contentsOptions.text = true;
1352
1353
  }
1353
1354
  if (text !== void 0) contentsOptions.text = text;
@@ -1361,7 +1362,6 @@ var Exa2 = class {
1361
1362
  contentsOptions.summary = summary;
1362
1363
  }
1363
1364
  }
1364
- if (highlights !== void 0) contentsOptions.highlights = highlights;
1365
1365
  if (subpages !== void 0) contentsOptions.subpages = subpages;
1366
1366
  if (subpageTarget !== void 0)
1367
1367
  contentsOptions.subpageTarget = subpageTarget;
@@ -1383,10 +1383,10 @@ var Exa2 = class {
1383
1383
  constructor(apiKey, baseURL = "https://api.exa.ai") {
1384
1384
  this.baseURL = baseURL;
1385
1385
  if (!apiKey) {
1386
- apiKey = process.env.EXASEARCH_API_KEY;
1386
+ apiKey = process.env.EXA_API_KEY;
1387
1387
  if (!apiKey) {
1388
1388
  throw new ExaError(
1389
- "API key must be provided as an argument or as an environment variable (EXASEARCH_API_KEY)",
1389
+ "API key must be provided as an argument or as an environment variable (EXA_API_KEY)",
1390
1390
  401 /* Unauthorized */
1391
1391
  );
1392
1392
  }
@@ -1489,17 +1489,28 @@ var Exa2 = class {
1489
1489
  });
1490
1490
  return response;
1491
1491
  }
1492
- /**
1493
- * Performs a search with an Exa prompt-engineered query.
1494
- *
1495
- * @param {string} query - The query string.
1496
- * @param {RegularSearchOptions} [options] - Additional search options
1497
- * @returns {Promise<SearchResponse<{}>>} A list of relevant search results.
1498
- */
1499
1492
  async search(query, options) {
1493
+ if (options === void 0 || !("contents" in options)) {
1494
+ return await this.request("/search", "POST", {
1495
+ query,
1496
+ ...options,
1497
+ contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } }
1498
+ });
1499
+ }
1500
+ if (options.contents === false || options.contents === null || options.contents === void 0) {
1501
+ const { contents, ...restOptions } = options;
1502
+ return await this.request("/search", "POST", { query, ...restOptions });
1503
+ }
1500
1504
  return await this.request("/search", "POST", { query, ...options });
1501
1505
  }
1502
1506
  /**
1507
+ * @deprecated Use `search()` instead. The search method now returns text contents by default.
1508
+ *
1509
+ * Migration examples:
1510
+ * - `searchAndContents(query)` → `search(query)`
1511
+ * - `searchAndContents(query, { text: true })` → `search(query, { contents: { text: true } })`
1512
+ * - `searchAndContents(query, { summary: true })` → `search(query, { contents: { summary: true } })`
1513
+ *
1503
1514
  * Performs a search with an Exa prompt-engineered query and returns the contents of the documents.
1504
1515
  *
1505
1516
  * @param {string} query - The query string.
@@ -1507,30 +1518,55 @@ var Exa2 = class {
1507
1518
  * @returns {Promise<SearchResponse<T>>} A list of relevant search results with requested contents.
1508
1519
  */
1509
1520
  async searchAndContents(query, options) {
1510
- const { contentsOptions, restOptions } = options === void 0 ? { contentsOptions: { text: true }, restOptions: {} } : this.extractContentsOptions(options);
1521
+ const { contentsOptions, restOptions } = options === void 0 ? {
1522
+ contentsOptions: {
1523
+ text: { maxCharacters: DEFAULT_MAX_CHARACTERS }
1524
+ },
1525
+ restOptions: {}
1526
+ } : this.extractContentsOptions(options);
1511
1527
  return await this.request("/search", "POST", {
1512
1528
  query,
1513
1529
  contents: contentsOptions,
1514
1530
  ...restOptions
1515
1531
  });
1516
1532
  }
1517
- /**
1518
- * Finds similar links to the provided URL.
1519
- * @param {string} url - The URL for which to find similar links.
1520
- * @param {FindSimilarOptions} [options] - Additional options for finding similar links.
1521
- * @returns {Promise<SearchResponse<{}>>} A list of similar search results.
1522
- */
1523
1533
  async findSimilar(url, options) {
1534
+ if (options === void 0 || !("contents" in options)) {
1535
+ return await this.request("/findSimilar", "POST", {
1536
+ url,
1537
+ ...options,
1538
+ contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } }
1539
+ });
1540
+ }
1541
+ if (options.contents === false || options.contents === null || options.contents === void 0) {
1542
+ const { contents, ...restOptions } = options;
1543
+ return await this.request("/findSimilar", "POST", {
1544
+ url,
1545
+ ...restOptions
1546
+ });
1547
+ }
1524
1548
  return await this.request("/findSimilar", "POST", { url, ...options });
1525
1549
  }
1526
1550
  /**
1551
+ * @deprecated Use `findSimilar()` instead. The findSimilar method now returns text contents by default.
1552
+ *
1553
+ * Migration examples:
1554
+ * - `findSimilarAndContents(url)` → `findSimilar(url)`
1555
+ * - `findSimilarAndContents(url, { text: true })` → `findSimilar(url, { contents: { text: true } })`
1556
+ * - `findSimilarAndContents(url, { summary: true })` → `findSimilar(url, { contents: { summary: true } })`
1557
+ *
1527
1558
  * Finds similar links to the provided URL and returns the contents of the documents.
1528
1559
  * @param {string} url - The URL for which to find similar links.
1529
1560
  * @param {FindSimilarOptions & T} [options] - Additional options for finding similar links + contents.
1530
1561
  * @returns {Promise<SearchResponse<T>>} A list of similar search results, including requested contents.
1531
1562
  */
1532
1563
  async findSimilarAndContents(url, options) {
1533
- const { contentsOptions, restOptions } = options === void 0 ? { contentsOptions: { text: true }, restOptions: {} } : this.extractContentsOptions(options);
1564
+ const { contentsOptions, restOptions } = options === void 0 ? {
1565
+ contentsOptions: {
1566
+ text: { maxCharacters: DEFAULT_MAX_CHARACTERS }
1567
+ },
1568
+ restOptions: {}
1569
+ } : this.extractContentsOptions(options);
1534
1570
  return await this.request("/findSimilar", "POST", {
1535
1571
  url,
1536
1572
  contents: contentsOptions,