@creature-ai/sdk 0.1.21 → 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;
@@ -14781,13 +14796,15 @@ var App = class {
14781
14796
  buildToolMeta(config) {
14782
14797
  const toolMeta = {};
14783
14798
  if (config.ui) {
14799
+ const visibility = config.visibility || ["model", "app"];
14784
14800
  toolMeta.ui = {
14785
14801
  resourceUri: config.ui,
14786
- visibility: config.visibility || ["model", "app"],
14802
+ visibility,
14787
14803
  ...config.displayModes && { displayModes: config.displayModes },
14788
14804
  ...config.defaultDisplayMode && { defaultDisplayMode: config.defaultDisplayMode }
14789
14805
  };
14790
14806
  toolMeta["openai/outputTemplate"] = config.ui;
14807
+ toolMeta["openai/widgetAccessible"] = visibility.includes("app");
14791
14808
  }
14792
14809
  if (config.loadingMessage) {
14793
14810
  toolMeta["openai/toolInvocation/invoking"] = config.loadingMessage;
@@ -14872,10 +14889,7 @@ function getCallerDirectory() {
14872
14889
  for (const frame of stack) {
14873
14890
  const filename = frame.getFileName();
14874
14891
  if (filename && !isSDKPath(filename)) {
14875
- if (filename.startsWith("file://")) {
14876
- return path2.dirname(fileURLToPath(filename));
14877
- }
14878
- return path2.dirname(filename);
14892
+ return filename.startsWith("file://") ? path2.dirname(fileURLToPath(filename)) : path2.dirname(filename);
14879
14893
  }
14880
14894
  }
14881
14895
  return process.cwd();