@mastra/agent-builder 1.0.10 → 1.0.11

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/dist/index.js CHANGED
@@ -14,7 +14,9 @@ import { promisify } from 'util';
14
14
  import { ModelRouterLanguageModel } from '@mastra/core/llm';
15
15
  import { tmpdir } from 'os';
16
16
  import { openai } from '@ai-sdk/openai';
17
+ import { toStandardSchema } from '@mastra/core/schema';
17
18
  import { createStep, createWorkflow } from '@mastra/core/workflows';
19
+ import { standardSchemaToJSONSchema } from '@mastra/schema-compat/schema';
18
20
  import * as z4 from 'zod/v4';
19
21
  import { z as z$1 } from 'zod/v4';
20
22
  import { ZodFirstPartyTypeKind } from 'zod/v3';
@@ -36,7 +38,7 @@ var AgentBuilderInputSchema = z.object({
36
38
  ref: z.string().optional().describe("Tag/branch/commit to checkout (defaults to main/master)"),
37
39
  slug: z.string().optional().describe("Slug for branch/scripts; defaults to inferred from repo"),
38
40
  targetPath: z.string().optional().describe("Project path to merge into; defaults to current directory"),
39
- variables: z.record(z.string()).optional().describe("Environment variables to set in .env file")
41
+ variables: z.record(z.string(), z.string()).optional().describe("Environment variables to set in .env file")
40
42
  });
41
43
  z.object({
42
44
  slug: z.string(),
@@ -67,7 +69,7 @@ var FileCopyInputSchema = z.object({
67
69
  commitSha: z.string(),
68
70
  slug: z.string(),
69
71
  targetPath: z.string().optional(),
70
- variables: z.record(z.string()).optional()
72
+ variables: z.record(z.string(), z.string()).optional()
71
73
  });
72
74
  var FileCopyResultSchema = z.object({
73
75
  success: z.boolean(),
@@ -160,10 +162,10 @@ var PackageAnalysisSchema = z.object({
160
162
  name: z.string().optional(),
161
163
  version: z.string().optional(),
162
164
  description: z.string().optional(),
163
- dependencies: z.record(z.string()).optional(),
164
- devDependencies: z.record(z.string()).optional(),
165
- peerDependencies: z.record(z.string()).optional(),
166
- scripts: z.record(z.string()).optional(),
165
+ dependencies: z.record(z.string(), z.string()).optional(),
166
+ devDependencies: z.record(z.string(), z.string()).optional(),
167
+ peerDependencies: z.record(z.string(), z.string()).optional(),
168
+ scripts: z.record(z.string(), z.string()).optional(),
167
169
  success: z.boolean().optional(),
168
170
  error: z.string().optional()
169
171
  });
@@ -1192,7 +1194,7 @@ export const mastra = new Mastra({
1192
1194
  timeout: z.number().default(3e4).describe("Timeout in milliseconds"),
1193
1195
  captureOutput: z.boolean().default(true).describe("Capture command output"),
1194
1196
  shell: z.string().optional().describe("Shell to use (defaults to system shell)"),
1195
- env: z.record(z.string()).optional().describe("Environment variables")
1197
+ env: z.record(z.string(), z.string()).optional().describe("Environment variables")
1196
1198
  }),
1197
1199
  outputSchema: z.object({
1198
1200
  success: z.boolean(),
@@ -1207,7 +1209,8 @@ export const mastra = new Mastra({
1207
1209
  execute: async (inputData) => {
1208
1210
  return await _AgentBuilderDefaults.executeCommand({
1209
1211
  ...inputData,
1210
- workingDirectory: inputData.workingDirectory || projectPath
1212
+ workingDirectory: inputData.workingDirectory || projectPath,
1213
+ env: inputData.env
1211
1214
  });
1212
1215
  }
1213
1216
  }),
@@ -1642,7 +1645,7 @@ export const mastra = new Mastra({
1642
1645
  method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).describe("HTTP method"),
1643
1646
  url: z.string().describe("Full URL or path (if baseUrl provided)"),
1644
1647
  baseUrl: z.string().optional().describe("Base URL for the server (e.g., http://localhost:4200)"),
1645
- headers: z.record(z.string()).optional().describe("HTTP headers"),
1648
+ headers: z.record(z.string(), z.string()).optional().describe("HTTP headers"),
1646
1649
  body: z.any().optional().describe("Request body (will be JSON stringified if object)"),
1647
1650
  timeout: z.number().optional().default(3e4).describe("Request timeout in milliseconds")
1648
1651
  }),
@@ -1650,7 +1653,7 @@ export const mastra = new Mastra({
1650
1653
  success: z.boolean(),
1651
1654
  status: z.number().optional(),
1652
1655
  statusText: z.string().optional(),
1653
- headers: z.record(z.string()).optional(),
1656
+ headers: z.record(z.string(), z.string()).optional(),
1654
1657
  data: z.any().optional(),
1655
1658
  errorMessage: z.string().optional(),
1656
1659
  url: z.string(),
@@ -3497,15 +3500,22 @@ Return the actual exported names of the units, as well as the file names.`,
3497
3500
  networks: z.array(z.object({ name: z.string(), file: z.string() })).optional(),
3498
3501
  other: z.array(z.object({ name: z.string(), file: z.string() })).optional()
3499
3502
  });
3500
- const result = isSupported ? await tryGenerateWithJsonFallback(agent, prompt, {
3501
- structuredOutput: {
3502
- schema: output
3503
- },
3504
- maxSteps: 100
3505
- }) : await agent.generateLegacy(prompt, {
3506
- experimental_output: output,
3507
- maxSteps: 100
3508
- });
3503
+ let result;
3504
+ if (isSupported) {
3505
+ result = await tryGenerateWithJsonFallback(agent, prompt, {
3506
+ structuredOutput: {
3507
+ schema: output
3508
+ },
3509
+ maxSteps: 100
3510
+ });
3511
+ } else {
3512
+ const standardSchema = toStandardSchema(output);
3513
+ const jsonSchema2 = standardSchemaToJSONSchema(standardSchema);
3514
+ result = await agent.generateLegacy(prompt, {
3515
+ experimental_output: jsonSchema2,
3516
+ maxSteps: 100
3517
+ });
3518
+ }
3509
3519
  const template = result.object ?? {};
3510
3520
  const units = [];
3511
3521
  template.agents?.forEach((agentId) => {
@@ -9103,7 +9113,7 @@ var PlanningIterationResultSchema = z.object({
9103
9113
  message: z.string(),
9104
9114
  error: z.string().optional(),
9105
9115
  allPreviousQuestions: z.array(z.any()).optional(),
9106
- allPreviousAnswers: z.record(z.string()).optional()
9116
+ allPreviousAnswers: z.record(z.string(), z.string()).optional()
9107
9117
  });
9108
9118
 
9109
9119
  // src/workflows/task-planning/prompts.ts
@@ -9214,7 +9224,7 @@ var ProjectDiscoveryResultSchema = z.object({
9214
9224
  existingAgents: z.array(z.string()),
9215
9225
  existingTools: z.array(z.string())
9216
9226
  }),
9217
- dependencies: z.record(z.string()),
9227
+ dependencies: z.record(z.string(), z.string()),
9218
9228
  message: z.string(),
9219
9229
  error: z.string().optional()
9220
9230
  });
@@ -9283,7 +9293,7 @@ z.object({
9283
9293
  questions: QuestionSchema
9284
9294
  });
9285
9295
  z.object({
9286
- answers: z.record(z.string()),
9296
+ answers: z.record(z.string(), z.string()),
9287
9297
  hasAnswers: z.boolean()
9288
9298
  });
9289
9299
  var WorkflowBuilderResultSchema = z.object({
@@ -9324,7 +9334,7 @@ var PlanningIterationInputSchema = z.object({
9324
9334
  discoveredWorkflows: z.array(DiscoveredWorkflowSchema),
9325
9335
  projectStructure: ProjectDiscoveryResultSchema,
9326
9336
  research: WorkflowResearchResultSchema,
9327
- userAnswers: z.record(z.string()).optional()
9337
+ userAnswers: z.record(z.string(), z.string()).optional()
9328
9338
  });
9329
9339
  var PlanningIterationSuspendSchema = z.object({
9330
9340
  questions: QuestionSchema,
@@ -9335,7 +9345,7 @@ var PlanningIterationSuspendSchema = z.object({
9335
9345
  })
9336
9346
  });
9337
9347
  var PlanningIterationResumeSchema = z.object({
9338
- answers: z.record(z.string())
9348
+ answers: z.record(z.string(), z.string())
9339
9349
  });
9340
9350
  var PlanningAgentOutputSchema = z.object({
9341
9351
  tasks: TaskSchema,
@@ -9384,10 +9394,11 @@ var planningIterationStep = createStep({
9384
9394
  const newAnswers = { ...userAnswers || {}, ...resumeData?.answers || {} };
9385
9395
  if (Object.keys(newAnswers).length > 0) {
9386
9396
  storedQAPairs = storedQAPairs.map((pair) => {
9387
- if (newAnswers[pair.question.id]) {
9397
+ const answerValue = newAnswers[pair.question.id];
9398
+ if (answerValue) {
9388
9399
  return {
9389
9400
  ...pair,
9390
- answer: newAnswers[pair.question.id] || null,
9401
+ answer: String(answerValue) || null,
9391
9402
  answeredAt: (/* @__PURE__ */ new Date()).toISOString()
9392
9403
  };
9393
9404
  }