graphai 2.0.11 → 2.0.12

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
@@ -64,6 +64,7 @@ class ComputedNode extends Node {
64
64
  this.filterParams = data.filterParams ?? {};
65
65
  this.passThrough = data.passThrough;
66
66
  this.retryLimit = data.retry ?? graph.retryLimit ?? 0;
67
+ this.repeatUntil = data.repeatUntil;
67
68
  this.timeout = data.timeout;
68
69
  this.isResult = data.isResult ?? false;
69
70
  this.priority = data.priority ?? 0;
@@ -299,6 +300,14 @@ class ComputedNode extends Node {
299
300
  GraphAILogger_1.GraphAILogger.log(`-- transactionId mismatch with ${this.nodeId} (probably timeout)`);
300
301
  return;
301
302
  }
303
+ if (this.repeatUntil?.exists) {
304
+ const dummyResult = { self: { result: this.getResult(result) } };
305
+ const repeatResult = (0, result_1.resultsOf)({ data: this.repeatUntil?.exists }, dummyResult, [], true);
306
+ if ((0, utils_1.isNull)(repeatResult?.data)) {
307
+ this.retry(type_1.NodeState.Failed, Error("Repeat Until"));
308
+ return;
309
+ }
310
+ }
302
311
  // after process
303
312
  this.afterExecute(result, localLog);
304
313
  }
package/lib/type.d.ts CHANGED
@@ -45,6 +45,9 @@ export type GraphDataLoaderOption = {
45
45
  fileName: string;
46
46
  option?: any;
47
47
  };
48
+ export type RepeatUntil = {
49
+ exists?: string;
50
+ };
48
51
  export type ComputedNodeData = {
49
52
  agent: string | AgentAnonymousFunction;
50
53
  inputs?: Record<string, any>;
@@ -53,6 +56,7 @@ export type ComputedNodeData = {
53
56
  params?: NodeDataParams;
54
57
  filterParams?: AgentFilterParams;
55
58
  retry?: number;
59
+ repeatUntil?: RepeatUntil;
56
60
  timeout?: number;
57
61
  if?: string;
58
62
  unless?: string;
@@ -35,7 +35,7 @@ const getNestedData = (result, propId, propFunctions) => {
35
35
  return undefined;
36
36
  };
37
37
  const innerGetDataFromSource = (result, propIds, propFunctions) => {
38
- if (!(0, utils_1.isNull)(result) && propIds && propIds.length > 0) {
38
+ if (propIds && propIds.length > 0) {
39
39
  const propId = propIds[0];
40
40
  const ret = getNestedData(result, propId, propFunctions);
41
41
  if (ret === undefined) {
@@ -116,7 +116,7 @@ const propNumberFunction = (result, propId) => {
116
116
  if (match) {
117
117
  return Number(result) + Number(match[1]);
118
118
  }
119
- const equalMatch = propId.match(/^equal\(([A-Za-z0-9!#$%&()*+,\-./:;<=>?@]+)\)/);
119
+ const equalMatch = propId.match(/^equal\(([A-Za-z0-9!#$%&()*+,\-/:;<=>?@]+)\)/);
120
120
  if (equalMatch) {
121
121
  return result === Number(equalMatch[1]);
122
122
  }
@@ -131,7 +131,20 @@ const propBooleanFunction = (result, propId) => {
131
131
  }
132
132
  return undefined;
133
133
  };
134
- exports.propFunctions = [propArrayFunction, propObjectFunction, propStringFunction, propNumberFunction, propBooleanFunction];
134
+ const propUndefinrdFunction = (result, propId) => {
135
+ if (result === undefined) {
136
+ const equalMatch = propId.match(/^default\(([A-Za-z0-9!#$%&()*+,\-/:;<=>?@]+)\)/);
137
+ if (equalMatch) {
138
+ if (equalMatch[1].match(/^[0-9-]+$/)) {
139
+ return Number(equalMatch[1]);
140
+ }
141
+ return equalMatch[1];
142
+ }
143
+ }
144
+ return undefined;
145
+ };
146
+ // TODO if (result === undefined) {default()}
147
+ exports.propFunctions = [propArrayFunction, propObjectFunction, propStringFunction, propNumberFunction, propBooleanFunction, propUndefinrdFunction];
135
148
  const utilsFunctions = (input, nodes) => {
136
149
  if (input === "@now" || input === "@now_ms") {
137
150
  return Date.now();
@@ -8,6 +8,7 @@ exports.computedNodeAttributeKeys = [
8
8
  "anyInput",
9
9
  "params",
10
10
  "retry",
11
+ "repeatUntil",
11
12
  "timeout",
12
13
  "agent",
13
14
  "graph",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphai",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
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",