@tonyclaw/llm-inspector 1.19.0 → 1.19.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.
Files changed (40) hide show
  1. package/.output/cli.js +338 -102
  2. package/.output/nitro.json +1 -1
  3. package/.output/public/assets/{CompareDrawer-DwayZPPO.js → CompareDrawer-BzTsEelr.js} +1 -1
  4. package/.output/public/assets/{ProxyViewerContainer-iv3LVMEW.js → ProxyViewerContainer-BHm-n-_W.js} +9 -9
  5. package/.output/public/assets/{ReplayDialog-CaV1elYO.js → ReplayDialog-Dxxo80xO.js} +1 -1
  6. package/.output/public/assets/{RequestAnatomy-CSfnjK7j.js → RequestAnatomy-D-swiaii.js} +1 -1
  7. package/.output/public/assets/{ResponseView-YkOL__xm.js → ResponseView-DvdH2bGk.js} +1 -1
  8. package/.output/public/assets/{StreamingChunkSequence-D_p6L-oB.js → StreamingChunkSequence-D_RzgyKq.js} +1 -1
  9. package/.output/public/assets/_sessionId-DdODJCYY.js +1 -0
  10. package/.output/public/assets/{index-DeJyypsp.css → index-Bqi9RAGS.css} +1 -1
  11. package/.output/public/assets/index-EvnsNPOK.js +1 -0
  12. package/.output/public/assets/{json-viewer-BB-9bqnP.js → json-viewer-DIHZbEId.js} +1 -1
  13. package/.output/public/assets/{main-COVN451W.js → main-Br2EjrqZ.js} +2 -2
  14. package/.output/server/{_sessionId-BJT5qIib.mjs → _sessionId-CPkCxTP8.mjs} +4 -3
  15. package/.output/server/_ssr/{CompareDrawer-DNGYdUXs.mjs → CompareDrawer-DKHgXC5-.mjs} +4 -4
  16. package/.output/server/_ssr/{ProxyViewerContainer-B-zDOLYE.mjs → ProxyViewerContainer-B41D-2Eo.mjs} +57 -9
  17. package/.output/server/_ssr/{ReplayDialog-DWeqMA4y.mjs → ReplayDialog-D2piRWb0.mjs} +5 -5
  18. package/.output/server/_ssr/{RequestAnatomy-TOsrMu9-.mjs → RequestAnatomy-Ce7QdQNP.mjs} +4 -3
  19. package/.output/server/_ssr/{ResponseView-BuqdPrzm.mjs → ResponseView-D50UPv-r.mjs} +5 -5
  20. package/.output/server/_ssr/{StreamingChunkSequence-DuzNZkqL.mjs → StreamingChunkSequence-CDlNFS3Z.mjs} +4 -4
  21. package/.output/server/_ssr/{index-1nCQUt3y.mjs → index-DhAQxjnZ.mjs} +4 -3
  22. package/.output/server/_ssr/index.mjs +2 -2
  23. package/.output/server/_ssr/{json-viewer-BL8xhHbi.mjs → json-viewer-BZRjG_f7.mjs} +4 -4
  24. package/.output/server/_ssr/{router-aCaUgVTW.mjs → router-yP98-Gq-.mjs} +126 -105
  25. package/.output/server/{_tanstack-start-manifest_v-cBRxvCjb.mjs → _tanstack-start-manifest_v-d4a4xlOi.mjs} +1 -1
  26. package/.output/server/index.mjs +64 -64
  27. package/README.md +22 -0
  28. package/package.json +3 -1
  29. package/src/cli/detect-tools.ts +1 -0
  30. package/src/cli/templates/skill-onboard.ts +204 -71
  31. package/src/cli.ts +164 -39
  32. package/src/components/ProxyViewerContainer.tsx +52 -0
  33. package/src/components/proxy-viewer/LogEntryHeader.tsx +1 -0
  34. package/src/proxy/logFinalizer.ts +7 -3
  35. package/src/proxy/sessionProcess.ts +14 -7
  36. package/src/proxy/sessionSupervisor.ts +3 -2
  37. package/src/proxy/socketTracker.ts +19 -7
  38. package/styles/globals.css +14 -7
  39. package/.output/public/assets/_sessionId-BgCVUC6R.js +0 -1
  40. package/.output/public/assets/index-CWA4S0FO.js +0 -1
@@ -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, D as DEFAULT_SLOW_RESPONSE_THRESHOLD_SECONDS, a as RuntimeConfigSchema, r as requestFormatForPath, c as createPendingProviderTestResults, P as ProviderTestResultsSchema, d as createFailedProviderTestResults, M as MAX_SLOW_RESPONSE_THRESHOLD_SECONDS, g as getSessionPath, e as ProviderConfigSchema, s as stripClaudeCodeBillingHeader, p as parseOpenAIResponse, O as OpenAIRequestSchema, A as AnthropicResponseSchema$1, b as AnthropicRequestSchema } from "./router-aCaUgVTW.mjs";
2
+ import { C as CapturedLogSchema, D as DEFAULT_SLOW_RESPONSE_THRESHOLD_SECONDS, a as RuntimeConfigSchema, r as requestFormatForPath, c as createPendingProviderTestResults, P as ProviderTestResultsSchema, d as createFailedProviderTestResults, M as MAX_SLOW_RESPONSE_THRESHOLD_SECONDS, g as getSessionPath, e as ProviderConfigSchema, s as stripClaudeCodeBillingHeader, p as parseOpenAIResponse, O as OpenAIRequestSchema, A as AnthropicResponseSchema$1, b as AnthropicRequestSchema } from "./router-yP98-Gq-.mjs";
3
3
  import { u as useSWR, a as useSWRConfig } from "../_libs/swr.mjs";
4
4
  import { J as JSZip } from "../_libs/jszip.mjs";
5
5
  import { c as clsx } from "../_libs/clsx.mjs";
@@ -275,7 +275,7 @@ function getStatusCategory(status) {
275
275
  if (status >= 500) return "server_error";
276
276
  return "pending";
277
277
  }
278
- const version = "1.19.0";
278
+ const version = "1.19.2";
279
279
  const packageJson = {
280
280
  version
281
281
  };
@@ -1343,27 +1343,27 @@ function useCopyFeedback(text) {
1343
1343
  return { copied, copy };
1344
1344
  }
1345
1345
  const LazyCompareDrawer = reactExports.lazy(
1346
- () => import("./CompareDrawer-DNGYdUXs.mjs").then((m) => ({ default: m.CompareDrawer }))
1346
+ () => import("./CompareDrawer-DKHgXC5-.mjs").then((m) => ({ default: m.CompareDrawer }))
1347
1347
  );
1348
1348
  const LazyReplayDialog = reactExports.lazy(
1349
- () => import("./ReplayDialog-DWeqMA4y.mjs").then((m) => ({ default: m.ReplayDialog }))
1349
+ () => import("./ReplayDialog-D2piRWb0.mjs").then((m) => ({ default: m.ReplayDialog }))
1350
1350
  );
1351
1351
  const LazyRequestAnatomy = reactExports.lazy(
1352
- () => import("./RequestAnatomy-TOsrMu9-.mjs").then((m) => ({ default: m.RequestAnatomy }))
1352
+ () => import("./RequestAnatomy-Ce7QdQNP.mjs").then((m) => ({ default: m.RequestAnatomy }))
1353
1353
  );
1354
1354
  const LazyResponseView = reactExports.lazy(
1355
- () => import("./ResponseView-BuqdPrzm.mjs").then((m) => ({ default: m.ResponseView }))
1355
+ () => import("./ResponseView-D50UPv-r.mjs").then((m) => ({ default: m.ResponseView }))
1356
1356
  );
1357
1357
  const LazyStreamingChunkSequence = reactExports.lazy(
1358
- () => import("./StreamingChunkSequence-DuzNZkqL.mjs").then((m) => ({
1358
+ () => import("./StreamingChunkSequence-CDlNFS3Z.mjs").then((m) => ({
1359
1359
  default: m.StreamingChunkSequence
1360
1360
  }))
1361
1361
  );
1362
1362
  const LazyJsonViewer = reactExports.lazy(
1363
- () => import("./json-viewer-BL8xhHbi.mjs").then((m) => ({ default: m.JsonViewer }))
1363
+ () => import("./json-viewer-BZRjG_f7.mjs").then((m) => ({ default: m.JsonViewer }))
1364
1364
  );
1365
1365
  const LazyJsonViewerFromString = reactExports.lazy(
1366
- () => import("./json-viewer-BL8xhHbi.mjs").then((m) => ({ default: m.JsonViewerFromString }))
1366
+ () => import("./json-viewer-BZRjG_f7.mjs").then((m) => ({ default: m.JsonViewerFromString }))
1367
1367
  );
1368
1368
  const HIGHLIGHT_DURATION_MS = 1200;
1369
1369
  const MAX_HIGHLIGHT_ATTEMPTS = 12;
@@ -1794,6 +1794,7 @@ const LogEntryHeader = reactExports.memo(function({
1794
1794
  return /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1795
1795
  "div",
1796
1796
  {
1797
+ id: `log-${log.id}`,
1797
1798
  role: "button",
1798
1799
  tabIndex: 0,
1799
1800
  "data-nav-id": `log-${log.id}`,
@@ -5634,6 +5635,8 @@ function filterLogs(logs, selectedSession, selectedModel) {
5634
5635
  });
5635
5636
  }
5636
5637
  const DEBOUNCE_MS = 50;
5638
+ const HASH_SCROLL_ATTEMPTS = 12;
5639
+ const HASH_HIGHLIGHT_MS = 1800;
5637
5640
  function buildLogsStreamUrl(sessionId) {
5638
5641
  if (sessionId === void 0) return "/api/logs/stream";
5639
5642
  const params = new URLSearchParams({ sessionId });
@@ -5649,6 +5652,7 @@ function ProxyViewerContainer({
5649
5652
  const [error, setError] = reactExports.useState(null);
5650
5653
  const eventSourceRef = reactExports.useRef(null);
5651
5654
  const reconnectTimeoutRef = reactExports.useRef(null);
5655
+ const handledHashRef = reactExports.useRef(null);
5652
5656
  const logIndexRef = reactExports.useRef(/* @__PURE__ */ new Map());
5653
5657
  const pendingUpdatesRef = reactExports.useRef([]);
5654
5658
  const flushTimerRef = reactExports.useRef(null);
@@ -5749,6 +5753,50 @@ function ProxyViewerContainer({
5749
5753
  }
5750
5754
  };
5751
5755
  }, [connectSSE]);
5756
+ reactExports.useEffect(() => {
5757
+ const hash = window.location.hash;
5758
+ if (!hash.startsWith("#log-")) return;
5759
+ if (handledHashRef.current === hash) return;
5760
+ const targetId = hash.slice(1);
5761
+ let cancelled = false;
5762
+ let attempts = 0;
5763
+ let highlightedTarget = null;
5764
+ let highlightTimer = null;
5765
+ const tryScrollToLog = () => {
5766
+ if (cancelled) return;
5767
+ const target = document.getElementById(targetId);
5768
+ if (target !== null) {
5769
+ handledHashRef.current = hash;
5770
+ target.scrollIntoView({ block: "center", behavior: "smooth" });
5771
+ if (target instanceof HTMLElement) {
5772
+ highlightedTarget = target;
5773
+ target.setAttribute("data-deep-link-highlight", "true");
5774
+ highlightTimer = window.setTimeout(() => {
5775
+ target.removeAttribute("data-deep-link-highlight");
5776
+ }, HASH_HIGHLIGHT_MS);
5777
+ target.focus({ preventScroll: true });
5778
+ if (target.getAttribute("data-nav-action") === "expand") {
5779
+ target.click();
5780
+ }
5781
+ }
5782
+ return;
5783
+ }
5784
+ attempts += 1;
5785
+ if (attempts < HASH_SCROLL_ATTEMPTS) {
5786
+ window.setTimeout(tryScrollToLog, 100);
5787
+ }
5788
+ };
5789
+ tryScrollToLog();
5790
+ return () => {
5791
+ cancelled = true;
5792
+ if (highlightTimer !== null) {
5793
+ window.clearTimeout(highlightTimer);
5794
+ }
5795
+ if (highlightedTarget !== null) {
5796
+ highlightedTarget.removeAttribute("data-deep-link-highlight");
5797
+ }
5798
+ };
5799
+ }, [logs.length]);
5752
5800
  const handleClearAll = reactExports.useCallback(() => {
5753
5801
  if (initialSessionId !== void 0 && allLogs.length === 0) return;
5754
5802
  void (async () => {
@@ -1,10 +1,10 @@
1
1
  import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
2
- import { D as Dialog, b as DialogContent, d as DialogHeader, e as DialogTitle, T as Tabs, h as TabsList, i as TabsTrigger, j as TabsContent, k as TooltipProvider, l as Tooltip, m as TooltipTrigger, n as TooltipContent, o as Button } from "./ProxyViewerContainer-B-zDOLYE.mjs";
3
- import { ResponseView } from "./ResponseView-BuqdPrzm.mjs";
4
- import "./router-aCaUgVTW.mjs";
2
+ import { D as Dialog, b as DialogContent, d as DialogHeader, e as DialogTitle, T as Tabs, h as TabsList, i as TabsTrigger, j as TabsContent, k as TooltipProvider, l as Tooltip, m as TooltipTrigger, n as TooltipContent, o as Button } from "./ProxyViewerContainer-B41D-2Eo.mjs";
3
+ import { ResponseView } from "./ResponseView-D50UPv-r.mjs";
4
+ import "./router-yP98-Gq-.mjs";
5
5
  import "../_libs/modelcontextprotocol__server.mjs";
6
6
  import "../_libs/jszip.mjs";
7
- import "./json-viewer-BL8xhHbi.mjs";
7
+ import "./json-viewer-BZRjG_f7.mjs";
8
8
  import { s as RotateCcw } from "../_libs/lucide-react.mjs";
9
9
  import { d as object, c as boolean, n as number, b as string } from "../_libs/zod.mjs";
10
10
  import "../_libs/swr.mjs";
@@ -132,6 +132,7 @@ import "../_libs/isbot.mjs";
132
132
  import "node:fs";
133
133
  import "node:fs/promises";
134
134
  import "node:buffer";
135
+ import "node:child_process";
135
136
  import "../_libs/conf.mjs";
136
137
  import "node:util";
137
138
  import "node:crypto";
@@ -152,7 +153,6 @@ import "../_libs/debounce-fn.mjs";
152
153
  import "../_libs/mimic-function.mjs";
153
154
  import "../_libs/semver.mjs";
154
155
  import "../_libs/uint8array-extras.mjs";
155
- import "node:child_process";
156
156
  import "node:worker_threads";
157
157
  import "../_libs/readable-stream.mjs";
158
158
  import "events";
@@ -1,6 +1,6 @@
1
1
  import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
2
- import { k as TooltipProvider, f as formatTokens, c as cn, l as Tooltip, m as TooltipTrigger, n as TooltipContent } from "./ProxyViewerContainer-B-zDOLYE.mjs";
3
- import "./router-aCaUgVTW.mjs";
2
+ import { k as TooltipProvider, f as formatTokens, c as cn, l as Tooltip, m as TooltipTrigger, n as TooltipContent } from "./ProxyViewerContainer-B41D-2Eo.mjs";
3
+ import "./router-yP98-Gq-.mjs";
4
4
  import "../_libs/modelcontextprotocol__server.mjs";
5
5
  import "../_libs/jszip.mjs";
6
6
  import { Q as Info } from "../_libs/lucide-react.mjs";
@@ -74,6 +74,8 @@ import "node:fs";
74
74
  import "node:fs/promises";
75
75
  import "node:buffer";
76
76
  import "node:path";
77
+ import "node:child_process";
78
+ import "node:url";
77
79
  import "../_libs/conf.mjs";
78
80
  import "node:util";
79
81
  import "node:process";
@@ -95,7 +97,6 @@ import "../_libs/debounce-fn.mjs";
95
97
  import "../_libs/mimic-function.mjs";
96
98
  import "../_libs/semver.mjs";
97
99
  import "../_libs/uint8array-extras.mjs";
98
- import "node:child_process";
99
100
  import "node:worker_threads";
100
101
  import "../_libs/readable-stream.mjs";
101
102
  import "events";
@@ -1,7 +1,7 @@
1
1
  import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
2
- import { g as getLogFormatAdapter, f as formatTokens, c as cn, p as getStatusCategory, B as Badge, s as safeJsonValue } from "./ProxyViewerContainer-B-zDOLYE.mjs";
3
- import { JsonViewer } from "./json-viewer-BL8xhHbi.mjs";
4
- import "./router-aCaUgVTW.mjs";
2
+ import { g as getLogFormatAdapter, f as formatTokens, c as cn, p as getStatusCategory, B as Badge, s as safeJsonValue } from "./ProxyViewerContainer-B41D-2Eo.mjs";
3
+ import { JsonViewer } from "./json-viewer-BZRjG_f7.mjs";
4
+ import "./router-yP98-Gq-.mjs";
5
5
  import "../_libs/modelcontextprotocol__server.mjs";
6
6
  import "../_libs/jszip.mjs";
7
7
  import { Z as Zap, i as TriangleAlert, V as CircleStop, Y as Brain, b as ChevronDown, f as ChevronRight, _ as Terminal } from "../_libs/lucide-react.mjs";
@@ -79,6 +79,8 @@ import "node:fs";
79
79
  import "node:fs/promises";
80
80
  import "node:buffer";
81
81
  import "node:path";
82
+ import "node:child_process";
83
+ import "node:url";
82
84
  import "../_libs/conf.mjs";
83
85
  import "node:util";
84
86
  import "node:process";
@@ -100,7 +102,6 @@ import "../_libs/debounce-fn.mjs";
100
102
  import "../_libs/mimic-function.mjs";
101
103
  import "../_libs/semver.mjs";
102
104
  import "../_libs/uint8array-extras.mjs";
103
- import "node:child_process";
104
105
  import "node:worker_threads";
105
106
  import "../_libs/readable-stream.mjs";
106
107
  import "events";
@@ -125,7 +126,6 @@ import "../_libs/trough.mjs";
125
126
  import "../_libs/vfile.mjs";
126
127
  import "../_libs/vfile-message.mjs";
127
128
  import "../_libs/unist-util-stringify-position.mjs";
128
- import "node:url";
129
129
  import "../_libs/remark-parse.mjs";
130
130
  import "../_libs/mdast-util-from-markdown.mjs";
131
131
  import "../_libs/micromark-util-decode-numeric-character-reference+[...].mjs";
@@ -1,7 +1,7 @@
1
1
  import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
2
- import { k as TooltipProvider, l as Tooltip, m as TooltipTrigger, B as Badge, n as TooltipContent } from "./ProxyViewerContainer-B-zDOLYE.mjs";
3
- import { JsonViewer } from "./json-viewer-BL8xhHbi.mjs";
4
- import "./router-aCaUgVTW.mjs";
2
+ import { k as TooltipProvider, l as Tooltip, m as TooltipTrigger, B as Badge, n as TooltipContent } from "./ProxyViewerContainer-B41D-2Eo.mjs";
3
+ import { JsonViewer } from "./json-viewer-BZRjG_f7.mjs";
4
+ import "./router-yP98-Gq-.mjs";
5
5
  import "../_libs/modelcontextprotocol__server.mjs";
6
6
  import "../_libs/jszip.mjs";
7
7
  import { b as ChevronDown, f as ChevronRight, L as LoaderCircle } from "../_libs/lucide-react.mjs";
@@ -128,6 +128,7 @@ import "../_libs/isbot.mjs";
128
128
  import "node:fs";
129
129
  import "node:fs/promises";
130
130
  import "node:buffer";
131
+ import "node:child_process";
131
132
  import "../_libs/conf.mjs";
132
133
  import "node:util";
133
134
  import "node:crypto";
@@ -148,7 +149,6 @@ import "../_libs/debounce-fn.mjs";
148
149
  import "../_libs/mimic-function.mjs";
149
150
  import "../_libs/semver.mjs";
150
151
  import "../_libs/uint8array-extras.mjs";
151
- import "node:child_process";
152
152
  import "node:worker_threads";
153
153
  import "../_libs/readable-stream.mjs";
154
154
  import "events";
@@ -1,6 +1,6 @@
1
- import { P as ProxyViewerContainer } from "./ProxyViewerContainer-B-zDOLYE.mjs";
1
+ import { P as ProxyViewerContainer } from "./ProxyViewerContainer-B41D-2Eo.mjs";
2
2
  import "../_libs/react.mjs";
3
- import "./router-aCaUgVTW.mjs";
3
+ import "./router-yP98-Gq-.mjs";
4
4
  import "../_libs/modelcontextprotocol__server.mjs";
5
5
  import "../_libs/jszip.mjs";
6
6
  import "../_libs/swr.mjs";
@@ -74,6 +74,8 @@ import "node:fs";
74
74
  import "node:fs/promises";
75
75
  import "node:buffer";
76
76
  import "node:path";
77
+ import "node:child_process";
78
+ import "node:url";
77
79
  import "../_libs/conf.mjs";
78
80
  import "node:util";
79
81
  import "node:process";
@@ -95,7 +97,6 @@ import "../_libs/debounce-fn.mjs";
95
97
  import "../_libs/mimic-function.mjs";
96
98
  import "../_libs/semver.mjs";
97
99
  import "../_libs/uint8array-extras.mjs";
98
- import "node:child_process";
99
100
  import "node:worker_threads";
100
101
  import "../_libs/readable-stream.mjs";
101
102
  import "events";
@@ -198,7 +198,7 @@ function getResponse() {
198
198
  return event.res;
199
199
  }
200
200
  async function getStartManifest(matchedRoutes) {
201
- const { tsrStartManifest } = await import("../_tanstack-start-manifest_v-cBRxvCjb.mjs");
201
+ const { tsrStartManifest } = await import("../_tanstack-start-manifest_v-d4a4xlOi.mjs");
202
202
  const startManifest = tsrStartManifest();
203
203
  const rootRoute = startManifest.routes[rootRouteId] = startManifest.routes[rootRouteId] || {};
204
204
  rootRoute.assets = rootRoute.assets || [];
@@ -767,7 +767,7 @@ let entriesPromise;
767
767
  let baseManifestPromise;
768
768
  let cachedFinalManifestPromise;
769
769
  async function loadEntries() {
770
- const routerEntry = await import("./router-aCaUgVTW.mjs").then((n) => n.f);
770
+ const routerEntry = await import("./router-yP98-Gq-.mjs").then((n) => n.f);
771
771
  const startEntry = await import("./start-HYkvq4Ni.mjs");
772
772
  return { startEntry, routerEntry };
773
773
  }
@@ -1,6 +1,6 @@
1
1
  import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
2
- import { q as parseJsonText, c as cn, k as TooltipProvider, l as Tooltip, m as TooltipTrigger, n as TooltipContent } from "./ProxyViewerContainer-B-zDOLYE.mjs";
3
- import "./router-aCaUgVTW.mjs";
2
+ import { q as parseJsonText, c as cn, k as TooltipProvider, l as Tooltip, m as TooltipTrigger, n as TooltipContent } from "./ProxyViewerContainer-B41D-2Eo.mjs";
3
+ import "./router-yP98-Gq-.mjs";
4
4
  import "../_libs/modelcontextprotocol__server.mjs";
5
5
  import "../_libs/jszip.mjs";
6
6
  import { C as Check, a as Copy, b as ChevronDown, f as ChevronRight, q as ChevronsDown } from "../_libs/lucide-react.mjs";
@@ -75,6 +75,8 @@ import "node:fs";
75
75
  import "node:fs/promises";
76
76
  import "node:buffer";
77
77
  import "node:path";
78
+ import "node:child_process";
79
+ import "node:url";
78
80
  import "../_libs/conf.mjs";
79
81
  import "node:util";
80
82
  import "node:process";
@@ -96,7 +98,6 @@ import "../_libs/debounce-fn.mjs";
96
98
  import "../_libs/mimic-function.mjs";
97
99
  import "../_libs/semver.mjs";
98
100
  import "../_libs/uint8array-extras.mjs";
99
- import "node:child_process";
100
101
  import "node:worker_threads";
101
102
  import "../_libs/readable-stream.mjs";
102
103
  import "events";
@@ -121,7 +122,6 @@ import "../_libs/trough.mjs";
121
122
  import "../_libs/vfile.mjs";
122
123
  import "../_libs/vfile-message.mjs";
123
124
  import "../_libs/unist-util-stringify-position.mjs";
124
- import "node:url";
125
125
  import "../_libs/remark-parse.mjs";
126
126
  import "../_libs/mdast-util-from-markdown.mjs";
127
127
  import "../_libs/micromark-util-decode-numeric-character-reference+[...].mjs";
@@ -5,9 +5,10 @@ import { existsSync, readFileSync, mkdirSync, writeFileSync, renameSync, copyFil
5
5
  import { mkdir, appendFile, readFile, open, readdir, stat, unlink, writeFile } from "node:fs/promises";
6
6
  import { Buffer } from "node:buffer";
7
7
  import path, { join, isAbsolute, dirname } from "node:path";
8
+ import { execFile, exec, spawn } from "node:child_process";
9
+ import { fileURLToPath } from "node:url";
8
10
  import { C as Conf } from "../_libs/conf.mjs";
9
11
  import { randomUUID } from "crypto";
10
- import { exec, fork } from "node:child_process";
11
12
  import { promisify } from "node:util";
12
13
  import { Worker } from "node:worker_threads";
13
14
  import { M as McpServer, W as WebStandardStreamableHTTPServerTransport } from "../_libs/modelcontextprotocol__server.mjs";
@@ -47,7 +48,7 @@ import "../_libs/debounce-fn.mjs";
47
48
  import "../_libs/mimic-function.mjs";
48
49
  import "../_libs/semver.mjs";
49
50
  import "../_libs/uint8array-extras.mjs";
50
- const appCss = "/assets/index-DeJyypsp.css";
51
+ const appCss = "/assets/index-Bqi9RAGS.css";
51
52
  const Route$l = createRootRoute({
52
53
  head: () => ({
53
54
  meta: [
@@ -71,7 +72,7 @@ function RootDocument({ children }) {
71
72
  ] })
72
73
  ] });
73
74
  }
74
- const $$splitComponentImporter$1 = () => import("./index-1nCQUt3y.mjs");
75
+ const $$splitComponentImporter$1 = () => import("./index-DhAQxjnZ.mjs");
75
76
  const Route$k = createFileRoute("/")({
76
77
  component: lazyRouteComponent($$splitComponentImporter$1, "component")
77
78
  });
@@ -114,7 +115,7 @@ function decodeSessionIdFromPath(encoded) {
114
115
  function getSessionPath(sessionId) {
115
116
  return `/session/${encodeSessionIdForPath(sessionId)}`;
116
117
  }
117
- const $$splitComponentImporter = () => import("../_sessionId-BJT5qIib.mjs");
118
+ const $$splitComponentImporter = () => import("../_sessionId-CPkCxTP8.mjs");
118
119
  const Route$j = createFileRoute("/session/$sessionId")({
119
120
  component: lazyRouteComponent($$splitComponentImporter, "component"),
120
121
  parseParams: (params) => ({
@@ -887,13 +888,113 @@ function readChunks(path2) {
887
888
  return null;
888
889
  }
889
890
  }
891
+ const IDLE_TIMEOUT_MS = Number(process.env["SESSION_PROCESS_IDLE_MS"]) || 5 * 60 * 1e3;
892
+ const MAX_RESTARTS = 3;
893
+ const _processes = /* @__PURE__ */ new Map();
894
+ function resolveSessionWorkerPath() {
895
+ return fileURLToPath(new URL("./sessionWorkerEntry.ts", import.meta.url));
896
+ }
897
+ function isSessionProcessAvailable() {
898
+ return existsSync(resolveSessionWorkerPath());
899
+ }
900
+ class SessionProcess {
901
+ constructor(sessionId) {
902
+ this.sessionId = sessionId;
903
+ }
904
+ child = null;
905
+ pending = /* @__PURE__ */ new Map();
906
+ nextId = 0;
907
+ idleTimer = null;
908
+ restartCount = 0;
909
+ destroyed = false;
910
+ /** Number of outstanding jobs sent to this process. */
911
+ get pendingCount() {
912
+ return this.pending.size;
913
+ }
914
+ ensureRunning() {
915
+ if (this.child !== null && this.child.connected) return this.child;
916
+ const resolvedPath = resolveSessionWorkerPath();
917
+ this.child = spawn(process.execPath, [...process.execArgv, resolvedPath], {
918
+ stdio: ["pipe", "pipe", "pipe", "ipc"],
919
+ windowsHide: true
920
+ });
921
+ this.restartCount += 1;
922
+ this.child.on("message", (msg) => {
923
+ const pending = this.pending.get(msg.id);
924
+ if (pending !== void 0) {
925
+ this.pending.delete(msg.id);
926
+ pending.resolve(msg.result);
927
+ }
928
+ this.resetIdleTimer();
929
+ });
930
+ this.child.on("error", (err) => {
931
+ logger.error(`[sessionProcess] Session ${this.sessionId} process error:`, err.message);
932
+ });
933
+ this.child.on("exit", (code, signal) => {
934
+ const wasConnected = this.child !== null;
935
+ this.child = null;
936
+ if (this.destroyed) return;
937
+ for (const [, pending] of this.pending) {
938
+ pending.reject(
939
+ new Error(
940
+ `Session process exited with code ${code ?? signal}, session=${this.sessionId}`
941
+ )
942
+ );
943
+ }
944
+ this.pending.clear();
945
+ if (wasConnected && this.restartCount <= MAX_RESTARTS) {
946
+ logger.warn(
947
+ `[sessionProcess] Session ${this.sessionId} worker exited (code=${code ?? signal}), restart ${this.restartCount}/${MAX_RESTARTS}`
948
+ );
949
+ }
950
+ });
951
+ this.resetIdleTimer();
952
+ return this.child;
953
+ }
954
+ enqueue(job) {
955
+ return new Promise((resolve, reject) => {
956
+ const child = this.ensureRunning();
957
+ const id = String(++this.nextId);
958
+ this.pending.set(id, { resolve, reject });
959
+ child.send({ id, job });
960
+ });
961
+ }
962
+ resetIdleTimer() {
963
+ if (this.idleTimer !== null) clearTimeout(this.idleTimer);
964
+ this.idleTimer = setTimeout(() => {
965
+ if (this.pending.size === 0) {
966
+ this.destroy();
967
+ }
968
+ }, IDLE_TIMEOUT_MS);
969
+ }
970
+ destroy() {
971
+ this.destroyed = true;
972
+ if (this.idleTimer !== null) {
973
+ clearTimeout(this.idleTimer);
974
+ this.idleTimer = null;
975
+ }
976
+ if (this.child !== null) {
977
+ this.child.kill();
978
+ this.child = null;
979
+ }
980
+ _processes.delete(this.sessionId);
981
+ }
982
+ }
983
+ function getSessionProcess(sessionId) {
984
+ const existing = _processes.get(sessionId);
985
+ if (existing !== void 0) return existing;
986
+ const sp = new SessionProcess(sessionId);
987
+ _processes.set(sessionId, sp);
988
+ return sp;
989
+ }
890
990
  const PROVIDER_TEST_SESSION_ID = "provider-test";
891
991
  function getRuntimeMode() {
892
992
  if (process.env["FINALIZER_USE_WORKER"] === "0") return "in-process";
893
993
  const mode = process.env["FINALIZER_RUNTIME"];
994
+ if (mode === "process") return "child-process";
894
995
  if (mode === "worker") return "worker-thread";
895
996
  if (mode === "inline") return "in-process";
896
- return "child-process";
997
+ return isSessionProcessAvailable() ? "child-process" : "in-process";
897
998
  }
898
999
  const sessions = /* @__PURE__ */ new Map();
899
1000
  const knownLogSessions = /* @__PURE__ */ new Map();
@@ -2263,6 +2364,7 @@ function findProviderByModel(model) {
2263
2364
  return null;
2264
2365
  }
2265
2366
  const execAsync = promisify(exec);
2367
+ const execFileAsync = promisify(execFile);
2266
2368
  const cache = /* @__PURE__ */ new Map();
2267
2369
  const CACHE_TTL_MS = 5 * 60 * 1e3;
2268
2370
  const MAX_CACHE_SIZE = 200;
@@ -2305,9 +2407,15 @@ async function lookupClientInfo(port) {
2305
2407
  ` Write-Output "$pid|$cmd"`,
2306
2408
  `}`
2307
2409
  ].join("; ");
2308
- const { stdout } = await execAsync(`powershell -NoProfile -Command "${psScript}"`, {
2309
- windowsHide: true
2310
- });
2410
+ const { stdout } = await execFileAsync(
2411
+ "powershell.exe",
2412
+ ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", psScript],
2413
+ {
2414
+ windowsHide: true,
2415
+ timeout: 3e3,
2416
+ maxBuffer: 64 * 1024
2417
+ }
2418
+ );
2311
2419
  const trimmed = stdout.trim();
2312
2420
  if (trimmed === "") {
2313
2421
  return { port, pid: null, cwd: null, projectFolder: null };
@@ -2374,9 +2482,14 @@ async function lookupProcessInfo(pid) {
2374
2482
  const platform = process.platform;
2375
2483
  try {
2376
2484
  if (platform === "win32") {
2377
- const { stdout } = await execAsync(
2378
- `wmic process where processid=${pid} get commandline /value`,
2379
- { windowsHide: true }
2485
+ const { stdout } = await execFileAsync(
2486
+ "wmic.exe",
2487
+ ["process", "where", `processid=${pid}`, "get", "commandline", "/value"],
2488
+ {
2489
+ windowsHide: true,
2490
+ timeout: 3e3,
2491
+ maxBuffer: 64 * 1024
2492
+ }
2380
2493
  );
2381
2494
  const lines = stdout.trim().split("\n").filter(Boolean);
2382
2495
  for (const line of lines) {
@@ -2646,99 +2759,6 @@ function stripOpenAIOrphanToolMessages(rawBody) {
2646
2759
  parsed.messages = kept;
2647
2760
  return { body: JSON.stringify(parsed), removed: indices.length, orphanIds };
2648
2761
  }
2649
- const IDLE_TIMEOUT_MS = Number(process.env["SESSION_PROCESS_IDLE_MS"]) || 5 * 60 * 1e3;
2650
- const MAX_RESTARTS = 3;
2651
- const _processes = /* @__PURE__ */ new Map();
2652
- class SessionProcess {
2653
- constructor(sessionId) {
2654
- this.sessionId = sessionId;
2655
- }
2656
- child = null;
2657
- pending = /* @__PURE__ */ new Map();
2658
- nextId = 0;
2659
- idleTimer = null;
2660
- restartCount = 0;
2661
- destroyed = false;
2662
- /** Number of outstanding jobs sent to this process. */
2663
- get pendingCount() {
2664
- return this.pending.size;
2665
- }
2666
- ensureRunning() {
2667
- if (this.child !== null && this.child.connected) return this.child;
2668
- const entryPath = new URL("./sessionWorkerEntry.ts", import.meta.url).pathname;
2669
- const resolvedPath = process.platform === "win32" && entryPath.startsWith("/") ? entryPath.slice(1) : entryPath;
2670
- this.child = fork(resolvedPath, [], {
2671
- stdio: ["pipe", "pipe", "pipe", "ipc"]
2672
- });
2673
- this.restartCount += 1;
2674
- this.child.on("message", (msg) => {
2675
- const pending = this.pending.get(msg.id);
2676
- if (pending !== void 0) {
2677
- this.pending.delete(msg.id);
2678
- pending.resolve(msg.result);
2679
- }
2680
- this.resetIdleTimer();
2681
- });
2682
- this.child.on("error", (err) => {
2683
- logger.error(`[sessionProcess] Session ${this.sessionId} process error:`, err.message);
2684
- });
2685
- this.child.on("exit", (code, signal) => {
2686
- const wasConnected = this.child !== null;
2687
- this.child = null;
2688
- if (this.destroyed) return;
2689
- for (const [, pending] of this.pending) {
2690
- pending.reject(
2691
- new Error(
2692
- `Session process exited with code ${code ?? signal}, session=${this.sessionId}`
2693
- )
2694
- );
2695
- }
2696
- this.pending.clear();
2697
- if (wasConnected && this.restartCount <= MAX_RESTARTS) {
2698
- logger.warn(
2699
- `[sessionProcess] Session ${this.sessionId} worker exited (code=${code ?? signal}), restart ${this.restartCount}/${MAX_RESTARTS}`
2700
- );
2701
- }
2702
- });
2703
- this.resetIdleTimer();
2704
- return this.child;
2705
- }
2706
- enqueue(job) {
2707
- return new Promise((resolve, reject) => {
2708
- const child = this.ensureRunning();
2709
- const id = String(++this.nextId);
2710
- this.pending.set(id, { resolve, reject });
2711
- child.send({ id, job });
2712
- });
2713
- }
2714
- resetIdleTimer() {
2715
- if (this.idleTimer !== null) clearTimeout(this.idleTimer);
2716
- this.idleTimer = setTimeout(() => {
2717
- if (this.pending.size === 0) {
2718
- this.destroy();
2719
- }
2720
- }, IDLE_TIMEOUT_MS);
2721
- }
2722
- destroy() {
2723
- this.destroyed = true;
2724
- if (this.idleTimer !== null) {
2725
- clearTimeout(this.idleTimer);
2726
- this.idleTimer = null;
2727
- }
2728
- if (this.child !== null) {
2729
- this.child.kill();
2730
- this.child = null;
2731
- }
2732
- _processes.delete(this.sessionId);
2733
- }
2734
- }
2735
- function getSessionProcess(sessionId) {
2736
- const existing = _processes.get(sessionId);
2737
- if (existing !== void 0) return existing;
2738
- const sp = new SessionProcess(sessionId);
2739
- _processes.set(sessionId, sp);
2740
- return sp;
2741
- }
2742
2762
  function buildFileLogEntry(log, upstreamUrl) {
2743
2763
  return {
2744
2764
  timestamp: log.timestamp,
@@ -2873,9 +2893,10 @@ function commitFinalizeLogResult(result) {
2873
2893
  const RUNTIME = (() => {
2874
2894
  if (process.env["FINALIZER_USE_WORKER"] === "0") return "inline";
2875
2895
  const mode = process.env["FINALIZER_RUNTIME"];
2896
+ if (mode === "process") return "process";
2876
2897
  if (mode === "worker") return "worker";
2877
2898
  if (mode === "inline") return "inline";
2878
- return "process";
2899
+ return isSessionProcessAvailable() ? "process" : "inline";
2879
2900
  })();
2880
2901
  function executeBuildInSessionProcess(job) {
2881
2902
  const sessionId = job.log.sessionId ?? "__unassigned__";
@@ -1,4 +1,4 @@
1
- const tsrStartManifest = () => ({ "routes": { "__root__": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/__root.tsx", "children": ["/", "/api/config", "/api/health", "/api/logs", "/api/mcp", "/api/models", "/api/providers", "/api/sessions", "/proxy/$", "/session/$sessionId"], "preloads": ["/assets/main-COVN451W.js"], "assets": [] }, "/": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/index.tsx", "assets": [], "preloads": ["/assets/index-CWA4S0FO.js", "/assets/ProxyViewerContainer-iv3LVMEW.js"] }, "/api/config": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/config.ts", "children": ["/api/config/paths"] }, "/api/health": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/health.ts" }, "/api/logs": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.ts", "children": ["/api/logs/$id", "/api/logs/stream"] }, "/api/mcp": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/mcp.ts" }, "/api/models": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/models.ts" }, "/api/providers": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.ts", "children": ["/api/providers/$providerId", "/api/providers/export", "/api/providers/import", "/api/providers/scan"] }, "/api/sessions": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/sessions.ts" }, "/proxy/$": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/proxy/$.ts" }, "/session/$sessionId": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/session/$sessionId.tsx", "assets": [], "preloads": ["/assets/_sessionId-BgCVUC6R.js", "/assets/ProxyViewerContainer-iv3LVMEW.js"] }, "/api/config/paths": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/config.paths.ts" }, "/api/logs/$id": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.$id.ts", "children": ["/api/logs/$id/chunks", "/api/logs/$id/replay"] }, "/api/logs/stream": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.stream.ts" }, "/api/providers/$providerId": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.$providerId.ts", "children": ["/api/providers/$providerId/test"] }, "/api/providers/export": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.export.ts" }, "/api/providers/import": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.import.ts" }, "/api/providers/scan": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.scan.ts" }, "/api/logs/$id/chunks": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.$id.chunks.ts" }, "/api/logs/$id/replay": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.$id.replay.ts" }, "/api/providers/$providerId/test": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.$providerId.test.ts", "children": ["/api/providers/$providerId/test/log"] }, "/api/providers/$providerId/test/log": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.$providerId.test.log.ts" } }, "clientEntry": "/assets/main-COVN451W.js" });
1
+ const tsrStartManifest = () => ({ "routes": { "__root__": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/__root.tsx", "children": ["/", "/api/config", "/api/health", "/api/logs", "/api/mcp", "/api/models", "/api/providers", "/api/sessions", "/proxy/$", "/session/$sessionId"], "preloads": ["/assets/main-Br2EjrqZ.js"], "assets": [] }, "/": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/index.tsx", "assets": [], "preloads": ["/assets/index-EvnsNPOK.js", "/assets/ProxyViewerContainer-BHm-n-_W.js"] }, "/api/config": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/config.ts", "children": ["/api/config/paths"] }, "/api/health": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/health.ts" }, "/api/logs": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.ts", "children": ["/api/logs/$id", "/api/logs/stream"] }, "/api/mcp": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/mcp.ts" }, "/api/models": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/models.ts" }, "/api/providers": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.ts", "children": ["/api/providers/$providerId", "/api/providers/export", "/api/providers/import", "/api/providers/scan"] }, "/api/sessions": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/sessions.ts" }, "/proxy/$": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/proxy/$.ts" }, "/session/$sessionId": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/session/$sessionId.tsx", "assets": [], "preloads": ["/assets/_sessionId-DdODJCYY.js", "/assets/ProxyViewerContainer-BHm-n-_W.js"] }, "/api/config/paths": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/config.paths.ts" }, "/api/logs/$id": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.$id.ts", "children": ["/api/logs/$id/chunks", "/api/logs/$id/replay"] }, "/api/logs/stream": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.stream.ts" }, "/api/providers/$providerId": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.$providerId.ts", "children": ["/api/providers/$providerId/test"] }, "/api/providers/export": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.export.ts" }, "/api/providers/import": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.import.ts" }, "/api/providers/scan": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.scan.ts" }, "/api/logs/$id/chunks": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.$id.chunks.ts" }, "/api/logs/$id/replay": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/logs.$id.replay.ts" }, "/api/providers/$providerId/test": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.$providerId.test.ts", "children": ["/api/providers/$providerId/test/log"] }, "/api/providers/$providerId/test/log": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/api/providers.$providerId.test.log.ts" } }, "clientEntry": "/assets/main-Br2EjrqZ.js" });
2
2
  export {
3
3
  tsrStartManifest
4
4
  };