graphai 2.0.10 → 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/bundle.cjs.js +1 -1
- package/lib/bundle.cjs.js.map +1 -1
- package/lib/bundle.esm.js +34 -3
- package/lib/bundle.esm.js.map +1 -1
- package/lib/bundle.umd.js +1 -1
- package/lib/bundle.umd.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/node.d.ts +1 -0
- package/lib/node.js +9 -0
- package/lib/type.d.ts +4 -0
- package/lib/utils/data_source.js +1 -1
- package/lib/utils/prop_function.js +22 -1
- package/lib/validators/common.js +1 -0
- package/package.json +4 -4
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;
|
package/lib/utils/data_source.js
CHANGED
|
@@ -35,7 +35,7 @@ const getNestedData = (result, propId, propFunctions) => {
|
|
|
35
35
|
return undefined;
|
|
36
36
|
};
|
|
37
37
|
const innerGetDataFromSource = (result, propIds, propFunctions) => {
|
|
38
|
-
if (
|
|
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) {
|
|
@@ -85,6 +85,10 @@ const propStringFunction = (result, propId) => {
|
|
|
85
85
|
if (propId === "toUpperCase()") {
|
|
86
86
|
return result.toUpperCase();
|
|
87
87
|
}
|
|
88
|
+
const equalMatch = propId.match(/^equal\(([A-Za-z0-9!#$%&()*+,\-./:;<=>?@]+)\)/);
|
|
89
|
+
if (equalMatch) {
|
|
90
|
+
return result === equalMatch[1];
|
|
91
|
+
}
|
|
88
92
|
const sliceMatch = propId.match(/^slice\((-?\d+)(?:,\s*(-?\d+))?\)/);
|
|
89
93
|
if (sliceMatch) {
|
|
90
94
|
if (sliceMatch[2] !== undefined) {
|
|
@@ -112,6 +116,10 @@ const propNumberFunction = (result, propId) => {
|
|
|
112
116
|
if (match) {
|
|
113
117
|
return Number(result) + Number(match[1]);
|
|
114
118
|
}
|
|
119
|
+
const equalMatch = propId.match(/^equal\(([A-Za-z0-9!#$%&()*+,\-/:;<=>?@]+)\)/);
|
|
120
|
+
if (equalMatch) {
|
|
121
|
+
return result === Number(equalMatch[1]);
|
|
122
|
+
}
|
|
115
123
|
}
|
|
116
124
|
return undefined;
|
|
117
125
|
};
|
|
@@ -123,7 +131,20 @@ const propBooleanFunction = (result, propId) => {
|
|
|
123
131
|
}
|
|
124
132
|
return undefined;
|
|
125
133
|
};
|
|
126
|
-
|
|
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];
|
|
127
148
|
const utilsFunctions = (input, nodes) => {
|
|
128
149
|
if (input === "@now" || input === "@now_ms") {
|
|
129
150
|
return Date.now();
|
package/lib/validators/common.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphai",
|
|
3
|
-
"version": "2.0.
|
|
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",
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"./lib"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "rm -r lib/* && tsc && npx rollup -c
|
|
12
|
+
"build": "rm -r lib/* && tsc && npx rollup -c",
|
|
13
13
|
"eslint": "eslint",
|
|
14
14
|
"typedoc": "npx typedoc src/index.ts --out ../../docs/apiDoc",
|
|
15
15
|
"typedoc:md": "npx typedoc src/index.ts --out ../../docs/apiDocMd --plugin typedoc-plugin-markdown",
|
|
16
16
|
"doc": "echo nothing",
|
|
17
|
-
"format": "prettier --write '{src,tests
|
|
18
|
-
"test": "node --test
|
|
17
|
+
"format": "prettier --write '{src,tests}/**/*.ts' *.mjs",
|
|
18
|
+
"test": "node --test --require ts-node/register ./tests/**/test_*.ts",
|
|
19
19
|
"b": "yarn run format && yarn run eslint && yarn run build"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|