@librechat/agents 2.4.30 → 2.4.33

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 (124) hide show
  1. package/dist/cjs/common/enum.cjs +1 -0
  2. package/dist/cjs/common/enum.cjs.map +1 -1
  3. package/dist/cjs/events.cjs +3 -3
  4. package/dist/cjs/events.cjs.map +1 -1
  5. package/dist/cjs/graphs/Graph.cjs +2 -1
  6. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  7. package/dist/cjs/main.cjs +7 -2
  8. package/dist/cjs/main.cjs.map +1 -1
  9. package/dist/cjs/messages/ids.cjs +23 -0
  10. package/dist/cjs/messages/ids.cjs.map +1 -0
  11. package/dist/cjs/splitStream.cjs +2 -1
  12. package/dist/cjs/splitStream.cjs.map +1 -1
  13. package/dist/cjs/stream.cjs +87 -154
  14. package/dist/cjs/stream.cjs.map +1 -1
  15. package/dist/cjs/tools/ToolNode.cjs +14 -3
  16. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  17. package/dist/cjs/tools/handlers.cjs +144 -0
  18. package/dist/cjs/tools/handlers.cjs.map +1 -0
  19. package/dist/cjs/tools/search/content.cjs +140 -0
  20. package/dist/cjs/tools/search/content.cjs.map +1 -0
  21. package/dist/cjs/tools/search/firecrawl.cjs +131 -0
  22. package/dist/cjs/tools/search/firecrawl.cjs.map +1 -0
  23. package/dist/cjs/tools/search/format.cjs +203 -0
  24. package/dist/cjs/tools/search/format.cjs.map +1 -0
  25. package/dist/cjs/tools/search/highlights.cjs +245 -0
  26. package/dist/cjs/tools/search/highlights.cjs.map +1 -0
  27. package/dist/cjs/tools/search/rerankers.cjs +194 -0
  28. package/dist/cjs/tools/search/rerankers.cjs.map +1 -0
  29. package/dist/cjs/tools/search/schema.cjs +70 -0
  30. package/dist/cjs/tools/search/schema.cjs.map +1 -0
  31. package/dist/cjs/tools/search/search.cjs +491 -0
  32. package/dist/cjs/tools/search/search.cjs.map +1 -0
  33. package/dist/cjs/tools/search/tool.cjs +292 -0
  34. package/dist/cjs/tools/search/tool.cjs.map +1 -0
  35. package/dist/cjs/tools/search/utils.cjs +66 -0
  36. package/dist/cjs/tools/search/utils.cjs.map +1 -0
  37. package/dist/esm/common/enum.mjs +1 -0
  38. package/dist/esm/common/enum.mjs.map +1 -1
  39. package/dist/esm/events.mjs +1 -1
  40. package/dist/esm/events.mjs.map +1 -1
  41. package/dist/esm/graphs/Graph.mjs +2 -1
  42. package/dist/esm/graphs/Graph.mjs.map +1 -1
  43. package/dist/esm/main.mjs +4 -1
  44. package/dist/esm/main.mjs.map +1 -1
  45. package/dist/esm/messages/ids.mjs +21 -0
  46. package/dist/esm/messages/ids.mjs.map +1 -0
  47. package/dist/esm/splitStream.mjs +2 -1
  48. package/dist/esm/splitStream.mjs.map +1 -1
  49. package/dist/esm/stream.mjs +87 -152
  50. package/dist/esm/stream.mjs.map +1 -1
  51. package/dist/esm/tools/ToolNode.mjs +14 -3
  52. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  53. package/dist/esm/tools/handlers.mjs +141 -0
  54. package/dist/esm/tools/handlers.mjs.map +1 -0
  55. package/dist/esm/tools/search/content.mjs +119 -0
  56. package/dist/esm/tools/search/content.mjs.map +1 -0
  57. package/dist/esm/tools/search/firecrawl.mjs +128 -0
  58. package/dist/esm/tools/search/firecrawl.mjs.map +1 -0
  59. package/dist/esm/tools/search/format.mjs +201 -0
  60. package/dist/esm/tools/search/format.mjs.map +1 -0
  61. package/dist/esm/tools/search/highlights.mjs +243 -0
  62. package/dist/esm/tools/search/highlights.mjs.map +1 -0
  63. package/dist/esm/tools/search/rerankers.mjs +188 -0
  64. package/dist/esm/tools/search/rerankers.mjs.map +1 -0
  65. package/dist/esm/tools/search/schema.mjs +61 -0
  66. package/dist/esm/tools/search/schema.mjs.map +1 -0
  67. package/dist/esm/tools/search/search.mjs +488 -0
  68. package/dist/esm/tools/search/search.mjs.map +1 -0
  69. package/dist/esm/tools/search/tool.mjs +290 -0
  70. package/dist/esm/tools/search/tool.mjs.map +1 -0
  71. package/dist/esm/tools/search/utils.mjs +61 -0
  72. package/dist/esm/tools/search/utils.mjs.map +1 -0
  73. package/dist/types/common/enum.d.ts +1 -0
  74. package/dist/types/graphs/Graph.d.ts +1 -1
  75. package/dist/types/index.d.ts +2 -0
  76. package/dist/types/messages/ids.d.ts +3 -0
  77. package/dist/types/messages/index.d.ts +1 -0
  78. package/dist/types/scripts/search.d.ts +1 -0
  79. package/dist/types/stream.d.ts +0 -8
  80. package/dist/types/tools/ToolNode.d.ts +6 -0
  81. package/dist/types/tools/example.d.ts +23 -3
  82. package/dist/types/tools/handlers.d.ts +8 -0
  83. package/dist/types/tools/search/content.d.ts +4 -0
  84. package/dist/types/tools/search/firecrawl.d.ts +38 -0
  85. package/dist/types/tools/search/format.d.ts +5 -0
  86. package/dist/types/tools/search/highlights.d.ts +13 -0
  87. package/dist/types/tools/search/index.d.ts +2 -0
  88. package/dist/types/tools/search/rerankers.d.ts +36 -0
  89. package/dist/types/tools/search/schema.d.ts +16 -0
  90. package/dist/types/tools/search/search.d.ts +9 -0
  91. package/dist/types/tools/search/test.d.ts +1 -0
  92. package/dist/types/tools/search/tool.d.ts +33 -0
  93. package/dist/types/tools/search/types.d.ts +540 -0
  94. package/dist/types/tools/search/utils.d.ts +10 -0
  95. package/package.json +10 -7
  96. package/src/common/enum.ts +1 -0
  97. package/src/events.ts +49 -15
  98. package/src/graphs/Graph.ts +6 -2
  99. package/src/index.ts +2 -0
  100. package/src/messages/ids.ts +26 -0
  101. package/src/messages/index.ts +1 -0
  102. package/src/scripts/search.ts +146 -0
  103. package/src/splitStream.test.ts +132 -71
  104. package/src/splitStream.ts +2 -1
  105. package/src/stream.ts +94 -183
  106. package/src/tools/ToolNode.ts +37 -14
  107. package/src/tools/handlers.ts +167 -0
  108. package/src/tools/search/content.test.ts +173 -0
  109. package/src/tools/search/content.ts +147 -0
  110. package/src/tools/search/firecrawl.ts +158 -0
  111. package/src/tools/search/format.ts +252 -0
  112. package/src/tools/search/highlights.ts +320 -0
  113. package/src/tools/search/index.ts +2 -0
  114. package/src/tools/search/output.md +2775 -0
  115. package/src/tools/search/rerankers.ts +269 -0
  116. package/src/tools/search/schema.ts +63 -0
  117. package/src/tools/search/search.ts +680 -0
  118. package/src/tools/search/test.html +884 -0
  119. package/src/tools/search/test.md +643 -0
  120. package/src/tools/search/test.ts +159 -0
  121. package/src/tools/search/tool.ts +427 -0
  122. package/src/tools/search/types.ts +621 -0
  123. package/src/tools/search/utils.ts +79 -0
  124. package/src/utils/llmConfig.ts +1 -1
@@ -0,0 +1,9 @@
1
+ import type * as t from './types';
2
+ import { FirecrawlScraper } from './firecrawl';
3
+ export declare const createSearchAPI: (config: t.SearchConfig) => {
4
+ getSources: (params: t.GetSourcesParams) => Promise<t.SearchResult>;
5
+ };
6
+ export declare const createSourceProcessor: (config?: t.ProcessSourcesConfig, scraperInstance?: FirecrawlScraper) => {
7
+ processSources: (fields: t.ProcessSourcesFields) => Promise<t.SearchResultData>;
8
+ topResults: number;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ import { DynamicStructuredTool } from '@langchain/core/tools';
3
+ import type * as t from './types';
4
+ import { DATE_RANGE } from './schema';
5
+ /**
6
+ * Creates a search tool with a schema that dynamically includes the country field
7
+ * only when the searchProvider is 'serper'.
8
+ *
9
+ * @param config - The search tool configuration
10
+ * @returns A DynamicStructuredTool with a schema that depends on the searchProvider
11
+ */
12
+ export declare const createSearchTool: (config?: t.SearchToolConfig) => DynamicStructuredTool<z.ZodObject<{
13
+ query: z.ZodString;
14
+ date: z.ZodOptional<z.ZodNativeEnum<typeof DATE_RANGE>>;
15
+ country?: z.ZodOptional<z.ZodString>;
16
+ images: z.ZodOptional<z.ZodBoolean>;
17
+ videos: z.ZodOptional<z.ZodBoolean>;
18
+ news: z.ZodOptional<z.ZodBoolean>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ query: string;
21
+ date?: DATE_RANGE | undefined;
22
+ images?: boolean | undefined;
23
+ videos?: boolean | undefined;
24
+ news?: boolean | undefined;
25
+ country?: unknown;
26
+ }, {
27
+ query: string;
28
+ date?: DATE_RANGE | undefined;
29
+ images?: boolean | undefined;
30
+ videos?: boolean | undefined;
31
+ news?: boolean | undefined;
32
+ country?: unknown;
33
+ }>>;
@@ -0,0 +1,540 @@
1
+ import { z } from 'zod';
2
+ import type { Logger as WinstonLogger } from 'winston';
3
+ import type { RunnableConfig } from '@langchain/core/runnables';
4
+ import type { BaseReranker } from './rerankers';
5
+ import { DATE_RANGE } from './schema';
6
+ export type SearchProvider = 'serper' | 'searxng';
7
+ export type RerankerType = 'infinity' | 'jina' | 'cohere' | 'none';
8
+ export interface Highlight {
9
+ score: number;
10
+ text: string;
11
+ references?: UsedReferences;
12
+ }
13
+ export type ProcessedSource = {
14
+ content?: string;
15
+ attribution?: string;
16
+ references?: References;
17
+ highlights?: Highlight[];
18
+ processed?: boolean;
19
+ };
20
+ export type ProcessedOrganic = OrganicResult & ProcessedSource;
21
+ export type ProcessedTopStory = TopStoryResult & ProcessedSource;
22
+ export type ValidSource = ProcessedOrganic | ProcessedTopStory;
23
+ export type ResultReference = {
24
+ link: string;
25
+ type: 'link' | 'image' | 'video';
26
+ title?: string;
27
+ attribution?: string;
28
+ };
29
+ export interface SearchResultData {
30
+ turn?: number;
31
+ organic?: ProcessedOrganic[];
32
+ topStories?: ProcessedTopStory[];
33
+ images?: ImageResult[];
34
+ videos?: VideoResult[];
35
+ places?: PlaceResult[];
36
+ news?: NewsResult[];
37
+ shopping?: ShoppingResult[];
38
+ knowledgeGraph?: KnowledgeGraphResult;
39
+ answerBox?: AnswerBoxResult;
40
+ peopleAlsoAsk?: PeopleAlsoAskResult[];
41
+ relatedSearches?: Array<{
42
+ query: string;
43
+ }>;
44
+ references?: ResultReference[];
45
+ error?: string;
46
+ }
47
+ export interface SearchResult {
48
+ data?: SearchResultData;
49
+ error?: string;
50
+ success: boolean;
51
+ }
52
+ export interface Source {
53
+ link: string;
54
+ html?: string;
55
+ title?: string;
56
+ snippet?: string;
57
+ date?: string;
58
+ }
59
+ export interface SearchConfig {
60
+ searchProvider?: SearchProvider;
61
+ serperApiKey?: string;
62
+ searxngInstanceUrl?: string;
63
+ searxngApiKey?: string;
64
+ }
65
+ export type References = {
66
+ links: MediaReference[];
67
+ images: MediaReference[];
68
+ videos: MediaReference[];
69
+ };
70
+ export interface ScrapeResult {
71
+ url: string;
72
+ error?: boolean;
73
+ content: string;
74
+ attribution?: string;
75
+ references?: References;
76
+ highlights?: Highlight[];
77
+ }
78
+ export interface ProcessSourcesConfig {
79
+ topResults?: number;
80
+ strategies?: string[];
81
+ filterContent?: boolean;
82
+ reranker?: BaseReranker;
83
+ logger?: Logger;
84
+ }
85
+ export interface FirecrawlConfig {
86
+ firecrawlApiKey?: string;
87
+ firecrawlApiUrl?: string;
88
+ firecrawlFormats?: string[];
89
+ }
90
+ export interface ScraperContentResult {
91
+ content: string;
92
+ }
93
+ export interface ScraperExtractionResult {
94
+ no_extraction: ScraperContentResult;
95
+ }
96
+ export interface JinaRerankerResult {
97
+ index: number;
98
+ relevance_score: number;
99
+ document?: string | {
100
+ text: string;
101
+ };
102
+ }
103
+ export interface JinaRerankerResponse {
104
+ model: string;
105
+ usage: {
106
+ total_tokens: number;
107
+ };
108
+ results: JinaRerankerResult[];
109
+ }
110
+ export interface CohereRerankerResult {
111
+ index: number;
112
+ relevance_score: number;
113
+ }
114
+ export interface CohereRerankerResponse {
115
+ results: CohereRerankerResult[];
116
+ id: string;
117
+ meta: {
118
+ api_version: {
119
+ version: string;
120
+ is_experimental: boolean;
121
+ };
122
+ billed_units: {
123
+ search_units: number;
124
+ };
125
+ };
126
+ }
127
+ export type SafeSearchLevel = 0 | 1 | 2;
128
+ export type Logger = WinstonLogger;
129
+ export interface SearchToolConfig extends SearchConfig, ProcessSourcesConfig, FirecrawlConfig {
130
+ logger?: Logger;
131
+ safeSearch?: SafeSearchLevel;
132
+ jinaApiKey?: string;
133
+ cohereApiKey?: string;
134
+ rerankerType?: RerankerType;
135
+ onSearchResults?: (results: SearchResult, runnableConfig?: RunnableConfig) => void;
136
+ onGetHighlights?: (link: string) => void;
137
+ }
138
+ export interface MediaReference {
139
+ originalUrl: string;
140
+ title?: string;
141
+ text?: string;
142
+ }
143
+ export type UsedReferences = {
144
+ type: 'link' | 'image' | 'video';
145
+ originalIndex: number;
146
+ reference: MediaReference;
147
+ }[];
148
+ /** Firecrawl */
149
+ export interface FirecrawlScrapeOptions {
150
+ formats?: string[];
151
+ includeTags?: string[];
152
+ excludeTags?: string[];
153
+ headers?: Record<string, string>;
154
+ waitFor?: number;
155
+ timeout?: number;
156
+ }
157
+ export interface ScrapeMetadata {
158
+ sourceURL?: string;
159
+ url?: string;
160
+ scrapeId?: string;
161
+ statusCode?: number;
162
+ title?: string;
163
+ description?: string;
164
+ language?: string;
165
+ favicon?: string;
166
+ viewport?: string;
167
+ robots?: string;
168
+ 'theme-color'?: string;
169
+ 'og:url'?: string;
170
+ 'og:title'?: string;
171
+ 'og:description'?: string;
172
+ 'og:type'?: string;
173
+ 'og:image'?: string;
174
+ 'og:image:width'?: string;
175
+ 'og:image:height'?: string;
176
+ 'og:site_name'?: string;
177
+ ogUrl?: string;
178
+ ogTitle?: string;
179
+ ogDescription?: string;
180
+ ogImage?: string;
181
+ ogSiteName?: string;
182
+ 'article:author'?: string;
183
+ 'article:published_time'?: string;
184
+ 'article:modified_time'?: string;
185
+ 'article:section'?: string;
186
+ 'article:tag'?: string;
187
+ 'article:publisher'?: string;
188
+ publishedTime?: string;
189
+ modifiedTime?: string;
190
+ 'twitter:site'?: string | boolean | number | null;
191
+ 'twitter:creator'?: string;
192
+ 'twitter:card'?: string;
193
+ 'twitter:image'?: string;
194
+ 'twitter:dnt'?: string;
195
+ 'twitter:app:name:iphone'?: string;
196
+ 'twitter:app:id:iphone'?: string;
197
+ 'twitter:app:url:iphone'?: string;
198
+ 'twitter:app:name:ipad'?: string;
199
+ 'twitter:app:id:ipad'?: string;
200
+ 'twitter:app:url:ipad'?: string;
201
+ 'twitter:app:name:googleplay'?: string;
202
+ 'twitter:app:id:googleplay'?: string;
203
+ 'twitter:app:url:googleplay'?: string;
204
+ 'fb:app_id'?: string;
205
+ 'al:ios:url'?: string;
206
+ 'al:ios:app_name'?: string;
207
+ 'al:ios:app_store_id'?: string;
208
+ [key: string]: string | number | boolean | null | undefined;
209
+ }
210
+ export interface FirecrawlScrapeResponse {
211
+ success: boolean;
212
+ data?: {
213
+ markdown?: string;
214
+ html?: string;
215
+ rawHtml?: string;
216
+ screenshot?: string;
217
+ links?: string[];
218
+ metadata?: ScrapeMetadata;
219
+ };
220
+ error?: string;
221
+ }
222
+ export interface FirecrawlScraperConfig {
223
+ apiKey?: string;
224
+ apiUrl?: string;
225
+ formats?: string[];
226
+ timeout?: number;
227
+ logger?: Logger;
228
+ }
229
+ export type GetSourcesParams = {
230
+ query: string;
231
+ date?: DATE_RANGE;
232
+ country?: string;
233
+ numResults?: number;
234
+ safeSearch?: SearchToolConfig['safeSearch'];
235
+ images?: boolean;
236
+ videos?: boolean;
237
+ news?: boolean;
238
+ type?: 'search' | 'images' | 'videos' | 'news';
239
+ };
240
+ /** Serper API */
241
+ export interface VideoResult {
242
+ title?: string;
243
+ link?: string;
244
+ snippet?: string;
245
+ imageUrl?: string;
246
+ duration?: string;
247
+ source?: string;
248
+ channel?: string;
249
+ date?: string;
250
+ position?: number;
251
+ }
252
+ export interface PlaceResult {
253
+ position?: number;
254
+ name?: string;
255
+ address?: string;
256
+ latitude?: number;
257
+ longitude?: number;
258
+ rating?: number;
259
+ ratingCount?: number;
260
+ category?: string;
261
+ identifier?: string;
262
+ }
263
+ export interface NewsResult {
264
+ title?: string;
265
+ link?: string;
266
+ snippet?: string;
267
+ date?: string;
268
+ source?: string;
269
+ imageUrl?: string;
270
+ position?: number;
271
+ }
272
+ export interface ShoppingResult {
273
+ title?: string;
274
+ source?: string;
275
+ link?: string;
276
+ price?: string;
277
+ delivery?: string;
278
+ imageUrl?: string;
279
+ rating?: number;
280
+ ratingCount?: number;
281
+ offers?: string;
282
+ productId?: string;
283
+ position?: number;
284
+ }
285
+ export interface ScholarResult {
286
+ title?: string;
287
+ link?: string;
288
+ publicationInfo?: string;
289
+ snippet?: string;
290
+ year?: number;
291
+ citedBy?: number;
292
+ }
293
+ export interface ImageResult {
294
+ title?: string;
295
+ imageUrl?: string;
296
+ imageWidth?: number;
297
+ imageHeight?: number;
298
+ thumbnailUrl?: string;
299
+ thumbnailWidth?: number;
300
+ thumbnailHeight?: number;
301
+ source?: string;
302
+ domain?: string;
303
+ link?: string;
304
+ googleUrl?: string;
305
+ position?: number;
306
+ }
307
+ export interface SerperSearchPayload extends SerperSearchInput {
308
+ /**
309
+ * Search type/vertical
310
+ * Options: "search" (web), "images", "news", "places", "videos"
311
+ */
312
+ type?: 'search' | 'images' | 'news' | 'places' | 'videos';
313
+ /**
314
+ * Starting index for search results pagination (used instead of page)
315
+ */
316
+ start?: number;
317
+ /**
318
+ * Filtering for safe search
319
+ * Options: "off", "moderate", "active"
320
+ */
321
+ safe?: 'off' | 'moderate' | 'active';
322
+ }
323
+ export type SerperSearchParameters = Pick<SerperSearchPayload, 'q' | 'type'> & {
324
+ engine: 'google';
325
+ };
326
+ export interface OrganicResult {
327
+ position?: number;
328
+ title?: string;
329
+ link: string;
330
+ snippet?: string;
331
+ date?: string;
332
+ sitelinks?: Array<{
333
+ title: string;
334
+ link: string;
335
+ }>;
336
+ }
337
+ export interface TopStoryResult {
338
+ title?: string;
339
+ link: string;
340
+ source?: string;
341
+ date?: string;
342
+ imageUrl?: string;
343
+ }
344
+ export interface KnowledgeGraphResult {
345
+ title?: string;
346
+ type?: string;
347
+ imageUrl?: string;
348
+ description?: string;
349
+ descriptionSource?: string;
350
+ descriptionLink?: string;
351
+ attributes?: Record<string, string>;
352
+ website?: string;
353
+ }
354
+ export interface AnswerBoxResult {
355
+ title?: string;
356
+ snippet?: string;
357
+ snippetHighlighted?: string[];
358
+ link?: string;
359
+ date?: string;
360
+ }
361
+ export interface PeopleAlsoAskResult {
362
+ question?: string;
363
+ snippet?: string;
364
+ title?: string;
365
+ link?: string;
366
+ }
367
+ export type RelatedSearches = Array<{
368
+ query: string;
369
+ }>;
370
+ export interface SerperSearchInput {
371
+ /**
372
+ * The search query string
373
+ */
374
+ q: string;
375
+ /**
376
+ * Country code for localized results
377
+ * Examples: "us", "uk", "ca", "de", etc.
378
+ */
379
+ gl?: string;
380
+ /**
381
+ * Interface language
382
+ * Examples: "en", "fr", "de", etc.
383
+ */
384
+ hl?: string;
385
+ /**
386
+ * Number of results to return (up to 100)
387
+ */
388
+ num?: number;
389
+ /**
390
+ * Specific location for contextual results
391
+ * Example: "New York, NY"
392
+ */
393
+ location?: string;
394
+ /**
395
+ * Search autocorrection setting
396
+ */
397
+ autocorrect?: boolean;
398
+ page?: number;
399
+ /**
400
+ * Date range for search results
401
+ * Options: "h" (past hour), "d" (past 24 hours), "w" (past week),
402
+ * "m" (past month), "y" (past year)
403
+ * `qdr:${DATE_RANGE}`
404
+ */
405
+ tbs?: string;
406
+ }
407
+ export type SerperResultData = {
408
+ searchParameters: SerperSearchPayload;
409
+ organic?: OrganicResult[];
410
+ topStories?: TopStoryResult[];
411
+ images?: ImageResult[];
412
+ videos?: VideoResult[];
413
+ places?: PlaceResult[];
414
+ news?: NewsResult[];
415
+ shopping?: ShoppingResult[];
416
+ peopleAlsoAsk?: PeopleAlsoAskResult[];
417
+ relatedSearches?: RelatedSearches;
418
+ knowledgeGraph?: KnowledgeGraphResult;
419
+ answerBox?: AnswerBoxResult;
420
+ credits?: number;
421
+ };
422
+ /** SearXNG */
423
+ export interface SearxNGSearchPayload {
424
+ /**
425
+ * The search query string
426
+ * Supports syntax specific to different search engines
427
+ * Example: "site:github.com SearXNG"
428
+ */
429
+ q: string;
430
+ /**
431
+ * Comma-separated list of search categories
432
+ * Example: "general,images,news"
433
+ */
434
+ categories?: string;
435
+ /**
436
+ * Comma-separated list of search engines to use
437
+ * Example: "google,bing,duckduckgo"
438
+ */
439
+ engines?: string;
440
+ /**
441
+ * Code of the language for search results
442
+ * Example: "en", "fr", "de", "es"
443
+ */
444
+ language?: string;
445
+ /**
446
+ * Search page number
447
+ * Default: 1
448
+ */
449
+ pageno?: number;
450
+ /**
451
+ * Time range filter for search results
452
+ * Options: "day", "month", "year"
453
+ */
454
+ time_range?: 'day' | 'month' | 'year';
455
+ /**
456
+ * Output format of results
457
+ * Options: "json", "csv", "rss"
458
+ */
459
+ format?: 'json' | 'csv' | 'rss';
460
+ /**
461
+ * Open search results on new tab
462
+ * Options: `0` (off), `1` (on)
463
+ */
464
+ results_on_new_tab?: 0 | 1;
465
+ /**
466
+ * Proxy image results through SearxNG
467
+ * Options: true, false
468
+ */
469
+ image_proxy?: boolean;
470
+ /**
471
+ * Service for autocomplete suggestions
472
+ * Options: "google", "dbpedia", "duckduckgo", "mwmbl",
473
+ * "startpage", "wikipedia", "stract", "swisscows", "qwant"
474
+ */
475
+ autocomplete?: string;
476
+ /**
477
+ * Safe search filtering level
478
+ * Options: "0" (off), "1" (moderate), "2" (strict)
479
+ */
480
+ safesearch?: 0 | 1 | 2;
481
+ /**
482
+ * Theme to use for results page
483
+ * Default: "simple" (other themes may be available per instance)
484
+ */
485
+ theme?: string;
486
+ /**
487
+ * List of enabled plugins
488
+ * Default: "Hash_plugin,Self_Information,Tracker_URL_remover,Ahmia_blacklist"
489
+ */
490
+ enabled_plugins?: string;
491
+ /**
492
+ * List of disabled plugins
493
+ */
494
+ disabled_plugins?: string;
495
+ /**
496
+ * List of enabled engines
497
+ */
498
+ enabled_engines?: string;
499
+ /**
500
+ * List of disabled engines
501
+ */
502
+ disabled_engines?: string;
503
+ }
504
+ export interface SearXNGResult {
505
+ title?: string;
506
+ url?: string;
507
+ content?: string;
508
+ publishedDate?: string;
509
+ img_src?: string;
510
+ }
511
+ export type ProcessSourcesFields = {
512
+ result: SearchResult;
513
+ numElements: number;
514
+ query: string;
515
+ news: boolean;
516
+ proMode: boolean;
517
+ onGetHighlights: SearchToolConfig['onGetHighlights'];
518
+ };
519
+ export type SearchToolSchema = z.ZodObject<{
520
+ query: z.ZodString;
521
+ date: z.ZodOptional<z.ZodNativeEnum<typeof DATE_RANGE>>;
522
+ country?: z.ZodOptional<z.ZodString>;
523
+ images: z.ZodOptional<z.ZodBoolean>;
524
+ videos: z.ZodOptional<z.ZodBoolean>;
525
+ news: z.ZodOptional<z.ZodBoolean>;
526
+ }, 'strip', z.ZodTypeAny, {
527
+ query: string;
528
+ date?: DATE_RANGE;
529
+ country?: unknown;
530
+ images?: boolean;
531
+ videos?: boolean;
532
+ news?: boolean;
533
+ }, {
534
+ query: string;
535
+ date?: DATE_RANGE;
536
+ country?: unknown;
537
+ images?: boolean;
538
+ videos?: boolean;
539
+ news?: boolean;
540
+ }>;
@@ -0,0 +1,10 @@
1
+ import type * as t from './types';
2
+ /**
3
+ * Creates a default logger that maps to console methods
4
+ * Uses a singleton pattern to avoid creating multiple instances
5
+ * @returns A default logger that implements the Logger interface
6
+ */
7
+ export declare const createDefaultLogger: () => t.Logger;
8
+ export declare const fileExtRegex: RegExp;
9
+ export declare const getDomainName: (link: string, metadata?: t.ScrapeMetadata, logger?: t.Logger) => string | undefined;
10
+ export declare function getAttribution(link: string, metadata?: t.ScrapeMetadata, logger?: t.Logger): string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@librechat/agents",
3
- "version": "2.4.30",
3
+ "version": "2.4.33",
4
4
  "main": "./dist/cjs/main.cjs",
5
5
  "module": "./dist/esm/main.mjs",
6
6
  "types": "./dist/types/index.d.ts",
@@ -52,6 +52,7 @@
52
52
  "thinking": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/thinking.ts --name 'Jo' --location 'New York, NY'",
53
53
  "memory": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/memory.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
54
54
  "tool-test": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/tools.ts --provider 'alibaba' --name 'Jo' --location 'New York, NY'",
55
+ "search": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/search.ts --provider 'anthropic' --name 'Jo' --location 'New York, NY'",
55
56
  "abort": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/abort.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
56
57
  "start:cli2": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/cli2.ts --provider 'anthropic' --name 'Jo' --location 'New York, NY'",
57
58
  "script2": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/proto/example_test.ts",
@@ -72,17 +73,18 @@
72
73
  },
73
74
  "dependencies": {
74
75
  "@langchain/anthropic": "^0.3.20",
75
- "@langchain/aws": "^0.1.9",
76
+ "@langchain/aws": "0.1.8",
76
77
  "@langchain/community": "^0.3.42",
77
- "@langchain/core": "^0.3.51",
78
+ "@langchain/core": "^0.3.55",
78
79
  "@langchain/deepseek": "^0.0.1",
79
- "@langchain/google-genai": "^0.2.5",
80
- "@langchain/google-vertexai": "^0.2.5",
81
- "@langchain/langgraph": "^0.2.67",
80
+ "@langchain/google-genai": "^0.2.8",
81
+ "@langchain/google-vertexai": "^0.2.8",
82
+ "@langchain/langgraph": "^0.2.72",
82
83
  "@langchain/mistralai": "^0.2.0",
83
84
  "@langchain/ollama": "^0.2.0",
84
85
  "@langchain/openai": "^0.5.10",
85
86
  "@langchain/xai": "^0.0.2",
87
+ "cheerio": "^1.0.0",
86
88
  "dotenv": "^16.4.7",
87
89
  "https-proxy-agent": "^7.0.6",
88
90
  "nanoid": "^3.3.7"
@@ -120,7 +122,8 @@
120
122
  "tsc-alias": "^1.8.10",
121
123
  "tsconfig-paths": "^4.2.0",
122
124
  "tslib": "^2.6.3",
123
- "typescript": "^5.5.3"
125
+ "typescript": "^5.5.3",
126
+ "winston": "^3.17.0"
124
127
  },
125
128
  "lint-staged": {
126
129
  "*.{js,ts}": [
@@ -158,6 +158,7 @@ export enum Callback {
158
158
  export enum Constants {
159
159
  OFFICIAL_CODE_BASEURL = 'https://api.librechat.ai/v1',
160
160
  EXECUTE_CODE = 'execute_code',
161
+ WEB_SEARCH = 'web_search',
161
162
  CONTENT_AND_ARTIFACT = 'content_and_artifact',
162
163
  }
163
164