@minded-ai/mindedjs 1.0.29 → 1.0.30

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 (173) hide show
  1. package/dist/agent.d.ts +1 -0
  2. package/dist/agent.d.ts.map +1 -0
  3. package/dist/checkpointer/checkpointSaverFactory.d.ts +1 -0
  4. package/dist/checkpointer/checkpointSaverFactory.d.ts.map +1 -0
  5. package/dist/cli/index.d.ts +1 -0
  6. package/dist/cli/index.d.ts.map +1 -0
  7. package/dist/cli/index.js +0 -0
  8. package/dist/edges/createDirectEdge.d.ts +1 -0
  9. package/dist/edges/createDirectEdge.d.ts.map +1 -0
  10. package/dist/edges/createLogicalRouter.d.ts +1 -0
  11. package/dist/edges/createLogicalRouter.d.ts.map +1 -0
  12. package/dist/edges/createPromptRouter.d.ts +1 -0
  13. package/dist/edges/createPromptRouter.d.ts.map +1 -0
  14. package/dist/edges/edgeFactory.d.ts +1 -0
  15. package/dist/edges/edgeFactory.d.ts.map +1 -0
  16. package/dist/events/AgentEvents.d.ts +1 -0
  17. package/dist/events/AgentEvents.d.ts.map +1 -0
  18. package/dist/events/index.d.ts +1 -0
  19. package/dist/events/index.d.ts.map +1 -0
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/llm/createLlmInstance.d.ts +1 -0
  23. package/dist/llm/createLlmInstance.d.ts.map +1 -0
  24. package/dist/nodes/addHumanInTheLoopNode.d.ts +1 -0
  25. package/dist/nodes/addHumanInTheLoopNode.d.ts.map +1 -0
  26. package/dist/nodes/addPromptNode.d.ts +1 -0
  27. package/dist/nodes/addPromptNode.d.ts.map +1 -0
  28. package/dist/nodes/addToolNode.d.ts +1 -0
  29. package/dist/nodes/addToolNode.d.ts.map +1 -0
  30. package/dist/nodes/addTriggerNode.d.ts +1 -0
  31. package/dist/nodes/addTriggerNode.d.ts.map +1 -0
  32. package/dist/nodes/nodeFactory.d.ts +1 -0
  33. package/dist/nodes/nodeFactory.d.ts.map +1 -0
  34. package/dist/platform/config.d.ts +1 -0
  35. package/dist/platform/config.d.ts.map +1 -0
  36. package/dist/platform/mindedChatOpenAI.d.ts +1 -0
  37. package/dist/platform/mindedChatOpenAI.d.ts.map +1 -0
  38. package/dist/platform/mindedCheckpointSaver.d.ts +1 -0
  39. package/dist/platform/mindedCheckpointSaver.d.ts.map +1 -0
  40. package/dist/platform/mindedConnection.d.ts +1 -0
  41. package/dist/platform/mindedConnection.d.ts.map +1 -0
  42. package/dist/platform/mindedConnectionTypes.d.ts +1 -0
  43. package/dist/platform/mindedConnectionTypes.d.ts.map +1 -0
  44. package/dist/platform/mindedRequest.js +2 -2
  45. package/dist/platform/mindedRequest.js.map +1 -1
  46. package/dist/triggers/triggerTypeToDefaultMessage.d.ts +1 -0
  47. package/dist/triggers/triggerTypeToDefaultMessage.d.ts.map +1 -0
  48. package/dist/types/Agent.types.d.ts +1 -0
  49. package/dist/types/Agent.types.d.ts.map +1 -0
  50. package/dist/types/Flows.types.d.ts +1 -0
  51. package/dist/types/Flows.types.d.ts.map +1 -0
  52. package/dist/types/LLM.types.d.ts +1 -0
  53. package/dist/types/LLM.types.d.ts.map +1 -0
  54. package/dist/types/LangGraph.types.d.ts +1 -0
  55. package/dist/types/LangGraph.types.d.ts.map +1 -0
  56. package/dist/types/Tools.types.d.ts +1 -0
  57. package/dist/types/Tools.types.d.ts.map +1 -0
  58. package/dist/types/Triggers.types.d.ts +1 -0
  59. package/dist/types/Triggers.types.js +3 -0
  60. package/dist/types/Triggers.types.js.map +1 -0
  61. package/package.json +6 -2
  62. package/.github/workflows/CI.yml +0 -34
  63. package/.prettierrc +0 -8
  64. package/dist/internalTools/appActionRunnerTool.d.ts +0 -6
  65. package/dist/internalTools/appActionRunnerTool.js +0 -55
  66. package/dist/internalTools/appActionRunnerTool.js.map +0 -1
  67. package/dist/nodes/actionRunnerTool.d.ts +0 -11
  68. package/dist/nodes/actionRunnerTool.js +0 -84
  69. package/dist/nodes/actionRunnerTool.js.map +0 -1
  70. package/dist/nodes/addAppTool.d.ts +0 -8
  71. package/dist/nodes/addAppTool.js +0 -12
  72. package/dist/nodes/addAppTool.js.map +0 -1
  73. package/dist/nodes/addAppToolNode.d.ts +0 -8
  74. package/dist/nodes/addAppToolNode.js +0 -29
  75. package/dist/nodes/addAppToolNode.js.map +0 -1
  76. package/dist/nodes/callTool.d.ts +0 -10
  77. package/dist/nodes/callTool.js +0 -57
  78. package/dist/nodes/callTool.js.map +0 -1
  79. package/dist/nodes/toolNodeRunner.d.ts +0 -15
  80. package/dist/nodes/toolNodeRunner.js +0 -79
  81. package/dist/nodes/toolNodeRunner.js.map +0 -1
  82. package/dist/tools/appToolRunner.d.ts +0 -30
  83. package/dist/tools/appToolRunner.js +0 -35
  84. package/dist/tools/appToolRunner.js.map +0 -1
  85. package/dist/tools/parser.d.ts +0 -14
  86. package/dist/tools/parser.js +0 -17
  87. package/dist/tools/parser.js.map +0 -1
  88. package/dist/tools/triggerTypeToDefaultMessage.d.ts +0 -3
  89. package/dist/tools/triggerTypeToDefaultMessage.js +0 -10
  90. package/dist/tools/triggerTypeToDefaultMessage.js.map +0 -1
  91. package/docs/.gitbook/assets/image.png +0 -0
  92. package/docs/README.md +0 -51
  93. package/docs/SUMMARY.md +0 -23
  94. package/docs/api-reference/.nojekyll +0 -1
  95. package/docs/api-reference/assets/hierarchy.js +0 -1
  96. package/docs/api-reference/assets/highlight.css +0 -120
  97. package/docs/api-reference/assets/icons.js +0 -18
  98. package/docs/api-reference/assets/icons.svg +0 -1
  99. package/docs/api-reference/assets/main.js +0 -60
  100. package/docs/api-reference/assets/navigation.js +0 -1
  101. package/docs/api-reference/assets/search.js +0 -1
  102. package/docs/api-reference/assets/style.css +0 -1640
  103. package/docs/api-reference/classes/index.Agent.html +0 -4
  104. package/docs/api-reference/enums/index.EdgeType.html +0 -4
  105. package/docs/api-reference/enums/index.NodeType.html +0 -6
  106. package/docs/api-reference/enums/index.TriggerType.html +0 -4
  107. package/docs/api-reference/enums/index.events.html +0 -3
  108. package/docs/api-reference/hierarchy.html +0 -1
  109. package/docs/api-reference/index.html +0 -310
  110. package/docs/api-reference/interfaces/index.AppToolNode.html +0 -5
  111. package/docs/api-reference/interfaces/index.AppTriggerNode.html +0 -6
  112. package/docs/api-reference/interfaces/index.Flow.html +0 -4
  113. package/docs/api-reference/interfaces/index.JunctionNode.html +0 -4
  114. package/docs/api-reference/interfaces/index.LogicalConditionEdge.html +0 -5
  115. package/docs/api-reference/interfaces/index.ManualTriggerNode.html +0 -5
  116. package/docs/api-reference/interfaces/index.PromptConditionEdge.html +0 -5
  117. package/docs/api-reference/interfaces/index.PromptNode.html +0 -6
  118. package/docs/api-reference/interfaces/index.StepForwardEdge.html +0 -4
  119. package/docs/api-reference/interfaces/index.Tool.html +0 -6
  120. package/docs/api-reference/interfaces/index.ToolNode.html +0 -5
  121. package/docs/api-reference/modules/index-1.html +0 -1
  122. package/docs/api-reference/modules/index.html +0 -1
  123. package/docs/api-reference/modules.html +0 -1
  124. package/docs/api-reference/types/index.Edge.html +0 -1
  125. package/docs/api-reference/types/index.Node.html +0 -1
  126. package/docs/api-reference/types/index.TriggerNode.html +0 -1
  127. package/docs/core-concepts/edges.md +0 -299
  128. package/docs/core-concepts/events.md +0 -165
  129. package/docs/core-concepts/flows.md +0 -74
  130. package/docs/core-concepts/memory-types.md +0 -208
  131. package/docs/core-concepts/nodes.md +0 -257
  132. package/docs/core-concepts/tools.md +0 -225
  133. package/docs/core-concepts/triggers.md +0 -87
  134. package/docs/examples/order-refund-flow.md +0 -560
  135. package/docs/getting-started/environment-configuration.md +0 -117
  136. package/docs/getting-started/installation.md +0 -40
  137. package/docs/getting-started/quick-start.md +0 -264
  138. package/docs-structure.md +0 -144
  139. package/eslint.config.js +0 -68
  140. package/examples/orderRefundAgent/flows/orderRefundFlow.yaml +0 -26
  141. package/examples/orderRefundAgent/minded.json +0 -10
  142. package/examples/orderRefundAgent/orderRefundAgent.ts +0 -64
  143. package/examples/orderRefundAgent/schema.ts +0 -7
  144. package/examples/orderRefundAgent/tools/escalateConversation.ts +0 -28
  145. package/examples/orderRefundAgent/tools/index.ts +0 -4
  146. package/examples/orderRefundAgent/tools/refundOrder.ts +0 -27
  147. package/test/can-stay-on-node/can-stay-on-node.test.ts +0 -154
  148. package/test/can-stay-on-node/flows/test-flow.yaml +0 -25
  149. package/test/cannot-stay-on-node/cannot-stay-on-node.test.ts +0 -209
  150. package/test/cannot-stay-on-node/flows/test-flow.yaml +0 -34
  151. package/test/checkpoint-saver/minded-checkpoint-saver-list.test.ts +0 -140
  152. package/test/checkpoint-saver/minded-checkpoint-saver.test.ts +0 -100
  153. package/test/edge-priority/edge-priority.test.ts +0 -182
  154. package/test/edge-priority/flows/all-three-edges/test-flow.yaml +0 -35
  155. package/test/edge-priority/flows/logical-prompt-edges/test-flow.yaml +0 -26
  156. package/test/edge-priority/flows/stepforward-logical-edges/test-flow.yaml +0 -25
  157. package/test/edge-priority/flows/stepforward-prompt-edges/test-flow.yaml +0 -25
  158. package/test/human-in-the-loop-node/flows/test-flow.yaml +0 -23
  159. package/test/human-in-the-loop-node/human-in-the-loop-node.test.ts +0 -94
  160. package/test/logical-edges/flows/logical-edge-test-flow.yaml +0 -24
  161. package/test/logical-edges/logical-edges.test.ts +0 -68
  162. package/test/no-human-in-the-loop-node/flows/test-flow.yaml +0 -23
  163. package/test/no-human-in-the-loop-node/no-human-in-the-loop-node.test.ts +0 -81
  164. package/test/prompt-edges/flows/test-flow.yaml +0 -24
  165. package/test/prompt-edges/prompt-edges.test.ts +0 -92
  166. package/test/prompt-node/flows/test-flow.yaml +0 -24
  167. package/test/prompt-node/prompt-node.test.ts +0 -88
  168. package/test/setup.ts +0 -5
  169. package/test/tool-node/flows/test-flow.yaml +0 -14
  170. package/test/tool-node/tool-node.test.ts +0 -68
  171. package/test/trigger/flows/test-flow.yaml +0 -7
  172. package/test/trigger/trigger.test.ts +0 -185
  173. package/tsconfig.json +0 -17
@@ -1,165 +0,0 @@
1
- # Events
2
-
3
- Events are messages that flow through your agent during execution, providing visibility into what's happening and enabling reactive behavior.
4
-
5
- MindedJS currently supports two main event types: `AI_MESSAGE` and `TRIGGER_EVENT`. Each event type has its own specific input structure, output requirements, and use cases.
6
-
7
- ## AI\_MESSAGE
8
-
9
- The `AI_MESSAGE` event is emitted when an AI generates a message that should be sent to the user.
10
-
11
- ### Input Structure
12
-
13
- ```typescript
14
- {
15
- message: string; // The AI-generated message content
16
- memory: Memory; // Current memory state (your defined memory schema)
17
- sessionId: string; // Unique identifier for the current session
18
- }
19
- ```
20
-
21
- ### Handler Return Value
22
-
23
- * **Return type**: `void`
24
- * **Purpose**: Handlers are used for side effects like sending messages to UI
25
- * **Note**: Return values are ignored
26
-
27
- ### Usage Example
28
-
29
- ```typescript
30
- import { Agent, events } from 'mindedjs';
31
-
32
- const agent = new Agent({
33
- memorySchema,
34
- config,
35
- tools,
36
- });
37
-
38
- // Listen to AI messages
39
- agent.on(events.AI_MESSAGE, async ({ message, memory, sessionId }) => {
40
- console.log('AI said:', message);
41
- console.log('Current memory:', memory);
42
- console.log('Session ID:', sessionId);
43
-
44
- // Send message to user interface with session context
45
- await sendMessageToUser(message, sessionId);
46
-
47
- // Send via WebSocket with session information
48
- await websocket.send(JSON.stringify({
49
- type: 'ai_message',
50
- content: message,
51
- sessionId: sessionId
52
- }));
53
- });
54
- ```
55
-
56
- ### Common Use Cases
57
-
58
- * **Real-time Chat UI**: Send AI responses to chat interfaces with session context
59
- * **Logging**: Record AI responses for analytics or debugging with session tracking
60
- * **Message Formatting**: Transform AI messages before displaying to users
61
- * **Notifications**: Trigger alerts or notifications based on AI responses
62
- * **Session Management**: Route messages to specific user sessions or conversation threads
63
-
64
- ## TRIGGER\_EVENT
65
-
66
- The `TRIGGER_EVENT` event is emitted when a trigger node is executed. This event allows you to qualify, transform, and provide initial state for trigger inputs before they're processed by the agent.
67
-
68
- ### Input Structure
69
-
70
- ```typescript
71
- {
72
- triggerName: string; // Name of the trigger being executed
73
- triggerBody: any; // The trigger input data (type varies by trigger)
74
- }
75
- ```
76
-
77
- ### Handler Return Values
78
-
79
- TRIGGER\_EVENT handlers have three possible return types:
80
-
81
- #### 1. Provide Initial State
82
-
83
- ```typescript
84
- {
85
- messages?: BaseMessage[]; // Initial messages for the conversation
86
- memory?: Memory; // Initial memory state
87
- }
88
- ```
89
-
90
- #### 2. Disqualify the Trigger
91
-
92
- ```typescript
93
- false // Rejects/disqualifies the trigger
94
- ```
95
-
96
- #### 3. Qualify without providing initial state
97
-
98
- ```typescript
99
- void // If no initial state is needed
100
- ```
101
-
102
- ### Usage Examples
103
-
104
- #### Processing User Input
105
-
106
- ```typescript
107
- agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
108
- if (triggerName === 'userMessage') {
109
- return {
110
- memory: {
111
- conversationStarted: true,
112
- },
113
- messages: [new HumanMessage(triggerBody)],
114
- };
115
- }
116
- });
117
- ```
118
-
119
- #### Trigger Qualification
120
-
121
- ```typescript
122
- agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
123
- // Validate the trigger input
124
- if (!isValidInput(triggerBody)) {
125
- return false; // Disqualify the trigger
126
- }
127
-
128
- // Only process business hours triggers
129
- if (triggerName === 'supportRequest' && !isBusinessHours()) {
130
- return false;
131
- }
132
-
133
- return {
134
- memory: { validatedInput: triggerBody },
135
- messages: [],
136
- };
137
- });
138
- ```
139
-
140
- #### Input Transformation
141
-
142
- ```typescript
143
- agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
144
- if (triggerName === 'emailTrigger') {
145
- // Transform email data into structured format
146
- const parsedEmail = parseEmailContent(triggerBody);
147
-
148
- return {
149
- memory: {
150
- emailSubject: parsedEmail.subject,
151
- senderEmail: parsedEmail.from
152
- },
153
- messages: [new HumanMessage(parsedEmail.content)],
154
- };
155
- }
156
- });
157
- ```
158
-
159
- ### Common Use Cases
160
-
161
- * **Input Validation**: Ensure trigger data meets requirements before processing
162
- * **Data Transformation**: Convert trigger inputs into standardized formats
163
- * **Context Setting**: Provide initial memory state based on trigger context
164
- * **Access Control**: Disqualify triggers based on permissions or business rules
165
- * **Routing Logic**: Handle different trigger types with specific logic
@@ -1,74 +0,0 @@
1
- # Flows
2
-
3
- Flows are the **core orchestration mechanism** in MindedJS that define how your AI agent processes conversations through a series of connected nodes. A flow represents a complete run of an AI agent that handles user interactions from trigger to completion.
4
-
5
- ## What are Flows?
6
-
7
- Flows define the **conversation logic** and **decision-making pathways** for your AI agent. Each flow consists of:
8
-
9
- * **Nodes** - Processing units that handle specific tasks
10
- * **Edges** - Routing logic that connects nodes
11
- * **Memory** - Shared state that persists throughout the flow
12
- * **Configuration** - Settings that control flow behavior
13
-
14
- ```yaml
15
- name: Customer Support Flow
16
- nodes:
17
- - type: trigger
18
- triggerType: manual
19
- name: Customer Request
20
-
21
- - type: promptNode
22
- name: Support Agent
23
- prompt: |
24
- You are a helpful customer support agent.
25
- Assist the customer with their inquiry.
26
- llmConfig:
27
- name: ChatOpenAI
28
- properties:
29
- model: gpt-4o
30
-
31
- edges:
32
- - source: Customer Request
33
- target: Support Agent
34
- type: stepForward
35
- ```
36
-
37
- ## Flow Components Overview
38
-
39
- | Component | Purpose | Description |
40
- | ------------------------------------------------ | ---------- | ---------------------------------------------------- |
41
- | [**Nodes**](nodes.md) | Processing | Handle specific tasks like LLM calls, tool execution |
42
- | [**Edges**](edges.md) | Routing | Define transitions and decision logic between nodes |
43
- | [**Memory**](memory-types.md) | State | Shared context that persists throughout the flow |
44
- | [**Configuration**](flows.md#flow-configuration) | Settings | Flow-level settings and metadata |
45
-
46
- ## Basic Flow Structure
47
-
48
- Every flow follows this YAML structure:
49
-
50
- ```yaml
51
- name: Flow Name # Required: Human-readable flow identifier
52
- nodes: # Required: Array of processing nodes
53
- - type: trigger # Node type
54
- name: Node Name # Unique node identifier
55
- # ... node-specific config
56
-
57
- edges: # Required: Array of routing connections
58
- - source: Source Node # Source node name
59
- target: Target Node # Target node name
60
- type: stepForward # Edge type
61
- # ... edge-specific config
62
- ```
63
-
64
- ## Nodes in Flows
65
-
66
- Flows orchestrate different types of nodes to handle various aspects of conversation processing. For detailed information about each node type, see the [**Nodes documentation**](nodes.md).
67
-
68
- ## Edges in Flows
69
-
70
- Edges define how your flow moves between nodes based on different conditions. For comprehensive information about edge types and routing logic, see the [**Edges documentation**](edges.md).
71
-
72
- ## Memory in Flows
73
-
74
- Memory provides shared state that persists throughout flow execution, allowing nodes to access and modify data from previous steps.
@@ -1,208 +0,0 @@
1
- # Memory Types
2
-
3
- Memory in MindedJS allows agents to persist and share data across conversation turns and flow executions. It acts as the agent's working memory, storing context, user information, conversation state, and any other data your agent needs to remember.
4
-
5
- ## What is Memory?
6
-
7
- Memory is a structured data store that:
8
- - Persists throughout an agent session
9
- - Is accessible to all nodes in your flows
10
- - Gets automatically merged when updated
11
- - Is validated against a schema you define
12
- - Can store any JSON-serializable data
13
-
14
- ## Defining Memory Schema
15
-
16
- Memory schemas are defined using [Zod](https://zod.dev/) for type safety and runtime validation.
17
-
18
- ```typescript
19
- import { z } from 'zod';
20
-
21
- const memorySchema = z.object({
22
- user: z.object({
23
- id: z.string(),
24
- name: z.string(),
25
- preferences: z.object({
26
- language: z.string().default('en'),
27
- timezone: z.string().default('UTC'),
28
- }),
29
- }),
30
- conversation: z.object({
31
- topic: z.string().optional(),
32
- urgency: z.enum(['low', 'medium', 'high']).default('medium'),
33
- }),
34
- order: z.object({
35
- id: z.string(),
36
- status: z.string(),
37
- total: z.number(),
38
- }).optional(),
39
- });
40
-
41
- type Memory = z.infer<typeof memorySchema>;
42
- ```
43
-
44
- ## Using Memory in Your Agent
45
-
46
- ### 1. Configure Memory Schema
47
-
48
- ```typescript
49
- import { Agent } from 'mindedjs';
50
-
51
- const agent = new Agent({
52
- memorySchema,
53
- config,
54
- tools,
55
- });
56
- ```
57
-
58
- ### 2. Initialize Memory
59
-
60
- Memory is typically initialized when a trigger event occurs:
61
-
62
- ```typescript
63
- import { events } from 'mindedjs';
64
-
65
- agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
66
- if (triggerName === 'new_order_issue') {
67
- return {
68
- memory: {
69
- user: { id: triggerBody.userId, name: triggerBody.userName },
70
- order: { id: triggerBody.orderId, status: 'pending' },
71
- },
72
- messages: [],
73
- };
74
- }
75
- });
76
- ```
77
-
78
- ### 3. Access Memory in Tools
79
-
80
- Tools can read from and write to memory:
81
-
82
- ```typescript
83
- const updateOrderStatus = {
84
- name: 'updateOrderStatus',
85
- description: 'Updates the order status in memory',
86
- inputSchema: z.object({
87
- newStatus: z.string(),
88
- }),
89
- execute: async ({ input, memory }) => {
90
- // Read from memory
91
- const currentOrder = memory.order;
92
-
93
- // Return updated memory (merges with existing)
94
- return {
95
- result: `Order status updated to ${input.newStatus}`,
96
- memory: {
97
- order: {
98
- ...currentOrder,
99
- status: input.newStatus,
100
- lastUpdated: new Date().toISOString(),
101
- }
102
- }
103
- };
104
- },
105
- };
106
- ```
107
-
108
- ## Memory Lifecycle
109
-
110
- 1. **Initialization**: Memory starts empty `{}` and gets populated during trigger events
111
- 2. **Persistence**: Automatically persisted between conversation turns
112
- 3. **Updates**: Memory updates are merged when tools return a memory object
113
- 4. **Validation**: All updates are validated against your schema
114
-
115
- ```typescript
116
- // Current memory: { userId: "123", userName: "John" }
117
- // Tool returns: { memory: { userName: "John Doe", email: "john@example.com" } }
118
- // Result: { userId: "123", userName: "John Doe", email: "john@example.com" }
119
- ```
120
-
121
- ## Best Practices
122
-
123
- ### 1. Keep It Focused
124
- Only store data relevant to your agent's functionality:
125
-
126
- ```typescript
127
- // Good: Focused schema
128
- const memorySchema = z.object({
129
- customerId: z.string(),
130
- currentIssue: z.string(),
131
- resolutionSteps: z.array(z.string()),
132
- });
133
- ```
134
-
135
- ### 2. Use Optional Fields and Defaults
136
- ```typescript
137
- const memorySchema = z.object({
138
- userId: z.string(),
139
- orderId: z.string().optional(), // Not all conversations involve orders
140
- conversationState: z.enum(['started', 'in_progress', 'resolved']).default('started'),
141
- attemptCount: z.number().default(0),
142
- });
143
- ```
144
-
145
- ### 3. Structure Related Data
146
- Group related fields into objects:
147
-
148
- ```typescript
149
- const memorySchema = z.object({
150
- customer: z.object({
151
- id: z.string(),
152
- name: z.string(),
153
- tier: z.enum(['bronze', 'silver', 'gold']),
154
- }),
155
- session: z.object({
156
- startTime: z.string(),
157
- channel: z.enum(['chat', 'email', 'phone']),
158
- }),
159
- });
160
- ```
161
-
162
- ## Common Patterns
163
-
164
- ### User Context Pattern
165
- ```typescript
166
- const memorySchema = z.object({
167
- user: z.object({
168
- id: z.string(),
169
- profile: z.object({
170
- name: z.string(),
171
- email: z.string(),
172
- preferences: z.record(z.unknown()),
173
- }),
174
- }),
175
- });
176
- ```
177
-
178
- ### Conversation State Pattern
179
- ```typescript
180
- const memorySchema = z.object({
181
- conversation: z.object({
182
- phase: z.enum(['greeting', 'information_gathering', 'processing', 'resolution']),
183
- data: z.record(z.unknown()),
184
- }),
185
- });
186
- ```
187
-
188
- ## Memory vs Messages
189
-
190
- - **Memory**: Structured data representing current state and context
191
- - **Messages**: Message history (AI, Human, Tool call, System etc.)
192
-
193
- ```typescript
194
- // Memory: Current state
195
- {
196
- orderId: "ORD-123",
197
- status: "processing",
198
- customer: { name: "John", tier: "gold" }
199
- }
200
-
201
- // Messages: Conversation history
202
- [
203
- { role: "user", content: "I need help with my order" },
204
- { role: "assistant", content: "I'd be happy to help!" },
205
- ]
206
- ```
207
-
208
- Both work together to provide complete context to your agent.
@@ -1,257 +0,0 @@
1
- # Nodes
2
-
3
- Nodes are the building blocks of MindedJS flows - discrete processing units that handle different aspects of your agent's workflow.
4
-
5
- ## Node Types Overview
6
-
7
- | Node Type | Purpose | Description |
8
- |-----------|---------|-------------|
9
- | **[Trigger](#trigger-nodes)** | Entry Points | Start flows from various sources |
10
- | **[Prompt](#prompt-nodes)** | LLM Processing | Generate responses using language models |
11
- | **[Tool](#tool-nodes)** | Actions | Execute external functions and APIs |
12
- | **[Junction](#junction-nodes)** | Flow Control | Route and organize flow logic |
13
-
14
- ## Trigger Nodes
15
-
16
- Trigger nodes are entry points that start your flows and initialize them with memory and messages.
17
-
18
- ### Trigger Types
19
-
20
- #### Manual Trigger
21
- ```yaml
22
- - type: trigger
23
- triggerType: manual
24
- name: Customer Support Request
25
- ```
26
-
27
- #### App Trigger
28
- ```yaml
29
- - type: trigger
30
- triggerType: app
31
- name: Zendesk Ticket Created
32
- appTriggerId: zendesk-new-ticket
33
- ```
34
-
35
- #### Webhook Trigger
36
- ```yaml
37
- - type: trigger
38
- triggerType: webhook
39
- name: Payment Failed Notification
40
- ```
41
-
42
- ### Trigger Implementation
43
-
44
- ```ts
45
- import { events } from 'mindedjs/src/index';
46
- import { HumanMessage } from '@langchain/core/messages';
47
-
48
- agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
49
- if (triggerName === 'Customer Support Request') {
50
- return {
51
- memory: {
52
- customerQuery: triggerBody,
53
- timestamp: new Date().toISOString(),
54
- },
55
- messages: [new HumanMessage(triggerBody)],
56
- };
57
- }
58
- });
59
- ```
60
-
61
- #### Disqualifying Triggers
62
-
63
- Return `false` to prevent flow execution:
64
-
65
- ```ts
66
- agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
67
- // Only process during business hours
68
- const hour = new Date().getHours();
69
- if (hour < 9 || hour > 17) {
70
- return false;
71
- }
72
-
73
- return {
74
- memory: { businessHours: true },
75
- messages: [new HumanMessage(triggerBody)],
76
- };
77
- });
78
- ```
79
-
80
- ## Prompt Nodes
81
-
82
- Prompt nodes process input through LLM to generate intelligent responses or invoke tools.
83
-
84
- **Optional Properties:**
85
- - `humanInTheLoop?: boolean` - When `true`, pauses execution after this node for human input before continuing
86
- - `canStayOnNode?: boolean` - When `true`, allows the node to route back to itself for iterative processing. Usually combined with `humanInTheLoop: true` to allow for iteration over human input.
87
-
88
- **Example Usage:**
89
- ```yaml
90
- - type: promptNode
91
- name: Content Reviewer
92
- prompt: "Ask user to review the content and approve or request changes."
93
- humanInTheLoop: true # Pause for human approval before proceeding
94
-
95
- - type: promptNode
96
- name: Research Assistant
97
- prompt: "Request user for more information until you have gathered all necessary information."
98
- canStayOnNode: true # Allow iterative research until complete
99
- humanInTheLoop: true # Pause for human approval before proceeding
100
- ```
101
-
102
- ### Basic Configuration
103
-
104
- ```yaml
105
- - type: promptNode
106
- name: Customer Service Agent
107
- prompt: |
108
- You are a helpful customer service representative.
109
- Respond to customer inquiries professionally.
110
-
111
- Customer: {{memory.customerName}}
112
- Issue: {{memory.issueCategory}}
113
- llmConfig:
114
- name: ChatOpenAI
115
- properties:
116
- model: gpt-4o
117
- temperature: 0.7
118
- max_tokens: 500
119
- ```
120
-
121
- ### LLM Configuration Options
122
-
123
- ```yaml
124
- # OpenAI
125
- llmConfig:
126
- name: ChatOpenAI
127
- properties:
128
- model: gpt-4o # or gpt-4o-mini, gpt-3.5-turbo
129
- temperature: 0.7 # 0.0 (deterministic) to 1.0 (creative)
130
- max_tokens: 500
131
-
132
- # Anthropic Claude
133
- llmConfig:
134
- name: ChatAnthropic
135
- properties:
136
- model: claude-3-sonnet-20240229
137
- temperature: 0.5
138
- max_tokens: 1000
139
- ```
140
-
141
- ## Tool Nodes
142
-
143
- Tool nodes execute functions to perform actions like API calls or database queries.
144
-
145
- ### Basic Tool Node
146
-
147
- ```yaml
148
- - type: tool
149
- name: Lookup Customer Order
150
- toolName: lookupOrder
151
- ```
152
-
153
- ### Tool Implementation
154
-
155
- ```ts
156
- import { z } from 'zod';
157
- import { Tool } from 'mindedjs/src/types/Tools.types';
158
-
159
- const schema = z.object({
160
- orderId: z.string(),
161
- customerEmail: z.string().optional(),
162
- });
163
-
164
- const lookupOrderTool: Tool<typeof schema, Memory> = {
165
- name: 'lookupOrder',
166
- description: 'Look up order details by order ID',
167
- input: schema,
168
- execute: async ({ input, memory }) => {
169
- const order = await fetchOrderById(input.orderId);
170
-
171
- if (!order) {
172
- throw new Error(`Order ${input.orderId} not found`);
173
- }
174
-
175
- return {
176
- memory: {
177
- orderInfo: order,
178
- orderStatus: order.status,
179
- },
180
- result: `Found order ${order.id} - Status: ${order.status}`,
181
- };
182
- },
183
- };
184
-
185
- export default lookupOrderTool;
186
- ```
187
-
188
- ## Junction Nodes
189
-
190
- Junction nodes provide flow control without processing, useful for organizing routing logic.
191
-
192
- ### Basic Junction
193
-
194
- ```yaml
195
- - type: junction
196
- name: Customer Routing Hub
197
- ```
198
-
199
- ### Routing Example
200
-
201
- ```yaml
202
- nodes:
203
- - type: junction
204
- name: Route Customer Request
205
- - type: promptNode
206
- name: VIP Support
207
- - type: promptNode
208
- name: Standard Support
209
-
210
- edges:
211
- - source: Route Customer Request
212
- target: VIP Support
213
- type: logicalCondition
214
- condition: "({ memory }) => memory.customerTier === 'premium'"
215
-
216
- - source: Route Customer Request
217
- target: Standard Support
218
- type: logicalCondition
219
- condition: "({ memory }) => memory.customerTier === 'standard'"
220
- ```
221
-
222
- ## Best Practices
223
-
224
- ### Use Descriptive Names
225
- ```yaml
226
- # ✅ Good
227
- - type: promptNode
228
- name: Technical Support Specialist
229
-
230
- # ❌ Avoid
231
- - type: promptNode
232
- name: Agent 1
233
- ```
234
-
235
- ### Keep Prompts Focused
236
- ```yaml
237
- # ✅ Good - Specific role and context
238
- - type: promptNode
239
- name: Order Refund Processor
240
- prompt: |
241
- You process customer refund requests for e-commerce orders.
242
- Order ID: {{memory.orderId}}
243
- Determine if refund should be approved based on order status and timing.
244
-
245
- # ❌ Avoid - Too broad
246
- - type: promptNode
247
- name: General Assistant
248
- prompt: "Help the customer with anything they need"
249
- ```
250
-
251
- ## Next Steps
252
-
253
- - **[Edges](edges.md)** - Connect nodes with intelligent routing
254
- - **[Tools](tools.md)** - Build powerful tool functions
255
- - **[Memory Types](memory-types.md)** - Design effective state management
256
-
257
- Nodes are your building blocks - combine them strategically to create powerful AI workflows! 🔧