@minded-ai/mindedjs 1.0.80-beta.5 → 1.0.80-beta.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"createLogicalRouter.d.ts","sourceRoot":"","sources":["../../src/edges/createLogicalRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAO3D,eAAO,MAAM,mBAAmB,GAAI,WAAW;IAAE,KAAK,EAAE,oBAAoB,EAAE,CAAA;CAAE,MAChE,OAAO,OAAO,eAAe,CAAC,KAAK,2BA2ElD,CAAC"}
1
+ {"version":3,"file":"createLogicalRouter.d.ts","sourceRoot":"","sources":["../../src/edges/createLogicalRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAO3D,eAAO,MAAM,mBAAmB,GAAI,WAAW;IAAE,KAAK,EAAE,oBAAoB,EAAE,CAAA;CAAE,MAChE,OAAO,OAAO,eAAe,CAAC,KAAK,2BAwFlD,CAAC"}
@@ -41,7 +41,11 @@ const CONDITION_TIMEOUT = 5000; // 5 seconds
41
41
  const createLogicalRouter = ({ edges }) => {
42
42
  return async (state) => {
43
43
  logger_1.logger.debug(`Evaluating logical conditions for ${edges.length} edges`);
44
- for (const edge of edges) {
44
+ // Separate regular conditions from "else" conditions
45
+ const regularEdges = edges.filter(edge => edge.condition.trim() !== 'else');
46
+ const elseEdges = edges.filter(edge => edge.condition.trim() === 'else');
47
+ // First, evaluate all regular conditions
48
+ for (const edge of regularEdges) {
45
49
  try {
46
50
  // Customer is responsible for providing valid JavaScript syntax
47
51
  // We execute their condition in a sandboxed VM with timeout protection
@@ -83,7 +87,6 @@ const createLogicalRouter = ({ edges }) => {
83
87
  logger_1.logger.info(`Condition matched for edge ${edge.source} → ${edge.target}`);
84
88
  return edge.target;
85
89
  }
86
- logger_1.logger.debug(`Condition not matched for edge ${edge.source} → ${edge.target}`);
87
90
  }
88
91
  catch (error) {
89
92
  // Provide detailed error information back to the customer
@@ -101,6 +104,14 @@ const createLogicalRouter = ({ edges }) => {
101
104
  continue;
102
105
  }
103
106
  }
107
+ // If no regular conditions matched, check for "else" conditions
108
+ if (elseEdges.length > 0) {
109
+ logger_1.logger.info(`No regular conditions matched, evaluating ${elseEdges.length} else condition(s)`);
110
+ // Return the first "else" condition's target
111
+ const elseEdge = elseEdges[0];
112
+ logger_1.logger.info(`Else condition matched for edge ${elseEdge.source} → ${elseEdge.target}`);
113
+ return elseEdge.target;
114
+ }
104
115
  // If no conditions matched or all failed, return to the source node
105
116
  logger_1.logger.info('No conditions matched');
106
117
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"createLogicalRouter.js","sourceRoot":"","sources":["../../src/edges/createLogicalRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,4CAAyC;AACzC,uCAAyB;AAEzB,6DAA6D;AAC7D,MAAM,iBAAiB,GAAG,IAAI,CAAC,CAAC,YAAY;AAErC,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAqC,EAAE,EAAE;IAClF,OAAO,KAAK,EAAE,KAAmC,EAAE,EAAE;QACnD,eAAM,CAAC,KAAK,CAAC,qCAAqC,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC;QAExE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,gEAAgE;gBAChE,uEAAuE;gBACvE,MAAM,aAAa,GAAG;;qBAET,IAAI,CAAC,SAAS;;SAE1B,CAAC;gBAEF,iDAAiD;gBACjD,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC;oBAC/B,mDAAmD;oBACnD,OAAO,EAAE;wBACP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oBAC1E,SAAS,EAAE,gBAAgB;oBAC3B,KAAK,EAAE,YAAY;oBACnB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;oBAC9B,OAAO,EAAE,iBAAiB;iBAC3B,CAAC,CAAC;gBAEH,sDAAsD;gBACtD,iEAAiE;gBACjE,SAAS;YACX,CAAC;QACH,CAAC;QAED,gEAAgE;QAChE,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,eAAM,CAAC,IAAI,CAAC,6CAA6C,SAAS,CAAC,MAAM,oBAAoB,CAAC,CAAC;YAC/F,6CAA6C;YAC7C,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,eAAM,CAAC,IAAI,CAAC,mCAAmC,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YACvF,OAAO,QAAQ,CAAC,MAAM,CAAC;QACzB,CAAC;QAED,oEAAoE;QACpE,eAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC,CAAC;AAzFW,QAAA,mBAAmB,uBAyF9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minded-ai/mindedjs",
3
- "version": "1.0.80-beta.5",
3
+ "version": "1.0.80-beta.7",
4
4
  "description": "MindedJS is a TypeScript library for building agents.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -47,7 +47,8 @@
47
47
  "ts-node": "^10.9.2",
48
48
  "typedoc": "^0.28.5",
49
49
  "typescript": "^5.3.3",
50
- "typescript-eslint": "^8.32.1"
50
+ "typescript-eslint": "^8.32.1",
51
+ "zod": "^3.24.4"
51
52
  },
52
53
  "dependencies": {
53
54
  "@langchain/core": "^0.3.55",
@@ -63,7 +64,9 @@
63
64
  "socket.io-client": "^4.8.1",
64
65
  "turndown": "^7.2.0",
65
66
  "uuid": "^11.1.0",
66
- "ws": "^8.15.1",
67
- "zod": "^3.24.4"
67
+ "ws": "^8.15.1"
68
+ },
69
+ "peerDependencies": {
70
+ "zod": "^3.0.0"
68
71
  }
69
72
  }
@@ -10,7 +10,12 @@ export const createLogicalRouter = ({ edges }: { edges: LogicalConditionEdge[] }
10
10
  return async (state: typeof stateAnnotation.State) => {
11
11
  logger.debug(`Evaluating logical conditions for ${edges.length} edges`);
12
12
 
13
- for (const edge of edges) {
13
+ // Separate regular conditions from "else" conditions
14
+ const regularEdges = edges.filter(edge => edge.condition.trim() !== 'else');
15
+ const elseEdges = edges.filter(edge => edge.condition.trim() === 'else');
16
+
17
+ // First, evaluate all regular conditions
18
+ for (const edge of regularEdges) {
14
19
  try {
15
20
  // Customer is responsible for providing valid JavaScript syntax
16
21
  // We execute their condition in a sandboxed VM with timeout protection
@@ -58,7 +63,6 @@ export const createLogicalRouter = ({ edges }: { edges: LogicalConditionEdge[] }
58
63
  return edge.target;
59
64
  }
60
65
 
61
- logger.debug(`Condition not matched for edge ${edge.source} → ${edge.target}`);
62
66
  } catch (error) {
63
67
  // Provide detailed error information back to the customer
64
68
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -78,6 +82,15 @@ export const createLogicalRouter = ({ edges }: { edges: LogicalConditionEdge[] }
78
82
  }
79
83
  }
80
84
 
85
+ // If no regular conditions matched, check for "else" conditions
86
+ if (elseEdges.length > 0) {
87
+ logger.info(`No regular conditions matched, evaluating ${elseEdges.length} else condition(s)`);
88
+ // Return the first "else" condition's target
89
+ const elseEdge = elseEdges[0];
90
+ logger.info(`Else condition matched for edge ${elseEdge.source} → ${elseEdge.target}`);
91
+ return elseEdge.target;
92
+ }
93
+
81
94
  // If no conditions matched or all failed, return to the source node
82
95
  logger.info('No conditions matched');
83
96
  return null;