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.
- package/README.md +6 -6
- package/dist/config/config-manager.d.ts +23 -0
- package/dist/config/config-types.d.ts +58 -0
- package/dist/config/environment-variables.d.ts +6 -0
- package/dist/config/index.d.ts +18 -0
- package/dist/config/language-models-database.d.ts +93 -0
- package/dist/config/mcp-server-registry.d.ts +7 -0
- package/dist/config/model-registry.d.ts +69 -0
- package/dist/config/model-tester.d.ts +51 -0
- package/dist/config/model-utils.d.ts +44 -0
- package/dist/config/provider-ui-config.d.ts +6 -0
- package/dist/index.d.ts +23 -0
- package/dist/memory/agent-memory-manager.d.ts +125 -0
- package/dist/memory/example.d.ts +36 -0
- package/dist/memory/index.d.ts +18 -0
- package/dist/memory/mastra-integration.d.ts +146 -0
- package/dist/memory/storage/drizzle-storage.d.ts +82 -0
- package/dist/memory/storage/in-memory-storage.d.ts +75 -0
- package/dist/memory/storage/storage-interface.d.ts +37 -0
- package/dist/memory/types.d.ts +122 -0
- package/dist/models/providers.d.ts +5 -0
- package/dist/models/registry.d.ts +4 -0
- package/dist/models/types.d.ts +4 -0
- package/dist/research-agent.cjs.js +2 -0
- package/dist/research-agent.cjs.js.map +1 -0
- package/dist/research-agent.es.js +2 -0
- package/dist/research-agent.es.js.map +1 -0
- package/dist/search.d.ts +5 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/open-connector-mastra.d.ts +137 -0
- package/dist/tools/open-connector-mcp.d.ts +88 -0
- package/dist/tools/qwksearch-api-tools.d.ts +149 -0
- package/dist/tools/search/doc-utils.d.ts +11 -0
- package/dist/tools/search/document.d.ts +14 -0
- package/dist/tools/search/index.d.ts +12 -0
- package/dist/tools/search/link-summarizer.d.ts +7 -0
- package/dist/tools/search/meta-search-types.d.ts +50 -0
- package/dist/tools/search/metaSearchAgent.d.ts +21 -0
- package/dist/tools/search/search-handlers.d.ts +27 -0
- package/dist/tools/search/suggestionGeneratorAgent.d.ts +8 -0
- package/dist/types.d.ts +2 -0
- package/dist/utils/chat-helpers.d.ts +10 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/markdown-to-html.d.ts +5 -0
- package/dist/utils/outputParser.d.ts +22 -0
- package/dist/utils/provider-image-cropper.d.ts +120 -0
- package/package.json +16 -6
- package/src/config/config-manager.ts +0 -8
- package/src/config/environment-variables.ts +11 -3
- package/src/config/language-models-database.ts +50 -42
- package/src/config/model-registry.ts +20 -5
- package/src/config/model-tester.ts +2 -2
- package/src/connectors/{composio.json → open-connector.json} +21 -45
- package/src/index.ts +3 -0
- package/src/memory/ARCHITECTURE.md +1 -1
- package/src/memory/example.ts +6 -6
- package/src/memory/mastra-integration.ts +6 -11
- package/src/memory/storage/drizzle-storage.ts +60 -29
- package/src/memory/storage/in-memory-storage.ts +2 -2
- package/src/memory/storage/storage-interface.ts +1 -1
- package/src/models/types.ts +1 -1
- package/src/tools/{composio-mastra.ts → open-connector-mastra.ts} +58 -93
- package/src/tools/open-connector-mcp.ts +170 -0
- package/src/tools/search/doc-utils.ts +36 -8
- package/src/tools/search/metaSearchAgent.ts +11 -0
- package/src/tools/search/search-handlers.ts +13 -1
- package/src/tools/search/suggestionGeneratorAgent.ts +5 -3
- package/src/tools/composio-mcp.ts +0 -205
package/README.md
CHANGED
|
@@ -79,9 +79,9 @@ npm install ai-research-agent
|
|
|
79
79
|
## Quick start
|
|
80
80
|
|
|
81
81
|
```ts
|
|
82
|
-
import {
|
|
82
|
+
import { writeLanguageResponse } from "ai-research-agent";
|
|
83
83
|
|
|
84
|
-
const response = await
|
|
84
|
+
const response = await writeLanguageResponse({
|
|
85
85
|
provider: "groq",
|
|
86
86
|
apiKey: process.env.GROQ_API_KEY,
|
|
87
87
|
agent: "question",
|
|
@@ -96,9 +96,9 @@ console.log(response.content);
|
|
|
96
96
|
### Using Amazon Bedrock
|
|
97
97
|
|
|
98
98
|
```ts
|
|
99
|
-
import {
|
|
99
|
+
import { writeLanguageResponse } from "ai-research-agent";
|
|
100
100
|
|
|
101
|
-
const response = await
|
|
101
|
+
const response = await writeLanguageResponse({
|
|
102
102
|
provider: "amazon",
|
|
103
103
|
apiKey: process.env.AWS_BEARER_TOKEN_BEDROCK, // or "region:accessKeyId:secretAccessKey"
|
|
104
104
|
model: "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
@@ -177,7 +177,7 @@ src/
|
|
|
177
177
|
agents/ # prompt + tool registry, generate function, model list
|
|
178
178
|
agent-prompts.ts # AGENT_PROMPTS, extractJSONFromLanguageReply
|
|
179
179
|
agent-tools.ts # AGENT_TOOLS (web_search, extract_page, ...)
|
|
180
|
-
generate-language.ts #
|
|
180
|
+
generate-language.ts # writeLanguageResponse — main entry point
|
|
181
181
|
generate-language-types.ts
|
|
182
182
|
language-model-names.ts # LANGUAGE_MODELS, LANGUAGE_PROVIDERS
|
|
183
183
|
llm-providers.ts # createLLMProvider — chat-model factory
|
|
@@ -209,7 +209,7 @@ Vite bundles ES + CJS targets to `dist/`, emits `.d.ts` files alongside, and app
|
|
|
209
209
|
|
|
210
210
|
### Transformer Architecture Visualizations
|
|
211
211
|
|
|
212
|
-
<img src="https://i.imgur.com/uW6E9VJ.gif"
|
|
212
|
+
<img src="https://i.imgur.com/uW6E9VJ.gif" alt="Transformer architecture visualization" />
|
|
213
213
|
|
|
214
214
|
|
|
215
215
|
## Alternative Agents Frameworks
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ConfigModelProvider, Config, UIConfigSections } from './config-types';
|
|
2
|
+
declare class ConfigManager {
|
|
3
|
+
configVersion: number;
|
|
4
|
+
currentConfig: Config;
|
|
5
|
+
uiConfigSections: UIConfigSections;
|
|
6
|
+
private initialized;
|
|
7
|
+
constructor();
|
|
8
|
+
private ensureInitialized;
|
|
9
|
+
private initialize;
|
|
10
|
+
getConfig(key: string, defaultValue?: any): any;
|
|
11
|
+
updateConfig(key: string, val: any): void;
|
|
12
|
+
addModelProvider(type: string, name: string, config: any): ConfigModelProvider;
|
|
13
|
+
removeModelProvider(id: string): void;
|
|
14
|
+
updateModelProvider(id: string, name: string, config: any): Promise<ConfigModelProvider>;
|
|
15
|
+
addProviderModel(providerId: string, type: "chat", model: any): any;
|
|
16
|
+
removeProviderModel(providerId: string, type: "chat", modelKey: string): void;
|
|
17
|
+
isSetupComplete(): boolean;
|
|
18
|
+
markSetupComplete(): void;
|
|
19
|
+
getUIConfigSections(): UIConfigSections;
|
|
20
|
+
getCurrentConfig(): Config;
|
|
21
|
+
}
|
|
22
|
+
declare const configManager: ConfigManager;
|
|
23
|
+
export default configManager;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module research/models/types
|
|
3
|
+
* @description Shared types for the config system and model registry.
|
|
4
|
+
*/
|
|
5
|
+
/** A chat model entry as shown in provider model lists. */
|
|
6
|
+
export type Model = {
|
|
7
|
+
name: string;
|
|
8
|
+
key: string;
|
|
9
|
+
};
|
|
10
|
+
/** Provider shape consumed by model-selector UI components. */
|
|
11
|
+
export type MinimalProvider = {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
chatModels: Model[];
|
|
15
|
+
};
|
|
16
|
+
/** Client-side model selection: which provider and model key to use. */
|
|
17
|
+
export type ModelWithProvider = {
|
|
18
|
+
key?: string;
|
|
19
|
+
providerId?: string;
|
|
20
|
+
};
|
|
21
|
+
/** A configured model provider (env-based or user-added). */
|
|
22
|
+
export type ConfigModelProvider = {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
/** Provider type key, e.g. "openai", "anthropic", "gemini". */
|
|
26
|
+
type: string;
|
|
27
|
+
/** User-added chat models (defaults come from LANGUAGE_MODELS). */
|
|
28
|
+
chatModels: Model[];
|
|
29
|
+
/** Provider connection config, e.g. { apiKey, baseURL }. */
|
|
30
|
+
config: Record<string, any>;
|
|
31
|
+
/** Hash of the config, used as the provider id. */
|
|
32
|
+
hash: string;
|
|
33
|
+
/** True when the provider was configured from environment variables. */
|
|
34
|
+
isEnvBased?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type MCPServerConfig = {
|
|
37
|
+
command?: string;
|
|
38
|
+
args?: string[];
|
|
39
|
+
env?: Record<string, string>;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
};
|
|
42
|
+
export type Config = {
|
|
43
|
+
version: number;
|
|
44
|
+
setupComplete: boolean;
|
|
45
|
+
preferences: Record<string, any>;
|
|
46
|
+
personalization: Record<string, any>;
|
|
47
|
+
modelProviders: ConfigModelProvider[];
|
|
48
|
+
mcpServers: MCPServerConfig[];
|
|
49
|
+
search: Record<string, any>;
|
|
50
|
+
};
|
|
51
|
+
/** UI field/section definitions consumed by the settings screens. */
|
|
52
|
+
export type UIConfigSections = {
|
|
53
|
+
preferences: any[];
|
|
54
|
+
personalization: any[];
|
|
55
|
+
modelProviders: any[];
|
|
56
|
+
mcpServers: any[];
|
|
57
|
+
search: any[];
|
|
58
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Configuration Management Module
|
|
3
|
+
*
|
|
4
|
+
* Manages model providers, environment variables, and UI configuration
|
|
5
|
+
* for the AI agent toolkit. Provides in-memory config storage with
|
|
6
|
+
* support for multiple LLM providers and MCP servers.
|
|
7
|
+
*
|
|
8
|
+
* @module config
|
|
9
|
+
* @author ai-research-agent contributors
|
|
10
|
+
*/
|
|
11
|
+
export { default as configManager } from './config-manager';
|
|
12
|
+
export { default as ModelRegistry } from './model-registry';
|
|
13
|
+
export { getEnv } from './environment-variables';
|
|
14
|
+
export { LANGUAGE_MODELS } from './language-models-database';
|
|
15
|
+
export { getModelProvidersUIConfigSection } from './provider-ui-config';
|
|
16
|
+
export * from './model-tester';
|
|
17
|
+
export * from './model-utils';
|
|
18
|
+
export type { Config, ConfigModelProvider, MCPServerConfig, UIConfigSections, Model, ModelWithProvider, } from './config-types';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List of default models for the chat providers and a list of models
|
|
3
|
+
* @property {string} provider - The provider name
|
|
4
|
+
* @property {string} docs - The documentation URL for the model
|
|
5
|
+
* @property {string} api_key - The API key url for the model
|
|
6
|
+
* @property {string} default - The default model for the chat provider
|
|
7
|
+
* @property {Object[]} models - The list of models available for the chat provider
|
|
8
|
+
* @category Generate
|
|
9
|
+
*/
|
|
10
|
+
export declare const LANGUAGE_MODELS: ({
|
|
11
|
+
provider: string;
|
|
12
|
+
docs: string;
|
|
13
|
+
api_key: string;
|
|
14
|
+
default: string;
|
|
15
|
+
models: {
|
|
16
|
+
name: string;
|
|
17
|
+
id: string;
|
|
18
|
+
contextLength: number;
|
|
19
|
+
free: boolean;
|
|
20
|
+
type: string;
|
|
21
|
+
}[];
|
|
22
|
+
} | {
|
|
23
|
+
provider: string;
|
|
24
|
+
docs: string;
|
|
25
|
+
api_key: string;
|
|
26
|
+
default: string;
|
|
27
|
+
models: {
|
|
28
|
+
name: string;
|
|
29
|
+
id: string;
|
|
30
|
+
contextLength: number;
|
|
31
|
+
}[];
|
|
32
|
+
} | {
|
|
33
|
+
provider: string;
|
|
34
|
+
docs: string;
|
|
35
|
+
api_key: string;
|
|
36
|
+
default: string;
|
|
37
|
+
models: {
|
|
38
|
+
name: string;
|
|
39
|
+
id: string;
|
|
40
|
+
contextLength: number;
|
|
41
|
+
free: boolean;
|
|
42
|
+
type: string;
|
|
43
|
+
rateLimit: string;
|
|
44
|
+
}[];
|
|
45
|
+
} | {
|
|
46
|
+
provider: string;
|
|
47
|
+
docs: string;
|
|
48
|
+
api_key: string;
|
|
49
|
+
models: {
|
|
50
|
+
name: string;
|
|
51
|
+
id: string;
|
|
52
|
+
contextLength: number;
|
|
53
|
+
}[];
|
|
54
|
+
default?: undefined;
|
|
55
|
+
} | {
|
|
56
|
+
provider: string;
|
|
57
|
+
docs: string;
|
|
58
|
+
api_key: string;
|
|
59
|
+
default: string;
|
|
60
|
+
models: ({
|
|
61
|
+
name: string;
|
|
62
|
+
id: string;
|
|
63
|
+
contextLength: number;
|
|
64
|
+
provider: string;
|
|
65
|
+
type?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
name: string;
|
|
68
|
+
id: string;
|
|
69
|
+
contextLength: number;
|
|
70
|
+
provider: string;
|
|
71
|
+
type: string;
|
|
72
|
+
})[];
|
|
73
|
+
})[];
|
|
74
|
+
/** List of available LLM provider services */
|
|
75
|
+
export declare const LANGUAGE_PROVIDERS: string[];
|
|
76
|
+
/**
|
|
77
|
+
* Guest-safe models that are known to work reliably.
|
|
78
|
+
* Based on test results: only models with HTTP 200 status.
|
|
79
|
+
*/
|
|
80
|
+
export declare const GUEST_SAFE_MODELS: {
|
|
81
|
+
openrouter: string[];
|
|
82
|
+
nvidia: string[];
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Filter models to only those in the guest-safe list.
|
|
86
|
+
* Returns models with `free: true` property.
|
|
87
|
+
*/
|
|
88
|
+
export declare function filterModelsForGuests(models: any[]): any[];
|
|
89
|
+
/**
|
|
90
|
+
* Get guest-safe provider list (only tested working models).
|
|
91
|
+
* Uses GUEST_SAFE_MODELS whitelist to ensure reliability.
|
|
92
|
+
*/
|
|
93
|
+
export declare function getGuestSafeProviders(): typeof LANGUAGE_MODELS;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfigModelProvider } from './config-types';
|
|
2
|
+
export declare const getConfiguredModelProviders: () => ConfigModelProvider[];
|
|
3
|
+
export declare const getConfiguredModelProviderById: (id: string) => ConfigModelProvider | undefined;
|
|
4
|
+
export declare const getSearxngURL: () => any;
|
|
5
|
+
export declare const getTavilyApiKey: () => any;
|
|
6
|
+
export declare const getSourceScrapeCount: () => number;
|
|
7
|
+
export declare const getSourceScrapeTimeout: () => number;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ConfigModelProvider, Model } from './config-types';
|
|
2
|
+
export default class ModelRegistry {
|
|
3
|
+
/**
|
|
4
|
+
* Currently configured providers (env-based + user-added).
|
|
5
|
+
* Sync getter used by the chat handler for logging and lookups.
|
|
6
|
+
*/
|
|
7
|
+
get activeProviders(): ConfigModelProvider[];
|
|
8
|
+
/**
|
|
9
|
+
* Providers with their full chat model lists (defaults merged with
|
|
10
|
+
* user-added models), shaped for the settings/providers UI.
|
|
11
|
+
*/
|
|
12
|
+
getActiveProviders(guestMode?: boolean): Promise<{
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
type: string;
|
|
16
|
+
chatModels: Model[];
|
|
17
|
+
}[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Get guest-safe chat models for a provider (only tested working models).
|
|
20
|
+
*/
|
|
21
|
+
private getGuestChatModels;
|
|
22
|
+
/**
|
|
23
|
+
* Finds a provider by id, falling back to free providers in order:
|
|
24
|
+
* OpenRouter (no daily limits, best for guests), Groq (fastest, daily limits),
|
|
25
|
+
* then NVIDIA, then the first configured provider.
|
|
26
|
+
* Client-side provider ids are config hashes that go stale whenever
|
|
27
|
+
* server env config changes, so a graceful fallback keeps existing
|
|
28
|
+
* chat sessions working after a redeploy.
|
|
29
|
+
*/
|
|
30
|
+
private findProvider;
|
|
31
|
+
/** Whether the resolved provider was configured from environment variables. */
|
|
32
|
+
isProviderEnvBased(providerId?: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Instantiates a Vercel AI SDK language model for the given provider and
|
|
35
|
+
* model key. Falls back to the provider's first/default model when no key
|
|
36
|
+
* is given. Temperature is a per-call setting in the AI SDK, so callers
|
|
37
|
+
* pass it to generateText/streamText rather than the model instance.
|
|
38
|
+
*/
|
|
39
|
+
loadChatModel(providerId?: string, modelKey?: string): Promise<any>;
|
|
40
|
+
/**
|
|
41
|
+
* Registers a new provider. Accepts both `(type, config)` — used by the
|
|
42
|
+
* providers API route — and `(type, name, config)`.
|
|
43
|
+
*/
|
|
44
|
+
addProvider(type: string, nameOrConfig: any, config?: Record<string, any>): Promise<{
|
|
45
|
+
chatModels: Model[];
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
type: string;
|
|
49
|
+
config: Record<string, any>;
|
|
50
|
+
hash: string;
|
|
51
|
+
isEnvBased?: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
removeProvider(providerId: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Updates a provider's config. Accepts both `(id, config)` — used by the
|
|
56
|
+
* providers API route — and `(id, name, config)`.
|
|
57
|
+
*/
|
|
58
|
+
updateProvider(providerId: string, nameOrConfig: any, config?: Record<string, any>): Promise<{
|
|
59
|
+
chatModels: Model[];
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
type: string;
|
|
63
|
+
config: Record<string, any>;
|
|
64
|
+
hash: string;
|
|
65
|
+
isEnvBased?: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
addProviderModel(providerId: string, type: "chat", model: any): Promise<any>;
|
|
68
|
+
removeProviderModel(providerId: string, type: "chat", modelKey: string): Promise<void>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Model availability testing and validation
|
|
3
|
+
* Tests which models are actually working for a given provider
|
|
4
|
+
*/
|
|
5
|
+
export interface ModelTestResult {
|
|
6
|
+
modelId: string;
|
|
7
|
+
modelName: string;
|
|
8
|
+
available: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
latency?: number;
|
|
11
|
+
type?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ProviderTestResult {
|
|
14
|
+
provider: string;
|
|
15
|
+
totalModels: number;
|
|
16
|
+
availableModels: ModelTestResult[];
|
|
17
|
+
unavailableModels: ModelTestResult[];
|
|
18
|
+
testDuration: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Test a single model to see if it's working
|
|
22
|
+
*/
|
|
23
|
+
export declare function testModel(provider: string, apiKey: string, modelId: string, modelName: string, modelType?: string, timeout?: number): Promise<ModelTestResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Test all models for a provider
|
|
26
|
+
*/
|
|
27
|
+
export declare function testProviderModels(provider: string, apiKey: string, models: Array<{
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
type?: string;
|
|
31
|
+
free?: boolean;
|
|
32
|
+
}>, options?: {
|
|
33
|
+
onlyFree?: boolean;
|
|
34
|
+
concurrency?: number;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
onProgress?: (current: number, total: number, modelName: string) => void;
|
|
37
|
+
}): Promise<ProviderTestResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Get only free models from a model list
|
|
40
|
+
*/
|
|
41
|
+
export declare function getOnlyFreeModels<T extends {
|
|
42
|
+
free?: boolean;
|
|
43
|
+
}>(models: T[]): T[];
|
|
44
|
+
/**
|
|
45
|
+
* Categorize models by type
|
|
46
|
+
*/
|
|
47
|
+
export declare function categorizeModelsByType<T extends {
|
|
48
|
+
type?: string;
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
}>(models: T[]): Record<string, T[]>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for working with AI models
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* List of model IDs that are free to use (no per-token cost)
|
|
6
|
+
* Updated regularly as providers change their pricing
|
|
7
|
+
*/
|
|
8
|
+
export declare const FREE_MODELS: Set<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Providers that offer free tiers with generous limits
|
|
11
|
+
*/
|
|
12
|
+
export declare const FREE_TIER_PROVIDERS: Set<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a model is free to use (no per-token cost)
|
|
15
|
+
* Note: Free models may have rate limits
|
|
16
|
+
*/
|
|
17
|
+
export declare function isModelFree(modelId: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a provider offers a free tier
|
|
20
|
+
*/
|
|
21
|
+
export declare function hasFreeTier(providerType: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Get a display name for a model with cost indicator
|
|
24
|
+
* Example: "Llama 3.3 70B (Free)" or "GPT-4o"
|
|
25
|
+
*/
|
|
26
|
+
export declare function getModelDisplayName(modelName: string, modelId: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get provider-specific information
|
|
29
|
+
*/
|
|
30
|
+
export declare function getProviderInfo(providerType: string): {
|
|
31
|
+
name: string;
|
|
32
|
+
hasFreeTier: boolean;
|
|
33
|
+
signupUrl: string;
|
|
34
|
+
docsUrl: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Get recommended free providers for getting started
|
|
38
|
+
*/
|
|
39
|
+
export declare function getRecommendedFreeProviders(): Array<{
|
|
40
|
+
type: string;
|
|
41
|
+
name: string;
|
|
42
|
+
reason: string;
|
|
43
|
+
signupUrl: string;
|
|
44
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ModelProviderUISection } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Gets provider UI configuration without triggering circular dependencies.
|
|
4
|
+
* This function uses static metadata instead of importing provider classes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getModelProvidersUIConfigSection: () => ModelProviderUISection[];
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview AI Agent Toolkit
|
|
3
|
+
*
|
|
4
|
+
* Multi-provider AI agent toolkit for generating language responses, searching the web,
|
|
5
|
+
* extracting page content, and managing long-term memory across 10+ LLM providers.
|
|
6
|
+
*
|
|
7
|
+
* Built on Vercel AI SDK with prompt templates for research, summarization, citation
|
|
8
|
+
* answering, query resolution, and knowledge-graph extraction.
|
|
9
|
+
*
|
|
10
|
+
* @module ai-research-agent
|
|
11
|
+
* @author vtempest <grokthiscontact@gmail.com>
|
|
12
|
+
* @license AGPL-3.0
|
|
13
|
+
* @see {@link https://github.com/vtempest/ai-research-agent}
|
|
14
|
+
*/
|
|
15
|
+
export * from 'write-language';
|
|
16
|
+
export * from './memory';
|
|
17
|
+
export * from './tools';
|
|
18
|
+
export { AGENT_TOOLS } from './tools';
|
|
19
|
+
export * from './utils';
|
|
20
|
+
export { configManager, ModelRegistry, getEnv, getModelProvidersUIConfigSection } from './config';
|
|
21
|
+
export type { Config, ConfigModelProvider, MCPServerConfig, UIConfigSections, Model, ModelWithProvider } from './config';
|
|
22
|
+
export { cropProvider, cropProviderAsBlob, cropProviderAsDataURL, getProviderImage, getProviderNames } from './utils/provider-image-cropper';
|
|
23
|
+
export type { Provider } from './utils/provider-image-cropper';
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { IMemoryStorage } from './storage/storage-interface';
|
|
2
|
+
import { MemoryType, MemorySearchOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* LLM provider interface
|
|
5
|
+
*/
|
|
6
|
+
interface LLMProvider {
|
|
7
|
+
invoke: (prompt: string) => Promise<{
|
|
8
|
+
content: string;
|
|
9
|
+
tokensUsed: number;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Chat options
|
|
14
|
+
*/
|
|
15
|
+
interface ChatOptions {
|
|
16
|
+
provider?: string;
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
temperature?: number;
|
|
20
|
+
systemPrompt?: string;
|
|
21
|
+
includeHistory?: boolean;
|
|
22
|
+
maxMemories?: number;
|
|
23
|
+
minImportance?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Chat response
|
|
27
|
+
*/
|
|
28
|
+
interface ChatResponse {
|
|
29
|
+
content?: string;
|
|
30
|
+
memoryContext?: string;
|
|
31
|
+
success: boolean;
|
|
32
|
+
tokensUsed?: number;
|
|
33
|
+
responseTime?: number;
|
|
34
|
+
sessionId?: string;
|
|
35
|
+
timestamp: string;
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Rate limit configuration
|
|
40
|
+
*/
|
|
41
|
+
interface RateLimitConfig {
|
|
42
|
+
requests: number;
|
|
43
|
+
windowMs: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Agent options
|
|
47
|
+
*/
|
|
48
|
+
export interface MemoryAgentOptions {
|
|
49
|
+
memoryOptions?: any;
|
|
50
|
+
defaultProvider?: string;
|
|
51
|
+
defaultApiKey?: string;
|
|
52
|
+
defaultModel?: string;
|
|
53
|
+
rateLimit?: RateLimitConfig;
|
|
54
|
+
providers?: Record<string, (apiKey: string, model: string, temperature: number) => LLMProvider>;
|
|
55
|
+
}
|
|
56
|
+
export declare class MemoryAgent {
|
|
57
|
+
private memory;
|
|
58
|
+
private defaultProvider;
|
|
59
|
+
private defaultApiKey?;
|
|
60
|
+
private defaultModel?;
|
|
61
|
+
private rateLimiter;
|
|
62
|
+
private rateLimitConfig;
|
|
63
|
+
private providers;
|
|
64
|
+
private sessionId;
|
|
65
|
+
private conversationHistory;
|
|
66
|
+
private analytics;
|
|
67
|
+
private userId;
|
|
68
|
+
/**
|
|
69
|
+
* Initialize memory agent
|
|
70
|
+
*/
|
|
71
|
+
constructor(userId: string, storage: IMemoryStorage, options?: MemoryAgentOptions);
|
|
72
|
+
/**
|
|
73
|
+
* Get default LLM providers
|
|
74
|
+
*/
|
|
75
|
+
private getDefaultProviders;
|
|
76
|
+
/**
|
|
77
|
+
* Generate unique session ID
|
|
78
|
+
*/
|
|
79
|
+
private generateSessionId;
|
|
80
|
+
/**
|
|
81
|
+
* Rate limiting check with sliding window
|
|
82
|
+
*/
|
|
83
|
+
private checkRateLimit;
|
|
84
|
+
/**
|
|
85
|
+
* Main chat method with comprehensive error handling
|
|
86
|
+
*/
|
|
87
|
+
chat(message: string, options?: ChatOptions): Promise<ChatResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Generate LLM response with timeout and error handling
|
|
90
|
+
*/
|
|
91
|
+
private generateResponse;
|
|
92
|
+
/**
|
|
93
|
+
* Build enhanced prompt with context
|
|
94
|
+
*/
|
|
95
|
+
private buildPrompt;
|
|
96
|
+
/**
|
|
97
|
+
* Update analytics
|
|
98
|
+
*/
|
|
99
|
+
private updateAnalytics;
|
|
100
|
+
/**
|
|
101
|
+
* Remember a fact manually
|
|
102
|
+
*/
|
|
103
|
+
remember(fact: string, importance?: number, category?: MemoryType, metadata?: Record<string, any>): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Get memories with filtering
|
|
106
|
+
*/
|
|
107
|
+
getMemories(query?: string, limit?: number, options?: MemorySearchOptions): Promise<any[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Force store summary of current conversation
|
|
110
|
+
*/
|
|
111
|
+
forceStoreSummary(): Promise<boolean>;
|
|
112
|
+
/**
|
|
113
|
+
* Health check for the agent
|
|
114
|
+
*/
|
|
115
|
+
healthCheck(): Promise<any>;
|
|
116
|
+
/**
|
|
117
|
+
* Get analytics and performance metrics
|
|
118
|
+
*/
|
|
119
|
+
getAnalytics(): any;
|
|
120
|
+
/**
|
|
121
|
+
* Reset session and clear conversation history
|
|
122
|
+
*/
|
|
123
|
+
resetSession(): void;
|
|
124
|
+
}
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IMemoryStorage, MemoryRecord } from './index';
|
|
2
|
+
declare function example1_basicMemory(db: any, userMemoriesTable: any): Promise<void>;
|
|
3
|
+
declare function example2_memoryAgent(db: any, userMemoriesTable: any): Promise<void>;
|
|
4
|
+
/**
|
|
5
|
+
* Example custom storage implementation using in-memory Map
|
|
6
|
+
* In production, this could be Redis, MongoDB, etc.
|
|
7
|
+
*/
|
|
8
|
+
declare class InMemoryStorage implements IMemoryStorage {
|
|
9
|
+
private memories;
|
|
10
|
+
private idCounter;
|
|
11
|
+
insertMemory(userId: string, memoryType: any, content: string, importance: number, metadata?: Record<string, any>): Promise<string>;
|
|
12
|
+
findMemories(userId: string, query?: string, limit?: number, options?: any): Promise<MemoryRecord[]>;
|
|
13
|
+
findSimilarMemories(userId: string, content: string, limit?: number): Promise<MemoryRecord[]>;
|
|
14
|
+
updateMemory(id: string, updates: any): Promise<void>;
|
|
15
|
+
deleteMemory(id: string): Promise<void>;
|
|
16
|
+
getMemoryById(id: string): Promise<MemoryRecord | null>;
|
|
17
|
+
batchUpdateMemories(updates: Array<{
|
|
18
|
+
id: string;
|
|
19
|
+
updates: any;
|
|
20
|
+
}>): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
declare function example3_customStorage(): Promise<void>;
|
|
23
|
+
declare class MockStorage implements IMemoryStorage {
|
|
24
|
+
insertCalls: any[];
|
|
25
|
+
findCalls: any[];
|
|
26
|
+
insertMemory(...args: any[]): Promise<string>;
|
|
27
|
+
findMemories(...args: any[]): Promise<MemoryRecord[]>;
|
|
28
|
+
findSimilarMemories(): Promise<MemoryRecord[]>;
|
|
29
|
+
updateMemory(): Promise<void>;
|
|
30
|
+
deleteMemory(): Promise<void>;
|
|
31
|
+
getMemoryById(): Promise<MemoryRecord | null>;
|
|
32
|
+
batchUpdateMemories(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
declare function example4_testing(): Promise<void>;
|
|
35
|
+
declare function example5_batchOperations(db: any, userMemoriesTable: any): Promise<void>;
|
|
36
|
+
export { example1_basicMemory, example2_memoryAgent, example3_customStorage, example4_testing, example5_batchOperations, InMemoryStorage, MockStorage, };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Memory Management System
|
|
3
|
+
*
|
|
4
|
+
* Intelligent long-term memory for AI agents with persistent storage,
|
|
5
|
+
* vector-based relevance search, and automatic conversation summarization.
|
|
6
|
+
* Supports in-memory and Drizzle ORM-backed persistence.
|
|
7
|
+
*
|
|
8
|
+
* @module memory
|
|
9
|
+
* @author ai-research-agent contributors
|
|
10
|
+
*/
|
|
11
|
+
export { MemoryAgent } from './agent-memory-manager';
|
|
12
|
+
export type { MemoryAgentOptions } from './agent-memory-manager';
|
|
13
|
+
export { SimpleMemory } from './storage/in-memory-storage';
|
|
14
|
+
export { DrizzleMemoryStorage, createMemorySchema } from './storage/drizzle-storage';
|
|
15
|
+
export type { IMemoryStorage } from './storage/storage-interface';
|
|
16
|
+
export { MEMORY_CONFIG, MEMORY_TYPES, type MemoryType, type MemoryRecord, type Message, type MemorySearchOptions, type MemoryUpdate, type MemoryContextOptions, type MemoryMetrics, type MemoryOptions, type ExtractedFact, } from './types';
|
|
17
|
+
export { MastraMemoryManager, MastraD1MemoryStorage, MastraKVMemoryStorage, createMastraMemory, } from './mastra-integration';
|
|
18
|
+
export type { CloudflareEnv, MastraStorageBackend, MastraMemoryConfig, } from './mastra-integration';
|