makefx 1.6.6 → 1.6.7

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.6
64
+ Version: 1.6.7
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.6+b1c0c6d222d7";
4445
+ var CLI_VERSION = "1.6.7+0439271d1461";
4446
4446
  var CLI_VERSION_HEADER = "X-MakeFX-CLI-Version";
4447
4447
  function cliVersionHeaders() {
4448
4448
  return {
@@ -4461,6 +4461,7 @@ function cliVersionHeaders() {
4461
4461
  var GENERATION_REQUEST_TIMEOUT_MS = 3e5;
4462
4462
  var VIDEO_GENERATION_REQUEST_TIMEOUT_MS = 72e4;
4463
4463
  var VARIANT_SYNC_POLL_INTERVAL_MS = 15e3;
4464
+ var GENERATION_RECONNECT_RETRY_MS = 1e3;
4464
4465
  function getGenerationRequestTimeoutMs(mediaKind) {
4465
4466
  return mediaKind === "video" ? VIDEO_GENERATION_REQUEST_TIMEOUT_MS : GENERATION_REQUEST_TIMEOUT_MS;
4466
4467
  }
@@ -4493,6 +4494,8 @@ var WebSocketClient = class WebSocketClient {
4493
4494
  env;
4494
4495
  spaceId;
4495
4496
  connectionLoggingEnabled = false;
4497
+ disconnectRequested = false;
4498
+ generationReconnect = null;
4496
4499
  chatHandlers = /* @__PURE__ */ new Map();
4497
4500
  generateHandlers = /* @__PURE__ */ new Map();
4498
4501
  earlyTerminalVariants = /* @__PURE__ */ new Map();
@@ -4535,6 +4538,7 @@ var WebSocketClient = class WebSocketClient {
4535
4538
  * Connect to the WebSocket endpoint
4536
4539
  */
4537
4540
  async connect() {
4541
+ this.disconnectRequested = false;
4538
4542
  return new Promise((resolve, reject) => {
4539
4543
  const protocol = this.baseUrl.startsWith("https") ? "wss" : "ws";
4540
4544
  const url = `${protocol}://${this.baseUrl.replace(/^https?:\/\//, "")}/api/spaces/${this.spaceId}/ws`;
@@ -4563,7 +4567,7 @@ var WebSocketClient = class WebSocketClient {
4563
4567
  });
4564
4568
  this.ws.on("close", (code, reason) => {
4565
4569
  if (this.connectionLoggingEnabled) console.log(`[WebSocketClient] Disconnected: ${code} - ${reason}`);
4566
- this.ws = null;
4570
+ this.handleSocketClose();
4567
4571
  });
4568
4572
  });
4569
4573
  }
@@ -4571,11 +4575,35 @@ var WebSocketClient = class WebSocketClient {
4571
4575
  * Disconnect from the WebSocket
4572
4576
  */
4573
4577
  disconnect() {
4578
+ this.disconnectRequested = true;
4574
4579
  if (this.ws) {
4575
4580
  this.ws.close();
4576
4581
  this.ws = null;
4577
4582
  }
4578
4583
  }
4584
+ handleSocketClose() {
4585
+ this.ws = null;
4586
+ if (!this.disconnectRequested && this.hasPendingGenerationWaits()) this.reconnectPendingGeneration();
4587
+ }
4588
+ hasPendingGenerationWaits() {
4589
+ return this.generateHandlers.size > 0 || this.variantCompletionHandlers.size > 0;
4590
+ }
4591
+ reconnectPendingGeneration() {
4592
+ if (this.generationReconnect || this.disconnectRequested || !this.hasPendingGenerationWaits()) return;
4593
+ this.generationReconnect = this.runGenerationReconnect().finally(() => {
4594
+ this.generationReconnect = null;
4595
+ });
4596
+ }
4597
+ async runGenerationReconnect() {
4598
+ while (!this.disconnectRequested && this.hasPendingGenerationWaits()) try {
4599
+ await this.connect();
4600
+ if (this.hasPendingGenerationWaits()) this.requestSync();
4601
+ return;
4602
+ } catch {
4603
+ if (this.disconnectRequested || !this.hasPendingGenerationWaits()) return;
4604
+ await new Promise((resolve) => setTimeout(resolve, GENERATION_RECONNECT_RETRY_MS));
4605
+ }
4606
+ }
4579
4607
  /**
4580
4608
  * Set error handler
4581
4609
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makefx",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "description": "Command-line interface for AI-assisted game asset production with Make Effects.",
5
5
  "license": "MIT",
6
6
  "type": "module",