@ai.ntellect/core 0.3.3 → 0.4.1
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/.nvmrc +1 -0
- package/README.FR.md +242 -247
- package/README.md +249 -246
- package/agent/index.ts +199 -215
- package/agent/tools/get-rss.ts +64 -0
- package/bull.ts +5 -0
- package/dist/agent/index.d.ts +29 -26
- package/dist/agent/index.js +123 -112
- package/dist/agent/tools/get-rss.d.ts +16 -0
- package/dist/agent/tools/get-rss.js +62 -0
- package/dist/bull.d.ts +1 -0
- package/dist/bull.js +9 -0
- package/dist/examples/index.d.ts +2 -0
- package/dist/examples/index.js +89 -0
- package/dist/llm/interpreter/context.d.ts +5 -22
- package/dist/llm/interpreter/context.js +8 -9
- package/dist/llm/interpreter/index.d.ts +9 -5
- package/dist/llm/interpreter/index.js +55 -48
- package/dist/llm/memory-manager/context.d.ts +2 -0
- package/dist/llm/memory-manager/context.js +22 -0
- package/dist/llm/memory-manager/index.d.ts +17 -0
- package/dist/llm/memory-manager/index.js +107 -0
- package/dist/llm/orchestrator/context.d.ts +2 -10
- package/dist/llm/orchestrator/context.js +19 -14
- package/dist/llm/orchestrator/index.d.ts +36 -21
- package/dist/llm/orchestrator/index.js +122 -88
- package/dist/llm/orchestrator/types.d.ts +12 -0
- package/dist/llm/orchestrator/types.js +2 -0
- package/dist/memory/cache.d.ts +6 -5
- package/dist/memory/cache.js +31 -21
- package/dist/memory/persistent.d.ts +5 -3
- package/dist/memory/persistent.js +89 -73
- package/dist/services/redis-cache.d.ts +37 -0
- package/dist/services/redis-cache.js +93 -0
- package/dist/services/scheduler.d.ts +39 -16
- package/dist/services/scheduler.js +81 -103
- package/dist/services/telegram-monitor.d.ts +0 -15
- package/dist/services/telegram-monitor.js +117 -101
- package/dist/test.js +106 -172
- package/dist/types.d.ts +38 -7
- package/dist/utils/generate-object.d.ts +12 -0
- package/dist/utils/generate-object.js +90 -0
- package/dist/utils/header-builder.d.ts +11 -0
- package/dist/utils/header-builder.js +34 -0
- package/dist/utils/inject-actions.js +2 -2
- package/dist/utils/queue-item-transformer.d.ts +2 -2
- package/dist/utils/schema-generator.d.ts +16 -0
- package/dist/utils/schema-generator.js +46 -0
- package/examples/index.ts +103 -0
- package/llm/interpreter/context.ts +20 -8
- package/llm/interpreter/index.ts +81 -54
- package/llm/memory-manager/context.ts +21 -0
- package/llm/memory-manager/index.ts +163 -0
- package/llm/orchestrator/context.ts +20 -13
- package/llm/orchestrator/index.ts +210 -130
- package/llm/orchestrator/types.ts +14 -0
- package/memory/cache.ts +37 -31
- package/memory/persistent.ts +121 -99
- package/package.json +11 -2
- package/services/redis-cache.ts +128 -0
- package/services/scheduler.ts +102 -141
- package/services/telegram-monitor.ts +138 -138
- package/t.py +79 -0
- package/t.spec +38 -0
- package/types.ts +40 -7
- package/utils/generate-object.ts +105 -0
- package/utils/header-builder.ts +40 -0
- package/utils/inject-actions.ts +4 -6
- package/utils/queue-item-transformer.ts +2 -1
- package/utils/schema-generator.ts +73 -0
- package/agent/handlers/ActionHandler.ts +0 -48
- package/agent/handlers/ConfirmationHandler.ts +0 -37
- package/agent/handlers/EventHandler.ts +0 -35
- package/dist/agent/handlers/ActionHandler.d.ts +0 -8
- package/dist/agent/handlers/ActionHandler.js +0 -36
- package/dist/agent/handlers/ConfirmationHandler.d.ts +0 -7
- package/dist/agent/handlers/ConfirmationHandler.js +0 -31
- package/dist/agent/handlers/EventHandler.d.ts +0 -10
- package/dist/agent/handlers/EventHandler.js +0 -34
- package/dist/llm/evaluator/context.d.ts +0 -10
- package/dist/llm/evaluator/context.js +0 -24
- package/dist/llm/evaluator/index.d.ts +0 -16
- package/dist/llm/evaluator/index.js +0 -150
- package/llm/evaluator/context.ts +0 -21
- package/llm/evaluator/index.ts +0 -193
package/agent/index.ts
CHANGED
@@ -1,260 +1,244 @@
|
|
1
|
-
import {
|
1
|
+
import { LanguageModel } from "ai";
|
2
|
+
import WebSocket from "ws";
|
2
3
|
import { Interpreter } from "../llm/interpreter";
|
3
|
-
import {
|
4
|
+
import { MemoryManager } from "../llm/memory-manager";
|
5
|
+
import { AgentRuntime } from "../llm/orchestrator";
|
6
|
+
import { State } from "../llm/orchestrator/types";
|
4
7
|
import { CacheMemory } from "../memory/cache";
|
5
8
|
import { PersistentMemory } from "../memory/persistent";
|
6
9
|
import { ActionQueueManager } from "../services/queue";
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
ActionSchema,
|
10
|
-
AgentEvent,
|
11
|
-
MemoryScope,
|
12
|
-
QueueResult,
|
13
|
-
ScheduledAction,
|
14
|
-
} from "../types";
|
10
|
+
import { CacheConfig, RedisCache } from "../services/redis-cache";
|
11
|
+
import { ActionData, ActionSchema, QueueCallbacks } from "../types";
|
15
12
|
import { QueueItemTransformer } from "../utils/queue-item-transformer";
|
16
|
-
import { ResultSanitizer } from "../utils/sanitize-results";
|
17
|
-
import { ActionHandler } from "./handlers/ActionHandler";
|
18
13
|
|
19
14
|
export class Agent {
|
20
|
-
private readonly
|
21
|
-
private readonly
|
22
|
-
private readonly
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
private readonly agent: AgentRuntime;
|
16
|
+
private readonly memoryManager: MemoryManager;
|
17
|
+
private readonly cache: RedisCache;
|
18
|
+
|
19
|
+
private listeners: Map<
|
20
|
+
string,
|
21
|
+
{ socket: WebSocket; callback: (data: any) => Promise<void> }
|
22
|
+
> = new Map();
|
23
|
+
private readonly config: {
|
24
|
+
orchestrator: {
|
25
|
+
model: LanguageModel;
|
26
|
+
tools: ActionSchema[];
|
27
|
+
memory?: {
|
28
|
+
cache?: CacheMemory;
|
29
|
+
persistent?: PersistentMemory;
|
30
|
+
};
|
31
|
+
};
|
32
|
+
interpreters: Interpreter[];
|
33
|
+
memoryManager: {
|
34
|
+
model: LanguageModel;
|
35
|
+
memory?: {
|
36
|
+
cache?: CacheMemory;
|
37
|
+
persistent?: PersistentMemory;
|
38
|
+
};
|
39
|
+
};
|
40
|
+
maxIterations: number;
|
26
41
|
};
|
27
|
-
private readonly stream: boolean;
|
28
|
-
private readonly maxEvaluatorIteration: number;
|
29
|
-
private evaluatorIteration = 0;
|
30
|
-
private accumulatedResults: string = "";
|
31
|
-
private currentInterpreter: Interpreter | undefined;
|
32
|
-
private readonly scheduler: ActionScheduler;
|
33
42
|
|
34
|
-
constructor({
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
43
|
+
constructor(config: {
|
44
|
+
cache: CacheConfig;
|
45
|
+
orchestrator: {
|
46
|
+
model: LanguageModel;
|
47
|
+
tools: ActionSchema[];
|
48
|
+
memory?: {
|
49
|
+
cache?: CacheMemory;
|
50
|
+
persistent?: PersistentMemory;
|
51
|
+
};
|
52
|
+
};
|
42
53
|
interpreters: Interpreter[];
|
43
|
-
|
44
|
-
|
45
|
-
|
54
|
+
memoryManager: {
|
55
|
+
model: LanguageModel;
|
56
|
+
memory?: {
|
57
|
+
cache?: CacheMemory;
|
58
|
+
persistent?: PersistentMemory;
|
59
|
+
};
|
46
60
|
};
|
47
|
-
|
48
|
-
|
61
|
+
callbacks?: QueueCallbacks;
|
62
|
+
maxIterations: number;
|
49
63
|
}) {
|
50
|
-
this.
|
51
|
-
this.
|
52
|
-
this.
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
new ActionQueueManager(this.orchestrator.tools),
|
59
|
-
this.orchestrator
|
64
|
+
this.cache = new RedisCache(config.cache);
|
65
|
+
this.config = config;
|
66
|
+
this.agent = new AgentRuntime(
|
67
|
+
config.orchestrator.model,
|
68
|
+
config.orchestrator.tools,
|
69
|
+
config.interpreters,
|
70
|
+
config.cache,
|
71
|
+
config.orchestrator.memory
|
60
72
|
);
|
73
|
+
this.memoryManager = new MemoryManager({
|
74
|
+
model: config.memoryManager.model,
|
75
|
+
memory: {
|
76
|
+
cache: config.memoryManager.memory?.cache ?? undefined,
|
77
|
+
persistent: config.memoryManager.memory?.persistent ?? undefined,
|
78
|
+
},
|
79
|
+
});
|
80
|
+
this.config.maxIterations = 3;
|
61
81
|
}
|
62
82
|
|
63
|
-
async process(
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
const
|
68
|
-
const promptOnly = parsedPrompt.userRequest;
|
69
|
-
const cacheMemories = await this.memory.cache?.findSimilarActions(
|
70
|
-
promptOnly,
|
71
|
-
{
|
72
|
-
similarityThreshold: 70,
|
73
|
-
maxResults: 5,
|
74
|
-
userId: "1",
|
75
|
-
scope: MemoryScope.GLOBAL,
|
76
|
-
}
|
77
|
-
);
|
78
|
-
console.log("✅ RECENT_ACTIONS: ", cacheMemories);
|
83
|
+
public async process(state: State, callbacks?: QueueCallbacks): Promise<any> {
|
84
|
+
console.log("🔄 Processing state:");
|
85
|
+
console.dir(state, { depth: null });
|
86
|
+
let countIterations = 0;
|
87
|
+
const response = await this.agent.process(state);
|
79
88
|
|
80
|
-
const
|
81
|
-
|
82
|
-
{
|
83
|
-
similarityThreshold: 80,
|
84
|
-
}
|
85
|
-
);
|
86
|
-
console.log("✅ PERSISTENT_MEMORY: ", persistentMemory);
|
87
|
-
const request = await this.orchestrator.process(
|
88
|
-
prompt,
|
89
|
-
`## RECENT_ACTIONS: ${JSON.stringify(
|
90
|
-
cacheMemories
|
91
|
-
)} ## PERSISTENT_MEMORY: ${JSON.stringify(
|
92
|
-
persistentMemory
|
93
|
-
)} ## CURRENT_RESULTS: ${this.accumulatedResults}`
|
89
|
+
const unscheduledActions = response.actions.filter(
|
90
|
+
(action) => !action.scheduler?.isScheduled
|
94
91
|
);
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
private async handleActions(
|
109
|
-
{
|
110
|
-
initialPrompt,
|
111
|
-
actions,
|
112
|
-
}: {
|
113
|
-
initialPrompt: string;
|
114
|
-
actions: {
|
115
|
-
name: string;
|
116
|
-
type: string;
|
117
|
-
parameters: {
|
118
|
-
name: string;
|
119
|
-
value: any;
|
120
|
-
}[];
|
121
|
-
}[];
|
122
|
-
},
|
123
|
-
events: AgentEvent
|
124
|
-
): Promise<any> {
|
125
|
-
const queueItems = this.transformActions(actions as any);
|
126
|
-
|
127
|
-
const actionsResult = await this.actionHandler.executeActions(
|
128
|
-
queueItems,
|
129
|
-
this.orchestrator.tools,
|
130
|
-
{
|
131
|
-
onQueueStart: events.onQueueStart,
|
132
|
-
onActionStart: events.onActionStart,
|
133
|
-
onActionComplete: events.onActionComplete,
|
134
|
-
onQueueComplete: events.onQueueComplete,
|
135
|
-
onConfirmationRequired: events.onConfirmationRequired,
|
92
|
+
// Execute actions if needed
|
93
|
+
if (unscheduledActions?.length > 0 && response.shouldContinue) {
|
94
|
+
console.log("\n📋 Processing action queue");
|
95
|
+
const queueManager = new ActionQueueManager(
|
96
|
+
this.config.orchestrator.tools,
|
97
|
+
callbacks
|
98
|
+
);
|
99
|
+
const queueItems = QueueItemTransformer.transformActionsToQueueItems(
|
100
|
+
response.actions as ActionData[]
|
101
|
+
);
|
102
|
+
if (!queueItems) {
|
103
|
+
throw new Error("No queue items found");
|
136
104
|
}
|
137
|
-
);
|
138
105
|
|
139
|
-
|
106
|
+
console.log(
|
107
|
+
"📋 Actions to execute:",
|
108
|
+
queueItems
|
109
|
+
.map((item) => (typeof item === "string" ? item : item.name))
|
110
|
+
.join(", ")
|
111
|
+
);
|
140
112
|
|
141
|
-
|
142
|
-
(
|
143
|
-
|
113
|
+
queueManager.addToQueue(queueItems);
|
114
|
+
console.log("\n⚡ Executing actions...");
|
115
|
+
const results = await queueManager.processQueue();
|
116
|
+
console.log("✅ Execution results:", results);
|
144
117
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
118
|
+
const updatedNextState: State = {
|
119
|
+
...state,
|
120
|
+
currentContext: state.currentContext,
|
121
|
+
previousActions: [...(state.previousActions || []), ...(results || [])],
|
149
122
|
};
|
150
|
-
}
|
151
123
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
});
|
124
|
+
console.log("\n🔁 Recursively processing with updated state");
|
125
|
+
countIterations++;
|
126
|
+
if (countIterations < this.config.maxIterations) {
|
127
|
+
return this.process(updatedNextState);
|
128
|
+
}
|
158
129
|
}
|
159
130
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
131
|
+
if (countIterations >= this.config.maxIterations) {
|
132
|
+
console.log("Max iterations reached");
|
133
|
+
response.shouldContinue = false;
|
134
|
+
console.log("Forcing stop");
|
135
|
+
}
|
165
136
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
137
|
+
// Handle final interpretation
|
138
|
+
if (
|
139
|
+
!response.shouldContinue &&
|
140
|
+
state.previousActions?.length &&
|
141
|
+
response.interpreter
|
142
|
+
) {
|
143
|
+
console.log("\n🏁 Analysis complete - generating final interpretation");
|
144
|
+
const interpreter = this.getInterpreter(
|
145
|
+
this.config.interpreters,
|
146
|
+
response.interpreter
|
147
|
+
);
|
148
|
+
console.log("🎭 Selected Interpreter:", interpreter?.name);
|
149
|
+
console.dir(state, { depth: null });
|
150
|
+
const interpretationResult = (await interpreter?.process(
|
151
|
+
"Interpret the analysis results",
|
152
|
+
{
|
153
|
+
...state,
|
154
|
+
results: JSON.stringify(state.previousActions),
|
155
|
+
userRequest: state.currentContext,
|
156
|
+
}
|
157
|
+
)) as { response: string };
|
170
158
|
|
171
|
-
|
172
|
-
this.interpreters,
|
173
|
-
evaluation.interpreter
|
174
|
-
);
|
159
|
+
console.log("\n📊 Final Analysis:", interpretationResult.response);
|
175
160
|
|
176
|
-
|
161
|
+
const finalState: State = {
|
162
|
+
...state,
|
163
|
+
results: interpretationResult.response,
|
164
|
+
};
|
177
165
|
|
178
|
-
|
179
|
-
this.evaluatorIteration++;
|
180
|
-
return this.handleActions(
|
181
|
-
{
|
182
|
-
initialPrompt: initialPrompt,
|
183
|
-
actions: evaluation.nextActionsNeeded,
|
184
|
-
},
|
185
|
-
events
|
186
|
-
);
|
166
|
+
console.log("🔄 Final state:", finalState);
|
187
167
|
}
|
188
168
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
169
|
+
// Return the final response at the end of the function
|
170
|
+
const validatedActions = response.actions.map((action) => ({
|
171
|
+
...action,
|
172
|
+
parameters: action.parameters.map((param) => ({
|
173
|
+
...param,
|
174
|
+
value: param.value ?? null, // Set a default value if undefined
|
175
|
+
})),
|
176
|
+
}));
|
177
|
+
|
178
|
+
const result = {
|
179
|
+
...response,
|
180
|
+
actions: validatedActions,
|
181
|
+
results: JSON.stringify(state.previousActions),
|
182
|
+
};
|
183
|
+
if (!result.shouldContinue) {
|
184
|
+
await this.memoryManager.process(state, JSON.stringify(result));
|
185
|
+
}
|
186
|
+
return result;
|
194
187
|
}
|
195
188
|
|
196
189
|
private getInterpreter(interpreters: Interpreter[], name: string) {
|
197
|
-
console.log({ interpreters, name });
|
198
190
|
return interpreters.find((interpreter) => interpreter.name === name);
|
199
191
|
}
|
200
192
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
if (
|
208
|
-
|
193
|
+
public addListener(
|
194
|
+
id: string,
|
195
|
+
url: string,
|
196
|
+
subscriptionMessageFactory: () => string,
|
197
|
+
callback: (data: any, agentContext: Agent) => Promise<void>
|
198
|
+
): void {
|
199
|
+
if (this.listeners.has(id)) {
|
200
|
+
console.warn(`WebSocket with ID ${id} already exists.`);
|
201
|
+
return;
|
209
202
|
}
|
210
|
-
console.log("✅ INTERPRETER: ", interpreter.name);
|
211
|
-
return this.stream
|
212
|
-
? (
|
213
|
-
await interpreter.streamProcess(initialPrompt, {
|
214
|
-
userRequest: initialPrompt,
|
215
|
-
results: data,
|
216
|
-
})
|
217
|
-
).toDataStreamResponse()
|
218
|
-
: await interpreter.process(initialPrompt, {
|
219
|
-
userRequest: initialPrompt,
|
220
|
-
results: data,
|
221
|
-
});
|
222
|
-
}
|
223
203
|
|
224
|
-
|
225
|
-
let predefinedActions =
|
226
|
-
QueueItemTransformer.transformActionsToQueueItems(actions) || [];
|
204
|
+
const socket = new WebSocket(url);
|
227
205
|
|
228
|
-
|
229
|
-
|
206
|
+
const wrappedCallback = async (data: any) => {
|
207
|
+
await callback(data, this);
|
208
|
+
};
|
230
209
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
210
|
+
socket.on("open", () => {
|
211
|
+
console.log(`🔗 WebSocket connected for ID: ${id}`);
|
212
|
+
|
213
|
+
// Envoie le message d'abonnement si une factory est fournie
|
214
|
+
if (subscriptionMessageFactory) {
|
215
|
+
const subscriptionMessage = subscriptionMessageFactory();
|
216
|
+
socket.send(subscriptionMessage);
|
217
|
+
console.log(
|
218
|
+
`📡 Sent subscription message for ID ${id}:`,
|
219
|
+
subscriptionMessage
|
220
|
+
);
|
221
|
+
}
|
222
|
+
});
|
242
223
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
224
|
+
socket.on("message", async (message: string) => {
|
225
|
+
console.log(`📨 Message received for WebSocket ID ${id}:`, message);
|
226
|
+
try {
|
227
|
+
const data = JSON.parse(message);
|
228
|
+
await wrappedCallback(data);
|
229
|
+
} catch (error) {
|
230
|
+
console.error(`❌ Error in callback for WebSocket ID ${id}:`, error);
|
231
|
+
}
|
232
|
+
});
|
233
|
+
|
234
|
+
socket.on("error", (error) => {
|
235
|
+
console.error(`❌ WebSocket error for ID ${id}:`, error);
|
236
|
+
});
|
237
|
+
|
238
|
+
socket.on("close", () => {
|
239
|
+
console.log(`🔌 WebSocket closed for ID: ${id}`);
|
240
|
+
});
|
256
241
|
|
257
|
-
|
258
|
-
return this.scheduler.cancelScheduledAction(actionId);
|
242
|
+
this.listeners.set(id, { socket, callback: wrappedCallback });
|
259
243
|
}
|
260
244
|
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import Parser from "rss-parser";
|
2
|
+
import { z } from "zod";
|
3
|
+
|
4
|
+
const RSS_FEEDS = [
|
5
|
+
"https://www.investing.com/rss/news_301.rss",
|
6
|
+
"https://cointelegraph.com/rss/category/analysis",
|
7
|
+
"https://cointelegraph.com/rss/category/top-10-cryptocurrencies",
|
8
|
+
];
|
9
|
+
|
10
|
+
const parser = new Parser();
|
11
|
+
|
12
|
+
function stripHtmlTags(content: string): string {
|
13
|
+
if (!content) return "";
|
14
|
+
return content
|
15
|
+
.replace(/<[^>]*>/g, "")
|
16
|
+
.replace(/\n/g, "")
|
17
|
+
.replace(" ", "");
|
18
|
+
}
|
19
|
+
|
20
|
+
export const getRssNews = {
|
21
|
+
name: "get-news-rss",
|
22
|
+
description: "Get latest news about on website",
|
23
|
+
parameters: z.object({}),
|
24
|
+
execute: async () => {
|
25
|
+
const itemsPerSource = 5;
|
26
|
+
|
27
|
+
try {
|
28
|
+
const feedPromises = RSS_FEEDS.map((url) => parser.parseURL(url));
|
29
|
+
const results = await Promise.allSettled(feedPromises);
|
30
|
+
const successfulFeeds = results
|
31
|
+
.filter(
|
32
|
+
(result): result is PromiseFulfilledResult<Parser.Output<any>> => {
|
33
|
+
return (
|
34
|
+
result.status === "fulfilled" && result.value?.items?.length > 0
|
35
|
+
);
|
36
|
+
}
|
37
|
+
)
|
38
|
+
.map((result) => result.value);
|
39
|
+
const allItems = successfulFeeds
|
40
|
+
.flatMap((feed) => feed.items.slice(0, itemsPerSource))
|
41
|
+
.sort((a, b) => {
|
42
|
+
const dateA = a.pubDate ? new Date(a.pubDate).getTime() : 0;
|
43
|
+
const dateB = b.pubDate ? new Date(b.pubDate).getTime() : 0;
|
44
|
+
return dateB - dateA;
|
45
|
+
})
|
46
|
+
.slice(0, 5)
|
47
|
+
.map((item) => ({
|
48
|
+
title: item.title,
|
49
|
+
content: stripHtmlTags(item.content),
|
50
|
+
link: item.link,
|
51
|
+
date: item.pubDate,
|
52
|
+
source: item.creator || new URL(item.link).hostname,
|
53
|
+
}));
|
54
|
+
|
55
|
+
const result = {
|
56
|
+
status: "success",
|
57
|
+
items: allItems,
|
58
|
+
};
|
59
|
+
return result;
|
60
|
+
} catch (error: any) {
|
61
|
+
throw error;
|
62
|
+
}
|
63
|
+
},
|
64
|
+
};
|
package/bull.ts
ADDED
package/dist/agent/index.d.ts
CHANGED
@@ -1,35 +1,38 @@
|
|
1
|
+
import { LanguageModel } from "ai";
|
1
2
|
import { Interpreter } from "../llm/interpreter";
|
2
|
-
import {
|
3
|
+
import { State } from "../llm/orchestrator/types";
|
3
4
|
import { CacheMemory } from "../memory/cache";
|
4
5
|
import { PersistentMemory } from "../memory/persistent";
|
5
|
-
import {
|
6
|
+
import { CacheConfig } from "../services/redis-cache";
|
7
|
+
import { ActionSchema, QueueCallbacks } from "../types";
|
6
8
|
export declare class Agent {
|
7
|
-
private readonly
|
8
|
-
private readonly
|
9
|
-
private readonly
|
10
|
-
private
|
11
|
-
private readonly
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
private readonly agent;
|
10
|
+
private readonly memoryManager;
|
11
|
+
private readonly cache;
|
12
|
+
private listeners;
|
13
|
+
private readonly config;
|
14
|
+
constructor(config: {
|
15
|
+
cache: CacheConfig;
|
16
|
+
orchestrator: {
|
17
|
+
model: LanguageModel;
|
18
|
+
tools: ActionSchema[];
|
19
|
+
memory?: {
|
20
|
+
cache?: CacheMemory;
|
21
|
+
persistent?: PersistentMemory;
|
22
|
+
};
|
23
|
+
};
|
19
24
|
interpreters: Interpreter[];
|
20
|
-
|
21
|
-
|
22
|
-
|
25
|
+
memoryManager: {
|
26
|
+
model: LanguageModel;
|
27
|
+
memory?: {
|
28
|
+
cache?: CacheMemory;
|
29
|
+
persistent?: PersistentMemory;
|
30
|
+
};
|
23
31
|
};
|
24
|
-
|
25
|
-
|
32
|
+
callbacks?: QueueCallbacks;
|
33
|
+
maxIterations: number;
|
26
34
|
});
|
27
|
-
process(
|
28
|
-
private handleActions;
|
35
|
+
process(state: State, callbacks?: QueueCallbacks): Promise<any>;
|
29
36
|
private getInterpreter;
|
30
|
-
|
31
|
-
private transformActions;
|
32
|
-
private formatResults;
|
33
|
-
scheduleAction(action: ActionSchema, scheduledTime: Date, userId: string, recurrence?: ScheduledAction["recurrence"]): Promise<string>;
|
34
|
-
cancelScheduledAction(actionId: string): Promise<boolean>;
|
37
|
+
addListener(id: string, url: string, subscriptionMessageFactory: () => string, callback: (data: any, agentContext: Agent) => Promise<void>): void;
|
35
38
|
}
|