@openscout/web 0.2.38 → 0.2.39

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.
@@ -4180,6 +4180,21 @@ import { fileURLToPath as fileURLToPath4 } from "url";
4180
4180
  function isTmpPath(p) {
4181
4181
  return /^\/(?:private\/)?tmp\//.test(p);
4182
4182
  }
4183
+ function resolveAdvertiseScope() {
4184
+ const raw2 = (process.env.OPENSCOUT_ADVERTISE_SCOPE ?? "").trim().toLowerCase();
4185
+ if (raw2 === "mesh")
4186
+ return "mesh";
4187
+ if (raw2 === "local")
4188
+ return "local";
4189
+ return DEFAULT_ADVERTISE_SCOPE;
4190
+ }
4191
+ function resolveBrokerHost(scope = resolveAdvertiseScope()) {
4192
+ const explicit = process.env.OPENSCOUT_BROKER_HOST;
4193
+ if (typeof explicit === "string" && explicit.trim().length > 0) {
4194
+ return explicit;
4195
+ }
4196
+ return scope === "mesh" ? DEFAULT_BROKER_HOST_MESH : DEFAULT_BROKER_HOST;
4197
+ }
4183
4198
  function buildDefaultBrokerUrl(host = DEFAULT_BROKER_HOST, port = DEFAULT_BROKER_PORT) {
4184
4199
  return `http://${host}:${port}`;
4185
4200
  }
@@ -4299,7 +4314,8 @@ function resolveBrokerServiceConfig() {
4299
4314
  const supportDirectory = isTmpPath(supportPaths.supportDirectory) ? defaultSupportDir : supportPaths.supportDirectory;
4300
4315
  const logsDirectory = join9(supportDirectory, "logs", "broker");
4301
4316
  const controlHome = isTmpPath(supportPaths.controlHome) ? join9(homedir6(), ".openscout", "control-plane") : supportPaths.controlHome;
4302
- const brokerHost = process.env.OPENSCOUT_BROKER_HOST ?? DEFAULT_BROKER_HOST;
4317
+ const advertiseScope = resolveAdvertiseScope();
4318
+ const brokerHost = resolveBrokerHost(advertiseScope);
4303
4319
  const brokerPort = Number.parseInt(process.env.OPENSCOUT_BROKER_PORT ?? String(DEFAULT_BROKER_PORT), 10);
4304
4320
  const brokerUrl = process.env.OPENSCOUT_BROKER_URL ?? buildDefaultBrokerUrl(brokerHost, brokerPort);
4305
4321
  const launchAgentPath = join9(homedir6(), "Library", "LaunchAgents", `${label}.plist`);
@@ -4319,7 +4335,8 @@ function resolveBrokerServiceConfig() {
4319
4335
  bunExecutable: resolveBunExecutable(),
4320
4336
  brokerHost,
4321
4337
  brokerPort,
4322
- brokerUrl
4338
+ brokerUrl,
4339
+ advertiseScope
4323
4340
  };
4324
4341
  }
4325
4342
  function renderLaunchAgentPlist(config) {
@@ -4331,6 +4348,7 @@ function renderLaunchAgentPlist(config) {
4331
4348
  OPENSCOUT_CONTROL_HOME: config.controlHome,
4332
4349
  OPENSCOUT_BROKER_SERVICE_MODE: config.mode,
4333
4350
  OPENSCOUT_BROKER_SERVICE_LABEL: config.label,
4351
+ OPENSCOUT_ADVERTISE_SCOPE: config.advertiseScope,
4334
4352
  HOME: homedir6(),
4335
4353
  PATH: launchPath,
4336
4354
  ...collectOptionalEnvVars([
@@ -4660,7 +4678,7 @@ function formatBrokerServiceStatus(status) {
4660
4678
  return lines.join(`
4661
4679
  `);
4662
4680
  }
4663
- var DEFAULT_BROKER_HOST = "127.0.0.1", DEFAULT_BROKER_PORT = 65535, BROKER_SERVICE_POLL_INTERVAL_MS = 100, DEFAULT_BROKER_START_TIMEOUT_MS = 15000, DEFAULT_BROKER_URL;
4681
+ var DEFAULT_BROKER_HOST = "127.0.0.1", DEFAULT_BROKER_HOST_MESH = "0.0.0.0", DEFAULT_BROKER_PORT = 65535, DEFAULT_ADVERTISE_SCOPE = "local", BROKER_SERVICE_POLL_INTERVAL_MS = 100, DEFAULT_BROKER_START_TIMEOUT_MS = 15000, DEFAULT_BROKER_URL;
4664
4682
  var init_broker_service = __esm(async () => {
4665
4683
  init_support_paths();
4666
4684
  DEFAULT_BROKER_URL = buildDefaultBrokerUrl();
@@ -8745,6 +8763,14 @@ async function readTailscalePeers() {
8745
8763
  }
8746
8764
 
8747
8765
  // server/core/mesh/service.ts
8766
+ function isLoopbackBrokerUrl(url) {
8767
+ try {
8768
+ const hostname2 = new URL(url).hostname;
8769
+ return hostname2 === "127.0.0.1" || hostname2 === "::1" || hostname2 === "localhost";
8770
+ } catch {
8771
+ return false;
8772
+ }
8773
+ }
8748
8774
  async function readTailscaleStatus() {
8749
8775
  const peers = await readTailscalePeers();
8750
8776
  return {
@@ -8760,7 +8786,9 @@ function computeWarnings(health, localNode, nodes, tailscale) {
8760
8786
  return warnings;
8761
8787
  }
8762
8788
  if (localNode?.advertiseScope === "local") {
8763
- warnings.push("Broker is bound to 127.0.0.1 \u2014 mesh peers cannot reach it. " + "Set OPENSCOUT_BROKER_HOST=0.0.0.0 or use your Tailscale IP.");
8789
+ warnings.push("Node advertise scope is `local` \u2014 peers will not discover this broker. " + "Set OPENSCOUT_ADVERTISE_SCOPE=mesh and restart the broker.");
8790
+ } else if (localNode?.advertiseScope === "mesh" && localNode.brokerUrl && isLoopbackBrokerUrl(localNode.brokerUrl)) {
8791
+ warnings.push("Broker advertises mesh scope but is bound to loopback \u2014 peers cannot reach it. " + "Unset OPENSCOUT_BROKER_HOST (mesh default is 0.0.0.0) or use your Tailscale IP.");
8764
8792
  }
8765
8793
  const remoteNodes = Object.values(nodes).filter((n) => n.id !== localNode?.id);
8766
8794
  if (remoteNodes.length === 0 && tailscale.onlineCount > 0) {
@@ -4755,6 +4755,21 @@ import { fileURLToPath as fileURLToPath3 } from "url";
4755
4755
  function isTmpPath(p) {
4756
4756
  return /^\/(?:private\/)?tmp\//.test(p);
4757
4757
  }
4758
+ function resolveAdvertiseScope() {
4759
+ const raw = (process.env.OPENSCOUT_ADVERTISE_SCOPE ?? "").trim().toLowerCase();
4760
+ if (raw === "mesh")
4761
+ return "mesh";
4762
+ if (raw === "local")
4763
+ return "local";
4764
+ return DEFAULT_ADVERTISE_SCOPE;
4765
+ }
4766
+ function resolveBrokerHost(scope = resolveAdvertiseScope()) {
4767
+ const explicit = process.env.OPENSCOUT_BROKER_HOST;
4768
+ if (typeof explicit === "string" && explicit.trim().length > 0) {
4769
+ return explicit;
4770
+ }
4771
+ return scope === "mesh" ? DEFAULT_BROKER_HOST_MESH : DEFAULT_BROKER_HOST;
4772
+ }
4758
4773
  function buildDefaultBrokerUrl(host = DEFAULT_BROKER_HOST, port = DEFAULT_BROKER_PORT) {
4759
4774
  return `http://${host}:${port}`;
4760
4775
  }
@@ -4874,7 +4889,8 @@ function resolveBrokerServiceConfig() {
4874
4889
  const supportDirectory = isTmpPath(supportPaths.supportDirectory) ? defaultSupportDir : supportPaths.supportDirectory;
4875
4890
  const logsDirectory = join12(supportDirectory, "logs", "broker");
4876
4891
  const controlHome = isTmpPath(supportPaths.controlHome) ? join12(homedir11(), ".openscout", "control-plane") : supportPaths.controlHome;
4877
- const brokerHost = process.env.OPENSCOUT_BROKER_HOST ?? DEFAULT_BROKER_HOST;
4892
+ const advertiseScope = resolveAdvertiseScope();
4893
+ const brokerHost = resolveBrokerHost(advertiseScope);
4878
4894
  const brokerPort = Number.parseInt(process.env.OPENSCOUT_BROKER_PORT ?? String(DEFAULT_BROKER_PORT), 10);
4879
4895
  const brokerUrl = process.env.OPENSCOUT_BROKER_URL ?? buildDefaultBrokerUrl(brokerHost, brokerPort);
4880
4896
  const launchAgentPath = join12(homedir11(), "Library", "LaunchAgents", `${label}.plist`);
@@ -4894,7 +4910,8 @@ function resolveBrokerServiceConfig() {
4894
4910
  bunExecutable: resolveBunExecutable(),
4895
4911
  brokerHost,
4896
4912
  brokerPort,
4897
- brokerUrl
4913
+ brokerUrl,
4914
+ advertiseScope
4898
4915
  };
4899
4916
  }
4900
4917
  function renderLaunchAgentPlist(config) {
@@ -4906,6 +4923,7 @@ function renderLaunchAgentPlist(config) {
4906
4923
  OPENSCOUT_CONTROL_HOME: config.controlHome,
4907
4924
  OPENSCOUT_BROKER_SERVICE_MODE: config.mode,
4908
4925
  OPENSCOUT_BROKER_SERVICE_LABEL: config.label,
4926
+ OPENSCOUT_ADVERTISE_SCOPE: config.advertiseScope,
4909
4927
  HOME: homedir11(),
4910
4928
  PATH: launchPath,
4911
4929
  ...collectOptionalEnvVars([
@@ -5235,7 +5253,7 @@ function formatBrokerServiceStatus(status) {
5235
5253
  return lines.join(`
5236
5254
  `);
5237
5255
  }
5238
- var DEFAULT_BROKER_HOST = "127.0.0.1", DEFAULT_BROKER_PORT = 65535, BROKER_SERVICE_POLL_INTERVAL_MS = 100, DEFAULT_BROKER_START_TIMEOUT_MS = 15000, DEFAULT_BROKER_URL;
5256
+ var DEFAULT_BROKER_HOST = "127.0.0.1", DEFAULT_BROKER_HOST_MESH = "0.0.0.0", DEFAULT_BROKER_PORT = 65535, DEFAULT_ADVERTISE_SCOPE = "local", BROKER_SERVICE_POLL_INTERVAL_MS = 100, DEFAULT_BROKER_START_TIMEOUT_MS = 15000, DEFAULT_BROKER_URL;
5239
5257
  var init_broker_service = __esm(async () => {
5240
5258
  init_support_paths();
5241
5259
  DEFAULT_BROKER_URL = buildDefaultBrokerUrl();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openscout/web",
3
- "version": "0.2.38",
3
+ "version": "0.2.39",
4
4
  "description": "Standalone lightweight Scout web UI with its own bundled Bun server",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -34,8 +34,8 @@
34
34
  "@noble/ciphers": "^2.1.1",
35
35
  "@noble/curves": "^2.0.1",
36
36
  "@noble/hashes": "^2.0.1",
37
- "@openscout/protocol": "0.2.38",
38
- "@openscout/runtime": "0.2.38",
37
+ "@openscout/protocol": "0.2.39",
38
+ "@openscout/runtime": "0.2.39",
39
39
  "@trpc/server": "^11.16.0",
40
40
  "@types/react": "^19",
41
41
  "@types/react-dom": "^19",