@minded-ai/mindedjs 1.0.19

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.
Files changed (183) hide show
  1. package/.github/workflows/CI.yml +34 -0
  2. package/.prettierrc +8 -0
  3. package/README.md +6 -0
  4. package/dist/agent.d.ts +36 -0
  5. package/dist/agent.js +199 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/analytics.d.ts +6 -0
  8. package/dist/analytics.js +19 -0
  9. package/dist/analytics.js.map +1 -0
  10. package/dist/edges/createDirectEdge.d.ts +4 -0
  11. package/dist/edges/createDirectEdge.js +14 -0
  12. package/dist/edges/createDirectEdge.js.map +1 -0
  13. package/dist/edges/createLogicalRouter.d.ts +5 -0
  14. package/dist/edges/createLogicalRouter.js +18 -0
  15. package/dist/edges/createLogicalRouter.js.map +1 -0
  16. package/dist/edges/createPromptRouter.d.ts +7 -0
  17. package/dist/edges/createPromptRouter.js +54 -0
  18. package/dist/edges/createPromptRouter.js.map +1 -0
  19. package/dist/edges/edgeFactory.d.ts +9 -0
  20. package/dist/edges/edgeFactory.js +65 -0
  21. package/dist/edges/edgeFactory.js.map +1 -0
  22. package/dist/events/AgentEvents.d.ts +22 -0
  23. package/dist/events/AgentEvents.js +9 -0
  24. package/dist/events/AgentEvents.js.map +1 -0
  25. package/dist/events/index.d.ts +2 -0
  26. package/dist/events/index.js +5 -0
  27. package/dist/events/index.js.map +1 -0
  28. package/dist/index.d.ts +6 -0
  29. package/dist/index.js +15 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/infrastructure.ts/mindedRequest.d.ts +8 -0
  32. package/dist/infrastructure.ts/mindedRequest.js +22 -0
  33. package/dist/infrastructure.ts/mindedRequest.js.map +1 -0
  34. package/dist/llm/createLlmInstance.d.ts +2 -0
  35. package/dist/llm/createLlmInstance.js +14 -0
  36. package/dist/llm/createLlmInstance.js.map +1 -0
  37. package/dist/nodes/addHumanInTheLoopNode.d.ts +8 -0
  38. package/dist/nodes/addHumanInTheLoopNode.js +17 -0
  39. package/dist/nodes/addHumanInTheLoopNode.js.map +1 -0
  40. package/dist/nodes/addPromptNode.d.ts +15 -0
  41. package/dist/nodes/addPromptNode.js +52 -0
  42. package/dist/nodes/addPromptNode.js.map +1 -0
  43. package/dist/nodes/addToolNode.d.ts +10 -0
  44. package/dist/nodes/addToolNode.js +82 -0
  45. package/dist/nodes/addToolNode.js.map +1 -0
  46. package/dist/nodes/addTriggerNode.d.ts +6 -0
  47. package/dist/nodes/addTriggerNode.js +12 -0
  48. package/dist/nodes/addTriggerNode.js.map +1 -0
  49. package/dist/nodes/nodeFactory.d.ts +13 -0
  50. package/dist/nodes/nodeFactory.js +41 -0
  51. package/dist/nodes/nodeFactory.js.map +1 -0
  52. package/dist/platform/analytics.d.ts +6 -0
  53. package/dist/platform/analytics.js +19 -0
  54. package/dist/platform/analytics.js.map +1 -0
  55. package/dist/platform/mindedCheckpointSaver.d.ts +10 -0
  56. package/dist/platform/mindedCheckpointSaver.js +49 -0
  57. package/dist/platform/mindedCheckpointSaver.js.map +1 -0
  58. package/dist/platform/mindedConnection.d.ts +13 -0
  59. package/dist/platform/mindedConnection.js +117 -0
  60. package/dist/platform/mindedConnection.js.map +1 -0
  61. package/dist/platform/mindedConnectionTypes.d.ts +10 -0
  62. package/dist/platform/mindedConnectionTypes.js +8 -0
  63. package/dist/platform/mindedConnectionTypes.js.map +1 -0
  64. package/dist/platform/mindedRequest.d.ts +8 -0
  65. package/dist/platform/mindedRequest.js +22 -0
  66. package/dist/platform/mindedRequest.js.map +1 -0
  67. package/dist/types/Agent.types.d.ts +8 -0
  68. package/dist/types/Agent.types.js +3 -0
  69. package/dist/types/Agent.types.js.map +1 -0
  70. package/dist/types/Flows.types.d.ts +83 -0
  71. package/dist/types/Flows.types.js +24 -0
  72. package/dist/types/Flows.types.js.map +1 -0
  73. package/dist/types/LLM.types.d.ts +10 -0
  74. package/dist/types/LLM.types.js +9 -0
  75. package/dist/types/LLM.types.js.map +1 -0
  76. package/dist/types/LangGraph.types.d.ts +29 -0
  77. package/dist/types/LangGraph.types.js +20 -0
  78. package/dist/types/LangGraph.types.js.map +1 -0
  79. package/dist/types/Tools.types.d.ts +14 -0
  80. package/dist/types/Tools.types.js +3 -0
  81. package/dist/types/Tools.types.js.map +1 -0
  82. package/dist/types/Triggers.types.d.ts +1 -0
  83. package/dist/types/Triggers.types.js +3 -0
  84. package/dist/types/Triggers.types.js.map +1 -0
  85. package/docs/.gitbook/assets/image.png +0 -0
  86. package/docs/README.md +51 -0
  87. package/docs/SUMMARY.md +21 -0
  88. package/docs/api-reference/.nojekyll +1 -0
  89. package/docs/api-reference/assets/hierarchy.js +1 -0
  90. package/docs/api-reference/assets/highlight.css +120 -0
  91. package/docs/api-reference/assets/icons.js +18 -0
  92. package/docs/api-reference/assets/icons.svg +1 -0
  93. package/docs/api-reference/assets/main.js +60 -0
  94. package/docs/api-reference/assets/navigation.js +1 -0
  95. package/docs/api-reference/assets/search.js +1 -0
  96. package/docs/api-reference/assets/style.css +1640 -0
  97. package/docs/api-reference/classes/index.Agent.html +4 -0
  98. package/docs/api-reference/enums/index.EdgeType.html +4 -0
  99. package/docs/api-reference/enums/index.NodeType.html +6 -0
  100. package/docs/api-reference/enums/index.TriggerType.html +4 -0
  101. package/docs/api-reference/enums/index.events.html +3 -0
  102. package/docs/api-reference/hierarchy.html +1 -0
  103. package/docs/api-reference/index.html +310 -0
  104. package/docs/api-reference/interfaces/index.AppToolNode.html +5 -0
  105. package/docs/api-reference/interfaces/index.AppTriggerNode.html +6 -0
  106. package/docs/api-reference/interfaces/index.Flow.html +4 -0
  107. package/docs/api-reference/interfaces/index.JunctionNode.html +4 -0
  108. package/docs/api-reference/interfaces/index.LogicalConditionEdge.html +5 -0
  109. package/docs/api-reference/interfaces/index.ManualTriggerNode.html +5 -0
  110. package/docs/api-reference/interfaces/index.PromptConditionEdge.html +5 -0
  111. package/docs/api-reference/interfaces/index.PromptNode.html +6 -0
  112. package/docs/api-reference/interfaces/index.StepForwardEdge.html +4 -0
  113. package/docs/api-reference/interfaces/index.Tool.html +6 -0
  114. package/docs/api-reference/interfaces/index.ToolNode.html +5 -0
  115. package/docs/api-reference/modules/index-1.html +1 -0
  116. package/docs/api-reference/modules/index.html +1 -0
  117. package/docs/api-reference/modules.html +1 -0
  118. package/docs/api-reference/types/index.Edge.html +1 -0
  119. package/docs/api-reference/types/index.Node.html +1 -0
  120. package/docs/api-reference/types/index.TriggerNode.html +1 -0
  121. package/docs/core-concepts/edges.md +242 -0
  122. package/docs/core-concepts/events.md +161 -0
  123. package/docs/core-concepts/flows.md +74 -0
  124. package/docs/core-concepts/memory-types.md +208 -0
  125. package/docs/core-concepts/nodes.md +239 -0
  126. package/docs/core-concepts/tools.md +205 -0
  127. package/docs/examples/order-refund-flow.md +560 -0
  128. package/docs/getting-started/installation.md +34 -0
  129. package/docs/getting-started/quick-start.md +264 -0
  130. package/docs-structure.md +144 -0
  131. package/eslint.config.js +68 -0
  132. package/examples/orderRefundAgent/flows/orderRefundFlow.yaml +32 -0
  133. package/examples/orderRefundAgent/minded.json +14 -0
  134. package/examples/orderRefundAgent/orderRefundAgent.ts +58 -0
  135. package/examples/orderRefundAgent/schema.ts +7 -0
  136. package/examples/orderRefundAgent/tools/escalateConversation.ts +28 -0
  137. package/examples/orderRefundAgent/tools/index.ts +4 -0
  138. package/examples/orderRefundAgent/tools/refundOrder.ts +27 -0
  139. package/package.json +46 -0
  140. package/src/agent.ts +216 -0
  141. package/src/edges/createDirectEdge.ts +11 -0
  142. package/src/edges/createLogicalRouter.ts +16 -0
  143. package/src/edges/createPromptRouter.ts +52 -0
  144. package/src/edges/edgeFactory.ts +85 -0
  145. package/src/events/AgentEvents.ts +22 -0
  146. package/src/events/index.ts +3 -0
  147. package/src/index.ts +22 -0
  148. package/src/llm/createLlmInstance.ts +10 -0
  149. package/src/nodes/addHumanInTheLoopNode.ts +20 -0
  150. package/src/nodes/addPromptNode.ts +66 -0
  151. package/src/nodes/addToolNode.ts +95 -0
  152. package/src/nodes/addTriggerNode.ts +12 -0
  153. package/src/nodes/nodeFactory.ts +65 -0
  154. package/src/platform/analytics.ts +16 -0
  155. package/src/platform/mindedCheckpointSaver.ts +74 -0
  156. package/src/platform/mindedConnection.ts +106 -0
  157. package/src/platform/mindedConnectionTypes.ts +15 -0
  158. package/src/platform/mindedRequest.ts +28 -0
  159. package/src/types/Agent.types.ts +10 -0
  160. package/src/types/Flows.types.ts +103 -0
  161. package/src/types/LLM.types.ts +13 -0
  162. package/src/types/LangGraph.types.ts +25 -0
  163. package/src/types/Tools.types.ts +9 -0
  164. package/test/can-stay-on-node/can-stay-on-node.test.ts +148 -0
  165. package/test/can-stay-on-node/flows/test-flow.yaml +25 -0
  166. package/test/cannot-stay-on-node/cannot-stay-on-node.test.ts +201 -0
  167. package/test/cannot-stay-on-node/flows/test-flow.yaml +34 -0
  168. package/test/human-in-the-loop-node/flows/test-flow.yaml +23 -0
  169. package/test/human-in-the-loop-node/human-in-the-loop-node.test.ts +92 -0
  170. package/test/logical-edges/flows/logical-edge-test-flow.yaml +24 -0
  171. package/test/logical-edges/logical-edges.test.ts +66 -0
  172. package/test/no-human-in-the-loop-node/flows/test-flow.yaml +23 -0
  173. package/test/no-human-in-the-loop-node/no-human-in-the-loop-node.test.ts +80 -0
  174. package/test/prompt-edges/flows/test-flow.yaml +24 -0
  175. package/test/prompt-edges/prompt-edges.test.ts +90 -0
  176. package/test/prompt-node/flows/test-flow.yaml +24 -0
  177. package/test/prompt-node/prompt-node.test.ts +86 -0
  178. package/test/setup.ts +5 -0
  179. package/test/tool-node/flows/test-flow.yaml +14 -0
  180. package/test/tool-node/tool-node.test.ts +67 -0
  181. package/test/trigger/flows/test-flow.yaml +7 -0
  182. package/test/trigger/trigger.test.ts +57 -0
  183. package/tsconfig.json +17 -0
@@ -0,0 +1,86 @@
1
+ import { expect } from 'chai';
2
+ import { Agent } from '../../src/agent';
3
+ import { z } from 'zod';
4
+ import { v4 as uuidv4 } from 'uuid';
5
+ import path from 'path';
6
+ import { AgentEvents } from '../../src/events/AgentEvents';
7
+ import { HumanMessage } from '@langchain/core/messages';
8
+
9
+ const memorySchema = z.object({
10
+ success: z.boolean(),
11
+ });
12
+
13
+ describe('Prompt Node', function () {
14
+ this.timeout(10000); // Set timeout to 10 seconds for all tests in this suite
15
+
16
+ let agent: Agent;
17
+
18
+ beforeEach(() => {
19
+ const flowsPath = path.join(__dirname, 'flows');
20
+ const toolsPath = path.join(__dirname, 'tools');
21
+ agent = new Agent({
22
+ memorySchema,
23
+ config: {
24
+ flows: [flowsPath],
25
+ tools: [toolsPath],
26
+ llm: {
27
+ name: 'ChatOpenAI',
28
+ properties: {
29
+ model: 'gpt-4.1',
30
+ },
31
+ },
32
+ },
33
+ tools: [
34
+ {
35
+ name: 'successTool',
36
+ description: 'Success Tool',
37
+ input: z.object({
38
+ name: z.string(),
39
+ }),
40
+ execute: async () => ({
41
+ memory: {
42
+ success: true,
43
+ },
44
+ }),
45
+ },
46
+ ],
47
+ });
48
+
49
+ // Add trigger event handler
50
+ agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
51
+ if (triggerName === 'Trigger') {
52
+ return {
53
+ memory: {},
54
+ messages: [new HumanMessage(triggerBody.message)],
55
+ };
56
+ }
57
+ });
58
+ });
59
+
60
+ it('should execute a multi-stage prompt node with onMessage callback', async function () {
61
+ this.timeout(20000); // Set timeout to 10 seconds for all tests in this suite
62
+
63
+ const sessionId = uuidv4();
64
+ const result = await agent.invoke({
65
+ triggerBody: {
66
+ message: 'Hi there',
67
+ },
68
+ triggerName: 'Trigger',
69
+ sessionId,
70
+ });
71
+
72
+ // Should pause execution at prompt node
73
+ expect(result.memory.success).to.not.equal(true);
74
+
75
+ // Should resume execution at success node
76
+ const result2 = await agent.invoke({
77
+ triggerBody: {
78
+ message: 'Itay',
79
+ },
80
+ triggerName: 'Trigger',
81
+ sessionId,
82
+ });
83
+
84
+ expect(result2.memory.success).to.equal(true);
85
+ });
86
+ });
package/test/setup.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { config } from 'dotenv';
2
+ import { resolve } from 'path';
3
+
4
+ // Load environment variables from .env file
5
+ config({ path: resolve(__dirname, '../.env') });
@@ -0,0 +1,14 @@
1
+ name: Test Flow
2
+ nodes:
3
+ - type: 'trigger'
4
+ triggerType: 'manual'
5
+ name: 'Trigger'
6
+
7
+ - type: 'tool'
8
+ name: 'Test Tool'
9
+ toolName: 'testTool'
10
+
11
+ edges:
12
+ - source: 'Trigger'
13
+ target: 'Test Tool'
14
+ type: 'stepForward'
@@ -0,0 +1,67 @@
1
+ import { expect } from 'chai';
2
+ import { Agent } from '../../src/agent';
3
+ import { z } from 'zod';
4
+ import path from 'path';
5
+ import { AgentEvents } from '../../src/events/AgentEvents';
6
+ import { HumanMessage } from '@langchain/core/messages';
7
+
8
+ const memorySchema = z.object({
9
+ processed: z.boolean(),
10
+ });
11
+
12
+ describe('Tool Node', function () {
13
+ this.timeout(10000); // Set timeout to 10 seconds for all tests in this suite
14
+
15
+ let agent: Agent;
16
+
17
+ beforeEach(() => {
18
+ const flowsPath = path.join(__dirname, 'flows');
19
+ const toolsPath = path.join(__dirname, 'tools');
20
+ agent = new Agent({
21
+ memorySchema,
22
+ config: {
23
+ flows: [flowsPath],
24
+ tools: [toolsPath],
25
+ llm: {
26
+ name: 'ChatOpenAI',
27
+ properties: {
28
+ model: 'gpt-4.1'
29
+ }
30
+ }
31
+ },
32
+ tools: [
33
+ {
34
+ name: 'testTool',
35
+ description: 'Test Tool',
36
+ input: z.object({
37
+ test: z.string(),
38
+ }),
39
+ execute: async () => ({
40
+ memory: { processed: true },
41
+ }),
42
+ },
43
+ ],
44
+ });
45
+
46
+ // Add trigger event handler
47
+ agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
48
+ if (triggerName === 'Trigger') {
49
+ return {
50
+ memory: {},
51
+ messages: [new HumanMessage(triggerBody.message)],
52
+ };
53
+ }
54
+ });
55
+ });
56
+
57
+ it('should execute tool with correct input', async () => {
58
+ const result = await agent.invoke({
59
+ triggerBody: {
60
+ message: 'Test message',
61
+ },
62
+ triggerName: 'Trigger',
63
+ });
64
+
65
+ expect(result.memory.processed).to.equal(true);
66
+ });
67
+ });
@@ -0,0 +1,7 @@
1
+ name: Test Flow
2
+ nodes:
3
+ - type: 'trigger'
4
+ triggerType: 'manual'
5
+ name: 'Trigger'
6
+
7
+ edges: []
@@ -0,0 +1,57 @@
1
+ import { expect } from 'chai';
2
+ import { Agent } from '../../src/agent';
3
+ import { z } from 'zod';
4
+ import path from 'path';
5
+ import { AgentEvents } from '../../src/events/AgentEvents';
6
+ import { HumanMessage } from '@langchain/core/messages';
7
+
8
+ const memorySchema = z.object({
9
+ success: z.boolean(),
10
+ });
11
+
12
+ describe('Trigger Node', () => {
13
+ let agent: Agent;
14
+
15
+ beforeEach(() => {
16
+ const flowsPath = path.join(__dirname, 'flows');
17
+ const toolsPath = path.join(__dirname, 'tools');
18
+ agent = new Agent({
19
+ memorySchema,
20
+ config: {
21
+ flows: [flowsPath],
22
+ tools: [toolsPath],
23
+ llm: {
24
+ name: 'ChatOpenAI',
25
+ properties: {
26
+ model: 'gpt-4.1'
27
+ }
28
+ }
29
+ },
30
+ tools: [],
31
+ });
32
+ // Add trigger event handler
33
+ agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
34
+ if (triggerName === 'Trigger') {
35
+ return {
36
+ memory: { success: true },
37
+ messages: [new HumanMessage(triggerBody.message)],
38
+ };
39
+ }
40
+ });
41
+ });
42
+
43
+ it('should properly transform trigger input', async function () {
44
+ this.timeout(10000); // Increase timeout to 10 seconds
45
+
46
+ const result = await agent.invoke({
47
+ triggerBody: {
48
+ message: 'Test message',
49
+ },
50
+ triggerName: 'Trigger',
51
+ });
52
+
53
+ expect(result.messages).to.have.lengthOf(1);
54
+ expect(result.messages[0].content).to.equal('Test message');
55
+ expect(result.memory.success).to.equal(true);
56
+ });
57
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2018",
4
+ "module": "commonjs",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "moduleResolution": "node",
12
+ "resolveJsonModule": true,
13
+ "sourceMap": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "dist"]
17
+ }