@tonyclaw/llm-inspector 1.7.1 → 1.7.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/.output/cli.js +54 -1
- package/.output/nitro.json +1 -1
- package/.output/server/index.mjs +13 -13
- package/package.json +1 -1
- package/src/cli.ts +72 -1
package/.output/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { spawn } from "node:child_process";
|
|
4
|
+
import { spawn, execSync } from "node:child_process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
var __filename = fileURLToPath(import.meta.url);
|
|
@@ -30,7 +30,60 @@ for (let i = 0; i < args.length; i++) {
|
|
|
30
30
|
break;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
function killProcessOnPort(targetPort) {
|
|
34
|
+
const platform = process.platform;
|
|
35
|
+
try {
|
|
36
|
+
let pids = [];
|
|
37
|
+
if (platform === "win32") {
|
|
38
|
+
const output = execSync(`netstat -ano | findstr :${targetPort}`, {
|
|
39
|
+
encoding: "utf8",
|
|
40
|
+
timeout: 5e3
|
|
41
|
+
});
|
|
42
|
+
const lines = output.trim().split("\n");
|
|
43
|
+
for (const line of lines) {
|
|
44
|
+
const parts = line.trim().split(/\s+/);
|
|
45
|
+
if (parts.length >= 5) {
|
|
46
|
+
const localAddress = parts[1] ?? "";
|
|
47
|
+
const pidStr = parts[4] ?? "";
|
|
48
|
+
if (localAddress !== "" && pidStr !== "" && localAddress.includes(`:${targetPort}`)) {
|
|
49
|
+
const pid = parseInt(pidStr, 10);
|
|
50
|
+
if (!isNaN(pid) && pid > 0) {
|
|
51
|
+
pids.push(pid);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
pids = [...new Set(pids)];
|
|
57
|
+
for (const pid of pids) {
|
|
58
|
+
try {
|
|
59
|
+
console.log(`Killing process ${pid} on port ${port}...`);
|
|
60
|
+
execSync(`taskkill /PID ${pid} /F`, { encoding: "utf8", timeout: 5e3 });
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
const output = execSync(`lsof -ti:${targetPort}`, { encoding: "utf8", timeout: 5e3 });
|
|
66
|
+
const lines = output.trim().split("\n");
|
|
67
|
+
for (const line of lines) {
|
|
68
|
+
const pid = parseInt(line.trim(), 10);
|
|
69
|
+
if (!isNaN(pid) && pid > 0) {
|
|
70
|
+
pids.push(pid);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
pids = [...new Set(pids)];
|
|
74
|
+
for (const pid of pids) {
|
|
75
|
+
try {
|
|
76
|
+
console.log(`Killing process ${pid} on port ${targetPort}...`);
|
|
77
|
+
execSync(`kill -9 ${pid}`, { encoding: "utf8", timeout: 5e3 });
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
33
85
|
process.env["PORT"] = String(port);
|
|
86
|
+
killProcessOnPort(port);
|
|
34
87
|
var url = `http://localhost:${port}`;
|
|
35
88
|
console.log(`Server running at ${url}`);
|
|
36
89
|
console.log(` Proxy: ${url}/proxy`);
|
package/.output/nitro.json
CHANGED
package/.output/server/index.mjs
CHANGED
|
@@ -100,49 +100,49 @@ const assets = {
|
|
|
100
100
|
"/assets/alibaba-TTwafVwX.svg": {
|
|
101
101
|
"type": "image/svg+xml",
|
|
102
102
|
"etag": '"171b-6dyV5K8QjiaY35sN9qNprh9zDIs"',
|
|
103
|
-
"mtime": "2026-06-03T09:
|
|
103
|
+
"mtime": "2026-06-03T09:30:18.865Z",
|
|
104
104
|
"size": 5915,
|
|
105
105
|
"path": "../public/assets/alibaba-TTwafVwX.svg"
|
|
106
106
|
},
|
|
107
107
|
"/assets/index-B3RwBPLW.css": {
|
|
108
108
|
"type": "text/css; charset=utf-8",
|
|
109
109
|
"etag": '"10c74-aXacU4DRFVsUwcC5jHnjoPRSlTA"',
|
|
110
|
-
"mtime": "2026-06-03T09:
|
|
110
|
+
"mtime": "2026-06-03T09:30:18.865Z",
|
|
111
111
|
"size": 68724,
|
|
112
112
|
"path": "../public/assets/index-B3RwBPLW.css"
|
|
113
113
|
},
|
|
114
|
-
"/assets/main-CpIX1ZHy.js": {
|
|
115
|
-
"type": "text/javascript; charset=utf-8",
|
|
116
|
-
"etag": '"4db57-PIyiLXQGvlFJuizUFXRhGOYXJwY"',
|
|
117
|
-
"mtime": "2026-06-03T09:17:40.504Z",
|
|
118
|
-
"size": 318295,
|
|
119
|
-
"path": "../public/assets/main-CpIX1ZHy.js"
|
|
120
|
-
},
|
|
121
114
|
"/assets/minimax-BPMzvuL-.jpeg": {
|
|
122
115
|
"type": "image/jpeg",
|
|
123
116
|
"etag": '"1b06-IwivU89ko5UTMUM1/t7hn4sQK9A"',
|
|
124
|
-
"mtime": "2026-06-03T09:
|
|
117
|
+
"mtime": "2026-06-03T09:30:18.865Z",
|
|
125
118
|
"size": 6918,
|
|
126
119
|
"path": "../public/assets/minimax-BPMzvuL-.jpeg"
|
|
127
120
|
},
|
|
128
121
|
"/assets/zhipuai-BPNAnxo-.svg": {
|
|
129
122
|
"type": "image/svg+xml",
|
|
130
123
|
"etag": '"2bf8-hNaLCTi89nOFCsIIfWpP/jrfo0s"',
|
|
131
|
-
"mtime": "2026-06-03T09:
|
|
124
|
+
"mtime": "2026-06-03T09:30:18.862Z",
|
|
132
125
|
"size": 11256,
|
|
133
126
|
"path": "../public/assets/zhipuai-BPNAnxo-.svg"
|
|
134
127
|
},
|
|
128
|
+
"/assets/main-CpIX1ZHy.js": {
|
|
129
|
+
"type": "text/javascript; charset=utf-8",
|
|
130
|
+
"etag": '"4db57-PIyiLXQGvlFJuizUFXRhGOYXJwY"',
|
|
131
|
+
"mtime": "2026-06-03T09:30:18.865Z",
|
|
132
|
+
"size": 318295,
|
|
133
|
+
"path": "../public/assets/main-CpIX1ZHy.js"
|
|
134
|
+
},
|
|
135
135
|
"/assets/qwen-CONDcHqt.png": {
|
|
136
136
|
"type": "image/png",
|
|
137
137
|
"etag": '"572c3-cdJAPaHdOvFCGzuaQjagdgOu6XE"',
|
|
138
|
-
"mtime": "2026-06-03T09:
|
|
138
|
+
"mtime": "2026-06-03T09:30:18.865Z",
|
|
139
139
|
"size": 357059,
|
|
140
140
|
"path": "../public/assets/qwen-CONDcHqt.png"
|
|
141
141
|
},
|
|
142
142
|
"/assets/index-Bf_WGooQ.js": {
|
|
143
143
|
"type": "text/javascript; charset=utf-8",
|
|
144
144
|
"etag": '"831df-gmdpd1CCnM4IdaxHIs9uyMgWFaY"',
|
|
145
|
-
"mtime": "2026-06-03T09:
|
|
145
|
+
"mtime": "2026-06-03T09:30:18.865Z",
|
|
146
146
|
"size": 537055,
|
|
147
147
|
"path": "../public/assets/index-Bf_WGooQ.js"
|
|
148
148
|
}
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
2
|
+
import { spawn, execSync } from "node:child_process";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
5
6
|
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = dirname(__filename);
|
|
@@ -35,8 +36,78 @@ for (let i = 0; i < args.length; i++) {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Check if a port is in use and kill the process using it
|
|
41
|
+
*/
|
|
42
|
+
function killProcessOnPort(targetPort: number): void {
|
|
43
|
+
const platform = process.platform;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
let pids: number[] = [];
|
|
47
|
+
|
|
48
|
+
if (platform === "win32") {
|
|
49
|
+
// Windows: use netstat to find PID, then taskkill
|
|
50
|
+
const output = execSync(`netstat -ano | findstr :${targetPort}`, {
|
|
51
|
+
encoding: "utf8",
|
|
52
|
+
timeout: 5000,
|
|
53
|
+
});
|
|
54
|
+
const lines = output.trim().split("\n");
|
|
55
|
+
for (const line of lines) {
|
|
56
|
+
const parts = line.trim().split(/\s+/);
|
|
57
|
+
if (parts.length >= 5) {
|
|
58
|
+
const localAddress = parts[1] ?? "";
|
|
59
|
+
const pidStr = parts[4] ?? "";
|
|
60
|
+
if (localAddress !== "" && pidStr !== "" && localAddress.includes(`:${targetPort}`)) {
|
|
61
|
+
const pid = parseInt(pidStr, 10);
|
|
62
|
+
if (!isNaN(pid) && pid > 0) {
|
|
63
|
+
pids.push(pid);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Remove duplicates
|
|
69
|
+
pids = [...new Set(pids)];
|
|
70
|
+
|
|
71
|
+
for (const pid of pids) {
|
|
72
|
+
try {
|
|
73
|
+
console.log(`Killing process ${pid} on port ${port}...`);
|
|
74
|
+
execSync(`taskkill /PID ${pid} /F`, { encoding: "utf8", timeout: 5000 });
|
|
75
|
+
} catch {
|
|
76
|
+
// Process may have already exited
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
// Unix-like: use lsof
|
|
81
|
+
const output = execSync(`lsof -ti:${targetPort}`, { encoding: "utf8", timeout: 5000 });
|
|
82
|
+
const lines = output.trim().split("\n");
|
|
83
|
+
for (const line of lines) {
|
|
84
|
+
const pid = parseInt(line.trim(), 10);
|
|
85
|
+
if (!isNaN(pid) && pid > 0) {
|
|
86
|
+
pids.push(pid);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Remove duplicates
|
|
90
|
+
pids = [...new Set(pids)];
|
|
91
|
+
|
|
92
|
+
for (const pid of pids) {
|
|
93
|
+
try {
|
|
94
|
+
console.log(`Killing process ${pid} on port ${targetPort}...`);
|
|
95
|
+
execSync(`kill -9 ${pid}`, { encoding: "utf8", timeout: 5000 });
|
|
96
|
+
} catch {
|
|
97
|
+
// Process may have already exited
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
102
|
+
// No process found on port, which is fine
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
38
106
|
process.env["PORT"] = String(port);
|
|
39
107
|
|
|
108
|
+
// Kill any existing process on the port
|
|
109
|
+
killProcessOnPort(port);
|
|
110
|
+
|
|
40
111
|
const url = `http://localhost:${port}`;
|
|
41
112
|
|
|
42
113
|
console.log(`Server running at ${url}`);
|