@threadbase-sh/streamer 1.52.2 → 1.52.3

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/index.d.cts CHANGED
@@ -530,6 +530,7 @@ interface SessionCursor {
530
530
  }
531
531
  interface ServerConfig {
532
532
  port: number;
533
+ host?: string;
533
534
  apiKey?: string;
534
535
  /** 'cli' when --api-key was passed; rotation persists in-memory only and reverts on restart */
535
536
  apiKeySource?: "config" | "cli";
@@ -2014,6 +2015,7 @@ declare class StreamerServer {
2014
2015
  private dbPool;
2015
2016
  private dbInstanceId;
2016
2017
  private disableDb;
2018
+ private host;
2017
2019
  private skipStartupWarmup;
2018
2020
  private autoResumeOnBoot;
2019
2021
  private browseRoot;
package/dist/index.d.ts CHANGED
@@ -530,6 +530,7 @@ interface SessionCursor {
530
530
  }
531
531
  interface ServerConfig {
532
532
  port: number;
533
+ host?: string;
533
534
  apiKey?: string;
534
535
  /** 'cli' when --api-key was passed; rotation persists in-memory only and reverts on restart */
535
536
  apiKeySource?: "config" | "cli";
@@ -2014,6 +2015,7 @@ declare class StreamerServer {
2014
2015
  private dbPool;
2015
2016
  private dbInstanceId;
2016
2017
  private disableDb;
2018
+ private host;
2017
2019
  private skipStartupWarmup;
2018
2020
  private autoResumeOnBoot;
2019
2021
  private browseRoot;
package/dist/index.js CHANGED
@@ -14437,6 +14437,7 @@ var StreamerServer = class {
14437
14437
  dbPool = null;
14438
14438
  dbInstanceId = null;
14439
14439
  disableDb = false;
14440
+ host;
14440
14441
  // Skip the startup warm-up scan (test hook; see ServerConfig.skipStartupWarmup).
14441
14442
  skipStartupWarmup;
14442
14443
  autoResumeOnBoot;
@@ -14558,6 +14559,7 @@ var StreamerServer = class {
14558
14559
  }
14559
14560
  this.verbose = config.verbose ?? false;
14560
14561
  this.disableDb = config.disableDb ?? false;
14562
+ this.host = config.host;
14561
14563
  this.skipStartupWarmup = config.skipStartupWarmup ?? false;
14562
14564
  this.autoResumeOnBoot = config.autoResumeOnBoot ?? false;
14563
14565
  this.scanProfiles = config.scanProfiles;
@@ -15210,7 +15212,7 @@ var StreamerServer = class {
15210
15212
  await runMigrations(this.dbPool);
15211
15213
  this.log.info("Database migrations applied", { event: "db.migrations_applied" });
15212
15214
  }
15213
- await this.bindWithRetry(port);
15215
+ await this.bindWithRetry(port, this.host);
15214
15216
  if (!this.ptyManager.isRemote()) {
15215
15217
  this.idleReaperTimer = setInterval(() => this.reapIdleSessions(), IDLE_REAP_SWEEP_MS);
15216
15218
  this.idleReaperTimer.unref?.();
@@ -15219,7 +15221,8 @@ var StreamerServer = class {
15219
15221
  {
15220
15222
  this.log.info(`Streamer server listening on port ${port}`, {
15221
15223
  port,
15222
- event: "server.listening"
15224
+ event: "server.listening",
15225
+ ...this.host !== void 0 && { host: this.host }
15223
15226
  });
15224
15227
  try {
15225
15228
  this.runtimeStore = RuntimeStore.open(this.runtimeDbPath);
@@ -15433,15 +15436,15 @@ var StreamerServer = class {
15433
15436
  // Bind the HTTP listener, retrying on a transient EADDRINUSE. See the call
15434
15437
  // site in listen() for why the race exists (kickstart -k relaunch). Total
15435
15438
  // worst case ≈ 6 × 500 ms = 3 s before the final attempt rethrows.
15436
- async bindWithRetry(port, attempts = 6, delayMs = 500) {
15439
+ async bindWithRetry(port, host, attempts = 6, delayMs = 500) {
15437
15440
  this.binding = true;
15438
15441
  try {
15439
- await this.bindWithRetryLoop(port, attempts, delayMs);
15442
+ await this.bindWithRetryLoop(port, host, attempts, delayMs);
15440
15443
  } finally {
15441
15444
  this.binding = false;
15442
15445
  }
15443
15446
  }
15444
- async bindWithRetryLoop(port, attempts, delayMs) {
15447
+ async bindWithRetryLoop(port, host, attempts, delayMs) {
15445
15448
  for (let attempt = 1; attempt <= attempts; attempt++) {
15446
15449
  try {
15447
15450
  await new Promise((resolve2, reject) => {
@@ -15455,7 +15458,11 @@ var StreamerServer = class {
15455
15458
  };
15456
15459
  this.httpServer.once("error", onError);
15457
15460
  this.httpServer.once("listening", onListening);
15458
- this.httpServer.listen(port);
15461
+ if (host === void 0) {
15462
+ this.httpServer.listen(port);
15463
+ } else {
15464
+ this.httpServer.listen(port, host);
15465
+ }
15459
15466
  });
15460
15467
  return;
15461
15468
  } catch (err) {
@@ -15463,13 +15470,18 @@ var StreamerServer = class {
15463
15470
  if (e.code === "EADDRINUSE" && attempt === attempts) {
15464
15471
  this.log.error(
15465
15472
  `port ${port} still busy (EADDRINUSE) after ${attempts} attempts; giving up`,
15466
- { port, attempts, event: "server.bind_failed" }
15473
+ {
15474
+ port,
15475
+ attempts,
15476
+ event: "server.bind_failed",
15477
+ ...host !== void 0 && { host }
15478
+ }
15467
15479
  );
15468
15480
  }
15469
15481
  if (e.code !== "EADDRINUSE" || attempt === attempts) throw err;
15470
15482
  this.log.debug?.(
15471
15483
  `port ${port} busy (EADDRINUSE), retry ${attempt}/${attempts - 1} in ${delayMs}ms`,
15472
- { port, attempt, event: "server.bind_retry" }
15484
+ { port, attempt, event: "server.bind_retry", ...host !== void 0 && { host } }
15473
15485
  );
15474
15486
  await new Promise((r) => setTimeout(r, delayMs));
15475
15487
  }