graphai 0.5.1 → 0.5.3
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.d.ts +3 -0
- package/lib/graphai.js +10 -7
- package/lib/index.d.ts +2 -3
- package/lib/index.js +3 -3
- package/lib/node.js +1 -0
- package/lib/type.d.ts +12 -6
- package/lib/type.js +1 -0
- package/lib/utils/utils.d.ts +1 -1
- package/lib/utils/utils.js +2 -2
- package/package.json +2 -2
- package/lib/utils/runner.d.ts +0 -2
- package/lib/utils/runner.js +0 -20
package/lib/graphai.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { TransactionLog } from "./transaction_log";
|
|
|
3
3
|
import { ComputedNode, StaticNode } from "./node";
|
|
4
4
|
import { TaskManager } from "./task_manager";
|
|
5
5
|
type GraphNodes = Record<string, ComputedNode | StaticNode>;
|
|
6
|
+
export declare const defaultConcurrency = 8;
|
|
7
|
+
export declare const graphDataLatestVersion = 0.5;
|
|
6
8
|
export declare class GraphAI {
|
|
7
9
|
readonly version: number;
|
|
8
10
|
private readonly graphId;
|
|
@@ -10,6 +12,7 @@ export declare class GraphAI {
|
|
|
10
12
|
private readonly loop?;
|
|
11
13
|
private readonly logs;
|
|
12
14
|
private readonly bypassAgentIds;
|
|
15
|
+
readonly config?: Record<string, unknown>;
|
|
13
16
|
readonly agentFunctionInfoDictionary: AgentFunctionInfoDictionary;
|
|
14
17
|
readonly taskManager: TaskManager;
|
|
15
18
|
readonly agentFilters: AgentFilterInfo[];
|
package/lib/graphai.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GraphAI = void 0;
|
|
3
|
+
exports.GraphAI = exports.graphDataLatestVersion = exports.defaultConcurrency = void 0;
|
|
4
4
|
const node_1 = require("./node");
|
|
5
5
|
const utils_1 = require("./utils/utils");
|
|
6
6
|
const validator_1 = require("./validator");
|
|
7
7
|
const task_manager_1 = require("./task_manager");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
exports.defaultConcurrency = 8;
|
|
9
|
+
exports.graphDataLatestVersion = 0.5;
|
|
10
10
|
class GraphAI {
|
|
11
11
|
// This method is called when either the GraphAI obect was created,
|
|
12
12
|
// or we are about to start n-th iteration (n>2).
|
|
@@ -67,24 +67,27 @@ class GraphAI {
|
|
|
67
67
|
taskManager: undefined,
|
|
68
68
|
agentFilters: [],
|
|
69
69
|
bypassAgentIds: [],
|
|
70
|
+
config: {},
|
|
70
71
|
}) {
|
|
71
72
|
this.logs = [];
|
|
73
|
+
this.config = {};
|
|
72
74
|
this.onLogCallback = (__log, __isUpdate) => { };
|
|
73
75
|
this.repeatCount = 0;
|
|
74
76
|
if (!data.version && !options.taskManager) {
|
|
75
77
|
console.warn("------------ missing version number");
|
|
76
78
|
}
|
|
77
|
-
this.version = data.version ??
|
|
78
|
-
if (this.version <
|
|
79
|
-
console.warn(`------------ upgrade to ${
|
|
79
|
+
this.version = data.version ?? exports.graphDataLatestVersion;
|
|
80
|
+
if (this.version < exports.graphDataLatestVersion) {
|
|
81
|
+
console.warn(`------------ upgrade to ${exports.graphDataLatestVersion}!`);
|
|
80
82
|
}
|
|
81
83
|
this.retryLimit = data.retry; // optional
|
|
82
84
|
this.graphId = URL.createObjectURL(new Blob()).slice(-36);
|
|
83
85
|
this.data = data;
|
|
84
86
|
this.agentFunctionInfoDictionary = agentFunctionInfoDictionary;
|
|
85
|
-
this.taskManager = options.taskManager ?? new task_manager_1.TaskManager(data.concurrency ?? defaultConcurrency);
|
|
87
|
+
this.taskManager = options.taskManager ?? new task_manager_1.TaskManager(data.concurrency ?? exports.defaultConcurrency);
|
|
86
88
|
this.agentFilters = options.agentFilters ?? [];
|
|
87
89
|
this.bypassAgentIds = options.bypassAgentIds ?? [];
|
|
90
|
+
this.config = options.config;
|
|
88
91
|
this.loop = data.loop;
|
|
89
92
|
this.verbose = data.verbose === true;
|
|
90
93
|
this.onComplete = () => {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { GraphAI } from "./graphai";
|
|
2
|
-
export { AgentFunction, AgentFunctionInfo, AgentFunctionInfoDictionary, AgentFunctionContext, GraphData, ResultDataDictionary, ResultData, NodeState, AgentFilterFunction, AgentFilterInfo, NodeData, StaticNodeData, ComputedNodeData, DefaultResultData, DefaultInputData, } from "./type";
|
|
1
|
+
export { GraphAI, defaultConcurrency, graphDataLatestVersion } from "./graphai";
|
|
2
|
+
export { AgentFunction, AgentFunctionInfo, AgentFunctionInfoDictionary, AgentFunctionInfoSample, AgentFunctionContext, GraphData, ResultDataDictionary, ResultData, NodeState, AgentFilterFunction, AgentFilterInfo, NodeData, StaticNodeData, ComputedNodeData, DefaultResultData, DefaultInputData, } from "./type";
|
|
3
3
|
export type { TransactionLog } from "./transaction_log";
|
|
4
|
-
export { agentFilterRunnerBuilder } from "./utils/runner";
|
|
5
4
|
export { defaultAgentInfo, agentInfoWrapper, defaultTestContext, strIntentionalError, assert, sleep } from "./utils/utils";
|
|
6
5
|
export { ValidationError } from "./validators/common";
|
package/lib/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidationError = exports.sleep = exports.assert = exports.strIntentionalError = exports.defaultTestContext = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.
|
|
3
|
+
exports.ValidationError = 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
|
+
Object.defineProperty(exports, "defaultConcurrency", { enumerable: true, get: function () { return graphai_1.defaultConcurrency; } });
|
|
7
|
+
Object.defineProperty(exports, "graphDataLatestVersion", { enumerable: true, get: function () { return graphai_1.graphDataLatestVersion; } });
|
|
6
8
|
var type_1 = require("./type");
|
|
7
9
|
Object.defineProperty(exports, "NodeState", { enumerable: true, get: function () { return type_1.NodeState; } });
|
|
8
|
-
var runner_1 = require("./utils/runner");
|
|
9
|
-
Object.defineProperty(exports, "agentFilterRunnerBuilder", { enumerable: true, get: function () { return runner_1.agentFilterRunnerBuilder; } });
|
|
10
10
|
var utils_1 = require("./utils/utils");
|
|
11
11
|
Object.defineProperty(exports, "defaultAgentInfo", { enumerable: true, get: function () { return utils_1.defaultAgentInfo; } });
|
|
12
12
|
Object.defineProperty(exports, "agentInfoWrapper", { enumerable: true, get: function () { return utils_1.agentInfoWrapper; } });
|
package/lib/node.js
CHANGED
package/lib/type.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare enum NodeState {
|
|
|
4
4
|
Waiting = "waiting",
|
|
5
5
|
Queued = "queued",
|
|
6
6
|
Executing = "executing",
|
|
7
|
+
ExecutingServer = "executing-server",
|
|
7
8
|
Failed = "failed",
|
|
8
9
|
TimedOut = "timed-out",
|
|
9
10
|
Completed = "completed",
|
|
@@ -60,6 +61,7 @@ export type GraphOptions = {
|
|
|
60
61
|
agentFilters?: AgentFilterInfo[] | undefined;
|
|
61
62
|
taskManager?: TaskManager | undefined;
|
|
62
63
|
bypassAgentIds?: string[] | undefined;
|
|
64
|
+
config?: Record<string, unknown>;
|
|
63
65
|
};
|
|
64
66
|
export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = {
|
|
65
67
|
params: NodeDataParams<ParamsType>;
|
|
@@ -79,6 +81,7 @@ export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType =
|
|
|
79
81
|
filterParams: AgentFilterParams;
|
|
80
82
|
agentFilters?: AgentFilterInfo[];
|
|
81
83
|
log?: TransactionLog[];
|
|
84
|
+
config?: Record<string, unknown>;
|
|
82
85
|
};
|
|
83
86
|
export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, InputDataType, NamedInputDataType>) => Promise<ResultData<ResultType>>;
|
|
84
87
|
export type AgentFilterFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, InputDataType, NamedInputDataType>, agent: AgentFunction) => Promise<ResultData<ResultType>>;
|
|
@@ -89,18 +92,21 @@ export type AgentFilterInfo = {
|
|
|
89
92
|
nodeIds?: string[];
|
|
90
93
|
filterParams?: AgentFilterParams;
|
|
91
94
|
};
|
|
95
|
+
export type AgentFunctionInfoSample = {
|
|
96
|
+
inputs: any;
|
|
97
|
+
params: DefaultParamsType;
|
|
98
|
+
result: any;
|
|
99
|
+
graph?: GraphData;
|
|
100
|
+
};
|
|
92
101
|
export type AgentFunctionInfo = {
|
|
93
102
|
name: string;
|
|
94
103
|
agent: AgentFunction<any, any, any, any>;
|
|
95
104
|
mock: AgentFunction<any, any, any, any>;
|
|
96
105
|
inputs?: any;
|
|
97
106
|
output?: any;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
result: any;
|
|
102
|
-
graph?: GraphData;
|
|
103
|
-
}[];
|
|
107
|
+
outputFormat?: any;
|
|
108
|
+
params?: any;
|
|
109
|
+
samples: AgentFunctionInfoSample[];
|
|
104
110
|
description: string;
|
|
105
111
|
category: string[];
|
|
106
112
|
author: string;
|
package/lib/type.js
CHANGED
|
@@ -6,6 +6,7 @@ var NodeState;
|
|
|
6
6
|
NodeState["Waiting"] = "waiting";
|
|
7
7
|
NodeState["Queued"] = "queued";
|
|
8
8
|
NodeState["Executing"] = "executing";
|
|
9
|
+
NodeState["ExecutingServer"] = "executing-server";
|
|
9
10
|
NodeState["Failed"] = "failed";
|
|
10
11
|
NodeState["TimedOut"] = "timed-out";
|
|
11
12
|
NodeState["Completed"] = "completed";
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { DataSource, ResultData, AgentFunction } from "../type";
|
|
|
2
2
|
export declare const sleep: (milliseconds: number) => Promise<unknown>;
|
|
3
3
|
export declare const parseNodeName: (inputNodeId: any, version: number) => DataSource;
|
|
4
4
|
export declare function assert(condition: boolean, message: string, isWarn?: boolean): asserts condition;
|
|
5
|
-
export declare const isObject: (x: unknown) =>
|
|
5
|
+
export declare const isObject: (x: unknown) => x is object;
|
|
6
6
|
export declare const getDataFromSource: (result: ResultData | undefined, source: DataSource) => ResultData | undefined;
|
|
7
7
|
export declare const strIntentionalError = "Intentional Error for Debugging";
|
|
8
8
|
export declare const defaultAgentInfo: {
|
package/lib/utils/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultTestContext = exports.isLogicallyTrue = exports.debugResultKey = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.strIntentionalError = exports.getDataFromSource = exports.isObject = exports.
|
|
3
|
+
exports.defaultTestContext = exports.isLogicallyTrue = exports.debugResultKey = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.strIntentionalError = exports.getDataFromSource = exports.isObject = exports.parseNodeName = exports.sleep = void 0;
|
|
4
|
+
exports.assert = assert;
|
|
4
5
|
const sleep = async (milliseconds) => {
|
|
5
6
|
return await new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
6
7
|
};
|
|
@@ -47,7 +48,6 @@ function assert(condition, message, isWarn = false) {
|
|
|
47
48
|
console.warn("warn: " + message);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
exports.assert = assert;
|
|
51
51
|
const isObject = (x) => {
|
|
52
52
|
return x !== null && typeof x === "object";
|
|
53
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphai",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Asynchronous data flow execution engine for agentic AI apps.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/receptron/graphai#readme",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"typedoc": "^0.
|
|
29
|
+
"typedoc": "^0.26.3"
|
|
30
30
|
},
|
|
31
31
|
"types": "./lib/index.d.ts",
|
|
32
32
|
"directories": {
|
package/lib/utils/runner.d.ts
DELETED
package/lib/utils/runner.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.agentFilterRunnerBuilder = void 0;
|
|
4
|
-
// for test and server.
|
|
5
|
-
const agentFilterRunnerBuilder = (__agentFilters) => {
|
|
6
|
-
const agentFilters = __agentFilters;
|
|
7
|
-
const agentFilterRunner = (context, agent) => {
|
|
8
|
-
let index = 0;
|
|
9
|
-
const next = (context) => {
|
|
10
|
-
const agentFilter = agentFilters[index++];
|
|
11
|
-
if (agentFilter) {
|
|
12
|
-
return agentFilter.agent(context, next);
|
|
13
|
-
}
|
|
14
|
-
return agent(context);
|
|
15
|
-
};
|
|
16
|
-
return next(context);
|
|
17
|
-
};
|
|
18
|
-
return agentFilterRunner;
|
|
19
|
-
};
|
|
20
|
-
exports.agentFilterRunnerBuilder = agentFilterRunnerBuilder;
|