@librechat/agents 3.2.64 → 3.2.65

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.
Files changed (61) hide show
  1. package/dist/cjs/graphs/Graph.cjs +3 -0
  2. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  3. package/dist/cjs/llm/anthropic/index.cjs +73 -9
  4. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  5. package/dist/cjs/llm/anthropic/types.cjs.map +1 -1
  6. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +41 -9
  7. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
  8. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +3 -1
  9. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
  10. package/dist/cjs/llm/anthropic/utils/stream_events.cjs +337 -0
  11. package/dist/cjs/llm/anthropic/utils/stream_events.cjs.map +1 -0
  12. package/dist/cjs/tools/search/crw-scraper.cjs +165 -0
  13. package/dist/cjs/tools/search/crw-scraper.cjs.map +1 -0
  14. package/dist/cjs/tools/search/crw-search.cjs +105 -0
  15. package/dist/cjs/tools/search/crw-search.cjs.map +1 -0
  16. package/dist/cjs/tools/search/search.cjs +4 -2
  17. package/dist/cjs/tools/search/search.cjs.map +1 -1
  18. package/dist/cjs/tools/search/tool.cjs +15 -3
  19. package/dist/cjs/tools/search/tool.cjs.map +1 -1
  20. package/dist/esm/graphs/Graph.mjs +3 -0
  21. package/dist/esm/graphs/Graph.mjs.map +1 -1
  22. package/dist/esm/llm/anthropic/index.mjs +73 -9
  23. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  24. package/dist/esm/llm/anthropic/types.mjs.map +1 -1
  25. package/dist/esm/llm/anthropic/utils/message_inputs.mjs +41 -9
  26. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
  27. package/dist/esm/llm/anthropic/utils/message_outputs.mjs +3 -2
  28. package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
  29. package/dist/esm/llm/anthropic/utils/stream_events.mjs +337 -0
  30. package/dist/esm/llm/anthropic/utils/stream_events.mjs.map +1 -0
  31. package/dist/esm/tools/search/crw-scraper.mjs +163 -0
  32. package/dist/esm/tools/search/crw-scraper.mjs.map +1 -0
  33. package/dist/esm/tools/search/crw-search.mjs +103 -0
  34. package/dist/esm/tools/search/crw-search.mjs.map +1 -0
  35. package/dist/esm/tools/search/search.mjs +4 -2
  36. package/dist/esm/tools/search/search.mjs.map +1 -1
  37. package/dist/esm/tools/search/tool.mjs +15 -3
  38. package/dist/esm/tools/search/tool.mjs.map +1 -1
  39. package/dist/types/llm/anthropic/index.d.ts +2 -0
  40. package/dist/types/llm/anthropic/types.d.ts +2 -0
  41. package/dist/types/llm/anthropic/utils/message_outputs.d.ts +1 -2
  42. package/dist/types/llm/anthropic/utils/stream_events.d.ts +25 -0
  43. package/dist/types/tools/search/crw-scraper.d.ts +41 -0
  44. package/dist/types/tools/search/crw-search.d.ts +4 -0
  45. package/dist/types/tools/search/types.d.ts +88 -3
  46. package/package.json +1 -1
  47. package/src/graphs/Graph.ts +15 -0
  48. package/src/llm/anthropic/index.ts +134 -10
  49. package/src/llm/anthropic/inherited-content-utils.spec.ts +10 -5
  50. package/src/llm/anthropic/inherited-stream-events.spec.ts +513 -9
  51. package/src/llm/anthropic/llm.spec.ts +100 -16
  52. package/src/llm/anthropic/types.ts +3 -0
  53. package/src/llm/anthropic/utils/message_inputs.ts +60 -3
  54. package/src/llm/anthropic/utils/message_outputs.ts +10 -2
  55. package/src/llm/anthropic/utils/stream_events.ts +471 -0
  56. package/src/tools/search/crw-scraper.ts +244 -0
  57. package/src/tools/search/crw-search.ts +167 -0
  58. package/src/tools/search/crw.test.ts +836 -0
  59. package/src/tools/search/search.ts +7 -1
  60. package/src/tools/search/tool.ts +23 -3
  61. package/src/tools/search/types.ts +103 -3
@@ -4,6 +4,7 @@ import type * as t from './types';
4
4
  import { getAttribution, createDefaultLogger } from './utils';
5
5
  import { createKeenableAPI } from './keenable-search';
6
6
  import { createTavilyAPI } from './tavily-search';
7
+ import { createCrwAPI } from './crw-search';
7
8
  import { BaseReranker } from './rerankers';
8
9
 
9
10
  const chunker = {
@@ -489,6 +490,9 @@ export const createSearchAPI = (
489
490
  keenableApiKey,
490
491
  keenableApiUrl,
491
492
  keenableSearchOptions,
493
+ crwApiKey,
494
+ crwApiUrl,
495
+ crwSearchOptions,
492
496
  } = config;
493
497
 
494
498
  if (searchProvider.toLowerCase() === 'serper') {
@@ -503,9 +507,11 @@ export const createSearchAPI = (
503
507
  keenableApiUrl,
504
508
  keenableSearchOptions
505
509
  );
510
+ } else if (searchProvider.toLowerCase() === 'crw') {
511
+ return createCrwAPI(crwApiKey, crwApiUrl, crwSearchOptions);
506
512
  } else {
507
513
  throw new Error(
508
- `Invalid search provider: ${searchProvider}. Must be 'serper', 'searxng', 'tavily', or 'keenable'`
514
+ `Invalid search provider: ${searchProvider}. Must be 'serper', 'searxng', 'tavily', 'keenable', or 'crw'`
509
515
  );
510
516
  }
511
517
  };
@@ -16,6 +16,7 @@ import { createSearchAPI, createSourceProcessor } from './search';
16
16
  import { createSerperScraper } from './serper-scraper';
17
17
  import { createTavilyScraper } from './tavily-scraper';
18
18
  import { createFirecrawlScraper } from './firecrawl';
19
+ import { createCrwScraper } from './crw-scraper';
19
20
  import { expandHighlights } from './highlights';
20
21
  import { formatResultsForLLM } from './format';
21
22
  import { createDefaultLogger } from './utils';
@@ -339,8 +340,8 @@ function createTool({
339
340
  /**
340
341
  * Creates a search tool with configurable search and scraper providers.
341
342
  *
342
- * Search providers: Serper (Google results), SearXNG (self-hosted meta-search), Tavily (AI-optimized).
343
- * Scraper providers: Firecrawl (default, full-featured), Serper (lightweight), Tavily (batch extraction).
343
+ * Search providers: Serper (Google results), SearXNG (self-hosted meta-search), Tavily (AI-optimized), fastCRW (Firecrawl-compatible, self-host or cloud).
344
+ * Scraper providers: Firecrawl (default, full-featured), Serper (lightweight), Tavily (batch extraction), fastCRW (Firecrawl-compatible, self-host or cloud).
344
345
  *
345
346
  * The country schema field is exposed to the LLM for providers that support localized results.
346
347
  */
@@ -386,6 +387,10 @@ export const createSearchTool = (
386
387
  firecrawlOptions,
387
388
  serperScraperOptions,
388
389
  tavilyScraperOptions,
390
+ crwApiKey,
391
+ crwApiUrl,
392
+ crwSearchOptions,
393
+ crwScraperOptions,
389
394
  scraperTimeout,
390
395
  jinaApiKey,
391
396
  jinaApiUrl,
@@ -432,6 +437,9 @@ export const createSearchTool = (
432
437
  keenableApiKey,
433
438
  keenableApiUrl,
434
439
  keenableSearchOptions,
440
+ crwApiKey,
441
+ crwApiUrl,
442
+ crwSearchOptions,
435
443
  });
436
444
 
437
445
  /** Create scraper based on scraperProvider */
@@ -455,6 +463,16 @@ export const createSearchTool = (
455
463
  timeout: scraperTimeout ?? tavilyScraperOptions?.timeout,
456
464
  logger,
457
465
  });
466
+ } else if (scraperProvider === 'crw') {
467
+ scraperInstance = createCrwScraper({
468
+ ...crwScraperOptions,
469
+ apiKey:
470
+ crwScraperOptions?.apiKey ?? crwApiKey ?? process.env.CRW_API_KEY,
471
+ apiUrl: crwScraperOptions?.apiUrl ?? crwApiUrl,
472
+ timeout: scraperTimeout ?? crwScraperOptions?.timeout,
473
+ formats: crwScraperOptions?.formats ?? ['markdown', 'rawHtml'],
474
+ logger,
475
+ });
458
476
  } else {
459
477
  scraperInstance = createFirecrawlScraper({
460
478
  ...firecrawlOptions,
@@ -501,7 +519,9 @@ export const createSearchTool = (
501
519
  // sub-searches would spend rate limit and merge nothing.
502
520
  supportsImages: searchProvider !== 'keenable',
503
521
  supportsVideos:
504
- searchProvider !== 'tavily' && searchProvider !== 'keenable',
522
+ searchProvider !== 'tavily' &&
523
+ searchProvider !== 'keenable' &&
524
+ searchProvider !== 'crw',
505
525
  supportsNews: searchProvider !== 'keenable',
506
526
  sourceProcessor,
507
527
  onGetHighlights,
@@ -3,8 +3,8 @@ import type { Logger as WinstonLogger } from 'winston';
3
3
  import type { BaseReranker } from './rerankers';
4
4
  import { DATE_RANGE } from './schema';
5
5
 
6
- export type SearchProvider = 'serper' | 'searxng' | 'tavily' | 'keenable';
7
- export type ScraperProvider = 'firecrawl' | 'serper' | 'tavily';
6
+ export type SearchProvider = 'serper' | 'searxng' | 'tavily' | 'keenable' | 'crw';
7
+ export type ScraperProvider = 'firecrawl' | 'serper' | 'tavily' | 'crw';
8
8
  export type RerankerType = 'infinity' | 'jina' | 'cohere' | 'none';
9
9
 
10
10
  export interface Highlight {
@@ -106,6 +106,54 @@ export interface TavilySearchPayload {
106
106
  chunks_per_source?: number;
107
107
  }
108
108
 
109
+ export interface CrwSearchOptions {
110
+ /** Max results to request (maps to `limit`; clamped 1..20). */
111
+ maxResults?: number;
112
+ /** Add 'images' to the sources array. */
113
+ includeImages?: boolean;
114
+ timeout?: number;
115
+ }
116
+
117
+ export type CrwSearchSource = 'web' | 'images' | 'news';
118
+
119
+ export interface CrwSearchPayload {
120
+ query: string;
121
+ limit: number;
122
+ sources?: CrwSearchSource[];
123
+ tbs?: string;
124
+ }
125
+
126
+ export interface CrwSearchResult {
127
+ title?: string;
128
+ url?: string;
129
+ description?: string;
130
+ snippet?: string;
131
+ position?: number;
132
+ category?: string;
133
+ }
134
+
135
+ export interface CrwImageSearchResult extends CrwSearchResult {
136
+ imageUrl?: string;
137
+ imageFormat?: string;
138
+ }
139
+
140
+ export interface CrwNewsSearchResult extends CrwSearchResult {
141
+ publishedDate?: string;
142
+ }
143
+
144
+ export interface CrwSearchGroups {
145
+ web?: CrwSearchResult[];
146
+ images?: CrwImageSearchResult[];
147
+ news?: CrwNewsSearchResult[];
148
+ }
149
+
150
+ export interface CrwSearchResponse {
151
+ success: boolean;
152
+ data?: (CrwSearchGroups & { results?: CrwSearchGroups }) | CrwSearchResult[];
153
+ error?: string;
154
+ error_code?: string;
155
+ }
156
+
109
157
  export interface SearchConfig {
110
158
  searchProvider?: SearchProvider;
111
159
  serperApiKey?: string;
@@ -118,6 +166,9 @@ export interface SearchConfig {
118
166
  keenableApiKey?: string;
119
167
  keenableApiUrl?: string;
120
168
  keenableSearchOptions?: KeenableSearchOptions;
169
+ crwApiKey?: string;
170
+ crwApiUrl?: string;
171
+ crwSearchOptions?: CrwSearchOptions;
121
172
  }
122
173
 
123
174
  export interface KeenableSearchOptions {
@@ -257,6 +308,7 @@ export interface SearchToolConfig
257
308
  ProcessSourcesConfig,
258
309
  FirecrawlConfig {
259
310
  tavilyScraperOptions?: TavilyScraperConfig;
311
+ crwScraperOptions?: CrwScraperConfig;
260
312
  /** Max chars of highlight content this tool feeds the MODEL per search (the
261
313
  * dominant, otherwise-unbounded part of the output). Distinct from
262
314
  * `maxContentLength`, which caps scraped/reranked content per source — full
@@ -296,7 +348,8 @@ export type UsedReferences = {
296
348
  export type AnyScraperResponse =
297
349
  | FirecrawlScrapeResponse
298
350
  | SerperScrapeResponse
299
- | TavilyScrapeResponse;
351
+ | TavilyScrapeResponse
352
+ | CrwScrapeResponse;
300
353
 
301
354
  /** Base Scraper Interface */
302
355
  export interface BaseScraper {
@@ -322,6 +375,29 @@ export type FirecrawlScrapeOptions = Omit<
322
375
  'apiKey' | 'apiUrl' | 'version' | 'logger'
323
376
  >;
324
377
 
378
+ export interface CrwScraperConfig {
379
+ apiKey?: string;
380
+ apiUrl?: string;
381
+ formats?: string[];
382
+ timeout?: number;
383
+ logger?: Logger;
384
+ onlyMainContent?: boolean;
385
+ includeTags?: string[];
386
+ excludeTags?: string[];
387
+ waitFor?: number;
388
+ headers?: Record<string, string>;
389
+ renderJs?: boolean | null;
390
+ cssSelector?: string;
391
+ xpath?: string;
392
+ proxy?: string;
393
+ stealth?: boolean;
394
+ }
395
+
396
+ export type CrwScrapeOptions = Omit<
397
+ CrwScraperConfig,
398
+ 'apiKey' | 'apiUrl' | 'logger'
399
+ >;
400
+
325
401
  export type SerperScrapeOptions = Omit<
326
402
  SerperScraperConfig,
327
403
  'apiKey' | 'apiUrl' | 'logger'
@@ -421,6 +497,30 @@ export interface FirecrawlScrapeResponse {
421
497
  error?: string;
422
498
  }
423
499
 
500
+ export interface CrwScrapeData {
501
+ markdown?: string;
502
+ html?: string;
503
+ rawHtml?: string;
504
+ plainText?: string;
505
+ screenshot?: string;
506
+ links?: string[];
507
+ metadata?: ScrapeMetadata;
508
+ }
509
+
510
+ export interface CrwScrapeResponse {
511
+ success: boolean;
512
+ data?: CrwScrapeData;
513
+ error?: string;
514
+ error_code?: string;
515
+ }
516
+
517
+ export interface CrwRawScrapeResponse extends CrwScrapeData {
518
+ success?: boolean;
519
+ data?: CrwScrapeData;
520
+ error?: string;
521
+ error_code?: string;
522
+ }
523
+
424
524
  export interface SerperScrapeResponse {
425
525
  success: boolean;
426
526
  data?: {