@ai.ntellect/core 0.7.1 → 0.7.2

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 (78) hide show
  1. package/dist/graph/controller.d.ts +33 -0
  2. package/dist/graph/controller.d.ts.map +1 -0
  3. package/dist/graph/controller.js +73 -0
  4. package/dist/graph/controller.js.map +1 -0
  5. package/dist/graph/event-manager.d.ts +92 -0
  6. package/dist/graph/event-manager.d.ts.map +1 -0
  7. package/dist/graph/event-manager.js +238 -0
  8. package/dist/graph/event-manager.js.map +1 -0
  9. package/dist/graph/index.d.ts +157 -0
  10. package/dist/graph/index.d.ts.map +1 -0
  11. package/dist/graph/index.js +299 -0
  12. package/dist/graph/index.js.map +1 -0
  13. package/dist/graph/logger.d.ts +46 -0
  14. package/dist/graph/logger.d.ts.map +1 -0
  15. package/dist/graph/logger.js +69 -0
  16. package/dist/graph/logger.js.map +1 -0
  17. package/dist/graph/node.d.ts +103 -0
  18. package/dist/graph/node.d.ts.map +1 -0
  19. package/dist/graph/node.js +310 -0
  20. package/dist/graph/node.js.map +1 -0
  21. package/dist/graph/observer.d.ts +113 -0
  22. package/dist/graph/observer.d.ts.map +1 -0
  23. package/dist/graph/observer.js +197 -0
  24. package/dist/graph/observer.js.map +1 -0
  25. package/dist/index.d.ts +26 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +42 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/interfaces/index.d.ts +447 -0
  30. package/dist/interfaces/index.d.ts.map +1 -0
  31. package/dist/interfaces/index.js +75 -0
  32. package/dist/interfaces/index.js.map +1 -0
  33. package/dist/modules/agenda/adapters/node-cron/index.d.ts +17 -0
  34. package/dist/modules/agenda/adapters/node-cron/index.d.ts.map +1 -0
  35. package/dist/modules/agenda/adapters/node-cron/index.js +30 -0
  36. package/dist/modules/agenda/adapters/node-cron/index.js.map +1 -0
  37. package/dist/modules/agenda/index.d.ts +63 -0
  38. package/dist/modules/agenda/index.d.ts.map +1 -0
  39. package/dist/modules/agenda/index.js +141 -0
  40. package/dist/modules/agenda/index.js.map +1 -0
  41. package/dist/modules/embedding/adapters/ai/index.d.ts +29 -0
  42. package/dist/modules/embedding/adapters/ai/index.d.ts.map +1 -0
  43. package/dist/modules/embedding/adapters/ai/index.js +58 -0
  44. package/dist/modules/embedding/adapters/ai/index.js.map +1 -0
  45. package/dist/modules/embedding/index.d.ts +36 -0
  46. package/dist/modules/embedding/index.d.ts.map +1 -0
  47. package/dist/modules/embedding/index.js +60 -0
  48. package/dist/modules/embedding/index.js.map +1 -0
  49. package/dist/modules/memory/adapters/in-memory/index.d.ts +120 -0
  50. package/dist/modules/memory/adapters/in-memory/index.d.ts.map +1 -0
  51. package/dist/modules/memory/adapters/in-memory/index.js +211 -0
  52. package/dist/modules/memory/adapters/in-memory/index.js.map +1 -0
  53. package/dist/modules/memory/adapters/meilisearch/index.d.ts +110 -0
  54. package/dist/modules/memory/adapters/meilisearch/index.d.ts.map +1 -0
  55. package/dist/modules/memory/adapters/meilisearch/index.js +321 -0
  56. package/dist/modules/memory/adapters/meilisearch/index.js.map +1 -0
  57. package/dist/modules/memory/adapters/redis/index.d.ts +82 -0
  58. package/dist/modules/memory/adapters/redis/index.d.ts.map +1 -0
  59. package/dist/modules/memory/adapters/redis/index.js +159 -0
  60. package/dist/modules/memory/adapters/redis/index.js.map +1 -0
  61. package/dist/modules/memory/index.d.ts +67 -0
  62. package/dist/modules/memory/index.d.ts.map +1 -0
  63. package/dist/modules/memory/index.js +104 -0
  64. package/dist/modules/memory/index.js.map +1 -0
  65. package/dist/types/index.d.ts +166 -0
  66. package/dist/types/index.d.ts.map +1 -0
  67. package/dist/types/index.js +3 -0
  68. package/dist/types/index.js.map +1 -0
  69. package/dist/utils/generate-action-schema.d.ts +5 -0
  70. package/dist/utils/generate-action-schema.d.ts.map +1 -0
  71. package/dist/utils/generate-action-schema.js +44 -0
  72. package/dist/utils/generate-action-schema.js.map +1 -0
  73. package/dist/utils/header-builder.d.ts +12 -0
  74. package/dist/utils/header-builder.d.ts.map +1 -0
  75. package/dist/utils/header-builder.js +35 -0
  76. package/dist/utils/header-builder.js.map +1 -0
  77. package/package.json +3 -1
  78. package/tsconfig.json +13 -2
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GraphNode = void 0;
13
+ /**
14
+ * Represents a node in the graph that can execute operations and manage state
15
+ * @template T - The Zod schema type for validation
16
+ */
17
+ class GraphNode {
18
+ /**
19
+ * Creates a new GraphNode instance
20
+ * @param nodes - Map of all nodes in the graph
21
+ * @param logger - Logger instance for tracking node operations
22
+ * @param eventManager - Manager for handling graph events
23
+ * @param eventSubject - Subject for emitting events
24
+ * @param stateSubject - Subject for managing graph state
25
+ */
26
+ constructor(nodes, logger, eventManager, eventSubject, stateSubject) {
27
+ this.nodes = nodes;
28
+ this.logger = logger;
29
+ this.eventManager = eventManager;
30
+ this.eventSubject = eventSubject;
31
+ this.stateSubject = stateSubject;
32
+ }
33
+ /**
34
+ * Emits an event with the specified type and payload
35
+ * @param type - The type of event to emit
36
+ * @param payload - The data associated with the event
37
+ * @private
38
+ */
39
+ emitEvent(type, payload) {
40
+ this.logger.addLog(`📢 Event: ${type}`);
41
+ const event = {
42
+ type,
43
+ payload: Object.assign(Object.assign({}, payload), { name: type === "nodeStateChanged"
44
+ ? payload.name || payload.nodeName
45
+ : payload.name, context: Object.assign({}, payload.context) }),
46
+ timestamp: Date.now(),
47
+ };
48
+ this.eventSubject.next(event);
49
+ this.eventManager.emitEvent(type, event);
50
+ // Update state subject only for state changes
51
+ if (type === "nodeStateChanged") {
52
+ this.stateSubject.next(Object.assign({}, payload.context));
53
+ }
54
+ }
55
+ /**
56
+ * Executes a node with the given name and context
57
+ * @param nodeName - The name of the node to execute
58
+ * @param context - The current graph context
59
+ * @param inputs - Input data for the node
60
+ * @param triggeredByEvent - Whether the execution was triggered by an event
61
+ * @throws Error if the node is not found or execution fails
62
+ */
63
+ executeNode(nodeName_1, context_1, inputs_1) {
64
+ return __awaiter(this, arguments, void 0, function* (nodeName, context, inputs, triggeredByEvent = false) {
65
+ const node = this.nodes.get(nodeName);
66
+ if (!node)
67
+ throw new Error(`Node "${nodeName}" not found.`);
68
+ this.logger.addLog(`🚀 Starting node "${nodeName}"`);
69
+ this.emitEvent("nodeStarted", { name: nodeName, context: Object.assign({}, context) });
70
+ try {
71
+ const contextProxy = new Proxy(context, {
72
+ set: (target, prop, value) => {
73
+ const oldValue = target[prop];
74
+ target[prop] = value;
75
+ this.emitEvent("nodeStateChanged", {
76
+ nodeName,
77
+ name: nodeName,
78
+ property: prop.toString(),
79
+ oldValue,
80
+ newValue: value,
81
+ context: Object.assign({}, target),
82
+ });
83
+ return true;
84
+ },
85
+ get: (target, prop) => {
86
+ return target[prop];
87
+ },
88
+ });
89
+ if (node.condition && !node.condition(contextProxy)) {
90
+ this.logger.addLog(`⏭️ Skipping node "${nodeName}" - condition not met`);
91
+ return;
92
+ }
93
+ if (node.inputs) {
94
+ yield this.validateInputs(node, inputs, nodeName);
95
+ }
96
+ if (node.retry && node.retry.maxAttempts > 0) {
97
+ yield this.executeWithRetry(node, contextProxy, inputs, nodeName);
98
+ }
99
+ else {
100
+ yield node.execute(contextProxy, inputs);
101
+ }
102
+ if (node.outputs) {
103
+ yield this.validateOutputs(node, contextProxy, nodeName);
104
+ }
105
+ if (!triggeredByEvent) {
106
+ const nextNodes = typeof node.next === "function"
107
+ ? node.next(contextProxy)
108
+ : node.next || [];
109
+ for (const nextNodeName of nextNodes) {
110
+ const nextNode = this.nodes.get(nextNodeName);
111
+ if (nextNode &&
112
+ (!nextNode.condition || nextNode.condition(contextProxy))) {
113
+ yield this.executeNode(nextNodeName, contextProxy, undefined, false);
114
+ }
115
+ }
116
+ }
117
+ if (!triggeredByEvent) {
118
+ yield this.handleEvents(node, nodeName, contextProxy);
119
+ }
120
+ this.logger.addLog(`✅ Node "${nodeName}" executed successfully`);
121
+ this.emitEvent("nodeCompleted", {
122
+ name: nodeName,
123
+ context: Object.assign({}, contextProxy),
124
+ });
125
+ }
126
+ catch (error) {
127
+ const errorToThrow = error instanceof Error
128
+ ? error
129
+ : new Error(error.message || "Unknown error");
130
+ this.logger.addLog(`❌ Error in node "${nodeName}": ${errorToThrow.message}`);
131
+ this.emitEvent("nodeError", {
132
+ name: nodeName,
133
+ error: errorToThrow,
134
+ context,
135
+ });
136
+ throw errorToThrow;
137
+ }
138
+ });
139
+ }
140
+ /**
141
+ * Validates the inputs for a node using its schema
142
+ * @param node - The node whose inputs need validation
143
+ * @param inputs - The input data to validate
144
+ * @param nodeName - The name of the node (for error messages)
145
+ * @throws Error if validation fails
146
+ * @private
147
+ */
148
+ validateInputs(node, inputs, nodeName) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ var _a, _b;
151
+ if (!inputs) {
152
+ throw new Error(`Inputs required for node "${nodeName}"`);
153
+ }
154
+ try {
155
+ return node.inputs.parse(inputs);
156
+ }
157
+ catch (error) {
158
+ throw new Error(((_b = (_a = error.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || error.message || "Input validation failed");
159
+ }
160
+ });
161
+ }
162
+ /**
163
+ * Validates the outputs of a node against its schema
164
+ * @param node - The node whose outputs need validation
165
+ * @param context - The current graph context
166
+ * @param nodeName - The name of the node (for error messages)
167
+ * @throws Error if validation fails
168
+ * @private
169
+ */
170
+ validateOutputs(node, context, nodeName) {
171
+ return __awaiter(this, void 0, void 0, function* () {
172
+ var _a, _b;
173
+ try {
174
+ node.outputs.parse(context);
175
+ }
176
+ catch (error) {
177
+ throw new Error(((_b = (_a = error.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) ||
178
+ error.message ||
179
+ "Output validation failed");
180
+ }
181
+ });
182
+ }
183
+ /**
184
+ * Handles event-related operations for a node
185
+ * @param node - The node whose events need handling
186
+ * @param nodeName - The name of the node
187
+ * @param context - The current graph context
188
+ * @private
189
+ */
190
+ handleEvents(node, nodeName, context) {
191
+ return __awaiter(this, void 0, void 0, function* () {
192
+ if (node.correlateEvents) {
193
+ yield this.handleCorrelatedEvents(node, nodeName);
194
+ }
195
+ if (node.waitForEvents) {
196
+ yield this.handleWaitForEvents(node, nodeName);
197
+ }
198
+ });
199
+ }
200
+ /**
201
+ * Executes a node with retry logic
202
+ * @param node - The node to execute
203
+ * @param contextProxy - The proxied graph context
204
+ * @param inputs - Input data for the node
205
+ * @param nodeName - The name of the node
206
+ * @throws Error if all retry attempts fail
207
+ * @private
208
+ */
209
+ executeWithRetry(node, contextProxy, inputs, nodeName) {
210
+ return __awaiter(this, void 0, void 0, function* () {
211
+ let attempts = 0;
212
+ let lastError = null;
213
+ while (attempts < node.retry.maxAttempts) {
214
+ try {
215
+ this.logger.addLog(`🔄 Attempt ${attempts + 1}/${node.retry.maxAttempts}`);
216
+ yield node.execute(contextProxy, inputs);
217
+ return;
218
+ }
219
+ catch (error) {
220
+ lastError = error instanceof Error ? error : new Error(error.message);
221
+ attempts++;
222
+ this.logger.addLog(`❌ Attempt ${attempts} failed: ${lastError.message}`);
223
+ if (attempts === node.retry.maxAttempts) {
224
+ if (node.retry.onRetryFailed && lastError) {
225
+ yield this.handleRetryFailure(node, lastError, contextProxy, nodeName);
226
+ }
227
+ throw lastError;
228
+ }
229
+ yield new Promise((resolve) => { var _a; return setTimeout(resolve, ((_a = node.retry) === null || _a === void 0 ? void 0 : _a.delay) || 0); });
230
+ }
231
+ }
232
+ });
233
+ }
234
+ /**
235
+ * Handles the failure of retry attempts
236
+ * @param node - The node that failed
237
+ * @param error - The error that caused the failure
238
+ * @param context - The current graph context
239
+ * @param nodeName - The name of the node
240
+ * @private
241
+ */
242
+ handleRetryFailure(node, error, context, nodeName) {
243
+ return __awaiter(this, void 0, void 0, function* () {
244
+ var _a;
245
+ this.logger.addLog(`🔄 Executing retry failure handler for node "${nodeName}"`);
246
+ try {
247
+ if ((_a = node.retry) === null || _a === void 0 ? void 0 : _a.onRetryFailed) {
248
+ yield node.retry.onRetryFailed(error, context);
249
+ if (node.retry.continueOnFailed) {
250
+ this.logger.addLog(`✅ Retry failure handler succeeded - continuing execution`);
251
+ return;
252
+ }
253
+ this.logger.addLog(`⚠️ Retry failure handler executed but node will still fail`);
254
+ }
255
+ }
256
+ catch (handlerError) {
257
+ this.logger.addLog(`❌ Retry failure handler failed: ${handlerError.message}`);
258
+ throw handlerError;
259
+ }
260
+ });
261
+ }
262
+ /**
263
+ * Handles correlated events for a node
264
+ * @param node - The node with correlated events
265
+ * @param nodeName - The name of the node
266
+ * @throws Error if correlation fails or timeout occurs
267
+ * @private
268
+ */
269
+ handleCorrelatedEvents(node, nodeName) {
270
+ return __awaiter(this, void 0, void 0, function* () {
271
+ if (node.correlateEvents) {
272
+ const { events, timeout, correlation } = node.correlateEvents;
273
+ this.logger.addLog(`⏳ Node "${nodeName}" waiting for correlated events: ${events.join(", ")}`);
274
+ try {
275
+ // Attendre les événements
276
+ const receivedEvents = yield this.eventManager.waitForEvents(events, timeout);
277
+ // Vérifier la corrélation
278
+ if (!correlation(receivedEvents)) {
279
+ this.logger.addLog(`❌ Event correlation failed for node "${nodeName}"`);
280
+ throw new Error(`Event correlation failed for node "${nodeName}"`);
281
+ }
282
+ this.logger.addLog(`✅ Event correlation succeeded for node "${nodeName}"`);
283
+ }
284
+ catch (error) {
285
+ this.logger.addLog(`❌ Error waiting for events: ${error.message}`);
286
+ throw error;
287
+ }
288
+ }
289
+ });
290
+ }
291
+ /**
292
+ * Handles waiting for events
293
+ * @param node - The node waiting for events
294
+ * @param nodeName - The name of the node
295
+ * @throws Error if timeout occurs
296
+ * @private
297
+ */
298
+ handleWaitForEvents(node, nodeName) {
299
+ return __awaiter(this, void 0, void 0, function* () {
300
+ if (node.waitForEvents) {
301
+ const { events, timeout } = node.waitForEvents;
302
+ this.logger.addLog(`⏳ Node "${nodeName}" waiting for events: ${events.join(", ")}`);
303
+ yield this.eventManager.waitForEvents(events, timeout);
304
+ this.logger.addLog(`✅ All events received for node "${nodeName}"`);
305
+ }
306
+ });
307
+ }
308
+ }
309
+ exports.GraphNode = GraphNode;
310
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../graph/node.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA;;;GAGG;AACH,MAAa,SAAS;IACpB;;;;;;;OAOG;IACH,YACU,KAAgC,EAChC,MAAmB,EACnB,YAAkC,EAClC,YAAoC,EACpC,YAA8C;QAJ9C,UAAK,GAAL,KAAK,CAA2B;QAChC,WAAM,GAAN,MAAM,CAAa;QACnB,iBAAY,GAAZ,YAAY,CAAsB;QAClC,iBAAY,GAAZ,YAAY,CAAwB;QACpC,iBAAY,GAAZ,YAAY,CAAkC;IACrD,CAAC;IAEJ;;;;;OAKG;IACK,SAAS,CAAC,IAAY,EAAE,OAAY;QAC1C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;QACxC,MAAM,KAAK,GAAG;YACZ,IAAI;YACJ,OAAO,kCACF,OAAO,KACV,IAAI,EACF,IAAI,KAAK,kBAAkB;oBACzB,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,QAAQ;oBAClC,CAAC,CAAC,OAAO,CAAC,IAAI,EAClB,OAAO,oBAAO,OAAO,CAAC,OAAO,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,GAAG,CAAC,CAAC;oBACrE,CAAC;oBAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAChB,2CAA2C,QAAQ,GAAG,CACvD,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAI,CAAC,MAAM,CAAC,MAAM,CAChB,+BAAgC,KAAe,CAAC,OAAO,EAAE,CAC1D,CAAC;oBACF,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;KAAA;IAED;;;;;;OAMG;IACW,mBAAmB,CAC/B,IAAkB,EAClB,QAAgB;;YAEhB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACvB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;gBAC/C,IAAI,CAAC,MAAM,CAAC,MAAM,CAChB,WAAW,QAAQ,yBAAyB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAChE,CAAC;gBACF,MAAM,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACvD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,mCAAmC,QAAQ,GAAG,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;KAAA;CACF;AAnYD,8BAmYC"}
@@ -0,0 +1,113 @@
1
+ import { BehaviorSubject, Observable, Subject } from "rxjs";
2
+ import { ZodSchema } from "zod";
3
+ import { GraphObservable } from "../interfaces";
4
+ import { GraphContext, GraphEvent } from "../types";
5
+ import { GraphFlow } from "./index";
6
+ /**
7
+ * GraphObserver class provides reactive observation capabilities for a GraphFlow instance
8
+ * It allows monitoring state changes, node updates, and specific events in the graph
9
+ * @template T - The Zod schema type that defines the structure of the graph data
10
+ */
11
+ export declare class GraphObserver<T extends ZodSchema> {
12
+ private graph;
13
+ private eventSubject;
14
+ private stateSubject;
15
+ private destroySubject;
16
+ constructor(graph: GraphFlow<T>, eventSubject: Subject<GraphEvent<T>>, stateSubject: BehaviorSubject<GraphContext<T>>, destroySubject: Subject<void>);
17
+ /**
18
+ * Observes the entire graph state changes
19
+ * @param options Configuration options for the observation
20
+ * @param options.debounce Debounce time in milliseconds
21
+ * @param options.delay Delay between emissions in milliseconds
22
+ * @param options.stream If true, streams the specified properties letter by letter
23
+ * @param options.properties List of properties to stream
24
+ * @param options.onStreamLetter Callback for each letter emitted during streaming
25
+ * @param options.onStreamComplete Callback when streaming is complete
26
+ * @returns An Observable that emits the complete graph context whenever it changes
27
+ */
28
+ state(options?: {
29
+ debounce?: number;
30
+ delay?: number;
31
+ stream?: boolean;
32
+ properties?: (keyof GraphContext<T>)[];
33
+ onStreamLetter?: (data: {
34
+ letter: string;
35
+ property: string;
36
+ }) => void;
37
+ onStreamComplete?: () => void;
38
+ }): GraphObservable<T>;
39
+ /**
40
+ * Observes state changes for a specific node
41
+ * @param name - The name of the node to observe
42
+ * @returns An Observable that emits the graph context when the specified node changes
43
+ */
44
+ node(name: string): Observable<GraphContext<T>>;
45
+ /**
46
+ * Observes state changes for multiple nodes
47
+ * @param names - Array of node names to observe
48
+ * @returns An Observable that emits the graph context when any of the specified nodes change
49
+ */
50
+ nodes(names: string[]): Observable<GraphContext<T>>;
51
+ /**
52
+ * Observes specific properties of the graph context
53
+ * @param keys - Single or multiple property keys to observe
54
+ * @returns An Observable that emits an object containing only the specified properties
55
+ * @template K - The key of the property to observe from GraphContext<T>
56
+ */
57
+ property<K extends keyof GraphContext<T>>(keys: K | K[]): Observable<{
58
+ [P in K]: GraphContext<T>[P];
59
+ } & {
60
+ name: string;
61
+ }>;
62
+ /**
63
+ * Observes specific events in the graph
64
+ * @param type - The type of event to observe
65
+ * @returns An Observable that emits events of the specified type
66
+ */
67
+ event(type: string): Observable<GraphEvent<T>>;
68
+ /**
69
+ * Waits for a specific condition to be met on an observable
70
+ * @param observable - The Observable to watch
71
+ * @param predicate - A function that returns true when the desired condition is met
72
+ * @returns A Promise that resolves with the value when the predicate returns true
73
+ * @template R - The type of value emitted by the observable
74
+ */
75
+ until<R>(observable: Observable<R>, predicate: (value: R) => boolean): Promise<R>;
76
+ /**
77
+ * Waits for correlated events to occur and validates them using a correlation function
78
+ * @param eventTypes - Array of event types to wait for
79
+ * @param timeoutMs - Timeout duration in milliseconds
80
+ * @param correlationFn - Function to validate the correlation between events
81
+ * @returns Promise that resolves when all correlated events are received
82
+ */
83
+ waitForCorrelatedEvents(eventTypes: string[], timeoutMs: number, correlationFn: (events: GraphEvent<T>[]) => boolean): Promise<GraphEvent<T>[]>;
84
+ /**
85
+ * Observes the current state of the graph
86
+ * @returns Observable that emits the current graph context
87
+ */
88
+ observeState(): Observable<GraphContext<T>>;
89
+ /**
90
+ * Observes specific event types in the graph
91
+ * @param eventType - The type of event to observe
92
+ * @returns Observable that emits events of the specified type
93
+ */
94
+ observeEvents(eventType: string): Observable<GraphEvent<T>>;
95
+ /**
96
+ * Observes state changes for a specific node
97
+ * @param nodeName - The name of the node to observe
98
+ * @returns Observable that emits the graph context when the specified node changes
99
+ */
100
+ observeNodeState(nodeName: string): Observable<GraphContext<T>>;
101
+ /**
102
+ * Streams a message letter by letter with a specified delay
103
+ * @param message - The message to stream
104
+ * @param delayMs - The delay in milliseconds between each letter
105
+ * @param property - The property name being streamed
106
+ * @returns An Observable that emits each letter of the message along with its property
107
+ */
108
+ streamMessage(message: string, delayMs: number, property: string): Observable<{
109
+ letter: string;
110
+ property: string;
111
+ }>;
112
+ }
113
+ //# sourceMappingURL=observer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../../graph/observer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,OAAO,EAGR,MAAM,MAAM,CAAC;AAWd,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,C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AAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAoClE;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAS9C;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,EACL,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAC/B,OAAO,CAAC,CAAC,CAAC;IAab;;;;;;OAMG;IACH,uBAAuB,CACrB,UAAU,EAAE,MAAM,EAAE,EACpB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,GAClD,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IA0B3B;;;OAGG;IACH,YAAY,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAS3C;;;;OAIG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAO3D;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAW/D;;;;;;OAMG;IACH,aAAa,CACX,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,UAAU,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAcpD"}
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphObserver = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ /**
7
+ * GraphObserver class provides reactive observation capabilities for a GraphFlow instance
8
+ * It allows monitoring state changes, node updates, and specific events in the graph
9
+ * @template T - The Zod schema type that defines the structure of the graph data
10
+ */
11
+ class GraphObserver {
12
+ constructor(graph, eventSubject, stateSubject, destroySubject) {
13
+ this.graph = graph;
14
+ this.eventSubject = eventSubject;
15
+ this.stateSubject = stateSubject;
16
+ this.destroySubject = destroySubject;
17
+ }
18
+ /**
19
+ * Observes the entire graph state changes
20
+ * @param options Configuration options for the observation
21
+ * @param options.debounce Debounce time in milliseconds
22
+ * @param options.delay Delay between emissions in milliseconds
23
+ * @param options.stream If true, streams the specified properties letter by letter
24
+ * @param options.properties List of properties to stream
25
+ * @param options.onStreamLetter Callback for each letter emitted during streaming
26
+ * @param options.onStreamComplete Callback when streaming is complete
27
+ * @returns An Observable that emits the complete graph context whenever it changes
28
+ */
29
+ state(options = {}) {
30
+ const baseObservable = new rxjs_1.Observable((subscriber) => {
31
+ const subscription = this.eventSubject
32
+ .pipe((0, operators_1.filter)((event) => event.type === "nodeStateChanged" ||
33
+ event.type === "nodeStarted" ||
34
+ event.type === "nodeCompleted"), (0, operators_1.map)((event) => event.payload.context), (0, operators_1.startWith)(this.stateSubject.getValue()), (0, operators_1.distinctUntilChanged)((prev, curr) => JSON.stringify(prev) === JSON.stringify(curr)))
35
+ .subscribe(subscriber);
36
+ // Stream the specified properties if specified
37
+ if (options.stream && options.properties) {
38
+ const context = this.stateSubject.getValue();
39
+ options.properties.forEach((property) => {
40
+ const message = context[property];
41
+ if (message) {
42
+ this.streamMessage(message.toString(), 500, property).subscribe({
43
+ next: (data) => { var _a; return (_a = options.onStreamLetter) === null || _a === void 0 ? void 0 : _a.call(options, data); },
44
+ complete: () => { var _a; return (_a = options.onStreamComplete) === null || _a === void 0 ? void 0 : _a.call(options); },
45
+ });
46
+ }
47
+ });
48
+ }
49
+ return () => subscription.unsubscribe();
50
+ });
51
+ // Extend the observable with our custom methods
52
+ return Object.assign(baseObservable, {
53
+ state: () => this.stateSubject.asObservable(),
54
+ node: (nodeName) => this.stateSubject.pipe((0, operators_1.map)((state) => (Object.assign(Object.assign({}, state), { nodeName })))),
55
+ nodes: (nodeNames) => this.eventSubject.pipe((0, operators_1.filter)((event) => {
56
+ var _a, _b;
57
+ return event.type === "nodeStateChanged" &&
58
+ nodeNames.includes((_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "");
59
+ }), (0, operators_1.map)((event) => event.payload.context), (0, operators_1.distinctUntilChanged)((prev, curr) => JSON.stringify(prev) === JSON.stringify(curr)), (0, operators_1.takeUntil)(this.destroySubject), (0, operators_1.share)()),
60
+ property: (props) => this.stateSubject.pipe((0, operators_1.map)((state) => {
61
+ const properties = Array.isArray(props) ? props : [props];
62
+ return properties.reduce((acc, prop) => (Object.assign(Object.assign({}, acc), { [prop]: state[prop] })), {});
63
+ })),
64
+ event: (eventName) => this.eventSubject.pipe((0, operators_1.filter)((event) => event.type === eventName)),
65
+ until: (observable, predicate) => (0, rxjs_1.firstValueFrom)(observable.pipe((0, operators_1.filter)(predicate), (0, operators_1.take)(1))),
66
+ });
67
+ }
68
+ /**
69
+ * Observes state changes for a specific node
70
+ * @param name - The name of the node to observe
71
+ * @returns An Observable that emits the graph context when the specified node changes
72
+ */
73
+ node(name) {
74
+ return this.eventSubject.pipe((0, operators_1.filter)((event) => { var _a; return event.type === "nodeStateChanged" && ((_a = event.payload) === null || _a === void 0 ? void 0 : _a.name) === name; }), (0, operators_1.map)((event) => event.payload.context), (0, operators_1.distinctUntilChanged)((prev, curr) => JSON.stringify(prev) === JSON.stringify(curr)), (0, operators_1.takeUntil)(this.destroySubject), (0, operators_1.share)());
75
+ }
76
+ /**
77
+ * Observes state changes for multiple nodes
78
+ * @param names - Array of node names to observe
79
+ * @returns An Observable that emits the graph context when any of the specified nodes change
80
+ */
81
+ nodes(names) {
82
+ return this.eventSubject.pipe((0, operators_1.filter)((event) => {
83
+ var _a, _b;
84
+ return names.includes((_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "") &&
85
+ event.type === "nodeStateChanged";
86
+ }), (0, operators_1.map)(() => this.graph.getContext()), (0, operators_1.distinctUntilChanged)((prev, curr) => JSON.stringify(prev) === JSON.stringify(curr)), (0, operators_1.takeUntil)(this.destroySubject), (0, operators_1.share)());
87
+ }
88
+ /**
89
+ * Observes specific properties of the graph context
90
+ * @param keys - Single or multiple property keys to observe
91
+ * @returns An Observable that emits an object containing only the specified properties
92
+ * @template K - The key of the property to observe from GraphContext<T>
93
+ */
94
+ property(keys) {
95
+ const properties = Array.isArray(keys) ? keys : [keys];
96
+ return this.eventSubject.pipe((0, operators_1.filter)((event) => event.type === "nodeStateChanged" &&
97
+ properties.some((key) => { var _a; return ((_a = event.payload) === null || _a === void 0 ? void 0 : _a.property) === key; })), (0, operators_1.map)((event) => (Object.assign(Object.assign({}, properties.reduce((obj, key) => (Object.assign(Object.assign({}, obj), { [key]: event.payload.context[key] })), {})), { name: event.payload.name }))), (0, operators_1.startWith)(Object.assign(Object.assign({}, properties.reduce((obj, key) => (Object.assign(Object.assign({}, obj), { [key]: this.stateSubject.value[key] })), {})), { name: "initial" })), (0, operators_1.distinctUntilChanged)((prev, curr) => JSON.stringify(prev) === JSON.stringify(curr)), (0, operators_1.share)());
98
+ }
99
+ /**
100
+ * Observes specific events in the graph
101
+ * @param type - The type of event to observe
102
+ * @returns An Observable that emits events of the specified type
103
+ */
104
+ event(type) {
105
+ return this.eventSubject.pipe((0, operators_1.filter)((event) => event.type === type), (0, operators_1.map)((event) => event), (0, operators_1.takeUntil)(this.destroySubject), (0, operators_1.share)());
106
+ }
107
+ /**
108
+ * Waits for a specific condition to be met on an observable
109
+ * @param observable - The Observable to watch
110
+ * @param predicate - A function that returns true when the desired condition is met
111
+ * @returns A Promise that resolves with the value when the predicate returns true
112
+ * @template R - The type of value emitted by the observable
113
+ */
114
+ until(observable, predicate) {
115
+ return new Promise((resolve) => {
116
+ const subscription = observable.subscribe({
117
+ next: (value) => {
118
+ if (predicate(value)) {
119
+ subscription.unsubscribe();
120
+ resolve(value);
121
+ }
122
+ },
123
+ });
124
+ });
125
+ }
126
+ /**
127
+ * Waits for correlated events to occur and validates them using a correlation function
128
+ * @param eventTypes - Array of event types to wait for
129
+ * @param timeoutMs - Timeout duration in milliseconds
130
+ * @param correlationFn - Function to validate the correlation between events
131
+ * @returns Promise that resolves when all correlated events are received
132
+ */
133
+ waitForCorrelatedEvents(eventTypes, timeoutMs, correlationFn) {
134
+ return new Promise((resolve, reject) => {
135
+ const eventObservables = eventTypes.map((eventType) => this.eventSubject.pipe((0, operators_1.filter)((event) => {
136
+ return event.type === eventType && "timestamp" in event;
137
+ }), (0, operators_1.take)(1)));
138
+ (0, rxjs_1.combineLatest)(eventObservables)
139
+ .pipe((0, operators_1.timeout)(timeoutMs), (0, operators_1.take)(1))
140
+ .subscribe({
141
+ next: (events) => {
142
+ if (correlationFn(events)) {
143
+ resolve(events);
144
+ }
145
+ else {
146
+ reject(new Error(`Correlation validation failed`));
147
+ }
148
+ },
149
+ error: (error) => reject(error),
150
+ });
151
+ });
152
+ }
153
+ /**
154
+ * Observes the current state of the graph
155
+ * @returns Observable that emits the current graph context
156
+ */
157
+ observeState() {
158
+ return this.stateSubject.asObservable().pipe((0, operators_1.takeUntil)(this.destroySubject), (0, operators_1.distinctUntilChanged)((prev, curr) => JSON.stringify(prev) === JSON.stringify(curr)));
159
+ }
160
+ /**
161
+ * Observes specific event types in the graph
162
+ * @param eventType - The type of event to observe
163
+ * @returns Observable that emits events of the specified type
164
+ */
165
+ observeEvents(eventType) {
166
+ return this.eventSubject.asObservable().pipe((0, operators_1.takeUntil)(this.destroySubject), (0, operators_1.filter)((event) => event.type === eventType));
167
+ }
168
+ /**
169
+ * Observes state changes for a specific node
170
+ * @param nodeName - The name of the node to observe
171
+ * @returns Observable that emits the graph context when the specified node changes
172
+ */
173
+ observeNodeState(nodeName) {
174
+ return this.eventSubject.asObservable().pipe((0, operators_1.takeUntil)(this.destroySubject), (0, operators_1.filter)((event) => { var _a; return event.type === "nodeStateChanged" && ((_a = event.payload) === null || _a === void 0 ? void 0 : _a.name) === nodeName; }), (0, operators_1.map)(() => this.stateSubject.value));
175
+ }
176
+ /**
177
+ * Streams a message letter by letter with a specified delay
178
+ * @param message - The message to stream
179
+ * @param delayMs - The delay in milliseconds between each letter
180
+ * @param property - The property name being streamed
181
+ * @returns An Observable that emits each letter of the message along with its property
182
+ */
183
+ streamMessage(message, delayMs, property) {
184
+ return new rxjs_1.Observable((subscriber) => {
185
+ for (let i = 0; i < message.length; i++) {
186
+ setTimeout(() => {
187
+ subscriber.next({ letter: message[i], property });
188
+ if (i === message.length - 1) {
189
+ subscriber.complete();
190
+ }
191
+ }, i * delayMs);
192
+ }
193
+ });
194
+ }
195
+ }
196
+ exports.GraphObserver = GraphObserver;
197
+ //# sourceMappingURL=observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observer.js","sourceRoot":"","sources":["../../graph/observer.ts"],"names":[],"mappings":";;;AAAA,+BAMc;AACd,8CASwB;AAMxB;;;;GAIG;AACH,MAAa,aAAa;IACxB,YACU,KAAmB,EACnB,YAAoC,EACpC,YAA8C,EAC9C,cAA6B;QAH7B,UAAK,GAAL,KAAK,CAAc;QACnB,iBAAY,GAAZ,YAAY,CAAwB;QACpC,iBAAY,GAAZ,YAAY,CAAkC;QAC9C,mBAAc,GAAd,cAAc,CAAe;IACpC,CAAC;IAEJ;;;;;;;;;;OAUG;IACH,KAAK,CACH,UAOI,EAAE;QAEN,MAAM,cAAc,GAAG,IAAI,iBAAU,CAAM,CAAC,UAAU,EAAE,EAAE;YACxD,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY;iBACnC,IAAI,CACH,IAAA,kBAAM,EACJ,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,IAAI,KAAK,kBAAkB;gBACjC,KAAK,CAAC,IAAI,KAAK,aAAa;gBAC5B,KAAK,CAAC,IAA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