chat-agent-toolkit 1.2.33 → 1.2.35

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 (42) hide show
  1. package/dist/research-agent.cjs.js.map +1 -1
  2. package/dist/research-agent.es.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/config/config-manager.ts +295 -295
  5. package/src/config/config-types.ts +65 -65
  6. package/src/config/environment-variables.ts +16 -16
  7. package/src/config/index.ts +26 -26
  8. package/src/config/language-models-database.ts +1434 -1434
  9. package/src/config/mcp-server-registry.ts +24 -24
  10. package/src/config/model-registry.ts +271 -271
  11. package/src/config/model-tester.ts +211 -211
  12. package/src/config/model-utils.ts +193 -193
  13. package/src/config/provider-ui-config.ts +196 -196
  14. package/src/connectors/open-connector.json +130 -130
  15. package/src/index.ts +26 -26
  16. package/src/memory/ARCHITECTURE.md +302 -302
  17. package/src/memory/README.md +224 -224
  18. package/src/memory/agent-memory-manager.ts +416 -416
  19. package/src/memory/example.ts +343 -343
  20. package/src/memory/index.ts +47 -47
  21. package/src/memory/mastra-integration.ts +604 -604
  22. package/src/memory/storage/drizzle-storage.ts +236 -236
  23. package/src/memory/storage/in-memory-storage.ts +551 -551
  24. package/src/memory/storage/storage-interface.ts +68 -68
  25. package/src/memory/types.ts +125 -125
  26. package/src/models/types.ts +4 -4
  27. package/src/tools/index.ts +13 -13
  28. package/src/tools/open-connector-mastra.ts +270 -270
  29. package/src/tools/open-connector-mcp.ts +170 -170
  30. package/src/tools/qwksearch-api-tools.ts +326 -326
  31. package/src/tools/search/doc-utils.ts +139 -139
  32. package/src/tools/search/document.ts +47 -47
  33. package/src/tools/search/index.ts +14 -14
  34. package/src/tools/search/link-summarizer.ts +112 -112
  35. package/src/tools/search/meta-search-types.ts +62 -62
  36. package/src/tools/search/metaSearchAgent.ts +465 -465
  37. package/src/tools/search/search-handlers.ts +97 -97
  38. package/src/tools/search/suggestionGeneratorAgent.ts +56 -56
  39. package/src/types.d.ts +137 -137
  40. package/src/utils/index.ts +2 -2
  41. package/src/utils/markdown-to-html.ts +53 -53
  42. package/src/utils/outputParser.ts +73 -73
@@ -1,97 +1,97 @@
1
- /**
2
- * @module research/search/index
3
- * @description Research library module.
4
- *
5
- * Note: To use these search handlers, you need to provide search functions
6
- * (searchSearxng, searchTavily, etc.) from extract-webpage package.
7
- * See extract-webpage/src/search/index.ts for an example.
8
- */
9
- import MetaSearchAgent from "./metaSearchAgent";
10
- import {
11
- webSearchRetrieverPrompt,
12
- webSearchResponsePrompt,
13
- webSearchRetrieverFewShots,
14
- writingAssistantPrompt,
15
- } from "../../prompts";
16
- import type { Config } from "./meta-search-types";
17
-
18
- const prompts = {
19
- webSearchRetrieverPrompt,
20
- webSearchResponsePrompt,
21
- webSearchRetrieverFewShots,
22
- writingAssistantPrompt,
23
- };
24
-
25
- /**
26
- * Creates search handler instances with provided search functions.
27
- * Pass in search functions from extract-webpage to enable web search.
28
- */
29
- export const createSearchHandlers = (searchFunctions?: Partial<Config>) => ({
30
- webSearch: new MetaSearchAgent({
31
- activeEngines: [],
32
- queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
33
- responsePrompt: prompts.webSearchResponsePrompt,
34
- queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
35
- rerank: true,
36
- rerankThreshold: 0.3,
37
- searchWeb: true,
38
- ...searchFunctions,
39
- }),
40
- academicSearch: new MetaSearchAgent({
41
- activeEngines: ["arxiv", "google scholar", "pubmed"],
42
- queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
43
- responsePrompt: prompts.webSearchResponsePrompt,
44
- queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
45
- rerank: true,
46
- rerankThreshold: 0,
47
- searchWeb: true,
48
- ...searchFunctions,
49
- }),
50
- writingAssistant: new MetaSearchAgent({
51
- activeEngines: [],
52
- queryGeneratorPrompt: "",
53
- queryGeneratorFewShots: [],
54
- responsePrompt: prompts.writingAssistantPrompt,
55
- rerank: true,
56
- rerankThreshold: 0,
57
- searchWeb: true,
58
- ...searchFunctions,
59
- }),
60
- wolframAlphaSearch: new MetaSearchAgent({
61
- activeEngines: ["wolframalpha"],
62
- queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
63
- responsePrompt: prompts.webSearchResponsePrompt,
64
- queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
65
- rerank: false,
66
- rerankThreshold: 0,
67
- searchWeb: true,
68
- ...searchFunctions,
69
- }),
70
- youtubeSearch: new MetaSearchAgent({
71
- activeEngines: ["youtube"],
72
- queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
73
- responsePrompt: prompts.webSearchResponsePrompt,
74
- queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
75
- rerank: true,
76
- rerankThreshold: 0.3,
77
- searchWeb: true,
78
- ...searchFunctions,
79
- }),
80
- redditSearch: new MetaSearchAgent({
81
- activeEngines: ["reddit"],
82
- queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
83
- responsePrompt: prompts.webSearchResponsePrompt,
84
- queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
85
- rerank: true,
86
- rerankThreshold: 0.3,
87
- searchWeb: true,
88
- ...searchFunctions,
89
- }),
90
- });
91
-
92
- /**
93
- * Default search handlers without search functions.
94
- * These will not perform actual web searches unless search functions are added to the Config.
95
- * @deprecated Use createSearchHandlers() with search functions instead
96
- */
97
- export const searchHandlers = createSearchHandlers();
1
+ /**
2
+ * @module research/search/index
3
+ * @description Research library module.
4
+ *
5
+ * Note: To use these search handlers, you need to provide search functions
6
+ * (searchSearxng, searchTavily, etc.) from extract-webpage package.
7
+ * See extract-webpage/src/search/index.ts for an example.
8
+ */
9
+ import MetaSearchAgent from "./metaSearchAgent";
10
+ import {
11
+ webSearchRetrieverPrompt,
12
+ webSearchResponsePrompt,
13
+ webSearchRetrieverFewShots,
14
+ writingAssistantPrompt,
15
+ } from "../../prompts";
16
+ import type { Config } from "./meta-search-types";
17
+
18
+ const prompts = {
19
+ webSearchRetrieverPrompt,
20
+ webSearchResponsePrompt,
21
+ webSearchRetrieverFewShots,
22
+ writingAssistantPrompt,
23
+ };
24
+
25
+ /**
26
+ * Creates search handler instances with provided search functions.
27
+ * Pass in search functions from extract-webpage to enable web search.
28
+ */
29
+ export const createSearchHandlers = (searchFunctions?: Partial<Config>) => ({
30
+ webSearch: new MetaSearchAgent({
31
+ activeEngines: [],
32
+ queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
33
+ responsePrompt: prompts.webSearchResponsePrompt,
34
+ queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
35
+ rerank: true,
36
+ rerankThreshold: 0.3,
37
+ searchWeb: true,
38
+ ...searchFunctions,
39
+ }),
40
+ academicSearch: new MetaSearchAgent({
41
+ activeEngines: ["arxiv", "google scholar", "pubmed"],
42
+ queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
43
+ responsePrompt: prompts.webSearchResponsePrompt,
44
+ queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
45
+ rerank: true,
46
+ rerankThreshold: 0,
47
+ searchWeb: true,
48
+ ...searchFunctions,
49
+ }),
50
+ writingAssistant: new MetaSearchAgent({
51
+ activeEngines: [],
52
+ queryGeneratorPrompt: "",
53
+ queryGeneratorFewShots: [],
54
+ responsePrompt: prompts.writingAssistantPrompt,
55
+ rerank: true,
56
+ rerankThreshold: 0,
57
+ searchWeb: true,
58
+ ...searchFunctions,
59
+ }),
60
+ wolframAlphaSearch: new MetaSearchAgent({
61
+ activeEngines: ["wolframalpha"],
62
+ queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
63
+ responsePrompt: prompts.webSearchResponsePrompt,
64
+ queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
65
+ rerank: false,
66
+ rerankThreshold: 0,
67
+ searchWeb: true,
68
+ ...searchFunctions,
69
+ }),
70
+ youtubeSearch: new MetaSearchAgent({
71
+ activeEngines: ["youtube"],
72
+ queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
73
+ responsePrompt: prompts.webSearchResponsePrompt,
74
+ queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
75
+ rerank: true,
76
+ rerankThreshold: 0.3,
77
+ searchWeb: true,
78
+ ...searchFunctions,
79
+ }),
80
+ redditSearch: new MetaSearchAgent({
81
+ activeEngines: ["reddit"],
82
+ queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
83
+ responsePrompt: prompts.webSearchResponsePrompt,
84
+ queryGeneratorFewShots: prompts.webSearchRetrieverFewShots,
85
+ rerank: true,
86
+ rerankThreshold: 0.3,
87
+ searchWeb: true,
88
+ ...searchFunctions,
89
+ }),
90
+ });
91
+
92
+ /**
93
+ * Default search handlers without search functions.
94
+ * These will not perform actual web searches unless search functions are added to the Config.
95
+ * @deprecated Use createSearchHandlers() with search functions instead
96
+ */
97
+ export const searchHandlers = createSearchHandlers();
@@ -1,56 +1,56 @@
1
- /**
2
- * @module research/chains/suggestionGeneratorAgent
3
- * @description Generates follow-up question suggestions from a conversation
4
- * using the Vercel AI SDK.
5
- */
6
- import { generateText, type LanguageModel } from "ai";
7
- import { LineListOutputParser } from "../../utils/outputParser";
8
- import { formatChatHistoryAsString } from "../../utils";
9
- import type { ChatTurnMessage } from "./meta-search-types";
10
-
11
- const createSuggestionGeneratorPrompt = (maxQuestions: number = 4) => `
12
- You are an AI suggestion generator for an AI powered search engine. You will be given a conversation below. You need to generate ${maxQuestions} suggestions based on the conversation. The suggestion should be relevant to the conversation that can be used by the user to ask the chat model for more information.
13
- You need to make sure the suggestions are relevant to the conversation and are helpful to the user. Keep a note that the user might use these suggestions to ask a chat model for more information.
14
- Make sure the suggestions are medium in length and are informative and relevant to the conversation.
15
-
16
- Provide these suggestions separated by newlines between the XML tags <suggestions> and </suggestions>. For example:
17
-
18
- <suggestions>
19
- Tell me more about SpaceX and their recent projects
20
- What is the latest news on SpaceX?
21
- Who is the CEO of SpaceX?
22
- </suggestions>
23
-
24
- Conversation:
25
- {chat_history}
26
- `;
27
-
28
- type SuggestionGeneratorInput = {
29
- chat_history: ChatTurnMessage[];
30
- maxQuestions?: number;
31
- };
32
-
33
- const outputParser = new LineListOutputParser({
34
- key: "suggestions",
35
- });
36
-
37
- const generateSuggestions = async (
38
- input: SuggestionGeneratorInput,
39
- llm: LanguageModel,
40
- ): Promise<string[]> => {
41
- const maxQuestions = input.maxQuestions ?? 4;
42
- const prompt = createSuggestionGeneratorPrompt(maxQuestions).replace(
43
- "{chat_history}",
44
- formatChatHistoryAsString(input.chat_history),
45
- );
46
-
47
- const { text } = await generateText({
48
- model: llm,
49
- temperature: 0,
50
- prompt,
51
- });
52
-
53
- return outputParser.parse(text);
54
- };
55
-
56
- export default generateSuggestions;
1
+ /**
2
+ * @module research/chains/suggestionGeneratorAgent
3
+ * @description Generates follow-up question suggestions from a conversation
4
+ * using the Vercel AI SDK.
5
+ */
6
+ import { generateText, type LanguageModel } from "ai";
7
+ import { LineListOutputParser } from "../../utils/outputParser";
8
+ import { formatChatHistoryAsString } from "../../utils";
9
+ import type { ChatTurnMessage } from "./meta-search-types";
10
+
11
+ const createSuggestionGeneratorPrompt = (maxQuestions: number = 4) => `
12
+ You are an AI suggestion generator for an AI powered search engine. You will be given a conversation below. You need to generate ${maxQuestions} suggestions based on the conversation. The suggestion should be relevant to the conversation that can be used by the user to ask the chat model for more information.
13
+ You need to make sure the suggestions are relevant to the conversation and are helpful to the user. Keep a note that the user might use these suggestions to ask a chat model for more information.
14
+ Make sure the suggestions are medium in length and are informative and relevant to the conversation.
15
+
16
+ Provide these suggestions separated by newlines between the XML tags <suggestions> and </suggestions>. For example:
17
+
18
+ <suggestions>
19
+ Tell me more about SpaceX and their recent projects
20
+ What is the latest news on SpaceX?
21
+ Who is the CEO of SpaceX?
22
+ </suggestions>
23
+
24
+ Conversation:
25
+ {chat_history}
26
+ `;
27
+
28
+ type SuggestionGeneratorInput = {
29
+ chat_history: ChatTurnMessage[];
30
+ maxQuestions?: number;
31
+ };
32
+
33
+ const outputParser = new LineListOutputParser({
34
+ key: "suggestions",
35
+ });
36
+
37
+ const generateSuggestions = async (
38
+ input: SuggestionGeneratorInput,
39
+ llm: LanguageModel,
40
+ ): Promise<string[]> => {
41
+ const maxQuestions = input.maxQuestions ?? 4;
42
+ const prompt = createSuggestionGeneratorPrompt(maxQuestions).replace(
43
+ "{chat_history}",
44
+ formatChatHistoryAsString(input.chat_history),
45
+ );
46
+
47
+ const { text } = await generateText({
48
+ model: llm,
49
+ temperature: 0,
50
+ prompt,
51
+ });
52
+
53
+ return outputParser.parse(text);
54
+ };
55
+
56
+ export default generateSuggestions;
package/src/types.d.ts CHANGED
@@ -1,137 +1,137 @@
1
- /**
2
- * @fileoverview Global Type Definitions
3
- *
4
- * Shared TypeScript types for UI configuration, model providers,
5
- * and MCP server configuration used throughout the toolkit.
6
- */
7
-
8
- import { Model } from "./config/config-types";
9
-
10
- type BaseUIConfigField = {
11
- name: string;
12
- key: string;
13
- required: boolean;
14
- description: string;
15
- scope: "client" | "server";
16
- env?: string;
17
- };
18
-
19
- type StringUIConfigField = BaseUIConfigField & {
20
- type: "string";
21
- placeholder?: string;
22
- default?: string;
23
- };
24
-
25
- type SelectUIConfigFieldOptions = {
26
- name: string;
27
- value: string;
28
- };
29
-
30
- type SelectUIConfigField = BaseUIConfigField & {
31
- type: "select";
32
- default?: string;
33
- options: SelectUIConfigFieldOptions[];
34
- };
35
-
36
- type PasswordUIConfigField = BaseUIConfigField & {
37
- type: "password";
38
- placeholder?: string;
39
- default?: string;
40
- };
41
-
42
- type TextareaUIConfigField = BaseUIConfigField & {
43
- type: "textarea";
44
- placeholder?: string;
45
- default?: string;
46
- };
47
-
48
- type SwitchUIConfigField = BaseUIConfigField & {
49
- type: "switch";
50
- default?: boolean;
51
- };
52
-
53
- type UIConfigField =
54
- | StringUIConfigField
55
- | SelectUIConfigField
56
- | PasswordUIConfigField
57
- | TextareaUIConfigField
58
- | SwitchUIConfigField;
59
-
60
- type ConfigModelProvider = {
61
- id: string;
62
- name: string;
63
- type: string;
64
- chatModels: Model[];
65
- config: { [key: string]: any };
66
- hash: string;
67
- isEnvBased?: boolean; // True if provider was created from environment variables (global keys)
68
- };
69
-
70
- type MCPServerConfig = {
71
- id: string;
72
- name: string;
73
- type: string;
74
- url?: string;
75
- apiKey?: string;
76
- config: { [key: string]: any };
77
- enabled: boolean;
78
- hash: string;
79
- };
80
-
81
- type Config = {
82
- version: number;
83
- setupComplete: boolean;
84
- preferences: {
85
- [key: string]: any;
86
- };
87
- personalization: {
88
- [key: string]: any;
89
- };
90
- modelProviders: ConfigModelProvider[];
91
- mcpServers: MCPServerConfig[];
92
- search: {
93
- [key: string]: any;
94
- };
95
- };
96
-
97
- type EnvMap = {
98
- [key: string]: {
99
- fieldKey: string;
100
- providerKey: string;
101
- };
102
- };
103
-
104
- type ModelProviderUISection = {
105
- name: string;
106
- key: string;
107
- fields: UIConfigField[];
108
- };
109
-
110
- type MCPServerUISection = {
111
- name: string;
112
- key: string;
113
- fields: UIConfigField[];
114
- };
115
-
116
- type UIConfigSections = {
117
- preferences: UIConfigField[];
118
- personalization: UIConfigField[];
119
- modelProviders: ModelProviderUISection[];
120
- mcpServers: MCPServerUISection[];
121
- search: UIConfigField[];
122
- };
123
-
124
- export type {
125
- UIConfigField,
126
- Config,
127
- EnvMap,
128
- UIConfigSections,
129
- SelectUIConfigField,
130
- StringUIConfigField,
131
- ModelProviderUISection,
132
- MCPServerUISection,
133
- ConfigModelProvider,
134
- MCPServerConfig,
135
- TextareaUIConfigField,
136
- SwitchUIConfigField,
137
- };
1
+ /**
2
+ * @fileoverview Global Type Definitions
3
+ *
4
+ * Shared TypeScript types for UI configuration, model providers,
5
+ * and MCP server configuration used throughout the toolkit.
6
+ */
7
+
8
+ import { Model } from "./config/config-types";
9
+
10
+ type BaseUIConfigField = {
11
+ name: string;
12
+ key: string;
13
+ required: boolean;
14
+ description: string;
15
+ scope: "client" | "server";
16
+ env?: string;
17
+ };
18
+
19
+ type StringUIConfigField = BaseUIConfigField & {
20
+ type: "string";
21
+ placeholder?: string;
22
+ default?: string;
23
+ };
24
+
25
+ type SelectUIConfigFieldOptions = {
26
+ name: string;
27
+ value: string;
28
+ };
29
+
30
+ type SelectUIConfigField = BaseUIConfigField & {
31
+ type: "select";
32
+ default?: string;
33
+ options: SelectUIConfigFieldOptions[];
34
+ };
35
+
36
+ type PasswordUIConfigField = BaseUIConfigField & {
37
+ type: "password";
38
+ placeholder?: string;
39
+ default?: string;
40
+ };
41
+
42
+ type TextareaUIConfigField = BaseUIConfigField & {
43
+ type: "textarea";
44
+ placeholder?: string;
45
+ default?: string;
46
+ };
47
+
48
+ type SwitchUIConfigField = BaseUIConfigField & {
49
+ type: "switch";
50
+ default?: boolean;
51
+ };
52
+
53
+ type UIConfigField =
54
+ | StringUIConfigField
55
+ | SelectUIConfigField
56
+ | PasswordUIConfigField
57
+ | TextareaUIConfigField
58
+ | SwitchUIConfigField;
59
+
60
+ type ConfigModelProvider = {
61
+ id: string;
62
+ name: string;
63
+ type: string;
64
+ chatModels: Model[];
65
+ config: { [key: string]: any };
66
+ hash: string;
67
+ isEnvBased?: boolean; // True if provider was created from environment variables (global keys)
68
+ };
69
+
70
+ type MCPServerConfig = {
71
+ id: string;
72
+ name: string;
73
+ type: string;
74
+ url?: string;
75
+ apiKey?: string;
76
+ config: { [key: string]: any };
77
+ enabled: boolean;
78
+ hash: string;
79
+ };
80
+
81
+ type Config = {
82
+ version: number;
83
+ setupComplete: boolean;
84
+ preferences: {
85
+ [key: string]: any;
86
+ };
87
+ personalization: {
88
+ [key: string]: any;
89
+ };
90
+ modelProviders: ConfigModelProvider[];
91
+ mcpServers: MCPServerConfig[];
92
+ search: {
93
+ [key: string]: any;
94
+ };
95
+ };
96
+
97
+ type EnvMap = {
98
+ [key: string]: {
99
+ fieldKey: string;
100
+ providerKey: string;
101
+ };
102
+ };
103
+
104
+ type ModelProviderUISection = {
105
+ name: string;
106
+ key: string;
107
+ fields: UIConfigField[];
108
+ };
109
+
110
+ type MCPServerUISection = {
111
+ name: string;
112
+ key: string;
113
+ fields: UIConfigField[];
114
+ };
115
+
116
+ type UIConfigSections = {
117
+ preferences: UIConfigField[];
118
+ personalization: UIConfigField[];
119
+ modelProviders: ModelProviderUISection[];
120
+ mcpServers: MCPServerUISection[];
121
+ search: UIConfigField[];
122
+ };
123
+
124
+ export type {
125
+ UIConfigField,
126
+ Config,
127
+ EnvMap,
128
+ UIConfigSections,
129
+ SelectUIConfigField,
130
+ StringUIConfigField,
131
+ ModelProviderUISection,
132
+ MCPServerUISection,
133
+ ConfigModelProvider,
134
+ MCPServerConfig,
135
+ TextareaUIConfigField,
136
+ SwitchUIConfigField,
137
+ };
@@ -1,2 +1,2 @@
1
- export * from './chat-helpers';
2
- export * from './outputParser';
1
+ export * from './chat-helpers';
2
+ export * from './outputParser';