@ai.ntellect/core 0.5.0 → 0.6.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.
Files changed (131) hide show
  1. package/.mocharc.json +1 -1
  2. package/README.md +311 -272
  3. package/dist/graph/controller.js +63 -0
  4. package/dist/graph/engine.js +563 -0
  5. package/dist/index.js +6 -6
  6. package/dist/memory/adapters/meilisearch/index.js +249 -0
  7. package/dist/memory/adapters/redis/index.js +96 -0
  8. package/dist/memory/index.js +9 -0
  9. package/dist/services/agenda.js +115 -0
  10. package/dist/services/embedding.js +40 -0
  11. package/dist/services/queue.js +99 -103
  12. package/dist/test/graph/controller.test.js +170 -0
  13. package/dist/test/graph/engine.test.js +465 -0
  14. package/dist/test/memory/adapters/meilisearch.test.js +250 -0
  15. package/dist/test/memory/adapters/redis.test.js +143 -0
  16. package/dist/test/memory/base.test.js +209 -0
  17. package/dist/test/services/agenda.test.js +230 -0
  18. package/dist/test/services/queue.test.js +258 -0
  19. package/dist/types/index.js +2 -0
  20. package/dist/utils/generate-object.js +32 -11
  21. package/dist/utils/inject-actions.js +2 -2
  22. package/dist/utils/queue-item-transformer.js +2 -2
  23. package/dist/utils/state-manager.js +20 -0
  24. package/graph/controller.ts +60 -0
  25. package/{services/workflow.ts → graph/engine.ts} +331 -113
  26. package/index.ts +7 -7
  27. package/interfaces/index.ts +119 -0
  28. package/memory/adapters/meilisearch/index.ts +286 -0
  29. package/memory/adapters/redis/index.ts +103 -0
  30. package/memory/index.ts +22 -0
  31. package/package.json +7 -2
  32. package/services/agenda.ts +48 -43
  33. package/services/embedding.ts +26 -0
  34. package/services/queue.ts +2 -29
  35. package/test/.env.test +4 -0
  36. package/test/graph/controller.test.ts +186 -0
  37. package/test/graph/engine.test.ts +563 -0
  38. package/test/memory/adapters/meilisearch.test.ts +297 -0
  39. package/test/memory/adapters/redis.test.ts +160 -0
  40. package/test/memory/base.test.ts +229 -0
  41. package/test/services/agenda.test.ts +280 -0
  42. package/test/services/queue.test.ts +286 -44
  43. package/tsconfig.json +10 -10
  44. package/types/index.ts +270 -0
  45. package/utils/generate-object.js +111 -0
  46. package/utils/header-builder.js +34 -0
  47. package/utils/inject-actions.js +16 -0
  48. package/utils/queue-item-transformer.js +24 -0
  49. package/utils/queue-item-transformer.ts +8 -11
  50. package/utils/sanitize-results.js +60 -0
  51. package/utils/schema-generator.js +46 -0
  52. package/utils/state-manager.js +20 -0
  53. package/utils/state-manager.ts +17 -12
  54. package/.nvmrc +0 -1
  55. package/README.FR.md +0 -916
  56. package/agent/index.ts +0 -151
  57. package/agent/workflow/conditions.ts +0 -16
  58. package/agent/workflow/handlers/interpreter.handler.ts +0 -48
  59. package/agent/workflow/handlers/memory.handler.ts +0 -106
  60. package/agent/workflow/handlers/orchestrator.handler.ts +0 -23
  61. package/agent/workflow/handlers/queue.handler.ts +0 -34
  62. package/agent/workflow/handlers/scheduler.handler.ts +0 -61
  63. package/agent/workflow/index.ts +0 -62
  64. package/dist/agent/index.d.ts +0 -38
  65. package/dist/agent/index.js +0 -143
  66. package/dist/agent/tools/get-rss.d.ts +0 -16
  67. package/dist/agent/tools/get-rss.js +0 -62
  68. package/dist/bull.d.ts +0 -1
  69. package/dist/bull.js +0 -9
  70. package/dist/examples/index.d.ts +0 -2
  71. package/dist/examples/index.js +0 -89
  72. package/dist/index.d.ts +0 -7
  73. package/dist/llm/interpreter/context.d.ts +0 -15
  74. package/dist/llm/interpreter/context.js +0 -89
  75. package/dist/llm/interpreter/index.d.ts +0 -21
  76. package/dist/llm/interpreter/index.js +0 -87
  77. package/dist/llm/memory-manager/context.d.ts +0 -2
  78. package/dist/llm/memory-manager/context.js +0 -22
  79. package/dist/llm/memory-manager/index.d.ts +0 -17
  80. package/dist/llm/memory-manager/index.js +0 -107
  81. package/dist/llm/orchestrator/context.d.ts +0 -2
  82. package/dist/llm/orchestrator/context.js +0 -23
  83. package/dist/llm/orchestrator/index.d.ts +0 -44
  84. package/dist/llm/orchestrator/index.js +0 -139
  85. package/dist/llm/orchestrator/types.d.ts +0 -12
  86. package/dist/memory/cache.d.ts +0 -22
  87. package/dist/memory/cache.js +0 -165
  88. package/dist/memory/persistent.d.ts +0 -57
  89. package/dist/memory/persistent.js +0 -189
  90. package/dist/services/queue.d.ts +0 -13
  91. package/dist/services/redis-cache.d.ts +0 -37
  92. package/dist/services/redis-cache.js +0 -93
  93. package/dist/services/scheduler.d.ts +0 -40
  94. package/dist/services/scheduler.js +0 -99
  95. package/dist/services/telegram-monitor.d.ts +0 -0
  96. package/dist/services/telegram-monitor.js +0 -118
  97. package/dist/t.d.ts +0 -46
  98. package/dist/t.js +0 -102
  99. package/dist/test.d.ts +0 -0
  100. package/dist/test.js +0 -438
  101. package/dist/types.d.ts +0 -258
  102. package/dist/types.js +0 -22
  103. package/dist/utils/generate-object.d.ts +0 -12
  104. package/dist/utils/header-builder.d.ts +0 -11
  105. package/dist/utils/inject-actions.d.ts +0 -2
  106. package/dist/utils/queue-item-transformer.d.ts +0 -7
  107. package/dist/utils/sanitize-results.d.ts +0 -17
  108. package/dist/utils/schema-generator.d.ts +0 -16
  109. package/examples/actions/get-rss.ts +0 -71
  110. package/examples/index.ts +0 -98
  111. package/index.html +0 -42
  112. package/llm/dynamic-condition/example.ts +0 -36
  113. package/llm/dynamic-condition/index.ts +0 -108
  114. package/llm/interpreter/context.ts +0 -94
  115. package/llm/interpreter/index.ts +0 -140
  116. package/llm/memory-manager/context.ts +0 -19
  117. package/llm/memory-manager/index.ts +0 -115
  118. package/llm/orchestrator/context.ts +0 -19
  119. package/llm/orchestrator/index.ts +0 -192
  120. package/llm/orchestrator/types.ts +0 -14
  121. package/memory/cache.ts +0 -221
  122. package/memory/persistent.ts +0 -265
  123. package/script.js +0 -167
  124. package/services/cache.ts +0 -298
  125. package/services/telegram-monitor.ts +0 -138
  126. package/t.py +0 -79
  127. package/t.ts +0 -25
  128. package/test/llm/orchestrator.test.ts +0 -47
  129. package/test/llm/synthesizer.test.ts +0 -31
  130. package/types.ts +0 -367
  131. /package/dist/{llm/orchestrator/types.js → interfaces/index.js} +0 -0
package/types.ts DELETED
@@ -1,367 +0,0 @@
1
- import { CoreMessage, Embedding, EmbeddingModel, StreamTextResult } from "ai";
2
- import { z } from "zod";
3
-
4
- export interface BaseLLM {
5
- process: (prompt: string) => Promise<string | object>;
6
- streamProcess?: (
7
- prompt: string
8
- ) => Promise<StreamTextResult<Record<string, any>>>;
9
- }
10
-
11
- export type User = {
12
- id: string;
13
- };
14
-
15
- export interface QueueItem {
16
- name: string;
17
- parameters: QueueItemParameter[];
18
- }
19
-
20
- export interface IEventHandler {
21
- emitQueueStart(actions: QueueItem[]): void;
22
- emitActionStart(action: QueueItem): void;
23
- emitActionComplete(action: QueueResult): void;
24
- emitQueueComplete(): void;
25
- }
26
-
27
- export type AgentEvent = {
28
- onMessage?: (data: any) => void;
29
- onQueueStart?: (actions: QueueItem[]) => void;
30
- onActionStart?: (action: QueueItem) => void;
31
- onActionComplete?: (action: QueueResult) => void;
32
- onQueueComplete?: (actions: QueueResult[]) => void;
33
- onConfirmationRequired?: (message: string) => Promise<boolean>;
34
- };
35
-
36
- export interface QueueResult {
37
- name: string;
38
- parameters: Record<string, string>;
39
- result: any;
40
- error: string | null;
41
- cancelled?: boolean;
42
- }
43
-
44
- export interface QueueCallbacks {
45
- onActionStart?: (action: QueueItem) => void;
46
- onActionComplete?: (result: QueueResult) => void;
47
- onQueueComplete?: (results: QueueResult[]) => void;
48
- onConfirmationRequired?: (message: string) => Promise<boolean>;
49
- }
50
-
51
- export interface ProcessPromptCallbacks {
52
- onQueueStart?: (actions: QueueItem[]) => void | Promise<void>;
53
- onActionStart?: (action: QueueItem) => void | Promise<void>;
54
- onActionComplete?: (action: QueueResult) => void | Promise<void>;
55
- onQueueComplete?: (actions: QueueResult[]) => void | Promise<void>;
56
- onConfirmationRequired?: (message: string) => Promise<boolean>;
57
- }
58
-
59
- export type Behavior = {
60
- role: string;
61
- language: string;
62
- guidelines: {
63
- important: string[];
64
- warnings: string[];
65
- steps?: string[];
66
- };
67
- examplesMessages?: {
68
- role: string;
69
- content: string;
70
- }[];
71
- };
72
-
73
- export interface ActionSchema {
74
- name: string;
75
- description: string;
76
- parameters: z.ZodObject<{
77
- [key: string]: z.ZodType;
78
- }>;
79
- execute: (args: any) => Promise<any>;
80
- examples?: {
81
- role: string;
82
- content: string;
83
- parameters?: Record<string, any>;
84
- }[];
85
- confirmation?: {
86
- requireConfirmation: boolean;
87
- message: string;
88
- };
89
- }
90
-
91
- export type ProcessPromptResult = {
92
- type: "success" | "clarification" | "confirmation";
93
- data:
94
- | QueueResult[]
95
- | {
96
- validationErrors: string[];
97
- prompt: string;
98
- }
99
- | {
100
- actions: QueueItem[];
101
- };
102
- initialPrompt: string;
103
- };
104
-
105
- export interface ActionPattern {
106
- id: string;
107
- actions: QueueResult[];
108
- embeddings: number[][];
109
- queries: string[];
110
- purpose: string;
111
- }
112
-
113
- export interface MatchOptions {
114
- similarityThreshold?: number;
115
- maxResults?: number;
116
- }
117
-
118
- export interface MatchResult {
119
- data: any;
120
- similarityPercentage: number;
121
- purpose: string;
122
- name?: string;
123
- parameters?: Record<string, any>;
124
- }
125
-
126
- export interface SummarizerAgent {
127
- process: (
128
- results: object,
129
- onFinish?: (event: any) => void
130
- ) => Promise<
131
- | {
132
- actions: { name: string; reasoning: string }[];
133
- response: string;
134
- }
135
- | StreamTextResult<Record<string, any>>
136
- >;
137
- streamProcess: (
138
- results: object,
139
- onFinish?: (event: any) => void
140
- ) => Promise<StreamTextResult<Record<string, any>>>;
141
- }
142
-
143
- export interface CacheMemoryOptions {
144
- embeddingModel: EmbeddingModel<string>;
145
- cacheTTL?: number;
146
- redisUrl?: string;
147
- cachePrefix?: string;
148
- }
149
-
150
- export type GenerateObjectResponse = {
151
- processing: {
152
- stop: boolean;
153
- stopReason?: string;
154
- };
155
- actions: Array<{
156
- name: string;
157
- parameters: Array<{
158
- name: string;
159
- value: any;
160
- }>;
161
- scheduler?: {
162
- isScheduled: boolean;
163
- cronExpression: string;
164
- reason?: string;
165
- };
166
- }>;
167
- response: string;
168
- interpreter?: string;
169
- };
170
-
171
- export interface CreateMemoryInput {
172
- query: string;
173
- data: any;
174
- userId?: string;
175
- scope?: MemoryScope;
176
- ttl?: number;
177
- }
178
-
179
- export interface CacheMemoryType {
180
- id: string;
181
- data: any;
182
- query: string;
183
- embedding: Embedding;
184
- userId?: string;
185
- scope: MemoryScope;
186
- createdAt: Date;
187
- }
188
-
189
- export interface PersistentMemoryOptions {
190
- host: string;
191
- apiKey: string;
192
- indexPrefix?: string;
193
- }
194
-
195
- export interface MemoryChunk {
196
- content: string;
197
- embedding: number[];
198
- }
199
-
200
- export type MemoryScopeType = (typeof MemoryScope)[keyof typeof MemoryScope];
201
-
202
- export interface LongTermMemory {
203
- id: string;
204
- query: string;
205
- category: string;
206
- data: any;
207
- roomId: string;
208
- createdAt: Date;
209
- chunks?: MemoryChunk[];
210
- tags: string[];
211
- }
212
-
213
- export const ActionSchema = z.array(
214
- z.object({
215
- name: z.string(),
216
- parameters: z.array(
217
- z.object({
218
- name: z.string(),
219
- value: z.string(),
220
- })
221
- ),
222
- })
223
- );
224
-
225
- export enum MemoryType {
226
- ACTION = "action",
227
- CONVERSATION = "conversation",
228
- KNOWLEDGE = "knowledge",
229
- }
230
-
231
- export enum MemoryScope {
232
- GLOBAL = "global",
233
- USER = "user",
234
- }
235
-
236
- export interface ActionData {
237
- name?: string;
238
- parameters?: Record<string, any>;
239
- }
240
-
241
- export interface QueueItemParameter {
242
- name: string;
243
- value: string;
244
- }
245
-
246
- export interface TransformedQueueItem {
247
- name: string;
248
- parameters: QueueItemParameter[];
249
- }
250
-
251
- export interface ScheduledAction {
252
- id: string;
253
- action: {
254
- name: string;
255
- parameters: QueueItemParameter[];
256
- };
257
- scheduledTime: Date;
258
- userId: string;
259
- status: "pending" | "completed" | "failed";
260
- recurrence?: {
261
- type: "daily" | "weekly" | "monthly";
262
- interval: number;
263
- };
264
- }
265
-
266
- export interface ScheduledActionEvents {
267
- onActionStart?: (action: ScheduledAction) => void;
268
- onActionComplete?: (action: ScheduledAction, result: any) => void;
269
- onActionFailed?: (action: ScheduledAction, error: Error) => void;
270
- onActionScheduled?: (action: ScheduledAction) => void;
271
- onActionCancelled?: (actionId: string) => void;
272
- }
273
-
274
- export interface WorkflowPattern {
275
- query: string;
276
- actions: Array<{
277
- done: boolean;
278
- name: string;
279
- result: string;
280
- }>;
281
- success: boolean;
282
- }
283
-
284
- // État partagé
285
- export type MyContext = {
286
- prompt?: string;
287
- processing: {
288
- stop: boolean;
289
- reason?: string;
290
- };
291
- actions?: {
292
- name: string;
293
- parameters: Record<string, any>;
294
- result?: any;
295
- error?: any;
296
- scheduler?: {
297
- isScheduled: boolean;
298
- cronExpression?: string;
299
- reason?: string;
300
- };
301
- }[];
302
- interpreter?: string | null;
303
- results?: any;
304
- };
305
-
306
- export interface SharedState<T> {
307
- messages?: CoreMessage[]; // Historique des interactions
308
- context: T;
309
- }
310
-
311
- export function mergeState<T>(
312
- current: SharedState<T>,
313
- updates: Partial<SharedState<T>>
314
- ): SharedState<T> {
315
- const uniqueMessages = new Map(
316
- [...(current.messages || []), ...(updates.messages || [])].map((msg) => [
317
- JSON.stringify(msg),
318
- msg,
319
- ])
320
- );
321
- return {
322
- ...current,
323
- context: { ...current.context, ...updates.context },
324
- messages: Array.from(uniqueMessages.values()), // Messages uniques
325
- };
326
- }
327
- export interface RetryConfig {
328
- maxRetries: number;
329
- retryDelay: number;
330
- shouldRetry?: (error: Error) => boolean;
331
- }
332
-
333
- export interface Node<T> {
334
- name: string;
335
- description?: string;
336
- execute: (state: SharedState<T>) => Promise<Partial<SharedState<T>>>;
337
- condition?: (state: SharedState<T>) => boolean;
338
- next?: string[];
339
- events?: string[];
340
- retry?: RetryConfig;
341
- }
342
-
343
- export interface Persistence<T> {
344
- saveState(
345
- graphName: string,
346
- state: SharedState<T>,
347
- currentNode: string
348
- ): Promise<void>;
349
- loadState(
350
- graphName: string
351
- ): Promise<{ state: SharedState<T>; currentNode: string } | null>;
352
- }
353
-
354
- export interface RealTimeNotifier {
355
- notify(event: string, data: any): void;
356
- }
357
-
358
- export interface WorkflowDefinition<T> {
359
- name: string;
360
- nodes: {
361
- [key: string]: Node<T> & {
362
- condition?: (state: SharedState<T>) => boolean;
363
- next?: string[];
364
- };
365
- };
366
- entryNode: string;
367
- }