@wix/ditto-codegen-public 1.0.389 → 1.0.391

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 CHANGED
@@ -80,6 +80,7 @@ var require_types_impl = __commonJS({
80
80
  ErrorType2["PROCESS_EXECUTION_ERROR"] = "PROCESS_EXECUTION_ERROR";
81
81
  ErrorType2["UNEXPECTED_ERROR"] = "UNEXPECTED_ERROR";
82
82
  ErrorType2["MISSING_JOB_ID_ERROR"] = "MISSING_JOB_ID_ERROR";
83
+ ErrorType2["USER_DECISION_TIMEOUT_ERROR"] = "USER_DECISION_TIMEOUT_ERROR";
83
84
  })(ErrorType || (exports2.ErrorType = ErrorType = {}));
84
85
  var FileOperation;
85
86
  (function(FileOperation2) {
@@ -10845,22 +10846,13 @@ var require_CodeGenService = __commonJS({
10845
10846
  [ditto_codegen_types_12.ProcessType.EXECUTION]: types_1.ProcessType.EXECUTION,
10846
10847
  [ditto_codegen_types_12.ProcessType.INITIALIZATION]: types_1.ProcessType.INITIALIZATION
10847
10848
  };
10848
- var ERROR_TYPE = {
10849
- [ditto_codegen_types_12.ErrorType.TIMEOUT_ERROR]: types_1.ErrorType.TIMEOUT_ERROR,
10850
- [ditto_codegen_types_12.ErrorType.PROCESS_EXECUTION_ERROR]: types_1.ErrorType.PROCESS_EXECUTION_ERROR,
10851
- [ditto_codegen_types_12.ErrorType.UNEXPECTED_ERROR]: types_1.ErrorType.UNEXPECTED_ERROR,
10852
- [ditto_codegen_types_12.ErrorType.MISSING_JOB_ID_ERROR]: types_1.ErrorType.MISSING_JOB_ID_ERROR,
10853
- // TODO: map to ApiErrorType.USER_DECISION_TIMEOUT_ERROR once the proto change (PR #938)
10854
- // is GA'd and the generated API enum includes it. For now report it as TIMEOUT_ERROR.
10855
- [ditto_codegen_types_12.ErrorType.USER_DECISION_TIMEOUT_ERROR]: types_1.ErrorType.TIMEOUT_ERROR
10856
- };
10857
10849
  function toApiError(error) {
10858
10850
  if (!error)
10859
10851
  return void 0;
10860
10852
  return {
10861
10853
  name: error.name,
10862
10854
  message: error.message,
10863
- errorType: ERROR_TYPE[error.errorType],
10855
+ errorType: error.errorType,
10864
10856
  retryable: error.retryable,
10865
10857
  expected: error.expected,
10866
10858
  ..."processType" in error && error.processType && { processType: PROCESS_TYPE[error.processType] },
@@ -10869,7 +10861,7 @@ var require_CodeGenService = __commonJS({
10869
10861
  };
10870
10862
  }
10871
10863
  function toJobOutput(payload) {
10872
- const { requiredPermissions, files, extensions, error, agentMessage, userActions, ...rest } = payload;
10864
+ const { requiredPermissions, files, extensions, error, agentMessage, ...rest } = payload;
10873
10865
  return {
10874
10866
  requiredPermissions,
10875
10867
  files: files?.map((file) => ({
@@ -10888,7 +10880,6 @@ var require_CodeGenService = __commonJS({
10888
10880
  })),
10889
10881
  error: toApiError(error),
10890
10882
  agentMessage,
10891
- userActions,
10892
10883
  agentOutput: Object.keys(rest).length > 0 ? rest : void 0
10893
10884
  };
10894
10885
  }
@@ -14363,7 +14354,6 @@ TOOL USAGE:
14363
14354
  - \`uuid\` to generate UUIDs (supports count param for multiple). Do NOT use bash.
14364
14355
  - \`wix-generate\` to scaffold extensions non-interactively \u2014 prefer over hand-writing boilerplate; pass an array to scaffold several at once. It RETURNS every created file's contents, so trust that and do NOT \`read\`/\`batch-read\` them afterward. On a \`FAILED\` block, fix the params per the error and retry.
14365
14356
  - \`required-permissions\` \u2014 declare the Wix app permissions the generated code needs (when/whether to call: workflow step 6 + PERMISSIONS).
14366
- - \`user-actions\` \u2014 declare manual setup steps the user must perform (when/whether to call: workflow step 7 + USER ACTIONS).
14367
14357
  - Package dependencies \u2014 \`npm install <pkg>\` any package not already in \`package.json\` BEFORE the first \`validate\` (do NOT wait for \`TS2307\`); install all needed packages in ONE command. Do NOT hand-edit \`package.json\` for deps unless npm cannot be used.
14368
14358
  - File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
14369
14359
  - \`batch-write\` to create N new files in one call. NEVER call \`write\` more than once per turn \u2014 use batch-write instead. \`write\` is reserved for single-file creation.
@@ -14385,7 +14375,7 @@ IMPLEMENTATION WORKFLOW:
14385
14375
  4. **Register**: Register all extensions in \`src/extensions.ts\`. Include a \`progress\` call (e.g. "Registering extensions").
14386
14376
  5. **Validate**: Run \`validate\` (typecheck only). Fix any errors and re-validate until tsc passes. Include a \`progress\` call (e.g. "Running type checks"). Then run \`validate({ runBuild: true })\` ONCE to verify the build. Pass \`installDeps: true\` ONLY when \`package.json\` changed without already running \`npm install <package-name>\` in this iteration; otherwise omit it (node_modules is pre-installed). Include a \`progress\` call (e.g. "Building project").
14387
14377
  6. **Declare permissions**: If the generated code requires Wix app permissions, call \`required-permissions\` ONCE with their SCOPE IDs (see PERMISSIONS below). Skip this step entirely if no permissions are needed.
14388
- 7. **Declare user actions**: If the user must perform manual steps for the app to work, call \`user-actions\` ONCE with them (see USER ACTIONS below). Skip this step entirely if there are none.
14378
+ 7. **Final message**: Your last message is returned to the user as the codegen output \u2014 keep it short and plain (a sentence or two on what the app now does).
14389
14379
  8. **Stop**: STOP immediately. Do NOT refactor, clean up, or verify.
14390
14380
 
14391
14381
  FILE CREATION:
@@ -14402,25 +14392,7 @@ When you call \`required-permissions\` (see workflow step 6 for when), use SCOPE
14402
14392
  - Embedded scripts \u2192 "SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS"
14403
14393
 
14404
14394
  CRITICAL: Only include permissions you have explicitly seen in the Wix SDK documentation (via MCP or loaded skills) \u2014 NEVER guess or infer a scope ID. If you cannot point to where you saw it, do NOT include it. When in doubt, skip the call entirely. A fabricated scope ID will show an error to the user and confuse them; a missing permission is just a warning the user can fix.
14405
-
14406
- USER ACTIONS:
14407
- A user action is manual setup the app needs to ACTUALLY WORK \u2014 either OUTSIDE Wix (third-party API keys, connecting an external account, registering a webhook elsewhere) or INSIDE Wix that you could not do in code (e.g. creating a Wix Triggered Email template, configuring a Wix Automation, adding a value in Secrets Manager). (When/whether to call: workflow step 7.)
14408
- \`output\` is a single markdown string rendered directly to the user: a short intro line + a bulleted/numbered list. FORMAT TIGHTLY \u2014 a SINGLE \`\\n\` between every line (intro\u2192first item AND between items); NEVER blank lines (\`\\n\\n\`), which make the client render each item with extra spacing. Example:
14409
- "After installing the app, complete these steps:\\n1. **Add your Stripe secret key** \u2014 open the app's settings and paste your Stripe secret key.\\n2. **Create the stock-alert email template** \u2014 in your Wix dashboard, create a Triggered Email template so subscribers receive the alert email."
14410
-
14411
- AUDIENCE \u2014 say WHO performs each step. Most third-party credentials and dashboard setup (their API key, creating a Triggered Email template, configuring an automation) are done by the SITE OWNER who installs the app, NOT the developer \u2014 phrase those as "After installing the app, \u2026" or "The site owner must \u2026". Use developer-facing phrasing only for steps the developer genuinely performs (in Dev Center / the app's own settings).
14412
-
14413
- CRITICAL \u2014 a user action is something the USER does in a dashboard, UI, or external system. It is NEVER a coding task. Do NOT ask the user to write, add, or modify code, call an API from the codebase, wire up logic, or "finish" an implementation \u2014 that is YOUR job. If a step can be done in code, you MUST do it now, not declare it. (E.g. if a feature needs to send an email, write the sending code yourself; only the dashboard email-template setup is a user action.)
14414
-
14415
- CRITICAL \u2014 declare ONLY steps the app REQUIRES to function as built. Do NOT include optional customizations, "for future" tweaks, nice-to-haves, or steps for an alternative path you did not implement. Every action must be mandatory for the app to work.
14416
-
14417
- If a feature only works once the user does required manual setup (e.g. you logged a notification intent because the actual email needs a Triggered Email template), you MUST declare that step here \u2014 do NOT bury it in prose or leave it unsaid.
14418
-
14419
- Do NOT include the steps Wix already handles through its own flows:
14420
- - ANYTHING about permissions or scopes \u2014 adding, granting, enabling, or configuring a permission/scope, whether in Dev Center or the dashboard. These are declared EXCLUSIVELY via the \`required-permissions\` tool.
14421
- - Releasing a new app version.
14422
- - Publishing the site.
14423
- Also do NOT include things you already did in code (created files, registered extensions) or things the app does automatically on install. In particular, a site plugin configured with \`installation: { autoAdd: true }\` is placed on its slot automatically \u2014 NEVER tell the user to add it in the Editor. Only declare manual placement for slots that don't support auto-add (e.g. the checkout page).`;
14395
+ `;
14424
14396
  }
14425
14397
  });
14426
14398
 
@@ -14775,10 +14747,6 @@ var require_config = __commonJS({
14775
14747
  [
14776
14748
  "required-permissions"
14777
14749
  /* OpenCodeTool.RequiredPermissions */
14778
- ]: "deny",
14779
- [
14780
- "user-actions"
14781
- /* OpenCodeTool.UserActions */
14782
14750
  ]: "deny"
14783
14751
  };
14784
14752
  var ASK_PERMISSIONS = {
@@ -14882,38 +14850,12 @@ var require_types4 = __commonJS({
14882
14850
  }
14883
14851
  });
14884
14852
 
14885
- // dist/opencode-integration/normalize-tool-string.js
14886
- var require_normalize_tool_string = __commonJS({
14887
- "dist/opencode-integration/normalize-tool-string.js"(exports2) {
14888
- "use strict";
14889
- Object.defineProperty(exports2, "__esModule", { value: true });
14890
- exports2.normalizeToolString = normalizeToolString;
14891
- function unescapeString(str) {
14892
- return str.replace(/\\(n|t|r|"|\\)/g, (_, c) => {
14893
- if (c === "n")
14894
- return "\n";
14895
- if (c === "t")
14896
- return " ";
14897
- if (c === "r")
14898
- return "\r";
14899
- if (c === '"')
14900
- return '"';
14901
- return "\\";
14902
- });
14903
- }
14904
- function normalizeToolString(text) {
14905
- return unescapeString(text).replace(/\r\n/g, "\n");
14906
- }
14907
- }
14908
- });
14909
-
14910
14853
  // dist/opencode-integration/parser.js
14911
14854
  var require_parser = __commonJS({
14912
14855
  "dist/opencode-integration/parser.js"(exports2) {
14913
14856
  "use strict";
14914
14857
  Object.defineProperty(exports2, "__esModule", { value: true });
14915
14858
  exports2.parseRequiredPermissions = parseRequiredPermissions;
14916
- exports2.parseUserActions = parseUserActions;
14917
14859
  exports2.parseAnswerText = parseAnswerText;
14918
14860
  exports2.createEmptyUsageStats = createEmptyUsageStats;
14919
14861
  exports2.parseUsageStats = parseUsageStats;
@@ -14921,10 +14863,6 @@ var require_parser = __commonJS({
14921
14863
  exports2.hasSessionError = hasSessionError;
14922
14864
  exports2.summarizeOpenCodeLine = summarizeOpenCodeLine;
14923
14865
  var types_1 = require_types4();
14924
- var normalize_tool_string_1 = require_normalize_tool_string();
14925
- function parseEvents(output, type) {
14926
- return output.split("\n").filter((line) => line.trim()).map((line) => (0, types_1.tryParseJson)(line)).filter((event) => event !== null && event.type === type);
14927
- }
14928
14866
  function parseRequiredPermissions(output) {
14929
14867
  let permissions = [];
14930
14868
  const lines = output.split("\n");
@@ -14942,25 +14880,9 @@ var require_parser = __commonJS({
14942
14880
  }
14943
14881
  return permissions;
14944
14882
  }
14945
- function parseUserActions(output) {
14946
- let markdown = "";
14947
- const lines = output.split("\n");
14948
- for (const line of lines) {
14949
- if (!line.trim())
14950
- continue;
14951
- const event = (0, types_1.tryParseJson)(line);
14952
- if (!event || event.type !== "tool_use" || event.part?.tool !== "user-actions" || event.part.state?.status !== "completed") {
14953
- continue;
14954
- }
14955
- const declared = event.part.state.input?.output;
14956
- if (typeof declared !== "string")
14957
- continue;
14958
- markdown = (0, normalize_tool_string_1.normalizeToolString)(declared);
14959
- }
14960
- return markdown;
14961
- }
14962
14883
  function parseAnswerText(output) {
14963
- return parseEvents(output, "text").map((event) => event.part?.text).filter(Boolean).join("").trim();
14884
+ const messages = output.split("\n").map((line) => (0, types_1.tryParseJson)(line)).filter((event) => event?.type === "text").map((event) => event.part?.text ?? "");
14885
+ return (messages[messages.length - 1] ?? "").trim();
14964
14886
  }
14965
14887
  function createEmptyUsageStats() {
14966
14888
  return {
@@ -15469,7 +15391,7 @@ var require_result_builder = __commonJS({
15469
15391
  exitCode: null,
15470
15392
  stdout,
15471
15393
  stderr,
15472
- userActions: (0, parser_1.parseUserActions)(stdout),
15394
+ agentMessage: (0, parser_1.parseAnswerText)(stdout),
15473
15395
  error: new ditto_codegen_types_12.TimeoutError(message),
15474
15396
  durationMs: Date.now() - startTime,
15475
15397
  requiredPermissions: [],
@@ -15483,7 +15405,7 @@ var require_result_builder = __commonJS({
15483
15405
  exitCode: code,
15484
15406
  stdout,
15485
15407
  stderr,
15486
- userActions: (0, parser_1.parseUserActions)(stdout),
15408
+ agentMessage: (0, parser_1.parseAnswerText)(stdout),
15487
15409
  error: code !== 0 ? new ditto_codegen_types_12.ProcessExecutionError(`Code generation process exited unexpectedly (exit code ${code})`, {
15488
15410
  processType: ditto_codegen_types_12.ProcessType.EXECUTION,
15489
15411
  exitCode: code ?? void 0,
@@ -15501,7 +15423,7 @@ var require_result_builder = __commonJS({
15501
15423
  exitCode: null,
15502
15424
  stdout,
15503
15425
  stderr,
15504
- userActions: (0, parser_1.parseUserActions)(stdout),
15426
+ agentMessage: (0, parser_1.parseAnswerText)(stdout),
15505
15427
  error: new ditto_codegen_types_12.ProcessExecutionError(`Failed to start code generation process: ${errorMessage}`, {
15506
15428
  processType: ditto_codegen_types_12.ProcessType.SPAWN,
15507
15429
  stderr
@@ -15626,7 +15548,6 @@ var require_executor = __commonJS({
15626
15548
  var MAX_RETRIES = 5;
15627
15549
  async function executeOpenCode(options) {
15628
15550
  let lastResult = null;
15629
- let accumulatedStdout = "";
15630
15551
  let accumulatedUsage = (0, parser_1.createEmptyUsageStats)();
15631
15552
  const accumulatedSkills = [];
15632
15553
  let currentPrompt = options.prompt;
@@ -15639,7 +15560,6 @@ var require_executor = __commonJS({
15639
15560
  continueSession = false;
15640
15561
  }
15641
15562
  const result = await executeOpenCodeOnce({ ...options, prompt: currentPrompt, continueSession }, attempt);
15642
- accumulatedStdout += result.stdout;
15643
15563
  accumulatedUsage = (0, parser_1.mergeUsageStats)(accumulatedUsage, result.usage);
15644
15564
  accumulatedSkills.push(...result.skillsUsed);
15645
15565
  const errorMsg = result.error?.message.toLowerCase() ?? "";
@@ -15649,7 +15569,7 @@ var require_executor = __commonJS({
15649
15569
  if (!isRetryableFailure) {
15650
15570
  const finalResult2 = {
15651
15571
  ...result,
15652
- userActions: (0, parser_1.parseUserActions)(accumulatedStdout),
15572
+ agentMessage: (0, parser_1.parseAnswerText)(result.stdout),
15653
15573
  usage: accumulatedUsage,
15654
15574
  skillsUsed: accumulatedSkills
15655
15575
  };
@@ -15669,7 +15589,7 @@ var require_executor = __commonJS({
15669
15589
  });
15670
15590
  const finalResult = {
15671
15591
  ...lastResult,
15672
- userActions: (0, parser_1.parseUserActions)(accumulatedStdout),
15592
+ agentMessage: (0, parser_1.parseAnswerText)(lastResult.stdout),
15673
15593
  usage: accumulatedUsage,
15674
15594
  skillsUsed: Array.from(accumulatedSkills)
15675
15595
  };
@@ -15749,7 +15669,7 @@ var require_executor = __commonJS({
15749
15669
  exitCode: null,
15750
15670
  stdout: state.stdout,
15751
15671
  stderr: state.stderr,
15752
- userActions: (0, parser_1.parseUserActions)(state.stdout),
15672
+ agentMessage: (0, parser_1.parseAnswerText)(state.stdout),
15753
15673
  error: new ditto_codegen_types_12.ProcessExecutionError(`Code generation process failed to run: ${error instanceof Error ? error.message : String(error)}`, {
15754
15674
  processType: ditto_codegen_types_12.ProcessType.EXECUTION,
15755
15675
  cause: error
@@ -21266,7 +21186,7 @@ var require_opencode_init = __commonJS({
21266
21186
  await (0, inject_created_by_1.injectCreatedByIntoExtensionFiles)(outputPath, extensions.created);
21267
21187
  await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
21268
21188
  requiredPermissions: result.requiredPermissions,
21269
- userActions: result.userActions,
21189
+ agentMessage: result.agentMessage,
21270
21190
  files,
21271
21191
  ...agentOutput,
21272
21192
  extensions
@@ -21456,7 +21376,7 @@ var require_opencode_iterate = __commonJS({
21456
21376
  await (0, inject_created_by_1.injectCreatedByIntoExtensionFiles)(outputPath, extensions.created);
21457
21377
  await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
21458
21378
  requiredPermissions: result.requiredPermissions,
21459
- userActions: result.userActions,
21379
+ agentMessage: result.agentMessage,
21460
21380
  files,
21461
21381
  ...agentOutput,
21462
21382
  extensions
@@ -21817,6 +21737,7 @@ var require_opencode_fix_git_conflicts = __commonJS({
21817
21737
  const extensions = await (0, collect_extensions_created_1.buildExtensionsJobPayload)(outputPath, files);
21818
21738
  await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
21819
21739
  requiredPermissions: result.requiredPermissions,
21740
+ agentMessage: result.agentMessage,
21820
21741
  files,
21821
21742
  extensions
21822
21743
  });
@@ -21993,10 +21914,11 @@ var require_job_timeout_monitor = __commonJS({
21993
21914
  });
21994
21915
  try {
21995
21916
  logger_12.logger.info("[Job] Timeout detected, exiting", logContext);
21996
- 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`));
21917
+ const codegenError = await this.resolveTimeoutError(jobId);
21918
+ await (0, utils_1.updateAllRunningTasks)(jobId, ditto_codegen_types_12.Status.FAILED, codegenError);
21997
21919
  await this.codeGenerationService.markJobAsCompleted(jobId);
21998
21920
  logger_12.logger.info("[Job] Marked job as completed, failed all running tasks", logContext);
21999
- await this.reportTimeoutBi(jobId);
21921
+ await this.reportTimeoutBi(jobId, codegenError);
22000
21922
  process.exit();
22001
21923
  } catch (error) {
22002
21924
  logger_12.logger.error("[Job] Failed to mark timed-out job as completed", {
@@ -22005,7 +21927,22 @@ var require_job_timeout_monitor = __commonJS({
22005
21927
  });
22006
21928
  }
22007
21929
  }
22008
- async reportTimeoutBi(jobId) {
21930
+ async resolveTimeoutError(jobId) {
21931
+ try {
21932
+ const job = await this.codeGenerationService.getJob(jobId);
21933
+ const pendingDecision = job?.pendingUserDecisions?.find((decision) => !decision.response?.selectedOptionId);
21934
+ if (pendingDecision?.id) {
21935
+ return new ditto_codegen_types_12.UserDecisionTimeoutError(jobId, pendingDecision.id);
21936
+ }
21937
+ } catch (error) {
21938
+ logger_12.logger.warn("[Job] Could not determine timeout error type", {
21939
+ jobId,
21940
+ error: error instanceof Error ? error.message : String(error)
21941
+ });
21942
+ }
21943
+ return new ditto_codegen_types_12.TimeoutError(`Job exceeded timeout of ${exports2.JOB_TIMEOUT_MS}ms`);
21944
+ }
21945
+ async reportTimeoutBi(jobId, codegenError) {
22009
21946
  const store = job_context_storage_12.jobContextStorage.getStore();
22010
21947
  if (!store)
22011
21948
  return;
@@ -22019,7 +21956,6 @@ var require_job_timeout_monitor = __commonJS({
22019
21956
  runKind: store.kind,
22020
21957
  environment
22021
21958
  };
22022
- const codegenError = (0, ditto_codegen_types_12.toCodegenError)(new ditto_codegen_types_12.TimeoutError(`Job exceeded timeout of ${exports2.JOB_TIMEOUT_MS}ms`));
22023
21959
  await (0, biEvents_1.reportSessionEnd)({
22024
21960
  ...biBase,
22025
21961
  taskStatus: ditto_codegen_types_12.Status.FAILED,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.389",
3
+ "version": "1.0.391",
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": "1f2c19ad8ba834649254819e388cb4feb7516e76da78903eee56d3d2"
32
+ "falconPackageHash": "ffaf520e25dae6b0db9450f128f6eedcf0cd611df74594a0e682a01c"
33
33
  }
@@ -1,19 +0,0 @@
1
- import { tool } from "@opencode-ai/plugin";
2
-
3
- export default tool({
4
- description:
5
- "Declare the manual setup steps the user must perform for the generated app to " +
6
- "work, as a single markdown string. Call once at the end, only if such setup is " +
7
- "required.",
8
- args: {
9
- output: tool.schema
10
- .string()
11
- .describe(
12
- "The setup steps, as markdown (a short intro line followed by a bulleted or " +
13
- "numbered list). Rendered directly to the user.",
14
- ),
15
- },
16
- async execute(args) {
17
- return `✓ recorded user actions (${args.output.length} chars)`;
18
- },
19
- });