@tonyclaw/agent-inspector 3.0.18 → 3.0.20

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 (110) hide show
  1. package/.output/cli.js +1257 -506
  2. package/.output/nitro.json +3 -3
  3. package/.output/public/assets/CompareDrawer-CV7rBBty.js +1 -0
  4. package/.output/public/assets/ProxyViewerContainer-CqRfBWJ3.js +127 -0
  5. package/.output/public/assets/ReplayDialog-yDeF-z9y.js +1 -0
  6. package/.output/public/assets/RequestAnatomy-BXxKNdgk.js +1 -0
  7. package/.output/public/assets/ResponseView-BIYNgUNB.js +3 -0
  8. package/.output/public/assets/StreamingChunkSequence-C1faiChu.js +1 -0
  9. package/.output/public/assets/_sessionId-B34PrfCQ.js +1 -0
  10. package/.output/public/assets/index-B3YOj8-_.css +1 -0
  11. package/.output/public/assets/index-BLwqIxup.js +12 -0
  12. package/.output/public/assets/{index-ClQ7Vi3J.js → index-DOspyaW6.js} +1 -1
  13. package/.output/public/assets/index-DT476lno.js +1 -0
  14. package/.output/public/assets/json-viewer-C1S08J_2.js +1 -0
  15. package/.output/server/_chunks/ssr-renderer.mjs +18 -2
  16. package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +165 -31
  17. package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +1 -1
  18. package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +2 -2
  19. package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +28 -1
  20. package/.output/server/_libs/mistralai__mistralai.mjs +1 -1
  21. package/.output/server/_libs/modelcontextprotocol__server.mjs +11571 -8127
  22. package/.output/server/_libs/radix-ui__primitive.mjs +1 -1
  23. package/.output/server/_libs/radix-ui__react-collapsible.mjs +1 -1
  24. package/.output/server/_libs/radix-ui__react-collection.mjs +8 -8
  25. package/.output/server/_libs/radix-ui__react-compose-refs.mjs +0 -1
  26. package/.output/server/_libs/radix-ui__react-context.mjs +4 -18
  27. package/.output/server/_libs/radix-ui__react-dialog.mjs +41 -88
  28. package/.output/server/_libs/radix-ui__react-focus-guards.mjs +15 -5
  29. package/.output/server/_libs/radix-ui__react-focus-scope.mjs +6 -2
  30. package/.output/server/_libs/radix-ui__react-id.mjs +3 -3
  31. package/.output/server/_libs/radix-ui__react-popper.mjs +62 -8
  32. package/.output/server/_libs/radix-ui__react-portal.mjs +2 -2
  33. package/.output/server/_libs/radix-ui__react-presence.mjs +50 -5
  34. package/.output/server/_libs/radix-ui__react-roving-focus.mjs +15 -4
  35. package/.output/server/_libs/radix-ui__react-scroll-area.mjs +30 -20
  36. package/.output/server/_libs/radix-ui__react-select.mjs +167 -123
  37. package/.output/server/_libs/radix-ui__react-slot.mjs +74 -41
  38. package/.output/server/_libs/radix-ui__react-tabs.mjs +6 -1
  39. package/.output/server/_libs/radix-ui__react-tooltip.mjs +6 -3
  40. package/.output/server/_libs/react-dom.mjs +13 -15
  41. package/.output/server/_libs/react.mjs +45 -45
  42. package/.output/server/_libs/srvx.mjs +409 -53
  43. package/.output/server/_libs/swr.mjs +10 -2
  44. package/.output/server/_libs/tailwind-merge.mjs +286 -41
  45. package/.output/server/_libs/tanstack__history.mjs +9 -13
  46. package/.output/server/_libs/tanstack__react-router.mjs +788 -1092
  47. package/.output/server/_libs/tanstack__react-store.mjs +1 -1
  48. package/.output/server/_libs/tanstack__react-virtual.mjs +82 -7
  49. package/.output/server/_libs/tanstack__router-core.mjs +1841 -2060
  50. package/.output/server/_libs/tanstack__virtual-core.mjs +116 -45
  51. package/.output/server/_libs/use-sync-external-store.mjs +1 -1
  52. package/.output/server/_libs/zod-to-json-schema.mjs +1 -1
  53. package/.output/server/_libs/zod.mjs +5085 -200
  54. package/.output/server/{_sessionId-Bi3ZIrqT.mjs → _sessionId-CmoBbtKT.mjs} +30 -32
  55. package/.output/server/_ssr/{CompareDrawer-BYZS_hCR.mjs → CompareDrawer-BsXnVK4e.mjs} +29 -31
  56. package/.output/server/_ssr/{ProxyViewerContainer-BE4umfVs.mjs → ProxyViewerContainer-D-_7pyfx.mjs} +54 -52
  57. package/.output/server/_ssr/{ReplayDialog-BlID2ZH4.mjs → ReplayDialog-deDQA2M5.mjs} +30 -32
  58. package/.output/server/_ssr/{RequestAnatomy-CGJ2lkzT.mjs → RequestAnatomy-CX-cCRdX.mjs} +29 -31
  59. package/.output/server/_ssr/{ResponseView-DDjcGf7M.mjs → ResponseView-D0LJR1qj.mjs} +29 -31
  60. package/.output/server/_ssr/{StreamingChunkSequence-G7B8M5G2.mjs → StreamingChunkSequence-CJRECetE.mjs} +29 -31
  61. package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +6 -0
  62. package/.output/server/_ssr/{index-ClQ9FvRJ.mjs → index-CYWOXS4d.mjs} +31 -33
  63. package/.output/server/_ssr/index.mjs +1102 -784
  64. package/.output/server/_ssr/{json-viewer-CFbpkiBJ.mjs → json-viewer-CCneYiCn.mjs} +29 -31
  65. package/.output/server/_ssr/{router-Cq8LEvhE.mjs → router-D-PAN8IK.mjs} +182 -67
  66. package/.output/server/_tanstack-start-manifest_v-CVZ9yh4R.mjs +4 -0
  67. package/.output/server/index.mjs +74 -92
  68. package/README.md +4 -4
  69. package/package.json +17 -8
  70. package/src/cli/onboard.ts +1 -1
  71. package/src/cli.ts +2 -2
  72. package/src/components/clients/ClientLogo.tsx +5 -1
  73. package/src/components/proxy-viewer/RequestToolsPanel.tsx +1 -0
  74. package/src/components/proxy-viewer/ResponseView.tsx +1 -0
  75. package/src/components/proxy-viewer/StreamingChunkSequence.tsx +1 -0
  76. package/src/components/proxy-viewer/TurnGroup.tsx +1 -0
  77. package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +1 -0
  78. package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +4 -0
  79. package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +1 -0
  80. package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +2 -0
  81. package/src/components/ui/dialog.tsx +1 -1
  82. package/src/components/ui/json-viewer.tsx +2 -0
  83. package/src/components/ui/select.tsx +1 -1
  84. package/src/contracts/json.ts +7 -2
  85. package/src/lib/providerContract.ts +25 -5
  86. package/src/mcp/server.ts +12 -3
  87. package/src/mcp/toolHandlers.ts +6 -1
  88. package/src/proxy/handler.ts +17 -7
  89. package/src/proxy/logFinalizer.ts +76 -8
  90. package/src/proxy/logIndex.ts +16 -32
  91. package/src/proxy/providers.ts +22 -1
  92. package/src/proxy/sessionProcess.ts +15 -1
  93. package/src/proxy/upstream.ts +4 -2
  94. package/src/router.tsx +9 -0
  95. package/.output/public/assets/CompareDrawer-Daj03-RL.js +0 -1
  96. package/.output/public/assets/ProxyViewerContainer-BLCRQtU_.js +0 -106
  97. package/.output/public/assets/ReplayDialog-5FR5crdo.js +0 -1
  98. package/.output/public/assets/RequestAnatomy-DF0hHdQY.js +0 -1
  99. package/.output/public/assets/ResponseView-BwkMSsUa.js +0 -3
  100. package/.output/public/assets/StreamingChunkSequence-CKeUd58x.js +0 -1
  101. package/.output/public/assets/_sessionId-CThgXa41.js +0 -1
  102. package/.output/public/assets/index-BHXN1Fsx.css +0 -1
  103. package/.output/public/assets/index-gm3A0idN.js +0 -1
  104. package/.output/public/assets/json-viewer-BA-W-PZq.js +0 -1
  105. package/.output/public/assets/main-BnRC1932.js +0 -18
  106. package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +0 -17
  107. package/.output/server/_libs/cfworker__json-schema.mjs +0 -1
  108. package/.output/server/_libs/tiny-invariant.mjs +0 -12
  109. package/.output/server/_libs/tiny-warning.mjs +0 -5
  110. package/.output/server/_tanstack-start-manifest_v-p7J0QCMh.mjs +0 -4
@@ -1,6 +1,6 @@
1
1
  import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
2
- import { I as parseJsonText, c as cn, n as TooltipProvider, o as Tooltip, p as TooltipTrigger, q as TooltipContent, b as copyTextToClipboard } from "./ProxyViewerContainer-BE4umfVs.mjs";
3
- import "./router-Cq8LEvhE.mjs";
2
+ import { I as parseJsonText, c as cn, n as TooltipProvider, o as Tooltip, p as TooltipTrigger, q as TooltipContent, b as copyTextToClipboard } from "./ProxyViewerContainer-D-_7pyfx.mjs";
3
+ import "./router-D-PAN8IK.mjs";
4
4
  import "node:fs";
5
5
  import "node:buffer";
6
6
  import "node:path";
@@ -18,42 +18,30 @@ import "../_libs/use-sync-external-store.mjs";
18
18
  import "../_libs/dequal.mjs";
19
19
  import "../_libs/clsx.mjs";
20
20
  import "../_libs/tailwind-merge.mjs";
21
- import "../_libs/radix-ui__react-dialog.mjs";
22
- import "../_libs/radix-ui__primitive.mjs";
23
- import "../_libs/radix-ui__react-compose-refs.mjs";
24
- import "../_libs/radix-ui__react-context.mjs";
25
- import "../_libs/radix-ui__react-id.mjs";
26
- import "../_libs/@radix-ui/react-use-layout-effect+[...].mjs";
27
- import "../_libs/@radix-ui/react-use-controllable-state+[...].mjs";
28
- import "../_libs/@radix-ui/react-dismissable-layer+[...].mjs";
29
- import "../_libs/radix-ui__react-primitive.mjs";
21
+ import "../_libs/class-variance-authority.mjs";
22
+ import "../_libs/tanstack__react-virtual.mjs";
30
23
  import "../_libs/react-dom.mjs";
31
24
  import "util";
32
25
  import "async_hooks";
33
26
  import "stream";
34
- import "../_libs/radix-ui__react-slot.mjs";
35
- import "../_libs/@radix-ui/react-use-callback-ref+[...].mjs";
36
- import "../_libs/@radix-ui/react-use-escape-keydown+[...].mjs";
37
- import "../_libs/radix-ui__react-focus-scope.mjs";
38
- import "../_libs/radix-ui__react-portal.mjs";
39
- import "../_libs/radix-ui__react-presence.mjs";
40
- import "../_libs/radix-ui__react-focus-guards.mjs";
41
- import "../_libs/react-remove-scroll.mjs";
42
- import "tslib";
43
- import "../_libs/react-remove-scroll-bar.mjs";
44
- import "../_libs/react-style-singleton.mjs";
45
- import "../_libs/get-nonce.mjs";
46
- import "../_libs/use-sidecar.mjs";
47
- import "../_libs/use-callback-ref.mjs";
48
- import "../_libs/aria-hidden.mjs";
49
- import "../_libs/class-variance-authority.mjs";
50
- import "../_libs/tanstack__react-virtual.mjs";
51
27
  import "../_libs/tanstack__virtual-core.mjs";
52
28
  import "../_libs/diff.mjs";
29
+ import "../_libs/zod.mjs";
53
30
  import "../_libs/radix-ui__react-select.mjs";
54
31
  import "../_libs/radix-ui__number.mjs";
32
+ import "../_libs/radix-ui__primitive.mjs";
55
33
  import "../_libs/radix-ui__react-collection.mjs";
34
+ import "../_libs/radix-ui__react-context.mjs";
35
+ import "../_libs/radix-ui__react-compose-refs.mjs";
36
+ import "../_libs/radix-ui__react-slot.mjs";
56
37
  import "../_libs/radix-ui__react-direction.mjs";
38
+ import "../_libs/@radix-ui/react-dismissable-layer+[...].mjs";
39
+ import "../_libs/radix-ui__react-primitive.mjs";
40
+ import "../_libs/@radix-ui/react-use-callback-ref+[...].mjs";
41
+ import "../_libs/radix-ui__react-focus-guards.mjs";
42
+ import "../_libs/radix-ui__react-focus-scope.mjs";
43
+ import "../_libs/radix-ui__react-id.mjs";
44
+ import "../_libs/@radix-ui/react-use-layout-effect+[...].mjs";
57
45
  import "../_libs/radix-ui__react-popper.mjs";
58
46
  import "../_libs/floating-ui__react-dom.mjs";
59
47
  import "../_libs/floating-ui__dom.mjs";
@@ -61,23 +49,33 @@ import "../_libs/floating-ui__core.mjs";
61
49
  import "../_libs/floating-ui__utils.mjs";
62
50
  import "../_libs/radix-ui__react-arrow.mjs";
63
51
  import "../_libs/radix-ui__react-use-size.mjs";
52
+ import "../_libs/radix-ui__react-portal.mjs";
53
+ import "../_libs/radix-ui__react-presence.mjs";
54
+ import "../_libs/@radix-ui/react-use-controllable-state+[...].mjs";
64
55
  import "../_libs/radix-ui__react-use-previous.mjs";
65
56
  import "../_libs/@radix-ui/react-visually-hidden+[...].mjs";
66
- import "../_libs/zod.mjs";
57
+ import "../_libs/aria-hidden.mjs";
58
+ import "../_libs/react-remove-scroll.mjs";
59
+ import "tslib";
60
+ import "../_libs/react-remove-scroll-bar.mjs";
61
+ import "../_libs/react-style-singleton.mjs";
62
+ import "../_libs/get-nonce.mjs";
63
+ import "../_libs/use-sidecar.mjs";
64
+ import "../_libs/use-callback-ref.mjs";
65
+ import "../_libs/radix-ui__react-dialog.mjs";
67
66
  import "../_libs/radix-ui__react-tabs.mjs";
68
67
  import "../_libs/radix-ui__react-roving-focus.mjs";
68
+ import "../_libs/@radix-ui/react-use-is-hydrated+[...].mjs";
69
69
  import "../_libs/radix-ui__react-tooltip.mjs";
70
70
  import "../_libs/radix-ui__react-collapsible.mjs";
71
71
  import "../_libs/radix-ui__react-scroll-area.mjs";
72
72
  import "../_libs/tanstack__react-router.mjs";
73
- import "../_libs/tiny-warning.mjs";
74
73
  import "../_libs/tanstack__router-core.mjs";
75
74
  import "../_libs/cookie-es.mjs";
76
75
  import "../_libs/seroval.mjs";
77
76
  import "../_libs/seroval-plugins.mjs";
78
77
  import "node:stream";
79
78
  import "../_libs/tanstack__history.mjs";
80
- import "../_libs/tiny-invariant.mjs";
81
79
  import "node:stream/web";
82
80
  import "../_libs/isbot.mjs";
83
81
  import "node:fs/promises";
@@ -2,7 +2,7 @@ import { c as createRouter, a as createRootRoute, b as createFileRoute, l as laz
2
2
  import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
3
3
  import { S as SWRConfig } from "../_libs/swr.mjs";
4
4
  import { existsSync, readFileSync, mkdirSync, writeFileSync, renameSync, copyFileSync, unlinkSync, createReadStream, readdirSync, statSync, rmSync, cpSync, createWriteStream } from "node:fs";
5
- import fs, { mkdir, appendFile, readFile, writeFile, readdir, open, stat, unlink, rm, rename } from "node:fs/promises";
5
+ import fs, { mkdir, appendFile, writeFile, readdir, open, readFile, stat, unlink, rm, rename } from "node:fs/promises";
6
6
  import { createInterface } from "node:readline";
7
7
  import { Buffer } from "node:buffer";
8
8
  import path, { basename, join, dirname, isAbsolute, resolve, relative } from "node:path";
@@ -16,15 +16,13 @@ import { Worker } from "node:worker_threads";
16
16
  import { M as McpServer, W as WebStandardStreamableHTTPServerTransport, R as ResourceTemplate } from "../_libs/modelcontextprotocol__server.mjs";
17
17
  import { J as JSZip } from "../_libs/jszip.mjs";
18
18
  import { homedir } from "node:os";
19
- import { d as object, b as string, a as array, n as number, r as record, _ as _enum, u as union, c as boolean, e as unknown, l as literal, h as _null, k as lazy, g as discriminatedUnion } from "../_libs/zod.mjs";
20
- import "../_libs/tiny-warning.mjs";
19
+ import { o as object, b as string, e as array, n as number, r as record, _ as _enum, u as union, d as boolean, a as unknown, l as literal, h as _null, j as lazy, g as discriminatedUnion } from "../_libs/zod.mjs";
21
20
  import "../_libs/tanstack__router-core.mjs";
22
21
  import "../_libs/cookie-es.mjs";
23
22
  import "../_libs/seroval.mjs";
24
23
  import "../_libs/seroval-plugins.mjs";
25
24
  import "node:stream";
26
25
  import "../_libs/tanstack__history.mjs";
27
- import "../_libs/tiny-invariant.mjs";
28
26
  import "node:stream/web";
29
27
  import "../_libs/react-dom.mjs";
30
28
  import "util";
@@ -66,7 +64,7 @@ import "../_libs/immediate.mjs";
66
64
  import "../_libs/setimmediate.mjs";
67
65
  import "../_libs/pako.mjs";
68
66
  const faviconSvg = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20role='img'%20aria-label='Agent%20Inspector'%3e%3cg%20fill='none'%20stroke='%23f59e0b'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'%20%3e%3cpath%20d='M5%2013%20C5%209%208%207%2012%207%20C16%207%2019%209%2019%2013%20C19%2016%2016%2018%2012%2018%20C8%2018%205%2016%205%2013%20Z'%20/%3e%3cpath%20d='M5%2011%20C3.5%209.5%201.5%2010%202%2012.5%20C2.5%2014%204%2013.5%205%2012.5'%20/%3e%3cpath%20d='M19%2011%20C20.5%209.5%2022.5%2010%2022%2012.5%20C21.5%2014%2020%2013.5%2019%2012.5'%20/%3e%3cline%20x1='10'%20y1='7'%20x2='9.5'%20y2='5'%20/%3e%3cline%20x1='14'%20y1='7'%20x2='14.5'%20y2='5'%20/%3e%3cline%20x1='6.5'%20y1='16'%20x2='4.5'%20y2='19.5'%20/%3e%3cline%20x1='9'%20y1='17.5'%20x2='8'%20y2='20.5'%20/%3e%3cline%20x1='15'%20y1='17.5'%20x2='16'%20y2='20.5'%20/%3e%3cline%20x1='17.5'%20y1='16'%20x2='19.5'%20y2='19.5'%20/%3e%3c/g%3e%3ccircle%20cx='9.5'%20cy='4.5'%20r='0.9'%20fill='%23f59e0b'%20/%3e%3ccircle%20cx='14.5'%20cy='4.5'%20r='0.9'%20fill='%23f59e0b'%20/%3e%3c/svg%3e";
69
- const appCss = "/assets/index-BHXN1Fsx.css";
67
+ const appCss = "/assets/index-B3YOj8-_.css";
70
68
  const CHUNK_LOAD_RELOAD_AT_KEY = "agent-inspector.chunkLoadReloadAt";
71
69
  const CHUNK_LOAD_RELOAD_WINDOW_MS = 15e3;
72
70
  const CHUNK_LOAD_FAILURE_PATTERNS = [
@@ -178,7 +176,7 @@ function RootDocument({ children }) {
178
176
  ] })
179
177
  ] });
180
178
  }
181
- const $$splitComponentImporter$1 = () => import("./index-ClQ9FvRJ.mjs");
179
+ const $$splitComponentImporter$1 = () => import("./index-CYWOXS4d.mjs");
182
180
  const Route$L = createFileRoute("/")({
183
181
  ssr: false,
184
182
  component: lazyRouteComponent($$splitComponentImporter$1, "component")
@@ -222,7 +220,7 @@ function decodeSessionIdFromPath(encoded) {
222
220
  function getSessionPath(sessionId) {
223
221
  return `/session/${encodeSessionIdForPath(sessionId)}`;
224
222
  }
225
- const $$splitComponentImporter = () => import("../_sessionId-Bi3ZIrqT.mjs");
223
+ const $$splitComponentImporter = () => import("../_sessionId-CmoBbtKT.mjs");
226
224
  const Route$K = createFileRoute("/session/$sessionId")({
227
225
  ssr: false,
228
226
  component: lazyRouteComponent($$splitComponentImporter, "component"),
@@ -364,16 +362,16 @@ let writeQueue = Promise.resolve();
364
362
  let logWriteLock = Promise.resolve();
365
363
  async function runWithLogWriteLock(fn) {
366
364
  const previousLock = logWriteLock;
367
- let releaseLock2 = () => {
365
+ let releaseLock = () => {
368
366
  };
369
367
  logWriteLock = new Promise((resolve2) => {
370
- releaseLock2 = resolve2;
368
+ releaseLock = resolve2;
371
369
  });
372
370
  await previousLock;
373
371
  try {
374
372
  return await fn();
375
373
  } finally {
376
- releaseLock2();
374
+ releaseLock();
377
375
  }
378
376
  }
379
377
  function drainBuffer() {
@@ -445,6 +443,9 @@ const JsonValueSchema = lazy(
445
443
  ])
446
444
  );
447
445
  function trustAsJsonValue(value) {
446
+ if (value === void 0 || typeof value === "bigint" || typeof value === "function") {
447
+ return null;
448
+ }
448
449
  return value;
449
450
  }
450
451
  const StreamingChunkSchema$1 = object({
@@ -1834,40 +1835,26 @@ async function rebuildIndex() {
1834
1835
  await replaceSqliteLogIndexEntries(Object.values(newIndex.entries));
1835
1836
  return newIndex;
1836
1837
  }
1837
- let idGenerationPromise = null;
1838
- let releaseLock = null;
1839
- async function acquireLock() {
1840
- if (releaseLock === null) {
1841
- idGenerationPromise = new Promise((resolve2) => {
1842
- releaseLock = resolve2;
1843
- });
1844
- } else {
1845
- await idGenerationPromise;
1846
- idGenerationPromise = new Promise((resolve2) => {
1847
- releaseLock = resolve2;
1848
- });
1849
- }
1850
- }
1851
- function releaseLockFn() {
1852
- if (releaseLock) {
1853
- const resolve2 = releaseLock;
1854
- releaseLock = null;
1855
- idGenerationPromise = null;
1856
- resolve2();
1857
- }
1838
+ let idGenerationChain = Promise.resolve();
1839
+ async function withIdLock(fn) {
1840
+ const run = idGenerationChain.then(fn);
1841
+ idGenerationChain = run.then(
1842
+ () => {
1843
+ },
1844
+ () => {
1845
+ }
1846
+ );
1847
+ return run;
1858
1848
  }
1859
1849
  async function getNextLogId() {
1860
- await acquireLock();
1861
- try {
1850
+ return withIdLock(async () => {
1862
1851
  const index = await loadIndex();
1863
1852
  const sqliteMaxId = await getSqliteLogIndexMaxId();
1864
1853
  const nextId = Math.max(index.maxId, sqliteMaxId ?? 0) + 1;
1865
1854
  index.maxId = nextId;
1866
1855
  cachedIndex = index;
1867
1856
  return nextId;
1868
- } finally {
1869
- releaseLockFn();
1870
- }
1857
+ });
1871
1858
  }
1872
1859
  function getCurrentLogFile() {
1873
1860
  const now = /* @__PURE__ */ new Date();
@@ -2488,6 +2475,14 @@ async function clearSessionArchives() {
2488
2475
  return 0;
2489
2476
  }
2490
2477
  }
2478
+ function isPlainRecord(val) {
2479
+ return typeof val === "object" && val !== null && !Array.isArray(val);
2480
+ }
2481
+ function safeGetOwnProperty(obj, key) {
2482
+ if (obj === null || typeof obj !== "object" || Array.isArray(obj)) return void 0;
2483
+ const desc = Object.getOwnPropertyDescriptor(obj, key);
2484
+ return desc?.value;
2485
+ }
2491
2486
  const IDLE_TIMEOUT_MS = Number(process.env["SESSION_PROCESS_IDLE_MS"]) || 5 * 60 * 1e3;
2492
2487
  const MAX_RESTARTS = 3;
2493
2488
  const _processes = /* @__PURE__ */ new Map();
@@ -2504,6 +2499,7 @@ class SessionProcess {
2504
2499
  constructor(sessionId) {
2505
2500
  this.sessionId = sessionId;
2506
2501
  }
2502
+ sessionId;
2507
2503
  child = null;
2508
2504
  pending = /* @__PURE__ */ new Map();
2509
2505
  nextId = 0;
@@ -2522,7 +2518,18 @@ class SessionProcess {
2522
2518
  windowsHide: true
2523
2519
  });
2524
2520
  this.restartCount += 1;
2525
- this.child.on("message", (msg) => {
2521
+ this.child.on("message", (raw) => {
2522
+ if (!isPlainRecord(raw)) {
2523
+ logger.error("[sessionProcess] Received malformed IPC message from worker, discarding");
2524
+ return;
2525
+ }
2526
+ const id = safeGetOwnProperty(raw, "id");
2527
+ const result = safeGetOwnProperty(raw, "result");
2528
+ if (typeof id !== "string" || !isPlainRecord(result)) {
2529
+ logger.error("[sessionProcess] Received malformed IPC message from worker, discarding");
2530
+ return;
2531
+ }
2532
+ const msg = { id, result };
2526
2533
  const pending = this.pending.get(msg.id);
2527
2534
  if (pending !== void 0) {
2528
2535
  this.pending.delete(msg.id);
@@ -4821,6 +4828,17 @@ function maskApiKey(apiKey) {
4821
4828
  if (apiKey.length <= 8) return "••••••••";
4822
4829
  return apiKey.slice(0, 4) + "••••••••" + apiKey.slice(-4);
4823
4830
  }
4831
+ function httpUrl() {
4832
+ return string().refine((val) => {
4833
+ if (val.length === 0) return true;
4834
+ try {
4835
+ const parsed = new URL(val);
4836
+ return parsed.protocol === "http:" || parsed.protocol === "https:";
4837
+ } catch {
4838
+ return false;
4839
+ }
4840
+ }, "Must be a valid http(s) URL");
4841
+ }
4824
4842
  const ProviderModelMetadataSchema = object({
4825
4843
  model: string().min(1),
4826
4844
  contextWindow: number().int().positive().optional(),
@@ -4834,12 +4852,12 @@ const ProviderConfigSchema = object({
4834
4852
  name: string(),
4835
4853
  apiKey: string(),
4836
4854
  model: string().optional(),
4837
- models: array(string()).min(1),
4855
+ models: array(string()).optional().default([]),
4838
4856
  format: _enum(["anthropic", "openai"]).optional(),
4839
- baseUrl: string().optional(),
4840
- anthropicBaseUrl: string().optional(),
4841
- openaiBaseUrl: string().optional(),
4842
- openaiResponsesBaseUrl: string().optional(),
4857
+ baseUrl: httpUrl().optional(),
4858
+ anthropicBaseUrl: httpUrl().optional(),
4859
+ openaiBaseUrl: httpUrl().optional(),
4860
+ openaiResponsesBaseUrl: httpUrl().optional(),
4843
4861
  authHeader: _enum(["bearer", "x-api-key"]).optional().default("bearer"),
4844
4862
  apiDocsUrl: string().optional(),
4845
4863
  modelMetadataUrl: string().optional(),
@@ -5452,7 +5470,24 @@ if (providersJson !== void 0) {
5452
5470
  }
5453
5471
  }
5454
5472
  function getProviders() {
5455
- return store.get("providers", []);
5473
+ const raw = store.get("providers", []);
5474
+ const valid = [];
5475
+ for (const candidate of raw) {
5476
+ const entry = ProviderConfigSchema.safeParse(candidate);
5477
+ if (entry.success) {
5478
+ valid.push(entry.data);
5479
+ continue;
5480
+ }
5481
+ let candidateName = "<unknown>";
5482
+ if (typeof candidate === "object" && candidate !== null) {
5483
+ const nameResult = object({ name: string() }).safeParse(candidate);
5484
+ if (nameResult.success) candidateName = nameResult.data.name;
5485
+ }
5486
+ logger.warn(
5487
+ `[providers] Skipping invalid on-disk provider "${candidateName}": ${entry.error.message}`
5488
+ );
5489
+ }
5490
+ return valid;
5456
5491
  }
5457
5492
  function getProvider(id) {
5458
5493
  const providers = getProviders();
@@ -6257,14 +6292,6 @@ function toPersistedConfig(value) {
6257
6292
  timeDisplayFormat: value.timeDisplayFormat
6258
6293
  };
6259
6294
  }
6260
- function isPlainRecord(val) {
6261
- return typeof val === "object" && val !== null && !Array.isArray(val);
6262
- }
6263
- function safeGetOwnProperty(obj, key) {
6264
- if (obj === null || typeof obj !== "object" || Array.isArray(obj)) return void 0;
6265
- const desc = Object.getOwnPropertyDescriptor(obj, key);
6266
- return desc?.value;
6267
- }
6268
6295
  const BILLING_HEADER_PREFIX = "x-anthropic-billing-header:";
6269
6296
  function isClaudeCodeBillingHeaderBlock(text) {
6270
6297
  const trimmed = text.trimStart();
@@ -6889,6 +6916,11 @@ function applyOptionalStreamingTiming(log, job) {
6889
6916
  totalStreamMs: job.totalStreamMs
6890
6917
  });
6891
6918
  return;
6919
+ default: {
6920
+ const _exhaustive = job;
6921
+ logger.error(`[logFinalizer] Unhandled job type: ${JSON.stringify(_exhaustive)}`);
6922
+ return;
6923
+ }
6892
6924
  }
6893
6925
  }
6894
6926
  let toolSchemaWarningQueue = Promise.resolve();
@@ -6952,6 +6984,11 @@ function cleanupPathForRawStream(rawStream) {
6952
6984
  return null;
6953
6985
  case "file":
6954
6986
  return rawStream.path;
6987
+ default: {
6988
+ const _exhaustive = rawStream;
6989
+ logger.error(`[logFinalizer] Unhandled raw stream type: ${JSON.stringify(_exhaustive)}`);
6990
+ return null;
6991
+ }
6955
6992
  }
6956
6993
  }
6957
6994
  function rawStreamByteLength(rawStream) {
@@ -6967,6 +7004,11 @@ function rawStreamByteLength(rawStream) {
6967
7004
  } catch {
6968
7005
  return null;
6969
7006
  }
7007
+ default: {
7008
+ const _exhaustive = rawStream;
7009
+ logger.error(`[logFinalizer] Unhandled raw stream type: ${JSON.stringify(_exhaustive)}`);
7010
+ return null;
7011
+ }
6970
7012
  }
6971
7013
  }
6972
7014
  function getOversizedRawStream(rawStream) {
@@ -6997,6 +7039,11 @@ function readRawStream(rawStream) {
6997
7039
  rawStreamText: readFileSync(rawStream.path, "utf-8"),
6998
7040
  cleanupRawStreamPath: rawStream.path
6999
7041
  };
7042
+ default: {
7043
+ const _exhaustive = rawStream;
7044
+ logger.error(`[logFinalizer] Unhandled raw stream type: ${JSON.stringify(_exhaustive)}`);
7045
+ return { rawStreamText: "", cleanupRawStreamPath: null };
7046
+ }
7000
7047
  }
7001
7048
  }
7002
7049
  function finalizeStreaming(job, log) {
@@ -7108,6 +7155,7 @@ function finalizeStreamAbort(job, log) {
7108
7155
  }
7109
7156
  function buildFinalizeLogResult(job) {
7110
7157
  const log = cloneLog(job.log);
7158
+ const upstreamUrl = job.upstreamUrl;
7111
7159
  switch (job.type) {
7112
7160
  case "non-streaming":
7113
7161
  return finalizeNonStreaming(job, log);
@@ -7115,6 +7163,16 @@ function buildFinalizeLogResult(job) {
7115
7163
  return finalizeStreaming(job, log);
7116
7164
  case "stream-abort":
7117
7165
  return finalizeStreamAbort(job, log);
7166
+ default: {
7167
+ const _exhaustive = job;
7168
+ logger.error(`[logFinalizer] Unhandled job type: ${JSON.stringify(_exhaustive)}`);
7169
+ return {
7170
+ log,
7171
+ upstreamUrl,
7172
+ error: "Unhandled job type",
7173
+ cleanupRawStreamPath: null
7174
+ };
7175
+ }
7118
7176
  }
7119
7177
  }
7120
7178
  function commitFinalizeLogResult(result) {
@@ -7163,6 +7221,16 @@ function resolveBuildPromise(job) {
7163
7221
  return executeBuildInWorker(job);
7164
7222
  case "inline":
7165
7223
  return Promise.resolve(buildFinalizeLogResult(job));
7224
+ default: {
7225
+ const _exhaustive = RUNTIME;
7226
+ logger.error(`[logFinalizer] Unhandled runtime: ${JSON.stringify(_exhaustive)}`);
7227
+ return Promise.resolve({
7228
+ log: job.log,
7229
+ upstreamUrl: job.upstreamUrl,
7230
+ error: "Unhandled runtime",
7231
+ cleanupRawStreamPath: null
7232
+ });
7233
+ }
7166
7234
  }
7167
7235
  }
7168
7236
  const WORKER_COUNT = Math.max(1, Number(process.env["FINALIZER_WORKER_COUNT"]) || 4);
@@ -7175,11 +7243,22 @@ function getWorkers() {
7175
7243
  _workers = [];
7176
7244
  for (let i = 0; i < WORKER_COUNT; i++) {
7177
7245
  const w = new Worker(new URL("./logFinalizer.worker.ts", import.meta.url));
7178
- w.on("message", (msg) => {
7179
- const resolve2 = _pending.get(msg.id);
7180
- if (resolve2 !== void 0) {
7246
+ w.on("message", (raw) => {
7247
+ if (!isPlainRecord(raw)) {
7248
+ logger.error("[logFinalizer] Received malformed IPC message from worker, discarding");
7249
+ return;
7250
+ }
7251
+ const id = safeGetOwnProperty(raw, "id");
7252
+ const result = safeGetOwnProperty(raw, "result");
7253
+ if (typeof id !== "string" || !isPlainRecord(result)) {
7254
+ logger.error("[logFinalizer] Received malformed IPC message from worker, discarding");
7255
+ return;
7256
+ }
7257
+ const msg = { id, result };
7258
+ const entry = _pending.get(msg.id);
7259
+ if (entry !== void 0) {
7181
7260
  _pending.delete(msg.id);
7182
- resolve2(msg.result);
7261
+ entry.resolve(msg.result);
7183
7262
  }
7184
7263
  });
7185
7264
  w.on("error", (err) => {
@@ -7187,20 +7266,29 @@ function getWorkers() {
7187
7266
  "[logFinalizer] Worker error:",
7188
7267
  err instanceof Error ? err.message : String(err)
7189
7268
  );
7269
+ for (const [id, entry] of _pending) {
7270
+ _pending.delete(id);
7271
+ entry.reject(
7272
+ new Error(`Worker crashed: ${err instanceof Error ? err.message : String(err)}`)
7273
+ );
7274
+ }
7190
7275
  });
7191
7276
  _workers.push(w);
7192
7277
  }
7193
7278
  return _workers;
7194
7279
  }
7195
7280
  function executeBuildInWorker(job) {
7196
- return new Promise((resolve2) => {
7281
+ return new Promise((resolve2, reject) => {
7197
7282
  const list = getWorkers();
7198
7283
  const idx = _nextWorker % list.length;
7199
7284
  _nextWorker++;
7200
7285
  const w = list[idx];
7201
- if (w === void 0) return;
7286
+ if (w === void 0) {
7287
+ reject(new Error("No workers available"));
7288
+ return;
7289
+ }
7202
7290
  const id = String(++_jobSeq);
7203
- _pending.set(id, resolve2);
7291
+ _pending.set(id, { resolve: resolve2, reject });
7204
7292
  w.postMessage({ id, job });
7205
7293
  });
7206
7294
  }
@@ -7453,6 +7541,9 @@ function setUpstreamHost(headers, upstreamBase) {
7453
7541
  try {
7454
7542
  headers.set(HEADER_HOST, new URL(upstreamBase).host);
7455
7543
  } catch {
7544
+ logger.warn(
7545
+ `[upstream] Invalid provider URL "${upstreamBase}" — falling back to api.anthropic.com for Host header`
7546
+ );
7456
7547
  headers.set(HEADER_HOST, "api.anthropic.com");
7457
7548
  }
7458
7549
  }
@@ -7581,13 +7672,20 @@ function handleStreamingResponse(upstreamRes, req, startTime, upstreamUrl, log,
7581
7672
  if (upstreamRes.body === null) {
7582
7673
  return new Response("No response body", { status: STATUS_BAD_GATEWAY });
7583
7674
  }
7584
- const loggedStream = upstreamRes.body.pipeThrough(transform);
7585
- req.signal?.addEventListener("abort", () => {
7586
- if (log.responseText === null) {
7587
- logger.info(`[handler] Streaming client aborted: ${log.method} ${log.path}`);
7588
- scheduleStreamingFinalization("stream-abort");
7589
- }
7675
+ void upstreamRes.body.pipeTo(transform.writable).catch(() => {
7676
+ scheduleStreamingFinalization("streaming");
7590
7677
  });
7678
+ const loggedStream = transform.readable;
7679
+ if (req.signal === void 0) {
7680
+ logger.warn("[handler] req.signal is undefined; abort detection disabled for this request");
7681
+ } else {
7682
+ req.signal.addEventListener("abort", () => {
7683
+ if (log.responseText === null) {
7684
+ logger.info(`[handler] Streaming client aborted: ${log.method} ${log.path}`);
7685
+ scheduleStreamingFinalization("stream-abort");
7686
+ }
7687
+ });
7688
+ }
7591
7689
  const responseHeaders = new Headers(upstreamRes.headers);
7592
7690
  responseHeaders.delete(HEADER_CONTENT_ENCODING);
7593
7691
  responseHeaders.delete(HEADER_CONTENT_LENGTH);
@@ -9688,7 +9786,7 @@ const Route$E = createFileRoute("/api/models")({
9688
9786
  }
9689
9787
  });
9690
9788
  const name = "@tonyclaw/agent-inspector";
9691
- const version = "3.0.18";
9789
+ const version = "3.0.20";
9692
9790
  const packageJson = {
9693
9791
  name,
9694
9792
  version
@@ -10137,6 +10235,8 @@ class LoopbackTimeoutError extends Error {
10137
10235
  this.timeoutMs = timeoutMs;
10138
10236
  this.name = "LoopbackTimeoutError";
10139
10237
  }
10238
+ path;
10239
+ timeoutMs;
10140
10240
  }
10141
10241
  async function callApi(path2, options = {}) {
10142
10242
  if (!path2.startsWith("/")) {
@@ -10839,7 +10939,11 @@ async function diagnoseCaptureImpl(callApi2, args = {}) {
10839
10939
  const runtime = await getRuntimeConfigImpl(callApi2);
10840
10940
  if (runtime.isError === true) return runtime;
10841
10941
  const runtimeText = runtime.content[0]?.text ?? "{}";
10842
- const runtimePayload = JSON.parse(runtimeText);
10942
+ let runtimePayload = {};
10943
+ try {
10944
+ runtimePayload = JSON.parse(runtimeText);
10945
+ } catch {
10946
+ }
10843
10947
  const runtimeRecord = isRecord(runtimePayload) ? runtimePayload : {};
10844
10948
  const configRecord = isRecord(runtimeRecord["config"]) ? runtimeRecord["config"] : {};
10845
10949
  const captureMode = stringField(configRecord, "captureMode");
@@ -11303,7 +11407,16 @@ function buildServer() {
11303
11407
  sessionIdGenerator: void 0
11304
11408
  // stateless — see module docstring
11305
11409
  });
11306
- void server.connect(transport);
11410
+ void server.connect(transport).then(
11411
+ () => {
11412
+ },
11413
+ (err) => {
11414
+ logger.error(
11415
+ "[mcp] server.connect failed:",
11416
+ err instanceof Error ? err.message : String(err)
11417
+ );
11418
+ }
11419
+ );
11307
11420
  return { server, transport };
11308
11421
  }
11309
11422
  async function getServer() {
@@ -18451,6 +18564,8 @@ function getRouter() {
18451
18564
  return router2;
18452
18565
  }
18453
18566
  function attachServerSsrStoreCompatibility(router2) {
18567
+ const stateDesc = Object.getOwnPropertyDescriptor(router2, "state");
18568
+ if (stateDesc === void 0) return;
18454
18569
  const existingStores = Object.getOwnPropertyDescriptor(router2, "stores");
18455
18570
  if (existingStores !== void 0) return;
18456
18571
  Object.defineProperty(router2, "stores", {
@@ -0,0 +1,4 @@
1
+ const tsrStartManifest = () => ({ routes: { __root__: { filePath: "C:/Users/claw/workspace/agent-inspector/src/routes/__root.tsx", children: ["/", "/api/alerts", "/api/config", "/api/groups", "/api/health", "/api/logs", "/api/mcp", "/api/models", "/api/pi-agent", "/api/providers", "/api/runs", "/api/sessions", "/proxy/$", "/session/$sessionId", "/api/ecosystem/packages", "/api/ecosystem/tasks", "/api/knowledge/candidates", "/api/knowledge/project-context", "/api/knowledge/search", "/api/ecosystem/recipes/$recipeId/run", "/api/knowledge/sessions/$sessionId/candidates"], preloads: ["/assets/index-BLwqIxup.js"], scripts: [{ attrs: { type: "module", async: true, src: "/assets/index-BLwqIxup.js" } }] }, "/": { filePath: "C:/Users/claw/workspace/agent-inspector/src/routes/index.tsx", children: void 0, preloads: ["/assets/index-DT476lno.js", "/assets/ProxyViewerContainer-CqRfBWJ3.js"] }, "/session/$sessionId": { filePath: "C:/Users/claw/workspace/agent-inspector/src/routes/session/$sessionId.tsx", children: void 0, preloads: ["/assets/_sessionId-B34PrfCQ.js", "/assets/ProxyViewerContainer-CqRfBWJ3.js"] } } });
2
+ export {
3
+ tsrStartManifest
4
+ };