graphai 0.2.1 → 0.2.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 CHANGED
@@ -12,6 +12,7 @@ export declare class GraphAI {
12
12
  private readonly logs;
13
13
  readonly callbackDictonary: AgentFunctionDictonary;
14
14
  readonly taskManager: TaskManager;
15
+ readonly retryLimit?: number;
15
16
  nodes: GraphNodes;
16
17
  onLogCallback: (__log: TransactionLog, __isUpdate: boolean) => void;
17
18
  verbose: boolean;
package/lib/graphai.js CHANGED
@@ -12,14 +12,16 @@ class GraphAI {
12
12
  // or we are about to start n-th iteration (n>2).
13
13
  createNodes(data) {
14
14
  const nodes = Object.keys(data.nodes).reduce((_nodes, nodeId) => {
15
- const isStaticNode = "value" in data.nodes[nodeId];
16
- if (isStaticNode) {
17
- _nodes[nodeId] = new node_1.StaticNode(nodeId, data.nodes[nodeId], this);
15
+ const nodeData = data.nodes[nodeId];
16
+ if ("value" in nodeData) {
17
+ _nodes[nodeId] = new node_1.StaticNode(nodeId, nodeData, this);
18
18
  }
19
- else {
20
- const nodeData = data.nodes[nodeId];
19
+ else if ("agentId" in nodeData) {
21
20
  _nodes[nodeId] = new node_1.ComputedNode(this.graphId, nodeId, nodeData, this);
22
21
  }
22
+ else {
23
+ throw new Error("Unknown node: " + nodeId);
24
+ }
23
25
  return _nodes;
24
26
  }, {});
25
27
  // Generate the waitlist for each node.
@@ -72,6 +74,7 @@ class GraphAI {
72
74
  console.log("------------ no version");
73
75
  }
74
76
  this.version = data.version ?? 0.2;
77
+ this.retryLimit = data.retry; // optional
75
78
  this.graphId = URL.createObjectURL(new Blob()).slice(-36);
76
79
  this.data = data;
77
80
  this.callbackDictonary = callbackDictonary;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { GraphAI } from "./graphai";
2
2
  export { GraphAI };
3
- export { AgentFunction, AgentFunctionDictonary, GraphData, ResultDataDictonary, ResultData } from "./type";
3
+ export { AgentFunction, AgentFunctionDictonary, GraphData, ResultDataDictonary, ResultData, NodeState } from "./type";
4
4
  export type { TransactionLog } from "./transaction_log";
package/lib/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GraphAI = void 0;
3
+ exports.NodeState = exports.GraphAI = void 0;
4
4
  const graphai_1 = require("./graphai");
5
5
  Object.defineProperty(exports, "GraphAI", { enumerable: true, get: function () { return graphai_1.GraphAI; } });
6
+ var type_1 = require("./type");
7
+ Object.defineProperty(exports, "NodeState", { enumerable: true, get: function () { return type_1.NodeState; } });
package/lib/node.js CHANGED
@@ -40,7 +40,7 @@ class ComputedNode extends Node {
40
40
  this.params = data.params ?? {};
41
41
  this.nestedGraph = data.graph;
42
42
  this.agentId = data.agentId;
43
- this.retryLimit = data.retry ?? 0;
43
+ this.retryLimit = data.retry ?? graph.retryLimit ?? 0;
44
44
  this.timeout = data.timeout;
45
45
  this.isResult = data.isResult ?? false;
46
46
  this.anyInput = data.anyInput ?? false;
package/lib/type.d.ts CHANGED
@@ -47,6 +47,7 @@ export type GraphData = {
47
47
  concurrency?: number;
48
48
  loop?: LoopData;
49
49
  verbose?: boolean;
50
+ retry?: number;
50
51
  };
51
52
  export type AgentFunctionContext<ParamsType, InputDataType> = {
52
53
  params: NodeDataParams<ParamsType>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.staticNodeAttributeKeys = exports.computedNodeAttributeKeys = exports.graphDataAttributeKeys = void 0;
4
- exports.graphDataAttributeKeys = ["nodes", "concurrency", "agentId", "loop", "verbose"];
4
+ exports.graphDataAttributeKeys = ["nodes", "concurrency", "agentId", "loop", "verbose", "version"];
5
5
  exports.computedNodeAttributeKeys = ["inputs", "anyInput", "params", "retry", "timeout", "agentId", "graph", "isResult"];
6
6
  exports.staticNodeAttributeKeys = ["value", "update", "isResult"];
@@ -10,7 +10,7 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
10
10
  computedNodeIds.forEach((computedNodeId) => {
11
11
  const nodeData = data.nodes[computedNodeId];
12
12
  pendings[computedNodeId] = new Set();
13
- if (nodeData.inputs) {
13
+ if ("inputs" in nodeData && nodeData && nodeData.inputs) {
14
14
  nodeData.inputs.forEach((inputNodeId) => {
15
15
  const sourceNodeId = (0, utils_1.parseNodeName)(inputNodeId).nodeId;
16
16
  if (sourceNodeId) {
@@ -27,8 +27,8 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
27
27
  // TODO. validate update
28
28
  staticNodeIds.forEach((staticNodeId) => {
29
29
  const nodeData = data.nodes[staticNodeId];
30
- const update = nodeData.update;
31
- if (update) {
30
+ if ("value" in nodeData && nodeData.update) {
31
+ const update = nodeData.update;
32
32
  const updateNodeId = (0, utils_1.parseNodeName)(update).nodeId;
33
33
  if (!updateNodeId) {
34
34
  throw new Error("Update it a literal");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphai",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Asynchronous data flow execution engine for agentic AI apps.",
5
5
  "main": "lib/index.js",
6
6
  "files": [