@librechat/agents 3.2.64 → 3.2.66
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/cjs/graphs/Graph.cjs +18 -2
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/instrumentation.cjs +15 -3
- package/dist/cjs/instrumentation.cjs.map +1 -1
- package/dist/cjs/langfuseToolOutputTracing.cjs +1 -2
- package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
- package/dist/cjs/langfuseTraceShaping.cjs +51 -24
- package/dist/cjs/langfuseTraceShaping.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/index.cjs +73 -9
- package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/types.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +49 -9
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +3 -1
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/stream_events.cjs +337 -0
- package/dist/cjs/llm/anthropic/utils/stream_events.cjs.map +1 -0
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +8 -0
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/tools/BashExecutor.cjs +9 -8
- package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +9 -7
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/search/crw-scraper.cjs +165 -0
- package/dist/cjs/tools/search/crw-scraper.cjs.map +1 -0
- package/dist/cjs/tools/search/crw-search.cjs +105 -0
- package/dist/cjs/tools/search/crw-search.cjs.map +1 -0
- package/dist/cjs/tools/search/search.cjs +4 -2
- package/dist/cjs/tools/search/search.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +15 -3
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +18 -2
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/instrumentation.mjs +15 -3
- package/dist/esm/instrumentation.mjs.map +1 -1
- package/dist/esm/langfuseToolOutputTracing.mjs +1 -2
- package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
- package/dist/esm/langfuseTraceShaping.mjs +51 -24
- package/dist/esm/langfuseTraceShaping.mjs.map +1 -1
- package/dist/esm/llm/anthropic/index.mjs +73 -9
- package/dist/esm/llm/anthropic/index.mjs.map +1 -1
- package/dist/esm/llm/anthropic/types.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +49 -9
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs +3 -2
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/stream_events.mjs +337 -0
- package/dist/esm/llm/anthropic/utils/stream_events.mjs.map +1 -0
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs +8 -0
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/tools/BashExecutor.mjs +9 -8
- package/dist/esm/tools/BashExecutor.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +9 -7
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/search/crw-scraper.mjs +163 -0
- package/dist/esm/tools/search/crw-scraper.mjs.map +1 -0
- package/dist/esm/tools/search/crw-search.mjs +103 -0
- package/dist/esm/tools/search/crw-search.mjs.map +1 -0
- package/dist/esm/tools/search/search.mjs +4 -2
- package/dist/esm/tools/search/search.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +15 -3
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/types/graphs/Graph.d.ts +2 -0
- package/dist/types/langfuseTraceShaping.d.ts +12 -6
- package/dist/types/llm/anthropic/index.d.ts +2 -0
- package/dist/types/llm/anthropic/types.d.ts +2 -0
- package/dist/types/llm/anthropic/utils/message_outputs.d.ts +1 -2
- package/dist/types/llm/anthropic/utils/stream_events.d.ts +25 -0
- package/dist/types/tools/BashExecutor.d.ts +7 -6
- package/dist/types/tools/CodeExecutor.d.ts +7 -5
- package/dist/types/tools/search/crw-scraper.d.ts +41 -0
- package/dist/types/tools/search/crw-search.d.ts +4 -0
- package/dist/types/tools/search/types.d.ts +88 -3
- package/dist/types/types/graph.d.ts +10 -3
- package/package.json +1 -1
- package/src/graphs/Graph.ts +36 -3
- package/src/instrumentation.ts +20 -0
- package/src/langfuseToolOutputTracing.ts +2 -4
- package/src/langfuseTraceShaping.ts +73 -20
- package/src/llm/anthropic/index.ts +134 -10
- package/src/llm/anthropic/inherited-content-utils.spec.ts +10 -5
- package/src/llm/anthropic/inherited-stream-events.spec.ts +513 -9
- package/src/llm/anthropic/llm.spec.ts +100 -16
- package/src/llm/anthropic/types.ts +3 -0
- package/src/llm/anthropic/utils/cross-provider-server-tools.test.ts +110 -0
- package/src/llm/anthropic/utils/message_inputs.ts +75 -3
- package/src/llm/anthropic/utils/message_outputs.ts +10 -2
- package/src/llm/anthropic/utils/stream_events.ts +471 -0
- package/src/llm/bedrock/utils/cross-provider-server-tools.test.ts +122 -0
- package/src/llm/bedrock/utils/message_inputs.ts +13 -0
- package/src/specs/langfuse-instrumentation.test.ts +64 -0
- package/src/specs/langfuse-routing.integration.test.ts +49 -4
- package/src/specs/langfuse-tool-output-tracing.test.ts +5 -4
- package/src/specs/langfuse-trace-shaping.test.ts +80 -9
- package/src/specs/subagent.test.ts +180 -0
- package/src/tools/BashExecutor.ts +9 -8
- package/src/tools/CodeExecutor.ts +9 -7
- package/src/tools/__tests__/BashExecutor.test.ts +16 -5
- package/src/tools/__tests__/CodeExecutor.stateful.test.ts +17 -6
- package/src/tools/search/crw-scraper.ts +244 -0
- package/src/tools/search/crw-search.ts +167 -0
- package/src/tools/search/crw.test.ts +836 -0
- package/src/tools/search/search.ts +7 -1
- package/src/tools/search/tool.ts +23 -3
- package/src/tools/search/types.ts +103 -3
- package/src/types/graph.ts +10 -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 '
|
|
514
|
+
`Invalid search provider: ${searchProvider}. Must be 'serper', 'searxng', 'tavily', 'keenable', or 'crw'`
|
|
509
515
|
);
|
|
510
516
|
}
|
|
511
517
|
};
|
package/src/tools/search/tool.ts
CHANGED
|
@@ -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' &&
|
|
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?: {
|
package/src/types/graph.ts
CHANGED
|
@@ -534,9 +534,9 @@ export type LangfuseToolOutputTracingConfig = {
|
|
|
534
534
|
|
|
535
535
|
export type LangfuseToolNodeTracingConfig = {
|
|
536
536
|
/**
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
537
|
+
* Opts into the internal ToolNode batch observation. Graph tool-dispatch
|
|
538
|
+
* and individual tool observations are exported without this wrapper, so
|
|
539
|
+
* the default is false to avoid a redundant hierarchy level.
|
|
540
540
|
*/
|
|
541
541
|
enabled?: boolean;
|
|
542
542
|
};
|
|
@@ -546,6 +546,13 @@ export interface LangfuseConfig {
|
|
|
546
546
|
publicKey?: string;
|
|
547
547
|
secretKey?: string;
|
|
548
548
|
baseUrl?: string;
|
|
549
|
+
/**
|
|
550
|
+
* Environment identifier attached to exported traces (Langfuse
|
|
551
|
+
* `environment`). When unset, falls back to `LANGFUSE_TRACING_ENVIRONMENT`
|
|
552
|
+
* then `NODE_ENV`, so production traces are not collapsed under the
|
|
553
|
+
* `default` environment.
|
|
554
|
+
*/
|
|
555
|
+
environment?: string;
|
|
549
556
|
metadata?: Record<string, string | number | boolean | null | undefined>;
|
|
550
557
|
/**
|
|
551
558
|
* Internal OTLP span attributes to attach to Langfuse observations before
|