@nekzus/liop-studio 1.0.0-alpha.6 → 1.0.0-alpha.7

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/index.js CHANGED
@@ -5,9 +5,9 @@ import { Command } from "commander";
5
5
  import pc2 from "picocolors";
6
6
 
7
7
  // src/server/index.ts
8
- import path from "path";
8
+ import path2 from "path";
9
9
  import process3 from "process";
10
- import { fileURLToPath } from "url";
10
+ import { fileURLToPath as fileURLToPath2 } from "url";
11
11
  import { serve } from "@hono/node-server";
12
12
  import { serveStatic } from "@hono/node-server/serve-static";
13
13
  import { TokenTelemetryEngine as TokenTelemetryEngine5 } from "@nekzus/liop";
@@ -63,10 +63,29 @@ function validateHttpTarget(targetUrl) {
63
63
  }
64
64
  return parsed;
65
65
  }
66
- function validateHostHeader(host, allowedHosts = ["localhost", "127.0.0.1", "0.0.0.0"]) {
66
+ function validateHostHeader(host, allowedHosts = [
67
+ "localhost",
68
+ "127.0.0.1",
69
+ "0.0.0.0",
70
+ "::1",
71
+ "[::1]"
72
+ ]) {
67
73
  if (!host) return false;
68
- const hostname = host.split(":")[0].toLowerCase();
69
- return allowedHosts.includes(hostname);
74
+ const trimmed = host.trim();
75
+ let hostname;
76
+ if (trimmed.startsWith("[")) {
77
+ const closingIndex = trimmed.indexOf("]");
78
+ hostname = closingIndex !== -1 ? trimmed.slice(0, closingIndex + 1) : trimmed;
79
+ } else if (trimmed.includes(":") && trimmed.indexOf(":") !== trimmed.lastIndexOf(":")) {
80
+ hostname = trimmed;
81
+ } else {
82
+ hostname = trimmed.split(":")[0];
83
+ }
84
+ hostname = hostname.toLowerCase();
85
+ return allowedHosts.some((allowed) => {
86
+ const normAllowed = allowed.toLowerCase();
87
+ return normAllowed === hostname || hostname === "[::1]" && normAllowed === "::1" || hostname === "::1" && normAllowed === "[::1]";
88
+ });
70
89
  }
71
90
 
72
91
  // src/transports/grpc.transport.ts
@@ -1197,9 +1216,7 @@ var MeshTransport = class {
1197
1216
  if (!this.isConnected()) {
1198
1217
  await this.connect();
1199
1218
  }
1200
- const clientAny = this.client;
1201
- const peerId = clientAny.meshNode?.getPeerId?.()?.toString() || "UnknownPeer";
1202
- const _connections = clientAny.meshNode?.node?.getConnections?.() || [];
1219
+ const peerId = this.client.peerId ?? "UnknownPeer";
1203
1220
  const latencyMs = Math.max(1, Math.round(performance.now() - tStart));
1204
1221
  const discovery = NetworkDiscoveryEngine.getInstance();
1205
1222
  const meshDiscovered = await discovery.scanNetwork("127.0.0.1").catch(() => []);
@@ -1884,15 +1901,40 @@ function createTransport(config) {
1884
1901
  }
1885
1902
  }
1886
1903
 
1887
- // src/server/index.ts
1904
+ // src/version.ts
1905
+ import fs from "fs";
1906
+ import path from "path";
1907
+ import { fileURLToPath } from "url";
1888
1908
  var __dirname = path.dirname(fileURLToPath(import.meta.url));
1909
+ function getPackageVersion() {
1910
+ try {
1911
+ let currentDir = __dirname;
1912
+ for (let i = 0; i < 4; i++) {
1913
+ const candidate = path.join(currentDir, "package.json");
1914
+ if (fs.existsSync(candidate)) {
1915
+ const raw = fs.readFileSync(candidate, "utf-8");
1916
+ const parsed = JSON.parse(raw);
1917
+ if (parsed.name === "@nekzus/liop-studio" && typeof parsed.version === "string") {
1918
+ return parsed.version;
1919
+ }
1920
+ }
1921
+ currentDir = path.dirname(currentDir);
1922
+ }
1923
+ } catch {
1924
+ }
1925
+ return "1.0.0-alpha.5";
1926
+ }
1927
+ var STUDIO_VERSION = getPackageVersion();
1928
+
1929
+ // src/server/index.ts
1930
+ var __dirname2 = path2.dirname(fileURLToPath2(import.meta.url));
1889
1931
  function createStudioServer(options = {}) {
1890
1932
  if (!process3.env.LIOP_SUPPRESS_TLS_WARNING) {
1891
1933
  process3.env.LIOP_SUPPRESS_TLS_WARNING = "true";
1892
1934
  }
1893
1935
  const app = new Hono();
1894
1936
  const port = options.port || 16e3;
1895
- const distPath = options.distPath || path.resolve(__dirname, "../../ui/dist");
1937
+ const distPath = options.distPath || path2.resolve(__dirname2, "../../ui/dist");
1896
1938
  let activeConfig = options.initialTarget || {
1897
1939
  type: "http",
1898
1940
  http: { url: process3.env.LIOP_MCP_URL || "http://127.0.0.1:15000/mcp" }
@@ -1925,7 +1967,7 @@ function createStudioServer(options = {}) {
1925
1967
  const isConnected = activeTransport.isConnected() && lastReport?.status === "online";
1926
1968
  return c.json({
1927
1969
  status: isConnected ? "healthy" : "offline",
1928
- version: "1.0.0",
1970
+ version: STUDIO_VERSION,
1929
1971
  targetType: activeConfig.type,
1930
1972
  connected: isConnected
1931
1973
  });
@@ -1941,7 +1983,7 @@ function createStudioServer(options = {}) {
1941
1983
  connected: isConnected,
1942
1984
  toolsCount: isConnected ? lastReport?.totalTools || 0 : 0,
1943
1985
  latencyMs: isConnected ? lastReport?.latencyMs || 0 : 0,
1944
- version: "1.0.0",
1986
+ version: STUDIO_VERSION,
1945
1987
  serverInfo: lastReport?.serverInfo
1946
1988
  });
1947
1989
  });
@@ -2253,7 +2295,7 @@ async function main() {
2253
2295
  const program = new Command();
2254
2296
  program.name("liop-studio").description(
2255
2297
  "LIOP Sovereign Studio & Mesh Scanner (Universal MCP / LIOP Inspector)"
2256
- ).version("1.0.0-alpha.0").option("-p, --port <port>", "Port to bind local Studio server", "16000").option("--no-open", "Do not automatically open browser on launch").option(
2298
+ ).version(STUDIO_VERSION).option("-p, --port <port>", "Port to bind local Studio server", "16000").option("--no-open", "Do not automatically open browser on launch").option(
2257
2299
  "--stdio <command>",
2258
2300
  "Initial target: Stdio command (e.g. 'node server.js')"
2259
2301
  ).option("--http <url>", "Initial target: HTTP / SSE MCP URL").option("--grpc <target>", "Initial target: Native LIOP gRPC endpoint").option("--mesh <multiaddr>", "Initial target: Libp2p P2P bootstrap node").option(