chat-agent-toolkit 1.2.32 → 1.2.34

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 (67) hide show
  1. package/dist/research-agent.cjs.js +1 -1
  2. package/dist/research-agent.cjs.js.map +1 -1
  3. package/dist/research-agent.es.js +1 -1
  4. package/dist/research-agent.es.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/config/config-manager.ts +295 -295
  7. package/src/config/config-types.ts +65 -65
  8. package/src/config/environment-variables.ts +16 -16
  9. package/src/config/index.ts +26 -26
  10. package/src/config/language-models-database.ts +1434 -1434
  11. package/src/config/mcp-server-registry.ts +24 -24
  12. package/src/config/model-registry.ts +271 -271
  13. package/src/config/model-tester.ts +211 -211
  14. package/src/config/model-utils.ts +193 -193
  15. package/src/config/provider-ui-config.ts +196 -196
  16. package/src/connectors/open-connector.json +130 -130
  17. package/src/index.ts +26 -26
  18. package/src/memory/ARCHITECTURE.md +302 -302
  19. package/src/memory/README.md +224 -224
  20. package/src/memory/agent-memory-manager.ts +416 -416
  21. package/src/memory/example.ts +343 -343
  22. package/src/memory/index.ts +47 -47
  23. package/src/memory/mastra-integration.ts +604 -604
  24. package/src/memory/storage/drizzle-storage.ts +236 -236
  25. package/src/memory/storage/in-memory-storage.ts +551 -551
  26. package/src/memory/storage/storage-interface.ts +68 -68
  27. package/src/memory/types.ts +125 -125
  28. package/src/models/types.ts +4 -4
  29. package/src/provider-logos/01-ai.png +0 -0
  30. package/src/provider-logos/anthropic.png +0 -0
  31. package/src/provider-logos/aws-bedrock.png +0 -0
  32. package/src/provider-logos/aws-sagemaker.png +0 -0
  33. package/src/provider-logos/azure-openai-service.png +0 -0
  34. package/src/provider-logos/chatglm.png +0 -0
  35. package/src/provider-logos/cohere.png +0 -0
  36. package/src/provider-logos/gemini.png +0 -0
  37. package/src/provider-logos/groqcloud.png +0 -0
  38. package/src/provider-logos/huggingface.png +0 -0
  39. package/src/provider-logos/jina.png +0 -0
  40. package/src/provider-logos/localai.png +0 -0
  41. package/src/provider-logos/mistral-ai.png +0 -0
  42. package/src/provider-logos/moonshot-ai.png +0 -0
  43. package/src/provider-logos/ollama.png +0 -0
  44. package/src/provider-logos/openai.png +0 -0
  45. package/src/provider-logos/openllm.png +0 -0
  46. package/src/provider-logos/openrouter.png +0 -0
  47. package/src/provider-logos/replicate.png +0 -0
  48. package/src/provider-logos/together-ai.png +0 -0
  49. package/src/provider-logos/tongyi.png +0 -0
  50. package/src/provider-logos/xorbits-inference.png +0 -0
  51. package/src/provider-logos/zhipu-ai.png +0 -0
  52. package/src/tools/index.ts +13 -13
  53. package/src/tools/open-connector-mastra.ts +270 -270
  54. package/src/tools/open-connector-mcp.ts +170 -170
  55. package/src/tools/qwksearch-api-tools.ts +326 -326
  56. package/src/tools/search/doc-utils.ts +139 -139
  57. package/src/tools/search/document.ts +47 -47
  58. package/src/tools/search/index.ts +14 -14
  59. package/src/tools/search/link-summarizer.ts +112 -112
  60. package/src/tools/search/meta-search-types.ts +62 -62
  61. package/src/tools/search/metaSearchAgent.ts +465 -465
  62. package/src/tools/search/search-handlers.ts +97 -97
  63. package/src/tools/search/suggestionGeneratorAgent.ts +56 -56
  64. package/src/types.d.ts +137 -137
  65. package/src/utils/index.ts +2 -2
  66. package/src/utils/markdown-to-html.ts +53 -53
  67. package/src/utils/outputParser.ts +73 -73
@@ -1,211 +1,211 @@
1
- /**
2
- * @fileoverview Model availability testing and validation
3
- * Tests which models are actually working for a given provider
4
- */
5
-
6
- import { generateText } from "ai";
7
- import { createLLMProvider } from "write-language";
8
-
9
- export interface ModelTestResult {
10
- modelId: string;
11
- modelName: string;
12
- available: boolean;
13
- error?: string;
14
- latency?: number;
15
- type?: string;
16
- }
17
-
18
- export interface ProviderTestResult {
19
- provider: string;
20
- totalModels: number;
21
- availableModels: ModelTestResult[];
22
- unavailableModels: ModelTestResult[];
23
- testDuration: number;
24
- }
25
-
26
- /**
27
- * Test a single model to see if it's working
28
- */
29
- export async function testModel(
30
- provider: string,
31
- apiKey: string,
32
- modelId: string,
33
- modelName: string,
34
- modelType: string = "text-generation",
35
- timeout: number = 10000
36
- ): Promise<ModelTestResult> {
37
- const startTime = Date.now();
38
-
39
- try {
40
- // Only test text-generation models
41
- if (modelType !== "text-generation") {
42
- return {
43
- modelId,
44
- modelName,
45
- available: false,
46
- error: `Skipped: ${modelType} models not testable via text generation`,
47
- type: modelType,
48
- };
49
- }
50
-
51
- const model = createLLMProvider(
52
- provider.toLowerCase(),
53
- apiKey,
54
- modelId,
55
- 0.1
56
- );
57
-
58
- if (!model) {
59
- return {
60
- modelId,
61
- modelName,
62
- available: false,
63
- error: "Provider not supported",
64
- type: modelType,
65
- };
66
- }
67
-
68
- // Create a promise that will timeout
69
- const timeoutPromise = new Promise((_, reject) =>
70
- setTimeout(() => reject(new Error("Test timeout")), timeout)
71
- );
72
-
73
- // Test with a simple prompt
74
- const testPromise = generateText({
75
- model,
76
- prompt: "Reply with just 'OK'",
77
- maxOutputTokens: 10,
78
- });
79
-
80
- const result = await Promise.race([testPromise, timeoutPromise]) as any;
81
-
82
- const latency = Date.now() - startTime;
83
-
84
- return {
85
- modelId,
86
- modelName,
87
- available: true,
88
- latency,
89
- type: modelType,
90
- };
91
- } catch (error: any) {
92
- return {
93
- modelId,
94
- modelName,
95
- available: false,
96
- error: error.message || String(error),
97
- latency: Date.now() - startTime,
98
- type: modelType,
99
- };
100
- }
101
- }
102
-
103
- /**
104
- * Test all models for a provider
105
- */
106
- export async function testProviderModels(
107
- provider: string,
108
- apiKey: string,
109
- models: Array<{ id: string; name: string; type?: string; free?: boolean }>,
110
- options: {
111
- onlyFree?: boolean;
112
- concurrency?: number;
113
- timeout?: number;
114
- onProgress?: (current: number, total: number, modelName: string) => void;
115
- } = {}
116
- ): Promise<ProviderTestResult> {
117
- const {
118
- onlyFree = false,
119
- concurrency = 3,
120
- timeout = 10000,
121
- onProgress,
122
- } = options;
123
-
124
- const startTime = Date.now();
125
-
126
- // Filter models
127
- let modelsToTest = models;
128
- if (onlyFree) {
129
- modelsToTest = models.filter((m) => m.free !== false);
130
- }
131
-
132
- const results: ModelTestResult[] = [];
133
- const queue = [...modelsToTest];
134
- let completed = 0;
135
-
136
- // Test models with concurrency control
137
- const workers = Array(Math.min(concurrency, modelsToTest.length))
138
- .fill(null)
139
- .map(async () => {
140
- while (queue.length > 0) {
141
- const model = queue.shift();
142
- if (!model) break;
143
-
144
- const result = await testModel(
145
- provider,
146
- apiKey,
147
- model.id,
148
- model.name,
149
- model.type || "text-generation",
150
- timeout
151
- );
152
-
153
- results.push(result);
154
- completed++;
155
-
156
- if (onProgress) {
157
- onProgress(completed, modelsToTest.length, model.name);
158
- }
159
- }
160
- });
161
-
162
- await Promise.all(workers);
163
-
164
- const availableModels = results.filter((r) => r.available);
165
- const unavailableModels = results.filter((r) => !r.available);
166
-
167
- return {
168
- provider,
169
- totalModels: modelsToTest.length,
170
- availableModels,
171
- unavailableModels,
172
- testDuration: Date.now() - startTime,
173
- };
174
- }
175
-
176
- /**
177
- * Get only free models from a model list
178
- */
179
- export function getOnlyFreeModels<T extends { free?: boolean }>(
180
- models: T[]
181
- ): T[] {
182
- return models.filter((m) => m.free === true);
183
- }
184
-
185
- /**
186
- * Categorize models by type
187
- */
188
- export function categorizeModelsByType<
189
- T extends { type?: string; id: string; name: string }
190
- >(models: T[]): Record<string, T[]> {
191
- const categories: Record<string, T[]> = {
192
- "text-generation": [],
193
- vision: [],
194
- embedding: [],
195
- reranker: [],
196
- image: [],
197
- video: [],
198
- audio: [],
199
- other: [],
200
- };
201
-
202
- for (const model of models) {
203
- const type = model.type || "text-generation";
204
- if (!categories[type]) {
205
- categories[type] = [];
206
- }
207
- categories[type].push(model);
208
- }
209
-
210
- return categories;
211
- }
1
+ /**
2
+ * @fileoverview Model availability testing and validation
3
+ * Tests which models are actually working for a given provider
4
+ */
5
+
6
+ import { generateText } from "ai";
7
+ import { createLLMProvider } from "write-language";
8
+
9
+ export interface ModelTestResult {
10
+ modelId: string;
11
+ modelName: string;
12
+ available: boolean;
13
+ error?: string;
14
+ latency?: number;
15
+ type?: string;
16
+ }
17
+
18
+ export interface ProviderTestResult {
19
+ provider: string;
20
+ totalModels: number;
21
+ availableModels: ModelTestResult[];
22
+ unavailableModels: ModelTestResult[];
23
+ testDuration: number;
24
+ }
25
+
26
+ /**
27
+ * Test a single model to see if it's working
28
+ */
29
+ export async function testModel(
30
+ provider: string,
31
+ apiKey: string,
32
+ modelId: string,
33
+ modelName: string,
34
+ modelType: string = "text-generation",
35
+ timeout: number = 10000
36
+ ): Promise<ModelTestResult> {
37
+ const startTime = Date.now();
38
+
39
+ try {
40
+ // Only test text-generation models
41
+ if (modelType !== "text-generation") {
42
+ return {
43
+ modelId,
44
+ modelName,
45
+ available: false,
46
+ error: `Skipped: ${modelType} models not testable via text generation`,
47
+ type: modelType,
48
+ };
49
+ }
50
+
51
+ const model = createLLMProvider(
52
+ provider.toLowerCase(),
53
+ apiKey,
54
+ modelId,
55
+ 0.1
56
+ );
57
+
58
+ if (!model) {
59
+ return {
60
+ modelId,
61
+ modelName,
62
+ available: false,
63
+ error: "Provider not supported",
64
+ type: modelType,
65
+ };
66
+ }
67
+
68
+ // Create a promise that will timeout
69
+ const timeoutPromise = new Promise((_, reject) =>
70
+ setTimeout(() => reject(new Error("Test timeout")), timeout)
71
+ );
72
+
73
+ // Test with a simple prompt
74
+ const testPromise = generateText({
75
+ model,
76
+ prompt: "Reply with just 'OK'",
77
+ maxOutputTokens: 10,
78
+ });
79
+
80
+ const result = await Promise.race([testPromise, timeoutPromise]) as any;
81
+
82
+ const latency = Date.now() - startTime;
83
+
84
+ return {
85
+ modelId,
86
+ modelName,
87
+ available: true,
88
+ latency,
89
+ type: modelType,
90
+ };
91
+ } catch (error: any) {
92
+ return {
93
+ modelId,
94
+ modelName,
95
+ available: false,
96
+ error: error.message || String(error),
97
+ latency: Date.now() - startTime,
98
+ type: modelType,
99
+ };
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Test all models for a provider
105
+ */
106
+ export async function testProviderModels(
107
+ provider: string,
108
+ apiKey: string,
109
+ models: Array<{ id: string; name: string; type?: string; free?: boolean }>,
110
+ options: {
111
+ onlyFree?: boolean;
112
+ concurrency?: number;
113
+ timeout?: number;
114
+ onProgress?: (current: number, total: number, modelName: string) => void;
115
+ } = {}
116
+ ): Promise<ProviderTestResult> {
117
+ const {
118
+ onlyFree = false,
119
+ concurrency = 3,
120
+ timeout = 10000,
121
+ onProgress,
122
+ } = options;
123
+
124
+ const startTime = Date.now();
125
+
126
+ // Filter models
127
+ let modelsToTest = models;
128
+ if (onlyFree) {
129
+ modelsToTest = models.filter((m) => m.free !== false);
130
+ }
131
+
132
+ const results: ModelTestResult[] = [];
133
+ const queue = [...modelsToTest];
134
+ let completed = 0;
135
+
136
+ // Test models with concurrency control
137
+ const workers = Array(Math.min(concurrency, modelsToTest.length))
138
+ .fill(null)
139
+ .map(async () => {
140
+ while (queue.length > 0) {
141
+ const model = queue.shift();
142
+ if (!model) break;
143
+
144
+ const result = await testModel(
145
+ provider,
146
+ apiKey,
147
+ model.id,
148
+ model.name,
149
+ model.type || "text-generation",
150
+ timeout
151
+ );
152
+
153
+ results.push(result);
154
+ completed++;
155
+
156
+ if (onProgress) {
157
+ onProgress(completed, modelsToTest.length, model.name);
158
+ }
159
+ }
160
+ });
161
+
162
+ await Promise.all(workers);
163
+
164
+ const availableModels = results.filter((r) => r.available);
165
+ const unavailableModels = results.filter((r) => !r.available);
166
+
167
+ return {
168
+ provider,
169
+ totalModels: modelsToTest.length,
170
+ availableModels,
171
+ unavailableModels,
172
+ testDuration: Date.now() - startTime,
173
+ };
174
+ }
175
+
176
+ /**
177
+ * Get only free models from a model list
178
+ */
179
+ export function getOnlyFreeModels<T extends { free?: boolean }>(
180
+ models: T[]
181
+ ): T[] {
182
+ return models.filter((m) => m.free === true);
183
+ }
184
+
185
+ /**
186
+ * Categorize models by type
187
+ */
188
+ export function categorizeModelsByType<
189
+ T extends { type?: string; id: string; name: string }
190
+ >(models: T[]): Record<string, T[]> {
191
+ const categories: Record<string, T[]> = {
192
+ "text-generation": [],
193
+ vision: [],
194
+ embedding: [],
195
+ reranker: [],
196
+ image: [],
197
+ video: [],
198
+ audio: [],
199
+ other: [],
200
+ };
201
+
202
+ for (const model of models) {
203
+ const type = model.type || "text-generation";
204
+ if (!categories[type]) {
205
+ categories[type] = [];
206
+ }
207
+ categories[type].push(model);
208
+ }
209
+
210
+ return categories;
211
+ }