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.
- package/dist/research-agent.cjs.js +1 -1
- package/dist/research-agent.cjs.js.map +1 -1
- package/dist/research-agent.es.js +1 -1
- package/dist/research-agent.es.js.map +1 -1
- package/package.json +1 -1
- package/src/config/config-manager.ts +295 -295
- package/src/config/config-types.ts +65 -65
- package/src/config/environment-variables.ts +16 -16
- package/src/config/index.ts +26 -26
- package/src/config/language-models-database.ts +1434 -1434
- package/src/config/mcp-server-registry.ts +24 -24
- package/src/config/model-registry.ts +271 -271
- package/src/config/model-tester.ts +211 -211
- package/src/config/model-utils.ts +193 -193
- package/src/config/provider-ui-config.ts +196 -196
- package/src/connectors/open-connector.json +130 -130
- package/src/index.ts +26 -26
- package/src/memory/ARCHITECTURE.md +302 -302
- package/src/memory/README.md +224 -224
- package/src/memory/agent-memory-manager.ts +416 -416
- package/src/memory/example.ts +343 -343
- package/src/memory/index.ts +47 -47
- package/src/memory/mastra-integration.ts +604 -604
- package/src/memory/storage/drizzle-storage.ts +236 -236
- package/src/memory/storage/in-memory-storage.ts +551 -551
- package/src/memory/storage/storage-interface.ts +68 -68
- package/src/memory/types.ts +125 -125
- package/src/models/types.ts +4 -4
- package/src/provider-logos/01-ai.png +0 -0
- package/src/provider-logos/anthropic.png +0 -0
- package/src/provider-logos/aws-bedrock.png +0 -0
- package/src/provider-logos/aws-sagemaker.png +0 -0
- package/src/provider-logos/azure-openai-service.png +0 -0
- package/src/provider-logos/chatglm.png +0 -0
- package/src/provider-logos/cohere.png +0 -0
- package/src/provider-logos/gemini.png +0 -0
- package/src/provider-logos/groqcloud.png +0 -0
- package/src/provider-logos/huggingface.png +0 -0
- package/src/provider-logos/jina.png +0 -0
- package/src/provider-logos/localai.png +0 -0
- package/src/provider-logos/mistral-ai.png +0 -0
- package/src/provider-logos/moonshot-ai.png +0 -0
- package/src/provider-logos/ollama.png +0 -0
- package/src/provider-logos/openai.png +0 -0
- package/src/provider-logos/openllm.png +0 -0
- package/src/provider-logos/openrouter.png +0 -0
- package/src/provider-logos/replicate.png +0 -0
- package/src/provider-logos/together-ai.png +0 -0
- package/src/provider-logos/tongyi.png +0 -0
- package/src/provider-logos/xorbits-inference.png +0 -0
- package/src/provider-logos/zhipu-ai.png +0 -0
- package/src/tools/index.ts +13 -13
- package/src/tools/open-connector-mastra.ts +270 -270
- package/src/tools/open-connector-mcp.ts +170 -170
- package/src/tools/qwksearch-api-tools.ts +326 -326
- package/src/tools/search/doc-utils.ts +139 -139
- package/src/tools/search/document.ts +47 -47
- package/src/tools/search/index.ts +14 -14
- package/src/tools/search/link-summarizer.ts +112 -112
- package/src/tools/search/meta-search-types.ts +62 -62
- package/src/tools/search/metaSearchAgent.ts +465 -465
- package/src/tools/search/search-handlers.ts +97 -97
- package/src/tools/search/suggestionGeneratorAgent.ts +56 -56
- package/src/types.d.ts +137 -137
- package/src/utils/index.ts +2 -2
- package/src/utils/markdown-to-html.ts +53 -53
- package/src/utils/outputParser.ts +73 -73
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage Interface
|
|
3
|
-
*
|
|
4
|
-
* Abstract interface for memory storage implementations.
|
|
5
|
-
* This allows swapping database backends without changing memory logic.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type {
|
|
9
|
-
MemoryRecord,
|
|
10
|
-
MemoryType,
|
|
11
|
-
MemorySearchOptions,
|
|
12
|
-
MemoryUpdate,
|
|
13
|
-
} from "../types";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Storage interface that any database adapter must implement
|
|
17
|
-
*/
|
|
18
|
-
export interface IMemoryStorage {
|
|
19
|
-
/**
|
|
20
|
-
* Insert a new memory record
|
|
21
|
-
*/
|
|
22
|
-
insertMemory(
|
|
23
|
-
userId: string,
|
|
24
|
-
memoryType: MemoryType,
|
|
25
|
-
content: string,
|
|
26
|
-
importance: number,
|
|
27
|
-
metadata?: Record<string, any>,
|
|
28
|
-
): Promise<string>;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Find memories by user ID and optional filters
|
|
32
|
-
*/
|
|
33
|
-
findMemories(
|
|
34
|
-
userId: string,
|
|
35
|
-
query?: string,
|
|
36
|
-
limit?: number,
|
|
37
|
-
options?: MemorySearchOptions,
|
|
38
|
-
): Promise<MemoryRecord[]>;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Find similar memories based on content
|
|
42
|
-
*/
|
|
43
|
-
findSimilarMemories(
|
|
44
|
-
userId: string,
|
|
45
|
-
content: string,
|
|
46
|
-
limit?: number,
|
|
47
|
-
): Promise<MemoryRecord[]>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Update a memory record
|
|
51
|
-
*/
|
|
52
|
-
updateMemory(id: string, updates: MemoryUpdate): Promise<void>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Delete a memory record
|
|
56
|
-
*/
|
|
57
|
-
deleteMemory(id: string): Promise<void>;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Get memory by ID
|
|
61
|
-
*/
|
|
62
|
-
getMemoryById(id: string): Promise<MemoryRecord | null>;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Batch update memories
|
|
66
|
-
*/
|
|
67
|
-
batchUpdateMemories(updates: Array<{ id: string; updates: MemoryUpdate }>): Promise<void>;
|
|
68
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Storage Interface
|
|
3
|
+
*
|
|
4
|
+
* Abstract interface for memory storage implementations.
|
|
5
|
+
* This allows swapping database backends without changing memory logic.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
MemoryRecord,
|
|
10
|
+
MemoryType,
|
|
11
|
+
MemorySearchOptions,
|
|
12
|
+
MemoryUpdate,
|
|
13
|
+
} from "../types";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Storage interface that any database adapter must implement
|
|
17
|
+
*/
|
|
18
|
+
export interface IMemoryStorage {
|
|
19
|
+
/**
|
|
20
|
+
* Insert a new memory record
|
|
21
|
+
*/
|
|
22
|
+
insertMemory(
|
|
23
|
+
userId: string,
|
|
24
|
+
memoryType: MemoryType,
|
|
25
|
+
content: string,
|
|
26
|
+
importance: number,
|
|
27
|
+
metadata?: Record<string, any>,
|
|
28
|
+
): Promise<string>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Find memories by user ID and optional filters
|
|
32
|
+
*/
|
|
33
|
+
findMemories(
|
|
34
|
+
userId: string,
|
|
35
|
+
query?: string,
|
|
36
|
+
limit?: number,
|
|
37
|
+
options?: MemorySearchOptions,
|
|
38
|
+
): Promise<MemoryRecord[]>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Find similar memories based on content
|
|
42
|
+
*/
|
|
43
|
+
findSimilarMemories(
|
|
44
|
+
userId: string,
|
|
45
|
+
content: string,
|
|
46
|
+
limit?: number,
|
|
47
|
+
): Promise<MemoryRecord[]>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Update a memory record
|
|
51
|
+
*/
|
|
52
|
+
updateMemory(id: string, updates: MemoryUpdate): Promise<void>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Delete a memory record
|
|
56
|
+
*/
|
|
57
|
+
deleteMemory(id: string): Promise<void>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get memory by ID
|
|
61
|
+
*/
|
|
62
|
+
getMemoryById(id: string): Promise<MemoryRecord | null>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Batch update memories
|
|
66
|
+
*/
|
|
67
|
+
batchUpdateMemories(updates: Array<{ id: string; updates: MemoryUpdate }>): Promise<void>;
|
|
68
|
+
}
|
package/src/memory/types.ts
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory System Types and Constants
|
|
3
|
-
*
|
|
4
|
-
* Defines interfaces and configuration for the memory management system
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Memory types for categorization
|
|
9
|
-
*/
|
|
10
|
-
export const MEMORY_TYPES = {
|
|
11
|
-
FACT: "fact",
|
|
12
|
-
CONVERSATION: "conversation",
|
|
13
|
-
PREFERENCE: "preference",
|
|
14
|
-
PERSONAL: "personal",
|
|
15
|
-
WORK: "work",
|
|
16
|
-
MANUAL: "manual",
|
|
17
|
-
} as const;
|
|
18
|
-
|
|
19
|
-
export type MemoryType = (typeof MEMORY_TYPES)[keyof typeof MEMORY_TYPES];
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Configuration constants for memory management
|
|
23
|
-
*/
|
|
24
|
-
export const MEMORY_CONFIG = {
|
|
25
|
-
DEFAULT_MAX_MEMORIES: 100,
|
|
26
|
-
DEFAULT_SUMMARY_THRESHOLD: 10,
|
|
27
|
-
DEFAULT_CACHE_EXPIRY: 5 * 60 * 1000, // 5 minutes
|
|
28
|
-
DEFAULT_BATCH_SIZE: 5,
|
|
29
|
-
DEFAULT_RELEVANCE_THRESHOLD: 0.3,
|
|
30
|
-
DEFAULT_IMPORTANCE_RANGE: { min: 0, max: 10 },
|
|
31
|
-
DEFAULT_RATE_LIMIT: { requests: 10, windowMs: 60000 },
|
|
32
|
-
DEFAULT_TIMEOUT: 30000, // 30 seconds
|
|
33
|
-
VECTOR_SEARCH_ENABLED: true,
|
|
34
|
-
AUTO_SUMMARIZATION_ENABLED: true,
|
|
35
|
-
} as const;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Memory record structure
|
|
39
|
-
*/
|
|
40
|
-
export interface MemoryRecord {
|
|
41
|
-
id: string;
|
|
42
|
-
user_id: string;
|
|
43
|
-
memory_type: MemoryType;
|
|
44
|
-
content: string;
|
|
45
|
-
importance: number;
|
|
46
|
-
access_count: number;
|
|
47
|
-
metadata?: Record<string, any>;
|
|
48
|
-
created_at: Date;
|
|
49
|
-
updated_at: Date;
|
|
50
|
-
relevance_score?: number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Message structure for conversation tracking
|
|
55
|
-
*/
|
|
56
|
-
export interface Message {
|
|
57
|
-
role: "user" | "assistant";
|
|
58
|
-
content: string;
|
|
59
|
-
timestamp: number;
|
|
60
|
-
metadata?: Record<string, any>;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Memory search options
|
|
65
|
-
*/
|
|
66
|
-
export interface MemorySearchOptions {
|
|
67
|
-
minImportance?: number;
|
|
68
|
-
memoryType?: MemoryType;
|
|
69
|
-
includeMetadata?: boolean;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Memory update payload
|
|
74
|
-
*/
|
|
75
|
-
export interface MemoryUpdate {
|
|
76
|
-
importance?: number;
|
|
77
|
-
access_count?: number | { increment: number };
|
|
78
|
-
updated_at?: Date;
|
|
79
|
-
metadata?: Record<string, any>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Memory context options
|
|
84
|
-
*/
|
|
85
|
-
export interface MemoryContextOptions {
|
|
86
|
-
maxMemories?: number;
|
|
87
|
-
minImportance?: number;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Performance metrics
|
|
92
|
-
*/
|
|
93
|
-
export interface MemoryMetrics {
|
|
94
|
-
cacheHits: number;
|
|
95
|
-
cacheMisses: number;
|
|
96
|
-
vectorSearches: number;
|
|
97
|
-
summarizations: number;
|
|
98
|
-
errors: number;
|
|
99
|
-
cacheSize: number;
|
|
100
|
-
recentMessagesCount: number;
|
|
101
|
-
isProcessing: boolean;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Memory initialization options
|
|
106
|
-
*/
|
|
107
|
-
export interface MemoryOptions {
|
|
108
|
-
maxMemories?: number;
|
|
109
|
-
summaryThreshold?: number;
|
|
110
|
-
cacheExpiry?: number;
|
|
111
|
-
batchSize?: number;
|
|
112
|
-
relevanceThreshold?: number;
|
|
113
|
-
enableVectorSearch?: boolean;
|
|
114
|
-
enableAutoSummarization?: boolean;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Extracted fact structure
|
|
119
|
-
*/
|
|
120
|
-
export interface ExtractedFact {
|
|
121
|
-
content: string;
|
|
122
|
-
importance?: number;
|
|
123
|
-
category?: MemoryType;
|
|
124
|
-
metadata?: Record<string, any>;
|
|
125
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Memory System Types and Constants
|
|
3
|
+
*
|
|
4
|
+
* Defines interfaces and configuration for the memory management system
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Memory types for categorization
|
|
9
|
+
*/
|
|
10
|
+
export const MEMORY_TYPES = {
|
|
11
|
+
FACT: "fact",
|
|
12
|
+
CONVERSATION: "conversation",
|
|
13
|
+
PREFERENCE: "preference",
|
|
14
|
+
PERSONAL: "personal",
|
|
15
|
+
WORK: "work",
|
|
16
|
+
MANUAL: "manual",
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
export type MemoryType = (typeof MEMORY_TYPES)[keyof typeof MEMORY_TYPES];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Configuration constants for memory management
|
|
23
|
+
*/
|
|
24
|
+
export const MEMORY_CONFIG = {
|
|
25
|
+
DEFAULT_MAX_MEMORIES: 100,
|
|
26
|
+
DEFAULT_SUMMARY_THRESHOLD: 10,
|
|
27
|
+
DEFAULT_CACHE_EXPIRY: 5 * 60 * 1000, // 5 minutes
|
|
28
|
+
DEFAULT_BATCH_SIZE: 5,
|
|
29
|
+
DEFAULT_RELEVANCE_THRESHOLD: 0.3,
|
|
30
|
+
DEFAULT_IMPORTANCE_RANGE: { min: 0, max: 10 },
|
|
31
|
+
DEFAULT_RATE_LIMIT: { requests: 10, windowMs: 60000 },
|
|
32
|
+
DEFAULT_TIMEOUT: 30000, // 30 seconds
|
|
33
|
+
VECTOR_SEARCH_ENABLED: true,
|
|
34
|
+
AUTO_SUMMARIZATION_ENABLED: true,
|
|
35
|
+
} as const;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Memory record structure
|
|
39
|
+
*/
|
|
40
|
+
export interface MemoryRecord {
|
|
41
|
+
id: string;
|
|
42
|
+
user_id: string;
|
|
43
|
+
memory_type: MemoryType;
|
|
44
|
+
content: string;
|
|
45
|
+
importance: number;
|
|
46
|
+
access_count: number;
|
|
47
|
+
metadata?: Record<string, any>;
|
|
48
|
+
created_at: Date;
|
|
49
|
+
updated_at: Date;
|
|
50
|
+
relevance_score?: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Message structure for conversation tracking
|
|
55
|
+
*/
|
|
56
|
+
export interface Message {
|
|
57
|
+
role: "user" | "assistant";
|
|
58
|
+
content: string;
|
|
59
|
+
timestamp: number;
|
|
60
|
+
metadata?: Record<string, any>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Memory search options
|
|
65
|
+
*/
|
|
66
|
+
export interface MemorySearchOptions {
|
|
67
|
+
minImportance?: number;
|
|
68
|
+
memoryType?: MemoryType;
|
|
69
|
+
includeMetadata?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Memory update payload
|
|
74
|
+
*/
|
|
75
|
+
export interface MemoryUpdate {
|
|
76
|
+
importance?: number;
|
|
77
|
+
access_count?: number | { increment: number };
|
|
78
|
+
updated_at?: Date;
|
|
79
|
+
metadata?: Record<string, any>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Memory context options
|
|
84
|
+
*/
|
|
85
|
+
export interface MemoryContextOptions {
|
|
86
|
+
maxMemories?: number;
|
|
87
|
+
minImportance?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Performance metrics
|
|
92
|
+
*/
|
|
93
|
+
export interface MemoryMetrics {
|
|
94
|
+
cacheHits: number;
|
|
95
|
+
cacheMisses: number;
|
|
96
|
+
vectorSearches: number;
|
|
97
|
+
summarizations: number;
|
|
98
|
+
errors: number;
|
|
99
|
+
cacheSize: number;
|
|
100
|
+
recentMessagesCount: number;
|
|
101
|
+
isProcessing: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Memory initialization options
|
|
106
|
+
*/
|
|
107
|
+
export interface MemoryOptions {
|
|
108
|
+
maxMemories?: number;
|
|
109
|
+
summaryThreshold?: number;
|
|
110
|
+
cacheExpiry?: number;
|
|
111
|
+
batchSize?: number;
|
|
112
|
+
relevanceThreshold?: number;
|
|
113
|
+
enableVectorSearch?: boolean;
|
|
114
|
+
enableAutoSummarization?: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Extracted fact structure
|
|
119
|
+
*/
|
|
120
|
+
export interface ExtractedFact {
|
|
121
|
+
content: string;
|
|
122
|
+
importance?: number;
|
|
123
|
+
category?: MemoryType;
|
|
124
|
+
metadata?: Record<string, any>;
|
|
125
|
+
}
|
package/src/models/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Re-export model types from config directory
|
|
3
|
-
*/
|
|
4
|
-
export type { Model, ConfigModelProvider, MinimalProvider } from "../config/config-types";
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Re-export model types from config directory
|
|
3
|
+
*/
|
|
4
|
+
export type { Model, ConfigModelProvider, MinimalProvider } from "../config/config-types";
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/tools/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Agent Tools Module
|
|
3
|
-
*
|
|
4
|
-
* Exports tool definitions for QwkSearch API integration including web search,
|
|
5
|
-
* content extraction, and AI response generation. Tools are automatically
|
|
6
|
-
* attached to agents when declared in prompt templates.
|
|
7
|
-
*
|
|
8
|
-
* @module tools
|
|
9
|
-
* @author ai-research-agent contributors
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export { AGENT_TOOLS } from "./qwksearch-api-tools";
|
|
13
|
-
export * from "./search";
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Agent Tools Module
|
|
3
|
+
*
|
|
4
|
+
* Exports tool definitions for QwkSearch API integration including web search,
|
|
5
|
+
* content extraction, and AI response generation. Tools are automatically
|
|
6
|
+
* attached to agents when declared in prompt templates.
|
|
7
|
+
*
|
|
8
|
+
* @module tools
|
|
9
|
+
* @author ai-research-agent contributors
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export { AGENT_TOOLS } from "./qwksearch-api-tools";
|
|
13
|
+
export * from "./search";
|