firecrawl 4.22.0 → 4.22.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.
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@mendable/firecrawl-js",
11
- version: "4.22.0",
11
+ version: "4.22.2",
12
12
  description: "JavaScript SDK for Firecrawl API",
13
13
  main: "dist/index.js",
14
14
  types: "dist/index.d.ts",
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "@mendable/firecrawl-js",
38
- version: "4.22.0",
38
+ version: "4.22.2",
39
39
  description: "JavaScript SDK for Firecrawl API",
40
40
  main: "dist/index.js",
41
41
  types: "dist/index.d.ts",
@@ -368,6 +368,30 @@ function ensureValidFormats(formats) {
368
368
  }
369
369
  continue;
370
370
  }
371
+ if (fmt.type === "question") {
372
+ const q = fmt;
373
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
374
+ throw new Error("question format requires a non-empty 'question' string");
375
+ }
376
+ continue;
377
+ }
378
+ if (fmt.type === "highlights") {
379
+ const h = fmt;
380
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
381
+ throw new Error("highlights format requires a non-empty 'query' string");
382
+ }
383
+ continue;
384
+ }
385
+ if (fmt.type === "query") {
386
+ const q = fmt;
387
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
388
+ throw new Error("query format requires a non-empty 'prompt' string");
389
+ }
390
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
391
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
392
+ }
393
+ continue;
394
+ }
371
395
  if (fmt.type === "screenshot") {
372
396
  const s = fmt;
373
397
  if (s.quality != null && (typeof s.quality !== "number" || s.quality < 0)) {
@@ -427,6 +451,30 @@ function ensureValidParseFormats(formats) {
427
451
  "json format schema appears to be a Zod schema's .shape property. Pass the Zod schema directly (e.g., `schema: MySchema`) instead of `schema: MySchema.shape`. The SDK will automatically convert Zod schemas to JSON Schema format."
428
452
  );
429
453
  }
454
+ continue;
455
+ }
456
+ if (fmt.type === "question") {
457
+ const q = fmt;
458
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
459
+ throw new Error("question format requires a non-empty 'question' string");
460
+ }
461
+ continue;
462
+ }
463
+ if (fmt.type === "highlights") {
464
+ const h = fmt;
465
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
466
+ throw new Error("highlights format requires a non-empty 'query' string");
467
+ }
468
+ continue;
469
+ }
470
+ if (fmt.type === "query") {
471
+ const q = fmt;
472
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
473
+ throw new Error("query format requires a non-empty 'prompt' string");
474
+ }
475
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
476
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
477
+ }
430
478
  }
431
479
  }
432
480
  }
@@ -2938,6 +2986,7 @@ var FirecrawlApp = class {
2938
2986
  * @param onActivity - Optional callback to receive activity updates in real-time.
2939
2987
  * @param onSource - Optional callback to receive source updates in real-time.
2940
2988
  * @returns The final research results.
2989
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
2941
2990
  */
2942
2991
  async deepResearch(query, params, onActivity, onSource) {
2943
2992
  try {
@@ -2994,6 +3043,7 @@ var FirecrawlApp = class {
2994
3043
  * Initiates a deep research operation on a given query without polling.
2995
3044
  * @param params - Parameters for the deep research operation.
2996
3045
  * @returns The response containing the research job ID.
3046
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
2997
3047
  */
2998
3048
  async asyncDeepResearch(query, params) {
2999
3049
  const headers = this.prepareHeaders();
@@ -3031,6 +3081,7 @@ var FirecrawlApp = class {
3031
3081
  * Checks the status of a deep research operation.
3032
3082
  * @param id - The ID of the deep research operation.
3033
3083
  * @returns The current status and results of the research operation.
3084
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
3034
3085
  */
3035
3086
  async checkDeepResearchStatus(id) {
3036
3087
  const headers = this.prepareHeaders();
@@ -3169,6 +3220,7 @@ var FirecrawlApp = class {
3169
3220
  * @param url - The URL to generate LLMs.txt from.
3170
3221
  * @param params - Parameters for the LLMs.txt generation operation.
3171
3222
  * @returns The final generation results.
3223
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
3172
3224
  */
3173
3225
  async generateLLMsText(url, params) {
3174
3226
  try {
@@ -3210,6 +3262,7 @@ var FirecrawlApp = class {
3210
3262
  * @param url - The URL to generate LLMs.txt from.
3211
3263
  * @param params - Parameters for the LLMs.txt generation operation.
3212
3264
  * @returns The response containing the generation job ID.
3265
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
3213
3266
  */
3214
3267
  async asyncGenerateLLMsText(url, params) {
3215
3268
  const headers = this.prepareHeaders();
@@ -3238,6 +3291,7 @@ var FirecrawlApp = class {
3238
3291
  * Checks the status of a LLMs.txt generation operation.
3239
3292
  * @param id - The ID of the LLMs.txt generation operation.
3240
3293
  * @returns The current status and results of the generation operation.
3294
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
3241
3295
  */
3242
3296
  async checkGenerateLLMsTextStatus(id) {
3243
3297
  const headers = this.prepareHeaders();
package/dist/index.d.cts CHANGED
@@ -40,17 +40,26 @@ interface AttributesFormat extends Format {
40
40
  attribute: string;
41
41
  }>;
42
42
  }
43
+ interface QuestionFormat {
44
+ type: 'question';
45
+ question: string;
46
+ }
47
+ interface HighlightsFormat {
48
+ type: 'highlights';
49
+ query: string;
50
+ }
51
+ /** @deprecated Use QuestionFormat or HighlightsFormat instead. */
43
52
  interface QueryFormat {
44
53
  type: 'query';
45
54
  prompt: string;
46
55
  mode?: 'freeform' | 'directQuote';
47
56
  }
48
- type FormatOption = FormatString | Format | JsonFormat | ChangeTrackingFormat | ScreenshotFormat | AttributesFormat | QueryFormat;
57
+ type FormatOption = FormatString | Format | JsonFormat | ChangeTrackingFormat | ScreenshotFormat | AttributesFormat | QuestionFormat | HighlightsFormat | QueryFormat;
49
58
  type ParseFormatString = Exclude<FormatString, 'screenshot' | 'changeTracking' | 'branding'>;
50
59
  interface ParseFormat {
51
60
  type: ParseFormatString;
52
61
  }
53
- type ParseFormatOption = ParseFormatString | ParseFormat | JsonFormat | AttributesFormat | QueryFormat;
62
+ type ParseFormatOption = ParseFormatString | ParseFormat | JsonFormat | AttributesFormat | QuestionFormat | HighlightsFormat | QueryFormat;
54
63
  interface LocationConfig$1 {
55
64
  country?: string;
56
65
  languages?: string[];
@@ -345,6 +354,7 @@ interface Document {
345
354
  }>;
346
355
  actions?: Record<string, unknown>;
347
356
  answer?: string;
357
+ highlights?: string;
348
358
  warning?: string;
349
359
  changeTracking?: Record<string, unknown>;
350
360
  branding?: BrandingProfile;
@@ -611,6 +621,8 @@ interface ExtractResponse$1 {
611
621
  data?: unknown;
612
622
  error?: string;
613
623
  warning?: string;
624
+ warnings?: string[];
625
+ replacement?: string;
614
626
  sources?: Record<string, unknown>;
615
627
  expiresAt?: string;
616
628
  creditsUsed?: number;
@@ -1511,6 +1523,8 @@ interface ExtractResponse<LLMSchema extends zt.ZodSchema = any> {
1511
1523
  data: LLMSchema;
1512
1524
  error?: string;
1513
1525
  warning?: string;
1526
+ warnings?: string[];
1527
+ replacement?: string;
1514
1528
  sources?: string[];
1515
1529
  creditsUsed?: number;
1516
1530
  }
@@ -1613,6 +1627,8 @@ interface DeepResearchParams<LLMSchema extends zt.ZodSchema = any> {
1613
1627
  interface DeepResearchResponse {
1614
1628
  success: boolean;
1615
1629
  id: string;
1630
+ warnings?: string[];
1631
+ replacement?: string;
1616
1632
  }
1617
1633
  /**
1618
1634
  * Status response interface for deep research operations.
@@ -1652,6 +1668,8 @@ interface DeepResearchStatusResponse {
1652
1668
  description: string;
1653
1669
  }>;
1654
1670
  summaries: string[];
1671
+ warnings?: string[];
1672
+ replacement?: string;
1655
1673
  }
1656
1674
  /**
1657
1675
  * Parameters for LLMs.txt generation operations.
@@ -1683,6 +1701,8 @@ interface GenerateLLMsTextParams {
1683
1701
  interface GenerateLLMsTextResponse {
1684
1702
  success: boolean;
1685
1703
  id: string;
1704
+ warnings?: string[];
1705
+ replacement?: string;
1686
1706
  }
1687
1707
  /**
1688
1708
  * Status response interface for LLMs.txt generation operations.
@@ -1696,6 +1716,8 @@ interface GenerateLLMsTextStatusResponse {
1696
1716
  status: "processing" | "completed" | "failed";
1697
1717
  error?: string;
1698
1718
  expiresAt: string;
1719
+ warnings?: string[];
1720
+ replacement?: string;
1699
1721
  }
1700
1722
  /**
1701
1723
  * Response interface for queue status operations.
@@ -1945,6 +1967,7 @@ declare class FirecrawlApp {
1945
1967
  * @param onActivity - Optional callback to receive activity updates in real-time.
1946
1968
  * @param onSource - Optional callback to receive source updates in real-time.
1947
1969
  * @returns The final research results.
1970
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
1948
1971
  */
1949
1972
  deepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>, onActivity?: (activity: {
1950
1973
  type: string;
@@ -1962,12 +1985,14 @@ declare class FirecrawlApp {
1962
1985
  * Initiates a deep research operation on a given query without polling.
1963
1986
  * @param params - Parameters for the deep research operation.
1964
1987
  * @returns The response containing the research job ID.
1988
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
1965
1989
  */
1966
1990
  asyncDeepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>): Promise<DeepResearchResponse | ErrorResponse>;
1967
1991
  /**
1968
1992
  * Checks the status of a deep research operation.
1969
1993
  * @param id - The ID of the deep research operation.
1970
1994
  * @returns The current status and results of the research operation.
1995
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
1971
1996
  */
1972
1997
  checkDeepResearchStatus(id: string): Promise<DeepResearchStatusResponse | ErrorResponse>;
1973
1998
  /**
@@ -2004,6 +2029,7 @@ declare class FirecrawlApp {
2004
2029
  * @param url - The URL to generate LLMs.txt from.
2005
2030
  * @param params - Parameters for the LLMs.txt generation operation.
2006
2031
  * @returns The final generation results.
2032
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
2007
2033
  */
2008
2034
  generateLLMsText(url: string, params?: GenerateLLMsTextParams): Promise<GenerateLLMsTextStatusResponse | ErrorResponse>;
2009
2035
  /**
@@ -2011,12 +2037,14 @@ declare class FirecrawlApp {
2011
2037
  * @param url - The URL to generate LLMs.txt from.
2012
2038
  * @param params - Parameters for the LLMs.txt generation operation.
2013
2039
  * @returns The response containing the generation job ID.
2040
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
2014
2041
  */
2015
2042
  asyncGenerateLLMsText(url: string, params?: GenerateLLMsTextParams): Promise<GenerateLLMsTextResponse | ErrorResponse>;
2016
2043
  /**
2017
2044
  * Checks the status of a LLMs.txt generation operation.
2018
2045
  * @param id - The ID of the LLMs.txt generation operation.
2019
2046
  * @returns The current status and results of the generation operation.
2047
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
2020
2048
  */
2021
2049
  checkGenerateLLMsTextStatus(id: string): Promise<GenerateLLMsTextStatusResponse | ErrorResponse>;
2022
2050
  /**
@@ -2081,4 +2109,4 @@ declare class Firecrawl extends FirecrawlClient {
2081
2109
  get v1(): FirecrawlApp;
2082
2110
  }
2083
2111
 
2084
- export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorEmailNotification, type MonitorNotification, type MonitorSchedule, type MonitorScrapeTarget, type MonitorSummary, type MonitorTarget, type MonitorWebhookConfig, type PDFAction, type PaginationConfig, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type PressAction, type QueryFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
2112
+ export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type HighlightsFormat, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorEmailNotification, type MonitorNotification, type MonitorSchedule, type MonitorScrapeTarget, type MonitorSummary, type MonitorTarget, type MonitorWebhookConfig, type PDFAction, type PaginationConfig, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type PressAction, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
package/dist/index.d.ts CHANGED
@@ -40,17 +40,26 @@ interface AttributesFormat extends Format {
40
40
  attribute: string;
41
41
  }>;
42
42
  }
43
+ interface QuestionFormat {
44
+ type: 'question';
45
+ question: string;
46
+ }
47
+ interface HighlightsFormat {
48
+ type: 'highlights';
49
+ query: string;
50
+ }
51
+ /** @deprecated Use QuestionFormat or HighlightsFormat instead. */
43
52
  interface QueryFormat {
44
53
  type: 'query';
45
54
  prompt: string;
46
55
  mode?: 'freeform' | 'directQuote';
47
56
  }
48
- type FormatOption = FormatString | Format | JsonFormat | ChangeTrackingFormat | ScreenshotFormat | AttributesFormat | QueryFormat;
57
+ type FormatOption = FormatString | Format | JsonFormat | ChangeTrackingFormat | ScreenshotFormat | AttributesFormat | QuestionFormat | HighlightsFormat | QueryFormat;
49
58
  type ParseFormatString = Exclude<FormatString, 'screenshot' | 'changeTracking' | 'branding'>;
50
59
  interface ParseFormat {
51
60
  type: ParseFormatString;
52
61
  }
53
- type ParseFormatOption = ParseFormatString | ParseFormat | JsonFormat | AttributesFormat | QueryFormat;
62
+ type ParseFormatOption = ParseFormatString | ParseFormat | JsonFormat | AttributesFormat | QuestionFormat | HighlightsFormat | QueryFormat;
54
63
  interface LocationConfig$1 {
55
64
  country?: string;
56
65
  languages?: string[];
@@ -345,6 +354,7 @@ interface Document {
345
354
  }>;
346
355
  actions?: Record<string, unknown>;
347
356
  answer?: string;
357
+ highlights?: string;
348
358
  warning?: string;
349
359
  changeTracking?: Record<string, unknown>;
350
360
  branding?: BrandingProfile;
@@ -611,6 +621,8 @@ interface ExtractResponse$1 {
611
621
  data?: unknown;
612
622
  error?: string;
613
623
  warning?: string;
624
+ warnings?: string[];
625
+ replacement?: string;
614
626
  sources?: Record<string, unknown>;
615
627
  expiresAt?: string;
616
628
  creditsUsed?: number;
@@ -1511,6 +1523,8 @@ interface ExtractResponse<LLMSchema extends zt.ZodSchema = any> {
1511
1523
  data: LLMSchema;
1512
1524
  error?: string;
1513
1525
  warning?: string;
1526
+ warnings?: string[];
1527
+ replacement?: string;
1514
1528
  sources?: string[];
1515
1529
  creditsUsed?: number;
1516
1530
  }
@@ -1613,6 +1627,8 @@ interface DeepResearchParams<LLMSchema extends zt.ZodSchema = any> {
1613
1627
  interface DeepResearchResponse {
1614
1628
  success: boolean;
1615
1629
  id: string;
1630
+ warnings?: string[];
1631
+ replacement?: string;
1616
1632
  }
1617
1633
  /**
1618
1634
  * Status response interface for deep research operations.
@@ -1652,6 +1668,8 @@ interface DeepResearchStatusResponse {
1652
1668
  description: string;
1653
1669
  }>;
1654
1670
  summaries: string[];
1671
+ warnings?: string[];
1672
+ replacement?: string;
1655
1673
  }
1656
1674
  /**
1657
1675
  * Parameters for LLMs.txt generation operations.
@@ -1683,6 +1701,8 @@ interface GenerateLLMsTextParams {
1683
1701
  interface GenerateLLMsTextResponse {
1684
1702
  success: boolean;
1685
1703
  id: string;
1704
+ warnings?: string[];
1705
+ replacement?: string;
1686
1706
  }
1687
1707
  /**
1688
1708
  * Status response interface for LLMs.txt generation operations.
@@ -1696,6 +1716,8 @@ interface GenerateLLMsTextStatusResponse {
1696
1716
  status: "processing" | "completed" | "failed";
1697
1717
  error?: string;
1698
1718
  expiresAt: string;
1719
+ warnings?: string[];
1720
+ replacement?: string;
1699
1721
  }
1700
1722
  /**
1701
1723
  * Response interface for queue status operations.
@@ -1945,6 +1967,7 @@ declare class FirecrawlApp {
1945
1967
  * @param onActivity - Optional callback to receive activity updates in real-time.
1946
1968
  * @param onSource - Optional callback to receive source updates in real-time.
1947
1969
  * @returns The final research results.
1970
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
1948
1971
  */
1949
1972
  deepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>, onActivity?: (activity: {
1950
1973
  type: string;
@@ -1962,12 +1985,14 @@ declare class FirecrawlApp {
1962
1985
  * Initiates a deep research operation on a given query without polling.
1963
1986
  * @param params - Parameters for the deep research operation.
1964
1987
  * @returns The response containing the research job ID.
1988
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
1965
1989
  */
1966
1990
  asyncDeepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>): Promise<DeepResearchResponse | ErrorResponse>;
1967
1991
  /**
1968
1992
  * Checks the status of a deep research operation.
1969
1993
  * @param id - The ID of the deep research operation.
1970
1994
  * @returns The current status and results of the research operation.
1995
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
1971
1996
  */
1972
1997
  checkDeepResearchStatus(id: string): Promise<DeepResearchStatusResponse | ErrorResponse>;
1973
1998
  /**
@@ -2004,6 +2029,7 @@ declare class FirecrawlApp {
2004
2029
  * @param url - The URL to generate LLMs.txt from.
2005
2030
  * @param params - Parameters for the LLMs.txt generation operation.
2006
2031
  * @returns The final generation results.
2032
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
2007
2033
  */
2008
2034
  generateLLMsText(url: string, params?: GenerateLLMsTextParams): Promise<GenerateLLMsTextStatusResponse | ErrorResponse>;
2009
2035
  /**
@@ -2011,12 +2037,14 @@ declare class FirecrawlApp {
2011
2037
  * @param url - The URL to generate LLMs.txt from.
2012
2038
  * @param params - Parameters for the LLMs.txt generation operation.
2013
2039
  * @returns The response containing the generation job ID.
2040
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
2014
2041
  */
2015
2042
  asyncGenerateLLMsText(url: string, params?: GenerateLLMsTextParams): Promise<GenerateLLMsTextResponse | ErrorResponse>;
2016
2043
  /**
2017
2044
  * Checks the status of a LLMs.txt generation operation.
2018
2045
  * @param id - The ID of the LLMs.txt generation operation.
2019
2046
  * @returns The current status and results of the generation operation.
2047
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
2020
2048
  */
2021
2049
  checkGenerateLLMsTextStatus(id: string): Promise<GenerateLLMsTextStatusResponse | ErrorResponse>;
2022
2050
  /**
@@ -2081,4 +2109,4 @@ declare class Firecrawl extends FirecrawlClient {
2081
2109
  get v1(): FirecrawlApp;
2082
2110
  }
2083
2111
 
2084
- export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorEmailNotification, type MonitorNotification, type MonitorSchedule, type MonitorScrapeTarget, type MonitorSummary, type MonitorTarget, type MonitorWebhookConfig, type PDFAction, type PaginationConfig, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type PressAction, type QueryFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
2112
+ export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type HighlightsFormat, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorEmailNotification, type MonitorNotification, type MonitorSchedule, type MonitorScrapeTarget, type MonitorSummary, type MonitorTarget, type MonitorWebhookConfig, type PDFAction, type PaginationConfig, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type PressAction, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-XWPH5FOQ.js";
3
+ } from "./chunk-HGRZHWZU.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -244,6 +244,30 @@ function ensureValidFormats(formats) {
244
244
  }
245
245
  continue;
246
246
  }
247
+ if (fmt.type === "question") {
248
+ const q = fmt;
249
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
250
+ throw new Error("question format requires a non-empty 'question' string");
251
+ }
252
+ continue;
253
+ }
254
+ if (fmt.type === "highlights") {
255
+ const h = fmt;
256
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
257
+ throw new Error("highlights format requires a non-empty 'query' string");
258
+ }
259
+ continue;
260
+ }
261
+ if (fmt.type === "query") {
262
+ const q = fmt;
263
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
264
+ throw new Error("query format requires a non-empty 'prompt' string");
265
+ }
266
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
267
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
268
+ }
269
+ continue;
270
+ }
247
271
  if (fmt.type === "screenshot") {
248
272
  const s = fmt;
249
273
  if (s.quality != null && (typeof s.quality !== "number" || s.quality < 0)) {
@@ -303,6 +327,30 @@ function ensureValidParseFormats(formats) {
303
327
  "json format schema appears to be a Zod schema's .shape property. Pass the Zod schema directly (e.g., `schema: MySchema`) instead of `schema: MySchema.shape`. The SDK will automatically convert Zod schemas to JSON Schema format."
304
328
  );
305
329
  }
330
+ continue;
331
+ }
332
+ if (fmt.type === "question") {
333
+ const q = fmt;
334
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
335
+ throw new Error("question format requires a non-empty 'question' string");
336
+ }
337
+ continue;
338
+ }
339
+ if (fmt.type === "highlights") {
340
+ const h = fmt;
341
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
342
+ throw new Error("highlights format requires a non-empty 'query' string");
343
+ }
344
+ continue;
345
+ }
346
+ if (fmt.type === "query") {
347
+ const q = fmt;
348
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
349
+ throw new Error("query format requires a non-empty 'prompt' string");
350
+ }
351
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
352
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
353
+ }
306
354
  }
307
355
  }
308
356
  }
@@ -1988,7 +2036,7 @@ var FirecrawlApp = class {
1988
2036
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
1989
2037
  return process.env.npm_package_version;
1990
2038
  }
1991
- const packageJson = await import("./package-VALCXP74.js");
2039
+ const packageJson = await import("./package-WSP46L7M.js");
1992
2040
  return packageJson.default.version;
1993
2041
  } catch (error) {
1994
2042
  const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
@@ -2814,6 +2862,7 @@ var FirecrawlApp = class {
2814
2862
  * @param onActivity - Optional callback to receive activity updates in real-time.
2815
2863
  * @param onSource - Optional callback to receive source updates in real-time.
2816
2864
  * @returns The final research results.
2865
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
2817
2866
  */
2818
2867
  async deepResearch(query, params, onActivity, onSource) {
2819
2868
  try {
@@ -2870,6 +2919,7 @@ var FirecrawlApp = class {
2870
2919
  * Initiates a deep research operation on a given query without polling.
2871
2920
  * @param params - Parameters for the deep research operation.
2872
2921
  * @returns The response containing the research job ID.
2922
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
2873
2923
  */
2874
2924
  async asyncDeepResearch(query, params) {
2875
2925
  const headers = this.prepareHeaders();
@@ -2907,6 +2957,7 @@ var FirecrawlApp = class {
2907
2957
  * Checks the status of a deep research operation.
2908
2958
  * @param id - The ID of the deep research operation.
2909
2959
  * @returns The current status and results of the research operation.
2960
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
2910
2961
  */
2911
2962
  async checkDeepResearchStatus(id) {
2912
2963
  const headers = this.prepareHeaders();
@@ -3045,6 +3096,7 @@ var FirecrawlApp = class {
3045
3096
  * @param url - The URL to generate LLMs.txt from.
3046
3097
  * @param params - Parameters for the LLMs.txt generation operation.
3047
3098
  * @returns The final generation results.
3099
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
3048
3100
  */
3049
3101
  async generateLLMsText(url, params) {
3050
3102
  try {
@@ -3086,6 +3138,7 @@ var FirecrawlApp = class {
3086
3138
  * @param url - The URL to generate LLMs.txt from.
3087
3139
  * @param params - Parameters for the LLMs.txt generation operation.
3088
3140
  * @returns The response containing the generation job ID.
3141
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
3089
3142
  */
3090
3143
  async asyncGenerateLLMsText(url, params) {
3091
3144
  const headers = this.prepareHeaders();
@@ -3114,6 +3167,7 @@ var FirecrawlApp = class {
3114
3167
  * Checks the status of a LLMs.txt generation operation.
3115
3168
  * @param id - The ID of the LLMs.txt generation operation.
3116
3169
  * @returns The current status and results of the generation operation.
3170
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
3117
3171
  */
3118
3172
  async checkGenerateLLMsTextStatus(id) {
3119
3173
  const headers = this.prepareHeaders();
@@ -1,4 +1,4 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-XWPH5FOQ.js";
3
+ } from "./chunk-HGRZHWZU.js";
4
4
  export default require_package();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "4.22.0",
3
+ "version": "4.22.2",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -56,6 +56,27 @@ describe("v2 utils: validation", () => {
56
56
  expect((formats[0] as any).viewport).toEqual({ width: 800, height: 600 });
57
57
  });
58
58
 
59
+ test("ensureValidFormats: accepts question, highlights, and deprecated query formats", () => {
60
+ const formats: FormatOption[] = [
61
+ { type: "question", question: "What is Firecrawl?" },
62
+ { type: "highlights", query: "What is Firecrawl?" },
63
+ { type: "query", prompt: "What is Firecrawl?", mode: "directQuote" },
64
+ ];
65
+ expect(() => ensureValidFormats(formats)).not.toThrow();
66
+ });
67
+
68
+ test("ensureValidFormats: validates question, highlights, and deprecated query fields", () => {
69
+ expect(() =>
70
+ ensureValidFormats([{ type: "question", question: "" } as any]),
71
+ ).toThrow(/question format requires/i);
72
+ expect(() =>
73
+ ensureValidFormats([{ type: "highlights", query: "" } as any]),
74
+ ).toThrow(/highlights format requires/i);
75
+ expect(() =>
76
+ ensureValidFormats([{ type: "query", prompt: "p", mode: "quoted" } as any]),
77
+ ).toThrow(/query format mode/i);
78
+ });
79
+
59
80
  test("ensureValidScrapeOptions: leaves parsers untouched", () => {
60
81
  const options = { parsers: ["pdf", "images"] as string[] } as any;
61
82
  const before = [...options.parsers];
package/src/v1/index.ts CHANGED
@@ -363,6 +363,8 @@ export interface ExtractResponse<LLMSchema extends zt.ZodSchema = any> {
363
363
  data: LLMSchema;
364
364
  error?: string;
365
365
  warning?: string;
366
+ warnings?: string[];
367
+ replacement?: string;
366
368
  sources?: string[];
367
369
  creditsUsed?: number;
368
370
  }
@@ -490,6 +492,8 @@ export interface DeepResearchParams<LLMSchema extends zt.ZodSchema = any> {
490
492
  export interface DeepResearchResponse {
491
493
  success: boolean;
492
494
  id: string;
495
+ warnings?: string[];
496
+ replacement?: string;
493
497
  }
494
498
 
495
499
  /**
@@ -530,6 +534,8 @@ export interface DeepResearchStatusResponse {
530
534
  description: string;
531
535
  }>;
532
536
  summaries: string[];
537
+ warnings?: string[];
538
+ replacement?: string;
533
539
  }
534
540
 
535
541
  /**
@@ -563,6 +569,8 @@ export interface GenerateLLMsTextParams {
563
569
  export interface GenerateLLMsTextResponse {
564
570
  success: boolean;
565
571
  id: string;
572
+ warnings?: string[];
573
+ replacement?: string;
566
574
  }
567
575
 
568
576
  /**
@@ -577,6 +585,8 @@ export interface GenerateLLMsTextStatusResponse {
577
585
  status: "processing" | "completed" | "failed";
578
586
  error?: string;
579
587
  expiresAt: string;
588
+ warnings?: string[];
589
+ replacement?: string;
580
590
  }
581
591
 
582
592
  /**
@@ -1626,6 +1636,7 @@ export default class FirecrawlApp {
1626
1636
  * @param onActivity - Optional callback to receive activity updates in real-time.
1627
1637
  * @param onSource - Optional callback to receive source updates in real-time.
1628
1638
  * @returns The final research results.
1639
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
1629
1640
  */
1630
1641
  async deepResearch(
1631
1642
  query: string,
@@ -1713,6 +1724,7 @@ export default class FirecrawlApp {
1713
1724
  * Initiates a deep research operation on a given query without polling.
1714
1725
  * @param params - Parameters for the deep research operation.
1715
1726
  * @returns The response containing the research job ID.
1727
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
1716
1728
  */
1717
1729
  async asyncDeepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>): Promise<DeepResearchResponse | ErrorResponse> {
1718
1730
  const headers = this.prepareHeaders();
@@ -1754,6 +1766,7 @@ export default class FirecrawlApp {
1754
1766
  * Checks the status of a deep research operation.
1755
1767
  * @param id - The ID of the deep research operation.
1756
1768
  * @returns The current status and results of the research operation.
1769
+ * @deprecated /v1/deep-research is deprecated. Use /v2/search instead.
1757
1770
  */
1758
1771
  async checkDeepResearchStatus(id: string): Promise<DeepResearchStatusResponse | ErrorResponse> {
1759
1772
  const headers = this.prepareHeaders();
@@ -1921,6 +1934,7 @@ export default class FirecrawlApp {
1921
1934
  * @param url - The URL to generate LLMs.txt from.
1922
1935
  * @param params - Parameters for the LLMs.txt generation operation.
1923
1936
  * @returns The final generation results.
1937
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
1924
1938
  */
1925
1939
  async generateLLMsText(url: string, params?: GenerateLLMsTextParams): Promise<GenerateLLMsTextStatusResponse | ErrorResponse> {
1926
1940
  try {
@@ -1973,6 +1987,7 @@ export default class FirecrawlApp {
1973
1987
  * @param url - The URL to generate LLMs.txt from.
1974
1988
  * @param params - Parameters for the LLMs.txt generation operation.
1975
1989
  * @returns The response containing the generation job ID.
1990
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
1976
1991
  */
1977
1992
  async asyncGenerateLLMsText(url: string, params?: GenerateLLMsTextParams): Promise<GenerateLLMsTextResponse | ErrorResponse> {
1978
1993
  const headers = this.prepareHeaders();
@@ -2003,6 +2018,7 @@ export default class FirecrawlApp {
2003
2018
  * Checks the status of a LLMs.txt generation operation.
2004
2019
  * @param id - The ID of the LLMs.txt generation operation.
2005
2020
  * @returns The current status and results of the generation operation.
2021
+ * @deprecated /v1/llmstxt is deprecated and will not be replaced.
2006
2022
  */
2007
2023
  async checkGenerateLLMsTextStatus(id: string): Promise<GenerateLLMsTextStatusResponse | ErrorResponse> {
2008
2024
  const headers = this.prepareHeaders();
package/src/v2/types.ts CHANGED
@@ -52,6 +52,17 @@ export interface AttributesFormat extends Format {
52
52
  }>;
53
53
  }
54
54
 
55
+ export interface QuestionFormat {
56
+ type: 'question';
57
+ question: string;
58
+ }
59
+
60
+ export interface HighlightsFormat {
61
+ type: 'highlights';
62
+ query: string;
63
+ }
64
+
65
+ /** @deprecated Use QuestionFormat or HighlightsFormat instead. */
55
66
  export interface QueryFormat {
56
67
  type: 'query';
57
68
  prompt: string;
@@ -65,6 +76,8 @@ export type FormatOption =
65
76
  | ChangeTrackingFormat
66
77
  | ScreenshotFormat
67
78
  | AttributesFormat
79
+ | QuestionFormat
80
+ | HighlightsFormat
68
81
  | QueryFormat;
69
82
 
70
83
  export type ParseFormatString = Exclude<
@@ -81,6 +94,8 @@ export type ParseFormatOption =
81
94
  | ParseFormat
82
95
  | JsonFormat
83
96
  | AttributesFormat
97
+ | QuestionFormat
98
+ | HighlightsFormat
84
99
  | QueryFormat;
85
100
 
86
101
  export interface LocationConfig {
@@ -450,6 +465,7 @@ export interface Document {
450
465
  }>;
451
466
  actions?: Record<string, unknown>;
452
467
  answer?: string;
468
+ highlights?: string;
453
469
  warning?: string;
454
470
  changeTracking?: Record<string, unknown>;
455
471
  branding?: BrandingProfile;
@@ -761,6 +777,8 @@ export interface ExtractResponse {
761
777
  data?: unknown;
762
778
  error?: string;
763
779
  warning?: string;
780
+ warnings?: string[];
781
+ replacement?: string;
764
782
  sources?: Record<string, unknown>;
765
783
  expiresAt?: string;
766
784
  creditsUsed?: number;
@@ -4,6 +4,9 @@ import {
4
4
  type JsonFormat,
5
5
  type ParseFormatOption,
6
6
  type ParseOptions,
7
+ type QuestionFormat,
8
+ type HighlightsFormat,
9
+ type QueryFormat,
7
10
  type ScrapeOptions,
8
11
  type ScreenshotFormat,
9
12
  } from "../types";
@@ -49,6 +52,30 @@ export function ensureValidFormats(formats?: FormatOption[]): void {
49
52
  }
50
53
  continue;
51
54
  }
55
+ if ((fmt as QuestionFormat).type === "question") {
56
+ const q = fmt as QuestionFormat;
57
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
58
+ throw new Error("question format requires a non-empty 'question' string");
59
+ }
60
+ continue;
61
+ }
62
+ if ((fmt as HighlightsFormat).type === "highlights") {
63
+ const h = fmt as HighlightsFormat;
64
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
65
+ throw new Error("highlights format requires a non-empty 'query' string");
66
+ }
67
+ continue;
68
+ }
69
+ if ((fmt as QueryFormat).type === "query") {
70
+ const q = fmt as QueryFormat;
71
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
72
+ throw new Error("query format requires a non-empty 'prompt' string");
73
+ }
74
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
75
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
76
+ }
77
+ continue;
78
+ }
52
79
  if ((fmt as ScreenshotFormat).type === "screenshot") {
53
80
  // no-op; already camelCase; validate numeric fields if present
54
81
  const s = fmt as ScreenshotFormat;
@@ -116,6 +143,31 @@ export function ensureValidParseFormats(formats?: ParseFormatOption[]): void {
116
143
  "The SDK will automatically convert Zod schemas to JSON Schema format."
117
144
  );
118
145
  }
146
+ continue;
147
+ }
148
+
149
+ if ((fmt as QuestionFormat).type === "question") {
150
+ const q = fmt as QuestionFormat;
151
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
152
+ throw new Error("question format requires a non-empty 'question' string");
153
+ }
154
+ continue;
155
+ }
156
+ if ((fmt as HighlightsFormat).type === "highlights") {
157
+ const h = fmt as HighlightsFormat;
158
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
159
+ throw new Error("highlights format requires a non-empty 'query' string");
160
+ }
161
+ continue;
162
+ }
163
+ if ((fmt as QueryFormat).type === "query") {
164
+ const q = fmt as QueryFormat;
165
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
166
+ throw new Error("query format requires a non-empty 'prompt' string");
167
+ }
168
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
169
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
170
+ }
119
171
  }
120
172
  }
121
173
  }