@wix/ditto-codegen-public 1.0.294 → 1.0.296

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/out.js +122 -32
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -12321,31 +12321,66 @@ var require_category_handler = __commonJS({
12321
12321
  var codeGenerationService_12 = require_codeGenerationService();
12322
12322
  var logger_12 = require_logger();
12323
12323
  var constants_1 = require_constants5();
12324
+ var CategoryKey;
12325
+ (function(CategoryKey2) {
12326
+ CategoryKey2["CodeSearch"] = "code-search";
12327
+ CategoryKey2["DocSearch"] = "doc-search";
12328
+ CategoryKey2["LoadSkill"] = "load-skill";
12329
+ CategoryKey2["RunCommands"] = "run-commands";
12330
+ CategoryKey2["WriteCode"] = "write-code";
12331
+ CategoryKey2["Validate"] = "validate";
12332
+ })(CategoryKey || (CategoryKey = {}));
12333
+ var CATEGORY_DESCRIPTIONS = {
12334
+ [CategoryKey.CodeSearch]: "Searching in code",
12335
+ [CategoryKey.DocSearch]: "Searching in docs",
12336
+ [CategoryKey.LoadSkill]: "Loading agent skills",
12337
+ [CategoryKey.RunCommands]: "Executing commands",
12338
+ [CategoryKey.WriteCode]: "Writing code",
12339
+ [CategoryKey.Validate]: "Validating code"
12340
+ };
12324
12341
  var CategoryTaskHandler = class {
12325
12342
  constructor() {
12326
- this.codeSearchCreated = false;
12327
- this.docSearchCreated = false;
12343
+ this.created = /* @__PURE__ */ new Set();
12344
+ this.completed = /* @__PURE__ */ new Set();
12328
12345
  }
12329
- /** Creates a search sub-task on the first use of code-search or MCP tools. */
12330
- async handle(tool, ctx) {
12331
- const jobContext = ctx.getJobContext();
12332
- if (!jobContext)
12346
+ async handle(tool, ctx, state) {
12347
+ if (!ctx.getJobContext())
12333
12348
  return;
12334
- if (constants_1.CODE_SEARCH_TOOLS.has(tool) && !this.codeSearchCreated) {
12335
- this.codeSearchCreated = true;
12336
- await this.createTask("code-search", "Searching in code", ctx);
12349
+ if ((0, constants_1.isMcpTool)(tool)) {
12350
+ await this.track(CategoryKey.DocSearch, ctx, state);
12351
+ }
12352
+ if (constants_1.CODE_SEARCH_TOOLS.has(tool)) {
12353
+ await this.track(CategoryKey.CodeSearch, ctx, state);
12354
+ }
12355
+ if (tool === "bash") {
12356
+ await this.track(CategoryKey.RunCommands, ctx, state);
12357
+ }
12358
+ if (tool === "validate") {
12359
+ await this.track(CategoryKey.Validate, ctx, state);
12360
+ }
12361
+ if (constants_1.WRITE_TOOLS.has(tool)) {
12362
+ await this.track(CategoryKey.WriteCode, ctx);
12363
+ }
12364
+ }
12365
+ async trackLoadSkill(ctx, state) {
12366
+ await this.track(CategoryKey.LoadSkill, ctx, state);
12367
+ }
12368
+ async track(key, ctx, state) {
12369
+ if (!this.created.has(key)) {
12370
+ await this.createTask(key, ctx);
12337
12371
  }
12338
- if ((0, constants_1.isMcpTool)(tool) && !this.docSearchCreated) {
12339
- this.docSearchCreated = true;
12340
- await this.createTask("doc-search", "Searching in docs", ctx);
12372
+ if (state?.status === "completed" && !this.completed.has(key)) {
12373
+ await this.completeTask(key, ctx);
12341
12374
  }
12342
12375
  }
12343
- async createTask(suffix, description, ctx) {
12376
+ async createTask(key, ctx) {
12377
+ this.created.add(key);
12344
12378
  const jobContext = ctx.getJobContext();
12345
12379
  if (!jobContext)
12346
12380
  return;
12347
- const taskId = `${jobContext.taskId}-${suffix}`;
12348
- ctx.trackedTasks.set(suffix, {
12381
+ const description = CATEGORY_DESCRIPTIONS[key];
12382
+ const taskId = `${jobContext.taskId}-${key}`;
12383
+ ctx.trackedTasks.set(key, {
12349
12384
  taskId,
12350
12385
  description,
12351
12386
  status: ditto_codegen_types_12.Status.RUNNING
@@ -12366,6 +12401,26 @@ var require_category_handler = __commonJS({
12366
12401
  });
12367
12402
  }
12368
12403
  }
12404
+ async completeTask(key, ctx) {
12405
+ this.completed.add(key);
12406
+ const jobContext = ctx.getJobContext();
12407
+ if (!jobContext)
12408
+ return;
12409
+ const tracked = ctx.trackedTasks.get(key);
12410
+ if (!tracked)
12411
+ return;
12412
+ tracked.status = ditto_codegen_types_12.Status.COMPLETED;
12413
+ try {
12414
+ await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, tracked.taskId, ditto_codegen_types_12.Status.COMPLETED, {});
12415
+ logger_12.logger.info("[OpenCode] Completed category task", {
12416
+ description: tracked.description
12417
+ });
12418
+ } catch (error) {
12419
+ logger_12.logger.error("[OpenCode] Failed to mark category task as completed", {
12420
+ error: error instanceof Error ? error.message : String(error)
12421
+ });
12422
+ }
12423
+ }
12369
12424
  };
12370
12425
  exports2.CategoryTaskHandler = CategoryTaskHandler;
12371
12426
  }
@@ -12436,13 +12491,11 @@ var require_task_tracker = __commonJS({
12436
12491
  await this.handleWriteEvent(tool, state);
12437
12492
  }
12438
12493
  if (tool === "skill" && state.status === "completed") {
12439
- this.handleSkillEvent(state);
12440
- }
12441
- if (this.store?.kind === ditto_codegen_types_12.TaskKind.ASK_CODEGEN) {
12442
- const ctx = this.handlerContext;
12443
- await this.categoryHandler.handle(tool, ctx);
12444
- this.taskCounter = ctx.taskCounter;
12494
+ await this.handleSkillEvent(state);
12445
12495
  }
12496
+ const ctx = this.handlerContext;
12497
+ await this.categoryHandler.handle(tool, ctx, state);
12498
+ this.taskCounter = ctx.taskCounter;
12446
12499
  }
12447
12500
  async handleWriteEvent(tool, state) {
12448
12501
  if (state.status !== "completed")
@@ -12477,6 +12530,7 @@ var require_task_tracker = __commonJS({
12477
12530
  const skillName = state.title?.replace("Loaded skill: ", "") || "unknown";
12478
12531
  this.skillsUsed.add(skillName);
12479
12532
  logger_12.logger.info("[OpenCode] Loaded skill", { skillName });
12533
+ await this.categoryHandler.trackLoadSkill(this.handlerContext, state);
12480
12534
  }
12481
12535
  /** Builds the task completion payload — includes file list for extension tasks. */
12482
12536
  buildTaskPayload(tracked) {
@@ -17984,21 +18038,30 @@ var require_opencode_ask = __commonJS({
17984
18038
  var ditto_codegen_types_2 = require_dist4();
17985
18039
  var context_12 = require_context();
17986
18040
  var logger_12 = require_logger();
18041
+ var config_1 = require_config();
18042
+ var biEvents_1 = require_biEvents();
17987
18043
  var runOpencodeAskFlow = async (chatHistory) => {
17988
18044
  const store = job_context_storage_12.jobContextStorage.getStore();
17989
18045
  if (!store?.jobId || !store?.taskId) {
17990
18046
  throw new Error("Job context not available - jobId and taskId are required");
17991
18047
  }
17992
- const localJobContext = {
17993
- jobId: store.jobId,
17994
- taskId: store.taskId
18048
+ const { jobId, taskId, kind } = store;
18049
+ const localJobContext = { jobId, taskId };
18050
+ const biBaseParams = {
18051
+ Job_id: jobId,
18052
+ Task_id: taskId,
18053
+ app_id: context_12.ctx.projectId,
18054
+ Dev_machine_session_id: process.env.CODEGEN_SESSION_ID,
18055
+ run_kind: kind,
18056
+ job_input: JSON.stringify(chatHistory)
17995
18057
  };
17996
- logger_12.logger.info("[OpenCode Ask] Starting task", {
17997
- taskId: localJobContext.taskId
17998
- });
17999
- await codeGenerationService_12.codeGenerationService.updateTask(localJobContext.jobId, localJobContext.taskId, ditto_codegen_types_12.Status.RUNNING, {});
18000
- logger_12.logger.info("[OpenCode Ask] Marked task RUNNING", {
18001
- taskId: localJobContext.taskId
18058
+ logger_12.logger.info("[OpenCode Ask] Starting task", { taskId });
18059
+ await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.RUNNING, {});
18060
+ logger_12.logger.info("[OpenCode Ask] Marked task RUNNING", { taskId });
18061
+ (0, biEvents_1.reportSessionStart)({
18062
+ ...biBaseParams,
18063
+ Task_model: config_1.DEFAULT_MODEL,
18064
+ Task_type: kind
18002
18065
  });
18003
18066
  try {
18004
18067
  const outputPath = (0, codegen_flow_helpers_12.getOutputPath)();
@@ -18009,16 +18072,43 @@ var require_opencode_ask = __commonJS({
18009
18072
  projectId: context_12.ctx.projectId,
18010
18073
  chatHistory
18011
18074
  });
18012
- await codeGenerationService_12.codeGenerationService.updateTask(localJobContext.jobId, localJobContext.taskId, ditto_codegen_types_12.Status.COMPLETED, {
18075
+ await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.COMPLETED, {
18013
18076
  taskOutput: {
18014
18077
  answer: result.answer
18015
18078
  }
18016
18079
  });
18017
- logger_12.logger.info("[OpenCode Ask] Completed task");
18080
+ (0, biEvents_1.reportSessionEnd)({
18081
+ ...biBaseParams,
18082
+ Task_model: config_1.DEFAULT_MODEL,
18083
+ Task_type: kind,
18084
+ Task_cost: Math.round(result.usage.cost * 1e6),
18085
+ Task_status: ditto_codegen_types_12.Status.COMPLETED,
18086
+ Agent_output: JSON.stringify({ answer: result.answer })
18087
+ });
18088
+ logger_12.logger.info("[OpenCode Ask] Completed task", { taskId });
18018
18089
  } catch (error) {
18019
18090
  const codegenError = (0, ditto_codegen_types_2.toCodegenError)(error);
18020
18091
  await (0, codegen_flow_helpers_12.updateParentTaskStatus)(localJobContext, ditto_codegen_types_12.Status.FAILED, codegenError);
18092
+ (0, biEvents_1.reportSessionEnd)({
18093
+ ...biBaseParams,
18094
+ Task_model: config_1.DEFAULT_MODEL,
18095
+ Task_type: kind,
18096
+ Task_status: ditto_codegen_types_12.Status.FAILED
18097
+ });
18098
+ (0, biEvents_1.reportSessionError)({
18099
+ ...biBaseParams,
18100
+ task_model: config_1.DEFAULT_MODEL,
18101
+ task_type: kind,
18102
+ Agent_output: JSON.stringify(codegenError),
18103
+ Error_desc: codegenError.errorType,
18104
+ error_massage: codegenError.message,
18105
+ error_json: JSON.stringify(codegenError),
18106
+ is_retryable: codegenError.retryable,
18107
+ is_expected: codegenError.expected,
18108
+ validation_type: codegenError.validationType
18109
+ });
18021
18110
  logger_12.logger.error("[OpenCode Ask] Failed task", {
18111
+ taskId,
18022
18112
  error: error instanceof Error ? error.message : String(error)
18023
18113
  });
18024
18114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.294",
3
+ "version": "1.0.296",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -27,5 +27,5 @@
27
27
  "@wix/ditto-codegen": "1.0.0",
28
28
  "esbuild": "^0.27.2"
29
29
  },
30
- "falconPackageHash": "6125c4c39a2c5d06b6cfdaadc601ecddcaab97b50fc7b8524f2102b8"
30
+ "falconPackageHash": "70e4d2ee1d465a2ed6701d8d2d7f58175b84d7b45e3afe4c4b7cd351"
31
31
  }