@wix/ditto-codegen-public 1.0.224 → 1.0.226
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 +368 -303
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -7641,6 +7641,16 @@ var require_CodeGenService = __commonJS({
|
|
|
7641
7641
|
}
|
|
7642
7642
|
}));
|
|
7643
7643
|
};
|
|
7644
|
+
this.markJobAsRuninng = async (jobId) => {
|
|
7645
|
+
await this.httpClient.request((0, http_1.updateJob)({
|
|
7646
|
+
projectId: this.projectId,
|
|
7647
|
+
job: {
|
|
7648
|
+
id: jobId,
|
|
7649
|
+
projectId: this.projectId,
|
|
7650
|
+
status: types_1.Status.RUNNING
|
|
7651
|
+
}
|
|
7652
|
+
}));
|
|
7653
|
+
};
|
|
7644
7654
|
this.markJobAsCancelled = async (jobId) => {
|
|
7645
7655
|
await this.httpClient.request((0, http_1.updateJob)({
|
|
7646
7656
|
projectId: this.projectId,
|
|
@@ -105088,48 +105098,6 @@ export default appBuilder;
|
|
|
105088
105098
|
}
|
|
105089
105099
|
});
|
|
105090
105100
|
|
|
105091
|
-
// dist/orchestrator-error-helpers.js
|
|
105092
|
-
var require_orchestrator_error_helpers = __commonJS({
|
|
105093
|
-
"dist/orchestrator-error-helpers.js"(exports2) {
|
|
105094
|
-
"use strict";
|
|
105095
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
105096
|
-
exports2.createExtensionErrorHandler = createExtensionErrorHandler;
|
|
105097
|
-
exports2.throwIfFailures = throwIfFailures;
|
|
105098
|
-
var ditto_codegen_types_12 = require_dist();
|
|
105099
|
-
function createExtensionErrorHandler(eventEmitter, extension) {
|
|
105100
|
-
return (error) => {
|
|
105101
|
-
const codegenError = (0, ditto_codegen_types_12.toCodegenError)(error);
|
|
105102
|
-
eventEmitter.emitEvent("agent:error", {
|
|
105103
|
-
extension,
|
|
105104
|
-
error: codegenError
|
|
105105
|
-
});
|
|
105106
|
-
console.error(`\u274C Failed to process extension ${extension.name}:`, error);
|
|
105107
|
-
throw codegenError;
|
|
105108
|
-
};
|
|
105109
|
-
}
|
|
105110
|
-
function throwIfFailures(results) {
|
|
105111
|
-
const failures = results.map((result, index) => {
|
|
105112
|
-
if (result.status === "rejected") {
|
|
105113
|
-
return {
|
|
105114
|
-
index,
|
|
105115
|
-
error: result.reason
|
|
105116
|
-
};
|
|
105117
|
-
}
|
|
105118
|
-
return null;
|
|
105119
|
-
}).filter((f) => f !== null);
|
|
105120
|
-
if (failures.length > 0) {
|
|
105121
|
-
const errorMessages = failures.map((f) => {
|
|
105122
|
-
const codegenError = (0, ditto_codegen_types_12.toCodegenError)(f.error);
|
|
105123
|
-
return `Task ${f.index} failed: ${codegenError.message}`;
|
|
105124
|
-
});
|
|
105125
|
-
const message = `Failed to process ${failures.length} of ${results.length} parallel tasks:
|
|
105126
|
-
${errorMessages.join("\n")}`;
|
|
105127
|
-
throw (0, ditto_codegen_types_12.toCodegenError)(new Error(message));
|
|
105128
|
-
}
|
|
105129
|
-
}
|
|
105130
|
-
}
|
|
105131
|
-
});
|
|
105132
|
-
|
|
105133
105101
|
// dist/utils.js
|
|
105134
105102
|
var require_utils15 = __commonJS({
|
|
105135
105103
|
"dist/utils.js"(exports2) {
|
|
@@ -105202,6 +105170,337 @@ var require_utils15 = __commonJS({
|
|
|
105202
105170
|
}
|
|
105203
105171
|
});
|
|
105204
105172
|
|
|
105173
|
+
// ../../node_modules/@wix/ambassador-ctp-ditto-v1-blueprint/build/cjs/http.impl.js
|
|
105174
|
+
var require_http_impl2 = __commonJS({
|
|
105175
|
+
"../../node_modules/@wix/ambassador-ctp-ditto-v1-blueprint/build/cjs/http.impl.js"(exports2) {
|
|
105176
|
+
"use strict";
|
|
105177
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
105178
|
+
exports2.getRequiredPermissions = exports2.editBlueprint = exports2.createAppName = exports2.createBlueprint = void 0;
|
|
105179
|
+
var ambassador_1 = require_ambassador_index();
|
|
105180
|
+
var metro_runtime_1 = require_cjs2();
|
|
105181
|
+
var _createAppNameRequest = {};
|
|
105182
|
+
var _createAppNameResponse = {};
|
|
105183
|
+
var _createBlueprintRequest = {};
|
|
105184
|
+
var _createBlueprintResponse = {};
|
|
105185
|
+
var _editBlueprintRequest = {};
|
|
105186
|
+
var _editBlueprintResponse = {};
|
|
105187
|
+
var _getRequiredPermissionsRequest = {};
|
|
105188
|
+
var _getRequiredPermissionsResponse = {};
|
|
105189
|
+
function resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl(opts) {
|
|
105190
|
+
var domainToMappings = {
|
|
105191
|
+
"manage._base_domain_": [
|
|
105192
|
+
{
|
|
105193
|
+
srcPath: "/_api/ditto-blueprint-service-web",
|
|
105194
|
+
destPath: ""
|
|
105195
|
+
}
|
|
105196
|
+
]
|
|
105197
|
+
};
|
|
105198
|
+
return (0, metro_runtime_1.resolveUrl)(Object.assign(opts, { domainToMappings }));
|
|
105199
|
+
}
|
|
105200
|
+
function createBlueprint(payload) {
|
|
105201
|
+
var _a = (0, ambassador_1.serializer)(_createBlueprintRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
|
|
105202
|
+
var fromRes = (0, ambassador_1.serializer)(_createBlueprintResponse, {}).fromJSON;
|
|
105203
|
+
function __createBlueprint(_a2) {
|
|
105204
|
+
var host = _a2.host;
|
|
105205
|
+
var serializedData = toReq(payload);
|
|
105206
|
+
var metadata = {
|
|
105207
|
+
entityFqdn: "wix.ctp.ditto.v1.blueprint",
|
|
105208
|
+
method: "POST",
|
|
105209
|
+
methodFqn: "com.wixpress.ditto_blueprint_service.api.DittoBlueprintService.CreateBlueprint",
|
|
105210
|
+
migrationOptions: {
|
|
105211
|
+
optInTransformResponse: true
|
|
105212
|
+
},
|
|
105213
|
+
url: resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl({
|
|
105214
|
+
protoPath: "/v1/blueprints",
|
|
105215
|
+
data: serializedData,
|
|
105216
|
+
host
|
|
105217
|
+
}),
|
|
105218
|
+
data: serializedData,
|
|
105219
|
+
transformResponse: fromRes
|
|
105220
|
+
};
|
|
105221
|
+
return metadata;
|
|
105222
|
+
}
|
|
105223
|
+
__createBlueprint.fromReq = fromReq;
|
|
105224
|
+
__createBlueprint.__isAmbassador = true;
|
|
105225
|
+
return __createBlueprint;
|
|
105226
|
+
}
|
|
105227
|
+
exports2.createBlueprint = createBlueprint;
|
|
105228
|
+
function createAppName(payload) {
|
|
105229
|
+
var _a = (0, ambassador_1.serializer)(_createAppNameRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
|
|
105230
|
+
var fromRes = (0, ambassador_1.serializer)(_createAppNameResponse, {}).fromJSON;
|
|
105231
|
+
function __createAppName(_a2) {
|
|
105232
|
+
var host = _a2.host;
|
|
105233
|
+
var serializedData = toReq(payload);
|
|
105234
|
+
var metadata = {
|
|
105235
|
+
entityFqdn: "wix.ctp.ditto.v1.blueprint",
|
|
105236
|
+
method: "POST",
|
|
105237
|
+
methodFqn: "com.wixpress.ditto_blueprint_service.api.DittoBlueprintService.CreateAppName",
|
|
105238
|
+
migrationOptions: {
|
|
105239
|
+
optInTransformResponse: true
|
|
105240
|
+
},
|
|
105241
|
+
url: resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl({
|
|
105242
|
+
protoPath: "/v1/blueprints/app-name",
|
|
105243
|
+
data: serializedData,
|
|
105244
|
+
host
|
|
105245
|
+
}),
|
|
105246
|
+
data: serializedData,
|
|
105247
|
+
transformResponse: fromRes
|
|
105248
|
+
};
|
|
105249
|
+
return metadata;
|
|
105250
|
+
}
|
|
105251
|
+
__createAppName.fromReq = fromReq;
|
|
105252
|
+
__createAppName.__isAmbassador = true;
|
|
105253
|
+
return __createAppName;
|
|
105254
|
+
}
|
|
105255
|
+
exports2.createAppName = createAppName;
|
|
105256
|
+
function editBlueprint(payload) {
|
|
105257
|
+
var _a = (0, ambassador_1.serializer)(_editBlueprintRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
|
|
105258
|
+
var fromRes = (0, ambassador_1.serializer)(_editBlueprintResponse, {}).fromJSON;
|
|
105259
|
+
function __editBlueprint(_a2) {
|
|
105260
|
+
var host = _a2.host;
|
|
105261
|
+
var serializedData = toReq(payload);
|
|
105262
|
+
var metadata = {
|
|
105263
|
+
entityFqdn: "wix.ctp.ditto.v1.blueprint",
|
|
105264
|
+
method: "POST",
|
|
105265
|
+
methodFqn: "com.wixpress.ditto_blueprint_service.api.DittoBlueprintService.EditBlueprint",
|
|
105266
|
+
migrationOptions: {
|
|
105267
|
+
optInTransformResponse: true
|
|
105268
|
+
},
|
|
105269
|
+
url: resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl({
|
|
105270
|
+
protoPath: "/v1/blueprints/edit",
|
|
105271
|
+
data: serializedData,
|
|
105272
|
+
host
|
|
105273
|
+
}),
|
|
105274
|
+
data: serializedData,
|
|
105275
|
+
transformResponse: fromRes
|
|
105276
|
+
};
|
|
105277
|
+
return metadata;
|
|
105278
|
+
}
|
|
105279
|
+
__editBlueprint.fromReq = fromReq;
|
|
105280
|
+
__editBlueprint.__isAmbassador = true;
|
|
105281
|
+
return __editBlueprint;
|
|
105282
|
+
}
|
|
105283
|
+
exports2.editBlueprint = editBlueprint;
|
|
105284
|
+
function getRequiredPermissions(payload) {
|
|
105285
|
+
var _a = (0, ambassador_1.serializer)(_getRequiredPermissionsRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
|
|
105286
|
+
var fromRes = (0, ambassador_1.serializer)(_getRequiredPermissionsResponse, {}).fromJSON;
|
|
105287
|
+
function __getRequiredPermissions(_a2) {
|
|
105288
|
+
var host = _a2.host;
|
|
105289
|
+
var serializedData = toReq(payload);
|
|
105290
|
+
var metadata = {
|
|
105291
|
+
entityFqdn: "wix.ctp.ditto.v1.blueprint",
|
|
105292
|
+
method: "POST",
|
|
105293
|
+
methodFqn: "com.wixpress.ditto_blueprint_service.api.DittoBlueprintService.GetRequiredPermissions",
|
|
105294
|
+
migrationOptions: {
|
|
105295
|
+
optInTransformResponse: true
|
|
105296
|
+
},
|
|
105297
|
+
url: resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl({
|
|
105298
|
+
protoPath: "/v1/blueprints/required-permissions",
|
|
105299
|
+
data: serializedData,
|
|
105300
|
+
host
|
|
105301
|
+
}),
|
|
105302
|
+
data: serializedData,
|
|
105303
|
+
transformResponse: fromRes
|
|
105304
|
+
};
|
|
105305
|
+
return metadata;
|
|
105306
|
+
}
|
|
105307
|
+
__getRequiredPermissions.fromReq = fromReq;
|
|
105308
|
+
__getRequiredPermissions.__isAmbassador = true;
|
|
105309
|
+
return __getRequiredPermissions;
|
|
105310
|
+
}
|
|
105311
|
+
exports2.getRequiredPermissions = getRequiredPermissions;
|
|
105312
|
+
}
|
|
105313
|
+
});
|
|
105314
|
+
|
|
105315
|
+
// dist/flows/codegen-flow-helpers.js
|
|
105316
|
+
var require_codegen_flow_helpers = __commonJS({
|
|
105317
|
+
"dist/flows/codegen-flow-helpers.js"(exports2) {
|
|
105318
|
+
"use strict";
|
|
105319
|
+
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
105320
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
105321
|
+
};
|
|
105322
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
105323
|
+
exports2.addAgentTask = addAgentTask;
|
|
105324
|
+
exports2.completeAgentTask = completeAgentTask;
|
|
105325
|
+
exports2.failAgentTask = failAgentTask;
|
|
105326
|
+
exports2.addUpdateExtensionAgentTask = addUpdateExtensionAgentTask;
|
|
105327
|
+
exports2.completeUpdateExtensionAgentTask = completeUpdateExtensionAgentTask;
|
|
105328
|
+
exports2.failUpdateExtensionAgentTask = failUpdateExtensionAgentTask;
|
|
105329
|
+
exports2.updateJobPayload = updateJobPayload;
|
|
105330
|
+
exports2.updateParentTaskStatus = updateParentTaskStatus;
|
|
105331
|
+
exports2.getOutputPath = getOutputPath;
|
|
105332
|
+
exports2.getRequiredPermissions = getRequiredPermissions;
|
|
105333
|
+
var path_1 = __importDefault2(require("path"));
|
|
105334
|
+
var codeGenerationService_12 = require_codeGenerationService();
|
|
105335
|
+
var ditto_codegen_types_12 = require_dist();
|
|
105336
|
+
var utils_1 = require_utils15();
|
|
105337
|
+
var http_1 = require_http_impl2();
|
|
105338
|
+
var http_client_1 = require_index_node();
|
|
105339
|
+
var orchestrator_1 = require_orchestrator();
|
|
105340
|
+
var job_context_storage_12 = require_job_context_storage();
|
|
105341
|
+
var slugify = (str = "") => {
|
|
105342
|
+
return str.toLowerCase().replace(/ /g, "-");
|
|
105343
|
+
};
|
|
105344
|
+
function getJobContext() {
|
|
105345
|
+
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
105346
|
+
if (!store?.jobId || !store?.taskId) {
|
|
105347
|
+
return null;
|
|
105348
|
+
}
|
|
105349
|
+
return { jobId: store.jobId, taskId: store.taskId };
|
|
105350
|
+
}
|
|
105351
|
+
function getAgentTaskId(parentTaskId, extension) {
|
|
105352
|
+
return `${parentTaskId}-${slugify(extension.name)}`;
|
|
105353
|
+
}
|
|
105354
|
+
async function addAgentTask(extension, agentName) {
|
|
105355
|
+
const jobContext = getJobContext();
|
|
105356
|
+
if (!jobContext) {
|
|
105357
|
+
console.log(`[Agent] start: ${extension.name} (no job context)`);
|
|
105358
|
+
return;
|
|
105359
|
+
}
|
|
105360
|
+
console.log(`[Agent] start: ${extension.name}`);
|
|
105361
|
+
const taskId = getAgentTaskId(jobContext.taskId, extension);
|
|
105362
|
+
await codeGenerationService_12.codeGenerationService.addTask(jobContext.jobId, {
|
|
105363
|
+
id: taskId,
|
|
105364
|
+
kind: ditto_codegen_types_12.TaskKind.RUN_AGENT,
|
|
105365
|
+
status: ditto_codegen_types_12.Status.RUNNING,
|
|
105366
|
+
name: "run_agent",
|
|
105367
|
+
description: `Run agent for ${extension.name}`,
|
|
105368
|
+
payload: { extension },
|
|
105369
|
+
agentName
|
|
105370
|
+
});
|
|
105371
|
+
}
|
|
105372
|
+
async function completeAgentTask(extension, files) {
|
|
105373
|
+
const jobContext = getJobContext();
|
|
105374
|
+
if (!jobContext) {
|
|
105375
|
+
console.log(`[Agent] done: ${extension.name} (no job context)`);
|
|
105376
|
+
return;
|
|
105377
|
+
}
|
|
105378
|
+
console.log(`[Agent] done: ${extension.name}`);
|
|
105379
|
+
const taskId = getAgentTaskId(jobContext.taskId, extension);
|
|
105380
|
+
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, taskId, ditto_codegen_types_12.Status.COMPLETED, { taskOutput: { files } });
|
|
105381
|
+
}
|
|
105382
|
+
async function failAgentTask(extension, error) {
|
|
105383
|
+
const jobContext = getJobContext();
|
|
105384
|
+
if (!jobContext) {
|
|
105385
|
+
console.error(`[Agent] error: ${extension.name} (no job context)`, error);
|
|
105386
|
+
return;
|
|
105387
|
+
}
|
|
105388
|
+
console.error(`[Agent] error: ${extension.name}`, error);
|
|
105389
|
+
const taskId = getAgentTaskId(jobContext.taskId, extension);
|
|
105390
|
+
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, taskId, ditto_codegen_types_12.Status.FAILED, { error: (0, utils_1.serializeError)(error) });
|
|
105391
|
+
}
|
|
105392
|
+
async function addUpdateExtensionAgentTask() {
|
|
105393
|
+
const jobContext = getJobContext();
|
|
105394
|
+
if (!jobContext) {
|
|
105395
|
+
console.log(`[Agent] start: iterating existing code (no job context)`);
|
|
105396
|
+
return;
|
|
105397
|
+
}
|
|
105398
|
+
console.log(`[Agent] start: iterating existing code`);
|
|
105399
|
+
const taskId = `${jobContext.taskId}-update-extension-agent`;
|
|
105400
|
+
await codeGenerationService_12.codeGenerationService.addTask(jobContext.jobId, {
|
|
105401
|
+
id: taskId,
|
|
105402
|
+
kind: ditto_codegen_types_12.TaskKind.RUN_AGENT,
|
|
105403
|
+
status: ditto_codegen_types_12.Status.RUNNING,
|
|
105404
|
+
name: "run_agent",
|
|
105405
|
+
description: "Iterating existing code",
|
|
105406
|
+
agentName: "UpdateExtensionAgent"
|
|
105407
|
+
});
|
|
105408
|
+
}
|
|
105409
|
+
async function completeUpdateExtensionAgentTask(files) {
|
|
105410
|
+
const jobContext = getJobContext();
|
|
105411
|
+
if (!jobContext) {
|
|
105412
|
+
console.log(`[Agent] done: iterating existing code (no job context)`);
|
|
105413
|
+
return;
|
|
105414
|
+
}
|
|
105415
|
+
console.log(`[Agent] done: iterating existing code`);
|
|
105416
|
+
const taskId = `${jobContext.taskId}-update-extension-agent`;
|
|
105417
|
+
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, taskId, ditto_codegen_types_12.Status.COMPLETED, { taskOutput: { files } });
|
|
105418
|
+
}
|
|
105419
|
+
async function failUpdateExtensionAgentTask(error) {
|
|
105420
|
+
const jobContext = getJobContext();
|
|
105421
|
+
if (!jobContext) {
|
|
105422
|
+
console.error(`[Agent] error: iterating existing code (no job context)`, error);
|
|
105423
|
+
return;
|
|
105424
|
+
}
|
|
105425
|
+
console.error(`[Agent] error: iterating existing code`, error);
|
|
105426
|
+
const taskId = `${jobContext.taskId}-update-extension-agent`;
|
|
105427
|
+
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, taskId, ditto_codegen_types_12.Status.FAILED, { error: (0, utils_1.serializeError)(error) });
|
|
105428
|
+
}
|
|
105429
|
+
async function updateJobPayload(jobContext, payload) {
|
|
105430
|
+
await codeGenerationService_12.codeGenerationService.updateJob(jobContext.jobId, payload);
|
|
105431
|
+
}
|
|
105432
|
+
async function updateParentTaskStatus(jobContext, status, error) {
|
|
105433
|
+
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, jobContext.taskId, status, error ? { error: (0, utils_1.serializeError)(error) } : {});
|
|
105434
|
+
}
|
|
105435
|
+
function getOutputPath() {
|
|
105436
|
+
const outputDir = process.env.OUTPUT_PATH || orchestrator_1.DittoOrchestrator.DEFAULT_OUTPUT_PATH;
|
|
105437
|
+
return outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
|
|
105438
|
+
}
|
|
105439
|
+
async function getRequiredPermissions(extensions) {
|
|
105440
|
+
const httpClient = (0, http_client_1.createHttpClient)({
|
|
105441
|
+
baseURL: "https://manage.wix.com"
|
|
105442
|
+
});
|
|
105443
|
+
return httpClient.request((0, http_1.getRequiredPermissions)({
|
|
105444
|
+
relatedApis: getRelatedApis(extensions ?? []),
|
|
105445
|
+
extensionTypes: getExtensionTypes(extensions ?? [])
|
|
105446
|
+
}));
|
|
105447
|
+
}
|
|
105448
|
+
function getExtensionTypes(extensions) {
|
|
105449
|
+
return Array.from(new Set((extensions ?? []).map(({ type }) => type).filter(Boolean)));
|
|
105450
|
+
}
|
|
105451
|
+
function getRelatedApis(extensions) {
|
|
105452
|
+
return Array.from(new Set((extensions ?? []).flatMap((ext) => [
|
|
105453
|
+
...(ext.relatedApis ?? []).map(({ name }) => name).filter(Boolean),
|
|
105454
|
+
...(ext.relatedSpis ?? []).map(({ name }) => name).filter(Boolean)
|
|
105455
|
+
])));
|
|
105456
|
+
}
|
|
105457
|
+
}
|
|
105458
|
+
});
|
|
105459
|
+
|
|
105460
|
+
// dist/orchestrator-error-helpers.js
|
|
105461
|
+
var require_orchestrator_error_helpers = __commonJS({
|
|
105462
|
+
"dist/orchestrator-error-helpers.js"(exports2) {
|
|
105463
|
+
"use strict";
|
|
105464
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
105465
|
+
exports2.createExtensionErrorHandler = createExtensionErrorHandler;
|
|
105466
|
+
exports2.throwIfFailures = throwIfFailures;
|
|
105467
|
+
var ditto_codegen_types_12 = require_dist();
|
|
105468
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
105469
|
+
function createExtensionErrorHandler(eventEmitter, extension) {
|
|
105470
|
+
return async (error) => {
|
|
105471
|
+
const codegenError = (0, ditto_codegen_types_12.toCodegenError)(error);
|
|
105472
|
+
await (0, codegen_flow_helpers_1.failAgentTask)(extension, codegenError);
|
|
105473
|
+
eventEmitter.emitEvent("agent:error", {
|
|
105474
|
+
extension,
|
|
105475
|
+
error: codegenError
|
|
105476
|
+
});
|
|
105477
|
+
console.error(`\u274C Failed to process extension ${extension.name}:`, error);
|
|
105478
|
+
throw codegenError;
|
|
105479
|
+
};
|
|
105480
|
+
}
|
|
105481
|
+
function throwIfFailures(results) {
|
|
105482
|
+
const failures = results.map((result, index) => {
|
|
105483
|
+
if (result.status === "rejected") {
|
|
105484
|
+
return {
|
|
105485
|
+
index,
|
|
105486
|
+
error: result.reason
|
|
105487
|
+
};
|
|
105488
|
+
}
|
|
105489
|
+
return null;
|
|
105490
|
+
}).filter((f) => f !== null);
|
|
105491
|
+
if (failures.length > 0) {
|
|
105492
|
+
const errorMessages = failures.map((f) => {
|
|
105493
|
+
const codegenError = (0, ditto_codegen_types_12.toCodegenError)(f.error);
|
|
105494
|
+
return `Task ${f.index} failed: ${codegenError.message}`;
|
|
105495
|
+
});
|
|
105496
|
+
const message = `Failed to process ${failures.length} of ${results.length} parallel tasks:
|
|
105497
|
+
${errorMessages.join("\n")}`;
|
|
105498
|
+
throw (0, ditto_codegen_types_12.toCodegenError)(new Error(message));
|
|
105499
|
+
}
|
|
105500
|
+
}
|
|
105501
|
+
}
|
|
105502
|
+
});
|
|
105503
|
+
|
|
105205
105504
|
// dist/validators/TypescriptValidator.js
|
|
105206
105505
|
var require_TypescriptValidator = __commonJS({
|
|
105207
105506
|
"dist/validators/TypescriptValidator.js"(exports2) {
|
|
@@ -106379,7 +106678,8 @@ var require_finalize_extension_generation = __commonJS({
|
|
|
106379
106678
|
var file_collector_1 = require_file_collector();
|
|
106380
106679
|
var orchestrator_error_helpers_1 = require_orchestrator_error_helpers();
|
|
106381
106680
|
var write_file_1 = require_write_file();
|
|
106382
|
-
|
|
106681
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
106682
|
+
async function finalizeExtensionGeneration(options, eventEmitter) {
|
|
106383
106683
|
const { extension, agentName, agentFiles, scaffolds = [], scaffoldPath, outputPath, generatedConfig } = options;
|
|
106384
106684
|
try {
|
|
106385
106685
|
const filesToCheck = agentFiles.map((f) => f.path || "");
|
|
@@ -106398,6 +106698,7 @@ var require_finalize_extension_generation = __commonJS({
|
|
|
106398
106698
|
outputPath,
|
|
106399
106699
|
existingFiles
|
|
106400
106700
|
});
|
|
106701
|
+
await (0, codegen_flow_helpers_1.completeAgentTask)(extension, allCreatedFiles);
|
|
106401
106702
|
eventEmitter.emitEvent("agent:done", {
|
|
106402
106703
|
extension,
|
|
106403
106704
|
name: agentName,
|
|
@@ -106405,7 +106706,8 @@ var require_finalize_extension_generation = __commonJS({
|
|
|
106405
106706
|
});
|
|
106406
106707
|
return extensionFilePath;
|
|
106407
106708
|
} catch (error) {
|
|
106408
|
-
|
|
106709
|
+
await (0, orchestrator_error_helpers_1.createExtensionErrorHandler)(eventEmitter, extension)(error);
|
|
106710
|
+
throw error;
|
|
106409
106711
|
}
|
|
106410
106712
|
}
|
|
106411
106713
|
}
|
|
@@ -106451,10 +106753,12 @@ var require_extensionProcessors = __commonJS({
|
|
|
106451
106753
|
exports2.processStandardExtension = processStandardExtension;
|
|
106452
106754
|
var finalize_extension_generation_1 = require_finalize_extension_generation();
|
|
106453
106755
|
var create_scaffolding_1 = require_create_scaffolding();
|
|
106756
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
106454
106757
|
async function processStandardExtension(params) {
|
|
106455
106758
|
const { extension, outputPath, plan, agentsFactory, eventEmitter, blueprint, userRequestSummary, previousResources } = params;
|
|
106456
106759
|
const scaffolds = await (0, create_scaffolding_1.createScaffolding)(extension, outputPath, eventEmitter);
|
|
106457
106760
|
const agent = agentsFactory.getAgent(extension);
|
|
106761
|
+
await (0, codegen_flow_helpers_1.addAgentTask)(extension, agent.name);
|
|
106458
106762
|
eventEmitter.emitEvent("agent:start", {
|
|
106459
106763
|
extension,
|
|
106460
106764
|
name: agent.name
|
|
@@ -106468,7 +106772,7 @@ var require_extensionProcessors = __commonJS({
|
|
|
106468
106772
|
...userRequestSummary && { userRequestSummary },
|
|
106469
106773
|
...previousResources && { previousResources }
|
|
106470
106774
|
});
|
|
106471
|
-
(0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106775
|
+
await (0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106472
106776
|
extension,
|
|
106473
106777
|
agentName: agent.name,
|
|
106474
106778
|
agentFiles: files,
|
|
@@ -106489,6 +106793,7 @@ var require_dashboardPage = __commonJS({
|
|
|
106489
106793
|
var finalize_extension_generation_1 = require_finalize_extension_generation();
|
|
106490
106794
|
var extensionProcessors_1 = require_extensionProcessors();
|
|
106491
106795
|
var ditto_codegen_types_12 = require_dist();
|
|
106796
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
106492
106797
|
async function processDashboardPage(params) {
|
|
106493
106798
|
const { extension, outputPath, plan, agentsFactory, eventEmitter, blueprint, userRequestSummary, previousResources } = params;
|
|
106494
106799
|
const decisionAgent = agentsFactory.getAgent({
|
|
@@ -106530,6 +106835,7 @@ var require_dashboardPage = __commonJS({
|
|
|
106530
106835
|
const autoPatternsGenerator = agentsFactory.getAgent({
|
|
106531
106836
|
type: "AUTO_PATTERNS_GENERATOR"
|
|
106532
106837
|
});
|
|
106838
|
+
await (0, codegen_flow_helpers_1.addAgentTask)(extension, "DashboardAgent");
|
|
106533
106839
|
eventEmitter.emitEvent("agent:start", {
|
|
106534
106840
|
extension,
|
|
106535
106841
|
name: "DashboardAgent"
|
|
@@ -106540,7 +106846,7 @@ var require_dashboardPage = __commonJS({
|
|
|
106540
106846
|
extensionName: extension.name || ""
|
|
106541
106847
|
});
|
|
106542
106848
|
const pagePath = files[0].path || "";
|
|
106543
|
-
(0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106849
|
+
await (0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106544
106850
|
extension,
|
|
106545
106851
|
agentName: "DashboardAgent",
|
|
106546
106852
|
agentFiles: files,
|
|
@@ -106562,6 +106868,7 @@ var require_servicePlugin = __commonJS({
|
|
|
106562
106868
|
var finalize_extension_generation_1 = require_finalize_extension_generation();
|
|
106563
106869
|
var create_scaffolding_1 = require_create_scaffolding();
|
|
106564
106870
|
var ditto_codegen_types_12 = require_dist();
|
|
106871
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
106565
106872
|
async function processMultipleServicePluginScaffolds(params) {
|
|
106566
106873
|
const { extension, scaffolds, outputPath, plan, agentsFactory, eventEmitter, blueprint, userRequestSummary, previousResources } = params;
|
|
106567
106874
|
if (!extension.relatedSpis || extension.relatedSpis.length === 0) {
|
|
@@ -106582,6 +106889,7 @@ var require_servicePlugin = __commonJS({
|
|
|
106582
106889
|
relatedSpis: [spi]
|
|
106583
106890
|
};
|
|
106584
106891
|
const agent = agentsFactory.getAgent(spiExtension);
|
|
106892
|
+
await (0, codegen_flow_helpers_1.addAgentTask)(spiExtension, agent.name);
|
|
106585
106893
|
eventEmitter.emitEvent("agent:start", {
|
|
106586
106894
|
extension: spiExtension,
|
|
106587
106895
|
name: agent.name
|
|
@@ -106595,7 +106903,7 @@ var require_servicePlugin = __commonJS({
|
|
|
106595
106903
|
...userRequestSummary && { userRequestSummary },
|
|
106596
106904
|
...previousResources && { previousResources }
|
|
106597
106905
|
});
|
|
106598
|
-
(0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106906
|
+
await (0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106599
106907
|
extension: spiExtension,
|
|
106600
106908
|
agentName: agent.name,
|
|
106601
106909
|
agentFiles: files,
|
|
@@ -106614,6 +106922,7 @@ var require_servicePlugin = __commonJS({
|
|
|
106614
106922
|
return processMultipleServicePluginScaffolds({ ...params, scaffolds });
|
|
106615
106923
|
}
|
|
106616
106924
|
const agent = agentsFactory.getAgent(extension);
|
|
106925
|
+
await (0, codegen_flow_helpers_1.addAgentTask)(extension, agent.name);
|
|
106617
106926
|
eventEmitter.emitEvent("agent:start", { extension, name: agent.name });
|
|
106618
106927
|
const files = await agent.generate({
|
|
106619
106928
|
extension,
|
|
@@ -106624,7 +106933,7 @@ var require_servicePlugin = __commonJS({
|
|
|
106624
106933
|
...userRequestSummary && { userRequestSummary },
|
|
106625
106934
|
...previousResources && { previousResources }
|
|
106626
106935
|
});
|
|
106627
|
-
(0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106936
|
+
await (0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106628
106937
|
extension,
|
|
106629
106938
|
agentName: agent.name,
|
|
106630
106939
|
agentFiles: files,
|
|
@@ -106645,10 +106954,12 @@ var require_embeddedScript = __commonJS({
|
|
|
106645
106954
|
var types_1 = require_types_impl2();
|
|
106646
106955
|
var finalize_extension_generation_1 = require_finalize_extension_generation();
|
|
106647
106956
|
var create_scaffolding_1 = require_create_scaffolding();
|
|
106957
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
106648
106958
|
async function processEmbeddedScriptExtension(params) {
|
|
106649
106959
|
const { extension, outputPath, plan, agentsFactory, eventEmitter, blueprint, userRequestSummary, previousResources } = params;
|
|
106650
106960
|
const scaffolds = await (0, create_scaffolding_1.createScaffolding)(extension, outputPath, eventEmitter);
|
|
106651
106961
|
const embeddedScriptAgent = agentsFactory.getAgent(extension);
|
|
106962
|
+
await (0, codegen_flow_helpers_1.addAgentTask)(extension, embeddedScriptAgent.name);
|
|
106652
106963
|
eventEmitter.emitEvent("agent:start", {
|
|
106653
106964
|
extension,
|
|
106654
106965
|
name: embeddedScriptAgent.name
|
|
@@ -106662,7 +106973,7 @@ var require_embeddedScript = __commonJS({
|
|
|
106662
106973
|
...userRequestSummary && { userRequestSummary },
|
|
106663
106974
|
...previousResources && { previousResources }
|
|
106664
106975
|
});
|
|
106665
|
-
(0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106976
|
+
await (0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106666
106977
|
extension,
|
|
106667
106978
|
agentName: embeddedScriptAgent.name,
|
|
106668
106979
|
agentFiles: files,
|
|
@@ -106686,9 +106997,11 @@ var require_backendApi = __commonJS({
|
|
|
106686
106997
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
106687
106998
|
exports2.processBackendApiExtension = processBackendApiExtension;
|
|
106688
106999
|
var finalize_extension_generation_1 = require_finalize_extension_generation();
|
|
107000
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
106689
107001
|
async function processBackendApiExtension(params) {
|
|
106690
107002
|
const { extension, outputPath, plan, agentsFactory, eventEmitter, blueprint, userRequestSummary, previousResources } = params;
|
|
106691
107003
|
const backendApiAgent = agentsFactory.getAgent(extension);
|
|
107004
|
+
await (0, codegen_flow_helpers_1.addAgentTask)(extension, backendApiAgent.name);
|
|
106692
107005
|
eventEmitter.emitEvent("agent:start", {
|
|
106693
107006
|
extension,
|
|
106694
107007
|
name: backendApiAgent.name
|
|
@@ -106701,7 +107014,7 @@ var require_backendApi = __commonJS({
|
|
|
106701
107014
|
...userRequestSummary && { userRequestSummary },
|
|
106702
107015
|
...previousResources && { previousResources }
|
|
106703
107016
|
});
|
|
106704
|
-
(0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
107017
|
+
await (0, finalize_extension_generation_1.finalizeExtensionGeneration)({
|
|
106705
107018
|
extension,
|
|
106706
107019
|
agentName: backendApiAgent.name,
|
|
106707
107020
|
agentFiles: files,
|
|
@@ -106967,255 +107280,6 @@ var require_orchestrator = __commonJS({
|
|
|
106967
107280
|
}
|
|
106968
107281
|
});
|
|
106969
107282
|
|
|
106970
|
-
// ../../node_modules/@wix/ambassador-ctp-ditto-v1-blueprint/build/cjs/http.impl.js
|
|
106971
|
-
var require_http_impl2 = __commonJS({
|
|
106972
|
-
"../../node_modules/@wix/ambassador-ctp-ditto-v1-blueprint/build/cjs/http.impl.js"(exports2) {
|
|
106973
|
-
"use strict";
|
|
106974
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
106975
|
-
exports2.getRequiredPermissions = exports2.editBlueprint = exports2.createAppName = exports2.createBlueprint = void 0;
|
|
106976
|
-
var ambassador_1 = require_ambassador_index();
|
|
106977
|
-
var metro_runtime_1 = require_cjs2();
|
|
106978
|
-
var _createAppNameRequest = {};
|
|
106979
|
-
var _createAppNameResponse = {};
|
|
106980
|
-
var _createBlueprintRequest = {};
|
|
106981
|
-
var _createBlueprintResponse = {};
|
|
106982
|
-
var _editBlueprintRequest = {};
|
|
106983
|
-
var _editBlueprintResponse = {};
|
|
106984
|
-
var _getRequiredPermissionsRequest = {};
|
|
106985
|
-
var _getRequiredPermissionsResponse = {};
|
|
106986
|
-
function resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl(opts) {
|
|
106987
|
-
var domainToMappings = {
|
|
106988
|
-
"manage._base_domain_": [
|
|
106989
|
-
{
|
|
106990
|
-
srcPath: "/_api/ditto-blueprint-service-web",
|
|
106991
|
-
destPath: ""
|
|
106992
|
-
}
|
|
106993
|
-
]
|
|
106994
|
-
};
|
|
106995
|
-
return (0, metro_runtime_1.resolveUrl)(Object.assign(opts, { domainToMappings }));
|
|
106996
|
-
}
|
|
106997
|
-
function createBlueprint(payload) {
|
|
106998
|
-
var _a = (0, ambassador_1.serializer)(_createBlueprintRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
|
|
106999
|
-
var fromRes = (0, ambassador_1.serializer)(_createBlueprintResponse, {}).fromJSON;
|
|
107000
|
-
function __createBlueprint(_a2) {
|
|
107001
|
-
var host = _a2.host;
|
|
107002
|
-
var serializedData = toReq(payload);
|
|
107003
|
-
var metadata = {
|
|
107004
|
-
entityFqdn: "wix.ctp.ditto.v1.blueprint",
|
|
107005
|
-
method: "POST",
|
|
107006
|
-
methodFqn: "com.wixpress.ditto_blueprint_service.api.DittoBlueprintService.CreateBlueprint",
|
|
107007
|
-
migrationOptions: {
|
|
107008
|
-
optInTransformResponse: true
|
|
107009
|
-
},
|
|
107010
|
-
url: resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl({
|
|
107011
|
-
protoPath: "/v1/blueprints",
|
|
107012
|
-
data: serializedData,
|
|
107013
|
-
host
|
|
107014
|
-
}),
|
|
107015
|
-
data: serializedData,
|
|
107016
|
-
transformResponse: fromRes
|
|
107017
|
-
};
|
|
107018
|
-
return metadata;
|
|
107019
|
-
}
|
|
107020
|
-
__createBlueprint.fromReq = fromReq;
|
|
107021
|
-
__createBlueprint.__isAmbassador = true;
|
|
107022
|
-
return __createBlueprint;
|
|
107023
|
-
}
|
|
107024
|
-
exports2.createBlueprint = createBlueprint;
|
|
107025
|
-
function createAppName(payload) {
|
|
107026
|
-
var _a = (0, ambassador_1.serializer)(_createAppNameRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
|
|
107027
|
-
var fromRes = (0, ambassador_1.serializer)(_createAppNameResponse, {}).fromJSON;
|
|
107028
|
-
function __createAppName(_a2) {
|
|
107029
|
-
var host = _a2.host;
|
|
107030
|
-
var serializedData = toReq(payload);
|
|
107031
|
-
var metadata = {
|
|
107032
|
-
entityFqdn: "wix.ctp.ditto.v1.blueprint",
|
|
107033
|
-
method: "POST",
|
|
107034
|
-
methodFqn: "com.wixpress.ditto_blueprint_service.api.DittoBlueprintService.CreateAppName",
|
|
107035
|
-
migrationOptions: {
|
|
107036
|
-
optInTransformResponse: true
|
|
107037
|
-
},
|
|
107038
|
-
url: resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl({
|
|
107039
|
-
protoPath: "/v1/blueprints/app-name",
|
|
107040
|
-
data: serializedData,
|
|
107041
|
-
host
|
|
107042
|
-
}),
|
|
107043
|
-
data: serializedData,
|
|
107044
|
-
transformResponse: fromRes
|
|
107045
|
-
};
|
|
107046
|
-
return metadata;
|
|
107047
|
-
}
|
|
107048
|
-
__createAppName.fromReq = fromReq;
|
|
107049
|
-
__createAppName.__isAmbassador = true;
|
|
107050
|
-
return __createAppName;
|
|
107051
|
-
}
|
|
107052
|
-
exports2.createAppName = createAppName;
|
|
107053
|
-
function editBlueprint(payload) {
|
|
107054
|
-
var _a = (0, ambassador_1.serializer)(_editBlueprintRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
|
|
107055
|
-
var fromRes = (0, ambassador_1.serializer)(_editBlueprintResponse, {}).fromJSON;
|
|
107056
|
-
function __editBlueprint(_a2) {
|
|
107057
|
-
var host = _a2.host;
|
|
107058
|
-
var serializedData = toReq(payload);
|
|
107059
|
-
var metadata = {
|
|
107060
|
-
entityFqdn: "wix.ctp.ditto.v1.blueprint",
|
|
107061
|
-
method: "POST",
|
|
107062
|
-
methodFqn: "com.wixpress.ditto_blueprint_service.api.DittoBlueprintService.EditBlueprint",
|
|
107063
|
-
migrationOptions: {
|
|
107064
|
-
optInTransformResponse: true
|
|
107065
|
-
},
|
|
107066
|
-
url: resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl({
|
|
107067
|
-
protoPath: "/v1/blueprints/edit",
|
|
107068
|
-
data: serializedData,
|
|
107069
|
-
host
|
|
107070
|
-
}),
|
|
107071
|
-
data: serializedData,
|
|
107072
|
-
transformResponse: fromRes
|
|
107073
|
-
};
|
|
107074
|
-
return metadata;
|
|
107075
|
-
}
|
|
107076
|
-
__editBlueprint.fromReq = fromReq;
|
|
107077
|
-
__editBlueprint.__isAmbassador = true;
|
|
107078
|
-
return __editBlueprint;
|
|
107079
|
-
}
|
|
107080
|
-
exports2.editBlueprint = editBlueprint;
|
|
107081
|
-
function getRequiredPermissions(payload) {
|
|
107082
|
-
var _a = (0, ambassador_1.serializer)(_getRequiredPermissionsRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
|
|
107083
|
-
var fromRes = (0, ambassador_1.serializer)(_getRequiredPermissionsResponse, {}).fromJSON;
|
|
107084
|
-
function __getRequiredPermissions(_a2) {
|
|
107085
|
-
var host = _a2.host;
|
|
107086
|
-
var serializedData = toReq(payload);
|
|
107087
|
-
var metadata = {
|
|
107088
|
-
entityFqdn: "wix.ctp.ditto.v1.blueprint",
|
|
107089
|
-
method: "POST",
|
|
107090
|
-
methodFqn: "com.wixpress.ditto_blueprint_service.api.DittoBlueprintService.GetRequiredPermissions",
|
|
107091
|
-
migrationOptions: {
|
|
107092
|
-
optInTransformResponse: true
|
|
107093
|
-
},
|
|
107094
|
-
url: resolveComWixpressDittoBlueprintServiceApiDittoBlueprintServiceUrl({
|
|
107095
|
-
protoPath: "/v1/blueprints/required-permissions",
|
|
107096
|
-
data: serializedData,
|
|
107097
|
-
host
|
|
107098
|
-
}),
|
|
107099
|
-
data: serializedData,
|
|
107100
|
-
transformResponse: fromRes
|
|
107101
|
-
};
|
|
107102
|
-
return metadata;
|
|
107103
|
-
}
|
|
107104
|
-
__getRequiredPermissions.fromReq = fromReq;
|
|
107105
|
-
__getRequiredPermissions.__isAmbassador = true;
|
|
107106
|
-
return __getRequiredPermissions;
|
|
107107
|
-
}
|
|
107108
|
-
exports2.getRequiredPermissions = getRequiredPermissions;
|
|
107109
|
-
}
|
|
107110
|
-
});
|
|
107111
|
-
|
|
107112
|
-
// dist/flows/codegen-flow-helpers.js
|
|
107113
|
-
var require_codegen_flow_helpers = __commonJS({
|
|
107114
|
-
"dist/flows/codegen-flow-helpers.js"(exports2) {
|
|
107115
|
-
"use strict";
|
|
107116
|
-
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
107117
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
107118
|
-
};
|
|
107119
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
107120
|
-
exports2.setupAgentTaskTracking = setupAgentTaskTracking;
|
|
107121
|
-
exports2.updateJobPayload = updateJobPayload;
|
|
107122
|
-
exports2.updateParentTaskStatus = updateParentTaskStatus;
|
|
107123
|
-
exports2.getOutputPath = getOutputPath;
|
|
107124
|
-
exports2.getRequiredPermissions = getRequiredPermissions;
|
|
107125
|
-
var path_1 = __importDefault2(require("path"));
|
|
107126
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
107127
|
-
var ditto_codegen_types_12 = require_dist();
|
|
107128
|
-
var utils_1 = require_utils15();
|
|
107129
|
-
var http_1 = require_http_impl2();
|
|
107130
|
-
var http_client_1 = require_index_node();
|
|
107131
|
-
var orchestrator_1 = require_orchestrator();
|
|
107132
|
-
var AgentsFactory_1 = require_AgentsFactory();
|
|
107133
|
-
var slugify = (str = "") => {
|
|
107134
|
-
return str.toLowerCase().replace(/ /g, "-");
|
|
107135
|
-
};
|
|
107136
|
-
function setupAgentTaskTracking(eventEmitter, jobContext) {
|
|
107137
|
-
const getTaskId = (extension) => {
|
|
107138
|
-
return `${jobContext.taskId}-${slugify(extension.name)}`;
|
|
107139
|
-
};
|
|
107140
|
-
eventEmitter.onEvent("agent:start", ({ extension }) => {
|
|
107141
|
-
console.log(`[Agent] start: ${extension.name}`);
|
|
107142
|
-
const taskId = getTaskId(extension);
|
|
107143
|
-
codeGenerationService_12.codeGenerationService.addTask(jobContext.jobId, {
|
|
107144
|
-
id: taskId,
|
|
107145
|
-
kind: ditto_codegen_types_12.TaskKind.RUN_AGENT,
|
|
107146
|
-
status: ditto_codegen_types_12.Status.RUNNING,
|
|
107147
|
-
name: "run_agent",
|
|
107148
|
-
description: `Run agent for ${extension.name}`,
|
|
107149
|
-
payload: { extension },
|
|
107150
|
-
agentName: new AgentsFactory_1.AgentsFactory().getAgent(extension).name
|
|
107151
|
-
});
|
|
107152
|
-
});
|
|
107153
|
-
eventEmitter.onEvent("agent:done", ({ extension, files }) => {
|
|
107154
|
-
console.log(`[Agent] done: ${extension.name}`);
|
|
107155
|
-
const taskId = getTaskId(extension);
|
|
107156
|
-
codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, taskId, ditto_codegen_types_12.Status.COMPLETED, { taskOutput: { files } });
|
|
107157
|
-
});
|
|
107158
|
-
eventEmitter.onEvent("agent:error", async ({ extension, error }) => {
|
|
107159
|
-
console.error(`[Agent] error: ${extension.name}`, error);
|
|
107160
|
-
const taskId = getTaskId(extension);
|
|
107161
|
-
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, taskId, ditto_codegen_types_12.Status.FAILED, {
|
|
107162
|
-
error: (0, utils_1.serializeError)(error)
|
|
107163
|
-
});
|
|
107164
|
-
});
|
|
107165
|
-
const updateExtensionAgentTaskId = `${jobContext.taskId}-update-extension-agent`;
|
|
107166
|
-
eventEmitter.onEvent("updateExtensionAgent:start", () => {
|
|
107167
|
-
console.log(`[Agent] start: iterating existing code`);
|
|
107168
|
-
codeGenerationService_12.codeGenerationService.addTask(jobContext.jobId, {
|
|
107169
|
-
id: updateExtensionAgentTaskId,
|
|
107170
|
-
kind: ditto_codegen_types_12.TaskKind.RUN_AGENT,
|
|
107171
|
-
status: ditto_codegen_types_12.Status.RUNNING,
|
|
107172
|
-
name: "run_agent",
|
|
107173
|
-
description: "Iterating existing code",
|
|
107174
|
-
agentName: "UpdateExtensionAgent"
|
|
107175
|
-
});
|
|
107176
|
-
});
|
|
107177
|
-
eventEmitter.onEvent("updateExtensionAgent:done", ({ files }) => {
|
|
107178
|
-
console.log(`[Agent] done: iterating existing code`);
|
|
107179
|
-
codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, updateExtensionAgentTaskId, ditto_codegen_types_12.Status.COMPLETED, { taskOutput: { files } });
|
|
107180
|
-
});
|
|
107181
|
-
eventEmitter.onEvent("updateExtensionAgent:error", async ({ error }) => {
|
|
107182
|
-
console.error(`[Agent] error: iterating existing code`, error);
|
|
107183
|
-
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, updateExtensionAgentTaskId, ditto_codegen_types_12.Status.FAILED, {
|
|
107184
|
-
error: (0, utils_1.serializeError)(error)
|
|
107185
|
-
});
|
|
107186
|
-
});
|
|
107187
|
-
}
|
|
107188
|
-
async function updateJobPayload(jobContext, payload) {
|
|
107189
|
-
await codeGenerationService_12.codeGenerationService.updateJob(jobContext.jobId, payload);
|
|
107190
|
-
}
|
|
107191
|
-
async function updateParentTaskStatus(jobContext, status, error) {
|
|
107192
|
-
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, jobContext.taskId, status, error ? { error: (0, utils_1.serializeError)(error) } : {});
|
|
107193
|
-
}
|
|
107194
|
-
function getOutputPath() {
|
|
107195
|
-
const outputDir = process.env.OUTPUT_PATH || orchestrator_1.DittoOrchestrator.DEFAULT_OUTPUT_PATH;
|
|
107196
|
-
return outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
|
|
107197
|
-
}
|
|
107198
|
-
async function getRequiredPermissions(extensions) {
|
|
107199
|
-
const httpClient = (0, http_client_1.createHttpClient)({
|
|
107200
|
-
baseURL: "https://manage.wix.com"
|
|
107201
|
-
});
|
|
107202
|
-
return httpClient.request((0, http_1.getRequiredPermissions)({
|
|
107203
|
-
relatedApis: getRelatedApis(extensions ?? []),
|
|
107204
|
-
extensionTypes: getExtensionTypes(extensions ?? [])
|
|
107205
|
-
}));
|
|
107206
|
-
}
|
|
107207
|
-
function getExtensionTypes(extensions) {
|
|
107208
|
-
return Array.from(new Set((extensions ?? []).map(({ type }) => type).filter(Boolean)));
|
|
107209
|
-
}
|
|
107210
|
-
function getRelatedApis(extensions) {
|
|
107211
|
-
return Array.from(new Set((extensions ?? []).flatMap((ext) => [
|
|
107212
|
-
...(ext.relatedApis ?? []).map(({ name }) => name).filter(Boolean),
|
|
107213
|
-
...(ext.relatedSpis ?? []).map(({ name }) => name).filter(Boolean)
|
|
107214
|
-
])));
|
|
107215
|
-
}
|
|
107216
|
-
}
|
|
107217
|
-
});
|
|
107218
|
-
|
|
107219
107283
|
// dist/flows/init-codegen.js
|
|
107220
107284
|
var require_init_codegen = __commonJS({
|
|
107221
107285
|
"dist/flows/init-codegen.js"(exports2) {
|
|
@@ -107234,14 +107298,12 @@ var require_init_codegen = __commonJS({
|
|
|
107234
107298
|
var runInitCodegenFlow = async (blueprint, history) => {
|
|
107235
107299
|
const localJobContext = job_context_storage_12.jobContextStorage.getStore();
|
|
107236
107300
|
console.log(`[Init] Starting init codegen task: jobId=${localJobContext?.jobId}, taskId=${localJobContext?.taskId}`);
|
|
107237
|
-
await codeGenerationService_12.codeGenerationService.updateJobStatus(localJobContext.jobId, ditto_codegen_types_12.Status.RUNNING);
|
|
107238
107301
|
await codeGenerationService_12.codeGenerationService.updateTask(localJobContext.jobId, localJobContext.taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
107239
107302
|
console.log(`[Init] Marked task RUNNING: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`);
|
|
107240
107303
|
try {
|
|
107241
107304
|
const outputPath = (0, codegen_flow_helpers_1.getOutputPath)();
|
|
107242
107305
|
const agentsFactory = new AgentsFactory_1.AgentsFactory(false);
|
|
107243
107306
|
const orchestrator = new orchestrator_1.DittoOrchestrator(agentsFactory);
|
|
107244
|
-
(0, codegen_flow_helpers_1.setupAgentTaskTracking)(orchestrator, localJobContext);
|
|
107245
107307
|
(0, cli_listeners_1.attachOrchestratorListeners)(orchestrator);
|
|
107246
107308
|
try {
|
|
107247
107309
|
const requiredPermissionsResponse = await (0, codegen_flow_helpers_1.getRequiredPermissions)(blueprint?.extensions ?? []);
|
|
@@ -321047,6 +321109,7 @@ var require_IterationOrchestrator = __commonJS({
|
|
|
321047
321109
|
var write_file_1 = require_write_file();
|
|
321048
321110
|
var projectContext_1 = require_projectContext();
|
|
321049
321111
|
var ditto_codegen_types_12 = require_dist();
|
|
321112
|
+
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
321050
321113
|
var IterationOrchestrator = class extends DittoEventEmitter_1.DittoEventEmitter {
|
|
321051
321114
|
constructor(agentsFactory) {
|
|
321052
321115
|
super();
|
|
@@ -321145,6 +321208,7 @@ var require_IterationOrchestrator = __commonJS({
|
|
|
321145
321208
|
return iterationPlan;
|
|
321146
321209
|
}
|
|
321147
321210
|
async processExistingExtensions({ currentExtensions, userRequestSummary, outputPath, plan, previousResources }) {
|
|
321211
|
+
await (0, codegen_flow_helpers_1.addUpdateExtensionAgentTask)();
|
|
321148
321212
|
this.emitEvent("updateExtensionAgent:start", {});
|
|
321149
321213
|
try {
|
|
321150
321214
|
const updateExtensionAgent = this.agentsFactory.getAgent({
|
|
@@ -321157,10 +321221,12 @@ var require_IterationOrchestrator = __commonJS({
|
|
|
321157
321221
|
plan,
|
|
321158
321222
|
previousResources
|
|
321159
321223
|
});
|
|
321224
|
+
await (0, codegen_flow_helpers_1.completeUpdateExtensionAgentTask)(result.filesModified);
|
|
321160
321225
|
this.emitEvent("updateExtensionAgent:done", {
|
|
321161
321226
|
files: result.filesModified
|
|
321162
321227
|
});
|
|
321163
321228
|
} catch (error) {
|
|
321229
|
+
await (0, codegen_flow_helpers_1.failUpdateExtensionAgentTask)(error);
|
|
321164
321230
|
this.emitEvent("updateExtensionAgent:error", {
|
|
321165
321231
|
error: error instanceof Error ? error : new Error(String(error))
|
|
321166
321232
|
});
|
|
@@ -321305,14 +321371,12 @@ var require_iterate_codegen = __commonJS({
|
|
|
321305
321371
|
var runIterateCodegenFlow = async (chatHistory) => {
|
|
321306
321372
|
const localJobContext = job_context_storage_12.jobContextStorage.getStore();
|
|
321307
321373
|
console.log(`[Iterate] Starting iterate codegen task: jobId=${localJobContext?.jobId}, taskId=${localJobContext?.taskId}`);
|
|
321308
|
-
await codeGenerationService_12.codeGenerationService.updateJobStatus(localJobContext.jobId, ditto_codegen_types_12.Status.RUNNING);
|
|
321309
321374
|
await codeGenerationService_12.codeGenerationService.updateTask(localJobContext.jobId, localJobContext.taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
321310
321375
|
console.log(`[Init] Marked task RUNNING: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`);
|
|
321311
321376
|
try {
|
|
321312
321377
|
const outputPath = (0, codegen_flow_helpers_1.getOutputPath)();
|
|
321313
321378
|
const agentsFactory = new AgentsFactory_1.AgentsFactory(true);
|
|
321314
321379
|
const iterationOrchestrator = new IterationOrchestrator_1.IterationOrchestrator(agentsFactory);
|
|
321315
|
-
(0, codegen_flow_helpers_1.setupAgentTaskTracking)(iterationOrchestrator, localJobContext);
|
|
321316
321380
|
(0, cli_listeners_1.attachOrchestratorListeners)(iterationOrchestrator);
|
|
321317
321381
|
const { iterationPlan, previousResources } = await iterationOrchestrator.getContextualIterationPlan({
|
|
321318
321382
|
outputPath,
|
|
@@ -321482,6 +321546,7 @@ var alwaysOnLoop = async () => {
|
|
|
321482
321546
|
}
|
|
321483
321547
|
const job = jobs[0];
|
|
321484
321548
|
console.log(`[Loop] Selected job: jobId=${job.jobId}`);
|
|
321549
|
+
await codeGenerationService_1.codeGenerationService.markJobAsRuninng(job.jobId);
|
|
321485
321550
|
await processJob(job);
|
|
321486
321551
|
await codeGenerationService_1.codeGenerationService.markJobAsCompleted(job.jobId);
|
|
321487
321552
|
console.log(`[Loop] Processed job: jobId=${job.jobId}. Sleeping ${POST_JOB_SLEEP_MS}ms`);
|
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.226",
|
|
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": "
|
|
27
|
+
"falconPackageHash": "82af5e4235ba0fe3432dad3e3ccdf5255acdad91e28aa9dd98e0f760"
|
|
28
28
|
}
|