@mastra/agent-builder 1.1.30-alpha.8 → 1.1.30

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
@@ -218,7 +218,8 @@ const exec$1 = promisify(exec);
218
218
  const execFile$1 = promisify(execFile);
219
219
  function isInWorkspaceSubfolder(cwd) {
220
220
  try {
221
- if (!existsSync(resolve(cwd, "package.json"))) return false;
221
+ const currentPackageJson = resolve(cwd, "package.json");
222
+ if (!existsSync(currentPackageJson)) return false;
222
223
  let currentDir = cwd;
223
224
  let previousDir = "";
224
225
  while (currentDir !== previousDir && currentDir !== "/") {
@@ -461,7 +462,8 @@ async function renameAndCopyFile(sourceFile, targetFile) {
461
462
  const extension = extname(targetFile);
462
463
  const directory = dirname(targetFile);
463
464
  while (existsSync(uniqueTargetFile)) {
464
- uniqueTargetFile = resolve(directory, `${baseName}.template-${counter}${extension}`);
465
+ const uniqueName = `${baseName}.template-${counter}${extension}`;
466
+ uniqueTargetFile = resolve(directory, uniqueName);
465
467
  counter++;
466
468
  }
467
469
  await copyFile(sourceFile, uniqueTargetFile);
@@ -1777,9 +1779,12 @@ export const mastra = new Mastra({
1777
1779
  ...env,
1778
1780
  PORT: port.toString()
1779
1781
  };
1780
- const serverProcess = spawn("pnpm", ["run", "dev"], {
1782
+ const execOptions = {
1781
1783
  cwd: projectPath || process.cwd(),
1782
- env: serverEnv,
1784
+ env: serverEnv
1785
+ };
1786
+ const serverProcess = spawn("pnpm", ["run", "dev"], {
1787
+ ...execOptions,
1783
1788
  detached: true,
1784
1789
  stdio: "pipe"
1785
1790
  });
@@ -2423,7 +2428,8 @@ export const mastra = new Mastra({
2423
2428
  try {
2424
2429
  if (createBackup) {
2425
2430
  const backupPath = `${filePath}.backup.${Date.now()}`;
2426
- await writeFile(backupPath, await readFile(filePath, "utf-8"), "utf-8");
2431
+ const originalContent = await readFile(filePath, "utf-8");
2432
+ await writeFile(backupPath, originalContent, "utf-8");
2427
2433
  backup = backupPath;
2428
2434
  }
2429
2435
  let content = await readFile(filePath, "utf-8");
@@ -2500,11 +2506,12 @@ export const mastra = new Mastra({
2500
2506
  const beforeLines = lines.slice(0, startLine - 1);
2501
2507
  const afterLines = lines.slice(endLine);
2502
2508
  const newLines = newContent ? newContent.split("\n") : [];
2503
- await writeFile(fullPath, [
2509
+ const updatedContent = [
2504
2510
  ...beforeLines,
2505
2511
  ...newLines,
2506
2512
  ...afterLines
2507
- ].join("\n"), "utf-8");
2513
+ ].join("\n");
2514
+ await writeFile(fullPath, updatedContent, "utf-8");
2508
2515
  const linesReplaced = endLine - startLine + 1;
2509
2516
  return {
2510
2517
  success: true,
@@ -2526,7 +2533,8 @@ export const mastra = new Mastra({
2526
2533
  static async showFileLines(context) {
2527
2534
  const { filePath, startLine, endLine, context: contextLines = 2, projectPath = process.cwd() } = context;
2528
2535
  try {
2529
- const lines = (await readFile(isAbsolute(filePath) ? filePath : join(projectPath, filePath), "utf-8")).split("\n");
2536
+ const fullPath = isAbsolute(filePath) ? filePath : join(projectPath, filePath);
2537
+ const lines = (await readFile(fullPath, "utf-8")).split("\n");
2530
2538
  let targetStart = startLine;
2531
2539
  let targetEnd = endLine;
2532
2540
  if (!targetStart) {
@@ -3241,7 +3249,8 @@ Return the actual exported names of the units, as well as the file names.`,
3241
3249
  listDirectory: tools.listDirectory
3242
3250
  }
3243
3251
  });
3244
- const isSupported = isSupportedLanguageModel(await agent.getModel());
3252
+ const resolvedModel = await agent.getModel();
3253
+ const isSupported = isSupportedLanguageModel(resolvedModel);
3245
3254
  const prompt = `Analyze the Mastra project directory structure at "${templateDir}".
3246
3255
 
3247
3256
  List directory contents using listDirectory tool, and then analyze each file with readFile tool.
@@ -3284,7 +3293,8 @@ Return the actual exported names of the units, as well as the file names.`,
3284
3293
  maxSteps: 100
3285
3294
  });
3286
3295
  else {
3287
- const jsonSchema = standardSchemaToJSONSchema(toStandardSchema(output));
3296
+ const standardSchema = toStandardSchema(output);
3297
+ const jsonSchema = standardSchemaToJSONSchema(standardSchema);
3288
3298
  result = await agent.generateLegacy(prompt, {
3289
3299
  experimental_output: jsonSchema,
3290
3300
  maxSteps: 100
@@ -3770,33 +3780,36 @@ const programmaticFileCopyStep = createStep({
3770
3780
  const targetGitignore = resolve(targetPath, ".gitignore");
3771
3781
  const templateGitignore = resolve(templateDir, ".gitignore");
3772
3782
  const targetExists = existsSync(targetGitignore);
3773
- if (existsSync(templateGitignore)) if (!targetExists) {
3774
- await copyFile(templateGitignore, targetGitignore);
3775
- copiedFiles.push({
3776
- source: templateGitignore,
3777
- destination: targetGitignore,
3778
- unit: {
3779
- kind: "other",
3780
- id: "gitignore"
3781
- }
3782
- });
3783
- console.info("✓ Copied .gitignore from template to target");
3784
- } else {
3785
- const targetContent = await readFile(targetGitignore, "utf-8");
3786
- const mergedContent = mergeGitignoreFiles(targetContent, await readFile(templateGitignore, "utf-8"), slug);
3787
- if (mergedContent !== targetContent) {
3788
- const addedLines = mergedContent.split("\n").length - targetContent.split("\n").length;
3789
- await writeFile(targetGitignore, mergedContent, "utf-8");
3783
+ if (existsSync(templateGitignore)) {
3784
+ if (!targetExists) {
3785
+ await copyFile(templateGitignore, targetGitignore);
3790
3786
  copiedFiles.push({
3791
3787
  source: templateGitignore,
3792
3788
  destination: targetGitignore,
3793
3789
  unit: {
3794
3790
  kind: "other",
3795
- id: "gitignore-merge"
3791
+ id: "gitignore"
3796
3792
  }
3797
3793
  });
3798
- console.info(`✓ Merged template .gitignore entries into existing .gitignore (${addedLines} new entries)`);
3799
- } else console.info("ℹ No new .gitignore entries to add from template");
3794
+ console.info("✓ Copied .gitignore from template to target");
3795
+ } else {
3796
+ const targetContent = await readFile(targetGitignore, "utf-8");
3797
+ const templateContent = await readFile(templateGitignore, "utf-8");
3798
+ const mergedContent = mergeGitignoreFiles(targetContent, templateContent, slug);
3799
+ if (mergedContent !== targetContent) {
3800
+ const addedLines = mergedContent.split("\n").length - targetContent.split("\n").length;
3801
+ await writeFile(targetGitignore, mergedContent, "utf-8");
3802
+ copiedFiles.push({
3803
+ source: templateGitignore,
3804
+ destination: targetGitignore,
3805
+ unit: {
3806
+ kind: "other",
3807
+ id: "gitignore-merge"
3808
+ }
3809
+ });
3810
+ console.info(`✓ Merged template .gitignore entries into existing .gitignore (${addedLines} new entries)`);
3811
+ } else console.info("ℹ No new .gitignore entries to add from template");
3812
+ }
3800
3813
  }
3801
3814
  } catch (e) {
3802
3815
  conflicts.push({
@@ -3814,7 +3827,8 @@ const programmaticFileCopyStep = createStep({
3814
3827
  if (variables && Object.keys(variables).length > 0) {
3815
3828
  const targetEnv = resolve(targetPath, ".env");
3816
3829
  if (!existsSync(targetEnv)) {
3817
- await writeFile(targetEnv, [`# Environment variables for ${slug}`, ...Object.entries(variables).map(([key, value]) => `${key}=${value}`)].join("\n"), "utf-8");
3830
+ const envContent = [`# Environment variables for ${slug}`, ...Object.entries(variables).map(([key, value]) => `${key}=${value}`)].join("\n");
3831
+ await writeFile(targetEnv, envContent, "utf-8");
3818
3832
  copiedFiles.push({
3819
3833
  source: "[template variables]",
3820
3834
  destination: targetEnv,
@@ -4077,7 +4091,8 @@ For each task:
4077
4091
 
4078
4092
  Start by listing your tasks and work through them systematically!
4079
4093
  `;
4080
- const result = isSupportedLanguageModel(await agentBuilder.getModel()) ? await agentBuilder.stream(prompt) : await agentBuilder.streamLegacy(prompt);
4094
+ const resolvedModel = await agentBuilder.getModel();
4095
+ const result = isSupportedLanguageModel(resolvedModel) ? await agentBuilder.stream(prompt) : await agentBuilder.streamLegacy(prompt);
4081
4096
  const actualResolutions = [];
4082
4097
  for await (const chunk of result.fullStream) if (chunk.type === "step-finish" || chunk.type === "step-start") {
4083
4098
  const chunkData = "payload" in chunk ? chunk.payload : chunk;
@@ -4305,7 +4320,8 @@ Be thorough and methodical. Always use listDirectory to verify actual file exist
4305
4320
  Start by running validateCode with all validation types to get a complete picture of any issues, then systematically fix them.` : `Continue validation and fixing for the template integration at ${targetPath}. This is iteration ${currentIteration} of validation.
4306
4321
 
4307
4322
  Previous iterations may have fixed some issues, so start by re-running validateCode to see the current state, then fix any remaining issues.`;
4308
- const isSupported = isSupportedLanguageModel(await validationAgent.getModel());
4323
+ const resolvedModel = await validationAgent.getModel();
4324
+ const isSupported = isSupportedLanguageModel(resolvedModel);
4309
4325
  const output = z.object({ success: z.boolean() });
4310
4326
  const result = isSupported ? await tryStreamWithJsonFallback(validationAgent, iterationPrompt, { structuredOutput: { schema: output } }) : await validationAgent.streamLegacy(iterationPrompt, { experimental_output: output });
4311
4327
  let iterationErrors = 0;
@@ -4548,7 +4564,7 @@ const shouldAbortWorkflow = (stepResult) => {
4548
4564
  return stepResult?.success === false || stepResult?.error;
4549
4565
  };
4550
4566
  //#endregion
4551
- //#region ../_vendored/ai_v5/dist/dist-C6PO6CsQ.js
4567
+ //#region ../_vendored/ai_v5/dist/dist-OCi48HWi.js
4552
4568
  var marker$1 = "vercel.ai.error";
4553
4569
  var symbol$1 = Symbol.for(marker$1);
4554
4570
  var _a$1;
@@ -4581,48 +4597,6 @@ var AISDKError = class _AISDKError extends (_b$1 = Error, _a$1 = symbol$1, _b$1)
4581
4597
  return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
4582
4598
  }
4583
4599
  };
4584
- var name$1 = "AI_APICallError";
4585
- var marker2$1 = `vercel.ai.error.${name$1}`;
4586
- var symbol2$1 = Symbol.for(marker2$1);
4587
- var _a2$1;
4588
- var _b2;
4589
- (class extends (_b2 = AISDKError, _a2$1 = symbol2$1, _b2) {
4590
- constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
4591
- super({
4592
- name: name$1,
4593
- message,
4594
- cause
4595
- });
4596
- this[_a2$1] = true;
4597
- this.url = url;
4598
- this.requestBodyValues = requestBodyValues;
4599
- this.statusCode = statusCode;
4600
- this.responseHeaders = responseHeaders;
4601
- this.responseBody = responseBody;
4602
- this.isRetryable = isRetryable;
4603
- this.data = data;
4604
- }
4605
- static isInstance(error) {
4606
- return AISDKError.hasMarker(error, marker2$1);
4607
- }
4608
- });
4609
- var name2$1 = "AI_EmptyResponseBodyError";
4610
- var marker3$1 = `vercel.ai.error.${name2$1}`;
4611
- var symbol3$1 = Symbol.for(marker3$1);
4612
- var _a3$1;
4613
- var _b3;
4614
- (class extends (_b3 = AISDKError, _a3$1 = symbol3$1, _b3) {
4615
- constructor({ message = "Empty response body" } = {}) {
4616
- super({
4617
- name: name2$1,
4618
- message
4619
- });
4620
- this[_a3$1] = true;
4621
- }
4622
- static isInstance(error) {
4623
- return AISDKError.hasMarker(error, marker3$1);
4624
- }
4625
- });
4626
4600
  function getErrorMessage$1(error) {
4627
4601
  if (error == null) return "unknown error";
4628
4602
  if (typeof error === "string") return error;
@@ -4648,43 +4622,6 @@ var InvalidArgumentError = class extends (_b4 = AISDKError, _a4$1 = symbol4$1, _
4648
4622
  return AISDKError.hasMarker(error, marker4$1);
4649
4623
  }
4650
4624
  };
4651
- var name4$1 = "AI_InvalidPromptError";
4652
- var marker5$1 = `vercel.ai.error.${name4$1}`;
4653
- var symbol5$1 = Symbol.for(marker5$1);
4654
- var _a5$1;
4655
- var _b5;
4656
- (class extends (_b5 = AISDKError, _a5$1 = symbol5$1, _b5) {
4657
- constructor({ prompt, message, cause }) {
4658
- super({
4659
- name: name4$1,
4660
- message: `Invalid prompt: ${message}`,
4661
- cause
4662
- });
4663
- this[_a5$1] = true;
4664
- this.prompt = prompt;
4665
- }
4666
- static isInstance(error) {
4667
- return AISDKError.hasMarker(error, marker5$1);
4668
- }
4669
- });
4670
- var name5$1 = "AI_InvalidResponseDataError";
4671
- var marker6$1 = `vercel.ai.error.${name5$1}`;
4672
- var symbol6$1 = Symbol.for(marker6$1);
4673
- var _a6$1;
4674
- var _b6;
4675
- (class extends (_b6 = AISDKError, _a6$1 = symbol6$1, _b6) {
4676
- constructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {
4677
- super({
4678
- name: name5$1,
4679
- message
4680
- });
4681
- this[_a6$1] = true;
4682
- this.data = data;
4683
- }
4684
- static isInstance(error) {
4685
- return AISDKError.hasMarker(error, marker6$1);
4686
- }
4687
- });
4688
4625
  var name6$1 = "AI_JSONParseError";
4689
4626
  var marker7$1 = `vercel.ai.error.${name6$1}`;
4690
4627
  var symbol7$1 = Symbol.for(marker7$1);
@@ -4705,97 +4642,6 @@ Error message: ${getErrorMessage$1(cause)}`,
4705
4642
  return AISDKError.hasMarker(error, marker7$1);
4706
4643
  }
4707
4644
  };
4708
- var name7$1 = "AI_LoadAPIKeyError";
4709
- var marker8$1 = `vercel.ai.error.${name7$1}`;
4710
- var symbol8$1 = Symbol.for(marker8$1);
4711
- var _a8$1;
4712
- var _b8;
4713
- (class extends (_b8 = AISDKError, _a8$1 = symbol8$1, _b8) {
4714
- constructor({ message }) {
4715
- super({
4716
- name: name7$1,
4717
- message
4718
- });
4719
- this[_a8$1] = true;
4720
- }
4721
- static isInstance(error) {
4722
- return AISDKError.hasMarker(error, marker8$1);
4723
- }
4724
- });
4725
- var name8$1 = "AI_LoadSettingError";
4726
- var marker9$1 = `vercel.ai.error.${name8$1}`;
4727
- var symbol9$1 = Symbol.for(marker9$1);
4728
- var _a9$1;
4729
- var _b9;
4730
- (class extends (_b9 = AISDKError, _a9$1 = symbol9$1, _b9) {
4731
- constructor({ message }) {
4732
- super({
4733
- name: name8$1,
4734
- message
4735
- });
4736
- this[_a9$1] = true;
4737
- }
4738
- static isInstance(error) {
4739
- return AISDKError.hasMarker(error, marker9$1);
4740
- }
4741
- });
4742
- var name9$1 = "AI_NoContentGeneratedError";
4743
- var marker10$1 = `vercel.ai.error.${name9$1}`;
4744
- var symbol10$1 = Symbol.for(marker10$1);
4745
- var _a10$1;
4746
- var _b10;
4747
- (class extends (_b10 = AISDKError, _a10$1 = symbol10$1, _b10) {
4748
- constructor({ message = "No content generated." } = {}) {
4749
- super({
4750
- name: name9$1,
4751
- message
4752
- });
4753
- this[_a10$1] = true;
4754
- }
4755
- static isInstance(error) {
4756
- return AISDKError.hasMarker(error, marker10$1);
4757
- }
4758
- });
4759
- var name10$1 = "AI_NoSuchModelError";
4760
- var marker11$1 = `vercel.ai.error.${name10$1}`;
4761
- var symbol11$1 = Symbol.for(marker11$1);
4762
- var _a11$1;
4763
- var _b11;
4764
- (class extends (_b11 = AISDKError, _a11$1 = symbol11$1, _b11) {
4765
- constructor({ errorName = name10$1, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {
4766
- super({
4767
- name: errorName,
4768
- message
4769
- });
4770
- this[_a11$1] = true;
4771
- this.modelId = modelId;
4772
- this.modelType = modelType;
4773
- }
4774
- static isInstance(error) {
4775
- return AISDKError.hasMarker(error, marker11$1);
4776
- }
4777
- });
4778
- var name11$1 = "AI_TooManyEmbeddingValuesForCallError";
4779
- var marker12$1 = `vercel.ai.error.${name11$1}`;
4780
- var symbol12$1 = Symbol.for(marker12$1);
4781
- var _a12$1;
4782
- var _b12;
4783
- (class extends (_b12 = AISDKError, _a12$1 = symbol12$1, _b12) {
4784
- constructor(options) {
4785
- super({
4786
- name: name11$1,
4787
- message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
4788
- });
4789
- this[_a12$1] = true;
4790
- this.provider = options.provider;
4791
- this.modelId = options.modelId;
4792
- this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
4793
- this.values = options.values;
4794
- }
4795
- static isInstance(error) {
4796
- return AISDKError.hasMarker(error, marker12$1);
4797
- }
4798
- });
4799
4645
  var name12$1 = "AI_TypeValidationError";
4800
4646
  var marker13$1 = `vercel.ai.error.${name12$1}`;
4801
4647
  var symbol13$1 = Symbol.for(marker13$1);
@@ -4832,60 +4678,7 @@ Error message: ${getErrorMessage$1(cause)}`,
4832
4678
  });
4833
4679
  }
4834
4680
  };
4835
- var name13$1 = "AI_UnsupportedFunctionalityError";
4836
- var marker14$1 = `vercel.ai.error.${name13$1}`;
4837
- var symbol14$1 = Symbol.for(marker14$1);
4838
- var _a14$1;
4839
- var _b14;
4840
- (class extends (_b14 = AISDKError, _a14$1 = symbol14$1, _b14) {
4841
- constructor({ functionality, message = `'${functionality}' functionality not supported.` }) {
4842
- super({
4843
- name: name13$1,
4844
- message
4845
- });
4846
- this[_a14$1] = true;
4847
- this.functionality = functionality;
4848
- }
4849
- static isInstance(error) {
4850
- return AISDKError.hasMarker(error, marker14$1);
4851
- }
4852
- });
4853
4681
  TransformStream;
4854
- var name$2 = "AI_DownloadError";
4855
- var marker$2 = `vercel.ai.error.${name$2}`;
4856
- var symbol$2 = Symbol.for(marker$2);
4857
- var _a$2;
4858
- var _b;
4859
- (class extends (_b = AISDKError, _a$2 = symbol$2, _b) {
4860
- constructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {
4861
- super({
4862
- name: name$2,
4863
- message,
4864
- cause
4865
- });
4866
- this[_a$2] = true;
4867
- this.url = url;
4868
- this.statusCode = statusCode;
4869
- this.statusText = statusText;
4870
- }
4871
- static isInstance(error) {
4872
- return AISDKError.hasMarker(error, marker$2);
4873
- }
4874
- });
4875
- function getCurrentModulePath() {
4876
- const originalPrepareStackTrace = Error.prepareStackTrace;
4877
- try {
4878
- Error.prepareStackTrace = (_error, callSites) => callSites;
4879
- const error = /* @__PURE__ */ new Error("Capture current module path");
4880
- Error.captureStackTrace(error, getCurrentModulePath);
4881
- const [caller] = error.stack;
4882
- const fileName = caller == null ? void 0 : caller.getFileName();
4883
- if (fileName == null) throw new Error("Unable to determine the current module path");
4884
- return fileName;
4885
- } finally {
4886
- Error.prepareStackTrace = originalPrepareStackTrace;
4887
- }
4888
- }
4889
4682
  var createIdGenerator = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator = "-" } = {}) => {
4890
4683
  const generator = () => {
4891
4684
  const alphabetLength = alphabet.length;
@@ -5043,8 +4836,10 @@ function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
5043
4836
  const properties = jsonSchema2.properties;
5044
4837
  if (properties != null) for (const property in properties) properties[property] = addAdditionalPropertiesToJsonSchema(properties[property]);
5045
4838
  }
5046
- if (jsonSchema2.type === "array" && jsonSchema2.items != null) if (Array.isArray(jsonSchema2.items)) jsonSchema2.items = jsonSchema2.items.map((item) => addAdditionalPropertiesToJsonSchema(item));
5047
- else jsonSchema2.items = addAdditionalPropertiesToJsonSchema(jsonSchema2.items);
4839
+ if (jsonSchema2.type === "array" && jsonSchema2.items != null) {
4840
+ if (Array.isArray(jsonSchema2.items)) jsonSchema2.items = jsonSchema2.items.map((item) => addAdditionalPropertiesToJsonSchema(item));
4841
+ else jsonSchema2.items = addAdditionalPropertiesToJsonSchema(jsonSchema2.items);
4842
+ }
5048
4843
  return jsonSchema2;
5049
4844
  }
5050
4845
  var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
@@ -5109,9 +4904,7 @@ function parseBigintDef(def) {
5109
4904
  if (check.inclusive) res.maximum = check.value;
5110
4905
  else res.exclusiveMaximum = check.value;
5111
4906
  break;
5112
- case "multipleOf":
5113
- res.multipleOf = check.value;
5114
- break;
4907
+ case "multipleOf": res.multipleOf = check.value;
5115
4908
  }
5116
4909
  return res;
5117
4910
  }
@@ -5149,9 +4942,7 @@ var integerDateParser = (def) => {
5149
4942
  case "min":
5150
4943
  res.minimum = check.value;
5151
4944
  break;
5152
- case "max":
5153
- res.maximum = check.value;
5154
- break;
4945
+ case "max": res.maximum = check.value;
5155
4946
  }
5156
4947
  return res;
5157
4948
  };
@@ -5275,9 +5066,7 @@ function parseStringDef(def, refs) {
5275
5066
  case "format:idn-email":
5276
5067
  addFormat(res, "idn-email", check.message, refs);
5277
5068
  break;
5278
- case "pattern:zod":
5279
- addPattern(res, zodPatterns.email, check.message, refs);
5280
- break;
5069
+ case "pattern:zod": addPattern(res, zodPatterns.email, check.message, refs);
5281
5070
  }
5282
5071
  break;
5283
5072
  case "url":
@@ -5348,16 +5137,10 @@ function parseStringDef(def, refs) {
5348
5137
  case "contentEncoding:base64":
5349
5138
  res.contentEncoding = "base64";
5350
5139
  break;
5351
- case "pattern:zod":
5352
- addPattern(res, zodPatterns.base64, check.message, refs);
5353
- break;
5140
+ case "pattern:zod": addPattern(res, zodPatterns.base64, check.message, refs);
5354
5141
  }
5355
5142
  break;
5356
5143
  case "nanoid": addPattern(res, zodPatterns.nanoid, check.message, refs);
5357
- case "toLowerCase":
5358
- case "toUpperCase":
5359
- case "trim": break;
5360
- default:
5361
5144
  }
5362
5145
  return res;
5363
5146
  }
@@ -5628,9 +5411,7 @@ function parseNumberDef(def) {
5628
5411
  if (check.inclusive) res.maximum = check.value;
5629
5412
  else res.exclusiveMaximum = check.value;
5630
5413
  break;
5631
- case "multipleOf":
5632
- res.multipleOf = check.value;
5633
- break;
5414
+ case "multipleOf": res.multipleOf = check.value;
5634
5415
  }
5635
5416
  return res;
5636
5417
  }
@@ -6979,7 +6760,6 @@ function fixJson(input) {
6979
6760
  stack.pop();
6980
6761
  stack.push(swapState);
6981
6762
  stack.push("INSIDE_ARRAY_START");
6982
- break;
6983
6763
  }
6984
6764
  }
6985
6765
  function processAfterObjectValue(char, i) {
@@ -6991,7 +6771,6 @@ function fixJson(input) {
6991
6771
  case "}":
6992
6772
  lastValidIndex = i;
6993
6773
  stack.pop();
6994
- break;
6995
6774
  }
6996
6775
  }
6997
6776
  function processAfterArrayValue(char, i) {
@@ -7003,7 +6782,6 @@ function fixJson(input) {
7003
6782
  case "]":
7004
6783
  lastValidIndex = i;
7005
6784
  stack.pop();
7006
- break;
7007
6785
  }
7008
6786
  }
7009
6787
  for (let i = 0; i < input.length; i++) {
@@ -7021,7 +6799,6 @@ function fixJson(input) {
7021
6799
  case "}":
7022
6800
  lastValidIndex = i;
7023
6801
  stack.pop();
7024
- break;
7025
6802
  }
7026
6803
  break;
7027
6804
  case "INSIDE_OBJECT_AFTER_COMMA":
@@ -7029,7 +6806,6 @@ function fixJson(input) {
7029
6806
  case "\"":
7030
6807
  stack.pop();
7031
6808
  stack.push("INSIDE_OBJECT_KEY");
7032
- break;
7033
6809
  }
7034
6810
  break;
7035
6811
  case "INSIDE_OBJECT_KEY":
@@ -7037,7 +6813,6 @@ function fixJson(input) {
7037
6813
  case "\"":
7038
6814
  stack.pop();
7039
6815
  stack.push("INSIDE_OBJECT_AFTER_KEY");
7040
- break;
7041
6816
  }
7042
6817
  break;
7043
6818
  case "INSIDE_OBJECT_AFTER_KEY":
@@ -7045,7 +6820,6 @@ function fixJson(input) {
7045
6820
  case ":":
7046
6821
  stack.pop();
7047
6822
  stack.push("INSIDE_OBJECT_BEFORE_VALUE");
7048
- break;
7049
6823
  }
7050
6824
  break;
7051
6825
  case "INSIDE_OBJECT_BEFORE_VALUE":
@@ -7075,7 +6849,6 @@ function fixJson(input) {
7075
6849
  default:
7076
6850
  lastValidIndex = i;
7077
6851
  processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
7078
- break;
7079
6852
  }
7080
6853
  break;
7081
6854
  case "INSIDE_ARRAY_AFTER_VALUE":
@@ -7088,9 +6861,7 @@ function fixJson(input) {
7088
6861
  lastValidIndex = i;
7089
6862
  stack.pop();
7090
6863
  break;
7091
- default:
7092
- lastValidIndex = i;
7093
- break;
6864
+ default: lastValidIndex = i;
7094
6865
  }
7095
6866
  break;
7096
6867
  case "INSIDE_ARRAY_AFTER_COMMA":
@@ -7131,9 +6902,7 @@ function fixJson(input) {
7131
6902
  stack.pop();
7132
6903
  if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") processAfterArrayValue(char, i);
7133
6904
  break;
7134
- default:
7135
- stack.pop();
7136
- break;
6905
+ default: stack.pop();
7137
6906
  }
7138
6907
  break;
7139
6908
  case "INSIDE_LITERAL": {
@@ -7573,9 +7342,10 @@ const planningIterationStep = createStep({
7573
7342
  requestContext.set(qaKey, storedQAPairs);
7574
7343
  }
7575
7344
  try {
7345
+ const model = await resolveModel({ requestContext });
7576
7346
  const planningAgent = new Agent({
7577
7347
  id: "workflow-planning-agent",
7578
- model: await resolveModel({ requestContext }),
7348
+ model,
7579
7349
  instructions: taskPlanningPrompts.planningAgent.instructions({ storedQAPairs }),
7580
7350
  name: "Workflow Planning Agent"
7581
7351
  });
@@ -8285,9 +8055,10 @@ const workflowResearchStep = createStep({
8285
8055
  execute: async ({ inputData, requestContext }) => {
8286
8056
  console.info("Starting workflow research...");
8287
8057
  try {
8058
+ const model = await resolveModel({ requestContext });
8288
8059
  const researchAgent = new Agent({
8289
8060
  id: "workflow-research-agent",
8290
- model: await resolveModel({ requestContext }),
8061
+ model,
8291
8062
  instructions: workflowBuilderPrompts.researchAgent.instructions,
8292
8063
  name: "Workflow Research Agent"
8293
8064
  });