@mastra/agent-builder 0.0.0-scorer-agentnames-conditional-20250926065249 → 0.0.0-scorers-logs-20251208093427

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
@@ -1,6 +1,5 @@
1
- import { Agent } from '@mastra/core/agent';
1
+ import { Agent, tryGenerateWithJsonFallback, tryStreamWithJsonFallback } from '@mastra/core/agent';
2
2
  import { Memory } from '@mastra/memory';
3
- import { TokenLimiter } from '@mastra/memory/processors';
4
3
  import { exec as exec$1, execFile as execFile$1, spawn as spawn$1 } from 'child_process';
5
4
  import { mkdtemp, rm, readFile, writeFile, readdir, mkdir, copyFile, stat } from 'fs/promises';
6
5
  import { join, resolve, basename, extname, dirname, isAbsolute, relative } from 'path';
@@ -10,8 +9,7 @@ import { z } from 'zod';
10
9
  import { existsSync, readFileSync } from 'fs';
11
10
  import { createRequire } from 'module';
12
11
  import { promisify } from 'util';
13
- import { openai as openai$1 } from '@ai-sdk/openai-v5';
14
- import { MemoryProcessor } from '@mastra/core/memory';
12
+ import { ModelRouterLanguageModel } from '@mastra/core/llm';
15
13
  import { tmpdir } from 'os';
16
14
  import { openai } from '@ai-sdk/openai';
17
15
  import { createStep, createWorkflow } from '@mastra/core/workflows';
@@ -189,7 +187,7 @@ var PackageMergeResultSchema = z.object({
189
187
  error: z.string().optional()
190
188
  });
191
189
  var InstallInputSchema = z.object({
192
- targetPath: z.string().describe("Path to the project to install packages in")
190
+ targetPath: z.string().optional().describe("Path to the project to install packages in")
193
191
  });
194
192
  var InstallResultSchema = z.object({
195
193
  success: z.boolean(),
@@ -501,11 +499,11 @@ async function renameAndCopyFile(sourceFile, targetFile) {
501
499
  var isValidMastraLanguageModel = (model) => {
502
500
  return model && typeof model === "object" && typeof model.modelId === "string";
503
501
  };
504
- var resolveTargetPath = (inputData, runtimeContext) => {
502
+ var resolveTargetPath = (inputData, requestContext) => {
505
503
  if (inputData.targetPath) {
506
504
  return inputData.targetPath;
507
505
  }
508
- const contextPath = runtimeContext.get("targetPath");
506
+ const contextPath = requestContext.get("targetPath");
509
507
  if (contextPath) {
510
508
  return contextPath;
511
509
  }
@@ -658,31 +656,9 @@ var createModelInstance = async (provider, modelId, version = "v2") => {
658
656
  const { google } = await import('@ai-sdk/google');
659
657
  return google(modelId);
660
658
  }
661
- },
662
- v2: {
663
- openai: async () => {
664
- const { openai: openai2 } = await import('@ai-sdk/openai-v5');
665
- return openai2(modelId);
666
- },
667
- anthropic: async () => {
668
- const { anthropic } = await import('@ai-sdk/anthropic-v5');
669
- return anthropic(modelId);
670
- },
671
- groq: async () => {
672
- const { groq } = await import('@ai-sdk/groq-v5');
673
- return groq(modelId);
674
- },
675
- xai: async () => {
676
- const { xai } = await import('@ai-sdk/xai-v5');
677
- return xai(modelId);
678
- },
679
- google: async () => {
680
- const { google } = await import('@ai-sdk/google-v5');
681
- return google(modelId);
682
- }
683
659
  }
684
660
  };
685
- const providerFn = providerMap[version][provider];
661
+ const providerFn = version === `v1` ? providerMap[version][provider] : () => new ModelRouterLanguageModel(`${provider}/${modelId}`);
686
662
  if (!providerFn) {
687
663
  console.error(`Unsupported provider: ${provider}`);
688
664
  return null;
@@ -696,13 +672,13 @@ var createModelInstance = async (provider, modelId, version = "v2") => {
696
672
  }
697
673
  };
698
674
  var resolveModel = async ({
699
- runtimeContext,
700
- defaultModel = openai$1("gpt-4.1"),
675
+ requestContext,
676
+ defaultModel = "openai/gpt-4.1",
701
677
  projectPath
702
678
  }) => {
703
- const modelFromContext = runtimeContext.get("model");
679
+ const modelFromContext = requestContext.get("model");
704
680
  if (modelFromContext) {
705
- console.info("Using model from runtime context");
681
+ console.info("Using model from request context");
706
682
  if (isValidMastraLanguageModel(modelFromContext)) {
707
683
  return modelFromContext;
708
684
  }
@@ -710,18 +686,18 @@ var resolveModel = async ({
710
686
  'Invalid model provided. Model must be a MastraLanguageModel instance (e.g., openai("gpt-4"), anthropic("claude-3-5-sonnet"), etc.)'
711
687
  );
712
688
  }
713
- const selectedModel = runtimeContext.get("selectedModel");
689
+ const selectedModel = requestContext.get("selectedModel");
714
690
  if (selectedModel?.provider && selectedModel?.modelId && projectPath) {
715
691
  console.info(`Resolving selected model: ${selectedModel.provider}/${selectedModel.modelId}`);
716
692
  const version = await detectAISDKVersion(projectPath);
717
693
  const modelInstance = await createModelInstance(selectedModel.provider, selectedModel.modelId, version);
718
694
  if (modelInstance) {
719
- runtimeContext.set("model", modelInstance);
695
+ requestContext.set("model", modelInstance);
720
696
  return modelInstance;
721
697
  }
722
698
  }
723
699
  console.info("Using default model");
724
- return defaultModel;
700
+ return typeof defaultModel === `string` ? new ModelRouterLanguageModel(defaultModel) : defaultModel;
725
701
  };
726
702
 
727
703
  // src/defaults.ts
@@ -890,7 +866,7 @@ You have access to an enhanced set of tools based on production coding agent pat
890
866
  ### Task Management
891
867
  - **taskManager**: Create and track multi-step coding tasks with states (pending, in_progress, completed, blocked). Use this for complex projects that require systematic progress tracking.
892
868
 
893
- ### Code Discovery & Analysis
869
+ ### Code Discovery & Analysis
894
870
  - **codeAnalyzer**: Analyze codebase structure, discover definitions (functions, classes, interfaces), map dependencies, and understand architectural patterns.
895
871
  - **smartSearch**: Intelligent search with context awareness, pattern matching, and relevance scoring.
896
872
 
@@ -928,12 +904,14 @@ import { LibSQLStore } from '@mastra/libsql';
928
904
  import { weatherTool } from '../tools/weather-tool';
929
905
 
930
906
  export const weatherAgent = new Agent({
907
+ id: 'weather-agent',
931
908
  name: 'Weather Agent',
932
909
  instructions: \${instructions},
933
910
  model: openai('gpt-4o-mini'),
934
911
  tools: { weatherTool },
935
912
  memory: new Memory({
936
913
  storage: new LibSQLStore({
914
+ id: 'mastra-memory-storage',
937
915
  url: 'file:../mastra.db', // ask user what database to use, use this as the default
938
916
  }),
939
917
  }),
@@ -962,8 +940,8 @@ export const weatherTool = createTool({
962
940
  conditions: z.string(),
963
941
  location: z.string(),
964
942
  }),
965
- execute: async ({ context }) => {
966
- return await getWeather(context.location);
943
+ execute: async (inputData) => {
944
+ return await getWeather(inputData.location);
967
945
  },
968
946
  });
969
947
  \`\`\`
@@ -981,7 +959,7 @@ const fetchWeather = createStep({
981
959
  city: z.string().describe('The city to get the weather for'),
982
960
  }),
983
961
  outputSchema: forecastSchema,
984
- execute: async ({ inputData }) => {
962
+ execute: async (inputData) => {
985
963
  if (!inputData) {
986
964
  throw new Error('Input data not found');
987
965
  }
@@ -1035,7 +1013,8 @@ const planActivities = createStep({
1035
1013
  outputSchema: z.object({
1036
1014
  activities: z.string(),
1037
1015
  }),
1038
- execute: async ({ inputData, mastra }) => {
1016
+ execute: async (inputData, context) => {
1017
+ const mastra = context?.mastra;
1039
1018
  const forecast = inputData;
1040
1019
 
1041
1020
  if (!forecast) {
@@ -1100,7 +1079,8 @@ export const mastra = new Mastra({
1100
1079
  workflows: { weatherWorkflow },
1101
1080
  agents: { weatherAgent },
1102
1081
  storage: new LibSQLStore({
1103
- // stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
1082
+ id: 'mastra-storage',
1083
+ // stores observability, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
1104
1084
  url: ":memory:",
1105
1085
  }),
1106
1086
  logger: new PinoLogger({
@@ -1144,8 +1124,8 @@ export const mastra = new Mastra({
1144
1124
  }).optional(),
1145
1125
  error: z.string().optional()
1146
1126
  }),
1147
- execute: async ({ context }) => {
1148
- return await _AgentBuilderDefaults.readFile({ ...context, projectPath });
1127
+ execute: async (inputData) => {
1128
+ return await _AgentBuilderDefaults.readFile({ ...inputData, projectPath });
1149
1129
  }
1150
1130
  }),
1151
1131
  writeFile: createTool({
@@ -1164,8 +1144,8 @@ export const mastra = new Mastra({
1164
1144
  message: z.string(),
1165
1145
  error: z.string().optional()
1166
1146
  }),
1167
- execute: async ({ context }) => {
1168
- return await _AgentBuilderDefaults.writeFile({ ...context, projectPath });
1147
+ execute: async (inputData) => {
1148
+ return await _AgentBuilderDefaults.writeFile({ ...inputData, projectPath });
1169
1149
  }
1170
1150
  }),
1171
1151
  listDirectory: createTool({
@@ -1196,8 +1176,8 @@ export const mastra = new Mastra({
1196
1176
  message: z.string(),
1197
1177
  error: z.string().optional()
1198
1178
  }),
1199
- execute: async ({ context }) => {
1200
- return await _AgentBuilderDefaults.listDirectory({ ...context, projectPath });
1179
+ execute: async (inputData) => {
1180
+ return await _AgentBuilderDefaults.listDirectory({ ...inputData, projectPath });
1201
1181
  }
1202
1182
  }),
1203
1183
  executeCommand: createTool({
@@ -1221,10 +1201,10 @@ export const mastra = new Mastra({
1221
1201
  executionTime: z.number().optional(),
1222
1202
  error: z.string().optional()
1223
1203
  }),
1224
- execute: async ({ context }) => {
1204
+ execute: async (inputData) => {
1225
1205
  return await _AgentBuilderDefaults.executeCommand({
1226
- ...context,
1227
- workingDirectory: context.workingDirectory || projectPath
1206
+ ...inputData,
1207
+ workingDirectory: inputData.workingDirectory || projectPath
1228
1208
  });
1229
1209
  }
1230
1210
  }),
@@ -1262,8 +1242,8 @@ export const mastra = new Mastra({
1262
1242
  ),
1263
1243
  message: z.string()
1264
1244
  }),
1265
- execute: async ({ context }) => {
1266
- return await _AgentBuilderDefaults.manageTaskList(context);
1245
+ execute: async (inputData) => {
1246
+ return await _AgentBuilderDefaults.manageTaskList(inputData);
1267
1247
  }
1268
1248
  }),
1269
1249
  // Advanced File Operations
@@ -1297,8 +1277,8 @@ export const mastra = new Mastra({
1297
1277
  ),
1298
1278
  message: z.string()
1299
1279
  }),
1300
- execute: async ({ context }) => {
1301
- return await _AgentBuilderDefaults.performMultiEdit({ ...context, projectPath });
1280
+ execute: async (inputData) => {
1281
+ return await _AgentBuilderDefaults.performMultiEdit({ ...inputData, projectPath });
1302
1282
  }
1303
1283
  }),
1304
1284
  replaceLines: createTool({
@@ -1322,8 +1302,8 @@ export const mastra = new Mastra({
1322
1302
  backup: z.string().optional(),
1323
1303
  error: z.string().optional()
1324
1304
  }),
1325
- execute: async ({ context }) => {
1326
- return await _AgentBuilderDefaults.replaceLines({ ...context, projectPath });
1305
+ execute: async (inputData) => {
1306
+ return await _AgentBuilderDefaults.replaceLines({ ...inputData, projectPath });
1327
1307
  }
1328
1308
  }),
1329
1309
  // File diagnostics tool to help debug line replacement issues
@@ -1351,8 +1331,8 @@ export const mastra = new Mastra({
1351
1331
  message: z.string(),
1352
1332
  error: z.string().optional()
1353
1333
  }),
1354
- execute: async ({ context }) => {
1355
- return await _AgentBuilderDefaults.showFileLines({ ...context, projectPath });
1334
+ execute: async (inputData) => {
1335
+ return await _AgentBuilderDefaults.showFileLines({ ...inputData, projectPath });
1356
1336
  }
1357
1337
  }),
1358
1338
  // Enhanced Pattern Search
@@ -1395,8 +1375,8 @@ export const mastra = new Mastra({
1395
1375
  patterns: z.array(z.string())
1396
1376
  })
1397
1377
  }),
1398
- execute: async ({ context }) => {
1399
- return await _AgentBuilderDefaults.performSmartSearch(context, projectPath);
1378
+ execute: async (inputData) => {
1379
+ return await _AgentBuilderDefaults.performSmartSearch(inputData, projectPath);
1400
1380
  }
1401
1381
  }),
1402
1382
  validateCode: createTool({
@@ -1429,8 +1409,8 @@ export const mastra = new Mastra({
1429
1409
  validationsFailed: z.array(z.string())
1430
1410
  })
1431
1411
  }),
1432
- execute: async ({ context }) => {
1433
- const { projectPath: validationProjectPath, validationType, files } = context;
1412
+ execute: async (inputData) => {
1413
+ const { projectPath: validationProjectPath, validationType, files } = inputData;
1434
1414
  const targetPath = validationProjectPath || projectPath;
1435
1415
  return await _AgentBuilderDefaults.validateCode({
1436
1416
  projectPath: targetPath,
@@ -1469,8 +1449,8 @@ export const mastra = new Mastra({
1469
1449
  suggestions: z.array(z.string()).optional(),
1470
1450
  error: z.string().optional()
1471
1451
  }),
1472
- execute: async ({ context }) => {
1473
- return await _AgentBuilderDefaults.webSearch(context);
1452
+ execute: async (inputData) => {
1453
+ return await _AgentBuilderDefaults.webSearch(inputData);
1474
1454
  }
1475
1455
  }),
1476
1456
  // Task Completion Signaling
@@ -1499,8 +1479,8 @@ export const mastra = new Mastra({
1499
1479
  summary: z.string(),
1500
1480
  confidence: z.number().min(0).max(100)
1501
1481
  }),
1502
- execute: async ({ context }) => {
1503
- return await _AgentBuilderDefaults.signalCompletion(context);
1482
+ execute: async (inputData) => {
1483
+ return await _AgentBuilderDefaults.signalCompletion(inputData);
1504
1484
  }
1505
1485
  }),
1506
1486
  manageProject: createTool({
@@ -1525,8 +1505,8 @@ export const mastra = new Mastra({
1525
1505
  details: z.string().optional(),
1526
1506
  error: z.string().optional()
1527
1507
  }),
1528
- execute: async ({ context }) => {
1529
- const { action, features, packages } = context;
1508
+ execute: async (inputData) => {
1509
+ const { action, features, packages } = inputData;
1530
1510
  try {
1531
1511
  switch (action) {
1532
1512
  case "create":
@@ -1587,8 +1567,8 @@ export const mastra = new Mastra({
1587
1567
  stdout: z.array(z.string()).optional().describe("Server output lines captured during startup"),
1588
1568
  error: z.string().optional()
1589
1569
  }),
1590
- execute: async ({ context }) => {
1591
- const { action, port } = context;
1570
+ execute: async (inputData) => {
1571
+ const { action, port } = inputData;
1592
1572
  try {
1593
1573
  switch (action) {
1594
1574
  case "start":
@@ -1673,8 +1653,8 @@ export const mastra = new Mastra({
1673
1653
  url: z.string(),
1674
1654
  method: z.string()
1675
1655
  }),
1676
- execute: async ({ context }) => {
1677
- const { method, url, baseUrl, headers, body, timeout } = context;
1656
+ execute: async (inputData) => {
1657
+ const { method, url, baseUrl, headers, body, timeout } = inputData;
1678
1658
  try {
1679
1659
  return await _AgentBuilderDefaults.makeHttpRequest({
1680
1660
  method,
@@ -1729,7 +1709,7 @@ export const mastra = new Mastra({
1729
1709
  /**
1730
1710
  * Get tools for a specific mode
1731
1711
  */
1732
- static async getToolsForMode(projectPath, mode = "code-editor") {
1712
+ static async listToolsForMode(projectPath, mode = "code-editor") {
1733
1713
  const allTools = await _AgentBuilderDefaults.DEFAULT_TOOLS(projectPath);
1734
1714
  if (mode === "template") {
1735
1715
  return _AgentBuilderDefaults.filterToolsForTemplateBuilder(allTools);
@@ -3102,13 +3082,15 @@ export const mastra = new Mastra({
3102
3082
  }
3103
3083
  }
3104
3084
  };
3105
- var ToolSummaryProcessor = class extends MemoryProcessor {
3085
+ var ToolSummaryProcessor = class {
3086
+ id = "tool-summary-processor";
3087
+ name = "ToolSummaryProcessor";
3106
3088
  summaryAgent;
3107
3089
  summaryCache = /* @__PURE__ */ new Map();
3108
3090
  constructor({ summaryModel }) {
3109
- super({ name: "ToolSummaryProcessor" });
3110
3091
  this.summaryAgent = new Agent({
3111
- name: "ToolSummaryAgent",
3092
+ id: "tool-summary-agent",
3093
+ name: "Tool Summary Agent",
3112
3094
  description: "A summary agent that summarizes tool calls and results",
3113
3095
  instructions: "You are a summary agent that summarizes tool calls and results",
3114
3096
  model: summaryModel
@@ -3142,30 +3124,37 @@ var ToolSummaryProcessor = class extends MemoryProcessor {
3142
3124
  keys: Array.from(this.summaryCache.keys())
3143
3125
  };
3144
3126
  }
3145
- async process(messages) {
3127
+ async processInput({
3128
+ messages,
3129
+ messageList: _messageList
3130
+ }) {
3146
3131
  const summaryTasks = [];
3147
3132
  for (const message of messages) {
3148
- if (message.role === "tool" && Array.isArray(message.content) && message.content.length > 0 && message.content?.some((content) => content.type === "tool-result")) {
3149
- for (const content of message.content) {
3150
- if (content.type === "tool-result") {
3151
- const assistantMessageWithToolCall = messages.find(
3152
- (message2) => message2.role === "assistant" && Array.isArray(message2.content) && message2.content.length > 0 && message2.content?.some(
3153
- (assistantContent) => assistantContent.type === "tool-call" && assistantContent.toolCallId === content.toolCallId
3154
- )
3155
- );
3156
- const toolCall = Array.isArray(assistantMessageWithToolCall?.content) ? assistantMessageWithToolCall?.content.find(
3157
- (assistantContent) => assistantContent.type === "tool-call" && assistantContent.toolCallId === content.toolCallId
3158
- ) : null;
3159
- const cacheKey = this.createCacheKey(toolCall);
3133
+ if (message.content.format === 2 && message.content.parts) {
3134
+ for (let partIndex = 0; partIndex < message.content.parts.length; partIndex++) {
3135
+ const part = message.content.parts[partIndex];
3136
+ if (part && part.type === "tool-invocation" && part.toolInvocation?.state === "result") {
3137
+ const cacheKey = this.createCacheKey(part.toolInvocation);
3160
3138
  const cachedSummary = this.summaryCache.get(cacheKey);
3161
3139
  if (cachedSummary) {
3162
- content.result = `Tool call summary: ${cachedSummary}`;
3140
+ message.content.parts[partIndex] = {
3141
+ type: "tool-invocation",
3142
+ toolInvocation: {
3143
+ state: "result",
3144
+ step: part.toolInvocation.step,
3145
+ toolCallId: part.toolInvocation.toolCallId,
3146
+ toolName: part.toolInvocation.toolName,
3147
+ args: part.toolInvocation.args,
3148
+ result: `Tool call summary: ${cachedSummary}`
3149
+ }
3150
+ };
3163
3151
  } else {
3164
3152
  const summaryPromise = this.summaryAgent.generate(
3165
- `Summarize the following tool call: ${JSON.stringify(toolCall)} and result: ${JSON.stringify(content)}`
3153
+ `Summarize the following tool call: ${JSON.stringify(part.toolInvocation)}`
3166
3154
  );
3167
3155
  summaryTasks.push({
3168
- content,
3156
+ message,
3157
+ partIndex,
3169
3158
  promise: summaryPromise,
3170
3159
  cacheKey
3171
3160
  });
@@ -3183,10 +3172,24 @@ var ToolSummaryProcessor = class extends MemoryProcessor {
3183
3172
  const summaryResult = result.value;
3184
3173
  const summaryText = summaryResult.text;
3185
3174
  this.summaryCache.set(task.cacheKey, summaryText);
3186
- task.content.result = `Tool call summary: ${summaryText}`;
3175
+ if (task.message.content.format === 2 && task.message.content.parts) {
3176
+ const part = task.message.content.parts[task.partIndex];
3177
+ if (part && part.type === "tool-invocation" && part.toolInvocation?.state === "result") {
3178
+ task.message.content.parts[task.partIndex] = {
3179
+ type: "tool-invocation",
3180
+ toolInvocation: {
3181
+ state: "result",
3182
+ step: part.toolInvocation.step,
3183
+ toolCallId: part.toolInvocation.toolCallId,
3184
+ toolName: part.toolInvocation.toolName,
3185
+ args: part.toolInvocation.args,
3186
+ result: `Tool call summary: ${summaryText}`
3187
+ }
3188
+ };
3189
+ }
3190
+ }
3187
3191
  } else if (result.status === "rejected") {
3188
3192
  console.warn(`Failed to generate summary for tool call:`, result.reason);
3189
- task.content.result = `Tool call summary: [Summary generation failed]`;
3190
3193
  }
3191
3194
  });
3192
3195
  }
@@ -3206,26 +3209,26 @@ var AgentBuilder = class extends Agent {
3206
3209
  ${config.instructions}` : "";
3207
3210
  const combinedInstructions = additionalInstructions + AgentBuilderDefaults.DEFAULT_INSTRUCTIONS(config.projectPath);
3208
3211
  const agentConfig = {
3212
+ id: "agent-builder",
3209
3213
  name: "agent-builder",
3210
3214
  description: "An AI agent specialized in generating Mastra agents, tools, and workflows from natural language requirements.",
3211
3215
  instructions: combinedInstructions,
3212
3216
  model: config.model,
3213
3217
  tools: async () => {
3214
3218
  return {
3215
- ...await AgentBuilderDefaults.getToolsForMode(config.projectPath, config.mode),
3219
+ ...await AgentBuilderDefaults.listToolsForMode(config.projectPath, config.mode),
3216
3220
  ...config.tools || {}
3217
3221
  };
3218
3222
  },
3219
3223
  memory: new Memory({
3220
- options: AgentBuilderDefaults.DEFAULT_MEMORY_CONFIG,
3221
- processors: [
3222
- // use the write to disk processor to debug the agent's context
3223
- // new WriteToDiskProcessor({ prefix: 'before-filter' }),
3224
- new ToolSummaryProcessor({ summaryModel: config.summaryModel || config.model }),
3225
- new TokenLimiter(1e5)
3226
- // new WriteToDiskProcessor({ prefix: 'after-filter' }),
3227
- ]
3228
- })
3224
+ options: AgentBuilderDefaults.DEFAULT_MEMORY_CONFIG
3225
+ }),
3226
+ inputProcessors: [
3227
+ // use the write to disk processor to debug the agent's context
3228
+ // new WriteToDiskProcessor({ prefix: 'before-filter' }),
3229
+ new ToolSummaryProcessor({ summaryModel: config.summaryModel || config.model })
3230
+ // new WriteToDiskProcessor({ prefix: 'after-filter' }),
3231
+ ]
3229
3232
  };
3230
3233
  super(agentConfig);
3231
3234
  this.builderConfig = config;
@@ -3234,9 +3237,9 @@ ${config.instructions}` : "";
3234
3237
  * Enhanced generate method with AgentBuilder-specific configuration
3235
3238
  * Overrides the base Agent generate method to provide additional project context
3236
3239
  */
3237
- generate = async (messages, generateOptions = {}) => {
3240
+ generateLegacy = async (messages, generateOptions = {}) => {
3238
3241
  const { maxSteps, ...baseOptions } = generateOptions;
3239
- const originalInstructions = await this.getInstructions({ runtimeContext: generateOptions?.runtimeContext });
3242
+ const originalInstructions = await this.getInstructions({ requestContext: generateOptions?.requestContext });
3240
3243
  const additionalInstructions = baseOptions.instructions;
3241
3244
  let enhancedInstructions = originalInstructions;
3242
3245
  if (additionalInstructions) {
@@ -3257,15 +3260,15 @@ ${additionalInstructions}`;
3257
3260
  this.logger.debug(`[AgentBuilder:${this.name}] Starting generation with enhanced context`, {
3258
3261
  projectPath: this.builderConfig.projectPath
3259
3262
  });
3260
- return super.generate(messages, enhancedOptions);
3263
+ return super.generateLegacy(messages, enhancedOptions);
3261
3264
  };
3262
3265
  /**
3263
3266
  * Enhanced stream method with AgentBuilder-specific configuration
3264
3267
  * Overrides the base Agent stream method to provide additional project context
3265
3268
  */
3266
- stream = async (messages, streamOptions = {}) => {
3269
+ streamLegacy = async (messages, streamOptions = {}) => {
3267
3270
  const { maxSteps, ...baseOptions } = streamOptions;
3268
- const originalInstructions = await this.getInstructions({ runtimeContext: streamOptions?.runtimeContext });
3271
+ const originalInstructions = await this.getInstructions({ requestContext: streamOptions?.requestContext });
3269
3272
  const additionalInstructions = baseOptions.instructions;
3270
3273
  let enhancedInstructions = originalInstructions;
3271
3274
  if (additionalInstructions) {
@@ -3286,15 +3289,15 @@ ${additionalInstructions}`;
3286
3289
  this.logger.debug(`[AgentBuilder:${this.name}] Starting streaming with enhanced context`, {
3287
3290
  projectPath: this.builderConfig.projectPath
3288
3291
  });
3289
- return super.stream(messages, enhancedOptions);
3292
+ return super.streamLegacy(messages, enhancedOptions);
3290
3293
  };
3291
3294
  /**
3292
3295
  * Enhanced stream method with AgentBuilder-specific configuration
3293
3296
  * Overrides the base Agent stream method to provide additional project context
3294
3297
  */
3295
- async streamVNext(messages, streamOptions) {
3298
+ async stream(messages, streamOptions) {
3296
3299
  const { ...baseOptions } = streamOptions || {};
3297
- const originalInstructions = await this.getInstructions({ runtimeContext: streamOptions?.runtimeContext });
3300
+ const originalInstructions = await this.getInstructions({ requestContext: streamOptions?.requestContext });
3298
3301
  const additionalInstructions = baseOptions.instructions;
3299
3302
  let enhancedInstructions = originalInstructions;
3300
3303
  if (additionalInstructions) {
@@ -3314,11 +3317,11 @@ ${additionalInstructions}`;
3314
3317
  this.logger.debug(`[AgentBuilder:${this.name}] Starting streaming with enhanced context`, {
3315
3318
  projectPath: this.builderConfig.projectPath
3316
3319
  });
3317
- return super.streamVNext(messages, enhancedOptions);
3320
+ return super.stream(messages, enhancedOptions);
3318
3321
  }
3319
- async generateVNext(messages, options) {
3322
+ async generate(messages, options) {
3320
3323
  const { ...baseOptions } = options || {};
3321
- const originalInstructions = await this.getInstructions({ runtimeContext: options?.runtimeContext });
3324
+ const originalInstructions = await this.getInstructions({ requestContext: options?.requestContext });
3322
3325
  const additionalInstructions = baseOptions.instructions;
3323
3326
  let enhancedInstructions = originalInstructions;
3324
3327
  if (additionalInstructions) {
@@ -3338,7 +3341,7 @@ ${additionalInstructions}`;
3338
3341
  this.logger.debug(`[AgentBuilder:${this.name}] Starting streaming with enhanced context`, {
3339
3342
  projectPath: this.builderConfig.projectPath
3340
3343
  });
3341
- return super.generateVNext(messages, enhancedOptions);
3344
+ return super.generate(messages, enhancedOptions);
3342
3345
  }
3343
3346
  };
3344
3347
  var cloneTemplateStep = createStep({
@@ -3426,14 +3429,15 @@ var discoverUnitsStep = createStep({
3426
3429
  description: "Discover template units by analyzing the templates directory structure",
3427
3430
  inputSchema: CloneTemplateResultSchema,
3428
3431
  outputSchema: DiscoveryResultSchema,
3429
- execute: async ({ inputData, runtimeContext }) => {
3432
+ execute: async ({ inputData, requestContext }) => {
3430
3433
  const { templateDir } = inputData;
3431
- const targetPath = resolveTargetPath(inputData, runtimeContext);
3434
+ const targetPath = resolveTargetPath(inputData, requestContext);
3432
3435
  const tools = await AgentBuilderDefaults.DEFAULT_TOOLS(templateDir);
3433
3436
  console.info("targetPath", targetPath);
3434
- const model = await resolveModel({ runtimeContext, projectPath: targetPath, defaultModel: openai("gpt-4.1") });
3437
+ const model = await resolveModel({ requestContext, projectPath: targetPath, defaultModel: openai("gpt-4.1") });
3435
3438
  try {
3436
3439
  const agent = new Agent({
3440
+ id: "mastra-project-discoverer",
3437
3441
  model,
3438
3442
  instructions: `You are an expert at analyzing Mastra projects.
3439
3443
 
@@ -3491,10 +3495,12 @@ Return the actual exported names of the units, as well as the file names.`,
3491
3495
  networks: z.array(z.object({ name: z.string(), file: z.string() })).optional(),
3492
3496
  other: z.array(z.object({ name: z.string(), file: z.string() })).optional()
3493
3497
  });
3494
- const result = isV2 ? await agent.generateVNext(prompt, {
3495
- output,
3498
+ const result = isV2 ? await tryGenerateWithJsonFallback(agent, prompt, {
3499
+ structuredOutput: {
3500
+ schema: output
3501
+ },
3496
3502
  maxSteps: 100
3497
- }) : await agent.generate(prompt, {
3503
+ }) : await agent.generateLegacy(prompt, {
3498
3504
  experimental_output: output,
3499
3505
  maxSteps: 100
3500
3506
  });
@@ -3568,8 +3574,8 @@ var prepareBranchStep = createStep({
3568
3574
  description: "Create or switch to integration branch before modifications",
3569
3575
  inputSchema: PrepareBranchInputSchema,
3570
3576
  outputSchema: PrepareBranchResultSchema,
3571
- execute: async ({ inputData, runtimeContext }) => {
3572
- const targetPath = resolveTargetPath(inputData, runtimeContext);
3577
+ execute: async ({ inputData, requestContext }) => {
3578
+ const targetPath = resolveTargetPath(inputData, requestContext);
3573
3579
  try {
3574
3580
  const branchName = `feat/install-template-${inputData.slug}`;
3575
3581
  await gitCheckoutBranch(branchName, targetPath);
@@ -3593,10 +3599,10 @@ var packageMergeStep = createStep({
3593
3599
  description: "Merge template package.json dependencies into target project",
3594
3600
  inputSchema: PackageMergeInputSchema,
3595
3601
  outputSchema: PackageMergeResultSchema,
3596
- execute: async ({ inputData, runtimeContext }) => {
3602
+ execute: async ({ inputData, requestContext }) => {
3597
3603
  console.info("Package merge step starting...");
3598
3604
  const { slug, packageInfo } = inputData;
3599
- const targetPath = resolveTargetPath(inputData, runtimeContext);
3605
+ const targetPath = resolveTargetPath(inputData, requestContext);
3600
3606
  try {
3601
3607
  const targetPkgPath = join(targetPath, "package.json");
3602
3608
  let targetPkgRaw = "{}";
@@ -3670,9 +3676,9 @@ var installStep = createStep({
3670
3676
  description: "Install packages based on merged package.json",
3671
3677
  inputSchema: InstallInputSchema,
3672
3678
  outputSchema: InstallResultSchema,
3673
- execute: async ({ inputData, runtimeContext }) => {
3679
+ execute: async ({ inputData, requestContext }) => {
3674
3680
  console.info("Running install step...");
3675
- const targetPath = resolveTargetPath(inputData, runtimeContext);
3681
+ const targetPath = resolveTargetPath(inputData, requestContext);
3676
3682
  try {
3677
3683
  await spawnSWPM(targetPath, "install", []);
3678
3684
  const lock = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock"].map((f) => join(targetPath, f)).find((f) => existsSync(f));
@@ -3698,10 +3704,10 @@ var programmaticFileCopyStep = createStep({
3698
3704
  description: "Programmatically copy template files to target project based on ordered units",
3699
3705
  inputSchema: FileCopyInputSchema,
3700
3706
  outputSchema: FileCopyResultSchema,
3701
- execute: async ({ inputData, runtimeContext }) => {
3707
+ execute: async ({ inputData, requestContext }) => {
3702
3708
  console.info("Programmatic file copy step starting...");
3703
3709
  const { orderedUnits, templateDir, commitSha, slug } = inputData;
3704
- const targetPath = resolveTargetPath(inputData, runtimeContext);
3710
+ const targetPath = resolveTargetPath(inputData, requestContext);
3705
3711
  try {
3706
3712
  const copiedFiles = [];
3707
3713
  const conflicts = [];
@@ -4050,12 +4056,12 @@ var intelligentMergeStep = createStep({
4050
4056
  description: "Use AgentBuilder to intelligently merge template files",
4051
4057
  inputSchema: IntelligentMergeInputSchema,
4052
4058
  outputSchema: IntelligentMergeResultSchema,
4053
- execute: async ({ inputData, runtimeContext }) => {
4059
+ execute: async ({ inputData, requestContext }) => {
4054
4060
  console.info("Intelligent merge step starting...");
4055
4061
  const { conflicts, copiedFiles, commitSha, slug, templateDir, branchName } = inputData;
4056
- const targetPath = resolveTargetPath(inputData, runtimeContext);
4062
+ const targetPath = resolveTargetPath(inputData, requestContext);
4057
4063
  try {
4058
- const model = await resolveModel({ runtimeContext, projectPath: targetPath, defaultModel: openai("gpt-4.1") });
4064
+ const model = await resolveModel({ requestContext, projectPath: targetPath, defaultModel: openai("gpt-4.1") });
4059
4065
  const copyFileTool = createTool({
4060
4066
  id: "copy-file",
4061
4067
  description: "Copy a file from template to target project (use only for edge cases - most files are already copied programmatically).",
@@ -4068,9 +4074,9 @@ var intelligentMergeStep = createStep({
4068
4074
  message: z.string(),
4069
4075
  error: z.string().optional()
4070
4076
  }),
4071
- execute: async ({ context }) => {
4077
+ execute: async (input) => {
4072
4078
  try {
4073
- const { sourcePath, destinationPath } = context;
4079
+ const { sourcePath, destinationPath } = input;
4074
4080
  const resolvedSourcePath = resolve(templateDir, sourcePath);
4075
4081
  const resolvedDestinationPath = resolve(targetPath, destinationPath);
4076
4082
  if (existsSync(resolvedSourcePath) && !existsSync(dirname(resolvedDestinationPath))) {
@@ -4240,7 +4246,7 @@ For each task:
4240
4246
  Start by listing your tasks and work through them systematically!
4241
4247
  `;
4242
4248
  const isV2 = model.specificationVersion === "v2";
4243
- const result = isV2 ? await agentBuilder.streamVNext(prompt) : await agentBuilder.stream(prompt);
4249
+ const result = isV2 ? await agentBuilder.stream(prompt) : await agentBuilder.streamLegacy(prompt);
4244
4250
  const actualResolutions = [];
4245
4251
  for await (const chunk of result.fullStream) {
4246
4252
  if (chunk.type === "step-finish" || chunk.type === "step-start") {
@@ -4318,10 +4324,10 @@ var validationAndFixStep = createStep({
4318
4324
  description: "Validate the merged template code and fix any issues using a specialized agent",
4319
4325
  inputSchema: ValidationFixInputSchema,
4320
4326
  outputSchema: ValidationFixResultSchema,
4321
- execute: async ({ inputData, runtimeContext }) => {
4327
+ execute: async ({ inputData, requestContext }) => {
4322
4328
  console.info("Validation and fix step starting...");
4323
4329
  const { commitSha, slug, orderedUnits, templateDir, copiedFiles, conflictsResolved, maxIterations = 5 } = inputData;
4324
- const targetPath = resolveTargetPath(inputData, runtimeContext);
4330
+ const targetPath = resolveTargetPath(inputData, requestContext);
4325
4331
  const hasChanges = copiedFiles.length > 0 || conflictsResolved && conflictsResolved.length > 0;
4326
4332
  if (!hasChanges) {
4327
4333
  console.info("\u23ED\uFE0F Skipping validation - no files copied or conflicts resolved");
@@ -4341,10 +4347,11 @@ var validationAndFixStep = createStep({
4341
4347
  );
4342
4348
  let currentIteration = 1;
4343
4349
  try {
4344
- const model = await resolveModel({ runtimeContext, projectPath: targetPath, defaultModel: openai("gpt-4.1") });
4345
- const allTools = await AgentBuilderDefaults.getToolsForMode(targetPath, "template");
4350
+ const model = await resolveModel({ requestContext, projectPath: targetPath, defaultModel: openai("gpt-4.1") });
4351
+ const allTools = await AgentBuilderDefaults.listToolsForMode(targetPath, "template");
4346
4352
  const validationAgent = new Agent({
4347
- name: "code-validator-fixer",
4353
+ id: "code-validator-fixer",
4354
+ name: "Code Validator Fixer",
4348
4355
  description: "Specialized agent for validating and fixing template integration issues",
4349
4356
  instructions: `You are a code validation and fixing specialist. Your job is to:
4350
4357
 
@@ -4482,9 +4489,11 @@ Start by running validateCode with all validation types to get a complete pictur
4482
4489
  Previous iterations may have fixed some issues, so start by re-running validateCode to see the current state, then fix any remaining issues.`;
4483
4490
  const isV2 = model.specificationVersion === "v2";
4484
4491
  const output = z.object({ success: z.boolean() });
4485
- const result = isV2 ? await validationAgent.streamVNext(iterationPrompt, {
4486
- output
4487
- }) : await validationAgent.stream(iterationPrompt, {
4492
+ const result = isV2 ? await tryStreamWithJsonFallback(validationAgent, iterationPrompt, {
4493
+ structuredOutput: {
4494
+ schema: output
4495
+ }
4496
+ }) : await validationAgent.streamLegacy(iterationPrompt, {
4488
4497
  experimental_output: output
4489
4498
  });
4490
4499
  let iterationErrors = 0;
@@ -4745,7 +4754,7 @@ var agentBuilderTemplateWorkflow = createWorkflow({
4745
4754
  }).commit();
4746
4755
  async function mergeTemplateBySlug(slug, targetPath) {
4747
4756
  const template = await getMastraTemplate(slug);
4748
- const run = await agentBuilderTemplateWorkflow.createRunAsync();
4757
+ const run = await agentBuilderTemplateWorkflow.createRun();
4749
4758
  return await run.start({
4750
4759
  inputData: {
4751
4760
  repo: template.githubUrl,
@@ -5052,7 +5061,7 @@ var planningIterationStep = createStep({
5052
5061
  outputSchema: PlanningIterationResultSchema,
5053
5062
  suspendSchema: PlanningIterationSuspendSchema,
5054
5063
  resumeSchema: PlanningIterationResumeSchema,
5055
- execute: async ({ inputData, resumeData, suspend, runtimeContext }) => {
5064
+ execute: async ({ inputData, resumeData, suspend, requestContext }) => {
5056
5065
  const {
5057
5066
  action,
5058
5067
  workflowName,
@@ -5065,7 +5074,7 @@ var planningIterationStep = createStep({
5065
5074
  } = inputData;
5066
5075
  console.info("Starting planning iteration...");
5067
5076
  const qaKey = "workflow-builder-qa";
5068
- let storedQAPairs = runtimeContext.get(qaKey) || [];
5077
+ let storedQAPairs = requestContext.get(qaKey) || [];
5069
5078
  const newAnswers = { ...userAnswers || {}, ...resumeData?.answers || {} };
5070
5079
  if (Object.keys(newAnswers).length > 0) {
5071
5080
  storedQAPairs = storedQAPairs.map((pair) => {
@@ -5078,11 +5087,12 @@ var planningIterationStep = createStep({
5078
5087
  }
5079
5088
  return pair;
5080
5089
  });
5081
- runtimeContext.set(qaKey, storedQAPairs);
5090
+ requestContext.set(qaKey, storedQAPairs);
5082
5091
  }
5083
5092
  try {
5084
- const model = await resolveModel({ runtimeContext });
5093
+ const model = await resolveModel({ requestContext });
5085
5094
  const planningAgent = new Agent({
5095
+ id: "workflow-planning-agent",
5086
5096
  model,
5087
5097
  instructions: taskPlanningPrompts.planningAgent.instructions({
5088
5098
  storedQAPairs
@@ -5111,8 +5121,10 @@ var planningIterationStep = createStep({
5111
5121
  projectStructure,
5112
5122
  research
5113
5123
  });
5114
- const result = await planningAgent.generateVNext(planningPrompt, {
5115
- output: PlanningAgentOutputSchema
5124
+ const result = await planningAgent.generate(planningPrompt, {
5125
+ structuredOutput: {
5126
+ schema: PlanningAgentOutputSchema
5127
+ }
5116
5128
  // maxSteps: 15,
5117
5129
  });
5118
5130
  const planResult = await result.object;
@@ -5136,7 +5148,7 @@ var planningIterationStep = createStep({
5136
5148
  answeredAt: null
5137
5149
  }));
5138
5150
  storedQAPairs = [...storedQAPairs, ...newQAPairs];
5139
- runtimeContext.set(qaKey, storedQAPairs);
5151
+ requestContext.set(qaKey, storedQAPairs);
5140
5152
  console.info(
5141
5153
  `Updated Q&A state: ${storedQAPairs.length} total question-answer pairs, ${storedQAPairs.filter((p) => p.answer).length} answered`
5142
5154
  );
@@ -5150,7 +5162,7 @@ var planningIterationStep = createStep({
5150
5162
  });
5151
5163
  }
5152
5164
  console.info(`Planning complete with ${planResult.tasks.length} tasks`);
5153
- runtimeContext.set(qaKey, storedQAPairs);
5165
+ requestContext.set(qaKey, storedQAPairs);
5154
5166
  console.info(
5155
5167
  `Final Q&A state: ${storedQAPairs.length} total question-answer pairs, ${storedQAPairs.filter((p) => p.answer).length} answered`
5156
5168
  );
@@ -5295,7 +5307,7 @@ const myStep = createStep({
5295
5307
  - \`mastra\`: Access to Mastra instance (agents, tools, other workflows)
5296
5308
  - \`getStepResult(stepInstance)\`: Get results from previous steps
5297
5309
  - \`getInitData()\`: Access original workflow input data
5298
- - \`runtimeContext\`: Runtime dependency injection context
5310
+ - \`requestContext\`: Runtime dependency injection context
5299
5311
  - \`runCount\`: Number of times this step has run (useful for retries)
5300
5312
 
5301
5313
  ### **\u{1F504} CONTROL FLOW METHODS**
@@ -5374,10 +5386,10 @@ const toolStep = createStep(myTool);
5374
5386
 
5375
5387
  // Method 2: Call tool in execute function
5376
5388
  const step = createStep({
5377
- execute: async ({ inputData, runtimeContext }) => {
5389
+ execute: async ({ inputData, requestContext }) => {
5378
5390
  const result = await myTool.execute({
5379
5391
  context: inputData,
5380
- runtimeContext
5392
+ requestContext
5381
5393
  });
5382
5394
  return result;
5383
5395
  }
@@ -5421,7 +5433,7 @@ export const mastra = new Mastra({
5421
5433
  sendEmailWorkflow, // Use camelCase for keys
5422
5434
  dataProcessingWorkflow
5423
5435
  },
5424
- storage: new LibSQLStore({ url: 'file:./mastra.db' }), // Required for suspend/resume
5436
+ storage: new LibSQLStore({ id: 'mastra-storage', url: 'file:./mastra.db' }), // Required for suspend/resume
5425
5437
  });
5426
5438
  \`\`\`
5427
5439
 
@@ -5469,7 +5481,7 @@ export const mastra = new Mastra({
5469
5481
  **Running Workflows:**
5470
5482
  \`\`\`typescript
5471
5483
  // Create and start run
5472
- const run = await workflow.createRunAsync();
5484
+ const run = await workflow.createRun();
5473
5485
  const result = await run.start({ inputData: {...} });
5474
5486
 
5475
5487
  // Stream execution for real-time monitoring
@@ -5493,7 +5505,7 @@ run.watch((event) => console.log(event));
5493
5505
  - Use workflows as steps: \`.then(otherWorkflow)\`
5494
5506
  - Enable complex workflow composition
5495
5507
 
5496
- **Runtime Context:**
5508
+ **Request Context:**
5497
5509
  - Pass shared data across all steps
5498
5510
  - Enable dependency injection patterns
5499
5511
 
@@ -5666,11 +5678,11 @@ var restrictedTaskManager = createTool({
5666
5678
  ),
5667
5679
  message: z.string()
5668
5680
  }),
5669
- execute: async ({ context }) => {
5681
+ execute: async (input) => {
5670
5682
  const adaptedContext = {
5671
- ...context,
5672
- action: context.action,
5673
- tasks: context.tasks?.map((task) => ({
5683
+ ...input,
5684
+ action: input.action,
5685
+ tasks: input.tasks?.map((task) => ({
5674
5686
  ...task,
5675
5687
  priority: task.priority || "medium"
5676
5688
  }))
@@ -5685,7 +5697,7 @@ var workflowDiscoveryStep = createStep({
5685
5697
  description: "Discover existing workflows in the project",
5686
5698
  inputSchema: WorkflowBuilderInputSchema,
5687
5699
  outputSchema: WorkflowDiscoveryResultSchema,
5688
- execute: async ({ inputData, runtimeContext: _runtimeContext }) => {
5700
+ execute: async ({ inputData, requestContext: _requestContext }) => {
5689
5701
  console.info("Starting workflow discovery...");
5690
5702
  const { projectPath = process.cwd() } = inputData;
5691
5703
  try {
@@ -5744,7 +5756,7 @@ var projectDiscoveryStep = createStep({
5744
5756
  description: "Analyze the project structure and setup",
5745
5757
  inputSchema: WorkflowDiscoveryResultSchema,
5746
5758
  outputSchema: ProjectDiscoveryResultSchema,
5747
- execute: async ({ inputData: _inputData, runtimeContext: _runtimeContext }) => {
5759
+ execute: async ({ inputData: _inputData, requestContext: _requestContext }) => {
5748
5760
  console.info("Starting project discovery...");
5749
5761
  try {
5750
5762
  const projectPath = process.cwd();
@@ -5806,11 +5818,12 @@ var workflowResearchStep = createStep({
5806
5818
  description: "Research Mastra workflows and gather relevant documentation",
5807
5819
  inputSchema: ProjectDiscoveryResultSchema,
5808
5820
  outputSchema: WorkflowResearchResultSchema,
5809
- execute: async ({ inputData, runtimeContext }) => {
5821
+ execute: async ({ inputData, requestContext }) => {
5810
5822
  console.info("Starting workflow research...");
5811
5823
  try {
5812
- const model = await resolveModel({ runtimeContext });
5824
+ const model = await resolveModel({ requestContext });
5813
5825
  const researchAgent = new Agent({
5826
+ id: "workflow-research-agent",
5814
5827
  model,
5815
5828
  instructions: workflowBuilderPrompts.researchAgent.instructions,
5816
5829
  name: "Workflow Research Agent"
@@ -5821,8 +5834,10 @@ var workflowResearchStep = createStep({
5821
5834
  dependencies: inputData.dependencies,
5822
5835
  hasWorkflowsDir: inputData.structure.hasWorkflowsDir
5823
5836
  });
5824
- const result = await researchAgent.generateVNext(researchPrompt, {
5825
- output: WorkflowResearchResultSchema
5837
+ const result = await researchAgent.generate(researchPrompt, {
5838
+ structuredOutput: {
5839
+ schema: WorkflowResearchResultSchema
5840
+ }
5826
5841
  // stopWhen: stepCountIs(10),
5827
5842
  });
5828
5843
  const researchResult = await result.object;
@@ -5873,7 +5888,7 @@ var taskExecutionStep = createStep({
5873
5888
  outputSchema: TaskExecutionResultSchema,
5874
5889
  suspendSchema: TaskExecutionSuspendSchema,
5875
5890
  resumeSchema: TaskExecutionResumeSchema,
5876
- execute: async ({ inputData, resumeData, suspend, runtimeContext }) => {
5891
+ execute: async ({ inputData, resumeData, suspend, requestContext }) => {
5877
5892
  const {
5878
5893
  action,
5879
5894
  workflowName,
@@ -5888,7 +5903,7 @@ var taskExecutionStep = createStep({
5888
5903
  console.info(`Starting task execution for ${action}ing workflow: ${workflowName}`);
5889
5904
  console.info(`Executing ${tasks.length} tasks using AgentBuilder stream...`);
5890
5905
  try {
5891
- const model = await resolveModel({ runtimeContext });
5906
+ const model = await resolveModel({ requestContext });
5892
5907
  const currentProjectPath = projectPath || process.cwd();
5893
5908
  console.info("Pre-populating taskManager with planned tasks...");
5894
5909
  const taskManagerContext = {
@@ -5933,18 +5948,11 @@ ${workflowBuilderPrompts.validation.instructions}`
5933
5948
  tasks,
5934
5949
  resumeData
5935
5950
  });
5936
- const originalInstructions = await executionAgent.getInstructions({ runtimeContext });
5937
- const additionalInstructions = executionAgent.instructions;
5938
- let enhancedInstructions = originalInstructions;
5939
- if (additionalInstructions) {
5940
- enhancedInstructions = `${originalInstructions}
5941
-
5942
- ${additionalInstructions}`;
5943
- }
5951
+ const originalInstructions = await executionAgent.getInstructions({ requestContext });
5944
5952
  const enhancedOptions = {
5945
5953
  stopWhen: stepCountIs(100),
5946
5954
  temperature: 0.3,
5947
- instructions: enhancedInstructions
5955
+ instructions: originalInstructions
5948
5956
  };
5949
5957
  let finalResult = null;
5950
5958
  let allTasksCompleted = false;
@@ -5973,7 +5981,7 @@ ${additionalInstructions}`;
5973
5981
  })}
5974
5982
 
5975
5983
  ${workflowBuilderPrompts.validation.instructions}`;
5976
- const stream = await executionAgent.streamVNext(iterationPrompt, {
5984
+ const stream = await executionAgent.stream(iterationPrompt, {
5977
5985
  structuredOutput: {
5978
5986
  schema: TaskExecutionIterationInputSchema(tasks.length),
5979
5987
  model