@minded-ai/mindedjs 1.0.90 → 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 (72) hide show
  1. package/dist/agent.d.ts.map +1 -1
  2. package/dist/agent.js +13 -5
  3. package/dist/agent.js.map +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/nodes/addAppToolNode.d.ts.map +1 -1
  9. package/dist/nodes/addAppToolNode.js +2 -2
  10. package/dist/nodes/addAppToolNode.js.map +1 -1
  11. package/dist/nodes/addJumpToNode.d.ts.map +1 -1
  12. package/dist/nodes/addJumpToNode.js +2 -2
  13. package/dist/nodes/addJumpToNode.js.map +1 -1
  14. package/dist/nodes/addJunctionNode.d.ts +7 -0
  15. package/dist/nodes/addJunctionNode.d.ts.map +1 -0
  16. package/dist/nodes/addJunctionNode.js +20 -0
  17. package/dist/nodes/addJunctionNode.js.map +1 -0
  18. package/dist/nodes/addPromptNode.d.ts.map +1 -1
  19. package/dist/nodes/addPromptNode.js +2 -2
  20. package/dist/nodes/addPromptNode.js.map +1 -1
  21. package/dist/nodes/addToolNode.d.ts.map +1 -1
  22. package/dist/nodes/addToolNode.js +2 -2
  23. package/dist/nodes/addToolNode.js.map +1 -1
  24. package/dist/nodes/addToolRunNode.d.ts.map +1 -1
  25. package/dist/nodes/addToolRunNode.js +1 -2
  26. package/dist/nodes/addToolRunNode.js.map +1 -1
  27. package/dist/nodes/addTriggerNode.d.ts.map +1 -1
  28. package/dist/nodes/addTriggerNode.js +1 -2
  29. package/dist/nodes/addTriggerNode.js.map +1 -1
  30. package/dist/nodes/nodeFactory.d.ts.map +1 -1
  31. package/dist/nodes/nodeFactory.js +2 -5
  32. package/dist/nodes/nodeFactory.js.map +1 -1
  33. package/dist/types/Agent.types.d.ts +11 -6
  34. package/dist/types/Agent.types.d.ts.map +1 -1
  35. package/dist/types/Agent.types.js +1 -0
  36. package/dist/types/Agent.types.js.map +1 -1
  37. package/docs/.gitbook/assets/ADLC.png +0 -0
  38. package/docs/.gitbook/assets/PII-masking.png +0 -0
  39. package/docs/.gitbook/assets/image.png +0 -0
  40. package/docs/README.md +54 -0
  41. package/docs/SUMMARY.md +39 -0
  42. package/docs/examples/order-refund-flow.md +566 -0
  43. package/docs/getting-started/environment-configuration.md +98 -0
  44. package/docs/getting-started/installation.md +44 -0
  45. package/docs/getting-started/project-configuration.md +206 -0
  46. package/docs/getting-started/quick-start.md +262 -0
  47. package/docs/integrations/zendesk.md +554 -0
  48. package/docs/low-code-editor/edges.md +392 -0
  49. package/docs/low-code-editor/flows.md +74 -0
  50. package/docs/low-code-editor/nodes.md +331 -0
  51. package/docs/low-code-editor/playbooks.md +262 -0
  52. package/docs/low-code-editor/tools.md +303 -0
  53. package/docs/low-code-editor/triggers.md +156 -0
  54. package/docs/platform/events.md +374 -0
  55. package/docs/platform/logging.md +72 -0
  56. package/docs/platform/memory.md +219 -0
  57. package/docs/platform/pii-masking.md +220 -0
  58. package/docs/platform/secrets.md +99 -0
  59. package/docs/resources/your-first-eval.md +108 -0
  60. package/docs-structure.md +141 -0
  61. package/package.json +5 -3
  62. package/src/agent.ts +19 -12
  63. package/src/index.ts +0 -1
  64. package/src/nodes/addAppToolNode.ts +3 -3
  65. package/src/nodes/addJumpToNode.ts +3 -3
  66. package/src/nodes/addJunctionNode.ts +19 -0
  67. package/src/nodes/addPromptNode.ts +3 -3
  68. package/src/nodes/addToolNode.ts +2 -3
  69. package/src/nodes/addToolRunNode.ts +2 -3
  70. package/src/nodes/addTriggerNode.ts +3 -3
  71. package/src/nodes/nodeFactory.ts +1 -5
  72. package/src/types/Agent.types.ts +11 -5
@@ -0,0 +1,331 @@
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**](nodes.md#trigger-nodes) | Entry Points | Start flows from various sources |
10
+ | [**Prompt**](nodes.md#prompt-nodes) | LLM Processing | Generate responses using language models |
11
+ | [**Tool**](nodes.md#tool-nodes) | Actions | Execute external functions and APIs |
12
+ | [**Junction**](nodes.md#junction-nodes) | Flow Control | Route and organize flow logic |
13
+ | [**Jump To**](nodes.md#jump-to-nodes) | Flow Control | Jump to specific nodes or subflows |
14
+
15
+ ## Trigger Nodes
16
+
17
+ Trigger nodes are entry points that start your flows and initialize them with memory and messages.
18
+
19
+ ### Trigger Types
20
+
21
+ #### Manual Trigger
22
+
23
+ ```yaml
24
+ - type: trigger
25
+ triggerType: manual
26
+ name: Customer Support Request
27
+ ```
28
+
29
+ #### App Trigger
30
+
31
+ ```yaml
32
+ - type: trigger
33
+ triggerType: app
34
+ name: Zendesk Ticket Created
35
+ appTriggerId: zendesk-new-ticket
36
+ ```
37
+
38
+ #### Webhook Trigger
39
+
40
+ ```yaml
41
+ - type: trigger
42
+ triggerType: webhook
43
+ name: Payment Failed Notification
44
+ ```
45
+
46
+ ### Trigger Implementation
47
+
48
+ ```ts
49
+ import { events } from 'mindedjs/src/index';
50
+ import { HumanMessage } from '@langchain/core/messages';
51
+
52
+ agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
53
+ if (triggerName === 'Customer Support Request') {
54
+ return {
55
+ memory: {
56
+ customerQuery: triggerBody,
57
+ timestamp: new Date().toISOString(),
58
+ },
59
+ messages: [new HumanMessage(triggerBody)],
60
+ };
61
+ }
62
+ });
63
+ ```
64
+
65
+ #### Disqualifying Triggers
66
+
67
+ Return an object with `isQualified: false` to prevent flow execution:
68
+
69
+ ```ts
70
+ agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
71
+ // Only process during business hours
72
+ const hour = new Date().getHours();
73
+ if (hour < 9 || hour > 17) {
74
+ return { isQualified: false };
75
+ }
76
+
77
+ return {
78
+ isQualified: true,
79
+ memory: { businessHours: true },
80
+ messages: [new HumanMessage(triggerBody)],
81
+ };
82
+ });
83
+ ```
84
+
85
+ ## Prompt Nodes
86
+
87
+ Prompt nodes process input through LLM to generate intelligent responses or invoke tools.
88
+
89
+ **Optional Properties:**
90
+
91
+ * `humanInTheLoop?: boolean` - When `true`, pauses execution after this node for human input before continuing
92
+ * `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.
93
+
94
+ **Example Usage:**
95
+
96
+ ```yaml
97
+ - type: promptNode
98
+ name: Content Reviewer
99
+ prompt: 'Ask user to review the content and approve or request changes.'
100
+ humanInTheLoop: true # Pause for human approval before proceeding
101
+
102
+ - type: promptNode
103
+ name: Research Assistant
104
+ prompt: 'Request user for more information until you have gathered all necessary information.'
105
+ canStayOnNode: true # Allow iterative research until complete
106
+ humanInTheLoop: true # Pause for human approval before proceeding
107
+ ```
108
+
109
+ ### Basic Configuration
110
+
111
+ ```yaml
112
+ - type: promptNode
113
+ name: Customer Service Agent
114
+ prompt: |
115
+ You are a helpful customer service representative.
116
+ Respond to customer inquiries professionally.
117
+
118
+ Customer: {{memory.customerName}}
119
+ Issue: {{memory.issueCategory}}
120
+ llmConfig:
121
+ name: ChatOpenAI
122
+ properties:
123
+ model: gpt-4o
124
+ temperature: 0.7
125
+ max_tokens: 500
126
+ ```
127
+
128
+ ### LLM Configuration Options
129
+
130
+ ```yaml
131
+ # OpenAI
132
+ llmConfig:
133
+ name: ChatOpenAI
134
+ properties:
135
+ model: gpt-4o # or gpt-4o-mini, gpt-3.5-turbo
136
+ temperature: 0.7 # 0.0 (deterministic) to 1.0 (creative)
137
+ max_tokens: 500
138
+
139
+ # Anthropic Claude
140
+ llmConfig:
141
+ name: ChatAnthropic
142
+ properties:
143
+ model: claude-3-sonnet-20240229
144
+ temperature: 0.5
145
+ max_tokens: 1000
146
+ ```
147
+
148
+ ## Tool Nodes
149
+
150
+ Tool nodes execute functions to perform actions like API calls or database queries.
151
+
152
+ ### Basic Tool Node
153
+
154
+ ```yaml
155
+ - type: tool
156
+ name: Lookup Customer Order
157
+ toolName: lookupOrder
158
+ ```
159
+
160
+ ### Tool Implementation
161
+
162
+ ```ts
163
+ import { z } from 'zod';
164
+ import { Tool } from 'mindedjs/src/types/Tools.types';
165
+
166
+ const schema = z.object({
167
+ orderId: z.string(),
168
+ customerEmail: z.string().optional(),
169
+ });
170
+
171
+ const lookupOrderTool: Tool<typeof schema, Memory> = {
172
+ name: 'lookupOrder',
173
+ description: 'Look up order details by order ID',
174
+ input: schema,
175
+ execute: async ({ input, memory }) => {
176
+ const order = await fetchOrderById(input.orderId);
177
+
178
+ if (!order) {
179
+ throw new Error(`Order ${input.orderId} not found`);
180
+ }
181
+
182
+ return {
183
+ memory: {
184
+ orderInfo: order,
185
+ orderStatus: order.status,
186
+ },
187
+ result: `Found order ${order.id} - Status: ${order.status}`,
188
+ };
189
+ },
190
+ };
191
+
192
+ export default lookupOrderTool;
193
+ ```
194
+
195
+ ## Junction Nodes
196
+
197
+ Junction nodes provide flow control without processing, useful for organizing routing logic.
198
+
199
+ ### Basic Junction
200
+
201
+ ```yaml
202
+ - type: junction
203
+ name: Customer Routing Hub
204
+ ```
205
+
206
+ ### Routing Example
207
+
208
+ ```yaml
209
+ nodes:
210
+ - type: junction
211
+ name: Route Customer Request
212
+ - type: promptNode
213
+ name: VIP Support
214
+ - type: promptNode
215
+ name: Standard Support
216
+
217
+ edges:
218
+ - source: Route Customer Request
219
+ target: VIP Support
220
+ type: logicalCondition
221
+ condition: "({ memory }) => memory.customerTier === 'premium'"
222
+
223
+ - source: Route Customer Request
224
+ target: Standard Support
225
+ type: logicalCondition
226
+ condition: "({ memory }) => memory.customerTier === 'standard'"
227
+ ```
228
+
229
+ ## Jump To Nodes
230
+
231
+ Jump To nodes provide direct navigation to specific nodes, enabling flow transitions and subflow execution.
232
+
233
+ ### Basic Jump To Node
234
+
235
+ ```yaml
236
+ - type: jumpToNode
237
+ name: Go To Order Processing
238
+ targetNodeId: Process Customer Order
239
+ ```
240
+
241
+ ### Subflow Navigation
242
+
243
+ Jump To nodes are particularly useful for organizing complex workflows into multiple flows:
244
+
245
+ ```yaml
246
+ # Main flow
247
+ - type: jumpToNode
248
+ name: Jump To Refund Subflow
249
+ targetNodeId: Refund Processing Trigger
250
+
251
+ # In refund subflow
252
+ - type: trigger
253
+ name: Refund Processing Trigger
254
+ triggerType: manual
255
+ ```
256
+
257
+ ### Multi-Flow Example
258
+
259
+ ```yaml
260
+ # flows/mainFlow.yaml
261
+ nodes:
262
+ - type: trigger
263
+ name: Customer Request
264
+ triggerType: manual
265
+
266
+ - type: promptNode
267
+ name: Classify Request
268
+ prompt: |
269
+ Classify the customer request as either 'refund' or 'support'.
270
+ Customer message: {{messages.last.content}}
271
+
272
+ - type: jumpToNode
273
+ name: Go To Refund Flow
274
+ targetNodeId: Refund Processor
275
+
276
+ # flows/refundFlow.yaml
277
+ nodes:
278
+ - type: trigger
279
+ name: Refund Processor
280
+ triggerType: manual
281
+
282
+ - type: tool
283
+ name: Process Refund
284
+ toolName: processRefund
285
+ ```
286
+
287
+ ### Implementation Notes
288
+
289
+ - **Direct Navigation**: Jump To nodes create direct edges to their target nodes
290
+ - **Cross-Flow Support**: Target nodes can exist in different flow files
291
+ - **State Preservation**: Current memory and message state is maintained during jumps
292
+ - **No Processing**: Jump To nodes perform no data processing, only navigation
293
+
294
+ ## Best Practices
295
+
296
+ ### Use Descriptive Names
297
+
298
+ ```yaml
299
+ # ✅ Good
300
+ - type: promptNode
301
+ name: Technical Support Specialist
302
+
303
+ # ❌ Avoid
304
+ - type: promptNode
305
+ name: Agent 1
306
+ ```
307
+
308
+ ### Keep Prompts Focused
309
+
310
+ ```yaml
311
+ # ✅ Good - Specific role and context
312
+ - type: promptNode
313
+ name: Order Refund Processor
314
+ prompt: |
315
+ You process customer refund requests for e-commerce orders.
316
+ Order ID: {{memory.orderId}}
317
+ Determine if refund should be approved based on order status and timing.
318
+
319
+ # ❌ Avoid - Too broad
320
+ - type: promptNode
321
+ name: General Assistant
322
+ prompt: 'Help the customer with anything they need'
323
+ ```
324
+
325
+ ## Next Steps
326
+
327
+ * [**Edges**](edges.md) - Connect nodes with intelligent routing
328
+ * [**Tools**](tools.md) - Build powerful tool functions
329
+ * [**Memory Types**](../platform/memory.md) - Design effective state management
330
+
331
+ Nodes are your building blocks - combine them strategically to create powerful AI workflows! 🔧
@@ -0,0 +1,262 @@
1
+ # Playbooks
2
+
3
+ Playbooks are reusable instructions that are automatically included in all prompt and tool nodes of your agent. They help maintain consistency and reduce repetition across your agent's behavior.
4
+
5
+ ## Overview
6
+
7
+ Playbooks are defined using EditorJS blocks format and support:
8
+
9
+ - **[EditorJS blocks](https://editorjs.io/)** for rich content structure
10
+ - **EJS templating** for dynamic content
11
+ - **Placeholders** for runtime values
12
+ - **Multiple files** for better organization
13
+ - **Platform integration** for web-based editing
14
+
15
+ ## Configuration
16
+
17
+ Add the playbooks directory to your `minded.json`:
18
+
19
+ ```json
20
+ {
21
+ "playbooks": ["./src/playbooks"]
22
+ }
23
+ ```
24
+
25
+ ## Creating Playbooks
26
+
27
+ Create YAML files in your playbooks directory using the EditorJS blocks structure:
28
+
29
+ ```yaml
30
+ # src/playbooks/general.yaml
31
+ id: general-playbooks
32
+ name: General Customer Service
33
+ blocks:
34
+ - type: header
35
+ data:
36
+ text: Customer Service Guidelines
37
+ level: 2
38
+ - type: paragraph
39
+ data:
40
+ text: "You are a helpful customer service agent for {companyName}."
41
+ - type: paragraph
42
+ data:
43
+ text: "Always be polite and professional in your responses."
44
+ - type: paragraph
45
+ data:
46
+ text: "Current time: <%= new Date().toISOString() %>"
47
+ - type: paragraph
48
+ data:
49
+ text: "User location: {userLocation}"
50
+ ```
51
+
52
+ ## Block Types
53
+
54
+ Playbooks support various EditorJS block types:
55
+
56
+ ### Header Block
57
+ ```yaml
58
+ - type: header
59
+ data:
60
+ text: "Section Title"
61
+ level: 2 # 1-6 for h1-h6
62
+ ```
63
+
64
+ ### Paragraph Block
65
+ ```yaml
66
+ - type: paragraph
67
+ data:
68
+ text: "Your paragraph content here"
69
+ ```
70
+
71
+ ### List Block
72
+ ```yaml
73
+ - type: list
74
+ data:
75
+ style: unordered # or "ordered"
76
+ items:
77
+ - "First item"
78
+ - "Second item"
79
+ - "Third item"
80
+ ```
81
+
82
+ ### Quote Block
83
+ ```yaml
84
+ - type: quote
85
+ data:
86
+ text: "Important note or quote"
87
+ caption: "Optional caption"
88
+ ```
89
+
90
+ ### Code Block
91
+ ```yaml
92
+ - type: code
93
+ data:
94
+ code: |
95
+ function example() {
96
+ return "code example";
97
+ }
98
+ ```
99
+
100
+ ### Delimiter Block
101
+ ```yaml
102
+ - type: delimiter
103
+ data: {}
104
+ ```
105
+
106
+ ## Using Templates
107
+
108
+ ### EJS Templates
109
+
110
+ Use EJS syntax (`<%= %>`) for dynamic content evaluated at compile time:
111
+
112
+ ```yaml
113
+ - type: paragraph
114
+ data:
115
+ text: "Today is <%= new Date().toDateString() %>"
116
+ - type: paragraph
117
+ data:
118
+ text: "Environment: <%= process.env.NODE_ENV %>"
119
+ ```
120
+
121
+ ### Placeholders
122
+
123
+ Use placeholders (`{state.memory.key}`) for values from the agent's memory state:
124
+
125
+ ```yaml
126
+ - type: paragraph
127
+ data:
128
+ text: "Hello {state.memory.customerName},"
129
+ - type: paragraph
130
+ data:
131
+ text: "Your order {state.memory.orderId} is being processed."
132
+ ```
133
+
134
+ These placeholders are automatically replaced with values from `state.memory` when the playbooks are compiled.
135
+
136
+ ## Using Memory Values in Playbooks
137
+
138
+ Placeholders in playbooks are replaced with values from the agent's memory state:
139
+
140
+ ```typescript
141
+ const updateCustomerTool: Tool<typeof inputSchema, any> = {
142
+ name: 'updateCustomer',
143
+ description: 'Update customer information',
144
+ input: inputSchema,
145
+ isGlobal: true,
146
+ execute: async ({ input, state }) => {
147
+ return {
148
+ memory: {
149
+ ...state.memory,
150
+ customer: input,
151
+ customerName: input.name,
152
+ userLocation: input.location,
153
+ },
154
+ };
155
+ },
156
+ };
157
+ ```
158
+
159
+ ## Nested Values
160
+
161
+ Placeholders support nested object access from the memory state:
162
+
163
+ ```yaml
164
+ - type: paragraph
165
+ data:
166
+ text: "Customer: {state.memory.customer.name}"
167
+ - type: paragraph
168
+ data:
169
+ text: "Email: {state.memory.customer.email}"
170
+ - type: paragraph
171
+ data:
172
+ text: "Order status: {state.memory.order.status}"
173
+ ```
174
+
175
+ These values are resolved from nested properties in `state.memory`, for example: `state.state.memory.customer.name`.
176
+
177
+ ## Complete Example
178
+
179
+ ```yaml
180
+ # src/playbooks/customer-service.yaml
181
+ id: customer-service-guidelines
182
+ name: Customer Service Guidelines
183
+ blocks:
184
+ - type: header
185
+ data:
186
+ text: Customer Service Best Practices
187
+ level: 1
188
+ - type: paragraph
189
+ data:
190
+ text: "You are representing {companyName} as a professional customer service agent."
191
+ - type: list
192
+ data:
193
+ style: unordered
194
+ items:
195
+ - "Always greet customers warmly"
196
+ - "Listen actively to their concerns"
197
+ - "Provide clear and helpful solutions"
198
+ - "Follow up to ensure satisfaction"
199
+ - type: quote
200
+ data:
201
+ text: "The customer's experience is our top priority"
202
+ caption: "Company motto"
203
+ - type: paragraph
204
+ data:
205
+ text: "Current session started: <%= new Date().toISOString() %>"
206
+ ```
207
+
208
+ ## Best Practices
209
+
210
+ 1. **Organize by purpose**: Create separate files for different aspects (general, domain-specific, compliance, etc.)
211
+ 2. **Use meaningful IDs**: Each playbook must have a unique ID
212
+ 3. **Structure content logically**: Use headers, lists, and quotes to organize information
213
+ 4. **Keep blocks focused**: Each block should contain a single concept or instruction
214
+ 5. **Document placeholders**: Comment which parameters your playbooks expect
215
+ 6. **Test thoroughly**: Verify that all placeholders are being populated correctly
216
+
217
+ ## Example Structure
218
+
219
+ ```
220
+ src/playbooks/
221
+ ├── general.yaml # General behavior guidelines
222
+ ├── compliance.yaml # Regulatory compliance rules
223
+ ├── brand-voice.yaml # Brand-specific communication style
224
+ └── domain-specific.yaml # Domain-specific instructions
225
+ ```
226
+
227
+ ## Platform Integration
228
+
229
+ When using the Minded platform:
230
+
231
+ 1. Playbooks are editable through the web interface using a rich text editor
232
+ 2. Changes are synchronized with your Git repository
233
+ 3. The platform uses the same EditorJS blocks format
234
+ 4. Local YAML files are automatically converted to the blocks format
235
+ 5. All templating features work the same in both local and platform environments
236
+
237
+ ## Migration from Content Format
238
+
239
+ If you have existing playbooks using the old `content` format, convert them to blocks:
240
+
241
+ **Old format:**
242
+ ```yaml
243
+ content: |
244
+ # Customer Service
245
+ Always be polite and professional.
246
+ Current time: <%= new Date().toISOString() %>
247
+ ```
248
+
249
+ **New format:**
250
+ ```yaml
251
+ blocks:
252
+ - type: header
253
+ data:
254
+ text: Customer Service
255
+ level: 1
256
+ - type: paragraph
257
+ data:
258
+ text: Always be polite and professional.
259
+ - type: paragraph
260
+ data:
261
+ text: "Current time: <%= new Date().toISOString() %>"
262
+ ```