@minded-ai/mindedjs 1.0.89 → 1.0.91-beta-1

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 (83) hide show
  1. package/dist/agent.d.ts +4 -0
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +32 -6
  4. package/dist/agent.js.map +1 -1
  5. package/dist/events/AgentEvents.d.ts +5 -0
  6. package/dist/events/AgentEvents.d.ts.map +1 -1
  7. package/dist/events/AgentEvents.js +1 -0
  8. package/dist/events/AgentEvents.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/nodes/addAppToolNode.d.ts.map +1 -1
  14. package/dist/nodes/addAppToolNode.js +2 -2
  15. package/dist/nodes/addAppToolNode.js.map +1 -1
  16. package/dist/nodes/addJumpToNode.d.ts.map +1 -1
  17. package/dist/nodes/addJumpToNode.js +2 -2
  18. package/dist/nodes/addJumpToNode.js.map +1 -1
  19. package/dist/nodes/addJunctionNode.d.ts +7 -0
  20. package/dist/nodes/addJunctionNode.d.ts.map +1 -0
  21. package/dist/nodes/addJunctionNode.js +20 -0
  22. package/dist/nodes/addJunctionNode.js.map +1 -0
  23. package/dist/nodes/addPromptNode.d.ts.map +1 -1
  24. package/dist/nodes/addPromptNode.js +2 -2
  25. package/dist/nodes/addPromptNode.js.map +1 -1
  26. package/dist/nodes/addToolNode.d.ts.map +1 -1
  27. package/dist/nodes/addToolNode.js +2 -2
  28. package/dist/nodes/addToolNode.js.map +1 -1
  29. package/dist/nodes/addToolRunNode.d.ts.map +1 -1
  30. package/dist/nodes/addToolRunNode.js +2 -3
  31. package/dist/nodes/addToolRunNode.js.map +1 -1
  32. package/dist/nodes/addTriggerNode.d.ts.map +1 -1
  33. package/dist/nodes/addTriggerNode.js +1 -2
  34. package/dist/nodes/addTriggerNode.js.map +1 -1
  35. package/dist/nodes/nodeFactory.d.ts.map +1 -1
  36. package/dist/nodes/nodeFactory.js +2 -5
  37. package/dist/nodes/nodeFactory.js.map +1 -1
  38. package/dist/platform/mindedConnectionTypes.d.ts +5 -0
  39. package/dist/platform/mindedConnectionTypes.d.ts.map +1 -1
  40. package/dist/platform/mindedConnectionTypes.js +1 -0
  41. package/dist/platform/mindedConnectionTypes.js.map +1 -1
  42. package/dist/types/Agent.types.d.ts +11 -6
  43. package/dist/types/Agent.types.d.ts.map +1 -1
  44. package/dist/types/Agent.types.js +1 -0
  45. package/dist/types/Agent.types.js.map +1 -1
  46. package/docs/.gitbook/assets/ADLC.png +0 -0
  47. package/docs/.gitbook/assets/PII-masking.png +0 -0
  48. package/docs/.gitbook/assets/image.png +0 -0
  49. package/docs/README.md +54 -0
  50. package/docs/SUMMARY.md +39 -0
  51. package/docs/examples/order-refund-flow.md +566 -0
  52. package/docs/getting-started/environment-configuration.md +98 -0
  53. package/docs/getting-started/installation.md +44 -0
  54. package/docs/getting-started/project-configuration.md +206 -0
  55. package/docs/getting-started/quick-start.md +262 -0
  56. package/docs/integrations/zendesk.md +554 -0
  57. package/docs/low-code-editor/edges.md +392 -0
  58. package/docs/low-code-editor/flows.md +74 -0
  59. package/docs/low-code-editor/nodes.md +331 -0
  60. package/docs/low-code-editor/playbooks.md +262 -0
  61. package/docs/low-code-editor/tools.md +303 -0
  62. package/docs/low-code-editor/triggers.md +156 -0
  63. package/docs/platform/events.md +374 -0
  64. package/docs/platform/logging.md +72 -0
  65. package/docs/platform/memory.md +219 -0
  66. package/docs/platform/pii-masking.md +220 -0
  67. package/docs/platform/secrets.md +99 -0
  68. package/docs/resources/your-first-eval.md +108 -0
  69. package/docs-structure.md +141 -0
  70. package/package.json +5 -3
  71. package/src/agent.ts +36 -8
  72. package/src/events/AgentEvents.ts +5 -0
  73. package/src/index.ts +0 -1
  74. package/src/nodes/addAppToolNode.ts +3 -3
  75. package/src/nodes/addJumpToNode.ts +3 -3
  76. package/src/nodes/addJunctionNode.ts +19 -0
  77. package/src/nodes/addPromptNode.ts +3 -3
  78. package/src/nodes/addToolNode.ts +2 -3
  79. package/src/nodes/addToolRunNode.ts +3 -4
  80. package/src/nodes/addTriggerNode.ts +3 -3
  81. package/src/nodes/nodeFactory.ts +1 -5
  82. package/src/platform/mindedConnectionTypes.ts +6 -0
  83. package/src/types/Agent.types.ts +11 -5
@@ -0,0 +1,392 @@
1
+ # Edges
2
+
3
+ Edges are the **routing logic** that connects nodes in your MindedJS flows. They determine how your agent moves through the workflow, making intelligent decisions about which path to take based on different conditions and contexts.
4
+
5
+ ## What are Edges?
6
+
7
+ Edges define the **transitions between nodes** in your flow. Each edge specifies:
8
+
9
+ - **Source** - The starting node
10
+ - **Target** - The destination node
11
+ - **Type** - The routing logic type
12
+ - **Condition** - The criteria for taking this path
13
+ - **Prompt** - The prompt for the LLM to make a decision
14
+
15
+ ```yaml
16
+ edges:
17
+ - source: Customer Support Request
18
+ target: Classify Issue
19
+ type: stepForward
20
+
21
+ - source: Classify Issue
22
+ target: Technical Support
23
+ type: promptCondition
24
+ prompt: 'Is this a technical issue requiring troubleshooting?'
25
+
26
+ - source: Classify Issue
27
+ target: Billing Support
28
+ type: logicalCondition
29
+ condition: "state.memory.issueCategory === 'billing'"
30
+ ```
31
+
32
+ ## Edge Types
33
+
34
+ MindedJS provides three types of edges for different routing scenarios:
35
+
36
+ | Edge Type | Purpose | When to Use |
37
+ | --------------------------------------------------------- | ------------- | ------------------------------------------------ |
38
+ | [**Step Forward**](edges.md#step-forward-edges) | Unconditional | Sequential processing, guaranteed transitions |
39
+ | [**Prompt Condition**](edges.md#prompt-condition-edges) | LLM-based | Intelligent routing based on context and content |
40
+ | [**Logical Condition**](edges.md#logical-condition-edges) | Code-based | Deterministic routing based on memory/data |
41
+
42
+ ## Step Forward Edges
43
+
44
+ Step forward edges create **unconditional transitions** between nodes. They're useful for sequential processing where you always want to move to the next step.
45
+
46
+ ```yaml
47
+ - source: Customer Support Request
48
+ target: Support Agent
49
+ type: stepForward
50
+ ```
51
+
52
+ **Use Cases:** Data transformation pipelines, required validation steps, guaranteed notifications, logging and audit trails.
53
+
54
+ ## Prompt Condition Edges
55
+
56
+ Prompt condition edges use **language models** to make intelligent routing decisions based on conversation context, memory state, and complex reasoning.
57
+
58
+ ```yaml
59
+ - source: Support Agent
60
+ target: Escalate to Human
61
+ type: promptCondition
62
+ prompt: 'Based on the conversation, should this be escalated to a human agent?'
63
+ ```
64
+
65
+ ### Context-Aware Routing
66
+
67
+ ```yaml
68
+ - source: Customer Service Bot
69
+ target: VIP Support
70
+ type: promptCondition
71
+ prompt: |
72
+ Should this customer be routed to VIP support?
73
+
74
+ Consider:
75
+ - Customer tier: {{memory.customerTier}}
76
+ - Issue severity: {{memory.issueSeverity}}
77
+ - Previous escalations: {{memory.previousEscalations}}
78
+ - Current sentiment: (analyze from conversation)
79
+ ```
80
+
81
+ ### Multi-Path Routing
82
+
83
+ ```yaml
84
+ # Route to different specialists based on issue type
85
+ - source: Issue Classifier
86
+ target: Technical Support
87
+ type: promptCondition
88
+ prompt: 'Is this a technical/software issue requiring troubleshooting?'
89
+
90
+ - source: Issue Classifier
91
+ target: Billing Support
92
+ type: promptCondition
93
+ prompt: 'Is this a billing, payment, or account-related issue?'
94
+
95
+ - source: Issue Classifier
96
+ target: General Support
97
+ type: promptCondition
98
+ prompt: "Is this a general inquiry that doesn't fit other categories?"
99
+ ```
100
+
101
+ ## Logical Condition Edges
102
+
103
+ Logical condition edges use **JavaScript expressions** to make deterministic routing decisions based on memory state, providing precise control over flow logic.
104
+
105
+ ```yaml
106
+ - source: Order Lookup
107
+ target: Refund Processing
108
+ type: logicalCondition
109
+ condition: "state.memory.orderStatus === 'delivered'"
110
+ ```
111
+
112
+ ### How Condition Expressions Work
113
+
114
+ The condition field accepts a **JavaScript expression** that will be evaluated to determine if the edge should be taken. The expression has access to the current agent state through the `state` variable.
115
+
116
+ The condition is automatically wrapped in a function that provides the state context:
117
+
118
+ ```javascript
119
+ // Your condition: state.memory.orderStatus === 'delivered'
120
+ // Becomes:
121
+ (function ({ state }) {
122
+ return state.memory.orderStatus === 'delivered';
123
+ });
124
+ ```
125
+
126
+ ### Supported Expression Types
127
+
128
+ #### Simple Comparisons
129
+
130
+ ```yaml
131
+ # Equality check
132
+ condition: "state.memory.status === 'active'"
133
+
134
+ # Numeric comparison
135
+ condition: "state.memory.orderValue > 1000"
136
+
137
+ # String comparison
138
+ condition: "state.memory.customerTier !== 'basic'"
139
+
140
+ # Boolean check
141
+ condition: "state.memory.isVerified"
142
+ condition: "!state.memory.hasErrors"
143
+ ```
144
+
145
+ #### Complex Expressions
146
+
147
+ ```yaml
148
+ # Multiple conditions with AND
149
+ condition: "state.memory.orderValue > 500 && state.memory.customerAge < 30"
150
+
151
+ # OR conditions
152
+ condition: "state.memory.priority === 'high' || state.memory.customerTier === 'vip'"
153
+
154
+ # Nested property access
155
+ condition: "state.memory.order.items.length > 5"
156
+
157
+ # Array methods
158
+ condition: "state.memory.tags.includes('urgent')"
159
+
160
+ # String methods
161
+ condition: "state.memory.email.endsWith('@company.com')"
162
+ ```
163
+
164
+ #### Advanced JavaScript Operations
165
+
166
+ ```yaml
167
+ # Ternary operators
168
+ condition: "state.memory.score > 80 ? state.memory.level === 'expert' : state.memory.level === 'beginner'"
169
+
170
+ # Date comparisons
171
+ condition: "new Date(state.memory.orderDate) < new Date()"
172
+
173
+ # Regular expressions
174
+ condition: "/^[A-Z]{2}\\d{4}$/.test(state.memory.orderId)"
175
+
176
+ # Math operations
177
+ condition: "Math.abs(state.memory.temperature - 72) < 5"
178
+
179
+ # JSON operations
180
+ condition: "JSON.parse(state.memory.configString).enabled === true"
181
+ ```
182
+
183
+ ### Available Context
184
+
185
+ Your condition expressions have access to:
186
+
187
+ - **state**: The full agent state object (access as `state.memory`, `state.messages`, etc.)
188
+ - **Standard JavaScript globals**: `Math`, `Date`, `JSON`, `console`
189
+ - **String/Array/Object methods**: All standard JavaScript methods
190
+
191
+ #### Accessing State Properties
192
+
193
+ ```yaml
194
+ # Access memory through state
195
+ condition: "state.memory.orderStatus === 'pending'"
196
+
197
+ # Access messages
198
+ condition: "state.messages.length > 10"
199
+
200
+ # Access other state properties
201
+ condition: "state.conversationId && state.memory.isAuthenticated"
202
+ ```
203
+
204
+ **Note:** For security, the following are NOT available:
205
+
206
+ - `process`, `require`, `global`, `Buffer`
207
+ - File system or network operations
208
+ - Module imports
209
+
210
+ ### Memory-Based Routing
211
+
212
+ ```yaml
213
+ # Route based on customer tier
214
+ - source: Customer Routing
215
+ target: Premium Support
216
+ type: logicalCondition
217
+ condition: "state.memory.customerTier === 'premium'"
218
+
219
+ # Route based on order value
220
+ - source: Order Processing
221
+ target: Manual Review
222
+ type: logicalCondition
223
+ condition: 'state.memory.orderValue > 1000'
224
+ ```
225
+
226
+ ### Complex Logic Conditions
227
+
228
+ ```yaml
229
+ # Multiple conditions with AND logic
230
+ - source: Payment Processor
231
+ target: Fraud Check
232
+ type: logicalCondition
233
+ condition: |
234
+ state.memory.orderValue > 500 &&
235
+ state.memory.customerAge < 30 &&
236
+ state.memory.shippingCountry !== state.memory.billingCountry
237
+
238
+ # Date-based conditions
239
+ - source: Order Validator
240
+ target: Late Order Handler
241
+ type: logicalCondition
242
+ condition: |
243
+ (Date.now() - new Date(state.memory.orderDate).getTime()) / (1000 * 60 * 60 * 24) > 30
244
+ ```
245
+
246
+ ## Edge Evaluation Order
247
+
248
+ When multiple edges exist from the same source node, MindedJS evaluates them by **edge type priority**, not declaration order:
249
+
250
+ ### Priority System
251
+
252
+ | Priority | Edge Type | Behavior |
253
+ | -------- | ------------------ | ------------------------------------------------------- |
254
+ | **1st** | `stepForward` | Always executes first (max 1 per source) |
255
+ | **2nd** | `logicalCondition` | Executes if no step forward edge |
256
+ | **3rd** | `promptCondition` | Executes if no step forward and logical conditions fail |
257
+
258
+ ```yaml
259
+ # Priority-based evaluation regardless of declaration order
260
+ edges:
261
+ - source: Decision Node
262
+ target: AI Router # 3rd priority: Only if logical fails
263
+ type: promptCondition
264
+ prompt: 'Which handler should process this request?'
265
+
266
+ - source: Decision Node
267
+ target: Default Handler # 1st priority: Always executes
268
+ type: stepForward
269
+
270
+ - source: Decision Node
271
+ target: High Priority # 2nd priority: Checked if no stepForward are present
272
+ type: logicalCondition
273
+ condition: "state.memory.priority === 'high'"
274
+ ```
275
+
276
+ ### Logical Condition Order
277
+
278
+ Within logical condition edges from the same source, evaluation follows **declaration order**:
279
+
280
+ ```yaml
281
+ edges:
282
+ # Logical conditions evaluated in declaration order: 1 -> 2 -> 3
283
+ - source: Order Processor
284
+ target: VIP Handler # 1st: Checked first
285
+ type: logicalCondition
286
+ condition: "state.memory.customerTier === 'vip'"
287
+
288
+ - source: Order Processor
289
+ target: Large Order # 2nd: Checked if VIP fails
290
+ type: logicalCondition
291
+ condition: 'state.memory.orderValue > 1000'
292
+
293
+ - source: Order Processor
294
+ target: Standard Handler # 3rd: Checked if both above fail
295
+ type: logicalCondition
296
+ condition: 'true' # Fallback condition
297
+ ```
298
+
299
+ ### Mixed Edge Example
300
+
301
+ ```yaml
302
+ edges:
303
+ # This stepForward will ALWAYS execute first, regardless of order
304
+ - source: Payment Processor
305
+ target: Success Page
306
+ type: stepForward
307
+
308
+ # These will never execute because stepForward takes priority
309
+ - source: Payment Processor
310
+ target: Error Handler
311
+ type: logicalCondition
312
+ condition: "state.memory.status === 'error'"
313
+
314
+ - source: Payment Processor
315
+ target: AI Router
316
+ type: promptCondition
317
+ prompt: 'Should we route to error handling?'
318
+ ```
319
+
320
+ ## Advanced Patterns
321
+
322
+ ### Fallback Chains
323
+
324
+ ```yaml
325
+ # Try specific handlers first, fall back to general
326
+ - source: Issue Classifier
327
+ target: Billing Specialist
328
+ type: logicalCondition
329
+ condition: "state.memory.issueType === 'billing'"
330
+
331
+ - source: Issue Classifier
332
+ target: General Support
333
+ type: stepForward # Fallback for any unmatched cases
334
+ ```
335
+
336
+ ### Error Handling
337
+
338
+ ```yaml
339
+ - source: Payment Processor
340
+ target: Success Handler
341
+ type: logicalCondition
342
+ condition: "state.memory.paymentStatus === 'success'"
343
+
344
+ - source: Payment Processor
345
+ target: Failure Handler
346
+ type: logicalCondition
347
+ condition: "state.memory.paymentStatus === 'failed' || state.memory.retryCount >= 3"
348
+ ```
349
+
350
+ ## Best Practices
351
+
352
+ ### Use the Right Edge Type
353
+
354
+ - **stepForward** for guaranteed transitions
355
+ - **logicalCondition** for deterministic rules
356
+ - **promptCondition** for complex reasoning
357
+
358
+ ### Order Edges Strategically
359
+
360
+ ```yaml
361
+ # Most specific conditions first
362
+ edges:
363
+ - source: Router
364
+ target: Emergency Handler
365
+ type: logicalCondition
366
+ condition: "state.memory.priority === 'emergency'"
367
+
368
+ - source: Router
369
+ target: Standard Handler
370
+ type: stepForward # Catch-all last
371
+ ```
372
+
373
+ ### Always Provide Fallback Paths
374
+
375
+ ```yaml
376
+ - source: Data Processor
377
+ target: Success Handler
378
+ type: logicalCondition
379
+ condition: "state.memory.status === 'success'"
380
+
381
+ - source: Data Processor
382
+ target: Failure Handler
383
+ type: stepForward # Handles any unexpected states
384
+ ```
385
+
386
+ ## Next Steps
387
+
388
+ - [**Tools**](tools.md) - Build powerful functions that your edges can route to
389
+ - [**Memory Types**](../platform/memory.md) - Design state that supports effective routing
390
+ - [**Implementation Examples**](../implementation-examples/edge-examples.md) - See complete edge examples
391
+
392
+ Master edges to create intelligent, responsive flows that adapt to any situation! 🔄
@@ -0,0 +1,74 @@
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**](../platform/memory.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.