chat-agent-toolkit 1.2.1 → 1.2.3

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 (68) hide show
  1. package/README.md +6 -6
  2. package/dist/config/config-manager.d.ts +23 -0
  3. package/dist/config/config-types.d.ts +58 -0
  4. package/dist/config/environment-variables.d.ts +6 -0
  5. package/dist/config/index.d.ts +18 -0
  6. package/dist/config/language-models-database.d.ts +93 -0
  7. package/dist/config/mcp-server-registry.d.ts +7 -0
  8. package/dist/config/model-registry.d.ts +69 -0
  9. package/dist/config/model-tester.d.ts +51 -0
  10. package/dist/config/model-utils.d.ts +44 -0
  11. package/dist/config/provider-ui-config.d.ts +6 -0
  12. package/dist/index.d.ts +23 -0
  13. package/dist/memory/agent-memory-manager.d.ts +125 -0
  14. package/dist/memory/example.d.ts +36 -0
  15. package/dist/memory/index.d.ts +18 -0
  16. package/dist/memory/mastra-integration.d.ts +146 -0
  17. package/dist/memory/storage/drizzle-storage.d.ts +82 -0
  18. package/dist/memory/storage/in-memory-storage.d.ts +75 -0
  19. package/dist/memory/storage/storage-interface.d.ts +37 -0
  20. package/dist/memory/types.d.ts +122 -0
  21. package/dist/models/providers.d.ts +5 -0
  22. package/dist/models/registry.d.ts +4 -0
  23. package/dist/models/types.d.ts +4 -0
  24. package/dist/research-agent.cjs.js +2 -0
  25. package/dist/research-agent.cjs.js.map +1 -0
  26. package/dist/research-agent.es.js +2 -0
  27. package/dist/research-agent.es.js.map +1 -0
  28. package/dist/search.d.ts +5 -0
  29. package/dist/tools/index.d.ts +12 -0
  30. package/dist/tools/open-connector-mastra.d.ts +137 -0
  31. package/dist/tools/open-connector-mcp.d.ts +88 -0
  32. package/dist/tools/qwksearch-api-tools.d.ts +149 -0
  33. package/dist/tools/search/doc-utils.d.ts +11 -0
  34. package/dist/tools/search/document.d.ts +14 -0
  35. package/dist/tools/search/index.d.ts +12 -0
  36. package/dist/tools/search/link-summarizer.d.ts +7 -0
  37. package/dist/tools/search/meta-search-types.d.ts +50 -0
  38. package/dist/tools/search/metaSearchAgent.d.ts +21 -0
  39. package/dist/tools/search/search-handlers.d.ts +27 -0
  40. package/dist/tools/search/suggestionGeneratorAgent.d.ts +8 -0
  41. package/dist/types.d.ts +2 -0
  42. package/dist/utils/chat-helpers.d.ts +10 -0
  43. package/dist/utils/index.d.ts +2 -0
  44. package/dist/utils/markdown-to-html.d.ts +5 -0
  45. package/dist/utils/outputParser.d.ts +22 -0
  46. package/dist/utils/provider-image-cropper.d.ts +120 -0
  47. package/package.json +16 -6
  48. package/src/config/config-manager.ts +0 -8
  49. package/src/config/environment-variables.ts +11 -3
  50. package/src/config/language-models-database.ts +50 -42
  51. package/src/config/model-registry.ts +20 -5
  52. package/src/config/model-tester.ts +2 -2
  53. package/src/connectors/{composio.json → open-connector.json} +21 -45
  54. package/src/index.ts +3 -0
  55. package/src/memory/ARCHITECTURE.md +1 -1
  56. package/src/memory/example.ts +6 -6
  57. package/src/memory/mastra-integration.ts +6 -11
  58. package/src/memory/storage/drizzle-storage.ts +60 -29
  59. package/src/memory/storage/in-memory-storage.ts +2 -2
  60. package/src/memory/storage/storage-interface.ts +1 -1
  61. package/src/models/types.ts +1 -1
  62. package/src/tools/{composio-mastra.ts → open-connector-mastra.ts} +58 -93
  63. package/src/tools/open-connector-mcp.ts +170 -0
  64. package/src/tools/search/doc-utils.ts +36 -8
  65. package/src/tools/search/metaSearchAgent.ts +11 -0
  66. package/src/tools/search/search-handlers.ts +13 -1
  67. package/src/tools/search/suggestionGeneratorAgent.ts +5 -3
  68. package/src/tools/composio-mcp.ts +0 -205
@@ -0,0 +1,137 @@
1
+ import { Agent } from '@mastra/core/agent';
2
+ import { MCPClient } from '@mastra/mcp';
3
+ /**
4
+ * Configuration for OpenConnector + Mastra integration
5
+ */
6
+ export interface OpenConnectorMastraConfig {
7
+ /** OpenConnector admin token */
8
+ adminToken: string;
9
+ /** Base URL of the deployed OpenConnector Worker */
10
+ baseUrl: string;
11
+ /** User ID for scoping the session */
12
+ userId: string;
13
+ /** Apps to enable */
14
+ apps: string[];
15
+ /** Agent configuration */
16
+ agent: {
17
+ id: string;
18
+ name: string;
19
+ instructions: string;
20
+ model: any;
21
+ maxSteps?: number;
22
+ };
23
+ /** Whether to require approval before tool execution */
24
+ requireToolApproval?: boolean;
25
+ }
26
+ /**
27
+ * OpenConnector + Mastra session manager
28
+ * Handles MCP connection lifecycle and agent creation
29
+ */
30
+ export declare class OpenConnectorMastraSession {
31
+ private config;
32
+ private mcpClient;
33
+ private agent;
34
+ constructor(config: OpenConnectorMastraConfig);
35
+ /**
36
+ * Get or create Mastra MCP client
37
+ * Connects to OpenConnector's MCP endpoint via HTTP
38
+ */
39
+ getMCPClient(): Promise<MCPClient>;
40
+ /**
41
+ * Get tools from OpenConnector MCP
42
+ * Use for static agent setup (same tools for all requests)
43
+ */
44
+ getTools(): Promise<Record<string, import('@mastra/core/tools').Tool<any, any, any, any, import('@mastra/core/tools').ToolExecutionContext<any, any, unknown>, string, unknown>>>;
45
+ /**
46
+ * Get toolsets from OpenConnector MCP
47
+ * Use for dynamic per-request tool configuration
48
+ */
49
+ getToolsets(): Promise<Record<string, Record<string, import('@mastra/core/tools').Tool<any, any, any, any, import('@mastra/core/tools').ToolExecutionContext<any, any, unknown>, string, unknown>>>>;
50
+ /**
51
+ * Create or get Mastra agent with OpenConnector tools
52
+ * Agent is cached and reused across generate() calls
53
+ */
54
+ getAgent(): Promise<Agent>;
55
+ /**
56
+ * Execute agent with a prompt
57
+ * Handles multi-step tool calling automatically
58
+ *
59
+ * @param prompt - User prompt
60
+ * @param options - Generation options
61
+ * @returns Agent response with text and tool calls
62
+ */
63
+ generate(prompt: string, options?: {
64
+ maxSteps?: number;
65
+ /** Extra context messages passed to the agent (model messages) */
66
+ context?: any[];
67
+ }): Promise<import('@mastra/core/stream').FullOutput<undefined>>;
68
+ /**
69
+ * Clean up MCP connection and agent
70
+ * Call when done with the session
71
+ */
72
+ cleanup(): Promise<void>;
73
+ }
74
+ /**
75
+ * Quick helper to create an OpenConnector + Mastra agent
76
+ * For one-off usage without session management
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * const result = await createOpenConnectorMastraAgent({
81
+ * adminToken: process.env.OPEN_CONNECTOR_ADMIN_TOKEN!,
82
+ * baseUrl: 'https://open-connector.example.workers.dev',
83
+ * userId: 'user-123',
84
+ * apps: ['gmail', 'slack'],
85
+ * agent: {
86
+ * id: 'email-agent',
87
+ * name: 'Email Assistant',
88
+ * instructions: 'Help with email tasks',
89
+ * model: openai('gpt-4o'),
90
+ * },
91
+ * }).generate('Check my unread emails');
92
+ * ```
93
+ */
94
+ export declare function createOpenConnectorMastraAgent(config: OpenConnectorMastraConfig): Promise<OpenConnectorMastraSession>;
95
+ /**
96
+ * Create Mastra agent with dynamic per-request apps
97
+ * Better for multi-user scenarios where tools vary per request
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const agent = await createDynamicOpenConnectorAgent({
102
+ * adminToken: process.env.OPEN_CONNECTOR_ADMIN_TOKEN!,
103
+ * baseUrl: 'https://open-connector.example.workers.dev',
104
+ * agent: {
105
+ * id: 'dynamic-agent',
106
+ * name: 'Dynamic Assistant',
107
+ * instructions: 'Use available tools',
108
+ * model: openai('gpt-4o'),
109
+ * },
110
+ * });
111
+ *
112
+ * // Each request can have different userId/apps
113
+ * const result = await agent.generate({
114
+ * userId: 'user-123',
115
+ * apps: ['gmail'],
116
+ * prompt: 'Check emails',
117
+ * });
118
+ * ```
119
+ */
120
+ export declare function createDynamicOpenConnectorAgent(config: {
121
+ adminToken: string;
122
+ baseUrl: string;
123
+ agent: {
124
+ id: string;
125
+ name: string;
126
+ instructions: string;
127
+ model: any;
128
+ maxSteps?: number;
129
+ };
130
+ }): Promise<{
131
+ generate(params: {
132
+ userId: string;
133
+ apps: string[];
134
+ prompt: string;
135
+ maxSteps?: number;
136
+ }): Promise<import('@mastra/core/stream').FullOutput<undefined>>;
137
+ }>;
@@ -0,0 +1,88 @@
1
+ import { MCPClient } from '@ai-sdk/mcp';
2
+ import { ToolSet } from 'ai';
3
+ /**
4
+ * Configuration for OpenConnector MCP session
5
+ */
6
+ export interface OpenConnectorMCPConfig {
7
+ /** OpenConnector admin token (OPEN_CONNECTOR_ADMIN_TOKEN) */
8
+ adminToken: string;
9
+ /** Base URL of the deployed OpenConnector Worker */
10
+ baseUrl: string;
11
+ /** User ID to scope the session */
12
+ userId: string;
13
+ /** Apps to enable (e.g., ['gmail', 'notion', 'slack']) */
14
+ apps: string[];
15
+ }
16
+ /**
17
+ * OpenConnector MCP session wrapper
18
+ * Manages the lifecycle of MCP client connections to OpenConnector
19
+ */
20
+ export declare class OpenConnectorMCPSession {
21
+ private config;
22
+ private client;
23
+ constructor(config: OpenConnectorMCPConfig);
24
+ /**
25
+ * Get or create the MCP client connection
26
+ * Uses HTTP SSE transport as provided by OpenConnector
27
+ */
28
+ getClient(): Promise<MCPClient>;
29
+ /**
30
+ * Get all available tools from OpenConnector MCP
31
+ * These tools can be passed directly to streamText/generateText
32
+ *
33
+ * @returns Tools object compatible with AI SDK
34
+ */
35
+ getTools(): Promise<ToolSet>;
36
+ /**
37
+ * Close the MCP connection
38
+ * Should be called after request completion or in finally block
39
+ */
40
+ close(): Promise<void>;
41
+ /**
42
+ * Health check for the OpenConnector Worker
43
+ */
44
+ healthCheck(): Promise<boolean>;
45
+ }
46
+ /**
47
+ * Helper function to create a one-shot OpenConnector MCP session
48
+ * For quick tool usage without managing session lifecycle
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const tools = await getOpenConnectorTools({
53
+ * adminToken: process.env.OPEN_CONNECTOR_ADMIN_TOKEN!,
54
+ * baseUrl: 'https://open-connector.example.workers.dev',
55
+ * userId: 'user-123',
56
+ * apps: ['gmail', 'slack'],
57
+ * });
58
+ *
59
+ * const result = await generateText({
60
+ * model: openai('gpt-4o'),
61
+ * prompt: 'Check my unread emails',
62
+ * tools,
63
+ * });
64
+ * ```
65
+ */
66
+ export declare function getOpenConnectorTools(config: OpenConnectorMCPConfig): Promise<ToolSet>;
67
+ /**
68
+ * Create a reusable OpenConnector MCP session
69
+ * Better for multiple requests with the same apps
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const session = await createOpenConnectorSession({
74
+ * adminToken: process.env.OPEN_CONNECTOR_ADMIN_TOKEN!,
75
+ * baseUrl: 'https://open-connector.example.workers.dev',
76
+ * userId: 'user-123',
77
+ * apps: ['gmail', 'notion'],
78
+ * });
79
+ *
80
+ * try {
81
+ * const tools = await session.getTools();
82
+ * const result = await streamText({ model, messages, tools });
83
+ * } finally {
84
+ * await session.close();
85
+ * }
86
+ * ```
87
+ */
88
+ export declare function createOpenConnectorSession(config: OpenConnectorMCPConfig): Promise<OpenConnectorMCPSession>;
@@ -0,0 +1,149 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * List of tools available for agent usage, including their schemas and implementation.
4
+ */
5
+ export declare const AGENT_TOOLS: ({
6
+ name: string;
7
+ description: string;
8
+ schema: z.ZodObject<{
9
+ query: z.ZodString;
10
+ category: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
11
+ general: "general";
12
+ it: "it";
13
+ files: "files";
14
+ news: "news";
15
+ videos: "videos";
16
+ images: "images";
17
+ science: "science";
18
+ }>>>;
19
+ recency: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
20
+ none: "none";
21
+ day: "day";
22
+ week: "week";
23
+ month: "month";
24
+ year: "year";
25
+ }>>>;
26
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
27
+ language: z.ZodDefault<z.ZodOptional<z.ZodString>>;
28
+ public: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
29
+ timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
30
+ baseURL: z.ZodOptional<z.ZodString>;
31
+ apiKey: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>;
33
+ func: ({ query, category, recency, page, language, public: isPublic, timeout, baseURL, apiKey }: {
34
+ query: any;
35
+ category?: string;
36
+ recency?: string;
37
+ page?: number;
38
+ language?: string;
39
+ public?: boolean;
40
+ timeout?: number;
41
+ baseURL: any;
42
+ apiKey: any;
43
+ }) => Promise<string>;
44
+ } | {
45
+ name: string;
46
+ description: string;
47
+ schema: z.ZodObject<{
48
+ url: z.ZodString;
49
+ images: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
50
+ links: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
51
+ formatting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
52
+ absoluteURLs: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
53
+ timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
54
+ baseURL: z.ZodOptional<z.ZodString>;
55
+ apiKey: z.ZodOptional<z.ZodString>;
56
+ }, z.core.$strip>;
57
+ func: ({ url, images, links, formatting, absoluteURLs, timeout, baseURL, apiKey }: {
58
+ url: any;
59
+ images?: boolean;
60
+ links?: boolean;
61
+ formatting?: boolean;
62
+ absoluteURLs?: boolean;
63
+ timeout?: number;
64
+ baseURL: any;
65
+ apiKey: any;
66
+ }) => Promise<string>;
67
+ } | {
68
+ name: string;
69
+ description: string;
70
+ schema: z.ZodObject<{
71
+ provider: z.ZodEnum<{
72
+ anthropic: "anthropic";
73
+ openai: "openai";
74
+ groq: "groq";
75
+ xai: "xai";
76
+ google: "google";
77
+ perplexity: "perplexity";
78
+ together: "together";
79
+ cloudflare: "cloudflare";
80
+ }>;
81
+ key: z.ZodOptional<z.ZodString>;
82
+ agent: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
83
+ question: "question";
84
+ "summarize-bullets": "summarize-bullets";
85
+ summarize: "summarize";
86
+ "suggest-followups": "suggest-followups";
87
+ "answer-cite-sources": "answer-cite-sources";
88
+ "query-resolution": "query-resolution";
89
+ "knowledge-graph-nodes": "knowledge-graph-nodes";
90
+ "summary-longtext": "summary-longtext";
91
+ }>>>;
92
+ model: z.ZodDefault<z.ZodOptional<z.ZodString>>;
93
+ temperature: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
94
+ html: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
95
+ query: z.ZodOptional<z.ZodString>;
96
+ chat_history: z.ZodOptional<z.ZodString>;
97
+ article: z.ZodOptional<z.ZodString>;
98
+ baseURL: z.ZodOptional<z.ZodString>;
99
+ apiKey: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$strip>;
101
+ func: ({ provider, key, agent, model, temperature, html, query, chat_history, article, baseURL, apiKey }: {
102
+ provider: any;
103
+ key: any;
104
+ agent?: string;
105
+ model?: string;
106
+ temperature?: number;
107
+ html?: boolean;
108
+ query: any;
109
+ chat_history: any;
110
+ article: any;
111
+ baseURL: any;
112
+ apiKey: any;
113
+ }) => Promise<string>;
114
+ } | {
115
+ name: string;
116
+ description: string;
117
+ schema: z.ZodObject<{
118
+ url: z.ZodString;
119
+ blockImages: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
120
+ wait: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
121
+ timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
122
+ waitUntil: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
123
+ load: "load";
124
+ domcontentloaded: "domcontentloaded";
125
+ networkidle0: "networkidle0";
126
+ networkidle2: "networkidle2";
127
+ }>>>;
128
+ bypassCaptcha: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
129
+ sessionId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
130
+ format: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
131
+ json: "json";
132
+ html: "html";
133
+ }>>>;
134
+ scraperUrl: z.ZodOptional<z.ZodString>;
135
+ scraperApiKey: z.ZodOptional<z.ZodString>;
136
+ }, z.core.$strip>;
137
+ func: ({ url, blockImages, wait, timeout, waitUntil, bypassCaptcha, sessionId, format, scraperUrl, scraperApiKey }: {
138
+ url: any;
139
+ blockImages?: boolean;
140
+ wait?: number;
141
+ timeout?: number;
142
+ waitUntil?: string;
143
+ bypassCaptcha?: boolean;
144
+ sessionId?: string;
145
+ format?: string;
146
+ scraperUrl: any;
147
+ scraperApiKey: any;
148
+ }) => Promise<string>;
149
+ })[];
@@ -0,0 +1,11 @@
1
+ import { Document } from './document';
2
+ export interface R2CredentialsInput {
3
+ accountId: string;
4
+ accessKeyId: string;
5
+ secretAccessKey: string;
6
+ bucket: string;
7
+ }
8
+ export declare function buildFallbackDocs(query: string): Document[];
9
+ export declare function normalizeSourcesOutput(output: unknown, query: string): Document[];
10
+ export declare function rerankDocs(query: string, docs: Document[], fileIds: string[], optimizationMode: "speed" | "balanced" | "quality", r2Credentials?: R2CredentialsInput): Promise<Document[]>;
11
+ export declare function processDocs(docs: Document[]): string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @module research/search/document
3
+ * @description Minimal document shape shared across the search pipeline.
4
+ * A document is a chunk of page content plus citation metadata (title, url, source, etc.).
5
+ */
6
+ export interface Document<Metadata extends Record<string, any> = Record<string, any>> {
7
+ pageContent: string;
8
+ metadata: Metadata;
9
+ }
10
+ /**
11
+ * Splits text into overlapping chunks on whitespace boundaries.
12
+ * Default chunkSize 1000, chunkOverlap 200.
13
+ */
14
+ export declare function splitTextIntoChunks(text: string, chunkSize?: number, chunkOverlap?: number): string[];
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module agent-toolkit/tools/search
3
+ * @description Meta search agent tools for AI-powered web search and research
4
+ */
5
+ export { default as MetaSearchAgent } from './metaSearchAgent';
6
+ export type { MetaSearchAgentType, Config, ChatTurnMessage, SearchingEvent, FewShotExample } from './meta-search-types';
7
+ export { searchHandlers, createSearchHandlers } from './search-handlers';
8
+ export { default as generateSuggestions } from './suggestionGeneratorAgent';
9
+ export { groupAndSummarizeDocs } from './link-summarizer';
10
+ export type { Document } from './document';
11
+ export { splitTextIntoChunks } from './document';
12
+ export { buildFallbackDocs, rerankDocs, processDocs, normalizeSourcesOutput } from './doc-utils';
@@ -0,0 +1,7 @@
1
+ import { LanguageModel } from 'ai';
2
+ import { Document } from './document';
3
+ /**
4
+ * Groups fetched link documents by URL (max 10 chunks per URL), then
5
+ * summarizes each group with the LLM in parallel.
6
+ */
7
+ export declare function groupAndSummarizeDocs(llm: LanguageModel, linkDocs: Document[], question: string): Promise<Document[]>;
@@ -0,0 +1,50 @@
1
+ import { LanguageModel } from 'ai';
2
+ import { default as EventEmitter } from 'events';
3
+ /** A single conversation turn, matching the Vercel AI SDK message shape. */
4
+ export interface ChatTurnMessage {
5
+ role: "user" | "assistant" | "system";
6
+ content: string;
7
+ }
8
+ /** A `[role, content]` tuple used for few-shot prompt examples. */
9
+ export type FewShotExample = [role: "user" | "assistant", content: string];
10
+ export interface MetaSearchAgentType {
11
+ searchAndAnswer: (message: string, history: ChatTurnMessage[], llm: LanguageModel, optimizationMode: "speed" | "balanced" | "quality", fileIds: string[], systemInstructions: string, category?: string, sourceExtractionEnabled?: boolean, thinkingTimeLimit?: number) => Promise<EventEmitter>;
12
+ }
13
+ /** Emitted on the EventEmitter data channel to report live search progress. */
14
+ export interface SearchingEvent {
15
+ query: string;
16
+ /** Display label shown in the UI (e.g. "Academic · max 10"). */
17
+ category?: string;
18
+ status: "running" | "done";
19
+ }
20
+ export interface Config {
21
+ searchWeb: boolean;
22
+ rerank: boolean;
23
+ rerankThreshold: number;
24
+ queryGeneratorPrompt: string;
25
+ queryGeneratorFewShots: FewShotExample[];
26
+ responsePrompt: string;
27
+ activeEngines: string[];
28
+ /** Optional: Function to fetch documents from URLs */
29
+ getDocumentsFromLinks?: (options: {
30
+ links: string[];
31
+ }) => Promise<any[]>;
32
+ /** Optional: Function to search via SearXNG */
33
+ searchSearxng?: (query: string, options: any) => Promise<{
34
+ results: any[];
35
+ suggestions: string[];
36
+ }>;
37
+ /** Optional: Function to search via Tavily */
38
+ searchTavily?: (query: string, options: any) => Promise<{
39
+ results: any[];
40
+ suggestions: string[];
41
+ }>;
42
+ /** Optional: Function to check if Tavily is configured */
43
+ isTavilyConfigured?: () => boolean;
44
+ /** Optional: Function to scrape a URL */
45
+ scrapeURL?: (url: string, options: any) => Promise<string>;
46
+ }
47
+ export type BasicChainInput = {
48
+ chat_history: ChatTurnMessage[];
49
+ query: string;
50
+ };
@@ -0,0 +1,21 @@
1
+ import { LanguageModel } from 'ai';
2
+ import { default as EventEmitter } from 'events';
3
+ import { Config, ChatTurnMessage, MetaSearchAgentType } from './meta-search-types';
4
+ export type { MetaSearchAgentType, Config } from './meta-search-types';
5
+ declare class MetaSearchAgent implements MetaSearchAgentType {
6
+ private config;
7
+ constructor(config: Config);
8
+ /**
9
+ * Rephrases the user's query into a standalone search question (and any
10
+ * URLs to summarize), runs the web search, and returns the documents to
11
+ * use as answer context.
12
+ */
13
+ private retrieveSearchDocs;
14
+ /**
15
+ * Runs the full search-and-answer pipeline, emitting "sources",
16
+ * "response", "searching", "end", and "error" events on the emitter.
17
+ */
18
+ private runPipeline;
19
+ searchAndAnswer(message: string, history: ChatTurnMessage[], llm: LanguageModel, optimizationMode: "speed" | "balanced" | "quality", fileIds: string[], systemInstructions: string, category?: string, sourceExtractionEnabled?: boolean, thinkingTimeLimit?: number): Promise<EventEmitter<[never]>>;
20
+ }
21
+ export default MetaSearchAgent;
@@ -0,0 +1,27 @@
1
+ import { default as MetaSearchAgent } from './metaSearchAgent';
2
+ import { Config } from './meta-search-types';
3
+ /**
4
+ * Creates search handler instances with provided search functions.
5
+ * Pass in search functions from extract-webpage to enable web search.
6
+ */
7
+ export declare const createSearchHandlers: (searchFunctions?: Partial<Config>) => {
8
+ webSearch: MetaSearchAgent;
9
+ academicSearch: MetaSearchAgent;
10
+ writingAssistant: MetaSearchAgent;
11
+ wolframAlphaSearch: MetaSearchAgent;
12
+ youtubeSearch: MetaSearchAgent;
13
+ redditSearch: MetaSearchAgent;
14
+ };
15
+ /**
16
+ * Default search handlers without search functions.
17
+ * These will not perform actual web searches unless search functions are added to the Config.
18
+ * @deprecated Use createSearchHandlers() with search functions instead
19
+ */
20
+ export declare const searchHandlers: {
21
+ webSearch: MetaSearchAgent;
22
+ academicSearch: MetaSearchAgent;
23
+ writingAssistant: MetaSearchAgent;
24
+ wolframAlphaSearch: MetaSearchAgent;
25
+ youtubeSearch: MetaSearchAgent;
26
+ redditSearch: MetaSearchAgent;
27
+ };
@@ -0,0 +1,8 @@
1
+ import { LanguageModel } from 'ai';
2
+ import { ChatTurnMessage } from './meta-search-types';
3
+ type SuggestionGeneratorInput = {
4
+ chat_history: ChatTurnMessage[];
5
+ maxQuestions?: number;
6
+ };
7
+ declare const generateSuggestions: (input: SuggestionGeneratorInput, llm: LanguageModel) => Promise<string[]>;
8
+ export default generateSuggestions;
@@ -0,0 +1,2 @@
1
+ export * from './index.js'
2
+ export {}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Chat history formatting utilities
3
+ */
4
+ type ChatHistoryMessage = {
5
+ content?: unknown;
6
+ role?: string;
7
+ type?: string;
8
+ };
9
+ export declare const formatChatHistoryAsString: (history: ChatHistoryMessage[]) => string;
10
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './chat-helpers';
2
+ export * from './outputParser';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Convert markdown text to HTML with Highlight.js syntax highlighting.
3
+ * Unescapes HTML entities like `&amp;` \u2192 `&`.
4
+ */
5
+ export declare function convertMarkdownToHTMLEscaped(markdown: string): Promise<string>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @module agent-toolkit/utils/outputParser
3
+ * @description Parsers that extract values from XML-tagged sections of LLM
4
+ * output (e.g. `<links>...</links>`, `<question>...</question>`).
5
+ */
6
+ interface LineListOutputParserArgs {
7
+ key?: string;
8
+ }
9
+ export declare class LineListOutputParser {
10
+ private key;
11
+ constructor(args?: LineListOutputParserArgs);
12
+ parse(text: string): Promise<string[]>;
13
+ }
14
+ interface LineOutputParserArgs {
15
+ key?: string;
16
+ }
17
+ export declare class LineOutputParser {
18
+ private key;
19
+ constructor(args?: LineOutputParserArgs);
20
+ parse(text: string): Promise<string | undefined>;
21
+ }
22
+ export default LineOutputParser;