graphai 0.6.13 → 0.6.15

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
@@ -74,7 +74,6 @@ class ComputedNode extends Node {
74
74
  const agent = data.agent;
75
75
  this.agentFunction = async ({ namedInputs, params }) => agent(namedInputs, params);
76
76
  }
77
- this.config = this.getConfig(!!data.graph);
78
77
  this.anyInput = data.anyInput ?? false;
79
78
  this.inputs = data.inputs;
80
79
  this.output = data.output;
@@ -108,15 +107,15 @@ class ComputedNode extends Node {
108
107
  getAgentId() {
109
108
  return this.agentId ?? "__custom__function"; // only for display purpose in the log.
110
109
  }
111
- getConfig(hasGraphData) {
112
- if (this.agentId) {
110
+ getConfig(hasGraphData, agentId) {
111
+ if (agentId) {
113
112
  if (hasGraphData) {
114
113
  return this.graph.config;
115
114
  }
116
115
  const config = this.graph.config ?? {};
117
116
  return {
118
117
  ...(config["global"] ?? {}),
119
- ...(config[this.agentId] ?? {}),
118
+ ...(config[agentId] ?? {}),
120
119
  };
121
120
  }
122
121
  return {};
@@ -233,6 +232,10 @@ class ComputedNode extends Node {
233
232
  }
234
233
  const previousResults = this.graph.resultsOf(this.inputs, this.anyInput);
235
234
  const agentId = this.agentId ? this.graph.resultOf((0, utils_2.parseNodeName)(this.agentId)) : this.agentId;
235
+ if (typeof agentId === "function") {
236
+ this.agentFunction = agentId;
237
+ }
238
+ const config = this.getConfig(!!this.nestedGraph, agentId);
236
239
  const transactionId = Date.now();
237
240
  this.prepareExecute(transactionId, Object.values(previousResults));
238
241
  if (this.timeout && this.timeout > 0) {
@@ -243,7 +246,7 @@ class ComputedNode extends Node {
243
246
  try {
244
247
  const agentFunction = this.agentFunction ?? this.graph.getAgentFunctionInfo(agentId).agent;
245
248
  const localLog = [];
246
- const context = this.getContext(previousResults, localLog, agentId);
249
+ const context = this.getContext(previousResults, localLog, agentId, config);
247
250
  // NOTE: We use the existence of graph object in the agent-specific params to determine
248
251
  // if this is a nested agent or not.
249
252
  if (this.nestedGraph) {
@@ -255,7 +258,7 @@ class ComputedNode extends Node {
255
258
  agentFilters: this.graph.agentFilters,
256
259
  taskManager: this.graph.taskManager,
257
260
  bypassAgentIds: this.graph.bypassAgentIds,
258
- config: this.config,
261
+ config,
259
262
  graphLoader: this.graph.graphLoader,
260
263
  },
261
264
  onLogCallback: this.graph.onLogCallback,
@@ -319,7 +322,7 @@ class ComputedNode extends Node {
319
322
  this.retry(type_1.NodeState.Failed, Error("Unknown"));
320
323
  }
321
324
  }
322
- getContext(previousResults, localLog, agentId) {
325
+ getContext(previousResults, localLog, agentId, config) {
323
326
  const context = {
324
327
  params: this.graph.resultsOf(this.params),
325
328
  namedInputs: previousResults,
@@ -328,7 +331,7 @@ class ComputedNode extends Node {
328
331
  cacheType: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(agentId)?.cacheType,
329
332
  filterParams: this.filterParams,
330
333
  agentFilters: this.graph.agentFilters,
331
- config: this.config,
334
+ config,
332
335
  log: localLog,
333
336
  };
334
337
  return context;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphai",
3
- "version": "0.6.13",
3
+ "version": "0.6.15",
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",