makefx 1.6.4 → 1.6.5

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 +30 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -61,4 +61,4 @@ IDs, or runs. Retired commands and aliases are not redirected.
61
61
 
62
62
  Run `makefx --help` or `makefx <noun> --help` for current options.
63
63
 
64
- Version: 1.6.4
64
+ Version: 1.6.5
package/makefx.mjs CHANGED
@@ -4442,7 +4442,7 @@ require_websocket_server();
4442
4442
  var wrapper_default = import_websocket.default;
4443
4443
  //#endregion
4444
4444
  //#region src/cli/version.ts
4445
- var CLI_VERSION = "1.6.4+0753202e927c";
4445
+ var CLI_VERSION = "1.6.5+9c81b1e6ede4";
4446
4446
  var CLI_VERSION_HEADER = "X-MakeFX-CLI-Version";
4447
4447
  function cliVersionHeaders() {
4448
4448
  return {
@@ -4460,6 +4460,7 @@ function cliVersionHeaders() {
4460
4460
  */
4461
4461
  var GENERATION_REQUEST_TIMEOUT_MS = 3e5;
4462
4462
  var VIDEO_GENERATION_REQUEST_TIMEOUT_MS = 72e4;
4463
+ var VARIANT_SYNC_POLL_INTERVAL_MS = 15e3;
4463
4464
  function getGenerationRequestTimeoutMs(mediaKind) {
4464
4465
  return mediaKind === "video" ? VIDEO_GENERATION_REQUEST_TIMEOUT_MS : GENERATION_REQUEST_TIMEOUT_MS;
4465
4466
  }
@@ -4656,6 +4657,7 @@ var WebSocketClient = class WebSocketClient {
4656
4657
  reject: handler.reject,
4657
4658
  timeout: handler.timeout
4658
4659
  });
4660
+ this.startVariantSyncPolling(startedMsg.variantId, startedMsg.requestId);
4659
4661
  this.generateHandlers.delete(startedMsg.requestId);
4660
4662
  const earlyTerminal = this.earlyTerminalVariants.get(startedMsg.variantId);
4661
4663
  if (earlyTerminal) {
@@ -4688,6 +4690,12 @@ var WebSocketClient = class WebSocketClient {
4688
4690
  }
4689
4691
  case "sync:state": {
4690
4692
  const syncMsg = message;
4693
+ for (const variant of syncMsg.variants) {
4694
+ const handler = this.variantCompletionHandlers.get(variant.id);
4695
+ if (!handler) continue;
4696
+ handler.onUpdate?.(variant);
4697
+ if (variant.status === "completed" || variant.status === "failed") this.handleTerminalVariant(variant);
4698
+ }
4691
4699
  this.onSyncState?.({
4692
4700
  assets: syncMsg.assets,
4693
4701
  variants: syncMsg.variants,
@@ -4800,6 +4808,7 @@ var WebSocketClient = class WebSocketClient {
4800
4808
  for (const [variantId, handler] of this.variantCompletionHandlers) if (handler.requestId === requestId) {
4801
4809
  this.variantCompletionHandlers.delete(variantId);
4802
4810
  clearTimeout(handler.timeout);
4811
+ if (handler.syncPoll) clearInterval(handler.syncPoll);
4803
4812
  handler.reject(error);
4804
4813
  return true;
4805
4814
  }
@@ -4812,6 +4821,7 @@ var WebSocketClient = class WebSocketClient {
4812
4821
  handled = true;
4813
4822
  this.variantCompletionHandlers.delete(variant.id);
4814
4823
  clearTimeout(handler.timeout);
4824
+ if (handler.syncPoll) clearInterval(handler.syncPoll);
4815
4825
  handler.onResult({
4816
4826
  requestId: handler.requestId,
4817
4827
  variantId: variant.id,
@@ -4824,6 +4834,19 @@ var WebSocketClient = class WebSocketClient {
4824
4834
  }
4825
4835
  return handled;
4826
4836
  }
4837
+ startVariantSyncPolling(variantId, requestId) {
4838
+ const requestCurrentState = () => {
4839
+ if (this.variantCompletionHandlers.get(variantId)?.requestId !== requestId) return;
4840
+ try {
4841
+ this.requestSync();
4842
+ } catch {}
4843
+ };
4844
+ requestCurrentState();
4845
+ const syncPoll = setInterval(requestCurrentState, VARIANT_SYNC_POLL_INTERVAL_MS);
4846
+ const handler = this.variantCompletionHandlers.get(variantId);
4847
+ if (handler?.requestId === requestId) handler.syncPoll = syncPoll;
4848
+ else clearInterval(syncPoll);
4849
+ }
4827
4850
  hasRequestsAwaitingStarted() {
4828
4851
  return this.generateHandlers.size > 0 || this.draftRunStartsAwaitingVariant.size > 0;
4829
4852
  }
@@ -5083,6 +5106,7 @@ var WebSocketClient = class WebSocketClient {
5083
5106
  }
5084
5107
  for (const [variantId, handler] of this.variantCompletionHandlers) if (handler.requestId === requestId) {
5085
5108
  this.variantCompletionHandlers.delete(variantId);
5109
+ if (handler.syncPoll) clearInterval(handler.syncPoll);
5086
5110
  reject(/* @__PURE__ */ new Error("Generate request timed out"));
5087
5111
  return;
5088
5112
  }
@@ -5138,8 +5162,10 @@ var WebSocketClient = class WebSocketClient {
5138
5162
  const timeoutMs = params.timeoutMs ?? 3e5;
5139
5163
  return new Promise((resolve, reject) => {
5140
5164
  const timeout = setTimeout(() => {
5141
- if (this.variantCompletionHandlers.get(params.variantId)?.requestId === requestId) {
5165
+ const handler = this.variantCompletionHandlers.get(params.variantId);
5166
+ if (handler?.requestId === requestId) {
5142
5167
  this.variantCompletionHandlers.delete(params.variantId);
5168
+ if (handler.syncPoll) clearInterval(handler.syncPoll);
5143
5169
  reject(/* @__PURE__ */ new Error("Follow request timed out"));
5144
5170
  }
5145
5171
  }, timeoutMs);
@@ -5152,6 +5178,7 @@ var WebSocketClient = class WebSocketClient {
5152
5178
  reject,
5153
5179
  timeout
5154
5180
  });
5181
+ this.startVariantSyncPolling(params.variantId, requestId);
5155
5182
  const earlyTerminal = this.earlyTerminalVariants.get(params.variantId);
5156
5183
  if (earlyTerminal) {
5157
5184
  this.earlyTerminalVariants.delete(params.variantId);
@@ -5165,6 +5192,7 @@ var WebSocketClient = class WebSocketClient {
5165
5192
  if (requestId && handler.requestId !== requestId) return;
5166
5193
  this.variantCompletionHandlers.delete(variantId);
5167
5194
  clearTimeout(handler.timeout);
5195
+ if (handler.syncPoll) clearInterval(handler.syncPoll);
5168
5196
  }
5169
5197
  /**
5170
5198
  * Send a describe image request and wait for response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makefx",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "Command-line interface for AI-assisted game asset production with Make Effects.",
5
5
  "license": "MIT",
6
6
  "type": "module",