@minded-ai/mindedjs 2.0.36-beta.4 → 2.0.36-beta.6

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.
@@ -48,6 +48,8 @@ Trigger nodes are entry points that start your flows and initialize them with me
48
48
 
49
49
  ### Trigger Implementation
50
50
 
51
+ Handle triggers in your agent code:
52
+
51
53
  ```ts
52
54
  import { events } from 'mindedjs/src/index';
53
55
  import { HumanMessage } from '@langchain/core/messages';
@@ -55,109 +57,77 @@ import { HumanMessage } from '@langchain/core/messages';
55
57
  agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
56
58
  if (triggerName === 'customer-support-request') {
57
59
  return {
58
- memory: {
59
- customerQuery: triggerBody,
60
- timestamp: new Date().toISOString(),
61
- },
60
+ memory: { customerQuery: triggerBody, timestamp: new Date().toISOString() },
62
61
  messages: [new HumanMessage(triggerBody)],
63
62
  };
64
63
  }
64
+ // Return { isQualified: false } to prevent flow execution
65
65
  });
66
66
  ```
67
67
 
68
- #### Disqualifying Triggers
69
-
70
- Return an object with `isQualified: false` to prevent flow execution:
68
+ ## Prompt Nodes
71
69
 
72
- ```ts
73
- agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
74
- // Only process during business hours
75
- const hour = new Date().getHours();
76
- if (hour < 9 || hour > 17) {
77
- return { isQualified: false };
78
- }
70
+ Prompt nodes process input through LLM to generate intelligent responses or invoke tools.
79
71
 
80
- return {
81
- isQualified: true,
82
- memory: { businessHours: true },
83
- messages: [new HumanMessage(triggerBody)],
84
- };
85
- });
86
- ```
72
+ ### Context
73
+ - Prompt nodes automatically have access to previous nodes' output as context.
74
+ - You can also inject context from the memory object using the {memory.propertyName} placeholder.
87
75
 
88
- ## Prompt Nodes
76
+ ### Properties
77
+ - `humanInTheLoop?: boolean` - When `true`, pauses execution after this node for human input before continuing. Use this property only if you need to gather an input from the user.
78
+ - `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.
89
79
 
90
- Prompt nodes process input through LLM to generate intelligent responses or invoke tools.
80
+ ### Limitations
81
+ - Prompt nodes can not save information to memory directly. Rather the user & agent messages are stored in the messages array of the state object. Making user's input available to the next prompt nodes or tools in the form of input schema.
82
+ - Image recognition is only supported when a user attaches an image to the message. If you need to extract information from an image, use a tool with agent.llm to process the image. Return the result in the tool response so following prompt nodes can use it.
91
83
 
92
- **Optional Properties:**
84
+ ### Common Prompt Patterns
93
85
 
94
- - `humanInTheLoop?: boolean` - When `true`, pauses execution after this node for human input before continuing
95
- - `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.
86
+ #### Extract Information from User
96
87
 
97
- **Example Usage:**
88
+ Use `humanInTheLoop: true` and `canStayOnNode: true` with `promptCondition` edges for iterative information gathering:
98
89
 
99
90
  ```yaml
100
91
  - type: promptNode
101
- name: content-reviewer
102
- displayName: Content Reviewer
103
- prompt: 'Ask user to review the content and approve or request changes.'
104
- humanInTheLoop: true # Pause for human approval before proceeding
92
+ name: collect-customer-info
93
+ displayName: Collect Customer Information
94
+ prompt: 'Ask the user for their contact information (name, email, phone).'
95
+ humanInTheLoop: true
96
+ canStayOnNode: true
105
97
 
106
- - type: promptNode
107
- name: research-assistant
108
- displayName: Research Assistant
109
- prompt: 'Request user for more information until you have gathered all necessary information.'
110
- canStayOnNode: true # Allow iterative research until complete
111
- humanInTheLoop: true # Pause for human approval before proceeding
98
+ edges:
99
+ - source: collect-customer-info
100
+ target: validate-info
101
+ type: promptCondition
102
+ prompt: 'Has all required information been collected?'
112
103
  ```
113
104
 
114
- ### Basic Configuration
105
+ #### Notify User
106
+
107
+ Use standard prompt nodes with `stepForward` edges for one-way notifications:
115
108
 
116
109
  ```yaml
117
110
  - type: promptNode
118
- name: customer-service-agent
119
- displayName: Customer Service Agent
120
- prompt: |
121
- You are a helpful customer service representative.
122
- Respond to customer inquiries professionally.
123
-
124
- Customer: {memory.customerName}
125
- Issue: {memory.issueCategory}
126
- Current Time: {system.currentTime}
127
- llmConfig:
128
- name: ChatOpenAI
129
- properties:
130
- model: gpt-4o
131
- temperature: 0.7
132
- max_tokens: 500
133
- ```
111
+ name: send-confirmation
112
+ displayName: Send Confirmation
113
+ prompt: 'Send confirmation: Order {memory.orderId}, Total: {memory.orderTotal}'
134
114
 
135
- ### Placeholder Support
136
-
137
- Prompt nodes support the following placeholder syntax:
138
-
139
- - **Memory placeholders**: `{memory.propertyName}` - Access values from the agent's memory state
140
- - **Nested memory values**: `{memory.customer.name}` - Access nested properties in memory
141
- - **System placeholders**: `{system.currentTime}` - Access system values like the current ISO timestamp
115
+ edges:
116
+ - source: process-order
117
+ target: send-confirmation
118
+ type: stepForward
119
+ ```
142
120
 
143
- ### LLM Configuration Options
121
+ ### Custom LLM Configuration
122
+ Provide a custom LLM configuration to the prompt node using the `llmConfig` property.
144
123
 
145
124
  ```yaml
146
- # OpenAI
147
125
  llmConfig:
148
- name: ChatOpenAI
126
+ name: ChatOpenAI # or ChatAnthropic
149
127
  properties:
150
- model: gpt-4o # or gpt-4o-mini, gpt-3.5-turbo
151
- temperature: 0.7 # 0.0 (deterministic) to 1.0 (creative)
128
+ model: gpt-4o
129
+ temperature: 0.7
152
130
  max_tokens: 500
153
-
154
- # Anthropic Claude
155
- llmConfig:
156
- name: ChatAnthropic
157
- properties:
158
- model: claude-3-sonnet-20240229
159
- temperature: 0.5
160
- max_tokens: 1000
161
131
  ```
162
132
 
163
133
  ## Tool Nodes
@@ -173,41 +143,6 @@ Tool nodes execute functions to perform actions like API calls or database queri
173
143
  toolName: lookupOrder
174
144
  ```
175
145
 
176
- ### Tool Implementation
177
-
178
- ```ts
179
- import { z } from 'zod';
180
- import { Tool } from 'mindedjs/src/types/Tools.types';
181
-
182
- const schema = z.object({
183
- orderId: z.string(),
184
- customerEmail: z.string().optional(),
185
- });
186
-
187
- const lookupOrderTool: Tool<typeof schema, Memory> = {
188
- name: 'lookupOrder',
189
- description: 'Look up order details by order ID',
190
- input: schema,
191
- execute: async ({ input, memory }) => {
192
- const order = await fetchOrderById(input.orderId);
193
-
194
- if (!order) {
195
- throw new Error(`Order ${input.orderId} not found`);
196
- }
197
-
198
- return {
199
- memory: {
200
- orderInfo: order,
201
- orderStatus: order.status,
202
- },
203
- result: `Found order ${order.id} - Status: ${order.status}`,
204
- };
205
- },
206
- };
207
-
208
- export default lookupOrderTool;
209
- ```
210
-
211
146
  ## Junction Nodes
212
147
 
213
148
  Junction nodes provide flow control without processing, useful for organizing routing logic.
@@ -223,27 +158,19 @@ Junction nodes provide flow control without processing, useful for organizing ro
223
158
  ### Routing Example
224
159
 
225
160
  ```yaml
226
- nodes:
227
- - type: junction
228
- name: route-customer-request
229
- displayName: Route Customer Request
230
- - type: promptNode
231
- name: vip-support
232
- displayName: VIP Support
233
- - type: promptNode
234
- name: standard-support
235
- displayName: Standard Support
161
+ - type: junction
162
+ name: route-customer-request
163
+ displayName: Route Customer Request
236
164
 
237
165
  edges:
238
166
  - source: route-customer-request
239
167
  target: vip-support
240
168
  type: logicalCondition
241
- condition: "({ memory }) => memory.customerTier === 'premium'"
242
-
169
+ condition: "state.memory.customerTier === 'premium'"
243
170
  - source: route-customer-request
244
171
  target: standard-support
245
172
  type: logicalCondition
246
- condition: "({ memory }) => memory.customerTier === 'standard'"
173
+ condition: "state.memory.customerTier === 'standard'"
247
174
  ```
248
175
 
249
176
  ## Jump To Nodes
@@ -259,100 +186,29 @@ Jump To nodes provide direct navigation to specific nodes, enabling flow transit
259
186
  targetNodeId: process-customer-order
260
187
  ```
261
188
 
262
- ### Subflow Navigation
189
+ ### Cross-Flow Navigation
263
190
 
264
- Jump To nodes are particularly useful for organizing complex workflows into multiple flows:
191
+ Jump To nodes enable navigation between flows. Target nodes can exist in different flow files, and state is preserved during jumps:
265
192
 
266
193
  ```yaml
267
- # Main flow
194
+ # flows/mainFlow.yaml
268
195
  - type: jumpToNode
269
- name: jump-to-refund-subflow
270
- displayName: Jump To Refund Subflow
271
- targetNodeId: refund-processing-trigger
196
+ name: go-to-refund-flow
197
+ displayName: Go To Refund Flow
198
+ targetNodeId: refund-processor
272
199
 
273
- # In refund subflow
200
+ # flows/refundFlow.yaml
274
201
  - type: trigger
275
- name: refund-processing-trigger
276
- displayName: Refund Processing Trigger
202
+ name: refund-processor
203
+ displayName: Refund Processor
277
204
  triggerType: manual
278
205
  ```
279
206
 
280
- ### Multi-Flow Example
281
-
282
- ```yaml
283
- # flows/mainFlow.yaml
284
- nodes:
285
- - type: trigger
286
- name: customer-request
287
- displayName: Customer Request
288
- triggerType: manual
289
-
290
- - type: promptNode
291
- name: classify-request
292
- displayName: Classify Request
293
- prompt: |
294
- Classify the customer request as either 'refund' or 'support'.
295
- Customer message: {{messages.last.content}}
296
-
297
- - type: jumpToNode
298
- name: go-to-refund-flow
299
- displayName: Go To Refund Flow
300
- targetNodeId: refund-processor
301
-
302
- # flows/refundFlow.yaml
303
- nodes:
304
- - type: trigger
305
- name: refund-processor
306
- displayName: Refund Processor
307
- triggerType: manual
308
-
309
- - type: tool
310
- name: process-refund
311
- displayName: Process Refund
312
- toolName: processRefund
313
- ```
314
-
315
- ### Implementation Notes
316
-
317
- - **Direct Navigation**: Jump To nodes create direct edges to their target nodes
318
- - **Cross-Flow Support**: Target nodes can exist in different flow files
319
- - **State Preservation**: Current memory and message state is maintained during jumps
320
- - **No Processing**: Jump To nodes perform no data processing, only navigation
321
-
322
207
  ## Best Practices
323
208
 
324
- ### Use Descriptive Names
325
-
326
- ```yaml
327
- # ✅ Good
328
- - type: promptNode
329
- name: technical-support-specialist
330
- displayName: Technical Support Specialist
331
-
332
- # ❌ Avoid
333
- - type: promptNode
334
- name: agent-1
335
- displayName: Agent 1
336
- ```
337
-
338
- ### Keep Prompts Focused
339
-
340
- ```yaml
341
- # ✅ Good - Specific role and context
342
- - type: promptNode
343
- name: order-refund-processor
344
- displayName: Order Refund Processor
345
- prompt: |
346
- You process customer refund requests for e-commerce orders.
347
- Order ID: {{memory.orderId}}
348
- Determine if refund should be approved based on order status and timing.
349
-
350
- # ❌ Avoid - Too broad
351
- - type: promptNode
352
- name: general-assistant
353
- displayName: General Assistant
354
- prompt: 'Help the customer with anything they need'
355
- ```
209
+ - **Use descriptive names**: `technical-support-specialist` not `agent-1`
210
+ - **Keep prompts focused**: Define specific roles and context, avoid overly broad prompts
211
+ - **Always include `displayName`**: Required for prompt nodes, recommended for all nodes
356
212
 
357
213
  ## Browser Task Nodes
358
214
 
@@ -367,20 +223,18 @@ Browser task nodes allow your agent to interact with web pages using AI-powered
367
223
  prompt: 'Go to amazon.com and search for wireless headphones under $100'
368
224
  ```
369
225
 
370
- ### Browser Task with Custom Model
226
+ ### Custom Model
371
227
 
372
- You can specify which AI model to use for browser automation:
228
+ Specify which AI model to use (default: `gpt-4o`):
373
229
 
374
230
  ```yaml
375
231
  - type: browserTask
376
- name: complex_task
232
+ name: complex-task
377
233
  displayName: Complex Web Task
378
234
  prompt: 'Navigate to the support page and fill out the contact form'
379
- model: 'gpt-4o' # Options: gpt-4o (default), gpt-4-turbo, claude-3-opus, etc.
235
+ model: 'gpt-4o' # Options: gpt-4o, gpt-4-turbo, claude-3-opus, etc.
380
236
  ```
381
237
 
382
- The browser task will execute the prompt using the browser-use CLI tool, which provides AI-powered browser automation capabilities.
383
-
384
238
  ## Next Steps
385
239
 
386
240
  - [**Edges**](edges.md) - Connect nodes with intelligent routing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minded-ai/mindedjs",
3
- "version": "2.0.36-beta.4",
3
+ "version": "2.0.36-beta.6",
4
4
  "description": "MindedJS is a TypeScript library for building agents.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",