@wix/ditto-codegen-public 1.0.352 → 1.0.354
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 +477 -375
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -39,13 +39,62 @@ var require_types_impl = __commonJS({
|
|
|
39
39
|
"../../node_modules/@wix/ambassador-ctp-codegen-job-service-v1-job/cjs/build/types.impl.js"(exports2) {
|
|
40
40
|
"use strict";
|
|
41
41
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
42
|
-
exports2.UserDecisionQuestionType = exports2.TaskKind = exports2.Status = exports2.Environment = void 0;
|
|
42
|
+
exports2.UserDecisionQuestionType = exports2.TaskKind = exports2.Status = exports2.ProcessType = exports2.FileOperation = exports2.ErrorType = exports2.Environment = exports2.ChatMessageRole = exports2.ExtensionType = void 0;
|
|
43
|
+
var ExtensionType;
|
|
44
|
+
(function(ExtensionType2) {
|
|
45
|
+
ExtensionType2["UNDEFINED_EXTENSION_TYPE"] = "UNDEFINED_EXTENSION_TYPE";
|
|
46
|
+
ExtensionType2["DASHBOARD_PAGE"] = "DASHBOARD_PAGE";
|
|
47
|
+
ExtensionType2["DASHBOARD_PLUGIN"] = "DASHBOARD_PLUGIN";
|
|
48
|
+
ExtensionType2["DASHBOARD_MODAL"] = "DASHBOARD_MODAL";
|
|
49
|
+
ExtensionType2["SITE_WIDGET"] = "SITE_WIDGET";
|
|
50
|
+
ExtensionType2["EMBEDDED_SCRIPT"] = "EMBEDDED_SCRIPT";
|
|
51
|
+
ExtensionType2["BACKEND_API"] = "BACKEND_API";
|
|
52
|
+
ExtensionType2["BACKEND_EVENT"] = "BACKEND_EVENT";
|
|
53
|
+
ExtensionType2["SERVICE_PLUGIN"] = "SERVICE_PLUGIN";
|
|
54
|
+
ExtensionType2["WEB_METHODS"] = "WEB_METHODS";
|
|
55
|
+
ExtensionType2["SITE_COMPONENT"] = "SITE_COMPONENT";
|
|
56
|
+
ExtensionType2["WEBHOOK"] = "WEBHOOK";
|
|
57
|
+
ExtensionType2["SITE_PLUGIN"] = "SITE_PLUGIN";
|
|
58
|
+
ExtensionType2["DATA_COLLECTION"] = "DATA_COLLECTION";
|
|
59
|
+
ExtensionType2["DASHBOARD_MENU_PLUGIN"] = "DASHBOARD_MENU_PLUGIN";
|
|
60
|
+
ExtensionType2["CUSTOM_ELEMENT_WIDGET"] = "CUSTOM_ELEMENT_WIDGET";
|
|
61
|
+
ExtensionType2["EDITOR_REACT_COMPONENT"] = "EDITOR_REACT_COMPONENT";
|
|
62
|
+
})(ExtensionType || (exports2.ExtensionType = ExtensionType = {}));
|
|
63
|
+
var ChatMessageRole;
|
|
64
|
+
(function(ChatMessageRole2) {
|
|
65
|
+
ChatMessageRole2["UNKNOWN_CHAT_MESSAGE_ROLE"] = "UNKNOWN_CHAT_MESSAGE_ROLE";
|
|
66
|
+
ChatMessageRole2["USER"] = "USER";
|
|
67
|
+
ChatMessageRole2["ASSISTANT"] = "ASSISTANT";
|
|
68
|
+
})(ChatMessageRole || (exports2.ChatMessageRole = ChatMessageRole = {}));
|
|
43
69
|
var Environment;
|
|
44
70
|
(function(Environment2) {
|
|
45
71
|
Environment2["UNKNOWN_ENVIRONMENT"] = "UNKNOWN_ENVIRONMENT";
|
|
46
72
|
Environment2["APP_BUILDER"] = "APP_BUILDER";
|
|
47
73
|
Environment2["STUDIO_2"] = "STUDIO_2";
|
|
74
|
+
Environment2["HARMONY"] = "HARMONY";
|
|
48
75
|
})(Environment || (exports2.Environment = Environment = {}));
|
|
76
|
+
var ErrorType;
|
|
77
|
+
(function(ErrorType2) {
|
|
78
|
+
ErrorType2["UNKNOWN_ERROR_TYPE"] = "UNKNOWN_ERROR_TYPE";
|
|
79
|
+
ErrorType2["TIMEOUT_ERROR"] = "TIMEOUT_ERROR";
|
|
80
|
+
ErrorType2["PROCESS_EXECUTION_ERROR"] = "PROCESS_EXECUTION_ERROR";
|
|
81
|
+
ErrorType2["UNEXPECTED_ERROR"] = "UNEXPECTED_ERROR";
|
|
82
|
+
ErrorType2["MISSING_JOB_ID_ERROR"] = "MISSING_JOB_ID_ERROR";
|
|
83
|
+
})(ErrorType || (exports2.ErrorType = ErrorType = {}));
|
|
84
|
+
var FileOperation;
|
|
85
|
+
(function(FileOperation2) {
|
|
86
|
+
FileOperation2["UNKNOWN_FILE_OPERATION"] = "UNKNOWN_FILE_OPERATION";
|
|
87
|
+
FileOperation2["INSERT"] = "INSERT";
|
|
88
|
+
FileOperation2["DELETE"] = "DELETE";
|
|
89
|
+
FileOperation2["EDIT"] = "EDIT";
|
|
90
|
+
})(FileOperation || (exports2.FileOperation = FileOperation = {}));
|
|
91
|
+
var ProcessType;
|
|
92
|
+
(function(ProcessType2) {
|
|
93
|
+
ProcessType2["UNKNOWN_PROCESS_TYPE"] = "UNKNOWN_PROCESS_TYPE";
|
|
94
|
+
ProcessType2["SPAWN"] = "SPAWN";
|
|
95
|
+
ProcessType2["EXECUTION"] = "EXECUTION";
|
|
96
|
+
ProcessType2["INITIALIZATION"] = "INITIALIZATION";
|
|
97
|
+
})(ProcessType || (exports2.ProcessType = ProcessType = {}));
|
|
49
98
|
var Status;
|
|
50
99
|
(function(Status2) {
|
|
51
100
|
Status2["UNKNOWN_STATUS"] = "UNKNOWN_STATUS";
|
|
@@ -65,6 +114,7 @@ var require_types_impl = __commonJS({
|
|
|
65
114
|
TaskKind2["RUN_AGENT"] = "RUN_AGENT";
|
|
66
115
|
TaskKind2["FIX_CODE"] = "FIX_CODE";
|
|
67
116
|
TaskKind2["ASK_CODEGEN"] = "ASK_CODEGEN";
|
|
117
|
+
TaskKind2["FIX_GIT_CONFLICTS"] = "FIX_GIT_CONFLICTS";
|
|
68
118
|
})(TaskKind || (exports2.TaskKind = TaskKind = {}));
|
|
69
119
|
var UserDecisionQuestionType;
|
|
70
120
|
(function(UserDecisionQuestionType2) {
|
|
@@ -10335,373 +10385,65 @@ var require_wixTokenRefresh = __commonJS({
|
|
|
10335
10385
|
}
|
|
10336
10386
|
});
|
|
10337
10387
|
|
|
10338
|
-
// dist/
|
|
10339
|
-
var
|
|
10340
|
-
"dist/
|
|
10388
|
+
// ../codegen-types/dist/errors/ErrorTypes.js
|
|
10389
|
+
var require_ErrorTypes = __commonJS({
|
|
10390
|
+
"../codegen-types/dist/errors/ErrorTypes.js"(exports2) {
|
|
10341
10391
|
"use strict";
|
|
10342
10392
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10343
|
-
exports2.
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
const resp = await this.request((0, http_1.listProjectJobs)({
|
|
10398
|
-
projectId: this.projectId
|
|
10399
|
-
}));
|
|
10400
|
-
const jobs = resp.data?.jobs ?? [];
|
|
10401
|
-
return jobs.filter(this.shouldProcessJob);
|
|
10402
|
-
};
|
|
10403
|
-
this.shouldProcessJob = (job) => {
|
|
10404
|
-
if (job.status !== types_1.Status.PENDING)
|
|
10405
|
-
return false;
|
|
10406
|
-
if (this.sandboxId)
|
|
10407
|
-
return job.sandboxId === this.sandboxId;
|
|
10408
|
-
return true;
|
|
10409
|
-
};
|
|
10410
|
-
this.markJobAsCompleted = async (jobId) => {
|
|
10411
|
-
await this.request((0, http_1.updateJob)({
|
|
10412
|
-
projectId: this.projectId,
|
|
10413
|
-
job: {
|
|
10414
|
-
id: jobId,
|
|
10415
|
-
projectId: this.projectId,
|
|
10416
|
-
status: types_1.Status.COMPLETED
|
|
10417
|
-
}
|
|
10418
|
-
}));
|
|
10419
|
-
};
|
|
10420
|
-
this.markJobAsRuninng = async (jobId) => {
|
|
10421
|
-
await this.request((0, http_1.updateJob)({
|
|
10422
|
-
projectId: this.projectId,
|
|
10423
|
-
job: {
|
|
10424
|
-
id: jobId,
|
|
10425
|
-
projectId: this.projectId,
|
|
10426
|
-
status: types_1.Status.RUNNING
|
|
10427
|
-
}
|
|
10428
|
-
}));
|
|
10429
|
-
};
|
|
10430
|
-
this.markJobAsCancelled = async (jobId) => {
|
|
10431
|
-
await this.request((0, http_1.updateJob)({
|
|
10432
|
-
projectId: this.projectId,
|
|
10433
|
-
job: {
|
|
10434
|
-
id: jobId,
|
|
10435
|
-
projectId: this.projectId,
|
|
10436
|
-
status: types_1.Status.CANCELLED
|
|
10437
|
-
}
|
|
10438
|
-
}));
|
|
10439
|
-
};
|
|
10440
|
-
this.updateJob = async (jobId, payload) => {
|
|
10441
|
-
await this.request((0, http_1.updateJob)({
|
|
10442
|
-
projectId: this.projectId,
|
|
10443
|
-
job: {
|
|
10444
|
-
id: jobId,
|
|
10445
|
-
projectId: this.projectId,
|
|
10446
|
-
payload
|
|
10447
|
-
}
|
|
10448
|
-
}));
|
|
10449
|
-
};
|
|
10450
|
-
this.updateJobStatus = async (jobId, status) => {
|
|
10451
|
-
logger_12.logger.info("Updating job status", {
|
|
10452
|
-
jobId,
|
|
10453
|
-
status
|
|
10454
|
-
});
|
|
10455
|
-
await this.request((0, http_1.updateJob)({
|
|
10456
|
-
projectId: this.projectId,
|
|
10457
|
-
job: {
|
|
10458
|
-
id: jobId,
|
|
10459
|
-
projectId: this.projectId,
|
|
10460
|
-
status
|
|
10461
|
-
}
|
|
10462
|
-
}));
|
|
10463
|
-
};
|
|
10464
|
-
this.updateJobWithPendingDecision = async (jobId, userDecision) => {
|
|
10465
|
-
logger_12.logger.info("Setting job to await user decision", {
|
|
10466
|
-
jobId,
|
|
10467
|
-
decisionId: userDecision.id,
|
|
10468
|
-
userDecision: JSON.stringify(userDecision, null, 2)
|
|
10469
|
-
});
|
|
10470
|
-
await this.request((0, http_1.updateJob)({
|
|
10471
|
-
projectId: this.projectId,
|
|
10472
|
-
job: {
|
|
10473
|
-
id: jobId,
|
|
10474
|
-
projectId: this.projectId,
|
|
10475
|
-
status: types_1.Status.AWAITING_USER_INPUT,
|
|
10476
|
-
pendingUserDecisions: [userDecision]
|
|
10477
|
-
}
|
|
10478
|
-
}));
|
|
10479
|
-
};
|
|
10480
|
-
this.resumeJobFromDecision = async (jobId) => {
|
|
10481
|
-
logger_12.logger.info("Resuming job from user decision");
|
|
10482
|
-
await this.request((0, http_1.updateJob)({
|
|
10483
|
-
projectId: this.projectId,
|
|
10484
|
-
job: {
|
|
10485
|
-
id: jobId,
|
|
10486
|
-
projectId: this.projectId,
|
|
10487
|
-
status: types_1.Status.RUNNING,
|
|
10488
|
-
pendingUserDecisions: []
|
|
10489
|
-
}
|
|
10490
|
-
}));
|
|
10491
|
-
};
|
|
10492
|
-
this.updateTask = async (jobId, taskId, status, payload) => {
|
|
10493
|
-
await this.request((0, http_1.updateTask)({
|
|
10494
|
-
projectId: this.projectId,
|
|
10495
|
-
jobId,
|
|
10496
|
-
task: {
|
|
10497
|
-
id: taskId,
|
|
10498
|
-
status,
|
|
10499
|
-
payload
|
|
10500
|
-
}
|
|
10501
|
-
}));
|
|
10502
|
-
};
|
|
10503
|
-
this.addTask = async (jobId, task) => {
|
|
10504
|
-
await this.request((0, http_1.createTask)({
|
|
10505
|
-
projectId: this.projectId,
|
|
10506
|
-
jobId,
|
|
10507
|
-
task: {
|
|
10508
|
-
id: task.id,
|
|
10509
|
-
kind: task.kind,
|
|
10510
|
-
name: task.name,
|
|
10511
|
-
status: task.status,
|
|
10512
|
-
payload: task.payload,
|
|
10513
|
-
agentName: task.agentName,
|
|
10514
|
-
description: typeof task?.description === "string" ? task.description : task?.payload ? JSON.stringify(task.payload) : ""
|
|
10515
|
-
}
|
|
10516
|
-
}));
|
|
10517
|
-
};
|
|
10518
|
-
this.getJob = async (jobId) => {
|
|
10519
|
-
const resp = await this.request((0, http_1.getJob)({
|
|
10520
|
-
projectId: this.projectId,
|
|
10521
|
-
jobId
|
|
10522
|
-
}));
|
|
10523
|
-
return resp.data?.job ?? null;
|
|
10524
|
-
};
|
|
10525
|
-
if (httpClient) {
|
|
10526
|
-
this.httpClient = httpClient;
|
|
10527
|
-
return;
|
|
10528
|
-
}
|
|
10529
|
-
const serverUrl = process.env.CODEGEN_SERVER_BASE_URL || "https://manage.wix.com";
|
|
10530
|
-
this.httpClient = (0, http_client_1.createHttpClient)({
|
|
10531
|
-
baseURL: serverUrl,
|
|
10532
|
-
errorHandler: createCodeGenErrorHandler(() => this.httpClient)
|
|
10533
|
-
});
|
|
10534
|
-
}
|
|
10535
|
-
getAccessToken() {
|
|
10536
|
-
return this.accessToken;
|
|
10537
|
-
}
|
|
10538
|
-
setAccessToken(token) {
|
|
10539
|
-
this.accessToken = token;
|
|
10540
|
-
}
|
|
10541
|
-
isUnauthorized(error) {
|
|
10542
|
-
if (!http_client_1.HttpClient.isHttpError(error))
|
|
10543
|
-
return false;
|
|
10544
|
-
if (this.httpClient.isCancel(error))
|
|
10545
|
-
return false;
|
|
10546
|
-
return error.response?.status === 401;
|
|
10547
|
-
}
|
|
10548
|
-
withAuth(req) {
|
|
10549
|
-
const authHeader = { authorization: `Bearer ${this.accessToken}` };
|
|
10550
|
-
if (typeof req === "function") {
|
|
10551
|
-
return (ctx) => {
|
|
10552
|
-
const r = req(ctx);
|
|
10553
|
-
return { ...r, headers: { ...r.headers ?? {}, ...authHeader } };
|
|
10554
|
-
};
|
|
10555
|
-
}
|
|
10556
|
-
return { ...req, headers: { ...req.headers ?? {}, ...authHeader } };
|
|
10557
|
-
}
|
|
10558
|
-
};
|
|
10559
|
-
exports2.CodeGenService = CodeGenService;
|
|
10560
|
-
}
|
|
10561
|
-
});
|
|
10562
|
-
|
|
10563
|
-
// dist/services/codeGenerationService.js
|
|
10564
|
-
var require_codeGenerationService = __commonJS({
|
|
10565
|
-
"dist/services/codeGenerationService.js"(exports2) {
|
|
10566
|
-
"use strict";
|
|
10567
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10568
|
-
exports2.codeGenerationService = void 0;
|
|
10569
|
-
var CodeGenService_12 = require_CodeGenService();
|
|
10570
|
-
var context_12 = require_context();
|
|
10571
|
-
exports2.codeGenerationService = new CodeGenService_12.CodeGenService(context_12.ctx.projectId);
|
|
10572
|
-
}
|
|
10573
|
-
});
|
|
10574
|
-
|
|
10575
|
-
// dist/events/cli-listeners.js
|
|
10576
|
-
var require_cli_listeners = __commonJS({
|
|
10577
|
-
"dist/events/cli-listeners.js"(exports2) {
|
|
10578
|
-
"use strict";
|
|
10579
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10580
|
-
exports2.attachOrchestratorListeners = attachOrchestratorListeners;
|
|
10581
|
-
var logger_12 = require_logger();
|
|
10582
|
-
function attachOrchestratorListeners(eventEmitter) {
|
|
10583
|
-
eventEmitter.onEvent("start:init", (info) => {
|
|
10584
|
-
logger_12.logger.info("\u{1F680} Starting initial code generation for app", {
|
|
10585
|
-
appName: info.appName,
|
|
10586
|
-
summary: info.summary,
|
|
10587
|
-
outputPath: info.outputPath,
|
|
10588
|
-
extensionsCount: info.extensionsCount
|
|
10589
|
-
});
|
|
10590
|
-
});
|
|
10591
|
-
eventEmitter.onEvent("start:iteration", ({ outputPath }) => {
|
|
10592
|
-
logger_12.logger.info("\u{1F680} Starting code iteration", { outputPath });
|
|
10593
|
-
});
|
|
10594
|
-
eventEmitter.onEvent("start:ask", ({ outputPath }) => {
|
|
10595
|
-
logger_12.logger.info("\u{1F680} Starting ask", { outputPath });
|
|
10596
|
-
});
|
|
10597
|
-
eventEmitter.onEvent("finish:init", ({ outputPath, durationMs }) => {
|
|
10598
|
-
logger_12.logger.info("\u2705 Init completed", {
|
|
10599
|
-
outputPath,
|
|
10600
|
-
durationMs,
|
|
10601
|
-
durationFormatted: getFormattedDuration(durationMs)
|
|
10602
|
-
});
|
|
10603
|
-
});
|
|
10604
|
-
eventEmitter.onEvent("finish:iteration", ({ outputPath, durationMs }) => {
|
|
10605
|
-
logger_12.logger.info("\u2705 Iteration completed", {
|
|
10606
|
-
outputPath,
|
|
10607
|
-
durationMs,
|
|
10608
|
-
durationFormatted: getFormattedDuration(durationMs)
|
|
10609
|
-
});
|
|
10610
|
-
});
|
|
10611
|
-
eventEmitter.onEvent("finish:ask", ({ durationMs }) => {
|
|
10612
|
-
logger_12.logger.info("\u2705 Ask completed", {
|
|
10613
|
-
durationMs,
|
|
10614
|
-
durationFormatted: getFormattedDuration(durationMs)
|
|
10615
|
-
});
|
|
10616
|
-
});
|
|
10617
|
-
eventEmitter.onEvent("opencode:start", ({ outputPath }) => {
|
|
10618
|
-
logger_12.logger.info("\u{1F527} OpenCode starting", { outputPath });
|
|
10619
|
-
});
|
|
10620
|
-
eventEmitter.onEvent("opencode:output", ({ data }) => {
|
|
10621
|
-
process.stdout.write(data);
|
|
10622
|
-
});
|
|
10623
|
-
eventEmitter.onEvent("opencode:done", ({ durationMs }) => {
|
|
10624
|
-
logger_12.logger.info("\u{1F527} OpenCode completed", {
|
|
10625
|
-
durationMs,
|
|
10626
|
-
durationFormatted: getFormattedDuration(durationMs)
|
|
10627
|
-
});
|
|
10628
|
-
});
|
|
10629
|
-
eventEmitter.onEvent("opencode:error", ({ error, exitCode, durationMs }) => {
|
|
10630
|
-
logger_12.logger.error("\u274C OpenCode failed", {
|
|
10631
|
-
error,
|
|
10632
|
-
exitCode,
|
|
10633
|
-
durationMs,
|
|
10634
|
-
durationFormatted: getFormattedDuration(durationMs)
|
|
10635
|
-
});
|
|
10636
|
-
});
|
|
10637
|
-
}
|
|
10638
|
-
var getFormattedDuration = (ms) => {
|
|
10639
|
-
const seconds = ms / 1e3;
|
|
10640
|
-
const minutes = seconds / 60;
|
|
10641
|
-
return `${ms} ms (${minutes.toFixed(2)} min or ${seconds.toFixed(2)} sec)`;
|
|
10642
|
-
};
|
|
10643
|
-
}
|
|
10644
|
-
});
|
|
10645
|
-
|
|
10646
|
-
// ../codegen-types/dist/errors/ErrorTypes.js
|
|
10647
|
-
var require_ErrorTypes = __commonJS({
|
|
10648
|
-
"../codegen-types/dist/errors/ErrorTypes.js"(exports2) {
|
|
10649
|
-
"use strict";
|
|
10650
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10651
|
-
exports2.ErrorType = void 0;
|
|
10652
|
-
var ErrorType;
|
|
10653
|
-
(function(ErrorType2) {
|
|
10654
|
-
ErrorType2["TIMEOUT_ERROR"] = "TIMEOUT_ERROR";
|
|
10655
|
-
ErrorType2["PROCESS_EXECUTION_ERROR"] = "PROCESS_EXECUTION_ERROR";
|
|
10656
|
-
ErrorType2["UNEXPECTED_ERROR"] = "UNEXPECTED_ERROR";
|
|
10657
|
-
ErrorType2["MISSING_JOB_ID_ERROR"] = "MISSING_JOB_ID_ERROR";
|
|
10658
|
-
})(ErrorType || (exports2.ErrorType = ErrorType = {}));
|
|
10659
|
-
}
|
|
10660
|
-
});
|
|
10661
|
-
|
|
10662
|
-
// ../codegen-types/dist/errors/enums.js
|
|
10663
|
-
var require_enums = __commonJS({
|
|
10664
|
-
"../codegen-types/dist/errors/enums.js"(exports2) {
|
|
10665
|
-
"use strict";
|
|
10666
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10667
|
-
exports2.ExtensionGenerationOperation = exports2.ProcessType = void 0;
|
|
10668
|
-
var ProcessType;
|
|
10669
|
-
(function(ProcessType2) {
|
|
10670
|
-
ProcessType2["SPAWN"] = "spawn";
|
|
10671
|
-
ProcessType2["EXECUTION"] = "execution";
|
|
10672
|
-
ProcessType2["INITIALIZATION"] = "initialization";
|
|
10673
|
-
})(ProcessType || (exports2.ProcessType = ProcessType = {}));
|
|
10674
|
-
var ExtensionGenerationOperation;
|
|
10675
|
-
(function(ExtensionGenerationOperation2) {
|
|
10676
|
-
ExtensionGenerationOperation2["INSERT"] = "insert";
|
|
10677
|
-
ExtensionGenerationOperation2["DELETE"] = "delete";
|
|
10678
|
-
ExtensionGenerationOperation2["EDIT"] = "edit";
|
|
10679
|
-
})(ExtensionGenerationOperation || (exports2.ExtensionGenerationOperation = ExtensionGenerationOperation = {}));
|
|
10680
|
-
}
|
|
10681
|
-
});
|
|
10682
|
-
|
|
10683
|
-
// ../codegen-types/dist/errors/BaseCodegenError.js
|
|
10684
|
-
var require_BaseCodegenError = __commonJS({
|
|
10685
|
-
"../codegen-types/dist/errors/BaseCodegenError.js"(exports2) {
|
|
10686
|
-
"use strict";
|
|
10687
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10688
|
-
exports2.BaseCodegenError = void 0;
|
|
10689
|
-
var BaseCodegenError = class extends Error {
|
|
10690
|
-
constructor(message) {
|
|
10691
|
-
super(message);
|
|
10692
|
-
}
|
|
10693
|
-
/**
|
|
10694
|
-
* Convert error to JSON format for API responses
|
|
10695
|
-
*/
|
|
10696
|
-
toJSON() {
|
|
10697
|
-
const additional = this.getAdditionalProperties();
|
|
10698
|
-
return {
|
|
10699
|
-
name: this.name,
|
|
10700
|
-
message: this.message,
|
|
10701
|
-
errorType: this.errorType,
|
|
10702
|
-
retryable: this.retryable,
|
|
10703
|
-
expected: this.expected,
|
|
10704
|
-
...Object.keys(additional).length > 0 ? additional : {}
|
|
10393
|
+
exports2.ErrorType = void 0;
|
|
10394
|
+
var ErrorType;
|
|
10395
|
+
(function(ErrorType2) {
|
|
10396
|
+
ErrorType2["TIMEOUT_ERROR"] = "TIMEOUT_ERROR";
|
|
10397
|
+
ErrorType2["PROCESS_EXECUTION_ERROR"] = "PROCESS_EXECUTION_ERROR";
|
|
10398
|
+
ErrorType2["UNEXPECTED_ERROR"] = "UNEXPECTED_ERROR";
|
|
10399
|
+
ErrorType2["MISSING_JOB_ID_ERROR"] = "MISSING_JOB_ID_ERROR";
|
|
10400
|
+
})(ErrorType || (exports2.ErrorType = ErrorType = {}));
|
|
10401
|
+
}
|
|
10402
|
+
});
|
|
10403
|
+
|
|
10404
|
+
// ../codegen-types/dist/errors/enums.js
|
|
10405
|
+
var require_enums = __commonJS({
|
|
10406
|
+
"../codegen-types/dist/errors/enums.js"(exports2) {
|
|
10407
|
+
"use strict";
|
|
10408
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10409
|
+
exports2.ExtensionGenerationOperation = exports2.ProcessType = void 0;
|
|
10410
|
+
var ProcessType;
|
|
10411
|
+
(function(ProcessType2) {
|
|
10412
|
+
ProcessType2["SPAWN"] = "spawn";
|
|
10413
|
+
ProcessType2["EXECUTION"] = "execution";
|
|
10414
|
+
ProcessType2["INITIALIZATION"] = "initialization";
|
|
10415
|
+
})(ProcessType || (exports2.ProcessType = ProcessType = {}));
|
|
10416
|
+
var ExtensionGenerationOperation;
|
|
10417
|
+
(function(ExtensionGenerationOperation2) {
|
|
10418
|
+
ExtensionGenerationOperation2["INSERT"] = "insert";
|
|
10419
|
+
ExtensionGenerationOperation2["DELETE"] = "delete";
|
|
10420
|
+
ExtensionGenerationOperation2["EDIT"] = "edit";
|
|
10421
|
+
})(ExtensionGenerationOperation || (exports2.ExtensionGenerationOperation = ExtensionGenerationOperation = {}));
|
|
10422
|
+
}
|
|
10423
|
+
});
|
|
10424
|
+
|
|
10425
|
+
// ../codegen-types/dist/errors/BaseCodegenError.js
|
|
10426
|
+
var require_BaseCodegenError = __commonJS({
|
|
10427
|
+
"../codegen-types/dist/errors/BaseCodegenError.js"(exports2) {
|
|
10428
|
+
"use strict";
|
|
10429
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10430
|
+
exports2.BaseCodegenError = void 0;
|
|
10431
|
+
var BaseCodegenError = class extends Error {
|
|
10432
|
+
constructor(message) {
|
|
10433
|
+
super(message);
|
|
10434
|
+
}
|
|
10435
|
+
/**
|
|
10436
|
+
* Convert error to JSON format for API responses
|
|
10437
|
+
*/
|
|
10438
|
+
toJSON() {
|
|
10439
|
+
const additional = this.getAdditionalProperties();
|
|
10440
|
+
return {
|
|
10441
|
+
name: this.name,
|
|
10442
|
+
message: this.message,
|
|
10443
|
+
errorType: this.errorType,
|
|
10444
|
+
retryable: this.retryable,
|
|
10445
|
+
expected: this.expected,
|
|
10446
|
+
...Object.keys(additional).length > 0 ? additional : {}
|
|
10705
10447
|
};
|
|
10706
10448
|
}
|
|
10707
10449
|
/**
|
|
@@ -11021,6 +10763,363 @@ var require_dist4 = __commonJS({
|
|
|
11021
10763
|
}
|
|
11022
10764
|
});
|
|
11023
10765
|
|
|
10766
|
+
// dist/services/CodeGenService.js
|
|
10767
|
+
var require_CodeGenService = __commonJS({
|
|
10768
|
+
"dist/services/CodeGenService.js"(exports2) {
|
|
10769
|
+
"use strict";
|
|
10770
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10771
|
+
exports2.CodeGenService = exports2.TaskKind = exports2.Status = void 0;
|
|
10772
|
+
exports2.createCodeGenErrorHandler = createCodeGenErrorHandler;
|
|
10773
|
+
var http_client_1 = require_index_node();
|
|
10774
|
+
var http_1 = require_http_impl();
|
|
10775
|
+
var wixTokenRefresh_1 = require_wixTokenRefresh();
|
|
10776
|
+
var types_1 = require_types_impl();
|
|
10777
|
+
Object.defineProperty(exports2, "Status", { enumerable: true, get: function() {
|
|
10778
|
+
return types_1.Status;
|
|
10779
|
+
} });
|
|
10780
|
+
Object.defineProperty(exports2, "TaskKind", { enumerable: true, get: function() {
|
|
10781
|
+
return types_1.TaskKind;
|
|
10782
|
+
} });
|
|
10783
|
+
var logger_12 = require_logger();
|
|
10784
|
+
var ditto_codegen_types_12 = require_dist4();
|
|
10785
|
+
var FILE_OPERATION = {
|
|
10786
|
+
[ditto_codegen_types_12.ExtensionGenerationOperation.INSERT]: types_1.FileOperation.INSERT,
|
|
10787
|
+
[ditto_codegen_types_12.ExtensionGenerationOperation.DELETE]: types_1.FileOperation.DELETE,
|
|
10788
|
+
[ditto_codegen_types_12.ExtensionGenerationOperation.EDIT]: types_1.FileOperation.EDIT
|
|
10789
|
+
};
|
|
10790
|
+
var PROCESS_TYPE = {
|
|
10791
|
+
[ditto_codegen_types_12.ProcessType.SPAWN]: types_1.ProcessType.SPAWN,
|
|
10792
|
+
[ditto_codegen_types_12.ProcessType.EXECUTION]: types_1.ProcessType.EXECUTION,
|
|
10793
|
+
[ditto_codegen_types_12.ProcessType.INITIALIZATION]: types_1.ProcessType.INITIALIZATION
|
|
10794
|
+
};
|
|
10795
|
+
function toApiError(error) {
|
|
10796
|
+
if (!error)
|
|
10797
|
+
return void 0;
|
|
10798
|
+
return {
|
|
10799
|
+
name: error.name,
|
|
10800
|
+
message: error.message,
|
|
10801
|
+
errorType: error.errorType,
|
|
10802
|
+
retryable: error.retryable,
|
|
10803
|
+
expected: error.expected,
|
|
10804
|
+
..."processType" in error && error.processType && { processType: PROCESS_TYPE[error.processType] },
|
|
10805
|
+
..."exitCode" in error && { exitCode: error.exitCode },
|
|
10806
|
+
..."stderr" in error && { stderr: error.stderr }
|
|
10807
|
+
};
|
|
10808
|
+
}
|
|
10809
|
+
function toJobOutput(payload) {
|
|
10810
|
+
const { requiredPermissions, files, extensions, error, agentMessage, ...rest } = payload;
|
|
10811
|
+
return {
|
|
10812
|
+
requiredPermissions,
|
|
10813
|
+
files: files?.map((file) => ({
|
|
10814
|
+
path: file.path,
|
|
10815
|
+
operation: FILE_OPERATION[file.operation] ?? types_1.FileOperation.UNKNOWN_FILE_OPERATION
|
|
10816
|
+
})),
|
|
10817
|
+
extensions: extensions?.created?.map((ext) => ({
|
|
10818
|
+
path: ext.path,
|
|
10819
|
+
extensionType: ext.extensionType,
|
|
10820
|
+
title: ext.title,
|
|
10821
|
+
files: ext.files.map((f) => ({
|
|
10822
|
+
path: f.path,
|
|
10823
|
+
operation: FILE_OPERATION[f.operation] ?? types_1.FileOperation.UNKNOWN_FILE_OPERATION
|
|
10824
|
+
}))
|
|
10825
|
+
})),
|
|
10826
|
+
error: toApiError(error),
|
|
10827
|
+
agentMessage,
|
|
10828
|
+
agentOutput: Object.keys(rest).length > 0 ? rest : void 0
|
|
10829
|
+
};
|
|
10830
|
+
}
|
|
10831
|
+
function createCodeGenErrorHandler(getHttpClient) {
|
|
10832
|
+
return {
|
|
10833
|
+
handleError: (error, { requestOptions }) => {
|
|
10834
|
+
if (!http_client_1.HttpClient.isHttpError(error))
|
|
10835
|
+
return;
|
|
10836
|
+
if (getHttpClient().isCancel(error))
|
|
10837
|
+
return;
|
|
10838
|
+
logger_12.logger.error("[CodeGenService] HTTP request failed", {
|
|
10839
|
+
method: error.config?.method?.toUpperCase(),
|
|
10840
|
+
url: requestOptions.url ?? error.config?.url,
|
|
10841
|
+
status: error.response?.status,
|
|
10842
|
+
code: error.code,
|
|
10843
|
+
requestId: error.requestId || void 0,
|
|
10844
|
+
message: error.message,
|
|
10845
|
+
data: error.response?.data
|
|
10846
|
+
});
|
|
10847
|
+
}
|
|
10848
|
+
};
|
|
10849
|
+
}
|
|
10850
|
+
var CodeGenService = class {
|
|
10851
|
+
constructor(projectId, httpClient) {
|
|
10852
|
+
this.projectId = projectId;
|
|
10853
|
+
this.accessToken = process.env.WIX_ACCESS_TOKEN;
|
|
10854
|
+
this.sandboxId = process.env.SANDBOX_ID;
|
|
10855
|
+
this.refreshAccessToken = async () => {
|
|
10856
|
+
const token = await (0, wixTokenRefresh_1.refreshWixAccessToken)();
|
|
10857
|
+
this.setAccessToken(token);
|
|
10858
|
+
return token;
|
|
10859
|
+
};
|
|
10860
|
+
this.request = async (req) => {
|
|
10861
|
+
try {
|
|
10862
|
+
return await this.httpClient.request(this.withAuth(req));
|
|
10863
|
+
} catch (err) {
|
|
10864
|
+
if (!this.isUnauthorized(err))
|
|
10865
|
+
throw err;
|
|
10866
|
+
logger_12.logger.warn("[CodeGenService] 401 received, refreshing token and retrying once");
|
|
10867
|
+
await this.refreshAccessToken();
|
|
10868
|
+
return await this.httpClient.request(this.withAuth(req));
|
|
10869
|
+
}
|
|
10870
|
+
};
|
|
10871
|
+
this.fetchPendingJobs = async () => {
|
|
10872
|
+
const resp = await this.request((0, http_1.listProjectJobs)({
|
|
10873
|
+
projectId: this.projectId
|
|
10874
|
+
}));
|
|
10875
|
+
const jobs = resp.data?.jobs ?? [];
|
|
10876
|
+
return jobs.filter(this.shouldProcessJob);
|
|
10877
|
+
};
|
|
10878
|
+
this.shouldProcessJob = (job) => {
|
|
10879
|
+
if (job.status !== types_1.Status.PENDING)
|
|
10880
|
+
return false;
|
|
10881
|
+
if (this.sandboxId)
|
|
10882
|
+
return job.sandboxId === this.sandboxId;
|
|
10883
|
+
return true;
|
|
10884
|
+
};
|
|
10885
|
+
this.markJobAsCompleted = async (jobId) => {
|
|
10886
|
+
await this.request((0, http_1.updateJob)({
|
|
10887
|
+
projectId: this.projectId,
|
|
10888
|
+
job: {
|
|
10889
|
+
id: jobId,
|
|
10890
|
+
projectId: this.projectId,
|
|
10891
|
+
status: types_1.Status.COMPLETED
|
|
10892
|
+
}
|
|
10893
|
+
}));
|
|
10894
|
+
};
|
|
10895
|
+
this.markJobAsRuninng = async (jobId) => {
|
|
10896
|
+
await this.request((0, http_1.updateJob)({
|
|
10897
|
+
projectId: this.projectId,
|
|
10898
|
+
job: {
|
|
10899
|
+
id: jobId,
|
|
10900
|
+
projectId: this.projectId,
|
|
10901
|
+
status: types_1.Status.RUNNING
|
|
10902
|
+
}
|
|
10903
|
+
}));
|
|
10904
|
+
};
|
|
10905
|
+
this.markJobAsCancelled = async (jobId) => {
|
|
10906
|
+
await this.request((0, http_1.updateJob)({
|
|
10907
|
+
projectId: this.projectId,
|
|
10908
|
+
job: {
|
|
10909
|
+
id: jobId,
|
|
10910
|
+
projectId: this.projectId,
|
|
10911
|
+
status: types_1.Status.CANCELLED
|
|
10912
|
+
}
|
|
10913
|
+
}));
|
|
10914
|
+
};
|
|
10915
|
+
this.updateJob = async (jobId, payload) => {
|
|
10916
|
+
await this.request((0, http_1.updateJob)({
|
|
10917
|
+
projectId: this.projectId,
|
|
10918
|
+
job: {
|
|
10919
|
+
id: jobId,
|
|
10920
|
+
projectId: this.projectId,
|
|
10921
|
+
payload,
|
|
10922
|
+
output: toJobOutput(payload)
|
|
10923
|
+
}
|
|
10924
|
+
}));
|
|
10925
|
+
};
|
|
10926
|
+
this.updateJobStatus = async (jobId, status) => {
|
|
10927
|
+
logger_12.logger.info("Updating job status", {
|
|
10928
|
+
jobId,
|
|
10929
|
+
status
|
|
10930
|
+
});
|
|
10931
|
+
await this.request((0, http_1.updateJob)({
|
|
10932
|
+
projectId: this.projectId,
|
|
10933
|
+
job: {
|
|
10934
|
+
id: jobId,
|
|
10935
|
+
projectId: this.projectId,
|
|
10936
|
+
status
|
|
10937
|
+
}
|
|
10938
|
+
}));
|
|
10939
|
+
};
|
|
10940
|
+
this.updateJobWithPendingDecision = async (jobId, userDecision) => {
|
|
10941
|
+
logger_12.logger.info("Setting job to await user decision", {
|
|
10942
|
+
jobId,
|
|
10943
|
+
decisionId: userDecision.id,
|
|
10944
|
+
userDecision: JSON.stringify(userDecision, null, 2)
|
|
10945
|
+
});
|
|
10946
|
+
await this.request((0, http_1.updateJob)({
|
|
10947
|
+
projectId: this.projectId,
|
|
10948
|
+
job: {
|
|
10949
|
+
id: jobId,
|
|
10950
|
+
projectId: this.projectId,
|
|
10951
|
+
status: types_1.Status.AWAITING_USER_INPUT,
|
|
10952
|
+
pendingUserDecisions: [userDecision]
|
|
10953
|
+
}
|
|
10954
|
+
}));
|
|
10955
|
+
};
|
|
10956
|
+
this.resumeJobFromDecision = async (jobId) => {
|
|
10957
|
+
logger_12.logger.info("Resuming job from user decision");
|
|
10958
|
+
await this.request((0, http_1.updateJob)({
|
|
10959
|
+
projectId: this.projectId,
|
|
10960
|
+
job: {
|
|
10961
|
+
id: jobId,
|
|
10962
|
+
projectId: this.projectId,
|
|
10963
|
+
status: types_1.Status.RUNNING,
|
|
10964
|
+
pendingUserDecisions: []
|
|
10965
|
+
}
|
|
10966
|
+
}));
|
|
10967
|
+
};
|
|
10968
|
+
this.updateTask = async (jobId, taskId, status, payload) => {
|
|
10969
|
+
await this.request((0, http_1.updateTask)({
|
|
10970
|
+
projectId: this.projectId,
|
|
10971
|
+
jobId,
|
|
10972
|
+
task: {
|
|
10973
|
+
id: taskId,
|
|
10974
|
+
status,
|
|
10975
|
+
payload
|
|
10976
|
+
}
|
|
10977
|
+
}));
|
|
10978
|
+
};
|
|
10979
|
+
this.addTask = async (jobId, task) => {
|
|
10980
|
+
await this.request((0, http_1.createTask)({
|
|
10981
|
+
projectId: this.projectId,
|
|
10982
|
+
jobId,
|
|
10983
|
+
task: {
|
|
10984
|
+
id: task.id,
|
|
10985
|
+
kind: task.kind,
|
|
10986
|
+
name: task.name,
|
|
10987
|
+
status: task.status,
|
|
10988
|
+
payload: task.payload,
|
|
10989
|
+
...task.input !== void 0 && { input: task.input },
|
|
10990
|
+
agentName: task.agentName,
|
|
10991
|
+
description: typeof task.description === "string" ? task.description : task.payload ? JSON.stringify(task.payload) : ""
|
|
10992
|
+
}
|
|
10993
|
+
}));
|
|
10994
|
+
};
|
|
10995
|
+
this.getJob = async (jobId) => {
|
|
10996
|
+
const resp = await this.request((0, http_1.getJob)({
|
|
10997
|
+
projectId: this.projectId,
|
|
10998
|
+
jobId
|
|
10999
|
+
}));
|
|
11000
|
+
return resp.data?.job ?? null;
|
|
11001
|
+
};
|
|
11002
|
+
if (httpClient) {
|
|
11003
|
+
this.httpClient = httpClient;
|
|
11004
|
+
return;
|
|
11005
|
+
}
|
|
11006
|
+
const serverUrl = process.env.CODEGEN_SERVER_BASE_URL || "https://manage.wix.com";
|
|
11007
|
+
this.httpClient = (0, http_client_1.createHttpClient)({
|
|
11008
|
+
baseURL: serverUrl,
|
|
11009
|
+
errorHandler: createCodeGenErrorHandler(() => this.httpClient)
|
|
11010
|
+
});
|
|
11011
|
+
}
|
|
11012
|
+
getAccessToken() {
|
|
11013
|
+
return this.accessToken;
|
|
11014
|
+
}
|
|
11015
|
+
setAccessToken(token) {
|
|
11016
|
+
this.accessToken = token;
|
|
11017
|
+
}
|
|
11018
|
+
isUnauthorized(error) {
|
|
11019
|
+
if (!http_client_1.HttpClient.isHttpError(error))
|
|
11020
|
+
return false;
|
|
11021
|
+
if (this.httpClient.isCancel(error))
|
|
11022
|
+
return false;
|
|
11023
|
+
return error.response?.status === 401;
|
|
11024
|
+
}
|
|
11025
|
+
withAuth(req) {
|
|
11026
|
+
const authHeader = { authorization: `Bearer ${this.accessToken}` };
|
|
11027
|
+
if (typeof req === "function") {
|
|
11028
|
+
return (ctx) => {
|
|
11029
|
+
const r = req(ctx);
|
|
11030
|
+
return { ...r, headers: { ...r.headers ?? {}, ...authHeader } };
|
|
11031
|
+
};
|
|
11032
|
+
}
|
|
11033
|
+
return { ...req, headers: { ...req.headers ?? {}, ...authHeader } };
|
|
11034
|
+
}
|
|
11035
|
+
};
|
|
11036
|
+
exports2.CodeGenService = CodeGenService;
|
|
11037
|
+
}
|
|
11038
|
+
});
|
|
11039
|
+
|
|
11040
|
+
// dist/services/codeGenerationService.js
|
|
11041
|
+
var require_codeGenerationService = __commonJS({
|
|
11042
|
+
"dist/services/codeGenerationService.js"(exports2) {
|
|
11043
|
+
"use strict";
|
|
11044
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11045
|
+
exports2.codeGenerationService = void 0;
|
|
11046
|
+
var CodeGenService_12 = require_CodeGenService();
|
|
11047
|
+
var context_12 = require_context();
|
|
11048
|
+
exports2.codeGenerationService = new CodeGenService_12.CodeGenService(context_12.ctx.projectId);
|
|
11049
|
+
}
|
|
11050
|
+
});
|
|
11051
|
+
|
|
11052
|
+
// dist/events/cli-listeners.js
|
|
11053
|
+
var require_cli_listeners = __commonJS({
|
|
11054
|
+
"dist/events/cli-listeners.js"(exports2) {
|
|
11055
|
+
"use strict";
|
|
11056
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11057
|
+
exports2.attachOrchestratorListeners = attachOrchestratorListeners;
|
|
11058
|
+
var logger_12 = require_logger();
|
|
11059
|
+
function attachOrchestratorListeners(eventEmitter) {
|
|
11060
|
+
eventEmitter.onEvent("start:init", (info) => {
|
|
11061
|
+
logger_12.logger.info("\u{1F680} Starting initial code generation for app", {
|
|
11062
|
+
appName: info.appName,
|
|
11063
|
+
summary: info.summary,
|
|
11064
|
+
outputPath: info.outputPath,
|
|
11065
|
+
extensionsCount: info.extensionsCount
|
|
11066
|
+
});
|
|
11067
|
+
});
|
|
11068
|
+
eventEmitter.onEvent("start:iteration", ({ outputPath }) => {
|
|
11069
|
+
logger_12.logger.info("\u{1F680} Starting code iteration", { outputPath });
|
|
11070
|
+
});
|
|
11071
|
+
eventEmitter.onEvent("start:ask", ({ outputPath }) => {
|
|
11072
|
+
logger_12.logger.info("\u{1F680} Starting ask", { outputPath });
|
|
11073
|
+
});
|
|
11074
|
+
eventEmitter.onEvent("finish:init", ({ outputPath, durationMs }) => {
|
|
11075
|
+
logger_12.logger.info("\u2705 Init completed", {
|
|
11076
|
+
outputPath,
|
|
11077
|
+
durationMs,
|
|
11078
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
11079
|
+
});
|
|
11080
|
+
});
|
|
11081
|
+
eventEmitter.onEvent("finish:iteration", ({ outputPath, durationMs }) => {
|
|
11082
|
+
logger_12.logger.info("\u2705 Iteration completed", {
|
|
11083
|
+
outputPath,
|
|
11084
|
+
durationMs,
|
|
11085
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
11086
|
+
});
|
|
11087
|
+
});
|
|
11088
|
+
eventEmitter.onEvent("finish:ask", ({ durationMs }) => {
|
|
11089
|
+
logger_12.logger.info("\u2705 Ask completed", {
|
|
11090
|
+
durationMs,
|
|
11091
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
11092
|
+
});
|
|
11093
|
+
});
|
|
11094
|
+
eventEmitter.onEvent("opencode:start", ({ outputPath }) => {
|
|
11095
|
+
logger_12.logger.info("\u{1F527} OpenCode starting", { outputPath });
|
|
11096
|
+
});
|
|
11097
|
+
eventEmitter.onEvent("opencode:output", ({ data }) => {
|
|
11098
|
+
process.stdout.write(data);
|
|
11099
|
+
});
|
|
11100
|
+
eventEmitter.onEvent("opencode:done", ({ durationMs }) => {
|
|
11101
|
+
logger_12.logger.info("\u{1F527} OpenCode completed", {
|
|
11102
|
+
durationMs,
|
|
11103
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
11104
|
+
});
|
|
11105
|
+
});
|
|
11106
|
+
eventEmitter.onEvent("opencode:error", ({ error, exitCode, durationMs }) => {
|
|
11107
|
+
logger_12.logger.error("\u274C OpenCode failed", {
|
|
11108
|
+
error,
|
|
11109
|
+
exitCode,
|
|
11110
|
+
durationMs,
|
|
11111
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
11112
|
+
});
|
|
11113
|
+
});
|
|
11114
|
+
}
|
|
11115
|
+
var getFormattedDuration = (ms) => {
|
|
11116
|
+
const seconds = ms / 1e3;
|
|
11117
|
+
const minutes = seconds / 60;
|
|
11118
|
+
return `${ms} ms (${minutes.toFixed(2)} min or ${seconds.toFixed(2)} sec)`;
|
|
11119
|
+
};
|
|
11120
|
+
}
|
|
11121
|
+
});
|
|
11122
|
+
|
|
11024
11123
|
// dist/events/DittoEventEmitter.js
|
|
11025
11124
|
var require_DittoEventEmitter = __commonJS({
|
|
11026
11125
|
"dist/events/DittoEventEmitter.js"(exports2) {
|
|
@@ -11073,14 +11172,14 @@ When generating editor React component or function library extensions, use this
|
|
|
11073
11172
|
const lastUserMessage = [...chatHistory].reverse().find((msg) => msg.role === "USER");
|
|
11074
11173
|
return {
|
|
11075
11174
|
currentUserRequest: lastUserMessage?.text || "",
|
|
11076
|
-
filteredChatHistory: chatHistory.filter((msg) => msg.text.length > 0)
|
|
11175
|
+
filteredChatHistory: chatHistory.filter((msg) => msg.text && msg.text.length > 0)
|
|
11077
11176
|
};
|
|
11078
11177
|
}
|
|
11079
11178
|
function formatChatHistory(history, label) {
|
|
11080
11179
|
if (!history || history.length === 0) {
|
|
11081
11180
|
return "";
|
|
11082
11181
|
}
|
|
11083
|
-
const lines = history.map((msg) => `${msg.role
|
|
11182
|
+
const lines = history.map((msg) => `${msg.role?.toUpperCase()}: ${msg.text}`).join("\n\n");
|
|
11084
11183
|
return `${label}:
|
|
11085
11184
|
${lines}`;
|
|
11086
11185
|
}
|
|
@@ -12011,11 +12110,14 @@ var require_site_data_layer_rules = __commonJS({
|
|
|
12011
12110
|
|
|
12012
12111
|
The agent operates on a live Wix site (METASITE_ID is in your prompt context).
|
|
12013
12112
|
|
|
12014
|
-
|
|
12113
|
+
## Mandatory for data persistence
|
|
12114
|
+
|
|
12115
|
+
For any persistent-data need (CMS collections, tables, schemas, data models):
|
|
12015
12116
|
|
|
12016
|
-
|
|
12117
|
+
1. **Invoke the \`wix-site-data-collection\` skill first** \u2014 before scaffolding or writing collection code.
|
|
12118
|
+
2. **Do NOT** run \`wix generate\` with \`extensionType: DATA_COLLECTION\`, and do not create data-collection CLI extension files manually (e.g. \`src/extensions/backend/data-collections/*\`).
|
|
12017
12119
|
|
|
12018
|
-
|
|
12120
|
+
\`wix-app\` is still correct for dashboard pages, modals, widgets, and UI \u2014 only the data layer is overridden here.`;
|
|
12019
12121
|
}
|
|
12020
12122
|
});
|
|
12021
12123
|
|
|
@@ -12159,7 +12261,7 @@ var require_job_decision_manager = __commonJS({
|
|
|
12159
12261
|
exports2.askJobConfirmation = askJobConfirmation;
|
|
12160
12262
|
var types_1 = require_types_impl();
|
|
12161
12263
|
var codeGenerationService_12 = require_codeGenerationService();
|
|
12162
|
-
var
|
|
12264
|
+
var types_2 = require_types_impl();
|
|
12163
12265
|
var logger_12 = require_logger();
|
|
12164
12266
|
var DECISION_POLL_INTERVAL_MS = 2e3;
|
|
12165
12267
|
var UserDecisionCancelledError = class extends Error {
|
|
@@ -12203,7 +12305,7 @@ var require_job_decision_manager = __commonJS({
|
|
|
12203
12305
|
if (!job) {
|
|
12204
12306
|
throw new Error(`Job ${jobId} not found`);
|
|
12205
12307
|
}
|
|
12206
|
-
if (job.status ===
|
|
12308
|
+
if (job.status === types_2.Status.CANCELLED || job.status === types_2.Status.PENDING_CANCEL) {
|
|
12207
12309
|
logger_12.logger.warn("[JobDecision] Job cancelled while waiting for user decision", { decisionId });
|
|
12208
12310
|
throw new UserDecisionCancelledError(jobId, decisionId);
|
|
12209
12311
|
}
|
|
@@ -19624,7 +19726,7 @@ function extractUserInput(kind, payload) {
|
|
|
19624
19726
|
const history = payload.history ?? [];
|
|
19625
19727
|
for (let i = history.length - 1; i >= 0; i--) {
|
|
19626
19728
|
if (history[i].role === "USER") {
|
|
19627
|
-
return history[i]
|
|
19729
|
+
return history[i]?.text?.trim() || void 0;
|
|
19628
19730
|
}
|
|
19629
19731
|
}
|
|
19630
19732
|
}
|
|
@@ -19640,7 +19742,7 @@ async function processJob(job) {
|
|
|
19640
19742
|
logger_1.logger.warn("[Job] No initial task found, skipping", { jobId });
|
|
19641
19743
|
return;
|
|
19642
19744
|
}
|
|
19643
|
-
const payload = task.payload ?? {};
|
|
19745
|
+
const payload = task.input ?? task.payload ?? {};
|
|
19644
19746
|
const plugins = buildPluginsForTask(jobId, task.id, task.kind, payload);
|
|
19645
19747
|
await job_context_storage_1.jobContextStorage.run({ jobId, taskId: task.id, kind: task.kind, plugins }, async () => {
|
|
19646
19748
|
logger_1.logger.info("[Job] Start processing", { taskKind: task.kind });
|
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.354",
|
|
4
4
|
"description": "AI-powered Wix CLI app generator - standalone executable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node build.mjs",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"esbuild": "^0.27.2",
|
|
30
30
|
"vitest": "^4.0.16"
|
|
31
31
|
},
|
|
32
|
-
"falconPackageHash": "
|
|
32
|
+
"falconPackageHash": "40867f76df93d5568a60eef3916c05a20897fbf7d10adf7a31019e9f"
|
|
33
33
|
}
|