graphai 2.0.11 → 2.0.13
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 +38 -6
- 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/graphai.d.ts +1 -0
- package/lib/graphai.js +8 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/node.d.ts +1 -0
- package/lib/node.js +10 -1
- package/lib/transaction_log.d.ts +1 -1
- package/lib/transaction_log.js +2 -1
- package/lib/type.d.ts +5 -0
- package/lib/utils/data_source.js +1 -1
- package/lib/utils/prop_function.js +15 -2
- package/lib/validators/common.js +1 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { GraphAI, defaultConcurrency, graphDataLatestVersion } from "./graphai";
|
|
|
2
2
|
export type { AgentFunction, AgentFunctionInfo, AgentFunctionInfoDictionary, AgentFunctionInfoSample, AgentFunctionContext, GraphData, GraphOptions, ResultDataDictionary, ResultData, AgentFilterFunction, AgentFilterInfo, NodeData, StaticNodeData, ComputedNodeData, DefaultResultData, DefaultInputData, DefaultParamsType, GraphDataLoaderOption, GraphDataLoader, ConfigDataDictionary, ConfigData, DefaultConfigData, CallbackFunction, LoopData, } from "./type";
|
|
3
3
|
export { NodeState } from "./type";
|
|
4
4
|
export type { TransactionLog } from "./transaction_log";
|
|
5
|
-
export { defaultAgentInfo, agentInfoWrapper, defaultTestContext, strIntentionalError, assert, sleep, isObject, parseNodeName, debugResultKey, isComputedNodeData, isStaticNodeData, } from "./utils/utils";
|
|
5
|
+
export { defaultAgentInfo, agentInfoWrapper, defaultTestContext, strIntentionalError, assert, sleep, isObject, parseNodeName, debugResultKey, isComputedNodeData, isStaticNodeData, isNull, } from "./utils/utils";
|
|
6
6
|
export { inputs2dataSources } from "./utils/nodeUtils";
|
|
7
7
|
export { ValidationError } from "./validators/common";
|
|
8
8
|
export { GraphAILogger } from "./utils/GraphAILogger";
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TaskManager = exports.GraphAILogger = exports.ValidationError = exports.inputs2dataSources = exports.isStaticNodeData = exports.isComputedNodeData = exports.debugResultKey = exports.parseNodeName = exports.isObject = exports.sleep = exports.assert = exports.strIntentionalError = exports.defaultTestContext = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.NodeState = exports.graphDataLatestVersion = exports.defaultConcurrency = exports.GraphAI = void 0;
|
|
3
|
+
exports.TaskManager = exports.GraphAILogger = exports.ValidationError = exports.inputs2dataSources = exports.isNull = exports.isStaticNodeData = exports.isComputedNodeData = exports.debugResultKey = exports.parseNodeName = exports.isObject = exports.sleep = exports.assert = exports.strIntentionalError = exports.defaultTestContext = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.NodeState = exports.graphDataLatestVersion = exports.defaultConcurrency = exports.GraphAI = void 0;
|
|
4
4
|
var graphai_1 = require("./graphai");
|
|
5
5
|
Object.defineProperty(exports, "GraphAI", { enumerable: true, get: function () { return graphai_1.GraphAI; } });
|
|
6
6
|
Object.defineProperty(exports, "defaultConcurrency", { enumerable: true, get: function () { return graphai_1.defaultConcurrency; } });
|
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "parseNodeName", { enumerable: true, get: functio
|
|
|
19
19
|
Object.defineProperty(exports, "debugResultKey", { enumerable: true, get: function () { return utils_1.debugResultKey; } });
|
|
20
20
|
Object.defineProperty(exports, "isComputedNodeData", { enumerable: true, get: function () { return utils_1.isComputedNodeData; } });
|
|
21
21
|
Object.defineProperty(exports, "isStaticNodeData", { enumerable: true, get: function () { return utils_1.isStaticNodeData; } });
|
|
22
|
+
Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return utils_1.isNull; } });
|
|
22
23
|
var nodeUtils_1 = require("./utils/nodeUtils");
|
|
23
24
|
Object.defineProperty(exports, "inputs2dataSources", { enumerable: true, get: function () { return nodeUtils_1.inputs2dataSources; } });
|
|
24
25
|
var common_1 = require("./validators/common");
|
package/lib/node.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare class ComputedNode extends Node {
|
|
|
22
22
|
readonly nestedGraph?: GraphData | DataSource;
|
|
23
23
|
readonly retryLimit: number;
|
|
24
24
|
retryCount: number;
|
|
25
|
+
private readonly repeatUntil?;
|
|
25
26
|
private readonly agentId?;
|
|
26
27
|
private agentFunction?;
|
|
27
28
|
readonly timeout?: number;
|
package/lib/node.js
CHANGED
|
@@ -15,7 +15,7 @@ class Node {
|
|
|
15
15
|
this.result = undefined;
|
|
16
16
|
this.nodeId = nodeId;
|
|
17
17
|
this.graph = graph;
|
|
18
|
-
this.log = new transaction_log_1.TransactionLog(nodeId);
|
|
18
|
+
this.log = new transaction_log_1.TransactionLog(nodeId, this.graph.mapIndex);
|
|
19
19
|
this.console = {};
|
|
20
20
|
}
|
|
21
21
|
asString() {
|
|
@@ -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/transaction_log.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class TransactionLog {
|
|
|
19
19
|
isLoop?: boolean;
|
|
20
20
|
repeatCount?: number;
|
|
21
21
|
log?: TransactionLog[];
|
|
22
|
-
constructor(nodeId: string);
|
|
22
|
+
constructor(nodeId: string, mapIndex?: number);
|
|
23
23
|
initForComputedNode(node: ComputedNode, graph: GraphAI): void;
|
|
24
24
|
onInjected(node: StaticNode, graph: GraphAI, injectFrom?: string): void;
|
|
25
25
|
onComplete(node: ComputedNode, graph: GraphAI, localLog: TransactionLog[]): void;
|
package/lib/transaction_log.js
CHANGED
|
@@ -5,9 +5,10 @@ const type_1 = require("./type");
|
|
|
5
5
|
const utils_1 = require("./utils/utils");
|
|
6
6
|
const nodeUtils_1 = require("./utils/nodeUtils");
|
|
7
7
|
class TransactionLog {
|
|
8
|
-
constructor(nodeId) {
|
|
8
|
+
constructor(nodeId, mapIndex) {
|
|
9
9
|
this.nodeId = nodeId;
|
|
10
10
|
this.state = type_1.NodeState.Waiting;
|
|
11
|
+
this.mapIndex = mapIndex;
|
|
11
12
|
}
|
|
12
13
|
initForComputedNode(node, graph) {
|
|
13
14
|
this.agentId = node.getAgentId();
|
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;
|
|
@@ -86,6 +90,7 @@ export type GraphOptions = {
|
|
|
86
90
|
config?: ConfigDataDictionary;
|
|
87
91
|
graphLoader?: GraphDataLoader;
|
|
88
92
|
forceLoop?: boolean;
|
|
93
|
+
mapIndex?: number;
|
|
89
94
|
};
|
|
90
95
|
export type CacheTypes = "pureAgent" | "impureAgent";
|
|
91
96
|
export type AgentFunctionContextDebugInfo = {
|
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) {
|
|
@@ -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
|
-
|
|
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();
|
package/lib/validators/common.js
CHANGED