graphai 0.6.20 → 0.6.22

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/node.js CHANGED
@@ -126,13 +126,16 @@ class ComputedNode extends Node {
126
126
  this.pendings.add(source.nodeId);
127
127
  return source;
128
128
  }
129
+ updateState(state) {
130
+ this.state = state;
131
+ if (this.debugInfo) {
132
+ this.debugInfo.state = state;
133
+ }
134
+ }
129
135
  resetPending() {
130
136
  this.pendings.clear();
131
137
  if (this.state === type_1.NodeState.Executing) {
132
- this.state = type_1.NodeState.Abort;
133
- if (this.debugInfo) {
134
- this.debugInfo.state = type_1.NodeState.Abort;
135
- }
138
+ this.updateState(type_1.NodeState.Abort);
136
139
  }
137
140
  if (this.debugInfo && this.debugInfo.subGraphs) {
138
141
  this.debugInfo.subGraphs.forEach((graph) => graph.abort());
@@ -145,7 +148,7 @@ class ComputedNode extends Node {
145
148
  this.isSkip = !!((this.ifSource && !(0, utils_2.isLogicallyTrue)(this.graph.resultOf(this.ifSource))) ||
146
149
  (this.unlessSource && (0, utils_2.isLogicallyTrue)(this.graph.resultOf(this.unlessSource))));
147
150
  if (this.isSkip && this.defaultValue === undefined) {
148
- this.state = type_1.NodeState.Skipped;
151
+ this.updateState(type_1.NodeState.Skipped);
149
152
  this.log.onSkipped(this, this.graph);
150
153
  return false;
151
154
  }
@@ -155,7 +158,7 @@ class ComputedNode extends Node {
155
158
  // the "retry" if specified. The transaction log must be updated before
156
159
  // callling this method.
157
160
  retry(state, error) {
158
- this.state = state; // this.execute() will update to NodeState.Executing
161
+ this.updateState(state); // this.execute() will update to NodeState.Executing
159
162
  this.log.onError(this, this.graph, error.message);
160
163
  if (this.retryCount < this.retryLimit) {
161
164
  this.retryCount++;
@@ -175,7 +178,7 @@ class ComputedNode extends Node {
175
178
  }
176
179
  // This method is called right before the Graph add this node to the task manager.
177
180
  beforeAddTask() {
178
- this.state = type_1.NodeState.Queued;
181
+ this.updateState(type_1.NodeState.Queued);
179
182
  this.log.beforeAddTask(this, this.graph);
180
183
  }
181
184
  // This method is called when the data became available on one of nodes,
@@ -304,7 +307,7 @@ class ComputedNode extends Node {
304
307
  if (this.state == type_1.NodeState.Abort) {
305
308
  return;
306
309
  }
307
- this.state = type_1.NodeState.Completed;
310
+ this.updateState(type_1.NodeState.Completed);
308
311
  this.result = this.getResult(result);
309
312
  if (this.output) {
310
313
  this.result = (0, result_1.resultsOf)(this.output, { self: this }, this.graph.propFunctions, true);
@@ -316,7 +319,7 @@ class ComputedNode extends Node {
316
319
  // This private method (called only by execute()) prepares the ComputedNode object
317
320
  // for execution, and create a new transaction to record it.
318
321
  prepareExecute(transactionId, inputs) {
319
- this.state = type_1.NodeState.Executing;
322
+ this.updateState(type_1.NodeState.Executing);
320
323
  this.log.beforeExecute(this, this.graph, transactionId, inputs);
321
324
  this.transactionId = transactionId;
322
325
  }
package/lib/type.d.ts CHANGED
@@ -154,4 +154,5 @@ export type AgentFunctionInfo = {
154
154
  };
155
155
  export type AgentFunctionInfoDictionary = Record<string, AgentFunctionInfo>;
156
156
  export type PropFunction = (result: ResultData, propId: string) => ResultData;
157
+ export type CallbackFunction = (log: TransactionLog, isUpdate: boolean) => void;
157
158
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphai",
3
- "version": "0.6.20",
3
+ "version": "0.6.22",
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",