@creature-ai/sdk 0.1.22 → 0.1.23

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.
@@ -596,6 +596,15 @@ declare class App {
596
596
  * Create an AWS Lambda handler function.
597
597
  */
598
598
  private createLambdaHandler;
599
+ /**
600
+ * Get the HMR port for injecting the live reload client.
601
+ *
602
+ * When MCP_PORT is set (by Creature), derives the HMR port deterministically
603
+ * as MCP_PORT + HMR_PORT_OFFSET. This eliminates the race condition where
604
+ * the hmr.json file might not exist yet when the server starts.
605
+ *
606
+ * Falls back to reading hmr.json for non-Creature environments (manual npm run dev).
607
+ */
599
608
  private getHmrPort;
600
609
  private generateInstanceId;
601
610
  /**
@@ -13481,6 +13481,9 @@ function generateHmrClientScriptTag(port) {
13481
13481
  return `<script>${generateHmrClientScript(port)}</script>`;
13482
13482
  }
13483
13483
 
13484
+ // src/vite/index.ts
13485
+ var HMR_PORT_OFFSET = 1e3;
13486
+
13484
13487
  // src/server/utils.ts
13485
13488
  function svgToDataUri(svg) {
13486
13489
  const base64 = Buffer.from(svg).toString("base64");
@@ -13537,8 +13540,6 @@ function loadHtml(filePath, basePath) {
13537
13540
  return fs.readFileSync(searchPath, "utf-8");
13538
13541
  }
13539
13542
  }
13540
- console.error(`[SDK] HTML file not found. Searched:
13541
- - ${uniquePaths.join("\n - ")}`);
13542
13543
  return `<!DOCTYPE html>
13543
13544
  <html><body>
13544
13545
  <h1>Error: UI not found</h1>
@@ -14424,9 +14425,23 @@ var App = class {
14424
14425
  }
14425
14426
  };
14426
14427
  }
14428
+ /**
14429
+ * Get the HMR port for injecting the live reload client.
14430
+ *
14431
+ * When MCP_PORT is set (by Creature), derives the HMR port deterministically
14432
+ * as MCP_PORT + HMR_PORT_OFFSET. This eliminates the race condition where
14433
+ * the hmr.json file might not exist yet when the server starts.
14434
+ *
14435
+ * Falls back to reading hmr.json for non-Creature environments (manual npm run dev).
14436
+ */
14427
14437
  getHmrPort() {
14428
14438
  if (!this.isDev) return null;
14429
14439
  if (this.hmrPort !== null) return this.hmrPort;
14440
+ const mcpPort = process.env.MCP_PORT ? parseInt(process.env.MCP_PORT, 10) : null;
14441
+ if (mcpPort && !isNaN(mcpPort)) {
14442
+ this.hmrPort = mcpPort + HMR_PORT_OFFSET;
14443
+ return this.hmrPort;
14444
+ }
14430
14445
  const hmrConfig = readHmrConfig();
14431
14446
  if (hmrConfig) {
14432
14447
  this.hmrPort = hmrConfig.port;
@@ -14874,10 +14889,7 @@ function getCallerDirectory() {
14874
14889
  for (const frame of stack) {
14875
14890
  const filename = frame.getFileName();
14876
14891
  if (filename && !isSDKPath(filename)) {
14877
- if (filename.startsWith("file://")) {
14878
- return path2.dirname(fileURLToPath(filename));
14879
- }
14880
- return path2.dirname(filename);
14892
+ return filename.startsWith("file://") ? path2.dirname(fileURLToPath(filename)) : path2.dirname(filename);
14881
14893
  }
14882
14894
  }
14883
14895
  return process.cwd();