@agenticc/core 1.0.0
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/LICENSE +21 -0
- package/README.md +370 -0
- package/README.zh-CN.md +372 -0
- package/dist/audit/index.d.ts +9 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +9 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/logger.d.ts +211 -0
- package/dist/audit/logger.d.ts.map +1 -0
- package/dist/audit/logger.js +268 -0
- package/dist/audit/logger.js.map +1 -0
- package/dist/audit/query.d.ts +164 -0
- package/dist/audit/query.d.ts.map +1 -0
- package/dist/audit/query.js +250 -0
- package/dist/audit/query.js.map +1 -0
- package/dist/conversation/context-builder.d.ts +119 -0
- package/dist/conversation/context-builder.d.ts.map +1 -0
- package/dist/conversation/context-builder.js +252 -0
- package/dist/conversation/context-builder.js.map +1 -0
- package/dist/conversation/index.d.ts +10 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +10 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/message-store.d.ts +231 -0
- package/dist/conversation/message-store.d.ts.map +1 -0
- package/dist/conversation/message-store.js +404 -0
- package/dist/conversation/message-store.js.map +1 -0
- package/dist/conversation/session.d.ts +201 -0
- package/dist/conversation/session.d.ts.map +1 -0
- package/dist/conversation/session.js +285 -0
- package/dist/conversation/session.js.map +1 -0
- package/dist/core/agent.d.ts +277 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +674 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/agentic-loop.d.ts +98 -0
- package/dist/core/agentic-loop.d.ts.map +1 -0
- package/dist/core/agentic-loop.js +496 -0
- package/dist/core/agentic-loop.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +14 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/intent-parser.d.ts +101 -0
- package/dist/core/intent-parser.d.ts.map +1 -0
- package/dist/core/intent-parser.js +221 -0
- package/dist/core/intent-parser.js.map +1 -0
- package/dist/core/plan-generator.d.ts +133 -0
- package/dist/core/plan-generator.d.ts.map +1 -0
- package/dist/core/plan-generator.js +294 -0
- package/dist/core/plan-generator.js.map +1 -0
- package/dist/core/plugin-manager.d.ts +120 -0
- package/dist/core/plugin-manager.d.ts.map +1 -0
- package/dist/core/plugin-manager.js +369 -0
- package/dist/core/plugin-manager.js.map +1 -0
- package/dist/core/response-handler.d.ts +141 -0
- package/dist/core/response-handler.d.ts.map +1 -0
- package/dist/core/response-handler.js +384 -0
- package/dist/core/response-handler.js.map +1 -0
- package/dist/core/tool-executor.d.ts +143 -0
- package/dist/core/tool-executor.d.ts.map +1 -0
- package/dist/core/tool-executor.js +354 -0
- package/dist/core/tool-executor.js.map +1 -0
- package/dist/core/tool-registry.d.ts +133 -0
- package/dist/core/tool-registry.d.ts.map +1 -0
- package/dist/core/tool-registry.js +252 -0
- package/dist/core/tool-registry.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/chunker.d.ts +78 -0
- package/dist/knowledge/chunker.d.ts.map +1 -0
- package/dist/knowledge/chunker.js +233 -0
- package/dist/knowledge/chunker.js.map +1 -0
- package/dist/knowledge/embedder.d.ts +93 -0
- package/dist/knowledge/embedder.d.ts.map +1 -0
- package/dist/knowledge/embedder.js +205 -0
- package/dist/knowledge/embedder.js.map +1 -0
- package/dist/knowledge/index.d.ts +10 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +11 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/loaders/index.d.ts +10 -0
- package/dist/knowledge/loaders/index.d.ts.map +1 -0
- package/dist/knowledge/loaders/index.js +10 -0
- package/dist/knowledge/loaders/index.js.map +1 -0
- package/dist/knowledge/loaders/markdown.d.ts +88 -0
- package/dist/knowledge/loaders/markdown.d.ts.map +1 -0
- package/dist/knowledge/loaders/markdown.js +205 -0
- package/dist/knowledge/loaders/markdown.js.map +1 -0
- package/dist/knowledge/loaders/yaml.d.ts +112 -0
- package/dist/knowledge/loaders/yaml.d.ts.map +1 -0
- package/dist/knowledge/loaders/yaml.js +368 -0
- package/dist/knowledge/loaders/yaml.js.map +1 -0
- package/dist/knowledge/retriever.d.ts +144 -0
- package/dist/knowledge/retriever.d.ts.map +1 -0
- package/dist/knowledge/retriever.js +399 -0
- package/dist/knowledge/retriever.js.map +1 -0
- package/dist/knowledge/store.d.ts +146 -0
- package/dist/knowledge/store.d.ts.map +1 -0
- package/dist/knowledge/store.js +420 -0
- package/dist/knowledge/store.js.map +1 -0
- package/dist/llm/adapter.d.ts +194 -0
- package/dist/llm/adapter.d.ts.map +1 -0
- package/dist/llm/adapter.js +42 -0
- package/dist/llm/adapter.js.map +1 -0
- package/dist/llm/adapters/anyrouter.d.ts +84 -0
- package/dist/llm/adapters/anyrouter.d.ts.map +1 -0
- package/dist/llm/adapters/anyrouter.js +372 -0
- package/dist/llm/adapters/anyrouter.js.map +1 -0
- package/dist/llm/adapters/claude.d.ts +66 -0
- package/dist/llm/adapters/claude.d.ts.map +1 -0
- package/dist/llm/adapters/claude.js +323 -0
- package/dist/llm/adapters/claude.js.map +1 -0
- package/dist/llm/adapters/index.d.ts +12 -0
- package/dist/llm/adapters/index.d.ts.map +1 -0
- package/dist/llm/adapters/index.js +12 -0
- package/dist/llm/adapters/index.js.map +1 -0
- package/dist/llm/adapters/mimo.d.ts +85 -0
- package/dist/llm/adapters/mimo.d.ts.map +1 -0
- package/dist/llm/adapters/mimo.js +316 -0
- package/dist/llm/adapters/mimo.js.map +1 -0
- package/dist/llm/adapters/openai.d.ts +53 -0
- package/dist/llm/adapters/openai.d.ts.map +1 -0
- package/dist/llm/adapters/openai.js +293 -0
- package/dist/llm/adapters/openai.js.map +1 -0
- package/dist/llm/adapters/qwen.d.ts +53 -0
- package/dist/llm/adapters/qwen.d.ts.map +1 -0
- package/dist/llm/adapters/qwen.js +299 -0
- package/dist/llm/adapters/qwen.js.map +1 -0
- package/dist/llm/adapters/siliconflow.d.ts +69 -0
- package/dist/llm/adapters/siliconflow.d.ts.map +1 -0
- package/dist/llm/adapters/siliconflow.js +331 -0
- package/dist/llm/adapters/siliconflow.js.map +1 -0
- package/dist/llm/index.d.ts +9 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +12 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/manager.d.ts +97 -0
- package/dist/llm/manager.d.ts.map +1 -0
- package/dist/llm/manager.js +337 -0
- package/dist/llm/manager.js.map +1 -0
- package/dist/test-utils/arbitraries.d.ts +230 -0
- package/dist/test-utils/arbitraries.d.ts.map +1 -0
- package/dist/test-utils/arbitraries.js +280 -0
- package/dist/test-utils/arbitraries.js.map +1 -0
- package/dist/test-utils/cleanup.d.ts +184 -0
- package/dist/test-utils/cleanup.d.ts.map +1 -0
- package/dist/test-utils/cleanup.js +282 -0
- package/dist/test-utils/cleanup.js.map +1 -0
- package/dist/test-utils/config.d.ts +80 -0
- package/dist/test-utils/config.d.ts.map +1 -0
- package/dist/test-utils/config.js +94 -0
- package/dist/test-utils/config.js.map +1 -0
- package/dist/test-utils/index.d.ts +10 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +36 -0
- package/dist/test-utils/index.js.map +1 -0
- package/dist/test-utils/mocks.d.ts +170 -0
- package/dist/test-utils/mocks.d.ts.map +1 -0
- package/dist/test-utils/mocks.js +281 -0
- package/dist/test-utils/mocks.js.map +1 -0
- package/dist/types/config.d.ts +170 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +120 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/knowledge.d.ts +95 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +7 -0
- package/dist/types/knowledge.js.map +1 -0
- package/dist/types/loop.d.ts +148 -0
- package/dist/types/loop.d.ts.map +1 -0
- package/dist/types/loop.js +16 -0
- package/dist/types/loop.js.map +1 -0
- package/dist/types/plugin.d.ts +137 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +15 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/types/response.d.ts +186 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/response.js +99 -0
- package/dist/types/response.js.map +1 -0
- package/dist/types/streaming.d.ts +478 -0
- package/dist/types/streaming.d.ts.map +1 -0
- package/dist/types/streaming.js +483 -0
- package/dist/types/streaming.js.map +1 -0
- package/dist/types/tool.d.ts +118 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/tool.js +42 -0
- package/dist/types/tool.js.map +1 -0
- package/dist/utils/error.d.ts +22 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +36 -0
- package/dist/utils/error.js.map +1 -0
- package/package.json +102 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AI Agent Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
# Agentic
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@agenticc/core)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://github.com/Chajian/agentic/actions)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
|
|
9
|
+
English | [简体中文](./README.zh-CN.md)
|
|
10
|
+
|
|
11
|
+
An intelligent AI Agent framework with LLM support, ReAct pattern execution, RAG knowledge retrieval, and extensible tool system.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- 🤖 **Multi-LLM Support**: OpenAI, Anthropic Claude, Google Gemini
|
|
16
|
+
- 🔧 **Tool Calling System**: Built-in ReAct pattern for autonomous reasoning
|
|
17
|
+
- 📚 **RAG Knowledge Base**: Semantic search and document retrieval
|
|
18
|
+
- 💬 **Stateless Architecture**: Flexible conversation management
|
|
19
|
+
- 📝 **Audit Logging**: Complete operation tracking
|
|
20
|
+
- 🔌 **Plugin System**: Extensible architecture for custom tools
|
|
21
|
+
- ⚡ **Streaming Support**: Real-time response streaming
|
|
22
|
+
- 🎯 **Intent Parsing**: Intelligent request interpretation
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @agenticc/core
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { Agent, ToolRegistry } from '@ai-agent/core';
|
|
34
|
+
|
|
35
|
+
// Initialize agent with OpenAI
|
|
36
|
+
const agent = new Agent({
|
|
37
|
+
llm: {
|
|
38
|
+
provider: 'openai',
|
|
39
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
40
|
+
model: 'gpt-4',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Define a tool
|
|
45
|
+
agent.tools.register({
|
|
46
|
+
name: 'get_weather',
|
|
47
|
+
description: 'Get weather information for a location',
|
|
48
|
+
parameters: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
location: { type: 'string' },
|
|
52
|
+
},
|
|
53
|
+
required: ['location'],
|
|
54
|
+
},
|
|
55
|
+
execute: async (params) => {
|
|
56
|
+
// Implement your tool logic
|
|
57
|
+
return `Weather for ${params.location}: ...`;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Use the agent (stateless - pass history from your storage)
|
|
62
|
+
const response = await agent.chat('What is the weather in New York?', {
|
|
63
|
+
history: [], // Load from your database
|
|
64
|
+
});
|
|
65
|
+
console.log(response);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Configuration
|
|
69
|
+
|
|
70
|
+
### LLM Providers
|
|
71
|
+
|
|
72
|
+
#### OpenAI
|
|
73
|
+
```typescript
|
|
74
|
+
new Agent({
|
|
75
|
+
llm: {
|
|
76
|
+
provider: 'openai',
|
|
77
|
+
apiKey: 'sk-...',
|
|
78
|
+
model: 'gpt-4',
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### Anthropic Claude
|
|
84
|
+
```typescript
|
|
85
|
+
new Agent({
|
|
86
|
+
llm: {
|
|
87
|
+
provider: 'anthropic',
|
|
88
|
+
apiKey: 'sk-ant-...',
|
|
89
|
+
model: 'claude-3-opus-20240229',
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Google Gemini
|
|
95
|
+
```typescript
|
|
96
|
+
new Agent({
|
|
97
|
+
llm: {
|
|
98
|
+
provider: 'openai', // Use OpenAI adapter for Gemini API compatibility
|
|
99
|
+
apiKey: process.env.GEMINI_API_KEY,
|
|
100
|
+
model: 'gemini-pro',
|
|
101
|
+
baseURL: 'https://generativelanguage.googleapis.com/v1beta/openai/',
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Tool Registry
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// Register a tool
|
|
110
|
+
agent.tools.register({
|
|
111
|
+
name: 'tool_name',
|
|
112
|
+
description: 'Tool description',
|
|
113
|
+
parameters: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
param1: { type: 'string' },
|
|
117
|
+
param2: { type: 'number' },
|
|
118
|
+
},
|
|
119
|
+
required: ['param1'],
|
|
120
|
+
},
|
|
121
|
+
riskLevel: 'low' | 'medium' | 'high',
|
|
122
|
+
execute: async (params, context) => {
|
|
123
|
+
// Implementation
|
|
124
|
+
return result;
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Get registered tools
|
|
129
|
+
const tools = agent.tools.getAll();
|
|
130
|
+
|
|
131
|
+
// Deregister a tool
|
|
132
|
+
agent.tools.deregister('tool_name');
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Plugin System
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// Create a plugin
|
|
139
|
+
const myPlugin = {
|
|
140
|
+
name: 'my-plugin',
|
|
141
|
+
version: '1.0.0',
|
|
142
|
+
tools: [/* array of tools */],
|
|
143
|
+
initialize: async (context) => {
|
|
144
|
+
console.log('Plugin initialized');
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// Load plugin
|
|
149
|
+
agent.plugins.load(myPlugin);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Stateless Conversation Management
|
|
153
|
+
|
|
154
|
+
The agent is stateless - you manage conversation history externally:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
// Load history from your database
|
|
158
|
+
const history = await db.messages.findMany({
|
|
159
|
+
where: { sessionId: 'session-123' }
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Pass history to agent
|
|
163
|
+
const response = await agent.chat(
|
|
164
|
+
'How can I optimize my code?',
|
|
165
|
+
{
|
|
166
|
+
sessionId: 'session-123',
|
|
167
|
+
history: history, // Pass loaded history
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
// Save response to your database
|
|
172
|
+
await db.messages.create({
|
|
173
|
+
data: {
|
|
174
|
+
sessionId: 'session-123',
|
|
175
|
+
role: 'assistant',
|
|
176
|
+
content: response.content,
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
For convenience, use optional storage helpers:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { MemoryStorage } from '@ai-agent/storage-memory';
|
|
185
|
+
|
|
186
|
+
const storage = new MemoryStorage();
|
|
187
|
+
|
|
188
|
+
// Save and load history
|
|
189
|
+
await storage.saveMessage(sessionId, message);
|
|
190
|
+
const history = await storage.getHistory(sessionId);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### RAG Knowledge Base
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import { KnowledgeStore, MarkdownLoader } from '@ai-agent/core';
|
|
197
|
+
|
|
198
|
+
// Create knowledge store
|
|
199
|
+
const knowledge = new KnowledgeStore();
|
|
200
|
+
|
|
201
|
+
// Load documents
|
|
202
|
+
const loader = new MarkdownLoader();
|
|
203
|
+
const docs = await loader.load('path/to/docs');
|
|
204
|
+
await knowledge.addDocuments(docs);
|
|
205
|
+
|
|
206
|
+
// Search knowledge
|
|
207
|
+
const results = await knowledge.search('query', { limit: 5 });
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Audit Logging
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
// Audit logs are automatically recorded
|
|
214
|
+
const logs = await agent.audit.query({
|
|
215
|
+
startDate: new Date('2024-01-01'),
|
|
216
|
+
endDate: new Date('2024-12-31'),
|
|
217
|
+
operation: 'chat',
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
console.log(logs);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Advanced Usage
|
|
224
|
+
|
|
225
|
+
### Custom LLM Integration
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
// Extend LLMProvider for custom LLM
|
|
229
|
+
class CustomLLM extends LLMProvider {
|
|
230
|
+
async generate(messages, options) {
|
|
231
|
+
// Custom implementation
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const agent = new Agent({
|
|
236
|
+
llm: new CustomLLM(config),
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Streaming Responses
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
const stream = await agent.chatStream('Tell me a story', {
|
|
244
|
+
onChunk: (chunk) => {
|
|
245
|
+
console.log('Received:', chunk);
|
|
246
|
+
},
|
|
247
|
+
onToolCall: (toolCall) => {
|
|
248
|
+
console.log('Tool called:', toolCall.name);
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Intent-Based Routing
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
const intent = await agent.parseIntent('Create a new user account');
|
|
257
|
+
// intent.type => 'create'
|
|
258
|
+
// intent.entity => 'user'
|
|
259
|
+
// intent.confidence => 0.95
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Examples
|
|
263
|
+
|
|
264
|
+
### Custom Plugin Example
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
import { Agent, PluginManager } from '@ai-agent/core';
|
|
268
|
+
|
|
269
|
+
const agent = new Agent(config);
|
|
270
|
+
|
|
271
|
+
// Create and load a custom plugin
|
|
272
|
+
const customPlugin = {
|
|
273
|
+
name: 'custom-tools',
|
|
274
|
+
version: '1.0.0',
|
|
275
|
+
tools: [
|
|
276
|
+
{
|
|
277
|
+
name: 'calculate',
|
|
278
|
+
description: 'Perform calculations',
|
|
279
|
+
parameters: { /* ... */ },
|
|
280
|
+
execute: async (params) => { /* ... */ }
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
agent.plugins.load(customPlugin);
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Q&A Bot with Knowledge Base
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
const agent = new Agent(config);
|
|
292
|
+
|
|
293
|
+
// Load knowledge
|
|
294
|
+
const knowledge = new KnowledgeStore();
|
|
295
|
+
await knowledge.addDocuments(documents);
|
|
296
|
+
|
|
297
|
+
// Answer questions
|
|
298
|
+
const answer = await agent.chat(
|
|
299
|
+
'What are the main features?',
|
|
300
|
+
{ knowledge }
|
|
301
|
+
);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## API Reference
|
|
305
|
+
|
|
306
|
+
See the [Full API Documentation](./docs/api.md) for detailed information.
|
|
307
|
+
|
|
308
|
+
## Development & Release
|
|
309
|
+
|
|
310
|
+
### CI/CD Pipeline
|
|
311
|
+
|
|
312
|
+
This project uses automated CI/CD with semantic-release for versioning and publishing:
|
|
313
|
+
|
|
314
|
+
- **Automated Testing**: All PRs run comprehensive tests (unit, property-based, integration)
|
|
315
|
+
- **Semantic Versioning**: Version bumps based on conventional commits
|
|
316
|
+
- **Automated Publishing**: Releases to npm on merge to main
|
|
317
|
+
- **Changelog Generation**: Automatic changelog from commit messages
|
|
318
|
+
|
|
319
|
+
See [CI/CD Documentation](./.github/CICD.md) for detailed information.
|
|
320
|
+
|
|
321
|
+
### Release Process
|
|
322
|
+
|
|
323
|
+
We use [semantic-release](https://github.com/semantic-release/semantic-release) with [Conventional Commits](https://www.conventionalcommits.org/):
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Feature (minor version bump)
|
|
327
|
+
git commit -m "feat: add new feature"
|
|
328
|
+
|
|
329
|
+
# Bug fix (patch version bump)
|
|
330
|
+
git commit -m "fix: resolve issue"
|
|
331
|
+
|
|
332
|
+
# Breaking change (major version bump)
|
|
333
|
+
git commit -m "feat!: breaking change"
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
See [Release Guide](./.github/RELEASE_GUIDE.md) for complete instructions.
|
|
337
|
+
|
|
338
|
+
## Contributing
|
|
339
|
+
|
|
340
|
+
We welcome contributions! Please read our [Contributing Guide](./CONTRIBUTING.md).
|
|
341
|
+
|
|
342
|
+
### Quick Start for Contributors
|
|
343
|
+
|
|
344
|
+
1. Fork and clone the repository
|
|
345
|
+
2. Install dependencies: `npm install`
|
|
346
|
+
3. Run tests: `npm test`
|
|
347
|
+
4. Make your changes following conventional commits
|
|
348
|
+
5. Submit a pull request
|
|
349
|
+
|
|
350
|
+
All PRs must pass:
|
|
351
|
+
- ✅ Type checking
|
|
352
|
+
- ✅ Unit tests
|
|
353
|
+
- ✅ Property-based tests
|
|
354
|
+
- ✅ Build verification
|
|
355
|
+
|
|
356
|
+
## License
|
|
357
|
+
|
|
358
|
+
MIT License - see LICENSE file for details.
|
|
359
|
+
|
|
360
|
+
## Support
|
|
361
|
+
|
|
362
|
+
- 📖 [Documentation](https://ai-agent-framework.dev)
|
|
363
|
+
- 🐛 [Issue Tracker](https://github.com/ai-agent-framework/core/issues)
|
|
364
|
+
- 💬 [Discussions](https://github.com/ai-agent-framework/core/discussions)
|
|
365
|
+
- 🚀 [Release Guide](./.github/RELEASE_GUIDE.md)
|
|
366
|
+
- 🔧 [CI/CD Documentation](./.github/CICD.md)
|
|
367
|
+
|
|
368
|
+
## Changelog
|
|
369
|
+
|
|
370
|
+
See [CHANGELOG.md](./CHANGELOG.md) for version history.
|