openmagic 0.26.0 → 0.26.2

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.
package/dist/cli.js CHANGED
@@ -1447,7 +1447,7 @@ async function handleLlmChat(params, onChunk, onDone, onError) {
1447
1447
  }
1448
1448
 
1449
1449
  // src/server.ts
1450
- var VERSION = "0.26.0";
1450
+ var VERSION = "0.26.2";
1451
1451
  var __dirname = dirname2(fileURLToPath(import.meta.url));
1452
1452
  function attachOpenMagic(httpServer, roots) {
1453
1453
  function handleRequest(req, res) {
@@ -1981,7 +1981,7 @@ process.on("uncaughtException", (err) => {
1981
1981
  });
1982
1982
  var childProcesses = [];
1983
1983
  var lastDetectedPort = null;
1984
- var VERSION2 = "0.26.0";
1984
+ var VERSION2 = "0.26.2";
1985
1985
  function ask(question) {
1986
1986
  const rl = createInterface({ input: process.stdin, output: process.stdout });
1987
1987
  return new Promise((resolve3) => {
@@ -2312,11 +2312,22 @@ async function offerToStartDevServer(expectedPort) {
2312
2312
  let childExited = false;
2313
2313
  let detectedPort = null;
2314
2314
  function parsePortFromOutput(line) {
2315
- const portMatch = line.match(/https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0):(\d+)/);
2315
+ const clean = line.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, "").replace(/\x1b[^a-zA-Z]*[a-zA-Z]/g, "").replace(/[\x00-\x1f\x7f]/g, "");
2316
+ const portMatch = clean.match(/https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0):(\d+)/);
2316
2317
  if (portMatch && !detectedPort) {
2317
2318
  const p = parseInt(portMatch[1], 10);
2318
2319
  if (p > 0 && p < 65536 && p !== port) {
2319
2320
  detectedPort = p;
2321
+ return;
2322
+ }
2323
+ }
2324
+ if (!detectedPort) {
2325
+ const fallback = clean.match(/(?:port|Port|PORT)\s+(\d{4,5})/);
2326
+ if (fallback) {
2327
+ const p = parseInt(fallback[1], 10);
2328
+ if (p > 0 && p < 65536 && p !== port) {
2329
+ detectedPort = p;
2330
+ }
2320
2331
  }
2321
2332
  }
2322
2333
  }
@@ -2392,6 +2403,14 @@ async function offerToStartDevServer(expectedPort) {
2392
2403
  return false;
2393
2404
  }
2394
2405
  if (!isUp) {
2406
+ const fallbackDetect = await detectDevServer();
2407
+ if (fallbackDetect && fallbackDetect.port !== port) {
2408
+ console.log(
2409
+ chalk.green(` \u2713 Dev server found on port ${fallbackDetect.port}.`)
2410
+ );
2411
+ lastDetectedPort = fallbackDetect.port;
2412
+ return true;
2413
+ }
2395
2414
  console.log(
2396
2415
  chalk.yellow(` \u26A0 Port ${port} didn't open after 30s.`)
2397
2416
  );