@ai.ntellect/core 0.5.0 → 0.6.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/.mocharc.json +1 -1
- package/README.md +311 -272
- package/create-llm-to-select-multiple-graph copy.ts +243 -0
- package/create-llm-to-select-multiple-graph.ts +148 -0
- package/dist/graph/controller.js +63 -0
- package/dist/graph/engine.js +563 -0
- package/dist/index.js +6 -6
- package/dist/memory/adapters/meilisearch/index.js +249 -0
- package/dist/memory/adapters/redis/index.js +96 -0
- package/dist/memory/index.js +9 -0
- package/dist/services/agenda.js +115 -0
- package/dist/services/embedding.js +40 -0
- package/dist/services/queue.js +99 -103
- package/dist/test/graph/controller.test.js +170 -0
- package/dist/test/graph/engine.test.js +465 -0
- package/dist/test/memory/adapters/meilisearch.test.js +250 -0
- package/dist/test/memory/adapters/redis.test.js +143 -0
- package/dist/test/memory/base.test.js +209 -0
- package/dist/test/services/agenda.test.js +230 -0
- package/dist/test/services/queue.test.js +258 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/generate-object.js +32 -11
- package/dist/utils/inject-actions.js +2 -2
- package/dist/utils/queue-item-transformer.js +2 -2
- package/dist/utils/state-manager.js +20 -0
- package/graph/controller.ts +64 -0
- package/graph/engine.ts +790 -0
- package/index copy.ts +81 -0
- package/index.ts +7 -7
- package/interfaces/index.ts +119 -0
- package/memory/adapters/meilisearch/index.ts +286 -0
- package/memory/adapters/redis/index.ts +103 -0
- package/memory/index.ts +22 -0
- package/package.json +7 -2
- package/services/agenda.ts +48 -43
- package/services/embedding.ts +26 -0
- package/services/queue.ts +2 -29
- package/test/.env.test +4 -0
- package/test/graph/controller.test.ts +186 -0
- package/test/graph/engine.test.ts +546 -0
- package/test/memory/adapters/meilisearch.test.ts +297 -0
- package/test/memory/adapters/redis.test.ts +160 -0
- package/test/memory/base.test.ts +229 -0
- package/test/services/agenda.test.ts +280 -0
- package/test/services/queue.test.ts +286 -44
- package/tsconfig.json +10 -10
- package/types/index.ts +278 -0
- package/utils/queue-item-transformer.ts +8 -11
- package/utils/setup-graphs.ts +45 -0
- package/utils/stringifiy-zod-schema.ts +45 -0
- package/.nvmrc +0 -1
- package/README.FR.md +0 -916
- package/agent/index.ts +0 -151
- package/agent/workflow/conditions.ts +0 -16
- package/agent/workflow/handlers/interpreter.handler.ts +0 -48
- package/agent/workflow/handlers/memory.handler.ts +0 -106
- package/agent/workflow/handlers/orchestrator.handler.ts +0 -23
- package/agent/workflow/handlers/queue.handler.ts +0 -34
- package/agent/workflow/handlers/scheduler.handler.ts +0 -61
- package/agent/workflow/index.ts +0 -62
- package/dist/agent/index.d.ts +0 -38
- package/dist/agent/index.js +0 -143
- package/dist/agent/tools/get-rss.d.ts +0 -16
- package/dist/agent/tools/get-rss.js +0 -62
- package/dist/bull.d.ts +0 -1
- package/dist/bull.js +0 -9
- package/dist/examples/index.d.ts +0 -2
- package/dist/examples/index.js +0 -89
- package/dist/index.d.ts +0 -7
- package/dist/llm/interpreter/context.d.ts +0 -15
- package/dist/llm/interpreter/context.js +0 -89
- package/dist/llm/interpreter/index.d.ts +0 -21
- package/dist/llm/interpreter/index.js +0 -87
- package/dist/llm/memory-manager/context.d.ts +0 -2
- package/dist/llm/memory-manager/context.js +0 -22
- package/dist/llm/memory-manager/index.d.ts +0 -17
- package/dist/llm/memory-manager/index.js +0 -107
- package/dist/llm/orchestrator/context.d.ts +0 -2
- package/dist/llm/orchestrator/context.js +0 -23
- package/dist/llm/orchestrator/index.d.ts +0 -44
- package/dist/llm/orchestrator/index.js +0 -139
- package/dist/llm/orchestrator/types.d.ts +0 -12
- package/dist/memory/cache.d.ts +0 -22
- package/dist/memory/cache.js +0 -165
- package/dist/memory/persistent.d.ts +0 -57
- package/dist/memory/persistent.js +0 -189
- package/dist/services/queue.d.ts +0 -13
- package/dist/services/redis-cache.d.ts +0 -37
- package/dist/services/redis-cache.js +0 -93
- package/dist/services/scheduler.d.ts +0 -40
- package/dist/services/scheduler.js +0 -99
- package/dist/services/telegram-monitor.d.ts +0 -0
- package/dist/services/telegram-monitor.js +0 -118
- package/dist/t.d.ts +0 -46
- package/dist/t.js +0 -102
- package/dist/test.d.ts +0 -0
- package/dist/test.js +0 -438
- package/dist/types.d.ts +0 -258
- package/dist/types.js +0 -22
- package/dist/utils/generate-object.d.ts +0 -12
- package/dist/utils/header-builder.d.ts +0 -11
- package/dist/utils/inject-actions.d.ts +0 -2
- package/dist/utils/queue-item-transformer.d.ts +0 -7
- package/dist/utils/sanitize-results.d.ts +0 -17
- package/dist/utils/schema-generator.d.ts +0 -16
- package/examples/actions/get-rss.ts +0 -71
- package/examples/index.ts +0 -98
- package/index.html +0 -42
- package/llm/dynamic-condition/example.ts +0 -36
- package/llm/dynamic-condition/index.ts +0 -108
- package/llm/interpreter/context.ts +0 -94
- package/llm/interpreter/index.ts +0 -140
- package/llm/memory-manager/context.ts +0 -19
- package/llm/memory-manager/index.ts +0 -115
- package/llm/orchestrator/context.ts +0 -19
- package/llm/orchestrator/index.ts +0 -192
- package/llm/orchestrator/types.ts +0 -14
- package/memory/cache.ts +0 -221
- package/memory/persistent.ts +0 -265
- package/script.js +0 -167
- package/services/cache.ts +0 -298
- package/services/telegram-monitor.ts +0 -138
- package/services/workflow.ts +0 -491
- package/t.py +0 -79
- package/t.ts +0 -25
- package/test/llm/orchestrator.test.ts +0 -47
- package/test/llm/synthesizer.test.ts +0 -31
- package/types.ts +0 -367
- package/utils/schema-generator.ts +0 -73
- package/utils/state-manager.ts +0 -25
- /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
|
-
}
|
@@ -1,73 +0,0 @@
|
|
1
|
-
import { z } from "zod";
|
2
|
-
|
3
|
-
export interface SchemaConfig {
|
4
|
-
schema: z.ZodType;
|
5
|
-
instructions?: string;
|
6
|
-
outputExamples?: {
|
7
|
-
input: string;
|
8
|
-
output: string;
|
9
|
-
}[];
|
10
|
-
}
|
11
|
-
|
12
|
-
export class SchemaGenerator {
|
13
|
-
static generate(config: SchemaConfig): {
|
14
|
-
schema: string;
|
15
|
-
instructions: string;
|
16
|
-
outputExamples: string;
|
17
|
-
} {
|
18
|
-
const {
|
19
|
-
schema,
|
20
|
-
instructions = "Output only the JSON schema, no 'triple quotes'json or any other text. Only the JSON schema.",
|
21
|
-
outputExamples = [],
|
22
|
-
} = config;
|
23
|
-
|
24
|
-
const getSchemaString = (schema: z.ZodType): string => {
|
25
|
-
if (schema instanceof z.ZodObject) {
|
26
|
-
const entries = Object.entries(schema.shape);
|
27
|
-
const fields = entries.map(([key, value]) => {
|
28
|
-
const description = (value as any)._def.description;
|
29
|
-
const schemaStr = getSchemaString(value as z.ZodType);
|
30
|
-
return description
|
31
|
-
? `${key}: ${schemaStr} // ${description}`
|
32
|
-
: `${key}: ${schemaStr}`;
|
33
|
-
});
|
34
|
-
return `z.object({${fields.join(", ")}})`;
|
35
|
-
}
|
36
|
-
|
37
|
-
if (schema instanceof z.ZodArray) {
|
38
|
-
return `z.array(${getSchemaString(schema.element)})`;
|
39
|
-
}
|
40
|
-
|
41
|
-
if (schema instanceof z.ZodString) {
|
42
|
-
return "z.string()";
|
43
|
-
}
|
44
|
-
|
45
|
-
if (schema instanceof z.ZodNumber) {
|
46
|
-
return "z.number()";
|
47
|
-
}
|
48
|
-
|
49
|
-
if (schema instanceof z.ZodBoolean) {
|
50
|
-
return "z.boolean()";
|
51
|
-
}
|
52
|
-
|
53
|
-
// Fallback for other Zod types
|
54
|
-
return `z.unknown()`;
|
55
|
-
};
|
56
|
-
|
57
|
-
const schemaString = getSchemaString(schema);
|
58
|
-
|
59
|
-
return {
|
60
|
-
schema: schemaString,
|
61
|
-
instructions,
|
62
|
-
outputExamples: outputExamples
|
63
|
-
.map(
|
64
|
-
(example) =>
|
65
|
-
`Input: ${JSON.stringify(example.input)}, Output: ${JSON.stringify(
|
66
|
-
example.output
|
67
|
-
)}`
|
68
|
-
)
|
69
|
-
.join("\n")
|
70
|
-
.trim(),
|
71
|
-
};
|
72
|
-
}
|
73
|
-
}
|
package/utils/state-manager.ts
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
import { MyContext, SharedState } from "../types";
|
2
|
-
|
3
|
-
export class StateManager {
|
4
|
-
/**
|
5
|
-
* Updates the shared state while preserving immutability
|
6
|
-
* @param currentState Current shared state
|
7
|
-
* @param updates Partial updates to apply
|
8
|
-
* @returns Updated shared state
|
9
|
-
*/
|
10
|
-
static updateState(
|
11
|
-
currentState: SharedState<MyContext>,
|
12
|
-
updates: Partial<SharedState<MyContext>>
|
13
|
-
): SharedState<MyContext> {
|
14
|
-
const updatedState = {
|
15
|
-
...currentState,
|
16
|
-
...updates,
|
17
|
-
context: {
|
18
|
-
...currentState.context,
|
19
|
-
...(updates.context || {}),
|
20
|
-
},
|
21
|
-
};
|
22
|
-
console.log("🔄 Updated State:", updatedState);
|
23
|
-
return updatedState;
|
24
|
-
}
|
25
|
-
}
|
File without changes
|