graphai 0.6.5 → 0.6.7

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/lib/graphai.js CHANGED
@@ -22,7 +22,6 @@ class GraphAI {
22
22
  else {
23
23
  _nodes[nodeId] = new node_1.StaticNode(nodeId, nodeData, this);
24
24
  }
25
- // throw new Error("Unknown node type (neither value nor agent): " + nodeId);
26
25
  return _nodes;
27
26
  }, {});
28
27
  // Generate the waitlist for each node.
@@ -197,7 +196,7 @@ class GraphAI {
197
196
  throw new Error("Static node must have value. Set value or injectValue or set update");
198
197
  }
199
198
  if (this.isRunning()) {
200
- throw new Error("This GraphUI instance is already running");
199
+ throw new Error("This GraphAI instance is already running");
201
200
  }
202
201
  this.pushReadyNodesIntoQueue();
203
202
  if (!this.isRunning()) {
@@ -250,14 +249,23 @@ class GraphAI {
250
249
  return false; // while condition is not met
251
250
  }
252
251
  }
253
- this.nodes = this.createNodes(this.data);
254
- this.initializeStaticNodes();
252
+ this.initializeGraphAI();
255
253
  this.updateStaticNodes(previousResults, true);
256
254
  this.pushReadyNodesIntoQueue();
257
255
  return true; // Indicating that we are going to continue.
258
256
  }
259
257
  return false;
260
258
  }
259
+ initializeGraphAI() {
260
+ if (this.isRunning()) {
261
+ throw new Error("This GraphAI instance is running");
262
+ }
263
+ this.nodes = this.createNodes(this.data);
264
+ this.initializeStaticNodes();
265
+ }
266
+ setPreviousResults(previousResults) {
267
+ this.updateStaticNodes(previousResults);
268
+ }
261
269
  setLoopLog(log) {
262
270
  log.isLoop = !!this.loop;
263
271
  log.repeatCount = this.repeatCount;
package/lib/node.js CHANGED
@@ -32,11 +32,19 @@ class Node {
32
32
  });
33
33
  }
34
34
  afterConsoleLog(result) {
35
- if (this.console === true || this.console.after === true) {
35
+ if (this.console === false) {
36
+ return;
37
+ }
38
+ else if (this.console === true || this.console.after === true) {
36
39
  console.log(typeof result === "string" ? result : JSON.stringify(result, null, 2));
37
40
  }
38
41
  else if (this.console.after) {
39
- console.log(this.console.after);
42
+ if ((0, utils_2.isObject)(this.console.after)) {
43
+ console.log(JSON.stringify((0, result_1.resultsOf)(this.console.after, { self: this }, this.graph.propFunctions, true), null, 2));
44
+ }
45
+ else {
46
+ console.log(this.console.after);
47
+ }
40
48
  }
41
49
  }
42
50
  }
@@ -329,7 +337,10 @@ class ComputedNode extends Node {
329
337
  };
330
338
  }
331
339
  beforeConsoleLog(context) {
332
- if (this.console === true || this.console.before === true) {
340
+ if (this.console === false) {
341
+ return;
342
+ }
343
+ else if (this.console === true || this.console.before === true) {
333
344
  console.log(JSON.stringify(context.namedInputs, null, 2));
334
345
  }
335
346
  else if (this.console.before) {
package/lib/type.d.ts CHANGED
@@ -23,8 +23,8 @@ export type DataSource = {
23
23
  value?: any;
24
24
  propIds?: string[];
25
25
  };
26
- type ConsoleAttribute = true | string | Record<string, any>;
27
- export type ConsoleElement = true | {
26
+ type ConsoleAttribute = boolean | string | Record<string, any>;
27
+ export type ConsoleElement = boolean | {
28
28
  before?: ConsoleAttribute;
29
29
  after?: ConsoleAttribute;
30
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphai",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "Asynchronous data flow execution engine for agentic AI apps.",
5
5
  "main": "lib/bundle.cjs.js",
6
6
  "module": "lib/bundle.esm.js",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/receptron/graphai#readme",
29
29
  "devDependencies": {
30
- "typedoc": "^0.27.3"
30
+ "typedoc": "^0.27.4"
31
31
  },
32
32
  "types": "./lib/index.d.ts",
33
33
  "directories": {