@wix/ditto-codegen-public 1.0.204 → 1.0.205

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/out.js +293 -382
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -38994,6 +38994,58 @@ var require_sdkConfig = __commonJS({
38994
38994
  }
38995
38995
  });
38996
38996
 
38997
+ // ../codegen-common-logic/dist/generate-text-helpers.js
38998
+ var require_generate_text_helpers = __commonJS({
38999
+ "../codegen-common-logic/dist/generate-text-helpers.js"(exports2) {
39000
+ "use strict";
39001
+ Object.defineProperty(exports2, "__esModule", { value: true });
39002
+ exports2.extractToolResult = extractToolResult;
39003
+ exports2.stopOnToolCall = stopOnToolCall;
39004
+ exports2.stopOnNoToolCalls = stopOnNoToolCalls;
39005
+ exports2.generateAgentText = generateAgentText;
39006
+ var ai_1 = require_dist8();
39007
+ var ditto_codegen_types_12 = require_dist();
39008
+ function extractToolResult(toolCalls, toolName) {
39009
+ const call = toolCalls.find((tc) => tc.toolName === toolName);
39010
+ return call?.input ?? null;
39011
+ }
39012
+ function stopOnToolCall(toolName) {
39013
+ return ({ steps }) => {
39014
+ const lastStep = steps[steps.length - 1];
39015
+ return lastStep?.toolCalls.some((tc) => tc.toolName === toolName && !("invalid" in tc) && !("error" in tc)) ?? false;
39016
+ };
39017
+ }
39018
+ function stopOnNoToolCalls(maxSteps) {
39019
+ return ({ steps }) => {
39020
+ if (steps.length >= maxSteps) {
39021
+ return true;
39022
+ }
39023
+ const lastStep = steps[steps.length - 1];
39024
+ return lastStep?.toolCalls.length === 0;
39025
+ };
39026
+ }
39027
+ async function generateAgentText(options) {
39028
+ return (0, ai_1.generateText)({
39029
+ model: options.model,
39030
+ tools: options.tools,
39031
+ stopWhen: options.stopWhen,
39032
+ messages: [
39033
+ {
39034
+ role: "system",
39035
+ content: options.systemPrompt,
39036
+ // Anthropic-specific: enables prompt caching. Ignored by other providers.
39037
+ providerOptions: (0, ditto_codegen_types_12.withCaching)("1h")
39038
+ },
39039
+ { role: "user", content: options.userMessage }
39040
+ ],
39041
+ maxRetries: 3,
39042
+ temperature: 0,
39043
+ experimental_telemetry: { isEnabled: true, functionId: options.agentName }
39044
+ });
39045
+ }
39046
+ }
39047
+ });
39048
+
38997
39049
  // ../codegen-common-logic/dist/index.js
38998
39050
  var require_dist9 = __commonJS({
38999
39051
  "../codegen-common-logic/dist/index.js"(exports2) {
@@ -39033,6 +39085,7 @@ var require_dist9 = __commonJS({
39033
39085
  __exportStar2(require_commonUseCasesGuide(), exports2);
39034
39086
  __exportStar2(require_system_prompts(), exports2);
39035
39087
  __exportStar2(require_sdkConfig(), exports2);
39088
+ __exportStar2(require_generate_text_helpers(), exports2);
39036
39089
  }
39037
39090
  });
39038
39091
 
@@ -72599,6 +72652,104 @@ var require_prompt_selectors = __commonJS({
72599
72652
  }
72600
72653
  });
72601
72654
 
72655
+ // dist/agents/utils/api.js
72656
+ var require_api2 = __commonJS({
72657
+ "dist/agents/utils/api.js"(exports2) {
72658
+ "use strict";
72659
+ Object.defineProperty(exports2, "__esModule", { value: true });
72660
+ exports2.getApiDocumentation = exports2.extractApis = exports2.extractApiNames = exports2.extractApiDocumentation = void 0;
72661
+ var isExtensionEnriched = (extension) => {
72662
+ return extension.relatedApis?.some((api) => "documentation" in api || "methodSchema" in api) ?? false;
72663
+ };
72664
+ var extractApiDocumentation = (extension) => {
72665
+ if (isExtensionEnriched(extension)) {
72666
+ return { apiDocumentation: (0, exports2.getApiDocumentation)(extension), apiNames: [] };
72667
+ }
72668
+ return { apiDocumentation: "", apiNames: (0, exports2.extractApiNames)(extension) };
72669
+ };
72670
+ exports2.extractApiDocumentation = extractApiDocumentation;
72671
+ var extractApiNames = (extension) => {
72672
+ return extension.relatedApis?.map((api) => api.name).filter((name) => !!name) || [];
72673
+ };
72674
+ exports2.extractApiNames = extractApiNames;
72675
+ var extractApis = (extension) => {
72676
+ return extension.relatedApis?.map((api) => ({
72677
+ name: api.name,
72678
+ purpose: api.purpose,
72679
+ documentation: api.documentation,
72680
+ methodSchema: api.methodSchema
72681
+ })) || [];
72682
+ };
72683
+ exports2.extractApis = extractApis;
72684
+ var getApiDocumentation = (extension) => {
72685
+ const apis = (0, exports2.extractApis)(extension);
72686
+ const docsWithContent = apis.filter((api) => api.documentation || api.methodSchema);
72687
+ if (docsWithContent.length === 0) {
72688
+ return "";
72689
+ }
72690
+ return docsWithContent.map((api) => {
72691
+ const parts = [];
72692
+ parts.push(`<api name="${api.name}">`);
72693
+ if (api.purpose) {
72694
+ parts.push(`<purpose>${api.purpose}</purpose>`);
72695
+ }
72696
+ if (api.documentation) {
72697
+ parts.push(`<documentation>${api.documentation}</documentation>`);
72698
+ }
72699
+ if (api.methodSchema) {
72700
+ parts.push(`<methodSchema>${api.methodSchema}</methodSchema>`);
72701
+ }
72702
+ parts.push(`</api>`);
72703
+ return parts.join("\n");
72704
+ }).join("\n\n");
72705
+ };
72706
+ exports2.getApiDocumentation = getApiDocumentation;
72707
+ }
72708
+ });
72709
+
72710
+ // dist/agents/utils/file-operations.js
72711
+ var require_file_operations = __commonJS({
72712
+ "dist/agents/utils/file-operations.js"(exports2) {
72713
+ "use strict";
72714
+ Object.defineProperty(exports2, "__esModule", { value: true });
72715
+ exports2.FilesSchema = exports2.FileItemSchema = exports2.FileCreateOrUpdateSchema = void 0;
72716
+ var zod_1 = require_zod();
72717
+ var ditto_codegen_types_12 = require_dist();
72718
+ exports2.FileCreateOrUpdateSchema = zod_1.z.object({
72719
+ operation: zod_1.z.union([
72720
+ zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT),
72721
+ zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.UPDATE)
72722
+ ]).describe("File operation: insert (new file), update (modify existing)").default(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT),
72723
+ path: zod_1.z.string().describe("Relative file path from project root"),
72724
+ content: zod_1.z.string().describe("Complete file content as a string (for JSON files, stringify the object). Required for insert and update operations.")
72725
+ });
72726
+ var FileEditSchema = zod_1.z.object({
72727
+ operation: zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.EDIT),
72728
+ path: zod_1.z.string().describe("Relative file path from project root"),
72729
+ replacements: zod_1.z.array(zod_1.z.object({
72730
+ oldString: zod_1.z.string().describe("The text to replace (must match the file contents exactly, including all whitespace and indentation)"),
72731
+ newString: zod_1.z.string().describe("The edited text to replace the oldString"),
72732
+ replaceAll: zod_1.z.boolean().optional().describe("Replace all occurrences of oldString (default false)")
72733
+ })).min(1).describe("List of string replacements to apply")
72734
+ });
72735
+ var FileDeleteSchema = zod_1.z.object({
72736
+ operation: zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.DELETE),
72737
+ path: zod_1.z.string().describe("Relative file path from project root")
72738
+ });
72739
+ exports2.FileItemSchema = zod_1.z.discriminatedUnion("operation", [
72740
+ exports2.FileCreateOrUpdateSchema,
72741
+ FileDeleteSchema,
72742
+ FileEditSchema
72743
+ ]).describe(`Representation of an operation that modifies a file on the local file system.
72744
+ Use the 'insert' operation to create a new file.
72745
+ Use the 'delete' operation to remove a file.
72746
+ To modify a file, you can either use the 'edit' operation to replace a specific strings with new strings (THIS IS THE PREFERRED WAY TO MODIFY A FILE), or use the 'update' operation to replace the entire file with new content.`);
72747
+ exports2.FilesSchema = zod_1.z.object({
72748
+ files: zod_1.z.array(exports2.FileItemSchema).default([]).describe("An array of files")
72749
+ });
72750
+ }
72751
+ });
72752
+
72602
72753
  // dist/agents/utils/file-loading.js
72603
72754
  var require_file_loading = __commonJS({
72604
72755
  "dist/agents/utils/file-loading.js"(exports2) {
@@ -72765,101 +72916,43 @@ ${JSON.stringify(formattedOps, null, 2)}`;
72765
72916
  }
72766
72917
  });
72767
72918
 
72768
- // dist/agents/utils/file-operations.js
72769
- var require_file_operations = __commonJS({
72770
- "dist/agents/utils/file-operations.js"(exports2) {
72771
- "use strict";
72772
- Object.defineProperty(exports2, "__esModule", { value: true });
72773
- exports2.FilesSchema = exports2.FileItemSchema = exports2.FileCreateOrUpdateSchema = void 0;
72774
- var zod_1 = require_zod();
72775
- var ditto_codegen_types_12 = require_dist();
72776
- exports2.FileCreateOrUpdateSchema = zod_1.z.object({
72777
- operation: zod_1.z.union([
72778
- zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT),
72779
- zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.UPDATE)
72780
- ]).describe("File operation: insert (new file), update (modify existing)").default(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT),
72781
- path: zod_1.z.string().describe("Relative file path from project root"),
72782
- content: zod_1.z.string().describe("Complete file content as a string (for JSON files, stringify the object). Required for insert and update operations.")
72783
- });
72784
- var FileEditSchema = zod_1.z.object({
72785
- operation: zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.EDIT),
72786
- path: zod_1.z.string().describe("Relative file path from project root"),
72787
- replacements: zod_1.z.array(zod_1.z.object({
72788
- oldString: zod_1.z.string().describe("The text to replace (must match the file contents exactly, including all whitespace and indentation)"),
72789
- newString: zod_1.z.string().describe("The edited text to replace the oldString"),
72790
- replaceAll: zod_1.z.boolean().optional().describe("Replace all occurrences of oldString (default false)")
72791
- })).min(1).describe("List of string replacements to apply")
72792
- });
72793
- var FileDeleteSchema = zod_1.z.object({
72794
- operation: zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.DELETE),
72795
- path: zod_1.z.string().describe("Relative file path from project root")
72796
- });
72797
- exports2.FileItemSchema = zod_1.z.discriminatedUnion("operation", [
72798
- exports2.FileCreateOrUpdateSchema,
72799
- FileDeleteSchema,
72800
- FileEditSchema
72801
- ]).describe(`Representation of an operation that modifies a file on the local file system.
72802
- Use the 'insert' operation to create a new file.
72803
- Use the 'delete' operation to remove a file.
72804
- To modify a file, you can either use the 'edit' operation to replace a specific strings with new strings (THIS IS THE PREFERRED WAY TO MODIFY A FILE), or use the 'update' operation to replace the entire file with new content.`);
72805
- exports2.FilesSchema = zod_1.z.object({
72806
- files: zod_1.z.array(exports2.FileItemSchema).default([]).describe("An array of files")
72807
- });
72808
- }
72809
- });
72810
-
72811
- // dist/agents/utils/api.js
72812
- var require_api2 = __commonJS({
72813
- "dist/agents/utils/api.js"(exports2) {
72919
+ // dist/agents/BaseCodeGenerationAgent.js
72920
+ var require_BaseCodeGenerationAgent = __commonJS({
72921
+ "dist/agents/BaseCodeGenerationAgent.js"(exports2) {
72814
72922
  "use strict";
72815
72923
  Object.defineProperty(exports2, "__esModule", { value: true });
72816
- exports2.getApiDocumentation = exports2.extractApis = exports2.extractApiNames = exports2.extractApiDocumentation = void 0;
72817
- var isExtensionEnriched = (extension) => {
72818
- return extension.relatedApis?.some((api) => "documentation" in api || "methodSchema" in api) ?? false;
72819
- };
72820
- var extractApiDocumentation = (extension) => {
72821
- if (isExtensionEnriched(extension)) {
72822
- return { apiDocumentation: (0, exports2.getApiDocumentation)(extension), apiNames: [] };
72924
+ exports2.BaseCodeGenerationAgent = void 0;
72925
+ var file_operations_1 = require_file_operations();
72926
+ var userPrompt_1 = require_userPrompt();
72927
+ var codeGenerationService_12 = require_codeGenerationService();
72928
+ var constants_1 = require_constants();
72929
+ var BaseCodeGenerationAgent = class {
72930
+ constructor(useIteration = false) {
72931
+ this.useIteration = useIteration;
72823
72932
  }
72824
- return { apiDocumentation: "", apiNames: (0, exports2.extractApiNames)(extension) };
72825
- };
72826
- exports2.extractApiDocumentation = extractApiDocumentation;
72827
- var extractApiNames = (extension) => {
72828
- return extension.relatedApis?.map((api) => api.name).filter((name) => !!name) || [];
72829
- };
72830
- exports2.extractApiNames = extractApiNames;
72831
- var extractApis = (extension) => {
72832
- return extension.relatedApis?.map((api) => ({
72833
- name: api.name,
72834
- purpose: api.purpose,
72835
- documentation: api.documentation,
72836
- methodSchema: api.methodSchema
72837
- })) || [];
72838
- };
72839
- exports2.extractApis = extractApis;
72840
- var getApiDocumentation = (extension) => {
72841
- const apis = (0, exports2.extractApis)(extension);
72842
- const docsWithContent = apis.filter((api) => api.documentation || api.methodSchema);
72843
- if (docsWithContent.length === 0) {
72844
- return "";
72933
+ getGenerateOptions() {
72934
+ return {
72935
+ schema: file_operations_1.FilesSchema,
72936
+ extractResult: (obj) => obj.files
72937
+ };
72938
+ }
72939
+ async generate(params) {
72940
+ const systemPrompt = await this.buildSystemPrompt(params);
72941
+ const primaryAction = this.getPrimaryAction(params);
72942
+ const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
72943
+ const { schema, model, extractResult } = this.getGenerateOptions();
72944
+ const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
72945
+ userMessage,
72946
+ systemPrompt,
72947
+ provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
72948
+ model: model ?? constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929,
72949
+ schema,
72950
+ agentName: this.name
72951
+ });
72952
+ return extractResult(result.object);
72845
72953
  }
72846
- return docsWithContent.map((api) => {
72847
- const parts = [];
72848
- parts.push(`<api name="${api.name}">`);
72849
- if (api.purpose) {
72850
- parts.push(`<purpose>${api.purpose}</purpose>`);
72851
- }
72852
- if (api.documentation) {
72853
- parts.push(`<documentation>${api.documentation}</documentation>`);
72854
- }
72855
- if (api.methodSchema) {
72856
- parts.push(`<methodSchema>${api.methodSchema}</methodSchema>`);
72857
- }
72858
- parts.push(`</api>`);
72859
- return parts.join("\n");
72860
- }).join("\n\n");
72861
72954
  };
72862
- exports2.getApiDocumentation = getApiDocumentation;
72955
+ exports2.BaseCodeGenerationAgent = BaseCodeGenerationAgent;
72863
72956
  }
72864
72957
  });
72865
72958
 
@@ -72877,33 +72970,19 @@ var require_DashboardPageAgent2 = __commonJS({
72877
72970
  var dashboard_page_prompt_1 = require_dashboard_page_prompt();
72878
72971
  var prompt_selectors_1 = require_prompt_selectors();
72879
72972
  var codegen_common_logic_1 = require_dist9();
72880
- var userPrompt_1 = require_userPrompt();
72881
- var file_operations_1 = require_file_operations();
72882
72973
  var codeGenerationService_12 = require_codeGenerationService();
72883
72974
  var constants_1 = require_constants();
72884
72975
  var codegen_dashboard_agents_1 = require_dist11();
72885
72976
  var api_1 = require_api2();
72886
- var DashboardPageAgent = class {
72887
- constructor(useIteration = false) {
72888
- this.useIteration = useIteration;
72977
+ var BaseCodeGenerationAgent_1 = require_BaseCodeGenerationAgent();
72978
+ var DashboardPageAgent = class extends BaseCodeGenerationAgent_1.BaseCodeGenerationAgent {
72979
+ constructor() {
72980
+ super(...arguments);
72889
72981
  this.name = "DashboardPageAgent";
72890
72982
  }
72891
72983
  getAgentDocumentation() {
72892
72984
  return (0, codegen_common_logic_1.getDashboardPageAgentDocumentation)();
72893
72985
  }
72894
- async buildSystemPrompt({ useData, useAutoPatterns, useApiSpec, useDynamicParameters, apiNames, apiDocumentation, autoPatternsSectionIds }) {
72895
- const systemPrompt = await (0, dashboard_page_prompt_1.dashboardPagePrompt)({
72896
- useData,
72897
- useAutoPatterns,
72898
- useApiSpec,
72899
- useDynamicParameters,
72900
- apiNames,
72901
- apiDocumentation,
72902
- useIteration: this.useIteration,
72903
- autoPatternsSectionIds
72904
- });
72905
- return systemPrompt;
72906
- }
72907
72986
  async getAutoPatternsSectionIds(useAutoPatterns, userRequestSummary) {
72908
72987
  if (!useAutoPatterns || !this.useIteration || !userRequestSummary) {
72909
72988
  return void 0;
@@ -72917,7 +72996,7 @@ var require_DashboardPageAgent2 = __commonJS({
72917
72996
  const result = await autoPatternsDocSelector.generate(userRequestSummary);
72918
72997
  return result.selectedSectionIds;
72919
72998
  }
72920
- // temporary fix to add all files in the auto patterns directory as relevant files
72999
+ // Temporary fix to add all files in the auto patterns directory as relevant files
72921
73000
  addAutoPatternsRelevantFiles(params) {
72922
73001
  const relevantFilePaths = params.relevantFilePaths ?? [];
72923
73002
  const patternsJsonPath = relevantFilePaths.find((p) => p.endsWith("patterns.json"));
@@ -72935,8 +73014,8 @@ var require_DashboardPageAgent2 = __commonJS({
72935
73014
  }
72936
73015
  }
72937
73016
  }
72938
- async generate(params) {
72939
- const { blueprint, plan, userRequestSummary } = params;
73017
+ async buildSystemPrompt(params) {
73018
+ const { plan, userRequestSummary } = params;
72940
73019
  const useData = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
72941
73020
  const useAutoPatterns = (0, prompt_selectors_1.shouldUseAutoPatterns)(params);
72942
73021
  const useApiSpec = Boolean(plan?.apiSpec);
@@ -72946,27 +73025,20 @@ var require_DashboardPageAgent2 = __commonJS({
72946
73025
  this.addAutoPatternsRelevantFiles(params);
72947
73026
  }
72948
73027
  const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
72949
- const systemPrompt = await this.buildSystemPrompt({
73028
+ return (0, dashboard_page_prompt_1.dashboardPagePrompt)({
72950
73029
  useData,
72951
73030
  useAutoPatterns,
72952
73031
  useApiSpec,
72953
73032
  useDynamicParameters,
72954
73033
  apiNames,
72955
73034
  apiDocumentation,
73035
+ useIteration: this.useIteration,
72956
73036
  autoPatternsSectionIds
72957
73037
  });
72958
- const appName = blueprint?.appName ? `'${blueprint.appName}'` : "";
72959
- const primaryAction = `Customize the Wix CLI dashboard page scaffolding for the app ${appName}`;
72960
- const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
72961
- const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
72962
- userMessage,
72963
- systemPrompt,
72964
- provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
72965
- model: constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929,
72966
- schema: file_operations_1.FilesSchema,
72967
- agentName: this.name
72968
- });
72969
- return result.object.files;
73038
+ }
73039
+ getPrimaryAction(params) {
73040
+ const appName = params.blueprint?.appName ? `'${params.blueprint.appName}'` : "";
73041
+ return `Customize the Wix CLI dashboard page scaffolding for the app ${appName}`;
72970
73042
  }
72971
73043
  };
72972
73044
  exports2.DashboardPageAgent = DashboardPageAgent;
@@ -73043,19 +73115,18 @@ var require_SiteComponentAgent2 = __commonJS({
73043
73115
  var api_1 = require_api2();
73044
73116
  var site_component_prompt_1 = require_site_component_prompt();
73045
73117
  var codegen_common_logic_1 = require_dist9();
73046
- var userPrompt_1 = require_userPrompt();
73047
- var file_operations_1 = require_file_operations();
73048
- var constants_1 = require_constants();
73049
- var codeGenerationService_12 = require_codeGenerationService();
73050
- var SiteComponentAgent = class {
73051
- constructor(useIteration = false) {
73052
- this.useIteration = useIteration;
73118
+ var BaseCodeGenerationAgent_1 = require_BaseCodeGenerationAgent();
73119
+ var SiteComponentAgent = class extends BaseCodeGenerationAgent_1.BaseCodeGenerationAgent {
73120
+ constructor() {
73121
+ super(...arguments);
73053
73122
  this.name = "SiteComponentAgent";
73054
73123
  }
73055
73124
  getAgentDocumentation() {
73056
73125
  return (0, codegen_common_logic_1.getSiteComponentAgentDocumentation)();
73057
73126
  }
73058
- buildSystemPrompt({ apiNames, apiDocumentation, useData }) {
73127
+ buildSystemPrompt(params) {
73128
+ const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73129
+ const useData = Boolean(params.plan?.collections?.length);
73059
73130
  return (0, site_component_prompt_1.siteComponentPrompt)({
73060
73131
  apiNames,
73061
73132
  useData,
@@ -73063,27 +73134,9 @@ var require_SiteComponentAgent2 = __commonJS({
73063
73134
  apiDocumentation
73064
73135
  });
73065
73136
  }
73066
- async generate(params) {
73067
- const { blueprint, plan } = params;
73068
- const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73069
- const useData = Boolean(plan?.collections?.length);
73070
- const systemPrompt = this.buildSystemPrompt({
73071
- apiNames,
73072
- apiDocumentation,
73073
- useData
73074
- });
73075
- const appName = blueprint?.appName ? `'${blueprint.appName}'` : "";
73076
- const primaryAction = `Customize the Wix CLI site component scaffolding for the app ${appName}`;
73077
- const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
73078
- const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
73079
- userMessage,
73080
- systemPrompt,
73081
- provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
73082
- model: constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929,
73083
- schema: file_operations_1.FilesSchema,
73084
- agentName: this.name
73085
- });
73086
- return result.object.files;
73137
+ getPrimaryAction(params) {
73138
+ const appName = params.blueprint?.appName ? `'${params.blueprint.appName}'` : "";
73139
+ return `Customize the Wix CLI site component scaffolding for the app ${appName}`;
73087
73140
  }
73088
73141
  };
73089
73142
  exports2.SiteComponentAgent = SiteComponentAgent;
@@ -73206,19 +73259,18 @@ var require_CustomElementAgent2 = __commonJS({
73206
73259
  var api_1 = require_api2();
73207
73260
  var custom_element_prompt_1 = require_custom_element_prompt();
73208
73261
  var codegen_common_logic_1 = require_dist9();
73209
- var userPrompt_1 = require_userPrompt();
73210
- var codeGenerationService_12 = require_codeGenerationService();
73211
- var file_operations_1 = require_file_operations();
73212
- var constants_1 = require_constants();
73213
- var CustomElementAgent = class {
73214
- constructor(useIteration = false) {
73215
- this.useIteration = useIteration;
73262
+ var BaseCodeGenerationAgent_1 = require_BaseCodeGenerationAgent();
73263
+ var CustomElementAgent = class extends BaseCodeGenerationAgent_1.BaseCodeGenerationAgent {
73264
+ constructor() {
73265
+ super(...arguments);
73216
73266
  this.name = "CustomElementAgent";
73217
73267
  }
73218
73268
  getAgentDocumentation() {
73219
73269
  return (0, codegen_common_logic_1.getCustomElementAgentDocumentation)();
73220
73270
  }
73221
- buildSystemPrompt({ apiNames, apiDocumentation, useData }) {
73271
+ buildSystemPrompt(params) {
73272
+ const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73273
+ const useData = Boolean(params.plan?.collections?.length);
73222
73274
  return (0, custom_element_prompt_1.customElementPrompt)({
73223
73275
  apiNames,
73224
73276
  useData,
@@ -73226,27 +73278,9 @@ var require_CustomElementAgent2 = __commonJS({
73226
73278
  apiDocumentation
73227
73279
  });
73228
73280
  }
73229
- async generate(params) {
73230
- const { blueprint, plan } = params;
73231
- const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73232
- const useData = Boolean(plan?.collections?.length);
73233
- const systemPrompt = this.buildSystemPrompt({
73234
- apiNames,
73235
- apiDocumentation,
73236
- useData
73237
- });
73238
- const appName = blueprint?.appName ? `'${blueprint.appName}'` : "";
73239
- const primaryAction = `Customize the Wix CLI custom element / site widget scaffolding for the app ${appName}`;
73240
- const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
73241
- const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
73242
- userMessage,
73243
- systemPrompt,
73244
- provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
73245
- model: constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929,
73246
- schema: file_operations_1.FilesSchema,
73247
- agentName: this.name
73248
- });
73249
- return result?.object.files;
73281
+ getPrimaryAction(params) {
73282
+ const appName = params.blueprint?.appName ? `'${params.blueprint.appName}'` : "";
73283
+ return `Customize the Wix CLI custom element / site widget scaffolding for the app ${appName}`;
73250
73284
  }
73251
73285
  };
73252
73286
  exports2.CustomElementAgent = CustomElementAgent;
@@ -73450,51 +73484,31 @@ var require_SPIAgent2 = __commonJS({
73450
73484
  var api_1 = require_api2();
73451
73485
  var prompt_selectors_1 = require_prompt_selectors();
73452
73486
  var codegen_common_logic_1 = require_dist9();
73453
- var userPrompt_1 = require_userPrompt();
73454
- var file_operations_1 = require_file_operations();
73455
- var constants_1 = require_constants();
73456
- var codeGenerationService_12 = require_codeGenerationService();
73457
- var SPIAgent = class {
73458
- constructor(useIteration = false) {
73459
- this.useIteration = useIteration;
73487
+ var BaseCodeGenerationAgent_1 = require_BaseCodeGenerationAgent();
73488
+ var SPIAgent = class extends BaseCodeGenerationAgent_1.BaseCodeGenerationAgent {
73489
+ constructor() {
73490
+ super(...arguments);
73460
73491
  this.name = "SPIAgent";
73461
73492
  }
73462
73493
  getAgentDocumentation() {
73463
73494
  return (0, codegen_common_logic_1.getSPIAgentDocumentation)();
73464
73495
  }
73465
- buildSystemPrompt({ apiNames, apiDocumentation, useData, spiNames }) {
73466
- const systemPrompt = (0, service_plugin_prompt_1.servicePluginPrompt)({
73496
+ buildSystemPrompt(params) {
73497
+ const { extension } = params;
73498
+ const spiNames = extension.relatedSpis?.map((spi) => spi.name).filter((name) => !!name) || [];
73499
+ const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73500
+ const useData = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
73501
+ return (0, service_plugin_prompt_1.servicePluginPrompt)({
73467
73502
  apiNames,
73468
73503
  apiDocumentation,
73469
73504
  useData,
73470
73505
  useIteration: this.useIteration,
73471
73506
  spiNames
73472
73507
  });
73473
- return systemPrompt;
73474
73508
  }
73475
- async generate(params) {
73476
- const { extension, blueprint } = params;
73477
- const allSpiNames = extension.relatedSpis?.map((spi) => spi.name).filter((name) => !!name) || [];
73478
- const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73479
- const useData = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
73480
- const systemPrompt = this.buildSystemPrompt({
73481
- apiNames,
73482
- apiDocumentation,
73483
- useData,
73484
- spiNames: allSpiNames
73485
- });
73486
- const appName = blueprint?.appName ? `'${blueprint.appName}'` : "";
73487
- const primaryAction = `Customize the Wix CLI service plugin scaffolding for the app ${appName}`;
73488
- const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
73489
- const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
73490
- userMessage,
73491
- systemPrompt,
73492
- provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
73493
- model: constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929,
73494
- schema: file_operations_1.FilesSchema,
73495
- agentName: this.name
73496
- });
73497
- return result.object.files;
73509
+ getPrimaryAction(params) {
73510
+ const appName = params.blueprint?.appName ? `'${params.blueprint.appName}'` : "";
73511
+ return `Customize the Wix CLI service plugin scaffolding for the app ${appName}`;
73498
73512
  }
73499
73513
  };
73500
73514
  exports2.SPIAgent = SPIAgent;
@@ -73573,19 +73587,18 @@ var require_BackendEventAgent2 = __commonJS({
73573
73587
  var api_1 = require_api2();
73574
73588
  var backend_event_prompt_1 = require_backend_event_prompt();
73575
73589
  var codegen_common_logic_1 = require_dist9();
73576
- var userPrompt_1 = require_userPrompt();
73577
- var file_operations_1 = require_file_operations();
73578
- var constants_1 = require_constants();
73579
- var codeGenerationService_12 = require_codeGenerationService();
73580
- var BackendEventAgent = class {
73581
- constructor(useIteration = false) {
73582
- this.useIteration = useIteration;
73590
+ var BaseCodeGenerationAgent_1 = require_BaseCodeGenerationAgent();
73591
+ var BackendEventAgent = class extends BaseCodeGenerationAgent_1.BaseCodeGenerationAgent {
73592
+ constructor() {
73593
+ super(...arguments);
73583
73594
  this.name = "BackendEventAgent";
73584
73595
  }
73585
73596
  getAgentDocumentation() {
73586
73597
  return (0, codegen_common_logic_1.getBackendEventAgentDocumentation)();
73587
73598
  }
73588
- buildSystemPrompt({ apiNames, apiDocumentation, useData }) {
73599
+ buildSystemPrompt(params) {
73600
+ const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73601
+ const useData = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
73589
73602
  return (0, backend_event_prompt_1.backendEventPrompt)({
73590
73603
  apiNames,
73591
73604
  useData,
@@ -73593,27 +73606,9 @@ var require_BackendEventAgent2 = __commonJS({
73593
73606
  apiDocumentation
73594
73607
  });
73595
73608
  }
73596
- async generate(params) {
73597
- const { blueprint } = params;
73598
- const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73599
- const useData = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
73600
- const systemPrompt = this.buildSystemPrompt({
73601
- apiNames,
73602
- apiDocumentation,
73603
- useData
73604
- });
73605
- const appName = blueprint?.appName ? `'${blueprint.appName}'` : "";
73606
- const primaryAction = `Customize backend event scaffolding for the app ${appName}`;
73607
- const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
73608
- const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
73609
- userMessage,
73610
- systemPrompt,
73611
- provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
73612
- model: constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929,
73613
- schema: file_operations_1.FilesSchema,
73614
- agentName: this.name
73615
- });
73616
- return result.object.files;
73609
+ getPrimaryAction(params) {
73610
+ const appName = params.blueprint?.appName ? `'${params.blueprint.appName}'` : "";
73611
+ return `Customize backend event scaffolding for the app ${appName}`;
73617
73612
  }
73618
73613
  };
73619
73614
  exports2.BackendEventAgent = BackendEventAgent;
@@ -73738,21 +73733,20 @@ var require_BackendApiAgent2 = __commonJS({
73738
73733
  exports2.BackendApiAgent = void 0;
73739
73734
  var backend_api_prompt_1 = require_backend_api_prompt();
73740
73735
  var codegen_common_logic_1 = require_dist9();
73741
- var userPrompt_1 = require_userPrompt();
73742
- var file_operations_1 = require_file_operations();
73743
- var constants_1 = require_constants();
73744
73736
  var api_1 = require_api2();
73745
73737
  var prompt_selectors_1 = require_prompt_selectors();
73746
- var codeGenerationService_12 = require_codeGenerationService();
73747
- var BackendApiAgent = class {
73748
- constructor(useIteration = false) {
73749
- this.useIteration = useIteration;
73738
+ var BaseCodeGenerationAgent_1 = require_BaseCodeGenerationAgent();
73739
+ var BackendApiAgent = class extends BaseCodeGenerationAgent_1.BaseCodeGenerationAgent {
73740
+ constructor() {
73741
+ super(...arguments);
73750
73742
  this.name = "BackendApiAgent";
73751
73743
  }
73752
73744
  getAgentDocumentation() {
73753
73745
  return (0, codegen_common_logic_1.getBackendApiAgentDocumentation)();
73754
73746
  }
73755
- buildSystemPrompt({ apiNames, apiDocumentation, useData }) {
73747
+ buildSystemPrompt(params) {
73748
+ const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73749
+ const useData = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
73756
73750
  return (0, backend_api_prompt_1.backendApiPrompt)({
73757
73751
  apiNames,
73758
73752
  useData,
@@ -73760,26 +73754,8 @@ var require_BackendApiAgent2 = __commonJS({
73760
73754
  apiDocumentation
73761
73755
  });
73762
73756
  }
73763
- async generate(params) {
73764
- const { blueprint } = params;
73765
- const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
73766
- const useData = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
73767
- const systemPrompt = this.buildSystemPrompt({
73768
- apiNames,
73769
- apiDocumentation,
73770
- useData
73771
- });
73772
- const primaryAction = `Create Astro Server Endpoints for the app ${blueprint?.appName}`;
73773
- const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
73774
- const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
73775
- userMessage,
73776
- systemPrompt,
73777
- provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
73778
- model: constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929,
73779
- schema: file_operations_1.FilesSchema,
73780
- agentName: this.name
73781
- });
73782
- return result.object.files;
73757
+ getPrimaryAction(params) {
73758
+ return `Create Astro Server Endpoints for the app ${params.blueprint?.appName}`;
73783
73759
  }
73784
73760
  };
73785
73761
  exports2.BackendApiAgent = BackendApiAgent;
@@ -74028,10 +74004,8 @@ var require_EmbeddedScriptAgent2 = __commonJS({
74028
74004
  var zod_1 = __importDefault2(require_zod());
74029
74005
  var embedded_script_prompt_1 = require_embedded_script_prompt();
74030
74006
  var codegen_common_logic_1 = require_dist9();
74031
- var userPrompt_1 = require_userPrompt();
74032
74007
  var file_operations_1 = require_file_operations();
74033
- var constants_1 = require_constants();
74034
- var codeGenerationService_12 = require_codeGenerationService();
74008
+ var BaseCodeGenerationAgent_1 = require_BaseCodeGenerationAgent();
74035
74009
  var EmbeddedScriptPlacement;
74036
74010
  (function(EmbeddedScriptPlacement2) {
74037
74011
  EmbeddedScriptPlacement2["HEAD"] = "HEAD";
@@ -74050,15 +74024,18 @@ var require_EmbeddedScriptAgent2 = __commonJS({
74050
74024
  scriptType: zod_1.default.enum(Object.values(EmbeddedScriptType)),
74051
74025
  placement: zod_1.default.enum(Object.values(EmbeddedScriptPlacement))
74052
74026
  });
74053
- var EmbeddedScriptAgent = class {
74054
- constructor(useIteration = false) {
74055
- this.useIteration = useIteration;
74027
+ var EmbeddedScriptAgent = class extends BaseCodeGenerationAgent_1.BaseCodeGenerationAgent {
74028
+ constructor() {
74029
+ super(...arguments);
74056
74030
  this.name = "EmbeddedScriptAgent";
74057
74031
  }
74058
74032
  getAgentDocumentation() {
74059
74033
  return (0, codegen_common_logic_1.getEmbeddedScriptAgentDocumentation)();
74060
74034
  }
74061
- buildSystemPrompt({ hasDynamicParameters, apiNames, apiDocumentation, useData }) {
74035
+ buildSystemPrompt(params) {
74036
+ const hasDynamicParameters = (0, prompt_selectors_1.shouldUseDynamicParametersPrompt)(params);
74037
+ const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
74038
+ const useData = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
74062
74039
  return (0, embedded_script_prompt_1.embeddedScriptPrompt)({
74063
74040
  hasDynamicParameters,
74064
74041
  apiNames,
@@ -74067,32 +74044,21 @@ var require_EmbeddedScriptAgent2 = __commonJS({
74067
74044
  apiDocumentation
74068
74045
  });
74069
74046
  }
74070
- async generate(params) {
74071
- const { blueprint } = params;
74072
- const hasDynamicParameters = (0, prompt_selectors_1.shouldUseDynamicParametersPrompt)(params);
74073
- const { apiDocumentation, apiNames } = (0, api_1.extractApiDocumentation)(params.extension);
74074
- const useData = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
74075
- const systemPrompt = this.buildSystemPrompt({
74076
- hasDynamicParameters,
74077
- apiNames,
74078
- apiDocumentation,
74079
- useData
74080
- });
74081
- const appName = blueprint?.appName ? `'${blueprint.appName}'` : "";
74082
- const primaryAction = `Customize the Wix CLI embedded script scaffolding for the app ${appName}`;
74083
- const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
74084
- const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
74085
- userMessage,
74086
- systemPrompt,
74087
- provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
74088
- model: constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929,
74089
- schema: EmbeddedScriptSchema,
74090
- agentName: this.name
74091
- });
74047
+ getPrimaryAction(params) {
74048
+ const appName = params.blueprint?.appName ? `'${params.blueprint.appName}'` : "";
74049
+ return `Customize the Wix CLI embedded script scaffolding for the app ${appName}`;
74050
+ }
74051
+ getGenerateOptions() {
74092
74052
  return {
74093
- files: result.object.files,
74094
- scriptType: result.object.scriptType,
74095
- placement: result.object.placement
74053
+ schema: EmbeddedScriptSchema,
74054
+ extractResult: (obj) => {
74055
+ const result = obj;
74056
+ return {
74057
+ files: result.files,
74058
+ scriptType: result.scriptType,
74059
+ placement: result.placement
74060
+ };
74061
+ }
74096
74062
  };
74097
74063
  }
74098
74064
  };
@@ -82208,9 +82174,9 @@ var require_IterationAgent = __commonJS({
82208
82174
  "use strict";
82209
82175
  Object.defineProperty(exports2, "__esModule", { value: true });
82210
82176
  exports2.IterationAgent = void 0;
82211
- var ai_1 = require_dist8();
82212
82177
  var iteration_agent_prompt_1 = require_iteration_agent_prompt();
82213
82178
  var AgentsRegistry_1 = require_AgentsRegistry();
82179
+ var codegen_common_logic_1 = require_dist9();
82214
82180
  var ditto_codegen_types_12 = require_dist();
82215
82181
  var constants_1 = require_constants();
82216
82182
  var contextBuilders_1 = require_contextBuilders();
@@ -82224,13 +82190,6 @@ var require_IterationAgent = __commonJS({
82224
82190
  buildSystemPrompt() {
82225
82191
  return (0, iteration_agent_prompt_1.iterationAgentPrompt)();
82226
82192
  }
82227
- extractPlanResult(toolCalls) {
82228
- const submitCall = toolCalls.find((call) => call.toolName === SUBMIT_PLAN_TOOL_NAME);
82229
- if (!submitCall) {
82230
- throw new Error("Failed to generate iteration plan");
82231
- }
82232
- return submitCall.input;
82233
- }
82234
82193
  mapExtensionType(extensionType) {
82235
82194
  const supportedExtensionTypes = (0, AgentsRegistry_1.getSupportedExtensionTypes)();
82236
82195
  if (supportedExtensionTypes.includes(extensionType)) {
@@ -82268,7 +82227,8 @@ var require_IterationAgent = __commonJS({
82268
82227
  const model = (0, customAnthropicProvider_1.createCustomTextModel)()(constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929, {
82269
82228
  agentName: this.name
82270
82229
  });
82271
- const result = await (0, ai_1.generateText)({
82230
+ const result = await (0, codegen_common_logic_1.generateAgentText)({
82231
+ agentName: this.name,
82272
82232
  model,
82273
82233
  tools: {
82274
82234
  [tools_1.TOOL_NAMES.READ_FILE]: (0, tools_1.createReadFileTool)(outputPath),
@@ -82276,23 +82236,14 @@ var require_IterationAgent = __commonJS({
82276
82236
  [tools_1.TOOL_NAMES.GLOB]: (0, tools_1.createGlobTool)(outputPath),
82277
82237
  [SUBMIT_PLAN_TOOL_NAME]: (0, tools_1.createSubmitPlanTool)()
82278
82238
  },
82279
- stopWhen: ({ steps }) => {
82280
- const lastStep = steps[steps.length - 1];
82281
- return lastStep?.toolCalls.some((toolCall) => toolCall.toolName === SUBMIT_PLAN_TOOL_NAME && !("invalid" in toolCall) && !("error" in toolCall)) ?? false;
82282
- },
82283
- messages: [
82284
- {
82285
- role: "system",
82286
- content: this.buildSystemPrompt(),
82287
- providerOptions: (0, ditto_codegen_types_12.withCaching)("1h")
82288
- },
82289
- { role: "user", content: userMessage }
82290
- ],
82291
- maxRetries: 3,
82292
- temperature: 0,
82293
- experimental_telemetry: { isEnabled: true, functionId: this.name }
82239
+ systemPrompt: this.buildSystemPrompt(),
82240
+ userMessage,
82241
+ stopWhen: (0, codegen_common_logic_1.stopOnToolCall)(SUBMIT_PLAN_TOOL_NAME)
82294
82242
  });
82295
- const planResult = this.extractPlanResult(result.toolCalls);
82243
+ const planResult = (0, codegen_common_logic_1.extractToolResult)(result.toolCalls, SUBMIT_PLAN_TOOL_NAME);
82244
+ if (!planResult) {
82245
+ throw new Error("Failed to generate iteration plan");
82246
+ }
82296
82247
  console.log("IterationAgent planResult:", JSON.stringify(planResult, null, 2));
82297
82248
  const resultObject = {
82298
82249
  currentExtensions: planResult.currentExtensions.map((ext) => ({
@@ -97697,7 +97648,7 @@ var require_SDKPickerAgent = __commonJS({
97697
97648
  Object.defineProperty(exports2, "__esModule", { value: true });
97698
97649
  exports2.SDKPickerAgent = void 0;
97699
97650
  var ditto_codegen_types_12 = require_dist();
97700
- var ai_1 = require_dist8();
97651
+ var codegen_common_logic_1 = require_dist9();
97701
97652
  var WixMCPClient_1 = require_WixMCPClient();
97702
97653
  var tools_1 = require_tools3();
97703
97654
  var sdkEnricher_1 = require_sdkEnricher();
@@ -97708,21 +97659,6 @@ var require_SDKPickerAgent = __commonJS({
97708
97659
  this.mcpClient = new WixMCPClient_1.WixMCPClient();
97709
97660
  this.model = model;
97710
97661
  }
97711
- createStopCondition() {
97712
- return ({ steps }) => {
97713
- const lastStep = steps[steps.length - 1];
97714
- const hasSuccessfulSubmit = lastStep?.toolCalls.some((toolCall) => toolCall.toolName === tools_1.SDK_PICKER_TOOL_NAMES.SUBMIT_PLAN && !("invalid" in toolCall) && !("error" in toolCall)) ?? false;
97715
- return hasSuccessfulSubmit;
97716
- };
97717
- }
97718
- extractSDKPickerResult({ toolCalls }) {
97719
- const submitCall = toolCalls.find((call) => call.toolName === tools_1.SDK_PICKER_TOOL_NAMES.SUBMIT_PLAN);
97720
- if (!submitCall) {
97721
- console.error("No submit_plan tool call found");
97722
- return null;
97723
- }
97724
- return submitCall.input;
97725
- }
97726
97662
  async generate({ validIds, extensionDocumentation, userPrompt }) {
97727
97663
  if (validIds.length === 0) {
97728
97664
  return { extensions: [] };
@@ -97733,26 +97669,15 @@ var require_SDKPickerAgent = __commonJS({
97733
97669
  mcpClient: this.mcpClient,
97734
97670
  validIds
97735
97671
  });
97736
- const systemPrompt = (0, sdk_picker_agent_prompt_1.sdkPickerAgentPrompt)(extensionDocumentation);
97737
- const result = await (0, ai_1.generateText)({
97672
+ const result = await (0, codegen_common_logic_1.generateAgentText)({
97673
+ agentName: this.name,
97738
97674
  model: this.model,
97739
97675
  tools,
97740
- stopWhen: this.createStopCondition(),
97741
- messages: [
97742
- {
97743
- role: "system",
97744
- content: systemPrompt,
97745
- providerOptions: (0, ditto_codegen_types_12.withCaching)("1h")
97746
- },
97747
- { role: "user", content: userPrompt }
97748
- ],
97749
- maxRetries: 3,
97750
- temperature: 0,
97751
- experimental_telemetry: { isEnabled: true, functionId: this.name }
97752
- });
97753
- const apiResult = this.extractSDKPickerResult({
97754
- toolCalls: result.toolCalls
97676
+ systemPrompt: (0, sdk_picker_agent_prompt_1.sdkPickerAgentPrompt)(extensionDocumentation),
97677
+ userMessage: userPrompt,
97678
+ stopWhen: (0, codegen_common_logic_1.stopOnToolCall)(tools_1.SDK_PICKER_TOOL_NAMES.SUBMIT_PLAN)
97755
97679
  });
97680
+ const apiResult = (0, codegen_common_logic_1.extractToolResult)(result.toolCalls, tools_1.SDK_PICKER_TOOL_NAMES.SUBMIT_PLAN);
97756
97681
  if (!apiResult) {
97757
97682
  throw new Error("Failed to extract SDK picker result from tool calls");
97758
97683
  }
@@ -98133,8 +98058,8 @@ var require_ExtensionIndexerAgent = __commonJS({
98133
98058
  };
98134
98059
  Object.defineProperty(exports2, "__esModule", { value: true });
98135
98060
  exports2.ExtensionIndexerAgent = void 0;
98136
- var ai_1 = require_dist8();
98137
98061
  var ditto_codegen_types_12 = require_dist();
98062
+ var codegen_common_logic_1 = require_dist9();
98138
98063
  var constants_1 = require_constants();
98139
98064
  var customAnthropicProvider_1 = require_customAnthropicProvider();
98140
98065
  var tools_1 = require_tools();
@@ -98175,7 +98100,8 @@ ${srcFolderStructure}
98175
98100
  const model = (0, customAnthropicProvider_1.createCustomTextModel)()(constants_1.LLM_MODELS.CLAUDE_HAIKU_4_5, {
98176
98101
  agentName: this.name
98177
98102
  });
98178
- await (0, ai_1.generateText)({
98103
+ await (0, codegen_common_logic_1.generateAgentText)({
98104
+ agentName: this.name,
98179
98105
  model,
98180
98106
  tools: {
98181
98107
  [tools_1.TOOL_NAMES.READ_FILE]: (0, tools_1.createReadFileTool)(outputPath),
@@ -98184,24 +98110,9 @@ ${srcFolderStructure}
98184
98110
  [tools_1.TOOL_NAMES.GREP]: (0, tools_1.createGrepTool)(outputPath),
98185
98111
  [tools_1.TOOL_NAMES.GLOB]: (0, tools_1.createGlobTool)(outputPath)
98186
98112
  },
98187
- stopWhen: ({ steps }) => {
98188
- if (steps.length >= MAX_STEPS) {
98189
- return true;
98190
- }
98191
- const lastStep = steps[steps.length - 1];
98192
- return lastStep?.toolCalls.length === 0;
98193
- },
98194
- messages: [
98195
- {
98196
- role: "system",
98197
- content: systemPrompt,
98198
- providerOptions: (0, ditto_codegen_types_12.withCaching)("1h")
98199
- },
98200
- { role: "user", content: userMessage }
98201
- ],
98202
- maxRetries: 3,
98203
- temperature: 0,
98204
- experimental_telemetry: { isEnabled: true, functionId: this.name }
98113
+ systemPrompt,
98114
+ userMessage,
98115
+ stopWhen: (0, codegen_common_logic_1.stopOnNoToolCalls)(MAX_STEPS)
98205
98116
  });
98206
98117
  } catch (error) {
98207
98118
  throw (0, ditto_codegen_types_12.toCodegenError)(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.204",
3
+ "version": "1.0.205",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -24,5 +24,5 @@
24
24
  "@wix/ditto-codegen": "1.0.0",
25
25
  "esbuild": "^0.27.2"
26
26
  },
27
- "falconPackageHash": "b38838efbcff60c6aa56eabbec8126a86f885bfd2bbc736a6e526ec2"
27
+ "falconPackageHash": "30c73c66aeeddb26c76b80c1f980e0ffe8c2698f2958772df94da841"
28
28
  }