@wix/ditto-codegen-public 1.0.61 → 1.0.62
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/out.js +122 -65
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -137963,6 +137963,49 @@ var require_file_collector = __commonJS({
|
|
|
137963
137963
|
}
|
|
137964
137964
|
});
|
|
137965
137965
|
|
|
137966
|
+
// dist/orchestrator-error-helpers.js
|
|
137967
|
+
var require_orchestrator_error_helpers = __commonJS({
|
|
137968
|
+
"dist/orchestrator-error-helpers.js"(exports2) {
|
|
137969
|
+
"use strict";
|
|
137970
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
137971
|
+
exports2.createExtensionErrorHandler = createExtensionErrorHandler;
|
|
137972
|
+
exports2.throwIfFailures = throwIfFailures;
|
|
137973
|
+
function createExtensionErrorHandler(orchestrator, extension) {
|
|
137974
|
+
return (error) => {
|
|
137975
|
+
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
137976
|
+
orchestrator.emitEvent("agent:error", {
|
|
137977
|
+
extension,
|
|
137978
|
+
error: errorObj
|
|
137979
|
+
});
|
|
137980
|
+
console.error(`\u274C Failed to process extension ${extension.name}:`, error);
|
|
137981
|
+
throw error;
|
|
137982
|
+
};
|
|
137983
|
+
}
|
|
137984
|
+
function throwIfFailures(results, errorMessagePrefix) {
|
|
137985
|
+
const failures = results.map((result, index) => {
|
|
137986
|
+
if (result.status === "rejected") {
|
|
137987
|
+
return {
|
|
137988
|
+
index,
|
|
137989
|
+
error: result.reason
|
|
137990
|
+
};
|
|
137991
|
+
}
|
|
137992
|
+
return null;
|
|
137993
|
+
}).filter((f) => f !== null);
|
|
137994
|
+
if (failures.length > 0) {
|
|
137995
|
+
const errorMessages = failures.map((f) => `Task ${f.index} failed: ${f.error instanceof Error ? f.error.message : String(f.error)}`);
|
|
137996
|
+
const message = errorMessagePrefix ? `${errorMessagePrefix}
|
|
137997
|
+
${errorMessages.join("\n")}` : `Failed to process ${failures.length} of ${results.length} parallel tasks:
|
|
137998
|
+
${errorMessages.join("\n")}`;
|
|
137999
|
+
const aggregatedError = new Error(message);
|
|
138000
|
+
if (failures[0]?.error instanceof Error) {
|
|
138001
|
+
aggregatedError.stack = failures[0].error.stack;
|
|
138002
|
+
}
|
|
138003
|
+
throw aggregatedError;
|
|
138004
|
+
}
|
|
138005
|
+
}
|
|
138006
|
+
}
|
|
138007
|
+
});
|
|
138008
|
+
|
|
137966
138009
|
// dist/orchestrator.js
|
|
137967
138010
|
var require_orchestrator = __commonJS({
|
|
137968
138011
|
"dist/orchestrator.js"(exports2) {
|
|
@@ -137983,6 +138026,7 @@ var require_orchestrator = __commonJS({
|
|
|
137983
138026
|
var extensionGenerators_1 = require_extensionGenerators();
|
|
137984
138027
|
var extensionIndexer_1 = require_extensionIndexer();
|
|
137985
138028
|
var file_collector_1 = require_file_collector();
|
|
138029
|
+
var orchestrator_error_helpers_1 = require_orchestrator_error_helpers();
|
|
137986
138030
|
var MAX_ERRORS_PER_BATCH = 20;
|
|
137987
138031
|
var DittoOrchestrator = class extends events_1.EventEmitter {
|
|
137988
138032
|
constructor(agentsFactory, apiKey) {
|
|
@@ -138344,7 +138388,8 @@ var require_orchestrator = __commonJS({
|
|
|
138344
138388
|
outputPath
|
|
138345
138389
|
});
|
|
138346
138390
|
});
|
|
138347
|
-
await Promise.
|
|
138391
|
+
const results = await Promise.allSettled(parallelTasks);
|
|
138392
|
+
(0, orchestrator_error_helpers_1.throwIfFailures)(results);
|
|
138348
138393
|
}
|
|
138349
138394
|
async processIterationExtension({ extension, paths, relevantUserRequest, outputPath, newExtension }) {
|
|
138350
138395
|
if (newExtension) {
|
|
@@ -138437,12 +138482,13 @@ var require_orchestrator = __commonJS({
|
|
|
138437
138482
|
blueprint,
|
|
138438
138483
|
outputPath,
|
|
138439
138484
|
planAndResources
|
|
138440
|
-
}));
|
|
138485
|
+
}).catch((0, orchestrator_error_helpers_1.createExtensionErrorHandler)(this, extension)));
|
|
138441
138486
|
const collections = planAndResources.createdCollections ?? [];
|
|
138442
138487
|
if (collections.length > 0 && siteId && siteId !== "N/A" && accessToken) {
|
|
138443
138488
|
parallelTasks.push(this.generateCMSData(request, collections));
|
|
138444
138489
|
}
|
|
138445
|
-
await Promise.
|
|
138490
|
+
const results = await Promise.allSettled(parallelTasks.filter(Boolean));
|
|
138491
|
+
(0, orchestrator_error_helpers_1.throwIfFailures)(results);
|
|
138446
138492
|
await (0, extensionIndexer_1.generateMainExtensionsFile)(outputPath);
|
|
138447
138493
|
const durationMsCodeGeneration = Date.now() - start;
|
|
138448
138494
|
this.emitEvent("finish:code-generation", {
|
|
@@ -138473,7 +138519,7 @@ var require_orchestrator = __commonJS({
|
|
|
138473
138519
|
relevantUserRequest: iterationPlan.summary,
|
|
138474
138520
|
outputPath,
|
|
138475
138521
|
newExtension: true
|
|
138476
|
-
});
|
|
138522
|
+
}).catch((0, orchestrator_error_helpers_1.createExtensionErrorHandler)(this, extension.extension));
|
|
138477
138523
|
}) || [];
|
|
138478
138524
|
if (iterationPlan?.currentExtensions && iterationPlan.currentExtensions.length > 0) {
|
|
138479
138525
|
parallelTasks.push(...iterationPlan.currentExtensions.map((extension) => {
|
|
@@ -138483,10 +138529,11 @@ var require_orchestrator = __commonJS({
|
|
|
138483
138529
|
relevantUserRequest: iterationPlan.summary,
|
|
138484
138530
|
outputPath,
|
|
138485
138531
|
newExtension: false
|
|
138486
|
-
});
|
|
138532
|
+
}).catch((0, orchestrator_error_helpers_1.createExtensionErrorHandler)(this, extension.extension));
|
|
138487
138533
|
}));
|
|
138488
138534
|
}
|
|
138489
|
-
await Promise.
|
|
138535
|
+
const results = await Promise.allSettled(parallelTasks.filter(Boolean));
|
|
138536
|
+
(0, orchestrator_error_helpers_1.throwIfFailures)(results);
|
|
138490
138537
|
await (0, extensionIndexer_1.generateMainExtensionsFile)(outputPath);
|
|
138491
138538
|
const durationMsCodeGeneration = Date.now() - start;
|
|
138492
138539
|
this.emitEvent("finish:code-generation", {
|
|
@@ -138590,52 +138637,88 @@ ${unfixedValidationErrors}`;
|
|
|
138590
138637
|
}
|
|
138591
138638
|
});
|
|
138592
138639
|
|
|
138593
|
-
// dist/flows/
|
|
138594
|
-
var
|
|
138595
|
-
"dist/flows/
|
|
138640
|
+
// dist/flows/codegen-flow-helpers.js
|
|
138641
|
+
var require_codegen_flow_helpers = __commonJS({
|
|
138642
|
+
"dist/flows/codegen-flow-helpers.js"(exports2) {
|
|
138596
138643
|
"use strict";
|
|
138597
138644
|
var __importDefault2 = exports2 && exports2.__importDefault || function(mod2) {
|
|
138598
138645
|
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
|
138599
138646
|
};
|
|
138600
138647
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
138601
|
-
exports2.
|
|
138648
|
+
exports2.setupAgentTaskTracking = setupAgentTaskTracking;
|
|
138649
|
+
exports2.updateParentTaskStatus = updateParentTaskStatus;
|
|
138650
|
+
exports2.getOutputPath = getOutputPath;
|
|
138602
138651
|
var path_1 = __importDefault2(require("path"));
|
|
138603
138652
|
var __1 = require_index();
|
|
138604
|
-
var AgentsFactory_1 = require_AgentsFactory();
|
|
138605
|
-
var cli_listeners_1 = require_cli_listeners();
|
|
138606
|
-
var context_1 = require_context();
|
|
138607
|
-
var job_context_storage_1 = require_job_context_storage();
|
|
138608
138653
|
var orchestrator_1 = require_orchestrator();
|
|
138609
138654
|
var CodeGenService_1 = require_CodeGenService();
|
|
138610
138655
|
var utils_1 = require_utils18();
|
|
138611
138656
|
var slugify = (str = "") => {
|
|
138612
138657
|
return str.toLowerCase().replace(/ /g, "-");
|
|
138613
138658
|
};
|
|
138659
|
+
function setupAgentTaskTracking(orchestrator, jobContext) {
|
|
138660
|
+
const getTaskId = (extension) => {
|
|
138661
|
+
return `${jobContext.taskId}-${slugify(extension.name)}`;
|
|
138662
|
+
};
|
|
138663
|
+
orchestrator.onEvent("agent:start", ({ extension }) => {
|
|
138664
|
+
console.log(`[Agent] start: ${extension.name}`);
|
|
138665
|
+
const taskId = getTaskId(extension);
|
|
138666
|
+
__1.codeGenerationService.addTask(jobContext.jobId, {
|
|
138667
|
+
id: taskId,
|
|
138668
|
+
kind: "run_agent",
|
|
138669
|
+
status: CodeGenService_1.TaskStatus.RUNNING,
|
|
138670
|
+
name: "run_agent",
|
|
138671
|
+
description: `Run agent for ${extension.name}`,
|
|
138672
|
+
payload: { extension }
|
|
138673
|
+
});
|
|
138674
|
+
});
|
|
138675
|
+
orchestrator.onEvent("agent:done", ({ extension, files }) => {
|
|
138676
|
+
console.log(`[Agent] done: ${extension.name}`);
|
|
138677
|
+
const taskId = getTaskId(extension);
|
|
138678
|
+
__1.codeGenerationService.updateTask(jobContext.jobId, taskId, CodeGenService_1.TaskStatus.COMPLETED, { taskOutput: { files } });
|
|
138679
|
+
});
|
|
138680
|
+
orchestrator.onEvent("agent:error", async ({ extension, error }) => {
|
|
138681
|
+
console.error(`[Agent] error: ${extension.name}`, error);
|
|
138682
|
+
const taskId = getTaskId(extension);
|
|
138683
|
+
await __1.codeGenerationService.updateTask(jobContext.jobId, taskId, CodeGenService_1.TaskStatus.FAILED, {
|
|
138684
|
+
error: (0, utils_1.serializeError)(error)
|
|
138685
|
+
});
|
|
138686
|
+
});
|
|
138687
|
+
}
|
|
138688
|
+
async function updateParentTaskStatus(jobContext, status, error) {
|
|
138689
|
+
await __1.codeGenerationService.updateTask(jobContext.jobId, jobContext.taskId, status, error ? { error: (0, utils_1.serializeError)(error) } : {});
|
|
138690
|
+
}
|
|
138691
|
+
function getOutputPath() {
|
|
138692
|
+
const outputDir = process.env.OUTPUT_PATH || orchestrator_1.DittoOrchestrator.DEFAULT_OUTPUT_PATH;
|
|
138693
|
+
return outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
|
|
138694
|
+
}
|
|
138695
|
+
}
|
|
138696
|
+
});
|
|
138697
|
+
|
|
138698
|
+
// dist/flows/init-codegen.js
|
|
138699
|
+
var require_init_codegen = __commonJS({
|
|
138700
|
+
"dist/flows/init-codegen.js"(exports2) {
|
|
138701
|
+
"use strict";
|
|
138702
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
138703
|
+
exports2.runInitCodegenFlow = void 0;
|
|
138704
|
+
var __1 = require_index();
|
|
138705
|
+
var AgentsFactory_1 = require_AgentsFactory();
|
|
138706
|
+
var cli_listeners_1 = require_cli_listeners();
|
|
138707
|
+
var context_1 = require_context();
|
|
138708
|
+
var job_context_storage_1 = require_job_context_storage();
|
|
138709
|
+
var orchestrator_1 = require_orchestrator();
|
|
138710
|
+
var CodeGenService_1 = require_CodeGenService();
|
|
138711
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
138614
138712
|
var runInitCodegenFlow = async (blueprint) => {
|
|
138615
138713
|
const localJobContext = job_context_storage_1.jobContextStorage.getStore();
|
|
138616
138714
|
console.log(`[Init] Starting init codegen task: jobId=${localJobContext?.jobId}, taskId=${localJobContext?.taskId}`);
|
|
138617
138715
|
await __1.codeGenerationService.updateTask(localJobContext.jobId, localJobContext.taskId, CodeGenService_1.TaskStatus.RUNNING, {});
|
|
138618
138716
|
console.log(`[Init] Marked task RUNNING: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`);
|
|
138619
138717
|
try {
|
|
138620
|
-
const
|
|
138621
|
-
const outputPath = outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
|
|
138718
|
+
const outputPath = (0, codegen_flow_helpers_1.getOutputPath)();
|
|
138622
138719
|
const agentsFactory = new AgentsFactory_1.AgentsFactory(context_1.ctx?.apiKey);
|
|
138623
138720
|
const orchestrator = new orchestrator_1.DittoOrchestrator(agentsFactory, context_1.ctx?.apiKey);
|
|
138624
|
-
|
|
138625
|
-
console.log(`[Agent] start: ${extension.name}`);
|
|
138626
|
-
__1.codeGenerationService.addTask(localJobContext.jobId, {
|
|
138627
|
-
id: `${localJobContext.taskId}-${slugify(extension.name)}`,
|
|
138628
|
-
kind: "run_agent",
|
|
138629
|
-
status: CodeGenService_1.TaskStatus.RUNNING,
|
|
138630
|
-
name: "run_agent",
|
|
138631
|
-
description: `Run agent for ${extension.name}`,
|
|
138632
|
-
payload: { extension }
|
|
138633
|
-
});
|
|
138634
|
-
});
|
|
138635
|
-
orchestrator.onEvent("agent:done", ({ extension, files }) => {
|
|
138636
|
-
console.log(`[Agent] done: ${extension.name}`);
|
|
138637
|
-
__1.codeGenerationService.updateTask(localJobContext.jobId, `${localJobContext.taskId}-${slugify(extension.name)}`, CodeGenService_1.TaskStatus.COMPLETED, { taskOutput: { files } });
|
|
138638
|
-
});
|
|
138721
|
+
(0, codegen_flow_helpers_1.setupAgentTaskTracking)(orchestrator, localJobContext);
|
|
138639
138722
|
(0, cli_listeners_1.attachOrchestratorListeners)(orchestrator);
|
|
138640
138723
|
await orchestrator.generateCode({
|
|
138641
138724
|
blueprint,
|
|
@@ -138643,12 +138726,10 @@ var require_init_codegen = __commonJS({
|
|
|
138643
138726
|
siteId: context_1.ctx.siteId,
|
|
138644
138727
|
accessToken: context_1.ctx.accessToken
|
|
138645
138728
|
});
|
|
138646
|
-
await
|
|
138729
|
+
await (0, codegen_flow_helpers_1.updateParentTaskStatus)(localJobContext, CodeGenService_1.TaskStatus.COMPLETED);
|
|
138647
138730
|
console.log(`[Init] Completed init codegen task: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`);
|
|
138648
138731
|
} catch (error) {
|
|
138649
|
-
await
|
|
138650
|
-
error: (0, utils_1.serializeError)(error)
|
|
138651
|
-
});
|
|
138732
|
+
await (0, codegen_flow_helpers_1.updateParentTaskStatus)(localJobContext, CodeGenService_1.TaskStatus.FAILED, error);
|
|
138652
138733
|
console.error(`\u274C [Init] Failed init codegen task: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`, error);
|
|
138653
138734
|
}
|
|
138654
138735
|
};
|
|
@@ -138660,12 +138741,8 @@ var require_init_codegen = __commonJS({
|
|
|
138660
138741
|
var require_iterate_codegen = __commonJS({
|
|
138661
138742
|
"dist/flows/iterate-codegen.js"(exports2) {
|
|
138662
138743
|
"use strict";
|
|
138663
|
-
var __importDefault2 = exports2 && exports2.__importDefault || function(mod2) {
|
|
138664
|
-
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
|
138665
|
-
};
|
|
138666
138744
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
138667
138745
|
exports2.runIterateCodegenFlow = void 0;
|
|
138668
|
-
var path_1 = __importDefault2(require("path"));
|
|
138669
138746
|
var __1 = require_index();
|
|
138670
138747
|
var AgentsFactory_1 = require_AgentsFactory();
|
|
138671
138748
|
var cli_listeners_1 = require_cli_listeners();
|
|
@@ -138673,35 +138750,17 @@ var require_iterate_codegen = __commonJS({
|
|
|
138673
138750
|
var job_context_storage_1 = require_job_context_storage();
|
|
138674
138751
|
var orchestrator_1 = require_orchestrator();
|
|
138675
138752
|
var CodeGenService_1 = require_CodeGenService();
|
|
138676
|
-
var
|
|
138677
|
-
var slugify = (str = "") => {
|
|
138678
|
-
return str.toLowerCase().replace(/ /g, "-");
|
|
138679
|
-
};
|
|
138753
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
138680
138754
|
var runIterateCodegenFlow = async (chatHistory) => {
|
|
138681
138755
|
const localJobContext = job_context_storage_1.jobContextStorage.getStore();
|
|
138682
138756
|
console.log(`[Iterate] Starting iterate codegen task: jobId=${localJobContext?.jobId}, taskId=${localJobContext?.taskId}`);
|
|
138683
138757
|
await __1.codeGenerationService.updateTask(localJobContext.jobId, localJobContext.taskId, CodeGenService_1.TaskStatus.RUNNING, {});
|
|
138684
138758
|
console.log(`[Init] Marked task RUNNING: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`);
|
|
138685
138759
|
try {
|
|
138686
|
-
const
|
|
138687
|
-
const outputPath = outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
|
|
138760
|
+
const outputPath = (0, codegen_flow_helpers_1.getOutputPath)();
|
|
138688
138761
|
const agentsFactory = new AgentsFactory_1.AgentsFactory(context_1.ctx?.apiKey);
|
|
138689
138762
|
const orchestrator = new orchestrator_1.DittoOrchestrator(agentsFactory, context_1.ctx?.apiKey);
|
|
138690
|
-
|
|
138691
|
-
console.log(`[Agent] start: ${extension.name}`);
|
|
138692
|
-
__1.codeGenerationService.addTask(localJobContext.jobId, {
|
|
138693
|
-
id: `${localJobContext.taskId}-${slugify(extension.name)}`,
|
|
138694
|
-
kind: "run_agent",
|
|
138695
|
-
status: CodeGenService_1.TaskStatus.RUNNING,
|
|
138696
|
-
name: "run_agent",
|
|
138697
|
-
description: `Run agent for ${extension.name}`,
|
|
138698
|
-
payload: { extension }
|
|
138699
|
-
});
|
|
138700
|
-
});
|
|
138701
|
-
orchestrator.onEvent("agent:done", ({ extension, files }) => {
|
|
138702
|
-
console.log(`[Agent] done: ${extension.name}`);
|
|
138703
|
-
__1.codeGenerationService.updateTask(localJobContext.jobId, `${localJobContext.taskId}-${slugify(extension.name)}`, CodeGenService_1.TaskStatus.COMPLETED, { taskOutput: { files } });
|
|
138704
|
-
});
|
|
138763
|
+
(0, codegen_flow_helpers_1.setupAgentTaskTracking)(orchestrator, localJobContext);
|
|
138705
138764
|
(0, cli_listeners_1.attachOrchestratorListeners)(orchestrator);
|
|
138706
138765
|
await orchestrator.generateIterationCode({
|
|
138707
138766
|
chatHistory,
|
|
@@ -138709,13 +138768,11 @@ var require_iterate_codegen = __commonJS({
|
|
|
138709
138768
|
siteId: context_1.ctx.siteId,
|
|
138710
138769
|
accessToken: context_1.ctx.accessToken
|
|
138711
138770
|
});
|
|
138712
|
-
await
|
|
138771
|
+
await (0, codegen_flow_helpers_1.updateParentTaskStatus)(localJobContext, CodeGenService_1.TaskStatus.COMPLETED);
|
|
138713
138772
|
console.log(`[Init] Completed iterate codegen task: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`);
|
|
138714
138773
|
} catch (error) {
|
|
138715
|
-
await
|
|
138716
|
-
|
|
138717
|
-
});
|
|
138718
|
-
console.error(`\u274C [Init] Failed iterate codegen task: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`, error);
|
|
138774
|
+
await (0, codegen_flow_helpers_1.updateParentTaskStatus)(localJobContext, CodeGenService_1.TaskStatus.FAILED, error);
|
|
138775
|
+
console.error(`\u274C [Iterate] Failed iterate codegen task: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`, error);
|
|
138719
138776
|
}
|
|
138720
138777
|
};
|
|
138721
138778
|
exports2.runIterateCodegenFlow = runIterateCodegenFlow;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/ditto-codegen-public",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.62",
|
|
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.25.9"
|
|
26
26
|
},
|
|
27
|
-
"falconPackageHash": "
|
|
27
|
+
"falconPackageHash": "73032240b41bf383a302f704545d08c7acbfdf0936a82b5aaa9c0c3b"
|
|
28
28
|
}
|