@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 +55 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +56 -11
- package/dist/index.js.map +1 -1
- package/dist/server/index.js +54 -12
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
- package/ui/README.md +45 -59
- package/ui/dist/assets/index-BjiNGEL8.js +306 -0
- package/ui/dist/assets/index-Cr1w0czW.css +1 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/index-BMzlkxln.css +0 -1
- package/ui/dist/assets/index-DQC14us6.js +0 -275
package/dist/index.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ declare function validateHttpTarget(targetUrl: string): URL;
|
|
|
74
74
|
declare const sanitizeUrl: typeof validateHttpTarget;
|
|
75
75
|
/**
|
|
76
76
|
* Validates Host headers to prevent DNS Rebinding attacks on local ports.
|
|
77
|
+
* Supports IPv4, localhost and IPv6 loopback ([::1] / ::1).
|
|
77
78
|
*/
|
|
78
79
|
declare function validateHostHeader(host: string | undefined, allowedHosts?: string[]): boolean;
|
|
79
80
|
|
|
@@ -173,4 +174,6 @@ declare class StdioTransport implements StudioTransport {
|
|
|
173
174
|
|
|
174
175
|
declare function createTransport(config: TargetConnectionConfig): StudioTransport;
|
|
175
176
|
|
|
176
|
-
|
|
177
|
+
declare const STUDIO_VERSION: string;
|
|
178
|
+
|
|
179
|
+
export { EnrichedTool, ExecutionResult, GrpcTransport, type GrpcTransportOptions, HttpTransport, type HttpTransportOptions, MeshTransport, type MeshTransportOptions, NetworkDiscoveryEngine, STUDIO_VERSION, ScanReport, ScannedTargetNode, StdioTransport, type StdioTransportOptions, StudioTransport, TargetConnectionConfig, TargetTransportType, createTransport, formatScanTable, resolveTargetConfig, runScan, sanitizeCommand, sanitizeUrl, validateHostHeader, validateHttpTarget };
|
package/dist/index.js
CHANGED
|
@@ -817,10 +817,29 @@ function validateHttpTarget(targetUrl) {
|
|
|
817
817
|
return parsed;
|
|
818
818
|
}
|
|
819
819
|
var sanitizeUrl = validateHttpTarget;
|
|
820
|
-
function validateHostHeader(host, allowedHosts = [
|
|
820
|
+
function validateHostHeader(host, allowedHosts = [
|
|
821
|
+
"localhost",
|
|
822
|
+
"127.0.0.1",
|
|
823
|
+
"0.0.0.0",
|
|
824
|
+
"::1",
|
|
825
|
+
"[::1]"
|
|
826
|
+
]) {
|
|
821
827
|
if (!host) return false;
|
|
822
|
-
const
|
|
823
|
-
|
|
828
|
+
const trimmed = host.trim();
|
|
829
|
+
let hostname;
|
|
830
|
+
if (trimmed.startsWith("[")) {
|
|
831
|
+
const closingIndex = trimmed.indexOf("]");
|
|
832
|
+
hostname = closingIndex !== -1 ? trimmed.slice(0, closingIndex + 1) : trimmed;
|
|
833
|
+
} else if (trimmed.includes(":") && trimmed.indexOf(":") !== trimmed.lastIndexOf(":")) {
|
|
834
|
+
hostname = trimmed;
|
|
835
|
+
} else {
|
|
836
|
+
hostname = trimmed.split(":")[0];
|
|
837
|
+
}
|
|
838
|
+
hostname = hostname.toLowerCase();
|
|
839
|
+
return allowedHosts.some((allowed) => {
|
|
840
|
+
const normAllowed = allowed.toLowerCase();
|
|
841
|
+
return normAllowed === hostname || hostname === "[::1]" && normAllowed === "::1" || hostname === "::1" && normAllowed === "[::1]";
|
|
842
|
+
});
|
|
824
843
|
}
|
|
825
844
|
|
|
826
845
|
// src/transports/http.transport.ts
|
|
@@ -1187,9 +1206,7 @@ var MeshTransport = class {
|
|
|
1187
1206
|
if (!this.isConnected()) {
|
|
1188
1207
|
await this.connect();
|
|
1189
1208
|
}
|
|
1190
|
-
const
|
|
1191
|
-
const peerId = clientAny.meshNode?.getPeerId?.()?.toString() || "UnknownPeer";
|
|
1192
|
-
const _connections = clientAny.meshNode?.node?.getConnections?.() || [];
|
|
1209
|
+
const peerId = this.client.peerId ?? "UnknownPeer";
|
|
1193
1210
|
const latencyMs = Math.max(1, Math.round(performance.now() - tStart));
|
|
1194
1211
|
const discovery = NetworkDiscoveryEngine.getInstance();
|
|
1195
1212
|
const meshDiscovered = await discovery.scanNetwork("127.0.0.1").catch(() => []);
|
|
@@ -2005,22 +2022,49 @@ async function runScan(targetStr, options) {
|
|
|
2005
2022
|
}
|
|
2006
2023
|
|
|
2007
2024
|
// src/server/index.ts
|
|
2008
|
-
import
|
|
2025
|
+
import path2 from "path";
|
|
2009
2026
|
import process4 from "process";
|
|
2010
|
-
import { fileURLToPath } from "url";
|
|
2027
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2011
2028
|
import { serve } from "@hono/node-server";
|
|
2012
2029
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
2013
2030
|
import { TokenTelemetryEngine as TokenTelemetryEngine5 } from "@nekzus/liop";
|
|
2014
2031
|
import { Hono } from "hono";
|
|
2015
2032
|
import { streamSSE } from "hono/streaming";
|
|
2033
|
+
|
|
2034
|
+
// src/version.ts
|
|
2035
|
+
import fs from "fs";
|
|
2036
|
+
import path from "path";
|
|
2037
|
+
import { fileURLToPath } from "url";
|
|
2016
2038
|
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
2039
|
+
function getPackageVersion() {
|
|
2040
|
+
try {
|
|
2041
|
+
let currentDir = __dirname;
|
|
2042
|
+
for (let i = 0; i < 4; i++) {
|
|
2043
|
+
const candidate = path.join(currentDir, "package.json");
|
|
2044
|
+
if (fs.existsSync(candidate)) {
|
|
2045
|
+
const raw = fs.readFileSync(candidate, "utf-8");
|
|
2046
|
+
const parsed = JSON.parse(raw);
|
|
2047
|
+
if (parsed.name === "@nekzus/liop-studio" && typeof parsed.version === "string") {
|
|
2048
|
+
return parsed.version;
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
currentDir = path.dirname(currentDir);
|
|
2052
|
+
}
|
|
2053
|
+
} catch {
|
|
2054
|
+
}
|
|
2055
|
+
return "1.0.0-alpha.5";
|
|
2056
|
+
}
|
|
2057
|
+
var STUDIO_VERSION = getPackageVersion();
|
|
2058
|
+
|
|
2059
|
+
// src/server/index.ts
|
|
2060
|
+
var __dirname2 = path2.dirname(fileURLToPath2(import.meta.url));
|
|
2017
2061
|
function createStudioServer(options = {}) {
|
|
2018
2062
|
if (!process4.env.LIOP_SUPPRESS_TLS_WARNING) {
|
|
2019
2063
|
process4.env.LIOP_SUPPRESS_TLS_WARNING = "true";
|
|
2020
2064
|
}
|
|
2021
2065
|
const app = new Hono();
|
|
2022
2066
|
const port = options.port || 16e3;
|
|
2023
|
-
const distPath = options.distPath ||
|
|
2067
|
+
const distPath = options.distPath || path2.resolve(__dirname2, "../../ui/dist");
|
|
2024
2068
|
let activeConfig = options.initialTarget || {
|
|
2025
2069
|
type: "http",
|
|
2026
2070
|
http: { url: process4.env.LIOP_MCP_URL || "http://127.0.0.1:15000/mcp" }
|
|
@@ -2053,7 +2097,7 @@ function createStudioServer(options = {}) {
|
|
|
2053
2097
|
const isConnected = activeTransport.isConnected() && lastReport?.status === "online";
|
|
2054
2098
|
return c.json({
|
|
2055
2099
|
status: isConnected ? "healthy" : "offline",
|
|
2056
|
-
version:
|
|
2100
|
+
version: STUDIO_VERSION,
|
|
2057
2101
|
targetType: activeConfig.type,
|
|
2058
2102
|
connected: isConnected
|
|
2059
2103
|
});
|
|
@@ -2069,7 +2113,7 @@ function createStudioServer(options = {}) {
|
|
|
2069
2113
|
connected: isConnected,
|
|
2070
2114
|
toolsCount: isConnected ? lastReport?.totalTools || 0 : 0,
|
|
2071
2115
|
latencyMs: isConnected ? lastReport?.latencyMs || 0 : 0,
|
|
2072
|
-
version:
|
|
2116
|
+
version: STUDIO_VERSION,
|
|
2073
2117
|
serverInfo: lastReport?.serverInfo
|
|
2074
2118
|
});
|
|
2075
2119
|
});
|
|
@@ -2247,6 +2291,7 @@ export {
|
|
|
2247
2291
|
HttpTransport,
|
|
2248
2292
|
MeshTransport,
|
|
2249
2293
|
NetworkDiscoveryEngine,
|
|
2294
|
+
STUDIO_VERSION,
|
|
2250
2295
|
StdioTransport,
|
|
2251
2296
|
createStudioServer,
|
|
2252
2297
|
createTransport,
|