@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,264 @@
1
+ # Quick Start
2
+
3
+ Build your first MindedJS agent in minutes! We'll create a customer support agent that can process refunds.
4
+
5
+ ## What You'll Build
6
+
7
+ A customer support agent for an ecommerce store:
8
+
9
+ * Greets customers and asks for order details
10
+ * Intelligently routes to refund processing when appropriate
11
+ * Processes refunds with business logic
12
+ * Maintains conversation state throughout
13
+
14
+ ## Project Setup
15
+
16
+ First, create the necessary files in your project:
17
+
18
+ ### 1. Agent Configuration
19
+
20
+ Create `minded.json` in your project root:
21
+
22
+ ```json
23
+ {
24
+ "flows": [
25
+ "./flows"
26
+ ],
27
+ "llm": {
28
+ "name": "ChatOpenAI",
29
+ "properties": {
30
+ "model": "gpt-4o"
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ ### 2. Flow Definition
37
+
38
+ Create `flows/refundFlow.yaml`:
39
+
40
+ ```yaml
41
+ name: 'Order Refund Flow'
42
+ nodes:
43
+ - type: 'trigger'
44
+ triggerType: 'manual'
45
+ name: 'CLI Trigger'
46
+ - type: 'promptNode'
47
+ name: 'Support Agent'
48
+ prompt: "Hello! I'm your customer support agent. I can help you with refunds. Please provide your name, order ID, and describe your issue."
49
+ - type: 'tool'
50
+ name: 'Process Refund'
51
+ toolName: 'processRefund'
52
+ edges:
53
+ - source: 'CLI Trigger'
54
+ target: 'Support Agent'
55
+ type: 'stepForward'
56
+ - source: 'Support Agent'
57
+ target: 'Process Refund'
58
+ type: 'promptCondition'
59
+ prompt: 'The user is asking for a refund and provided their order details'
60
+ ```
61
+
62
+ ### 3. Memory Schema
63
+
64
+ Create `schema.ts`:
65
+
66
+ ```ts
67
+ import { z } from 'zod';
68
+
69
+ export default z.object({
70
+ customerName: z.string().optional(),
71
+ orderId: z.string().optional(),
72
+ issue: z.string().optional(),
73
+ });
74
+ ```
75
+
76
+ ### 4. Tools
77
+
78
+ Create `tools/processRefund.ts`:
79
+
80
+ ```ts
81
+ import { z } from 'zod';
82
+ import { Tool } from 'mindedjs/src/types/Tools.types';
83
+ import memorySchema from '../schema';
84
+
85
+ type Memory = z.infer<typeof memorySchema>;
86
+
87
+ const schema = z.object({
88
+ orderId: z.string(),
89
+ customerName: z.string(),
90
+ reason: z.string(),
91
+ });
92
+
93
+ const processRefundTool: Tool<typeof schema, Memory> = {
94
+ name: 'processRefund',
95
+ description: 'Process a refund for the customer order',
96
+ input: schema,
97
+ execute: async ({ input, memory }) => {
98
+ console.log('*Action: Processing refund*');
99
+ console.log(`Refunding order ${input.orderId} for ${input.customerName}`);
100
+ console.log(`Reason: ${input.reason}`);
101
+
102
+ // Simulate refund processing
103
+ const refundAmount = Math.floor(Math.random() * 100) + 20; // Random amount between $20-$120
104
+ console.log(`Refund of $${memory.orderAmount} has been processed successfully!`);
105
+
106
+ return {
107
+ memory: {
108
+ customerName: input.customerName,
109
+ orderId: input.orderId,
110
+ issue: `Refund processed - $${refundAmount}`,
111
+ },
112
+ };
113
+ },
114
+ };
115
+
116
+ export default processRefundTool;
117
+ ```
118
+
119
+ Create `tools/index.ts`:
120
+
121
+ ```ts
122
+ import processRefundTool from './processRefund';
123
+
124
+ export default [processRefundTool];
125
+ ```
126
+
127
+ ### 5. Main Agent
128
+
129
+ Create `agent.ts`:
130
+
131
+ ```ts
132
+ import { Agent } from 'mindedjs/src/agent';
133
+ import { HumanMessage } from '@langchain/core/messages';
134
+ import { events } from 'mindedjs/src/index';
135
+ import * as readline from 'readline';
136
+ import memorySchema from './schema';
137
+ import tools from './tools';
138
+ import config from './minded.json';
139
+
140
+ // 1. Create readline interface for interactive chat
141
+ const rl = readline.createInterface({
142
+ input: process.stdin,
143
+ output: process.stdout,
144
+ });
145
+
146
+ // 2. Create the agent with config from minded.json
147
+ const agent = new Agent({
148
+ memorySchema,
149
+ config,
150
+ tools,
151
+ });
152
+
153
+ // 3. Listen for AI messages
154
+ agent.on(events.AI_MESSAGE, async ({ message }) => {
155
+ console.log('AI:', message);
156
+ promptUser(); // Continue the conversation
157
+ });
158
+
159
+ // 4. Handle trigger events
160
+ agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
161
+ if (triggerName === 'CLI Trigger') {
162
+ return {
163
+ memory: {},
164
+ messages: [new HumanMessage(triggerBody)],
165
+ };
166
+ }
167
+ });
168
+
169
+ // 5. Function to prompt user for input
170
+ const promptUser = () => {
171
+ rl.question('You: ', async (input) => {
172
+ if (input.toLowerCase() === 'exit' || input.toLowerCase() === 'quit') {
173
+ console.log('Goodbye!');
174
+ rl.close();
175
+ return;
176
+ }
177
+
178
+ console.log(); // Add spacing for readability
179
+
180
+ // Send user message to agent
181
+ await agent.invoke({
182
+ triggerBody: input,
183
+ triggerName: 'CLI Trigger'
184
+ });
185
+ });
186
+ };
187
+
188
+ // 6. Start the interactive session
189
+ console.log('🤖 Customer Support Agent is ready!');
190
+ console.log('Type your message below (or "exit" to quit):\n');
191
+ promptUser();
192
+ ```
193
+
194
+ ## Project Structure
195
+
196
+ Your project should look like this:
197
+
198
+ ```
199
+ your-project/
200
+ ├── minded.json # Agent configuration
201
+ ├── schema.ts # Memory schema definition
202
+ ├── agent.ts # Main agent file
203
+ ├── flows/ # Flow definitions
204
+ │ └── refundFlow.yaml # Individual flow files
205
+ └── tools/ # Tools directory
206
+ ├── processRefund.ts # Refund processing tool
207
+ └── index.ts # Export your tools
208
+ ```
209
+
210
+ ## Run Your Agent
211
+
212
+ Start the interactive chat session:
213
+
214
+ ```bash
215
+ npx ts-node agent.ts
216
+ ```
217
+
218
+ This will start an interactive conversation where you can chat with your agent:
219
+
220
+ ```
221
+ 🤖 Customer Support Agent is ready!
222
+ Type your message below (or "exit" to quit):
223
+
224
+ You: Hi, I want to refund my order #1234. I received the wrong item.
225
+
226
+ AI: Hello! I'm your customer support agent. I can help you with refunds. Please provide your name, order ID, and describe your issue.
227
+
228
+ You: My name is John Smith, order ID is 1234, and I received the wrong size shoes.
229
+
230
+ *Action: Processing refund*
231
+ Refunding order 1234 for John Smith
232
+ Reason: received the wrong size shoes
233
+ Refund of $87 has been processed successfully!
234
+
235
+ You: Thank you!
236
+
237
+ AI: You're welcome! Your refund has been processed successfully. Is there anything else I can help you with?
238
+
239
+ You: exit
240
+ Goodbye!
241
+ ```
242
+
243
+ **Tips:**
244
+
245
+ * Type `exit` or `quit` to end the conversation
246
+ * Each message maintains conversation context and memory
247
+ * The agent will intelligently route to refund processing when appropriate
248
+
249
+ ## What Happens
250
+
251
+ 1. **Trigger Activation**: The manual trigger receives your input message
252
+ 2. **Support Agent**: The prompt node greets the customer and asks for details
253
+ 3. **Intelligent Routing**: If the customer mentions refunds and provides order details, the flow routes to the refund tool
254
+ 4. **Refund Processing**: The tool processes the refund and updates memory
255
+ 5. **State Management**: Memory persists customer information throughout the conversation
256
+
257
+ ## Next Steps
258
+
259
+ Now that you have a working agent, explore:
260
+
261
+ * [**Core Concepts**](../core-concepts/flows.md) - Understand how flows, nodes, and edges work
262
+ * [**Node Types**](../core-concepts/nodes.md) - Learn about all available node types
263
+ * [**Edge Types**](../core-concepts/edges.md) - Learn about all available edge types
264
+ * [**Tools**](../core-concepts/tools.md) - Learn about all available tools
@@ -0,0 +1,144 @@
1
+ # GitBook Documentation Structure
2
+
3
+ ## Recommended File Organization
4
+
5
+ ```
6
+ docs/
7
+ ├── README.md # Introduction & Why MindedJS
8
+ ├── getting-started/
9
+ │ ├── installation.md # Installation instructions
10
+ │ ├── quick-start.md # Quick start example
11
+ │ └── project-setup.md # Project structure & configuration
12
+ ├── core-concepts/
13
+ │ ├── memory-types.md # Memory type system
14
+ │ ├── flows.md # Flow overview
15
+ │ ├── nodes.md # Node types overview
16
+ │ ├── edges.md # Edge types overview
17
+ │ ├── tools.md # Tools system
18
+ │ └── events.md # Event system
19
+ ├── node-types/
20
+ │ ├── trigger-nodes.md # TRIGGER nodes
21
+ │ ├── prompt-nodes.md # PROMPT_NODE nodes
22
+ │ ├── tool-nodes.md # TOOL nodes
23
+ │ ├── app-tool-nodes.md # APP_TOOL nodes
24
+ │ └── junction-nodes.md # JUNCTION nodes
25
+ ├── edge-types/
26
+ │ ├── step-forward.md # STEP_FORWARD edges
27
+ │ ├── prompt-condition.md # PROMPT_CONDITION edges
28
+ │ └── logical-condition.md # LOGICAL_CONDITION edges
29
+ ├── implementation-examples/
30
+ │ ├── node-examples.md # All node implementation examples
31
+ │ ├── edge-examples.md # All edge implementation examples
32
+ │ └── complete-flows.md # Full flow examples
33
+ ├── how-to-guides/
34
+ │ ├── add-new-tool.md # Adding tools
35
+ │ ├── listen-for-events.md # Event handling
36
+ │ ├── persist-memory.md # Memory persistence
37
+ │ └── run-from-cli.md # CLI execution
38
+ ├── api-reference/
39
+ │ ├── agent-class.md # Agent class reference
40
+ │ ├── tool-interface.md # Tool interface
41
+ │ ├── flow-schema.md # Flow YAML schema
42
+ │ └── event-types.md # Event type definitions
43
+ └── examples/
44
+ ├── order-refund-flow.md # Order refund example
45
+ ├── customer-support.md # Customer support example
46
+ └── e-commerce-agent.md # E-commerce example
47
+ ```
48
+
49
+ ## SUMMARY.md Structure
50
+
51
+ ```markdown
52
+ # Table of contents
53
+
54
+ * [Introduction](README.md)
55
+
56
+ ## Getting Started
57
+ * [Installation](getting-started/installation.md)
58
+ * [Quick Start](getting-started/quick-start.md)
59
+ * [Project Setup](getting-started/project-setup.md)
60
+
61
+ ## Core Concepts
62
+ * [Memory Types](core-concepts/memory-types.md)
63
+ * [Flows](core-concepts/flows.md)
64
+ * [Nodes](core-concepts/nodes.md)
65
+ * [Edges](core-concepts/edges.md)
66
+ * [Tools](core-concepts/tools.md)
67
+ * [Events](core-concepts/events.md)
68
+
69
+ ## Node Types
70
+ * [Trigger Nodes](node-types/trigger-nodes.md)
71
+ * [Prompt Nodes](node-types/prompt-nodes.md)
72
+ * [Tool Nodes](node-types/tool-nodes.md)
73
+ * [App Tool Nodes](node-types/app-tool-nodes.md)
74
+ * [Junction Nodes](node-types/junction-nodes.md)
75
+
76
+ ## Edge Types
77
+ * [Step Forward](edge-types/step-forward.md)
78
+ * [Prompt Condition](edge-types/prompt-condition.md)
79
+ * [Logical Condition](edge-types/logical-condition.md)
80
+
81
+ ## Implementation Examples
82
+ * [Node Examples](implementation-examples/node-examples.md)
83
+ * [Edge Examples](implementation-examples/edge-examples.md)
84
+ * [Complete Flows](implementation-examples/complete-flows.md)
85
+
86
+ ## How-to Guides
87
+ * [Add a New Tool](how-to-guides/add-new-tool.md)
88
+ * [Listen for Events](how-to-guides/listen-for-events.md)
89
+ * [Persist Memory](how-to-guides/persist-memory.md)
90
+ * [Run from CLI](how-to-guides/run-from-cli.md)
91
+
92
+ ## API Reference
93
+ * [Agent Class](api-reference/agent-class.md)
94
+ * [Tool Interface](api-reference/tool-interface.md)
95
+ * [Flow Schema](api-reference/flow-schema.md)
96
+ * [Event Types](api-reference/event-types.md)
97
+
98
+ ## Examples
99
+ * [Order Refund Flow](examples/order-refund-flow.md)
100
+ * [Customer Support](examples/customer-support.md)
101
+ * [E-commerce Agent](examples/e-commerce-agent.md)
102
+ ```
103
+
104
+ ## Content Distribution Guide
105
+
106
+ ### README.md (Introduction)
107
+ - Why MindedJS section
108
+ - Key features/benefits
109
+ - Brief overview
110
+ - Link to getting started
111
+
112
+ ### getting-started/quick-start.md
113
+ - The current quick start example
114
+ - Basic project setup
115
+ - First flow creation
116
+
117
+ ### core-concepts/
118
+ - Split the "Core Concepts" section into individual files
119
+ - Each concept gets detailed explanation
120
+ - Keep tables and type definitions here
121
+
122
+ ### node-types/ & edge-types/
123
+ - Detailed documentation for each type
124
+ - Implementation details
125
+ - Advanced configuration options
126
+ - Best practices for each type
127
+
128
+ ### implementation-examples/
129
+ - All the practical examples
130
+ - Code snippets
131
+ - Real-world use cases
132
+
133
+ ### api-reference/
134
+ - Complete API documentation
135
+ - Method signatures
136
+ - Parameter details
137
+ - Return types
138
+
139
+ This structure provides:
140
+ 1. **Progressive disclosure** - readers can dive deeper as needed
141
+ 2. **Easy navigation** - logical grouping of related content
142
+ 3. **Searchability** - specific topics in dedicated files
143
+ 4. **Maintainability** - easier to update specific sections
144
+ 5. **Cross-references** - ability to link between related concepts
@@ -0,0 +1,68 @@
1
+ const js = require('@eslint/js');
2
+ const tseslint = require('typescript-eslint');
3
+ const globals = require('globals');
4
+
5
+ module.exports = tseslint.config(
6
+ {
7
+ // Only apply to TypeScript files in src directory
8
+ files: ['src/**/*.ts', 'src/**/*.tsx'],
9
+ extends: [
10
+ js.configs.recommended,
11
+ ...tseslint.configs.recommended,
12
+ ],
13
+ languageOptions: {
14
+ globals: {
15
+ ...globals.node,
16
+ },
17
+ parser: tseslint.parser,
18
+ parserOptions: {
19
+ project: './tsconfig.json',
20
+ tsconfigRootDir: __dirname,
21
+ },
22
+ },
23
+ rules: {
24
+ '@typescript-eslint/no-explicit-any': 'off',
25
+ },
26
+ },
27
+ {
28
+ // Allow require() in config files at root level
29
+ files: ['*.config.js', 'eslint.config.js'],
30
+ extends: [js.configs.recommended],
31
+ languageOptions: {
32
+ globals: {
33
+ ...globals.node,
34
+ },
35
+ },
36
+ rules: {
37
+ '@typescript-eslint/no-require-imports': 'off',
38
+ },
39
+ },
40
+ {
41
+ // Relax TypeScript project rules for test and example files
42
+ files: ['test/**/*.ts', 'examples/**/*.ts'],
43
+ extends: [
44
+ js.configs.recommended,
45
+ ...tseslint.configs.recommended,
46
+ ],
47
+ languageOptions: {
48
+ globals: {
49
+ ...globals.node,
50
+ },
51
+ parser: tseslint.parser,
52
+ parserOptions: {
53
+ project: false,
54
+ },
55
+ },
56
+ rules: {
57
+ '@typescript-eslint/no-explicit-any': 'off',
58
+ },
59
+ },
60
+ {
61
+ ignores: [
62
+ 'dist/**/*',
63
+ 'node_modules/**/*',
64
+ 'docs/**/*', // Ignore generated documentation
65
+ '*.d.ts' // Ignore type declaration files
66
+ ],
67
+ }
68
+ );
@@ -0,0 +1,32 @@
1
+ name: 'Order refund flow'
2
+ nodes:
3
+ - type: 'trigger'
4
+ triggerType: 'manual'
5
+ name: 'CLI Trigger'
6
+ - type: 'tool'
7
+ name: 'Refund order'
8
+ toolName: 'refundOrder'
9
+ - type: 'tool'
10
+ name: 'Escalate conversation'
11
+ toolName: 'escalateConversation'
12
+ - type: 'promptNode'
13
+ name: 'Prompt'
14
+ humanInTheLoop: true
15
+ canStayOnNode: true
16
+ prompt: "You are a customer support agent (Alex) tasked with identifying the issue and escalating it if necessary. Introduce yourself and make sure to collect the customer's name, the issue they are having, and the order id they are referring to. make sure you got all the details you need before continue with the flow. You don't need to further help the customer."
17
+ llmConfig:
18
+ name: 'ChatOpenAI'
19
+ properties:
20
+ model: 'o3'
21
+ edges:
22
+ - source: 'CLI Trigger'
23
+ target: 'Prompt'
24
+ type: 'stepForward'
25
+ - source: 'Prompt'
26
+ target: 'Refund order'
27
+ type: 'promptCondition'
28
+ prompt: 'The user is asking for a refund'
29
+ - source: 'Prompt'
30
+ target: 'Escalate conversation'
31
+ type: 'promptCondition'
32
+ prompt: 'if user does not want refund but says what they need help with and user provided all the details you need'
@@ -0,0 +1,14 @@
1
+ {
2
+ "flows": [
3
+ "./flows"
4
+ ],
5
+ "tools": [
6
+ "./tools"
7
+ ],
8
+ "llm": {
9
+ "name": "ChatOpenAI",
10
+ "properties": {
11
+ "model": "gpt-4o"
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,58 @@
1
+ import { Agent } from '../../src/agent';
2
+ import readline from 'readline';
3
+ import memorySchema from './schema';
4
+ import tools from './tools';
5
+ import { HumanMessage } from '@langchain/core/messages';
6
+ import { events } from '../../src/index';
7
+ import mindedConfig from './minded.json';
8
+
9
+ const agent = new Agent({
10
+ memorySchema,
11
+ config: mindedConfig,
12
+ tools,
13
+ });
14
+
15
+ agent.on(events.AI_MESSAGE, async ({ message }) => {
16
+ await sendMessage(message);
17
+ });
18
+
19
+ agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
20
+ if (triggerName === 'CLI Trigger') {
21
+ return {
22
+ memory: {},
23
+ messages: [new HumanMessage(triggerBody)],
24
+ };
25
+ }
26
+ });
27
+
28
+ const sendMessage = async (message: string) => {
29
+ console.log('AI:', message);
30
+ };
31
+
32
+ if (process.env.NO_PLATFORM_CONNECT === 'true') {
33
+ // Simple CLI interface
34
+ const rl = readline.createInterface({
35
+ input: process.stdin,
36
+ output: process.stdout,
37
+ prompt: 'You: ',
38
+ });
39
+
40
+ console.log('Type your message and press Enter (type "exit" to quit)');
41
+ rl.prompt();
42
+
43
+ rl.on('line', async (line) => {
44
+ const userInput = line.trim();
45
+ if (userInput.toLowerCase() === 'exit') {
46
+ rl.close();
47
+ process.exit(0);
48
+ }
49
+
50
+ await agent.invoke({
51
+ triggerBody: userInput,
52
+ triggerName: 'CLI Trigger',
53
+ sessionId: 'cli-session',
54
+ });
55
+
56
+ rl.prompt();
57
+ });
58
+ }
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+
3
+ export default z.object({
4
+ orderId: z.string(),
5
+ customerName: z.string(),
6
+ issue: z.string(),
7
+ });
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import memorySchema from '../schema';
3
+ import { Tool } from '../../../src/types/Tools.types';
4
+ type Memory = z.infer<typeof memorySchema>;
5
+
6
+ const schema = z.object({
7
+ issue: z.string(),
8
+ orderId: z.string(),
9
+ customerName: z.string(),
10
+ });
11
+
12
+ const escalateConversationTool: Tool<typeof schema, Memory> = {
13
+ name: 'escalateConversation',
14
+ description: 'Escalate conversation',
15
+ input: schema,
16
+ execute: async ({ input }) => {
17
+ console.log('*Action: Escalate conversation to a human*');
18
+ return {
19
+ memory: {
20
+ issue: input.issue,
21
+ orderId: input.orderId,
22
+ customerName: input.customerName,
23
+ },
24
+ };
25
+ },
26
+ };
27
+
28
+ export default escalateConversationTool;
@@ -0,0 +1,4 @@
1
+ import refundOrderTool from './refundOrder';
2
+ import escalateConversationTool from './escalateConversation';
3
+
4
+ export default [refundOrderTool, escalateConversationTool];
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { Tool } from '../../../src/types/Tools.types';
3
+ import memorySchema from '../schema';
4
+ type Memory = z.infer<typeof memorySchema>;
5
+
6
+ const schema = z.object({
7
+ orderId: z.string(),
8
+ customerName: z.string(),
9
+ });
10
+
11
+ const refundOrderTool: Tool<typeof schema, Memory> = {
12
+ name: 'refundOrder',
13
+ description: 'Refund order',
14
+ input: schema,
15
+ execute: async ({ input }) => {
16
+ console.log('*Action: Refund order*');
17
+ return {
18
+ memory: {
19
+ orderId: input.orderId,
20
+ customerName: input.customerName,
21
+ issue: 'Refund',
22
+ },
23
+ };
24
+ },
25
+ };
26
+
27
+ export default refundOrderTool;
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@minded-ai/mindedjs",
3
+ "version": "1.0.19",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "watch": "tsc -w",
10
+ "test": "NODE_ENV=test mocha --parallel --jobs auto --retries 1 -r ts-node/register -r ./test/setup.ts \"test/**/*.test.ts\"",
11
+ "testFile": "NODE_ENV=test mocha -r ts-node/register -r ./test/setup.ts",
12
+ "order-refund": "cd examples/orderRefundAgent && nodemon --watch '**/*.ts' --exec 'ts-node' orderRefundAgent.ts",
13
+ "lint": "eslint .",
14
+ "lintFix": "eslint --fix .",
15
+ "generateApiDocs": "typedoc src --out docs/api-reference ./src"
16
+ },
17
+ "author": "",
18
+ "license": "ISC",
19
+ "devDependencies": {
20
+ "@eslint/js": "^9.27.0",
21
+ "@types/chai": "^4.3.11",
22
+ "@types/mocha": "^10.0.6",
23
+ "@types/node": "^20.11.19",
24
+ "chai": "^4.3.10",
25
+ "dotenv": "^16.4.5",
26
+ "eslint": "^9.27.0",
27
+ "globals": "^16.2.0",
28
+ "mocha": "^10.3.0",
29
+ "nodemon": "^3.1.10",
30
+ "ts-node": "^10.9.2",
31
+ "typedoc": "^0.28.5",
32
+ "typescript": "^5.3.3",
33
+ "typescript-eslint": "^8.32.1"
34
+ },
35
+ "dependencies": {
36
+ "@langchain/core": "^0.3.55",
37
+ "@langchain/langgraph": "^0.2.72",
38
+ "@types/js-yaml": "^4.0.9",
39
+ "axios": "^1.9.0",
40
+ "js-yaml": "^4.1.0",
41
+ "langchain": "^0.3.25",
42
+ "socket.io-client": "^4.8.1",
43
+ "uuid": "^11.1.0",
44
+ "zod": "^3.24.4"
45
+ }
46
+ }