@mastra/agent-builder 0.0.0-vnext-20251104230439 → 0.0.0-vnext-20251119160359
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.
- package/CHANGELOG.md +88 -4
- package/dist/defaults.d.ts +1074 -24
- package/dist/defaults.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/workflows/task-planning/schema.d.ts +6 -6
- package/dist/workflows/task-planning/task-planning.d.ts +12 -12
- package/dist/workflows/workflow-builder/prompts.d.ts +1 -1
- package/dist/workflows/workflow-builder/prompts.d.ts.map +1 -1
- package/dist/workflows/workflow-builder/schema.d.ts +10 -10
- package/dist/workflows/workflow-builder/tools.d.ts +106 -0
- package/dist/workflows/workflow-builder/tools.d.ts.map +1 -1
- package/dist/workflows/workflow-builder/workflow-builder.d.ts +28 -28
- package/package.json +11 -9
|
@@ -106,14 +106,14 @@ export declare const PlanningIterationInputSchema: z.ZodObject<{
|
|
|
106
106
|
snippet: z.ZodString;
|
|
107
107
|
relevance: z.ZodNumber;
|
|
108
108
|
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
url: string;
|
|
109
110
|
relevance: number;
|
|
110
111
|
title: string;
|
|
111
|
-
url: string;
|
|
112
112
|
snippet: string;
|
|
113
113
|
}, {
|
|
114
|
+
url: string;
|
|
114
115
|
relevance: number;
|
|
115
116
|
title: string;
|
|
116
|
-
url: string;
|
|
117
117
|
snippet: string;
|
|
118
118
|
}>, "many">;
|
|
119
119
|
message: z.ZodString;
|
|
@@ -127,9 +127,9 @@ export declare const PlanningIterationInputSchema: z.ZodObject<{
|
|
|
127
127
|
bestPractices: string[];
|
|
128
128
|
};
|
|
129
129
|
webResources: {
|
|
130
|
+
url: string;
|
|
130
131
|
relevance: number;
|
|
131
132
|
title: string;
|
|
132
|
-
url: string;
|
|
133
133
|
snippet: string;
|
|
134
134
|
}[];
|
|
135
135
|
error?: string | undefined;
|
|
@@ -142,9 +142,9 @@ export declare const PlanningIterationInputSchema: z.ZodObject<{
|
|
|
142
142
|
bestPractices: string[];
|
|
143
143
|
};
|
|
144
144
|
webResources: {
|
|
145
|
+
url: string;
|
|
145
146
|
relevance: number;
|
|
146
147
|
title: string;
|
|
147
|
-
url: string;
|
|
148
148
|
snippet: string;
|
|
149
149
|
}[];
|
|
150
150
|
error?: string | undefined;
|
|
@@ -184,9 +184,9 @@ export declare const PlanningIterationInputSchema: z.ZodObject<{
|
|
|
184
184
|
bestPractices: string[];
|
|
185
185
|
};
|
|
186
186
|
webResources: {
|
|
187
|
+
url: string;
|
|
187
188
|
relevance: number;
|
|
188
189
|
title: string;
|
|
189
|
-
url: string;
|
|
190
190
|
snippet: string;
|
|
191
191
|
}[];
|
|
192
192
|
error?: string | undefined;
|
|
@@ -229,9 +229,9 @@ export declare const PlanningIterationInputSchema: z.ZodObject<{
|
|
|
229
229
|
bestPractices: string[];
|
|
230
230
|
};
|
|
231
231
|
webResources: {
|
|
232
|
+
url: string;
|
|
232
233
|
relevance: number;
|
|
233
234
|
title: string;
|
|
234
|
-
url: string;
|
|
235
235
|
snippet: string;
|
|
236
236
|
}[];
|
|
237
237
|
error?: string | undefined;
|
|
@@ -109,14 +109,14 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
109
109
|
snippet: import("zod").ZodString;
|
|
110
110
|
relevance: import("zod").ZodNumber;
|
|
111
111
|
}, "strip", import("zod").ZodTypeAny, {
|
|
112
|
+
url: string;
|
|
112
113
|
relevance: number;
|
|
113
114
|
title: string;
|
|
114
|
-
url: string;
|
|
115
115
|
snippet: string;
|
|
116
116
|
}, {
|
|
117
|
+
url: string;
|
|
117
118
|
relevance: number;
|
|
118
119
|
title: string;
|
|
119
|
-
url: string;
|
|
120
120
|
snippet: string;
|
|
121
121
|
}>, "many">;
|
|
122
122
|
message: import("zod").ZodString;
|
|
@@ -130,9 +130,9 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
130
130
|
bestPractices: string[];
|
|
131
131
|
};
|
|
132
132
|
webResources: {
|
|
133
|
+
url: string;
|
|
133
134
|
relevance: number;
|
|
134
135
|
title: string;
|
|
135
|
-
url: string;
|
|
136
136
|
snippet: string;
|
|
137
137
|
}[];
|
|
138
138
|
error?: string | undefined;
|
|
@@ -145,9 +145,9 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
145
145
|
bestPractices: string[];
|
|
146
146
|
};
|
|
147
147
|
webResources: {
|
|
148
|
+
url: string;
|
|
148
149
|
relevance: number;
|
|
149
150
|
title: string;
|
|
150
|
-
url: string;
|
|
151
151
|
snippet: string;
|
|
152
152
|
}[];
|
|
153
153
|
error?: string | undefined;
|
|
@@ -187,9 +187,9 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
187
187
|
bestPractices: string[];
|
|
188
188
|
};
|
|
189
189
|
webResources: {
|
|
190
|
+
url: string;
|
|
190
191
|
relevance: number;
|
|
191
192
|
title: string;
|
|
192
|
-
url: string;
|
|
193
193
|
snippet: string;
|
|
194
194
|
}[];
|
|
195
195
|
error?: string | undefined;
|
|
@@ -232,9 +232,9 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
232
232
|
bestPractices: string[];
|
|
233
233
|
};
|
|
234
234
|
webResources: {
|
|
235
|
+
url: string;
|
|
235
236
|
relevance: number;
|
|
236
237
|
title: string;
|
|
237
|
-
url: string;
|
|
238
238
|
snippet: string;
|
|
239
239
|
}[];
|
|
240
240
|
error?: string | undefined;
|
|
@@ -766,14 +766,14 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
766
766
|
snippet: import("zod").ZodString;
|
|
767
767
|
relevance: import("zod").ZodNumber;
|
|
768
768
|
}, "strip", import("zod").ZodTypeAny, {
|
|
769
|
+
url: string;
|
|
769
770
|
relevance: number;
|
|
770
771
|
title: string;
|
|
771
|
-
url: string;
|
|
772
772
|
snippet: string;
|
|
773
773
|
}, {
|
|
774
|
+
url: string;
|
|
774
775
|
relevance: number;
|
|
775
776
|
title: string;
|
|
776
|
-
url: string;
|
|
777
777
|
snippet: string;
|
|
778
778
|
}>, "many">;
|
|
779
779
|
message: import("zod").ZodString;
|
|
@@ -787,9 +787,9 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
787
787
|
bestPractices: string[];
|
|
788
788
|
};
|
|
789
789
|
webResources: {
|
|
790
|
+
url: string;
|
|
790
791
|
relevance: number;
|
|
791
792
|
title: string;
|
|
792
|
-
url: string;
|
|
793
793
|
snippet: string;
|
|
794
794
|
}[];
|
|
795
795
|
error?: string | undefined;
|
|
@@ -802,9 +802,9 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
802
802
|
bestPractices: string[];
|
|
803
803
|
};
|
|
804
804
|
webResources: {
|
|
805
|
+
url: string;
|
|
805
806
|
relevance: number;
|
|
806
807
|
title: string;
|
|
807
|
-
url: string;
|
|
808
808
|
snippet: string;
|
|
809
809
|
}[];
|
|
810
810
|
error?: string | undefined;
|
|
@@ -844,9 +844,9 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
844
844
|
bestPractices: string[];
|
|
845
845
|
};
|
|
846
846
|
webResources: {
|
|
847
|
+
url: string;
|
|
847
848
|
relevance: number;
|
|
848
849
|
title: string;
|
|
849
|
-
url: string;
|
|
850
850
|
snippet: string;
|
|
851
851
|
}[];
|
|
852
852
|
error?: string | undefined;
|
|
@@ -889,9 +889,9 @@ export declare const planningAndApprovalWorkflow: import("@mastra/core/workflows
|
|
|
889
889
|
bestPractices: string[];
|
|
890
890
|
};
|
|
891
891
|
webResources: {
|
|
892
|
+
url: string;
|
|
892
893
|
relevance: number;
|
|
893
894
|
title: string;
|
|
894
|
-
url: string;
|
|
895
895
|
snippet: string;
|
|
896
896
|
}[];
|
|
897
897
|
error?: string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const workflowResearch = "\n## \uD83D\uDD0D **COMPREHENSIVE MASTRA WORKFLOW RESEARCH SUMMARY**\n\nBased on extensive research of Mastra documentation and examples, here's essential information for building effective Mastra workflows:\n\n### **\uD83D\uDCCB WORKFLOW FUNDAMENTALS**\n\n**Core Components:**\n- **`createWorkflow()`**: Main factory function that creates workflow instances\n- **`createStep()`**: Creates individual workflow steps with typed inputs/outputs \n- **`.commit()`**: Finalizes workflow definition (REQUIRED to make workflows executable)\n- **Zod schemas**: Used for strict input/output typing and validation\n\n**Basic Structure:**\n```typescript\nimport { createWorkflow, createStep } from \"@mastra/core/workflows\";\nimport { z } from \"zod\";\n\nconst workflow = createWorkflow({\n id: \"unique-workflow-id\", // Required: kebab-case recommended\n description: \"What this workflow does\", // Optional but recommended\n inputSchema: z.object({...}), // Required: Defines workflow inputs\n outputSchema: z.object({...}) // Required: Defines final outputs\n})\n .then(step1) // Chain steps sequentially\n .then(step2)\n .commit(); // CRITICAL: Makes workflow executable\n```\n\n### **\uD83D\uDD27 STEP CREATION PATTERNS**\n\n**Standard Step Definition:**\n```typescript\nconst myStep = createStep({\n id: \"step-id\", // Required: unique identifier\n description: \"Step description\", // Recommended for clarity\n inputSchema: z.object({...}), // Required: input validation\n outputSchema: z.object({...}), // Required: output validation\n execute: async ({ inputData, mastra, getStepResult, getInitData }) => {\n // Step logic here\n return { /* matches outputSchema */ };\n }\n});\n```\n\n**Execute Function Parameters:**\n- `inputData`: Validated input matching inputSchema\n- `mastra`: Access to Mastra instance (agents, tools, other workflows)\n- `getStepResult(stepInstance)`: Get results from previous steps\n- `getInitData()`: Access original workflow input data\n- `requestContext`: Runtime dependency injection context\n- `runCount`: Number of times this step has run (useful for retries)\n\n### **\uD83D\uDD04 CONTROL FLOW METHODS**\n\n**Sequential Execution:**\n- `.then(step)`: Execute steps one after another\n- Data flows automatically if schemas match\n\n**Parallel Execution:**\n- `.parallel([step1, step2])`: Run steps simultaneously\n- All parallel steps complete before continuing\n\n**Conditional Logic:**\n- `.branch([[condition, step], [condition, step]])`: Execute different steps based on conditions\n- Conditions evaluated sequentially, matching steps run in parallel\n\n**Loops:**\n- `.dountil(step, condition)`: Repeat until condition becomes true\n- `.dowhile(step, condition)`: Repeat while condition is true \n- `.foreach(step, {concurrency: N})`: Execute step for each array item\n\n**Data Transformation:**\n- `.map(({ inputData, getStepResult, getInitData }) => transformedData)`: Transform data between steps\n\n### **\u23F8\uFE0F SUSPEND & RESUME CAPABILITIES**\n\n**For Human-in-the-Loop Workflows:**\n```typescript\nconst userInputStep = createStep({\n id: \"user-input\",\n suspendSchema: z.object({}), // Schema for suspension payload\n resumeSchema: z.object({ // Schema for resume data\n userResponse: z.string()\n }),\n execute: async ({ resumeData, suspend }) => {\n if (!resumeData?.userResponse) {\n await suspend({}); // Pause workflow\n return { response: \"\" };\n }\n return { response: resumeData.userResponse };\n }\n});\n```\n\n**Resume Workflow:**\n```typescript\nconst result = await run.start({ inputData: {...} });\nif (result.status === \"suspended\") {\n await run.resume({\n step: result.suspended[0], // Or specific step ID\n resumeData: { userResponse: \"answer\" }\n });\n}\n```\n\n### **\uD83D\uDEE0\uFE0F INTEGRATING AGENTS & TOOLS**\n\n**Using Agents in Steps:**\n```typescript\n// Method 1: Agent as step\nconst agentStep = createStep(myAgent);\n\n// Method 2: Call agent in execute function\nconst step = createStep({\n execute: async ({ inputData }) => {\n const result = await myAgent.generate(prompt);\n return { output: result.text };\n }\n});\n```\n\n**Using Tools in Steps:**\n```typescript\n// Method 1: Tool as step \nconst toolStep = createStep(myTool);\n\n// Method 2: Call tool in execute function\nconst step = createStep({\n execute: async ({ inputData, requestContext }) => {\n const result = await myTool.execute({\n context: inputData,\n requestContext\n });\n return result;\n }\n});\n```\n\n### **\uD83D\uDDC2\uFE0F PROJECT ORGANIZATION PATTERNS**\n\n**MANDATORY Workflow Organization:**\nEach workflow MUST be organized in its own dedicated folder with separated concerns:\n\n```\nsrc/mastra/workflows/\n\u251C\u2500\u2500 my-workflow-name/ # Kebab-case folder name\n\u2502 \u251C\u2500\u2500 types.ts # All Zod schemas and TypeScript types\n\u2502 \u251C\u2500\u2500 steps.ts # All individual step definitions\n\u2502 \u251C\u2500\u2500 workflow.ts # Main workflow composition and export\n\u2502 \u2514\u2500\u2500 utils.ts # Helper functions (if needed)\n\u251C\u2500\u2500 another-workflow/\n\u2502 \u251C\u2500\u2500 types.ts\n\u2502 \u251C\u2500\u2500 steps.ts\n\u2502 \u251C\u2500\u2500 workflow.ts\n\u2502 \u2514\u2500\u2500 utils.ts\n\u2514\u2500\u2500 index.ts # Export all workflows\n```\n\n**CRITICAL File Organization Rules:**\n- **ALWAYS create a dedicated folder** for each workflow\n- **Folder names MUST be kebab-case** version of workflow name\n- **types.ts**: Define all input/output schemas, validation types, and interfaces\n- **steps.ts**: Create all individual step definitions using createStep()\n- **workflow.ts**: Compose steps into workflow using createWorkflow() and export the final workflow\n- **utils.ts**: Any helper functions, constants, or utilities (create only if needed)\n- **NEVER put everything in one file** - always separate concerns properly\n\n**Workflow Registration:**\n```typescript\n// src/mastra/index.ts\nexport const mastra = new Mastra({\n workflows: {\n sendEmailWorkflow, // Use camelCase for keys\n dataProcessingWorkflow\n },\n storage: new LibSQLStore({ url: 'file:./mastra.db' }), // Required for suspend/resume\n});\n```\n\n### **\uD83D\uDCE6 ESSENTIAL DEPENDENCIES**\n\n**Required Packages:**\n```json\n{\n \"dependencies\": {\n \"@mastra/core\": \"latest\",\n \"zod\": \"^3.25.67\"\n }\n}\n```\n\n**Additional Packages (as needed):**\n- `@mastra/libsql`: For workflow state persistence\n- `@ai-sdk/openai`: For AI model integration\n- `ai`: For AI SDK functionality\n\n### **\u2705 WORKFLOW BEST PRACTICES**\n\n**Schema Design:**\n- Use descriptive property names in schemas\n- Make schemas as specific as possible (avoid `z.any()`)\n- Include validation for required business logic\n\n**Error Handling:**\n- Use `try/catch` blocks in step execute functions\n- Return meaningful error messages\n- Consider using `bail()` for early successful exits\n\n**Step Organization:**\n- Keep steps focused on single responsibilities\n- Use descriptive step IDs (kebab-case recommended)\n- Create reusable steps for common operations\n\n**Data Flow:**\n- Use `.map()` when schemas don't align between steps\n- Access previous step results with `getStepResult(stepInstance)`\n- Use `getInitData()` to access original workflow input\n\n### **\uD83D\uDE80 EXECUTION PATTERNS**\n\n**Running Workflows:**\n```typescript\n// Create and start run\nconst run = await workflow.createRun();\nconst result = await run.start({ inputData: {...} });\n\n// Stream execution for real-time monitoring\nconst stream = await run.streamVNext({ inputData: {...} });\nfor await (const chunk of stream) {\n console.log(chunk);\n}\n\n// Watch for events\nrun.watch((event) => console.log(event));\n```\n\n**Workflow Status Types:**\n- `\"success\"`: Completed successfully\n- `\"suspended\"`: Paused awaiting input\n- `\"failed\"`: Encountered error\n\n### **\uD83D\uDD17 ADVANCED FEATURES**\n\n**Nested Workflows:**\n- Use workflows as steps: `.then(otherWorkflow)`\n- Enable complex workflow composition\n\n**Request Context:**\n- Pass shared data across all steps\n- Enable dependency injection patterns\n\n**Streaming & Events:**\n- Real-time workflow monitoring\n- Integration with external event systems\n\n**Cloning:**\n- `cloneWorkflow(original, {id: \"new-id\"})`: Reuse workflow structure\n- `cloneStep(original, {id: \"new-id\"})`: Reuse step logic\n\nThis comprehensive research provides the foundation for creating robust, maintainable Mastra workflows with proper typing, error handling, and architectural patterns.\n";
|
|
1
|
+
export declare const workflowResearch = "\n## \uD83D\uDD0D **COMPREHENSIVE MASTRA WORKFLOW RESEARCH SUMMARY**\n\nBased on extensive research of Mastra documentation and examples, here's essential information for building effective Mastra workflows:\n\n### **\uD83D\uDCCB WORKFLOW FUNDAMENTALS**\n\n**Core Components:**\n- **`createWorkflow()`**: Main factory function that creates workflow instances\n- **`createStep()`**: Creates individual workflow steps with typed inputs/outputs \n- **`.commit()`**: Finalizes workflow definition (REQUIRED to make workflows executable)\n- **Zod schemas**: Used for strict input/output typing and validation\n\n**Basic Structure:**\n```typescript\nimport { createWorkflow, createStep } from \"@mastra/core/workflows\";\nimport { z } from \"zod\";\n\nconst workflow = createWorkflow({\n id: \"unique-workflow-id\", // Required: kebab-case recommended\n description: \"What this workflow does\", // Optional but recommended\n inputSchema: z.object({...}), // Required: Defines workflow inputs\n outputSchema: z.object({...}) // Required: Defines final outputs\n})\n .then(step1) // Chain steps sequentially\n .then(step2)\n .commit(); // CRITICAL: Makes workflow executable\n```\n\n### **\uD83D\uDD27 STEP CREATION PATTERNS**\n\n**Standard Step Definition:**\n```typescript\nconst myStep = createStep({\n id: \"step-id\", // Required: unique identifier\n description: \"Step description\", // Recommended for clarity\n inputSchema: z.object({...}), // Required: input validation\n outputSchema: z.object({...}), // Required: output validation\n execute: async ({ inputData, mastra, getStepResult, getInitData }) => {\n // Step logic here\n return { /* matches outputSchema */ };\n }\n});\n```\n\n**Execute Function Parameters:**\n- `inputData`: Validated input matching inputSchema\n- `mastra`: Access to Mastra instance (agents, tools, other workflows)\n- `getStepResult(stepInstance)`: Get results from previous steps\n- `getInitData()`: Access original workflow input data\n- `requestContext`: Runtime dependency injection context\n- `runCount`: Number of times this step has run (useful for retries)\n\n### **\uD83D\uDD04 CONTROL FLOW METHODS**\n\n**Sequential Execution:**\n- `.then(step)`: Execute steps one after another\n- Data flows automatically if schemas match\n\n**Parallel Execution:**\n- `.parallel([step1, step2])`: Run steps simultaneously\n- All parallel steps complete before continuing\n\n**Conditional Logic:**\n- `.branch([[condition, step], [condition, step]])`: Execute different steps based on conditions\n- Conditions evaluated sequentially, matching steps run in parallel\n\n**Loops:**\n- `.dountil(step, condition)`: Repeat until condition becomes true\n- `.dowhile(step, condition)`: Repeat while condition is true \n- `.foreach(step, {concurrency: N})`: Execute step for each array item\n\n**Data Transformation:**\n- `.map(({ inputData, getStepResult, getInitData }) => transformedData)`: Transform data between steps\n\n### **\u23F8\uFE0F SUSPEND & RESUME CAPABILITIES**\n\n**For Human-in-the-Loop Workflows:**\n```typescript\nconst userInputStep = createStep({\n id: \"user-input\",\n suspendSchema: z.object({}), // Schema for suspension payload\n resumeSchema: z.object({ // Schema for resume data\n userResponse: z.string()\n }),\n execute: async ({ resumeData, suspend }) => {\n if (!resumeData?.userResponse) {\n await suspend({}); // Pause workflow\n return { response: \"\" };\n }\n return { response: resumeData.userResponse };\n }\n});\n```\n\n**Resume Workflow:**\n```typescript\nconst result = await run.start({ inputData: {...} });\nif (result.status === \"suspended\") {\n await run.resume({\n step: result.suspended[0], // Or specific step ID\n resumeData: { userResponse: \"answer\" }\n });\n}\n```\n\n### **\uD83D\uDEE0\uFE0F INTEGRATING AGENTS & TOOLS**\n\n**Using Agents in Steps:**\n```typescript\n// Method 1: Agent as step\nconst agentStep = createStep(myAgent);\n\n// Method 2: Call agent in execute function\nconst step = createStep({\n execute: async ({ inputData }) => {\n const result = await myAgent.generate(prompt);\n return { output: result.text };\n }\n});\n```\n\n**Using Tools in Steps:**\n```typescript\n// Method 1: Tool as step \nconst toolStep = createStep(myTool);\n\n// Method 2: Call tool in execute function\nconst step = createStep({\n execute: async ({ inputData, requestContext }) => {\n const result = await myTool.execute({\n context: inputData,\n requestContext\n });\n return result;\n }\n});\n```\n\n### **\uD83D\uDDC2\uFE0F PROJECT ORGANIZATION PATTERNS**\n\n**MANDATORY Workflow Organization:**\nEach workflow MUST be organized in its own dedicated folder with separated concerns:\n\n```\nsrc/mastra/workflows/\n\u251C\u2500\u2500 my-workflow-name/ # Kebab-case folder name\n\u2502 \u251C\u2500\u2500 types.ts # All Zod schemas and TypeScript types\n\u2502 \u251C\u2500\u2500 steps.ts # All individual step definitions\n\u2502 \u251C\u2500\u2500 workflow.ts # Main workflow composition and export\n\u2502 \u2514\u2500\u2500 utils.ts # Helper functions (if needed)\n\u251C\u2500\u2500 another-workflow/\n\u2502 \u251C\u2500\u2500 types.ts\n\u2502 \u251C\u2500\u2500 steps.ts\n\u2502 \u251C\u2500\u2500 workflow.ts\n\u2502 \u2514\u2500\u2500 utils.ts\n\u2514\u2500\u2500 index.ts # Export all workflows\n```\n\n**CRITICAL File Organization Rules:**\n- **ALWAYS create a dedicated folder** for each workflow\n- **Folder names MUST be kebab-case** version of workflow name\n- **types.ts**: Define all input/output schemas, validation types, and interfaces\n- **steps.ts**: Create all individual step definitions using createStep()\n- **workflow.ts**: Compose steps into workflow using createWorkflow() and export the final workflow\n- **utils.ts**: Any helper functions, constants, or utilities (create only if needed)\n- **NEVER put everything in one file** - always separate concerns properly\n\n**Workflow Registration:**\n```typescript\n// src/mastra/index.ts\nexport const mastra = new Mastra({\n workflows: {\n sendEmailWorkflow, // Use camelCase for keys\n dataProcessingWorkflow\n },\n storage: new LibSQLStore({ id: 'mastra-storage', url: 'file:./mastra.db' }), // Required for suspend/resume\n});\n```\n\n### **\uD83D\uDCE6 ESSENTIAL DEPENDENCIES**\n\n**Required Packages:**\n```json\n{\n \"dependencies\": {\n \"@mastra/core\": \"latest\",\n \"zod\": \"^3.25.67\"\n }\n}\n```\n\n**Additional Packages (as needed):**\n- `@mastra/libsql`: For workflow state persistence\n- `@ai-sdk/openai`: For AI model integration\n- `ai`: For AI SDK functionality\n\n### **\u2705 WORKFLOW BEST PRACTICES**\n\n**Schema Design:**\n- Use descriptive property names in schemas\n- Make schemas as specific as possible (avoid `z.any()`)\n- Include validation for required business logic\n\n**Error Handling:**\n- Use `try/catch` blocks in step execute functions\n- Return meaningful error messages\n- Consider using `bail()` for early successful exits\n\n**Step Organization:**\n- Keep steps focused on single responsibilities\n- Use descriptive step IDs (kebab-case recommended)\n- Create reusable steps for common operations\n\n**Data Flow:**\n- Use `.map()` when schemas don't align between steps\n- Access previous step results with `getStepResult(stepInstance)`\n- Use `getInitData()` to access original workflow input\n\n### **\uD83D\uDE80 EXECUTION PATTERNS**\n\n**Running Workflows:**\n```typescript\n// Create and start run\nconst run = await workflow.createRun();\nconst result = await run.start({ inputData: {...} });\n\n// Stream execution for real-time monitoring\nconst stream = await run.streamVNext({ inputData: {...} });\nfor await (const chunk of stream) {\n console.log(chunk);\n}\n\n// Watch for events\nrun.watch((event) => console.log(event));\n```\n\n**Workflow Status Types:**\n- `\"success\"`: Completed successfully\n- `\"suspended\"`: Paused awaiting input\n- `\"failed\"`: Encountered error\n\n### **\uD83D\uDD17 ADVANCED FEATURES**\n\n**Nested Workflows:**\n- Use workflows as steps: `.then(otherWorkflow)`\n- Enable complex workflow composition\n\n**Request Context:**\n- Pass shared data across all steps\n- Enable dependency injection patterns\n\n**Streaming & Events:**\n- Real-time workflow monitoring\n- Integration with external event systems\n\n**Cloning:**\n- `cloneWorkflow(original, {id: \"new-id\"})`: Reuse workflow structure\n- `cloneStep(original, {id: \"new-id\"})`: Reuse step logic\n\nThis comprehensive research provides the foundation for creating robust, maintainable Mastra workflows with proper typing, error handling, and architectural patterns.\n";
|
|
2
2
|
/**
|
|
3
3
|
* Prompts and instructions for workflow builder agents
|
|
4
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/workflows/workflow-builder/prompts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/workflows/workflow-builder/prompts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,2rRAqQ5B,CAAC;AACF;;GAEG;AAEH,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,CAAC,OAAO,EAAE;YAAE,gBAAgB,EAAE,GAAG,CAAC;YAAC,YAAY,EAAE,GAAG,CAAC;YAAC,eAAe,EAAE,OAAO,CAAA;SAAE,KAAK,MAAM,CAAC;KACrG,CAAC;IACF,cAAc,EAAE;QACd,YAAY,EAAE,CAAC,OAAO,EAAE;YACtB,MAAM,EAAE,MAAM,CAAC;YACf,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,WAAW,EAAE,MAAM,CAAC;YACpB,kBAAkB,EAAE,MAAM,CAAC;YAC3B,mBAAmB,EAAE,GAAG,CAAC;YACzB,gBAAgB,EAAE,GAAG,CAAC;YACtB,QAAQ,EAAE,GAAG,CAAC;YACd,KAAK,EAAE,GAAG,EAAE,CAAC;YACb,UAAU,CAAC,EAAE,GAAG,CAAC;SAClB,KAAK,MAAM,CAAC;QACb,MAAM,EAAE,CAAC,OAAO,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,YAAY,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,GAAG,EAAE,CAAC;YAAC,UAAU,CAAC,EAAE,GAAG,CAAA;SAAE,KAAK,MAAM,CAAC;QACvG,eAAe,EAAE,CAAC,OAAO,EAAE;YACzB,cAAc,EAAE,GAAG,EAAE,CAAC;YACtB,YAAY,EAAE,GAAG,EAAE,CAAC;YACpB,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,UAAU,CAAC,EAAE,GAAG,CAAC;SAClB,KAAK,MAAM,CAAC;KACd,CAAC;IACF,UAAU,EAAE;QACV,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED,eAAO,MAAM,sBAAsB,EAAE,sBAsIpC,CAAC"}
|
|
@@ -174,14 +174,14 @@ export declare const WorkflowResearchResultSchema: z.ZodObject<{
|
|
|
174
174
|
snippet: z.ZodString;
|
|
175
175
|
relevance: z.ZodNumber;
|
|
176
176
|
}, "strip", z.ZodTypeAny, {
|
|
177
|
+
url: string;
|
|
177
178
|
relevance: number;
|
|
178
179
|
title: string;
|
|
179
|
-
url: string;
|
|
180
180
|
snippet: string;
|
|
181
181
|
}, {
|
|
182
|
+
url: string;
|
|
182
183
|
relevance: number;
|
|
183
184
|
title: string;
|
|
184
|
-
url: string;
|
|
185
185
|
snippet: string;
|
|
186
186
|
}>, "many">;
|
|
187
187
|
message: z.ZodString;
|
|
@@ -195,9 +195,9 @@ export declare const WorkflowResearchResultSchema: z.ZodObject<{
|
|
|
195
195
|
bestPractices: string[];
|
|
196
196
|
};
|
|
197
197
|
webResources: {
|
|
198
|
+
url: string;
|
|
198
199
|
relevance: number;
|
|
199
200
|
title: string;
|
|
200
|
-
url: string;
|
|
201
201
|
snippet: string;
|
|
202
202
|
}[];
|
|
203
203
|
error?: string | undefined;
|
|
@@ -210,9 +210,9 @@ export declare const WorkflowResearchResultSchema: z.ZodObject<{
|
|
|
210
210
|
bestPractices: string[];
|
|
211
211
|
};
|
|
212
212
|
webResources: {
|
|
213
|
+
url: string;
|
|
213
214
|
relevance: number;
|
|
214
215
|
title: string;
|
|
215
|
-
url: string;
|
|
216
216
|
snippet: string;
|
|
217
217
|
}[];
|
|
218
218
|
error?: string | undefined;
|
|
@@ -630,14 +630,14 @@ export declare const WorkflowBuilderResultSchema: z.ZodObject<{
|
|
|
630
630
|
snippet: z.ZodString;
|
|
631
631
|
relevance: z.ZodNumber;
|
|
632
632
|
}, "strip", z.ZodTypeAny, {
|
|
633
|
+
url: string;
|
|
633
634
|
relevance: number;
|
|
634
635
|
title: string;
|
|
635
|
-
url: string;
|
|
636
636
|
snippet: string;
|
|
637
637
|
}, {
|
|
638
|
+
url: string;
|
|
638
639
|
relevance: number;
|
|
639
640
|
title: string;
|
|
640
|
-
url: string;
|
|
641
641
|
snippet: string;
|
|
642
642
|
}>, "many">;
|
|
643
643
|
message: z.ZodString;
|
|
@@ -651,9 +651,9 @@ export declare const WorkflowBuilderResultSchema: z.ZodObject<{
|
|
|
651
651
|
bestPractices: string[];
|
|
652
652
|
};
|
|
653
653
|
webResources: {
|
|
654
|
+
url: string;
|
|
654
655
|
relevance: number;
|
|
655
656
|
title: string;
|
|
656
|
-
url: string;
|
|
657
657
|
snippet: string;
|
|
658
658
|
}[];
|
|
659
659
|
error?: string | undefined;
|
|
@@ -666,9 +666,9 @@ export declare const WorkflowBuilderResultSchema: z.ZodObject<{
|
|
|
666
666
|
bestPractices: string[];
|
|
667
667
|
};
|
|
668
668
|
webResources: {
|
|
669
|
+
url: string;
|
|
669
670
|
relevance: number;
|
|
670
671
|
title: string;
|
|
671
|
-
url: string;
|
|
672
672
|
snippet: string;
|
|
673
673
|
}[];
|
|
674
674
|
error?: string | undefined;
|
|
@@ -923,9 +923,9 @@ export declare const WorkflowBuilderResultSchema: z.ZodObject<{
|
|
|
923
923
|
bestPractices: string[];
|
|
924
924
|
};
|
|
925
925
|
webResources: {
|
|
926
|
+
url: string;
|
|
926
927
|
relevance: number;
|
|
927
928
|
title: string;
|
|
928
|
-
url: string;
|
|
929
929
|
snippet: string;
|
|
930
930
|
}[];
|
|
931
931
|
error?: string | undefined;
|
|
@@ -1033,9 +1033,9 @@ export declare const WorkflowBuilderResultSchema: z.ZodObject<{
|
|
|
1033
1033
|
bestPractices: string[];
|
|
1034
1034
|
};
|
|
1035
1035
|
webResources: {
|
|
1036
|
+
url: string;
|
|
1036
1037
|
relevance: number;
|
|
1037
1038
|
title: string;
|
|
1038
|
-
url: string;
|
|
1039
1039
|
snippet: string;
|
|
1040
1040
|
}[];
|
|
1041
1041
|
error?: string | undefined;
|
|
@@ -104,6 +104,112 @@ export declare const restrictedTaskManager: import("@mastra/core/tools").Tool<z.
|
|
|
104
104
|
notes?: string | undefined;
|
|
105
105
|
}[];
|
|
106
106
|
}>, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any>> & {
|
|
107
|
+
inputSchema: z.ZodObject<{
|
|
108
|
+
action: z.ZodEnum<["list", "update", "complete"]>;
|
|
109
|
+
tasks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
110
|
+
id: z.ZodString;
|
|
111
|
+
content: z.ZodOptional<z.ZodString>;
|
|
112
|
+
status: z.ZodEnum<["pending", "in_progress", "completed", "blocked"]>;
|
|
113
|
+
priority: z.ZodOptional<z.ZodEnum<["high", "medium", "low"]>>;
|
|
114
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
115
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
status: "pending" | "in_progress" | "completed" | "blocked";
|
|
118
|
+
id: string;
|
|
119
|
+
dependencies?: string[] | undefined;
|
|
120
|
+
content?: string | undefined;
|
|
121
|
+
priority?: "high" | "medium" | "low" | undefined;
|
|
122
|
+
notes?: string | undefined;
|
|
123
|
+
}, {
|
|
124
|
+
status: "pending" | "in_progress" | "completed" | "blocked";
|
|
125
|
+
id: string;
|
|
126
|
+
dependencies?: string[] | undefined;
|
|
127
|
+
content?: string | undefined;
|
|
128
|
+
priority?: "high" | "medium" | "low" | undefined;
|
|
129
|
+
notes?: string | undefined;
|
|
130
|
+
}>, "many">>;
|
|
131
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
action: "update" | "list" | "complete";
|
|
134
|
+
tasks?: {
|
|
135
|
+
status: "pending" | "in_progress" | "completed" | "blocked";
|
|
136
|
+
id: string;
|
|
137
|
+
dependencies?: string[] | undefined;
|
|
138
|
+
content?: string | undefined;
|
|
139
|
+
priority?: "high" | "medium" | "low" | undefined;
|
|
140
|
+
notes?: string | undefined;
|
|
141
|
+
}[] | undefined;
|
|
142
|
+
taskId?: string | undefined;
|
|
143
|
+
}, {
|
|
144
|
+
action: "update" | "list" | "complete";
|
|
145
|
+
tasks?: {
|
|
146
|
+
status: "pending" | "in_progress" | "completed" | "blocked";
|
|
147
|
+
id: string;
|
|
148
|
+
dependencies?: string[] | undefined;
|
|
149
|
+
content?: string | undefined;
|
|
150
|
+
priority?: "high" | "medium" | "low" | undefined;
|
|
151
|
+
notes?: string | undefined;
|
|
152
|
+
}[] | undefined;
|
|
153
|
+
taskId?: string | undefined;
|
|
154
|
+
}>;
|
|
155
|
+
outputSchema: z.ZodObject<{
|
|
156
|
+
success: z.ZodBoolean;
|
|
157
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
158
|
+
id: z.ZodString;
|
|
159
|
+
content: z.ZodString;
|
|
160
|
+
status: z.ZodString;
|
|
161
|
+
priority: z.ZodString;
|
|
162
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
163
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
164
|
+
createdAt: z.ZodString;
|
|
165
|
+
updatedAt: z.ZodString;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
status: string;
|
|
168
|
+
id: string;
|
|
169
|
+
content: string;
|
|
170
|
+
priority: string;
|
|
171
|
+
createdAt: string;
|
|
172
|
+
updatedAt: string;
|
|
173
|
+
dependencies?: string[] | undefined;
|
|
174
|
+
notes?: string | undefined;
|
|
175
|
+
}, {
|
|
176
|
+
status: string;
|
|
177
|
+
id: string;
|
|
178
|
+
content: string;
|
|
179
|
+
priority: string;
|
|
180
|
+
createdAt: string;
|
|
181
|
+
updatedAt: string;
|
|
182
|
+
dependencies?: string[] | undefined;
|
|
183
|
+
notes?: string | undefined;
|
|
184
|
+
}>, "many">;
|
|
185
|
+
message: z.ZodString;
|
|
186
|
+
}, "strip", z.ZodTypeAny, {
|
|
187
|
+
message: string;
|
|
188
|
+
success: boolean;
|
|
189
|
+
tasks: {
|
|
190
|
+
status: string;
|
|
191
|
+
id: string;
|
|
192
|
+
content: string;
|
|
193
|
+
priority: string;
|
|
194
|
+
createdAt: string;
|
|
195
|
+
updatedAt: string;
|
|
196
|
+
dependencies?: string[] | undefined;
|
|
197
|
+
notes?: string | undefined;
|
|
198
|
+
}[];
|
|
199
|
+
}, {
|
|
200
|
+
message: string;
|
|
201
|
+
success: boolean;
|
|
202
|
+
tasks: {
|
|
203
|
+
status: string;
|
|
204
|
+
id: string;
|
|
205
|
+
content: string;
|
|
206
|
+
priority: string;
|
|
207
|
+
createdAt: string;
|
|
208
|
+
updatedAt: string;
|
|
209
|
+
dependencies?: string[] | undefined;
|
|
210
|
+
notes?: string | undefined;
|
|
211
|
+
}[];
|
|
212
|
+
}>;
|
|
107
213
|
execute: (inputData: {
|
|
108
214
|
action: "update" | "list" | "complete";
|
|
109
215
|
tasks?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/workflows/workflow-builder/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/workflows/workflow-builder/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDhC,CAAC"}
|