makefx 1.6.12 → 1.6.13

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 +130 -37
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -77,4 +77,4 @@ IDs, or runs. Retired commands and aliases are not redirected.
77
77
 
78
78
  Run `makefx --help` or `makefx <noun> --help` for current options.
79
79
 
80
- Version: 1.6.12
80
+ Version: 1.6.13
package/makefx.mjs CHANGED
@@ -292,7 +292,7 @@ function resolveMediaType(ext, requestedMediaKind) {
292
292
  }
293
293
  //#endregion
294
294
  //#region src/cli/version.ts
295
- var CLI_VERSION = "1.6.12+2a9af5c5c870";
295
+ var CLI_VERSION = "1.6.13+1b64f349b8b2";
296
296
  var CLI_VERSION_HEADER = "X-MakeFX-CLI-Version";
297
297
  function cliVersionHeaders() {
298
298
  return {
@@ -4562,6 +4562,26 @@ var WebSocketClient = class WebSocketClient {
4562
4562
  if (this.env === "local" && protocol === "wss") wsOptions.agent = new https.Agent({ rejectUnauthorized: false });
4563
4563
  else if (this.env === "local" && protocol === "ws") wsOptions.agent = new http.Agent();
4564
4564
  this.ws = new wrapper_default(url, wsOptions);
4565
+ this.ws.once("unexpected-response", (_request, response) => {
4566
+ let responseBody = "";
4567
+ response.setEncoding("utf8");
4568
+ response.on("data", (chunk) => {
4569
+ responseBody = `${responseBody}${chunk}`.slice(0, 16384);
4570
+ });
4571
+ response.on("end", () => {
4572
+ let message = `WebSocket connection rejected (${response.statusCode ?? "unknown status"})`;
4573
+ try {
4574
+ const payload = JSON.parse(responseBody);
4575
+ const detail = typeof payload.message === "string" ? payload.message : typeof payload.error === "string" ? payload.error : null;
4576
+ if (detail) message = detail;
4577
+ } catch {
4578
+ if (responseBody.trim()) message = responseBody.trim();
4579
+ }
4580
+ const error = new Error(message);
4581
+ this.onError?.(error);
4582
+ reject(error);
4583
+ });
4584
+ });
4565
4585
  this.ws.on("open", () => {
4566
4586
  if (this.connectionLoggingEnabled) console.log(`[WebSocketClient] Connected to space ${this.spaceId}`);
4567
4587
  resolve();
@@ -7304,24 +7324,82 @@ function stringValue(value) {
7304
7324
  }
7305
7325
  //#endregion
7306
7326
  //#region src/shared/recipes.ts
7327
+ var RECIPE_CREATION_ACTIONS = [
7328
+ "generate",
7329
+ "derive",
7330
+ "regenerate",
7331
+ "vary",
7332
+ "fork",
7333
+ "copy",
7334
+ "upload"
7335
+ ];
7336
+ function isRecipeCreationAction(value) {
7337
+ return typeof value === "string" && RECIPE_CREATION_ACTIONS.includes(value);
7338
+ }
7307
7339
  /** Public projections expose product semantics; resolvers expose origins as compact Variant refs. */
7308
7340
  function publicRecipeCreation(value) {
7309
- if (!isRecord(value) || typeof value.action !== "string") return void 0;
7310
- if (![
7311
- "generate",
7312
- "derive",
7313
- "regenerate",
7314
- "vary",
7315
- "fork",
7316
- "copy",
7317
- "upload"
7318
- ].includes(value.action)) return;
7341
+ if (!isRecord(value) || !isRecipeCreationAction(value.action)) return void 0;
7319
7342
  return { action: value.action };
7320
7343
  }
7321
7344
  function isRecord(value) {
7322
7345
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7323
7346
  }
7324
7347
  //#endregion
7348
+ //#region src/shared/recipeProjection.ts
7349
+ function parseRecipeObject(value) {
7350
+ try {
7351
+ const parsed = typeof value === "string" ? JSON.parse(value) : value;
7352
+ return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
7353
+ } catch {
7354
+ return null;
7355
+ }
7356
+ }
7357
+ var INTERNAL_RECIPE_CONTAINERS = new Set([
7358
+ "references",
7359
+ "uploadstorage",
7360
+ "providerrequest",
7361
+ "providerresponse",
7362
+ "providerdiagnostic",
7363
+ "providerdiagnostics",
7364
+ "providermetadata",
7365
+ "diagnostic",
7366
+ "diagnostics",
7367
+ "rawupstream",
7368
+ "upstreamraw",
7369
+ "upstreamrequest",
7370
+ "upstreamresponse"
7371
+ ]);
7372
+ function normalizedKey(key) {
7373
+ return key.replace(/[^a-zA-Z0-9]/gu, "").toLowerCase();
7374
+ }
7375
+ function isRoutingContainer(key) {
7376
+ return /(?:storage|image|media|thumb|thumbnail|sidecar)s?$/u.test(normalizedKey(key));
7377
+ }
7378
+ function isInternalField(key, value, insideRoutingContainer) {
7379
+ const normalized = normalizedKey(key);
7380
+ if (INTERNAL_RECIPE_CONTAINERS.has(normalized)) return true;
7381
+ if (/(?:storage|image|media|thumb|thumbnail|sidecar|r2|object)(?:key|keys|path|paths|url|urls|uri|uris|bucket|object|objects|locator|route|routing)$/u.test(normalized) || /(?:space|asset|variant|user|creator|run|request|workflow|task|checkpoint|execution|reference|planstep|job|prediction|generation|operation|submission)ids?$/u.test(normalized) || normalized === "createdby" || /taskpayload$/u.test(normalized) || /credentials?/u.test(normalized) || /^(?:api|auth|access|refresh|bearer|session|secret|provider)tokens?/u.test(normalized) || normalized === "token" || normalized === "tokens" || /binary|base64/u.test(normalized) || /(?:api|private|secret)(?:[a-z0-9]*)(?:key|secret)$/u.test(normalized) || /(?:secret|password)$/u.test(normalized) || normalized === "accesskey" || normalized === "authorization" || /headers?$/u.test(normalized) || /cookie/u.test(normalized) || /^(?:key|keys|path|paths|url|urls|uri|uris|bucket|object|objects|locator|route|routing)$/u.test(normalized) && insideRoutingContainer) return true;
7382
+ return (Array.isArray(value) || value !== null && typeof value === "object") && (/diagnostic/u.test(normalized) || /^(?:provider(?:request|response|metadata)|rawupstream|upstream(?:raw|request|response)|workflow|task|checkpoint|executiontarget|credential|credentials|token|tokens|binary|base64)/u.test(normalized));
7383
+ }
7384
+ function projectExternalValue(value, insideRoutingContainer = false) {
7385
+ if (Array.isArray(value)) return value.map((item) => projectExternalValue(item, insideRoutingContainer));
7386
+ if (value === null || typeof value !== "object") return value;
7387
+ return Object.fromEntries(Object.entries(value).filter(([key, child]) => !isInternalField(key, child, insideRoutingContainer)).map(([key, child]) => [key, projectExternalValue(child, insideRoutingContainer || isRoutingContainer(key))]));
7388
+ }
7389
+ /** Projection for CLI, MCP, public API, and public viewers. Raw internal IDs never cross this boundary. */
7390
+ function projectExternalRecipe(value) {
7391
+ const parsed = parseRecipeObject(value);
7392
+ if (!parsed) return null;
7393
+ const projected = projectExternalValue(parsed);
7394
+ const creation = publicRecipeCreation(projected.creation);
7395
+ const execution = projected.execution !== null && typeof projected.execution === "object" && !Array.isArray(projected.execution) ? Object.fromEntries(Object.entries(projected.execution).filter(([key]) => key !== "target")) : projected.execution;
7396
+ return {
7397
+ ...projected,
7398
+ ...execution !== void 0 ? { execution } : {},
7399
+ ...creation ? { creation } : {}
7400
+ };
7401
+ }
7402
+ //#endregion
7325
7403
  //#region src/cli/commands/assets.ts
7326
7404
  var defaultDeps$13 = {
7327
7405
  loadConfig: loadStoredConfig,
@@ -7762,8 +7840,8 @@ function printAssetDetails(details, ctx, print) {
7762
7840
  if (execution?.provider) print(` Provider: ${String(execution.provider)}`);
7763
7841
  if (execution?.model) print(` Model: ${String(execution.model)}`);
7764
7842
  if (parameters?.prompt !== void 0) print(` Prompt: ${String(parameters.prompt)}`);
7765
- if (detail.made_from.length > 0) for (const reference of detail.made_from) print(` Reference[${reference.sequence_index}] ${reference.slot}: ${formatRecipeReferenceTarget(reference)}`);
7766
- print(` Views: made_from=${detail.made_from.length} used_by=${detail.used_by_total}${detail.used_by_truncated ? "+" : ""}`);
7843
+ if (detail.parents.input.length > 0) for (const reference of detail.parents.input) print(` Reference[${reference.sequence_index}] ${reference.slot}: ${formatRecipeReferenceTarget(reference)}`);
7844
+ print(` Relations: parents=${Object.values(detail.parents).reduce((sum, group) => sum + group.length, 0)} children=${Object.values(detail.children_total).reduce((sum, count) => sum + count, 0)}`);
7767
7845
  }
7768
7846
  }
7769
7847
  }
@@ -7771,6 +7849,28 @@ function printAssetDetails(details, ctx, print) {
7771
7849
  function formatRecipeReferenceTarget(target) {
7772
7850
  return target.available && target.asset_id && target.asset_name ? createVariantRef(target.asset_name, target.asset_id, target.variant_id) : `unresolved:${target.variant_id}`;
7773
7851
  }
7852
+ function toCliRecipeTarget(target) {
7853
+ return {
7854
+ variantRef: target.available && target.asset_id && target.asset_name ? createVariantRef(target.asset_name, target.asset_id, target.variant_id) : null,
7855
+ available: target.available,
7856
+ ...target.media_kind ? { mediaKind: target.media_kind } : {},
7857
+ ...target.status ? { status: target.status } : {}
7858
+ };
7859
+ }
7860
+ function toCliInputReference(reference) {
7861
+ return {
7862
+ ...toCliRecipeTarget(reference),
7863
+ slot: reference.slot,
7864
+ sequenceIndex: reference.sequence_index,
7865
+ modalityIndex: reference.modality_index,
7866
+ mediaKind: reference.media_kind,
7867
+ mimeType: reference.mime_type,
7868
+ sizeBytes: reference.size_bytes,
7869
+ width: reference.width,
7870
+ height: reference.height,
7871
+ durationMs: reference.duration_ms
7872
+ };
7873
+ }
7774
7874
  function toAssetJson(asset) {
7775
7875
  return {
7776
7876
  assetRef: createAssetRef(asset.name, asset.id),
@@ -7804,36 +7904,29 @@ function toAssetDetailsJson(details) {
7804
7904
  issues: detail.recipe_state.issues,
7805
7905
  replayabilityIssues: detail.recipe_state.replayability_issues
7806
7906
  },
7807
- references: detail.made_from.map((reference) => ({
7808
- variantRef: reference.available && reference.asset_id && reference.asset_name ? createVariantRef(reference.asset_name, reference.asset_id, reference.variant_id) : null,
7809
- ...!reference.available ? { historicalVariantId: reference.variant_id } : {},
7810
- slot: reference.slot,
7811
- sequenceIndex: reference.sequence_index,
7812
- modalityIndex: reference.modality_index,
7813
- mediaKind: reference.media_kind,
7814
- mimeType: reference.mime_type,
7815
- sizeBytes: reference.size_bytes,
7816
- width: reference.width,
7817
- height: reference.height,
7818
- durationMs: reference.duration_ms
7819
- })),
7820
- madeFrom: detail.made_from.map(formatRecipeReferenceTarget),
7821
- usedBy: detail.used_by.map(formatRecipeReferenceTarget),
7822
- usedByTotal: detail.used_by_total,
7823
- usedByTruncated: detail.used_by_truncated
7907
+ parents: {
7908
+ input: detail.parents.input.map(toCliInputReference),
7909
+ regenerate: detail.parents.regenerate.map(toCliRecipeTarget),
7910
+ vary: detail.parents.vary.map(toCliRecipeTarget),
7911
+ fork: detail.parents.fork.map(toCliRecipeTarget),
7912
+ copy: detail.parents.copy.map(toCliRecipeTarget)
7913
+ },
7914
+ children: {
7915
+ input: detail.children.input.map(toCliRecipeTarget),
7916
+ regenerate: detail.children.regenerate.map(toCliRecipeTarget),
7917
+ vary: detail.children.vary.map(toCliRecipeTarget),
7918
+ fork: detail.children.fork.map(toCliRecipeTarget),
7919
+ copy: detail.children.copy.map(toCliRecipeTarget)
7920
+ },
7921
+ childrenTotal: detail.children_total,
7922
+ childrenTruncated: detail.children_truncated
7824
7923
  })),
7825
7924
  totalVariantCount: details.recipe_references.total_variant_count,
7826
7925
  truncated: details.recipe_references.truncated
7827
7926
  };
7828
7927
  }
7829
7928
  function publicCliRecipe(recipe) {
7830
- if (!recipe) return null;
7831
- const { references: _references, regeneration: _regeneration, copiedFromVariantId: _copiedFromVariantId, creation: rawCreation, ...publicRecipe } = recipe;
7832
- const creation = publicRecipeCreation(rawCreation);
7833
- return {
7834
- ...publicRecipe,
7835
- ...creation ? { creation } : {}
7836
- };
7929
+ return projectExternalRecipe(recipe);
7837
7930
  }
7838
7931
  function formatTimestamp(value) {
7839
7932
  if (!value) return "-";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makefx",
3
- "version": "1.6.12",
3
+ "version": "1.6.13",
4
4
  "description": "MakeFX CLI for reproducible image, video, and audio Assets in Make Effects.",
5
5
  "homepage": "https://makefx.app/docs/cli",
6
6
  "keywords": [