@wix/ditto-codegen-public 1.0.129 → 1.0.131
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 +115 -7
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -65668,6 +65668,7 @@ var require_ErrorTypes = __commonJS({
|
|
|
65668
65668
|
ErrorType2["AI_RATE_LIMIT_ERROR"] = "AI_RATE_LIMIT_ERROR";
|
|
65669
65669
|
ErrorType2["AI_NETWORK_ERROR"] = "AI_NETWORK_ERROR";
|
|
65670
65670
|
ErrorType2["FILE_SYSTEM_ERROR"] = "FILE_SYSTEM_ERROR";
|
|
65671
|
+
ErrorType2["TIMEOUT_ERROR"] = "TIMEOUT_ERROR";
|
|
65671
65672
|
ErrorType2["PROCESS_EXECUTION_ERROR"] = "PROCESS_EXECUTION_ERROR";
|
|
65672
65673
|
ErrorType2["AGENT_CONFIGURATION_ERROR"] = "AGENT_CONFIGURATION_ERROR";
|
|
65673
65674
|
ErrorType2["SCAFFOLDING_ERROR"] = "SCAFFOLDING_ERROR";
|
|
@@ -66198,6 +66199,27 @@ var require_UnexpectedError = __commonJS({
|
|
|
66198
66199
|
}
|
|
66199
66200
|
});
|
|
66200
66201
|
|
|
66202
|
+
// ../codegen-types/dist/errors/TimeoutError.js
|
|
66203
|
+
var require_TimeoutError = __commonJS({
|
|
66204
|
+
"../codegen-types/dist/errors/TimeoutError.js"(exports2) {
|
|
66205
|
+
"use strict";
|
|
66206
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
66207
|
+
exports2.TimeoutError = void 0;
|
|
66208
|
+
var BaseCodegenError_1 = require_BaseCodegenError();
|
|
66209
|
+
var ErrorTypes_1 = require_ErrorTypes();
|
|
66210
|
+
var TimeoutError = class extends BaseCodegenError_1.BaseCodegenError {
|
|
66211
|
+
constructor(message) {
|
|
66212
|
+
super(message);
|
|
66213
|
+
this.name = "TimeoutError";
|
|
66214
|
+
this.errorType = ErrorTypes_1.ErrorType.TIMEOUT_ERROR;
|
|
66215
|
+
this.expected = false;
|
|
66216
|
+
this.retryable = true;
|
|
66217
|
+
}
|
|
66218
|
+
};
|
|
66219
|
+
exports2.TimeoutError = TimeoutError;
|
|
66220
|
+
}
|
|
66221
|
+
});
|
|
66222
|
+
|
|
66201
66223
|
// ../codegen-types/dist/errors/helpers.js
|
|
66202
66224
|
var require_helpers = __commonJS({
|
|
66203
66225
|
"../codegen-types/dist/errors/helpers.js"(exports2) {
|
|
@@ -66293,6 +66315,7 @@ var require_errors = __commonJS({
|
|
|
66293
66315
|
__exportStar2(require_ExtensionGenerationError(), exports2);
|
|
66294
66316
|
__exportStar2(require_ValidationConfigurationError(), exports2);
|
|
66295
66317
|
__exportStar2(require_UnexpectedError(), exports2);
|
|
66318
|
+
__exportStar2(require_TimeoutError(), exports2);
|
|
66296
66319
|
__exportStar2(require_helpers(), exports2);
|
|
66297
66320
|
}
|
|
66298
66321
|
});
|
|
@@ -117813,6 +117836,25 @@ var require_PlannerAgentSchema = __commonJS({
|
|
|
117813
117836
|
}
|
|
117814
117837
|
});
|
|
117815
117838
|
|
|
117839
|
+
// dist/agents/planner/forceDataPermissionsToAnyone.js
|
|
117840
|
+
var require_forceDataPermissionsToAnyone = __commonJS({
|
|
117841
|
+
"dist/agents/planner/forceDataPermissionsToAnyone.js"(exports2) {
|
|
117842
|
+
"use strict";
|
|
117843
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
117844
|
+
exports2.forceDataPermissionsToAnyone = forceDataPermissionsToAnyone;
|
|
117845
|
+
var ditto_codegen_types_12 = require_dist();
|
|
117846
|
+
function forceDataPermissionsToAnyone(plan) {
|
|
117847
|
+
const dataPermissionsList = plan.collections.flatMap((x) => x.operation === ditto_codegen_types_12.ExtensionGenerationOperation.INSERT || x.operation === ditto_codegen_types_12.ExtensionGenerationOperation.UPDATE ? [x.data.dataPermissions] : []);
|
|
117848
|
+
dataPermissionsList.forEach((x) => {
|
|
117849
|
+
x.itemRead = "ANYONE";
|
|
117850
|
+
x.itemInsert = "ANYONE";
|
|
117851
|
+
x.itemUpdate = "ANYONE";
|
|
117852
|
+
x.itemRemove = "ANYONE";
|
|
117853
|
+
});
|
|
117854
|
+
}
|
|
117855
|
+
}
|
|
117856
|
+
});
|
|
117857
|
+
|
|
117816
117858
|
// dist/agents/planner/PlannerAgent.js
|
|
117817
117859
|
var require_PlannerAgent = __commonJS({
|
|
117818
117860
|
"dist/agents/planner/PlannerAgent.js"(exports2) {
|
|
@@ -117826,6 +117868,7 @@ var require_PlannerAgent = __commonJS({
|
|
|
117826
117868
|
var utils_1 = require_utils11();
|
|
117827
117869
|
var ditto_codegen_types_12 = require_dist();
|
|
117828
117870
|
var PlannerAgentSchema_1 = require_PlannerAgentSchema();
|
|
117871
|
+
var forceDataPermissionsToAnyone_1 = require_forceDataPermissionsToAnyone();
|
|
117829
117872
|
var PlannerAgent = class {
|
|
117830
117873
|
constructor(apiKey) {
|
|
117831
117874
|
this.apiKey = apiKey;
|
|
@@ -117838,7 +117881,7 @@ var require_PlannerAgent = __commonJS({
|
|
|
117838
117881
|
isIteration
|
|
117839
117882
|
});
|
|
117840
117883
|
}
|
|
117841
|
-
async generatePlan({ systemPrompt, blueprint, error, previousResources, schema }) {
|
|
117884
|
+
async generatePlan({ systemPrompt, blueprint, error, previousResources, schema, isIteration }) {
|
|
117842
117885
|
const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-3-5-haiku-latest");
|
|
117843
117886
|
const userContent = `
|
|
117844
117887
|
${JSON.stringify(blueprint, null, 2)}
|
|
@@ -117872,7 +117915,12 @@ ${error}` : ""}
|
|
|
117872
117915
|
functionId: this.name
|
|
117873
117916
|
}
|
|
117874
117917
|
});
|
|
117875
|
-
|
|
117918
|
+
const plan = result.object;
|
|
117919
|
+
if (!isIteration) {
|
|
117920
|
+
console.log("\u{1F513} Force data permissions to ANYONE");
|
|
117921
|
+
(0, forceDataPermissionsToAnyone_1.forceDataPermissionsToAnyone)(plan);
|
|
117922
|
+
}
|
|
117923
|
+
return plan;
|
|
117876
117924
|
}
|
|
117877
117925
|
async generate(blueprint, options) {
|
|
117878
117926
|
const { isIteration = false, previousResources } = options || {};
|
|
@@ -117897,7 +117945,8 @@ ${error}` : ""}
|
|
|
117897
117945
|
blueprint,
|
|
117898
117946
|
error: lastError,
|
|
117899
117947
|
previousResources,
|
|
117900
|
-
schema
|
|
117948
|
+
schema,
|
|
117949
|
+
isIteration
|
|
117901
117950
|
});
|
|
117902
117951
|
return result;
|
|
117903
117952
|
} catch (error) {
|
|
@@ -132369,6 +132418,9 @@ var require_utils18 = __commonJS({
|
|
|
132369
132418
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
132370
132419
|
exports2.serializeError = serializeError;
|
|
132371
132420
|
exports2.mapGroupBy = mapGroupBy;
|
|
132421
|
+
exports2.updateAllRunningTasks = updateAllRunningTasks;
|
|
132422
|
+
var ditto_codegen_types_12 = require_dist();
|
|
132423
|
+
var codeGenerationService_1 = require_codeGenerationService();
|
|
132372
132424
|
function serializeError(error) {
|
|
132373
132425
|
if (error instanceof Error) {
|
|
132374
132426
|
const base = {
|
|
@@ -132421,6 +132473,13 @@ var require_utils18 = __commonJS({
|
|
|
132421
132473
|
}
|
|
132422
132474
|
return groups;
|
|
132423
132475
|
}
|
|
132476
|
+
async function updateAllRunningTasks(jobId, status, error) {
|
|
132477
|
+
const job = await codeGenerationService_1.codeGenerationService.getJob(jobId);
|
|
132478
|
+
const tasks = job?.tasks.filter((task) => task.status === ditto_codegen_types_12.Status.RUNNING || task.status === ditto_codegen_types_12.Status.PENDING) || [];
|
|
132479
|
+
for (const task of tasks) {
|
|
132480
|
+
await codeGenerationService_1.codeGenerationService.updateTask(jobId, task.id, status, error ? { error: serializeError(error) } : {});
|
|
132481
|
+
}
|
|
132482
|
+
}
|
|
132424
132483
|
}
|
|
132425
132484
|
});
|
|
132426
132485
|
|
|
@@ -353363,6 +353422,7 @@ var require_job_cancellation_monitor = __commonJS({
|
|
|
353363
353422
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
353364
353423
|
exports2.JobCancellationMonitor = void 0;
|
|
353365
353424
|
var ditto_codegen_types_12 = require_dist();
|
|
353425
|
+
var utils_1 = require_utils18();
|
|
353366
353426
|
var STATUS_CHECK_INTERVAL_MS = 2e3;
|
|
353367
353427
|
var JobCancellationMonitor = class {
|
|
353368
353428
|
constructor(codeGenerationService) {
|
|
@@ -353389,6 +353449,8 @@ var require_job_cancellation_monitor = __commonJS({
|
|
|
353389
353449
|
if (job.status === ditto_codegen_types_12.Status.PENDING_CANCEL) {
|
|
353390
353450
|
console.log(`[Job] Detected cancellation request. Exiting.`);
|
|
353391
353451
|
await this.codeGenerationService.markJobAsCancelled(jobId);
|
|
353452
|
+
await (0, utils_1.updateAllRunningTasks)(jobId, ditto_codegen_types_12.Status.CANCELLED);
|
|
353453
|
+
console.log(`[Job] Marked job ${jobId} as CANCELLED and cancelled all running and pending tasks.`);
|
|
353392
353454
|
process.exit();
|
|
353393
353455
|
}
|
|
353394
353456
|
this.start(jobId);
|
|
@@ -353402,9 +353464,51 @@ var require_job_cancellation_monitor = __commonJS({
|
|
|
353402
353464
|
}
|
|
353403
353465
|
});
|
|
353404
353466
|
|
|
353467
|
+
// dist/job-timeout-monitor.js
|
|
353468
|
+
var require_job_timeout_monitor = __commonJS({
|
|
353469
|
+
"dist/job-timeout-monitor.js"(exports2) {
|
|
353470
|
+
"use strict";
|
|
353471
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
353472
|
+
exports2.JobTimeoutMonitor = exports2.JOB_TIMEOUT_MS = void 0;
|
|
353473
|
+
var ditto_codegen_types_12 = require_dist();
|
|
353474
|
+
var utils_1 = require_utils18();
|
|
353475
|
+
exports2.JOB_TIMEOUT_MS = 1e3 * 60 * 10;
|
|
353476
|
+
var JobTimeoutMonitor = class {
|
|
353477
|
+
constructor(codeGenerationService) {
|
|
353478
|
+
this.codeGenerationService = codeGenerationService;
|
|
353479
|
+
this.jobTimeout = null;
|
|
353480
|
+
}
|
|
353481
|
+
start(jobId) {
|
|
353482
|
+
this.jobTimeout = setTimeout(() => {
|
|
353483
|
+
this.handleTimeout(jobId);
|
|
353484
|
+
}, exports2.JOB_TIMEOUT_MS);
|
|
353485
|
+
}
|
|
353486
|
+
stop() {
|
|
353487
|
+
if (this.jobTimeout) {
|
|
353488
|
+
clearTimeout(this.jobTimeout);
|
|
353489
|
+
this.jobTimeout = null;
|
|
353490
|
+
}
|
|
353491
|
+
}
|
|
353492
|
+
async handleTimeout(jobId) {
|
|
353493
|
+
console.error(`[Job] Job ${jobId} exceeded timeout of ${exports2.JOB_TIMEOUT_MS}ms`);
|
|
353494
|
+
try {
|
|
353495
|
+
console.log(`[Job] Timeout detected. Exiting.`);
|
|
353496
|
+
await (0, utils_1.updateAllRunningTasks)(jobId, ditto_codegen_types_12.Status.FAILED, new ditto_codegen_types_12.TimeoutError(`Job exceeded timeout of ${exports2.JOB_TIMEOUT_MS}ms`));
|
|
353497
|
+
await this.codeGenerationService.markJobAsCompleted(jobId);
|
|
353498
|
+
console.log(`[Job] Marked job ${jobId} as completed and failed all running and pending tasks.`);
|
|
353499
|
+
process.exit();
|
|
353500
|
+
} catch (error) {
|
|
353501
|
+
console.error(`[Job] Failed to mark job ${jobId} as completed and failed all running and pending tasks:`, error);
|
|
353502
|
+
}
|
|
353503
|
+
}
|
|
353504
|
+
};
|
|
353505
|
+
exports2.JobTimeoutMonitor = JobTimeoutMonitor;
|
|
353506
|
+
}
|
|
353507
|
+
});
|
|
353508
|
+
|
|
353405
353509
|
// dist/index.js
|
|
353406
353510
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
353407
|
-
exports.
|
|
353511
|
+
exports.codeGenerationService = void 0;
|
|
353408
353512
|
exports.processJob = processJob;
|
|
353409
353513
|
var instrumentation_1 = require_instrumentation3();
|
|
353410
353514
|
var context_1 = require_context();
|
|
@@ -353414,6 +353518,7 @@ var job_context_storage_1 = require_job_context_storage();
|
|
|
353414
353518
|
var init_codegen_1 = require_init_codegen();
|
|
353415
353519
|
var iterate_codegen_1 = require_iterate_codegen();
|
|
353416
353520
|
var job_cancellation_monitor_1 = require_job_cancellation_monitor();
|
|
353521
|
+
var job_timeout_monitor_1 = require_job_timeout_monitor();
|
|
353417
353522
|
var initializeTracing = async () => {
|
|
353418
353523
|
try {
|
|
353419
353524
|
await instrumentation_1.tracingReady;
|
|
@@ -353424,7 +353529,8 @@ var initializeTracing = async () => {
|
|
|
353424
353529
|
};
|
|
353425
353530
|
var baseUrl = process.env.CODEGEN_BASE_URL || "http://localhost:3000";
|
|
353426
353531
|
exports.codeGenerationService = new CodeGenService_1.CodeGenService(baseUrl, context_1.ctx.projectId);
|
|
353427
|
-
|
|
353532
|
+
var jobCancellationMonitor = new job_cancellation_monitor_1.JobCancellationMonitor(exports.codeGenerationService);
|
|
353533
|
+
var jobTimeoutMonitor = new job_timeout_monitor_1.JobTimeoutMonitor(exports.codeGenerationService);
|
|
353428
353534
|
var delay = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
353429
353535
|
var ACTIVE_JOB_SLEEP_MS = 1e3;
|
|
353430
353536
|
var NO_JOBS_SLEEP_MS = 5e3;
|
|
@@ -353474,7 +353580,8 @@ async function processJob(job) {
|
|
|
353474
353580
|
console.log(`[Job] jobId=${job.jobId}, taskKind=${task.kind} - start processing`);
|
|
353475
353581
|
context_1.ctx.setJobStatus(job.jobId, ditto_codegen_types_1.Status.RUNNING);
|
|
353476
353582
|
console.log(`[Job] Marked job RUNNING: jobId=${job.jobId}, initTaskId=${task.id}`);
|
|
353477
|
-
|
|
353583
|
+
jobCancellationMonitor.start(job.jobId);
|
|
353584
|
+
jobTimeoutMonitor.start(job.jobId);
|
|
353478
353585
|
try {
|
|
353479
353586
|
console.log("Task Payload", JSON.stringify(task.payload, null, 2));
|
|
353480
353587
|
await job_context_storage_1.jobContextStorage.run({ jobId: job.jobId, taskId: task.id, kind: task.kind }, async () => {
|
|
@@ -353487,7 +353594,8 @@ async function processJob(job) {
|
|
|
353487
353594
|
}
|
|
353488
353595
|
});
|
|
353489
353596
|
} finally {
|
|
353490
|
-
|
|
353597
|
+
jobCancellationMonitor.stop();
|
|
353598
|
+
jobTimeoutMonitor.stop();
|
|
353491
353599
|
}
|
|
353492
353600
|
}
|
|
353493
353601
|
(0, context_1.initCtx)().then((ctx) => {
|
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.131",
|
|
4
4
|
"description": "AI-powered Wix CLI app generator - standalone executable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node build.mjs",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@wix/ditto-codegen": "1.0.0",
|
|
25
25
|
"esbuild": "^0.25.9"
|
|
26
26
|
},
|
|
27
|
-
"falconPackageHash": "
|
|
27
|
+
"falconPackageHash": "a077e8a8144f4e64fc6ddeb47287c87732f0b70c2d99c29dbab13874"
|
|
28
28
|
}
|