makefx 1.0.1 → 1.0.2

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 (3) hide show
  1. package/README.md +1 -1
  2. package/makefx.mjs +42 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -176,4 +176,4 @@ Run `makefx --help` or `makefx help <command>` for command-specific options.
176
176
  - Media generation guide: https://makefx.app/docs/media-playbooks
177
177
  - Source: https://github.com/krasnoperov/inventory
178
178
 
179
- Version: 1.0.1
179
+ Version: 1.0.2
package/makefx.mjs CHANGED
@@ -5609,6 +5609,33 @@ Examples:
5609
5609
  `);
5610
5610
  }
5611
5611
  //#endregion
5612
+ //#region src/cli/lib/error-format.ts
5613
+ function formatServerErrorMessage(code, message) {
5614
+ return `${code}: ${formatGenerationFailureMessage(message)}`;
5615
+ }
5616
+ function formatGenerationFailureMessage(message) {
5617
+ const rawMessage = message?.trim() || "Generation failed";
5618
+ const cleanMessage = extractProviderErrorMessage(rawMessage) ?? rawMessage;
5619
+ if (isProviderAuthenticationError(cleanMessage)) return "The generation provider is not configured correctly. Try again later or contact Make Effects support.";
5620
+ return cleanMessage;
5621
+ }
5622
+ function extractProviderErrorMessage(message) {
5623
+ const match = message.match(/ApiError:\s*(\{.*\})/s);
5624
+ if (!match) return null;
5625
+ try {
5626
+ const parsed = JSON.parse(match[1]);
5627
+ if (typeof parsed.error?.message === "string") return parsed.error.message;
5628
+ if (typeof parsed.error?.status === "string") return parsed.error.status;
5629
+ } catch {
5630
+ return "Provider request failed";
5631
+ }
5632
+ return "Provider request failed";
5633
+ }
5634
+ function isProviderAuthenticationError(message) {
5635
+ const lower = message.toLowerCase();
5636
+ return lower.includes("api key not valid") || lower.includes("api_key_invalid") || lower.includes("invalid api key") || lower.includes("generativelanguage.googleapis.com");
5637
+ }
5638
+ //#endregion
5612
5639
  //#region src/cli/lib/run-manifest.ts
5613
5640
  function createRunId(date = /* @__PURE__ */ new Date()) {
5614
5641
  return `${date.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z")}-${crypto.randomUUID().slice(0, 8)}`;
@@ -5866,7 +5893,7 @@ var WebSocketClient = class WebSocketClient {
5866
5893
  accessToken;
5867
5894
  env;
5868
5895
  spaceId;
5869
- connectionLoggingEnabled = true;
5896
+ connectionLoggingEnabled = false;
5870
5897
  chatHandlers = /* @__PURE__ */ new Map();
5871
5898
  generateHandlers = /* @__PURE__ */ new Map();
5872
5899
  batchHandlers = /* @__PURE__ */ new Map();
@@ -5926,11 +5953,10 @@ var WebSocketClient = class WebSocketClient {
5926
5953
  const message = JSON.parse(data.toString());
5927
5954
  this.handleMessage(message);
5928
5955
  } catch (err) {
5929
- console.error("[WebSocketClient] Error parsing message:", err);
5956
+ this.onError?.(err instanceof Error ? err : /* @__PURE__ */ new Error("Received an unreadable real-time update"));
5930
5957
  }
5931
5958
  });
5932
5959
  this.ws.on("error", (err) => {
5933
- console.error("[WebSocketClient] WebSocket error:", err);
5934
5960
  this.onError?.(err);
5935
5961
  reject(err);
5936
5962
  });
@@ -6053,7 +6079,7 @@ var WebSocketClient = class WebSocketClient {
6053
6079
  if (handler) {
6054
6080
  this.generateHandlers.delete(errorMsg.requestId);
6055
6081
  clearTimeout(handler.timeout);
6056
- handler.reject(/* @__PURE__ */ new Error(`${errorMsg.code}: ${errorMsg.error}`));
6082
+ handler.reject(new Error(formatServerErrorMessage(errorMsg.code, errorMsg.error)));
6057
6083
  }
6058
6084
  break;
6059
6085
  }
@@ -6063,7 +6089,7 @@ var WebSocketClient = class WebSocketClient {
6063
6089
  if (handler) {
6064
6090
  this.batchHandlers.delete(errorMsg.requestId);
6065
6091
  clearTimeout(handler.timeout);
6066
- handler.reject(/* @__PURE__ */ new Error(`${errorMsg.code}: ${errorMsg.error}`));
6092
+ handler.reject(new Error(formatServerErrorMessage(errorMsg.code, errorMsg.error)));
6067
6093
  }
6068
6094
  break;
6069
6095
  }
@@ -6088,7 +6114,7 @@ var WebSocketClient = class WebSocketClient {
6088
6114
  if (variant.status === "completed") batchHandler.completed.push(variant);
6089
6115
  else batchHandler.failed.push({
6090
6116
  variantId: variant.id,
6091
- error: variant.error_message || "Generation failed"
6117
+ error: formatGenerationFailureMessage(variant.error_message)
6092
6118
  });
6093
6119
  if (batchHandler.pending.size === 0) {
6094
6120
  this.batchHandlers.delete(batchRequestId);
@@ -6116,7 +6142,7 @@ var WebSocketClient = class WebSocketClient {
6116
6142
  jobId: variant.id,
6117
6143
  success: variant.status === "completed",
6118
6144
  variant: variant.status === "completed" ? variant : void 0,
6119
- error: variant.status === "failed" ? variant.error_message || "Generation failed" : void 0
6145
+ error: variant.status === "failed" ? formatGenerationFailureMessage(variant.error_message) : void 0
6120
6146
  };
6121
6147
  handler.onResult(result);
6122
6148
  }
@@ -6167,7 +6193,7 @@ var WebSocketClient = class WebSocketClient {
6167
6193
  const mutationConsumed = this.failMutationWaiters(error);
6168
6194
  const estimateConsumed = this.failEstimateHandlers(error);
6169
6195
  if (!(mutationConsumed || estimateConsumed)) {
6170
- console.error(`[WebSocketClient] Server error: ${errorMsg.code} - ${errorMsg.message}`);
6196
+ console.error(`Server error: ${formatServerErrorMessage(errorMsg.code, errorMsg.message)}`);
6171
6197
  this.onError?.(new Error(errorMsg.message));
6172
6198
  }
6173
6199
  break;
@@ -7068,10 +7094,15 @@ async function handleForgeCommand(command, parsed) {
7068
7094
  await executeForgeCommand(command, parsed, defaultDeps$7);
7069
7095
  } catch (error) {
7070
7096
  console.error("Error:", error instanceof Error ? error.message : error);
7071
- printUsage$7(command);
7097
+ if (shouldPrintUsageForForgeError(error)) printUsage$7(command);
7072
7098
  process$1.exitCode = 1;
7073
7099
  }
7074
7100
  }
7101
+ function shouldPrintUsageForForgeError(error) {
7102
+ if (!(error instanceof Error)) return false;
7103
+ const message = error.message;
7104
+ return message.startsWith("--") || message.startsWith("Output path is required") || message.startsWith("Output directory is required") || message.startsWith("Pass either prompt text") || message.startsWith("Speech generation requires") || message.startsWith("Dialogue generation requires") || message.startsWith("Prompt is required");
7105
+ }
7075
7106
  async function executeForgeCommand(command, parsed, deps = defaultDeps$7, options = {}) {
7076
7107
  const mediaKind = options.mediaKind || CLI_GENERATION_MEDIA_KIND;
7077
7108
  if (parsed.options.follow) {
@@ -7497,7 +7528,7 @@ function resultFromTerminalVariant(variant, requestId) {
7497
7528
  requestId,
7498
7529
  jobId: variant.id,
7499
7530
  success: false,
7500
- error: variant.error_message || "Generation failed"
7531
+ error: formatGenerationFailureMessage(variant.error_message)
7501
7532
  };
7502
7533
  }
7503
7534
  function parseGenerationRecipe(recipeJson) {
@@ -9256,7 +9287,7 @@ Options:
9256
9287
  }
9257
9288
  //#endregion
9258
9289
  //#region src/cli/index.ts
9259
- var CLI_VERSION = "1.0.1+b273381daffd";
9290
+ var CLI_VERSION = "1.0.2+ce1ff2c1182d";
9260
9291
  async function main() {
9261
9292
  const argv = process$1.argv.slice(2);
9262
9293
  if (argv[0] === "--") argv.shift();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makefx",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Command-line interface for AI-assisted game asset production with Make Effects.",
5
5
  "license": "MIT",
6
6
  "type": "module",