@minded-ai/mindedjs 2.0.43 → 2.0.45-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 (36) hide show
  1. package/dist/agent.d.ts.map +1 -1
  2. package/dist/agent.js +29 -1
  3. package/dist/agent.js.map +1 -1
  4. package/dist/browserTask/executeBrowserTask.js +34 -33
  5. package/dist/browserTask/executeBrowserTask.js.map +1 -1
  6. package/dist/nodes/addThinkingNode.d.ts.map +1 -1
  7. package/dist/nodes/addThinkingNode.js +36 -11
  8. package/dist/nodes/addThinkingNode.js.map +1 -1
  9. package/dist/nodes/compilePrompt.d.ts.map +1 -1
  10. package/dist/nodes/compilePrompt.js +84 -4
  11. package/dist/nodes/compilePrompt.js.map +1 -1
  12. package/dist/platform/mindedConnectionTypes.d.ts +12 -1
  13. package/dist/platform/mindedConnectionTypes.d.ts.map +1 -1
  14. package/dist/platform/mindedConnectionTypes.js +1 -0
  15. package/dist/platform/mindedConnectionTypes.js.map +1 -1
  16. package/dist/types/Flows.types.d.ts +36 -23
  17. package/dist/types/Flows.types.d.ts.map +1 -1
  18. package/dist/types/Flows.types.js.map +1 -1
  19. package/dist/types/Tools.types.d.ts +5 -3
  20. package/dist/types/Tools.types.d.ts.map +1 -1
  21. package/dist/types/Tools.types.js.map +1 -1
  22. package/dist/utils/schemaConverter.d.ts +3 -0
  23. package/dist/utils/schemaConverter.d.ts.map +1 -0
  24. package/dist/utils/schemaConverter.js +73 -0
  25. package/dist/utils/schemaConverter.js.map +1 -0
  26. package/docs/low-code-editor/rpa-tools.md +17 -8
  27. package/package.json +2 -2
  28. package/src/agent.ts +40 -8
  29. package/src/browserTask/executeBrowserTask.ts +34 -34
  30. package/src/nodes/addPromptNode.ts +1 -1
  31. package/src/nodes/addThinkingNode.ts +40 -12
  32. package/src/nodes/compilePrompt.ts +92 -4
  33. package/src/platform/mindedConnectionTypes.ts +13 -0
  34. package/src/types/Flows.types.ts +39 -32
  35. package/src/types/Tools.types.ts +7 -3
  36. package/src/utils/schemaConverter.ts +82 -0
@@ -104,6 +104,33 @@ export interface ScheduleTriggerNode extends BaseTriggerNode {
104
104
  timezone?: string;
105
105
  }
106
106
 
107
+ /**
108
+ * Base schema field type for backward compatibility with platform.
109
+ * Represents simple input/output schema fields (string and number only).
110
+ */
111
+ export interface SchemaField {
112
+ name: string;
113
+ type: 'string' | 'number';
114
+ description?: string;
115
+ required?: boolean;
116
+ }
117
+
118
+ /**
119
+ * Extended schema field type with support for complex types (boolean, array, object).
120
+ * Uses Omit to override the 'type' field and intersection type (&) with Partial<> to
121
+ * elegantly add optional properties for complex types (items, properties).
122
+ * Filtered for backward compatibility when communicating with platform.
123
+ */
124
+ export type OutputSchemaField = Omit<SchemaField, 'type'> & {
125
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object';
126
+ } & Partial<{
127
+ items: {
128
+ type: 'string' | 'number' | 'boolean' | 'object';
129
+ properties?: any;
130
+ };
131
+ properties: any;
132
+ }>;
133
+
107
134
  export interface PromptNode extends BaseNode {
108
135
  type: NodeType.PROMPT_NODE;
109
136
  prompt: string;
@@ -114,6 +141,7 @@ export interface ThinkingNode extends BaseNode {
114
141
  type: NodeType.THINKING;
115
142
  prompt: string;
116
143
  llmConfig?: LLMConfig;
144
+ outputSchema?: OutputSchemaField[];
117
145
  }
118
146
 
119
147
  export interface JumpToNode extends BaseNode {
@@ -125,18 +153,8 @@ export interface BrowserTaskNode extends BaseNode {
125
153
  type: NodeType.BROWSER_TASK;
126
154
  prompt: string;
127
155
  model?: string;
128
- inputSchema?: {
129
- name: string;
130
- type: 'string' | 'number';
131
- description?: string;
132
- required?: boolean;
133
- }[];
134
- outputSchema?: {
135
- name: string;
136
- type: 'string' | 'number';
137
- description?: string;
138
- required?: boolean;
139
- }[];
156
+ inputSchema?: SchemaField[];
157
+ outputSchema?: OutputSchemaField[];
140
158
  autoTrigger?: boolean;
141
159
  defaultPayload?: string;
142
160
  proxy?: string; // 2-digit country code like 'IL'
@@ -166,17 +184,7 @@ export interface RpaStep {
166
184
  shouldReplaceExistingText?: boolean;
167
185
  waitTime?: number;
168
186
  description?: string;
169
- outputSchema?: {
170
- name: string;
171
- type: 'string' | 'number' | 'boolean' | 'array' | 'object';
172
- description?: string;
173
- required?: boolean;
174
- items?: {
175
- type: 'string' | 'number' | 'boolean' | 'object';
176
- properties?: any;
177
- };
178
- properties?: any;
179
- }[];
187
+ outputSchema?: OutputSchemaField[];
180
188
  }
181
189
 
182
190
  export type TriggerNode =
@@ -197,6 +205,13 @@ export interface ToolNode extends BaseNode {
197
205
  prompt: string;
198
206
  appImgSrc?: string;
199
207
  parameters?: Record<string, any>;
208
+ inputSchema?: {
209
+ name: string;
210
+ type: 'string' | 'number' | 'boolean' | 'array';
211
+ description?: string;
212
+ required?: boolean;
213
+ }[];
214
+ outputSchema?: OutputSchemaField[];
200
215
  }
201
216
 
202
217
  export interface AppToolNode extends BaseNode, BaseAppNode {
@@ -208,15 +223,7 @@ export interface AppToolNode extends BaseNode, BaseAppNode {
208
223
  actionKey: string;
209
224
  }
210
225
 
211
- export type Node =
212
- | TriggerNode
213
- | JunctionNode
214
- | ToolNode
215
- | AppToolNode
216
- | PromptNode
217
- | JumpToNode
218
- | BrowserTaskNode
219
- | ThinkingNode;
226
+ export type Node = TriggerNode | JunctionNode | ToolNode | AppToolNode | PromptNode | JumpToNode | BrowserTaskNode | ThinkingNode;
220
227
 
221
228
  export interface BaseEdge {
222
229
  source: string;
@@ -8,13 +8,16 @@ import { BrowserTaskMode } from '../browserTask/types';
8
8
  export type ToolReturnType = { result?: any } | void;
9
9
 
10
10
  // Tool can be either RPA or Default
11
- export type Tool<Input extends z.ZodSchema, Memory = any> = RPATool<Input, Memory> | DefaultTool<Input, Memory>;
11
+ export type Tool<Input extends z.ZodSchema, Memory = any, Output extends z.ZodSchema = any> =
12
+ | RPATool<Input, Memory, Output>
13
+ | DefaultTool<Input, Memory, Output>;
12
14
 
13
15
  // RPA Tool - always includes Page
14
- export interface RPATool<Input extends z.ZodSchema, Memory = any> {
16
+ export interface RPATool<Input extends z.ZodSchema, Memory = any, Output extends z.ZodSchema = any> {
15
17
  name: string;
16
18
  description: string;
17
19
  input: Input;
20
+ output?: Output;
18
21
  isGlobal?: boolean;
19
22
  allowExecutionRequests?: boolean;
20
23
  type: 'rpa';
@@ -24,10 +27,11 @@ export interface RPATool<Input extends z.ZodSchema, Memory = any> {
24
27
  }
25
28
 
26
29
  // Default Tool - no Page parameter
27
- export interface DefaultTool<Input extends z.ZodSchema, Memory = any> {
30
+ export interface DefaultTool<Input extends z.ZodSchema, Memory = any, Output extends z.ZodSchema = any> {
28
31
  name: string;
29
32
  description: string;
30
33
  input: Input;
34
+ output?: Output;
31
35
  isGlobal?: boolean;
32
36
  allowExecutionRequests?: boolean;
33
37
  type?: 'default';
@@ -0,0 +1,82 @@
1
+ import { z } from 'zod';
2
+ import { OutputSchemaField } from '../types/Flows.types';
3
+ import { logger } from './logger';
4
+
5
+ export function convertArraySchemaToZod(schemaArray: unknown): z.ZodObject<any> {
6
+ if (schemaArray && typeof schemaArray === 'object' && '_def' in schemaArray) {
7
+ return schemaArray as z.ZodObject<any>;
8
+ }
9
+
10
+ if (!Array.isArray(schemaArray) || schemaArray.length === 0) {
11
+ logger.warn({ message: 'Empty or invalid schema array provided to convertArraySchemaToZod', schemaArray });
12
+ return z.object({});
13
+ }
14
+
15
+ const typeMap: Record<string, (field: OutputSchemaField) => z.ZodTypeAny> = {
16
+ string: () => z.string(),
17
+ number: () => z.number(),
18
+ boolean: () => z.boolean(),
19
+ // For arrays, check if items are defined, otherwise default to string array
20
+ array: (field) => {
21
+ if (field.items?.type) {
22
+ const itemTypeMap: Record<string, z.ZodTypeAny> = {
23
+ string: z.string(),
24
+ number: z.number(),
25
+ boolean: z.boolean(),
26
+ };
27
+ return z.array(itemTypeMap[field.items.type] || z.string());
28
+ }
29
+ return z.array(z.string());
30
+ },
31
+ // For objects, create a record type that allows any key-value pairs
32
+ // OpenAI's structured outputs don't support truly dynamic objects well
33
+ // So we use record(string, string) which is the most flexible allowed format
34
+ object: (field) => {
35
+ if (field.properties && Object.keys(field.properties).length > 0) {
36
+ // If properties are defined, create a structured object
37
+ const shape = Object.fromEntries(
38
+ Object.entries(field.properties).map(([key, value]: [string, any]) => {
39
+ const propType = value.type || 'string';
40
+ const propTypeMap: Record<string, z.ZodTypeAny> = {
41
+ string: z.string(),
42
+ number: z.number(),
43
+ boolean: z.boolean(),
44
+ };
45
+ return [key, propTypeMap[propType] || z.string()];
46
+ }),
47
+ );
48
+ return z.object(shape);
49
+ }
50
+ // If no properties defined, use record(string, string) for maximum compatibility
51
+ // This allows any key-value pairs where values are strings
52
+ return z.record(z.string(), z.string());
53
+ },
54
+ };
55
+
56
+ const shape = Object.fromEntries(
57
+ schemaArray.map((field: OutputSchemaField) => {
58
+ const typeFunc = typeMap[field.type];
59
+ let schema = typeFunc ? typeFunc(field) : z.any();
60
+
61
+ if (field.description) {
62
+ schema = schema.describe(field.description);
63
+ }
64
+
65
+ // OpenAI's structured outputs require all fields in the 'required' array
66
+ // To make a field optional, we use .nullable() which means the field is required but can be null
67
+ // This satisfies OpenAI's requirement while allowing optional fields
68
+ if (!field.required) {
69
+ schema = schema.nullable();
70
+ }
71
+
72
+ return [field.name, schema];
73
+ }),
74
+ );
75
+
76
+ // Create the final Zod object
77
+ // Note: All fields will be in the 'required' array for OpenAI's JSON schema
78
+ // Optional fields are handled by .nullable() above
79
+ const zodObject = z.object(shape);
80
+
81
+ return zodObject;
82
+ }