@tonyclaw/llm-inspector 1.7.1 → 1.7.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/.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`);
@@ -1,5 +1,5 @@
1
1
  {
2
- "date": "2026-06-03T09:17:47.326Z",
2
+ "date": "2026-06-03T09:45:59.559Z",
3
3
  "preset": "node-server",
4
4
  "framework": {
5
5
  "name": "nitro",
@@ -1,5 +1,5 @@
1
1
  import { r as reactExports, j as jsxRuntimeExports, a as React } from "../_libs/react.mjs";
2
- import { C as CapturedLogSchema, a as parseRequest, p as parseOpenAIResponse, I as InspectorResponseSchema } from "./router-D7g2K6y6.mjs";
2
+ import { C as CapturedLogSchema, a as parseRequest, p as parseOpenAIResponse, I as InspectorResponseSchema } from "./router-BWDeDWmr.mjs";
3
3
  import { u as useVirtualizer } from "../_libs/tanstack__react-virtual.mjs";
4
4
  import { J as JSZip } from "../_libs/jszip.mjs";
5
5
  import { c as clsx } from "../_libs/clsx.mjs";
@@ -766,7 +766,7 @@ let entriesPromise;
766
766
  let baseManifestPromise;
767
767
  let cachedFinalManifestPromise;
768
768
  async function loadEntries() {
769
- const routerEntry = await import("./router-D7g2K6y6.mjs").then((n) => n.r);
769
+ const routerEntry = await import("./router-BWDeDWmr.mjs").then((n) => n.r);
770
770
  const startEntry = await import("./start-HYkvq4Ni.mjs");
771
771
  return { startEntry, routerEntry };
772
772
  }
@@ -65,7 +65,7 @@ function RootDocument({ children }) {
65
65
  ] })
66
66
  ] });
67
67
  }
68
- const $$splitComponentImporter = () => import("./index-BZkxgx8f.mjs");
68
+ const $$splitComponentImporter = () => import("./index-D0iGQ1Zd.mjs");
69
69
  const Route$d = createFileRoute("/")({
70
70
  component: lazyRouteComponent($$splitComponentImporter, "component")
71
71
  });
@@ -1417,11 +1417,13 @@ function migrateProviders() {
1417
1417
  }
1418
1418
  const oldAnthropicBaseUrl = getOldUrl(p, "anthropicBaseUrl");
1419
1419
  const oldOpenaiBaseUrl = getOldUrl(p, "openaiBaseUrl");
1420
- if (p.format !== void 0 && oldAnthropicBaseUrl === "" && oldOpenaiBaseUrl === "") {
1420
+ const currentAnthropicUrl = p.anthropicBaseUrl ?? "";
1421
+ const currentOpenaiUrl = p.openaiBaseUrl ?? "";
1422
+ if (p.format !== void 0 && (currentAnthropicUrl !== "" || currentOpenaiUrl !== "")) {
1421
1423
  return p;
1422
1424
  }
1423
- const newAnthropicUrl = oldAnthropicBaseUrl !== "" ? oldAnthropicBaseUrl : p.anthropicBaseUrl ?? "";
1424
- const newOpenaiUrl = oldOpenaiBaseUrl !== "" ? oldOpenaiBaseUrl : p.openaiBaseUrl ?? "";
1425
+ const newAnthropicUrl = oldAnthropicBaseUrl !== "" ? oldAnthropicBaseUrl : currentAnthropicUrl;
1426
+ const newOpenaiUrl = oldOpenaiBaseUrl !== "" ? oldOpenaiBaseUrl : currentOpenaiUrl;
1425
1427
  let format;
1426
1428
  let baseUrl;
1427
1429
  if (newAnthropicUrl !== "" && newOpenaiUrl !== "") {
@@ -1433,6 +1435,14 @@ function migrateProviders() {
1433
1435
  } else if (newAnthropicUrl !== "") {
1434
1436
  format = "anthropic";
1435
1437
  baseUrl = newAnthropicUrl;
1438
+ } else if (p.format !== void 0 && p.baseUrl !== void 0 && p.baseUrl !== "") {
1439
+ format = p.format;
1440
+ baseUrl = p.baseUrl;
1441
+ if (format === "openai") {
1442
+ return { ...p, format, baseUrl, anthropicBaseUrl: "", openaiBaseUrl: p.baseUrl };
1443
+ } else {
1444
+ return { ...p, format, baseUrl, anthropicBaseUrl: p.baseUrl, openaiBaseUrl: "" };
1445
+ }
1436
1446
  }
1437
1447
  migrated = true;
1438
1448
  return {
@@ -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:17:40.502Z",
103
+ "mtime": "2026-06-03T09:45:53.063Z",
104
104
  "size": 5915,
105
105
  "path": "../public/assets/alibaba-TTwafVwX.svg"
106
106
  },
107
- "/assets/index-B3RwBPLW.css": {
108
- "type": "text/css; charset=utf-8",
109
- "etag": '"10c74-aXacU4DRFVsUwcC5jHnjoPRSlTA"',
110
- "mtime": "2026-06-03T09:17:40.504Z",
111
- "size": 68724,
112
- "path": "../public/assets/index-B3RwBPLW.css"
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
107
  "/assets/minimax-BPMzvuL-.jpeg": {
122
108
  "type": "image/jpeg",
123
109
  "etag": '"1b06-IwivU89ko5UTMUM1/t7hn4sQK9A"',
124
- "mtime": "2026-06-03T09:17:40.501Z",
110
+ "mtime": "2026-06-03T09:45:53.065Z",
125
111
  "size": 6918,
126
112
  "path": "../public/assets/minimax-BPMzvuL-.jpeg"
127
113
  },
114
+ "/assets/index-B3RwBPLW.css": {
115
+ "type": "text/css; charset=utf-8",
116
+ "etag": '"10c74-aXacU4DRFVsUwcC5jHnjoPRSlTA"',
117
+ "mtime": "2026-06-03T09:45:53.063Z",
118
+ "size": 68724,
119
+ "path": "../public/assets/index-B3RwBPLW.css"
120
+ },
128
121
  "/assets/zhipuai-BPNAnxo-.svg": {
129
122
  "type": "image/svg+xml",
130
123
  "etag": '"2bf8-hNaLCTi89nOFCsIIfWpP/jrfo0s"',
131
- "mtime": "2026-06-03T09:17:40.502Z",
124
+ "mtime": "2026-06-03T09:45:53.063Z",
132
125
  "size": 11256,
133
126
  "path": "../public/assets/zhipuai-BPNAnxo-.svg"
134
127
  },
135
128
  "/assets/qwen-CONDcHqt.png": {
136
129
  "type": "image/png",
137
130
  "etag": '"572c3-cdJAPaHdOvFCGzuaQjagdgOu6XE"',
138
- "mtime": "2026-06-03T09:17:40.502Z",
131
+ "mtime": "2026-06-03T09:45:53.065Z",
139
132
  "size": 357059,
140
133
  "path": "../public/assets/qwen-CONDcHqt.png"
141
134
  },
135
+ "/assets/main-CpIX1ZHy.js": {
136
+ "type": "text/javascript; charset=utf-8",
137
+ "etag": '"4db57-PIyiLXQGvlFJuizUFXRhGOYXJwY"',
138
+ "mtime": "2026-06-03T09:45:53.065Z",
139
+ "size": 318295,
140
+ "path": "../public/assets/main-CpIX1ZHy.js"
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:17:40.504Z",
145
+ "mtime": "2026-06-03T09:45:53.065Z",
146
146
  "size": 537055,
147
147
  "path": "../public/assets/index-Bf_WGooQ.js"
148
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonyclaw/llm-inspector",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "type": "module",
5
5
  "description": "LLM API proxy inspector — captures and displays requests/responses from AI coding tools in a web UI",
6
6
  "license": "MIT",
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}`);
@@ -7,7 +7,6 @@ import {
7
7
  Trash2,
8
8
  RotateCw,
9
9
  CheckCircle,
10
- XCircle,
11
10
  Minus,
12
11
  ExternalLink,
13
12
  AlertCircle,
@@ -60,16 +60,17 @@ function migrateProviders(): void {
60
60
 
61
61
  const oldAnthropicBaseUrl = getOldUrl(p, "anthropicBaseUrl");
62
62
  const oldOpenaiBaseUrl = getOldUrl(p, "openaiBaseUrl");
63
+ const currentAnthropicUrl = p.anthropicBaseUrl ?? "";
64
+ const currentOpenaiUrl = p.openaiBaseUrl ?? "";
63
65
 
64
- // If already migrated (has format field and both URLs), skip
65
- if (p.format !== undefined && oldAnthropicBaseUrl === "" && oldOpenaiBaseUrl === "") {
66
+ // If already migrated (has format field and at least one URL), skip
67
+ if (p.format !== undefined && (currentAnthropicUrl !== "" || currentOpenaiUrl !== "")) {
66
68
  return p;
67
69
  }
68
70
 
69
71
  // Preserve both URLs
70
- const newAnthropicUrl =
71
- oldAnthropicBaseUrl !== "" ? oldAnthropicBaseUrl : (p.anthropicBaseUrl ?? "");
72
- const newOpenaiUrl = oldOpenaiBaseUrl !== "" ? oldOpenaiBaseUrl : (p.openaiBaseUrl ?? "");
72
+ const newAnthropicUrl = oldAnthropicBaseUrl !== "" ? oldAnthropicBaseUrl : currentAnthropicUrl;
73
+ const newOpenaiUrl = oldOpenaiBaseUrl !== "" ? oldOpenaiBaseUrl : currentOpenaiUrl;
73
74
 
74
75
  // Determine primary format based on which URL is set
75
76
  let format: "anthropic" | "openai" | undefined;
@@ -85,6 +86,15 @@ function migrateProviders(): void {
85
86
  } else if (newAnthropicUrl !== "") {
86
87
  format = "anthropic";
87
88
  baseUrl = newAnthropicUrl;
89
+ } else if (p.format !== undefined && p.baseUrl !== undefined && p.baseUrl !== "") {
90
+ // Only baseUrl is set (legacy config) - migrate based on format
91
+ format = p.format;
92
+ baseUrl = p.baseUrl;
93
+ if (format === "openai") {
94
+ return { ...p, format, baseUrl, anthropicBaseUrl: "", openaiBaseUrl: p.baseUrl };
95
+ } else {
96
+ return { ...p, format, baseUrl, anthropicBaseUrl: p.baseUrl, openaiBaseUrl: "" };
97
+ }
88
98
  }
89
99
 
90
100
  migrated = true;