@tonyclaw/llm-inspector 1.6.0
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/nitro.json +17 -0
- package/.output/public/assets/alibaba-TTwafVwX.svg +1 -0
- package/.output/public/assets/index-B3RwBPLW.css +1 -0
- package/.output/public/assets/index-s4lwsWvq.js +97 -0
- package/.output/public/assets/main-Cp8AM0Pa.js +17 -0
- package/.output/public/assets/minimax-BPMzvuL-.jpeg +0 -0
- package/.output/public/assets/qwen-CONDcHqt.png +0 -0
- package/.output/public/assets/zhipuai-BPNAnxo-.svg +219 -0
- package/.output/server/_chunks/ssr-renderer.mjs +17 -0
- package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +210 -0
- package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +11 -0
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +69 -0
- package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +17 -0
- package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +6 -0
- package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +34 -0
- package/.output/server/_libs/ajv-formats.mjs +330 -0
- package/.output/server/_libs/ajv.mjs +11444 -0
- package/.output/server/_libs/aria-hidden.mjs +122 -0
- package/.output/server/_libs/atomically.mjs +152 -0
- package/.output/server/_libs/bail.mjs +8 -0
- package/.output/server/_libs/character-entities.mjs +2130 -0
- package/.output/server/_libs/class-variance-authority.mjs +44 -0
- package/.output/server/_libs/clsx.mjs +16 -0
- package/.output/server/_libs/comma-separated-tokens.mjs +10 -0
- package/.output/server/_libs/conf.mjs +635 -0
- package/.output/server/_libs/cookie-es.mjs +58 -0
- package/.output/server/_libs/core-util-is.mjs +75 -0
- package/.output/server/_libs/croner.mjs +1 -0
- package/.output/server/_libs/crossws.mjs +1 -0
- package/.output/server/_libs/debounce-fn.mjs +69 -0
- package/.output/server/_libs/decode-named-character-reference+[...].mjs +8 -0
- package/.output/server/_libs/detect-node-es.mjs +1 -0
- package/.output/server/_libs/devlop.mjs +8 -0
- package/.output/server/_libs/dot-prop.mjs +265 -0
- package/.output/server/_libs/env-paths.mjs +57 -0
- package/.output/server/_libs/estree-util-is-identifier-name.mjs +11 -0
- package/.output/server/_libs/extend.mjs +97 -0
- package/.output/server/_libs/fast-deep-equal.mjs +38 -0
- package/.output/server/_libs/fast-uri.mjs +812 -0
- package/.output/server/_libs/floating-ui__core.mjs +725 -0
- package/.output/server/_libs/floating-ui__dom.mjs +622 -0
- package/.output/server/_libs/floating-ui__react-dom.mjs +292 -0
- package/.output/server/_libs/floating-ui__utils.mjs +320 -0
- package/.output/server/_libs/get-nonce.mjs +9 -0
- package/.output/server/_libs/h3-v2.mjs +276 -0
- package/.output/server/_libs/h3.mjs +400 -0
- package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
- package/.output/server/_libs/hast-util-whitespace.mjs +10 -0
- package/.output/server/_libs/hookable.mjs +1 -0
- package/.output/server/_libs/html-url-attributes.mjs +26 -0
- package/.output/server/_libs/immediate.mjs +74 -0
- package/.output/server/_libs/inherits.mjs +50 -0
- package/.output/server/_libs/inline-style-parser.mjs +142 -0
- package/.output/server/_libs/is-plain-obj.mjs +10 -0
- package/.output/server/_libs/isarray.mjs +14 -0
- package/.output/server/_libs/isbot.mjs +20 -0
- package/.output/server/_libs/json-schema-traverse.mjs +180 -0
- package/.output/server/_libs/jszip.mjs +3049 -0
- package/.output/server/_libs/lie.mjs +273 -0
- package/.output/server/_libs/lucide-react.mjs +368 -0
- package/.output/server/_libs/mdast-util-from-markdown.mjs +717 -0
- package/.output/server/_libs/mdast-util-to-hast.mjs +710 -0
- package/.output/server/_libs/mdast-util-to-string.mjs +38 -0
- package/.output/server/_libs/micromark-core-commonmark.mjs +2259 -0
- package/.output/server/_libs/micromark-factory-destination.mjs +94 -0
- package/.output/server/_libs/micromark-factory-label.mjs +63 -0
- package/.output/server/_libs/micromark-factory-space.mjs +24 -0
- package/.output/server/_libs/micromark-factory-title.mjs +65 -0
- package/.output/server/_libs/micromark-factory-whitespace.mjs +22 -0
- package/.output/server/_libs/micromark-util-character.mjs +44 -0
- package/.output/server/_libs/micromark-util-chunked.mjs +36 -0
- package/.output/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
- package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
- package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
- package/.output/server/_libs/micromark-util-decode-string.mjs +21 -0
- package/.output/server/_libs/micromark-util-encode.mjs +1 -0
- package/.output/server/_libs/micromark-util-html-tag-name.mjs +69 -0
- package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
- package/.output/server/_libs/micromark-util-resolve-all.mjs +15 -0
- package/.output/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
- package/.output/server/_libs/micromark-util-subtokenize.mjs +346 -0
- package/.output/server/_libs/micromark.mjs +906 -0
- package/.output/server/_libs/mimic-function.mjs +47 -0
- package/.output/server/_libs/ohash.mjs +1 -0
- package/.output/server/_libs/pako.mjs +4223 -0
- package/.output/server/_libs/process-nextick-args.mjs +48 -0
- package/.output/server/_libs/property-information.mjs +1209 -0
- package/.output/server/_libs/radix-ui.mjs +1 -0
- package/.output/server/_libs/radix-ui__number.mjs +6 -0
- package/.output/server/_libs/radix-ui__primitive.mjs +11 -0
- package/.output/server/_libs/radix-ui__react-accordion.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-arrow.mjs +23 -0
- package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-avatar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-checkbox.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-collapsible.mjs +144 -0
- package/.output/server/_libs/radix-ui__react-collection.mjs +69 -0
- package/.output/server/_libs/radix-ui__react-compose-refs.mjs +39 -0
- package/.output/server/_libs/radix-ui__react-context-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-context.mjs +78 -0
- package/.output/server/_libs/radix-ui__react-dialog.mjs +325 -0
- package/.output/server/_libs/radix-ui__react-direction.mjs +9 -0
- package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-focus-guards.mjs +29 -0
- package/.output/server/_libs/radix-ui__react-focus-scope.mjs +206 -0
- package/.output/server/_libs/radix-ui__react-form.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-hover-card.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-id.mjs +14 -0
- package/.output/server/_libs/radix-ui__react-label.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-menubar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-popover.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-popper.mjs +286 -0
- package/.output/server/_libs/radix-ui__react-portal.mjs +16 -0
- package/.output/server/_libs/radix-ui__react-presence.mjs +128 -0
- package/.output/server/_libs/radix-ui__react-primitive.mjs +42 -0
- package/.output/server/_libs/radix-ui__react-progress.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-radio-group.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-roving-focus.mjs +224 -0
- package/.output/server/_libs/radix-ui__react-scroll-area.mjs +721 -0
- package/.output/server/_libs/radix-ui__react-select.mjs +1163 -0
- package/.output/server/_libs/radix-ui__react-separator.mjs +28 -0
- package/.output/server/_libs/radix-ui__react-slider.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-slot.mjs +99 -0
- package/.output/server/_libs/radix-ui__react-switch.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-tabs.mjs +189 -0
- package/.output/server/_libs/radix-ui__react-toast.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toggle-group.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toggle.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toolbar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-tooltip.mjs +495 -0
- package/.output/server/_libs/radix-ui__react-use-previous.mjs +14 -0
- package/.output/server/_libs/radix-ui__react-use-size.mjs +39 -0
- package/.output/server/_libs/react-dom.mjs +9935 -0
- package/.output/server/_libs/react-markdown.mjs +147 -0
- package/.output/server/_libs/react-remove-scroll-bar.mjs +82 -0
- package/.output/server/_libs/react-remove-scroll.mjs +328 -0
- package/.output/server/_libs/react-style-singleton.mjs +69 -0
- package/.output/server/_libs/react.mjs +515 -0
- package/.output/server/_libs/readable-stream.mjs +1518 -0
- package/.output/server/_libs/remark-parse.mjs +19 -0
- package/.output/server/_libs/remark-rehype.mjs +21 -0
- package/.output/server/_libs/rou3.mjs +8 -0
- package/.output/server/_libs/safe-buffer.mjs +64 -0
- package/.output/server/_libs/semver.mjs +1984 -0
- package/.output/server/_libs/seroval-plugins.mjs +58 -0
- package/.output/server/_libs/seroval.mjs +1765 -0
- package/.output/server/_libs/setimmediate.mjs +1 -0
- package/.output/server/_libs/space-separated-tokens.mjs +6 -0
- package/.output/server/_libs/srvx.mjs +334 -0
- package/.output/server/_libs/stubborn-fs.mjs +91 -0
- package/.output/server/_libs/stubborn-utils.mjs +66 -0
- package/.output/server/_libs/style-to-js.mjs +72 -0
- package/.output/server/_libs/style-to-object.mjs +38 -0
- package/.output/server/_libs/tailwind-merge.mjs +3010 -0
- package/.output/server/_libs/tanstack__history.mjs +217 -0
- package/.output/server/_libs/tanstack__react-router.mjs +1480 -0
- package/.output/server/_libs/tanstack__react-store.mjs +1 -0
- package/.output/server/_libs/tanstack__react-virtual.mjs +44 -0
- package/.output/server/_libs/tanstack__router-core.mjs +4827 -0
- package/.output/server/_libs/tanstack__store.mjs +1 -0
- package/.output/server/_libs/tanstack__virtual-core.mjs +1225 -0
- package/.output/server/_libs/tiny-invariant.mjs +12 -0
- package/.output/server/_libs/tiny-warning.mjs +5 -0
- package/.output/server/_libs/trim-lines.mjs +41 -0
- package/.output/server/_libs/trough.mjs +85 -0
- package/.output/server/_libs/tslib.mjs +576 -0
- package/.output/server/_libs/ufo.mjs +54 -0
- package/.output/server/_libs/uint8array-extras.mjs +69 -0
- package/.output/server/_libs/unctx.mjs +1 -0
- package/.output/server/_libs/ungap__structured-clone.mjs +212 -0
- package/.output/server/_libs/unified.mjs +661 -0
- package/.output/server/_libs/unist-util-is.mjs +100 -0
- package/.output/server/_libs/unist-util-position.mjs +27 -0
- package/.output/server/_libs/unist-util-stringify-position.mjs +27 -0
- package/.output/server/_libs/unist-util-visit-parents.mjs +82 -0
- package/.output/server/_libs/unist-util-visit.mjs +24 -0
- package/.output/server/_libs/unstorage.mjs +1 -0
- package/.output/server/_libs/use-callback-ref.mjs +66 -0
- package/.output/server/_libs/use-sidecar.mjs +106 -0
- package/.output/server/_libs/use-sync-external-store.mjs +1 -0
- package/.output/server/_libs/util-deprecate.mjs +12 -0
- package/.output/server/_libs/vfile-message.mjs +138 -0
- package/.output/server/_libs/vfile.mjs +467 -0
- package/.output/server/_libs/when-exit.mjs +53 -0
- package/.output/server/_libs/zod.mjs +4460 -0
- package/.output/server/_ssr/index-ByCLZu7J.mjs +3061 -0
- package/.output/server/_ssr/index.mjs +1176 -0
- package/.output/server/_ssr/router-Bq_mxeNz.mjs +2872 -0
- package/.output/server/_ssr/start-HYkvq4Ni.mjs +4 -0
- package/.output/server/_tanstack-start-manifest_v-C4E0e9my.mjs +4 -0
- package/.output/server/index.mjs +393 -0
- package/README.md +196 -0
- package/package.json +91 -0
- package/src/assets/logos/alibaba.svg +1 -0
- package/src/assets/logos/anthropic.svg +1 -0
- package/src/assets/logos/deepseek.svg +1 -0
- package/src/assets/logos/minimax.jpeg +0 -0
- package/src/assets/logos/openai.svg +1 -0
- package/src/assets/logos/qwen.png +0 -0
- package/src/assets/logos/zhipuai.svg +219 -0
- package/src/cli.ts +68 -0
- package/src/components/ProxyViewer.tsx +325 -0
- package/src/components/ProxyViewerContainer.tsx +211 -0
- package/src/components/providers/ProviderCard.tsx +186 -0
- package/src/components/providers/ProviderForm.tsx +259 -0
- package/src/components/providers/ProviderLogo.tsx +111 -0
- package/src/components/providers/ProvidersPanel.tsx +259 -0
- package/src/components/providers/SettingsDialog.tsx +39 -0
- package/src/components/proxy-viewer/ConversationGroup.tsx +68 -0
- package/src/components/proxy-viewer/ConversationHeader.tsx +141 -0
- package/src/components/proxy-viewer/LogEntry.tsx +225 -0
- package/src/components/proxy-viewer/LogEntryHeader.tsx +250 -0
- package/src/components/proxy-viewer/ReplayDialog.tsx +208 -0
- package/src/components/proxy-viewer/ResponseView.tsx +161 -0
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +171 -0
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +139 -0
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +64 -0
- package/src/components/proxy-viewer/formats/index.tsx +24 -0
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +80 -0
- package/src/components/proxy-viewer/index.ts +8 -0
- package/src/components/ui/badge.tsx +47 -0
- package/src/components/ui/button.tsx +47 -0
- package/src/components/ui/collapsible.tsx +21 -0
- package/src/components/ui/dialog.tsx +129 -0
- package/src/components/ui/json-viewer.tsx +464 -0
- package/src/components/ui/scroll-area.tsx +54 -0
- package/src/components/ui/select.tsx +178 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/tabs.tsx +88 -0
- package/src/components/ui/tooltip.tsx +51 -0
- package/src/index.css +11 -0
- package/src/lib/export-logs.ts +51 -0
- package/src/lib/utils.ts +22 -0
- package/src/proxy/chunkStorage.ts +118 -0
- package/src/proxy/constants.ts +36 -0
- package/src/proxy/formats/anthropic/anthropicProvider.ts +75 -0
- package/src/proxy/formats/anthropic/handler.ts +74 -0
- package/src/proxy/formats/anthropic/index.ts +14 -0
- package/src/proxy/formats/anthropic/register.ts +4 -0
- package/src/proxy/formats/anthropic/schemas.ts +217 -0
- package/src/proxy/formats/anthropic/stream.ts +167 -0
- package/src/proxy/formats/handler.ts +46 -0
- package/src/proxy/formats/index.ts +12 -0
- package/src/proxy/formats/jsonSchema.ts +24 -0
- package/src/proxy/formats/openai/alibabaProvider.ts +38 -0
- package/src/proxy/formats/openai/handler.ts +70 -0
- package/src/proxy/formats/openai/index.ts +25 -0
- package/src/proxy/formats/openai/provider.ts +50 -0
- package/src/proxy/formats/openai/register.ts +4 -0
- package/src/proxy/formats/openai/schemas.ts +150 -0
- package/src/proxy/formats/openai/stream.ts +153 -0
- package/src/proxy/formats/protocol.ts +50 -0
- package/src/proxy/formats/providerRegistry.ts +51 -0
- package/src/proxy/formats/providers/index.ts +3 -0
- package/src/proxy/formats/registry.ts +61 -0
- package/src/proxy/handler.ts +389 -0
- package/src/proxy/logIndex.ts +187 -0
- package/src/proxy/logger.ts +99 -0
- package/src/proxy/providers.ts +234 -0
- package/src/proxy/schemas.ts +160 -0
- package/src/proxy/socketTracker.ts +158 -0
- package/src/proxy/store.ts +386 -0
- package/src/router.tsx +16 -0
- package/src/routes/__root.tsx +38 -0
- package/src/routes/api/config.paths.ts +14 -0
- package/src/routes/api/health.ts +11 -0
- package/src/routes/api/logs.$id.chunks.ts +36 -0
- package/src/routes/api/logs.$id.replay.ts +262 -0
- package/src/routes/api/logs.$id.ts +22 -0
- package/src/routes/api/logs.stream.ts +64 -0
- package/src/routes/api/logs.ts +30 -0
- package/src/routes/api/models.ts +10 -0
- package/src/routes/api/providers.$providerId.ts +45 -0
- package/src/routes/api/providers.ts +37 -0
- package/src/routes/api/sessions.ts +10 -0
- package/src/routes/index.tsx +6 -0
- package/src/routes/proxy/$.ts +15 -0
- package/styles/globals.css +121 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const tsrStartManifest = () => ({ "routes": { "__root__": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/__root.tsx", "children": ["/", "/api/health", "/api/logs", "/api/models", "/api/providers", "/api/sessions", "/proxy/$", "/api/config/paths"], "preloads": ["/assets/main-Cp8AM0Pa.js"], "assets": [] }, "/": { "filePath": "C:/Users/claw/workspace/llm-inspector/src/routes/index.tsx", "assets": [], "preloads": ["/assets/index-s4lwsWvq.js"] }, "/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/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/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" }, "/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/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" } }, "clientEntry": "/assets/main-Cp8AM0Pa.js" });
|
|
2
|
+
export {
|
|
3
|
+
tsrStartManifest
|
|
4
|
+
};
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
globalThis.__nitro_main__ = import.meta.url;
|
|
2
|
+
import { a as FastResponse, s as serve } from "./_libs/srvx.mjs";
|
|
3
|
+
import { d as defineHandler, H as HTTPError, t as toEventHandler, a as defineLazyEventHandler, b as H3Core } from "./_libs/h3.mjs";
|
|
4
|
+
import { d as decodePath, w as withLeadingSlash, a as withoutTrailingSlash, j as joinURL } from "./_libs/ufo.mjs";
|
|
5
|
+
import { promises } from "node:fs";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { dirname, resolve } from "node:path";
|
|
8
|
+
import "./_libs/rou3.mjs";
|
|
9
|
+
function lazyService(loader) {
|
|
10
|
+
let promise, mod;
|
|
11
|
+
return {
|
|
12
|
+
fetch(req) {
|
|
13
|
+
if (mod) {
|
|
14
|
+
return mod.fetch(req);
|
|
15
|
+
}
|
|
16
|
+
if (!promise) {
|
|
17
|
+
promise = loader().then((_mod) => mod = _mod.default || _mod);
|
|
18
|
+
}
|
|
19
|
+
return promise.then((mod2) => mod2.fetch(req));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const services = {
|
|
24
|
+
["ssr"]: lazyService(() => import("./_ssr/index.mjs"))
|
|
25
|
+
};
|
|
26
|
+
globalThis.__nitro_vite_envs__ = services;
|
|
27
|
+
const errorHandler$1 = (error, event) => {
|
|
28
|
+
const res = defaultHandler(error, event);
|
|
29
|
+
return new FastResponse(typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2), res);
|
|
30
|
+
};
|
|
31
|
+
function defaultHandler(error, event, opts) {
|
|
32
|
+
const isSensitive = error.unhandled;
|
|
33
|
+
const status = error.status || 500;
|
|
34
|
+
const url = event.url || new URL(event.req.url);
|
|
35
|
+
if (status === 404) {
|
|
36
|
+
const baseURL = "/";
|
|
37
|
+
if (/^\/[^/]/.test(baseURL) && !url.pathname.startsWith(baseURL)) {
|
|
38
|
+
const redirectTo = `${baseURL}${url.pathname.slice(1)}${url.search}`;
|
|
39
|
+
return {
|
|
40
|
+
status: 302,
|
|
41
|
+
statusText: "Found",
|
|
42
|
+
headers: { location: redirectTo },
|
|
43
|
+
body: `Redirecting...`
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (isSensitive && !opts?.silent) {
|
|
48
|
+
const tags = [error.unhandled && "[unhandled]"].filter(Boolean).join(" ");
|
|
49
|
+
console.error(`[request error] ${tags} [${event.req.method}] ${url}
|
|
50
|
+
`, error);
|
|
51
|
+
}
|
|
52
|
+
const headers2 = {
|
|
53
|
+
"content-type": "application/json",
|
|
54
|
+
"x-content-type-options": "nosniff",
|
|
55
|
+
"x-frame-options": "DENY",
|
|
56
|
+
"referrer-policy": "no-referrer",
|
|
57
|
+
"content-security-policy": "script-src 'none'; frame-ancestors 'none';"
|
|
58
|
+
};
|
|
59
|
+
if (status === 404 || !event.res.headers.has("cache-control")) {
|
|
60
|
+
headers2["cache-control"] = "no-cache";
|
|
61
|
+
}
|
|
62
|
+
const body = {
|
|
63
|
+
error: true,
|
|
64
|
+
url: url.href,
|
|
65
|
+
status,
|
|
66
|
+
statusText: error.statusText,
|
|
67
|
+
message: isSensitive ? "Server Error" : error.message,
|
|
68
|
+
data: isSensitive ? void 0 : error.data
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
status,
|
|
72
|
+
statusText: error.statusText,
|
|
73
|
+
headers: headers2,
|
|
74
|
+
body
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const errorHandlers = [errorHandler$1];
|
|
78
|
+
async function errorHandler(error, event) {
|
|
79
|
+
for (const handler of errorHandlers) {
|
|
80
|
+
try {
|
|
81
|
+
const response = await handler(error, event, { defaultHandler });
|
|
82
|
+
if (response) {
|
|
83
|
+
return response;
|
|
84
|
+
}
|
|
85
|
+
} catch (error2) {
|
|
86
|
+
console.error(error2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const headers = ((m) => function headersRouteRule(event) {
|
|
91
|
+
for (const [key2, value] of Object.entries(m.options || {})) {
|
|
92
|
+
event.res.headers.set(key2, value);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const assets = {
|
|
96
|
+
"/assets/alibaba-TTwafVwX.svg": {
|
|
97
|
+
"type": "image/svg+xml",
|
|
98
|
+
"etag": '"171b-6dyV5K8QjiaY35sN9qNprh9zDIs"',
|
|
99
|
+
"mtime": "2026-06-03T06:11:11.193Z",
|
|
100
|
+
"size": 5915,
|
|
101
|
+
"path": "../public/assets/alibaba-TTwafVwX.svg"
|
|
102
|
+
},
|
|
103
|
+
"/assets/index-B3RwBPLW.css": {
|
|
104
|
+
"type": "text/css; charset=utf-8",
|
|
105
|
+
"etag": '"10c74-aXacU4DRFVsUwcC5jHnjoPRSlTA"',
|
|
106
|
+
"mtime": "2026-06-03T06:11:11.195Z",
|
|
107
|
+
"size": 68724,
|
|
108
|
+
"path": "../public/assets/index-B3RwBPLW.css"
|
|
109
|
+
},
|
|
110
|
+
"/assets/minimax-BPMzvuL-.jpeg": {
|
|
111
|
+
"type": "image/jpeg",
|
|
112
|
+
"etag": '"1b06-IwivU89ko5UTMUM1/t7hn4sQK9A"',
|
|
113
|
+
"mtime": "2026-06-03T06:11:11.192Z",
|
|
114
|
+
"size": 6918,
|
|
115
|
+
"path": "../public/assets/minimax-BPMzvuL-.jpeg"
|
|
116
|
+
},
|
|
117
|
+
"/assets/zhipuai-BPNAnxo-.svg": {
|
|
118
|
+
"type": "image/svg+xml",
|
|
119
|
+
"etag": '"2bf8-hNaLCTi89nOFCsIIfWpP/jrfo0s"',
|
|
120
|
+
"mtime": "2026-06-03T06:11:11.193Z",
|
|
121
|
+
"size": 11256,
|
|
122
|
+
"path": "../public/assets/zhipuai-BPNAnxo-.svg"
|
|
123
|
+
},
|
|
124
|
+
"/assets/main-Cp8AM0Pa.js": {
|
|
125
|
+
"type": "text/javascript; charset=utf-8",
|
|
126
|
+
"etag": '"4db57-FpqlPRLq9OHoaAFCL2NIXtZbW5c"',
|
|
127
|
+
"mtime": "2026-06-03T06:11:11.193Z",
|
|
128
|
+
"size": 318295,
|
|
129
|
+
"path": "../public/assets/main-Cp8AM0Pa.js"
|
|
130
|
+
},
|
|
131
|
+
"/assets/qwen-CONDcHqt.png": {
|
|
132
|
+
"type": "image/png",
|
|
133
|
+
"etag": '"572c3-cdJAPaHdOvFCGzuaQjagdgOu6XE"',
|
|
134
|
+
"mtime": "2026-06-03T06:11:11.193Z",
|
|
135
|
+
"size": 357059,
|
|
136
|
+
"path": "../public/assets/qwen-CONDcHqt.png"
|
|
137
|
+
},
|
|
138
|
+
"/assets/index-s4lwsWvq.js": {
|
|
139
|
+
"type": "text/javascript; charset=utf-8",
|
|
140
|
+
"etag": '"828c8-LEW/XL92J2/5lU4VKALlH7aVpaA"',
|
|
141
|
+
"mtime": "2026-06-03T06:11:11.193Z",
|
|
142
|
+
"size": 534728,
|
|
143
|
+
"path": "../public/assets/index-s4lwsWvq.js"
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
function readAsset(id) {
|
|
147
|
+
const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__));
|
|
148
|
+
return promises.readFile(resolve(serverDir, assets[id].path));
|
|
149
|
+
}
|
|
150
|
+
const publicAssetBases = {};
|
|
151
|
+
function isPublicAssetURL(id = "") {
|
|
152
|
+
if (assets[id]) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
for (const base in publicAssetBases) {
|
|
156
|
+
if (id.startsWith(base)) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
function getAsset(id) {
|
|
163
|
+
return assets[id];
|
|
164
|
+
}
|
|
165
|
+
const METHODS = /* @__PURE__ */ new Set(["HEAD", "GET"]);
|
|
166
|
+
const EncodingMap = {
|
|
167
|
+
gzip: ".gz",
|
|
168
|
+
br: ".br",
|
|
169
|
+
zstd: ".zst"
|
|
170
|
+
};
|
|
171
|
+
const _zAOcG1 = defineHandler((event) => {
|
|
172
|
+
if (event.req.method && !METHODS.has(event.req.method)) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
let id = decodePath(withLeadingSlash(withoutTrailingSlash(event.url.pathname)));
|
|
176
|
+
let asset;
|
|
177
|
+
const encodingHeader = event.req.headers.get("accept-encoding") || "";
|
|
178
|
+
const encodings = [...encodingHeader.split(",").map((e) => EncodingMap[e.trim()]).filter(Boolean).sort(), ""];
|
|
179
|
+
if (encodings.length > 1) {
|
|
180
|
+
event.res.headers.append("Vary", "Accept-Encoding");
|
|
181
|
+
}
|
|
182
|
+
for (const encoding of encodings) {
|
|
183
|
+
for (const _id of [id + encoding, joinURL(id, "index.html" + encoding)]) {
|
|
184
|
+
const _asset = getAsset(_id);
|
|
185
|
+
if (_asset) {
|
|
186
|
+
asset = _asset;
|
|
187
|
+
id = _id;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (!asset) {
|
|
193
|
+
if (isPublicAssetURL(id)) {
|
|
194
|
+
event.res.headers.delete("Cache-Control");
|
|
195
|
+
throw new HTTPError({ status: 404 });
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const ifNotMatch = event.req.headers.get("if-none-match") === asset.etag;
|
|
200
|
+
if (ifNotMatch) {
|
|
201
|
+
event.res.status = 304;
|
|
202
|
+
event.res.statusText = "Not Modified";
|
|
203
|
+
return "";
|
|
204
|
+
}
|
|
205
|
+
const ifModifiedSinceH = event.req.headers.get("if-modified-since");
|
|
206
|
+
const mtimeDate = new Date(asset.mtime);
|
|
207
|
+
if (ifModifiedSinceH && asset.mtime && new Date(ifModifiedSinceH) >= mtimeDate) {
|
|
208
|
+
event.res.status = 304;
|
|
209
|
+
event.res.statusText = "Not Modified";
|
|
210
|
+
return "";
|
|
211
|
+
}
|
|
212
|
+
if (asset.type) {
|
|
213
|
+
event.res.headers.set("Content-Type", asset.type);
|
|
214
|
+
}
|
|
215
|
+
if (asset.etag && !event.res.headers.has("ETag")) {
|
|
216
|
+
event.res.headers.set("ETag", asset.etag);
|
|
217
|
+
}
|
|
218
|
+
if (asset.mtime && !event.res.headers.has("Last-Modified")) {
|
|
219
|
+
event.res.headers.set("Last-Modified", mtimeDate.toUTCString());
|
|
220
|
+
}
|
|
221
|
+
if (asset.encoding && !event.res.headers.has("Content-Encoding")) {
|
|
222
|
+
event.res.headers.set("Content-Encoding", asset.encoding);
|
|
223
|
+
}
|
|
224
|
+
if (asset.size > 0 && !event.res.headers.has("Content-Length")) {
|
|
225
|
+
event.res.headers.set("Content-Length", asset.size.toString());
|
|
226
|
+
}
|
|
227
|
+
return readAsset(id);
|
|
228
|
+
});
|
|
229
|
+
const findRouteRules = /* @__PURE__ */ (() => {
|
|
230
|
+
const $0 = [{ name: "headers", route: "/assets/**", handler: headers, options: { "cache-control": "public, max-age=31536000, immutable" } }];
|
|
231
|
+
return (m, p) => {
|
|
232
|
+
let r = [];
|
|
233
|
+
if (p.charCodeAt(p.length - 1) === 47) p = p.slice(0, -1) || "/";
|
|
234
|
+
let s = p.split("/");
|
|
235
|
+
s.length - 1;
|
|
236
|
+
if (s[1] === "assets") {
|
|
237
|
+
r.unshift({ data: $0, params: { "_": s.slice(2).join("/") } });
|
|
238
|
+
}
|
|
239
|
+
return r;
|
|
240
|
+
};
|
|
241
|
+
})();
|
|
242
|
+
const _lazy_oesjP1 = defineLazyEventHandler(() => import("./_chunks/ssr-renderer.mjs"));
|
|
243
|
+
const findRoute = /* @__PURE__ */ (() => {
|
|
244
|
+
const data = { route: "/**", handler: _lazy_oesjP1 };
|
|
245
|
+
return ((_m, p) => {
|
|
246
|
+
return { data, params: { "_": p.slice(1) } };
|
|
247
|
+
});
|
|
248
|
+
})();
|
|
249
|
+
const globalMiddleware = [
|
|
250
|
+
toEventHandler(_zAOcG1)
|
|
251
|
+
].filter(Boolean);
|
|
252
|
+
const APP_ID = "default";
|
|
253
|
+
function useNitroApp() {
|
|
254
|
+
let instance = useNitroApp._instance;
|
|
255
|
+
if (instance) {
|
|
256
|
+
return instance;
|
|
257
|
+
}
|
|
258
|
+
instance = useNitroApp._instance = createNitroApp();
|
|
259
|
+
globalThis.__nitro__ = globalThis.__nitro__ || {};
|
|
260
|
+
globalThis.__nitro__[APP_ID] = instance;
|
|
261
|
+
return instance;
|
|
262
|
+
}
|
|
263
|
+
function createNitroApp() {
|
|
264
|
+
const hooks = void 0;
|
|
265
|
+
const captureError = (error, errorCtx) => {
|
|
266
|
+
if (errorCtx?.event) {
|
|
267
|
+
const errors = errorCtx.event.req.context?.nitro?.errors;
|
|
268
|
+
if (errors) {
|
|
269
|
+
errors.push({
|
|
270
|
+
error,
|
|
271
|
+
context: errorCtx
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
const h3App = createH3App({ onError(error, event) {
|
|
277
|
+
return errorHandler(error, event);
|
|
278
|
+
} });
|
|
279
|
+
let appHandler = (req) => {
|
|
280
|
+
req.context ||= {};
|
|
281
|
+
req.context.nitro = req.context.nitro || { errors: [] };
|
|
282
|
+
return h3App.fetch(req);
|
|
283
|
+
};
|
|
284
|
+
const app = {
|
|
285
|
+
fetch: appHandler,
|
|
286
|
+
h3: h3App,
|
|
287
|
+
hooks,
|
|
288
|
+
captureError
|
|
289
|
+
};
|
|
290
|
+
return app;
|
|
291
|
+
}
|
|
292
|
+
function createH3App(config) {
|
|
293
|
+
const h3App = new H3Core(config);
|
|
294
|
+
h3App["~findRoute"] = (event) => findRoute(event.req.method, event.url.pathname);
|
|
295
|
+
h3App["~middleware"].push(...globalMiddleware);
|
|
296
|
+
{
|
|
297
|
+
h3App["~getMiddleware"] = (event, route) => {
|
|
298
|
+
const pathname = event.url.pathname;
|
|
299
|
+
const method = event.req.method;
|
|
300
|
+
const middleware = [];
|
|
301
|
+
{
|
|
302
|
+
const routeRules = getRouteRules(method, pathname);
|
|
303
|
+
event.context.routeRules = routeRules?.routeRules;
|
|
304
|
+
if (routeRules?.routeRuleMiddleware.length) {
|
|
305
|
+
middleware.push(...routeRules.routeRuleMiddleware);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
middleware.push(...h3App["~middleware"]);
|
|
309
|
+
if (route?.data?.middleware?.length) {
|
|
310
|
+
middleware.push(...route.data.middleware);
|
|
311
|
+
}
|
|
312
|
+
return middleware;
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
return h3App;
|
|
316
|
+
}
|
|
317
|
+
function getRouteRules(method, pathname) {
|
|
318
|
+
const m = findRouteRules(method, pathname);
|
|
319
|
+
if (!m?.length) {
|
|
320
|
+
return { routeRuleMiddleware: [] };
|
|
321
|
+
}
|
|
322
|
+
const routeRules = {};
|
|
323
|
+
for (const layer of m) {
|
|
324
|
+
for (const rule of layer.data) {
|
|
325
|
+
const currentRule = routeRules[rule.name];
|
|
326
|
+
if (currentRule) {
|
|
327
|
+
if (rule.options === false) {
|
|
328
|
+
delete routeRules[rule.name];
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (typeof currentRule.options === "object" && typeof rule.options === "object") {
|
|
332
|
+
currentRule.options = {
|
|
333
|
+
...currentRule.options,
|
|
334
|
+
...rule.options
|
|
335
|
+
};
|
|
336
|
+
} else {
|
|
337
|
+
currentRule.options = rule.options;
|
|
338
|
+
}
|
|
339
|
+
currentRule.route = rule.route;
|
|
340
|
+
currentRule.params = {
|
|
341
|
+
...currentRule.params,
|
|
342
|
+
...layer.params
|
|
343
|
+
};
|
|
344
|
+
} else if (rule.options !== false) {
|
|
345
|
+
routeRules[rule.name] = {
|
|
346
|
+
...rule,
|
|
347
|
+
params: layer.params
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const middleware = [];
|
|
353
|
+
for (const rule of Object.values(routeRules)) {
|
|
354
|
+
if (rule.options === false || !rule.handler) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
middleware.push(rule.handler(rule));
|
|
358
|
+
}
|
|
359
|
+
return {
|
|
360
|
+
routeRules,
|
|
361
|
+
routeRuleMiddleware: middleware
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function _captureError(error, type) {
|
|
365
|
+
console.error(`[${type}]`, error);
|
|
366
|
+
useNitroApp().captureError?.(error, { tags: [type] });
|
|
367
|
+
}
|
|
368
|
+
function trapUnhandledErrors() {
|
|
369
|
+
process.on("unhandledRejection", (error) => _captureError(error, "unhandledRejection"));
|
|
370
|
+
process.on("uncaughtException", (error) => _captureError(error, "uncaughtException"));
|
|
371
|
+
}
|
|
372
|
+
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
373
|
+
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
374
|
+
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
375
|
+
const cert = process.env.NITRO_SSL_CERT;
|
|
376
|
+
const key = process.env.NITRO_SSL_KEY;
|
|
377
|
+
const nitroApp = useNitroApp();
|
|
378
|
+
let _fetch = nitroApp.fetch;
|
|
379
|
+
serve({
|
|
380
|
+
port,
|
|
381
|
+
hostname: host,
|
|
382
|
+
tls: cert && key ? {
|
|
383
|
+
cert,
|
|
384
|
+
key
|
|
385
|
+
} : void 0,
|
|
386
|
+
fetch: _fetch,
|
|
387
|
+
bun: { websocket: void 0 }
|
|
388
|
+
});
|
|
389
|
+
trapUnhandledErrors();
|
|
390
|
+
const bun = {};
|
|
391
|
+
export {
|
|
392
|
+
bun as default
|
|
393
|
+
};
|
package/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# llm-inspector
|
|
2
|
+
|
|
3
|
+
> LLM API 透明代理调试器 / Transparent LLM API proxy inspector
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
llm-inspector 是一个 LLM API 透明代理,能够捕获 AI 编程工具(Claude Code、OpenCode、Cody、Cursor 等)与 LLM 提供商之间的每一次请求和响应,在 Web UI 中实时展示系统提示词、工具定义、消息内容、SSE 流式数据块和 Token 用量。
|
|
8
|
+
|
|
9
|
+
**专为理解 AI 编程工具底层 API 调用而设计。**
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 核心特性 / Features
|
|
14
|
+
|
|
15
|
+
### 支持多种 AI 编程工具 / Multiple AI Coding Tools
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Claude Code
|
|
19
|
+
ANTHROPIC_BASE_URL=http://localhost:25947/proxy claude
|
|
20
|
+
|
|
21
|
+
# OpenCode
|
|
22
|
+
LLM_BASE_URL=http://localhost:25947/proxy opencode
|
|
23
|
+
|
|
24
|
+
# Cursor, Cody 等 / etc.
|
|
25
|
+
ANTHROPIC_BASE_URL=http://localhost:25947/proxy <your-tool>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 支持双 API 格式 / Dual API Format Support
|
|
29
|
+
|
|
30
|
+
| API 格式 | 端点 | 工具 |
|
|
31
|
+
|----------|------|------|
|
|
32
|
+
| Anthropic | `/v1/messages` | Claude Code 等 |
|
|
33
|
+
| OpenAI | `/v1/chat/completions` | OpenAI、DeepSeek 等 |
|
|
34
|
+
|
|
35
|
+
### 多 LLM 提供商支持 / Multi-Provider Support
|
|
36
|
+
|
|
37
|
+
| 提供商 | 模型前缀 | API 格式 |
|
|
38
|
+
|--------|---------|----------|
|
|
39
|
+
| Anthropic | `claude-*` | Anthropic |
|
|
40
|
+
| OpenAI | `gpt-*`, `o1-*`, `o3-*` | OpenAI |
|
|
41
|
+
| DeepSeek | `deepseek-*` | OpenAI |
|
|
42
|
+
| MiniMax | `MiniMax-*` | Anthropic/OpenAI |
|
|
43
|
+
| Qwen | `qwen-*` | OpenAI |
|
|
44
|
+
| ZhipuAI | `glm-*` | OpenAI |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 快速开始 / Quick Start
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# 安装依赖
|
|
52
|
+
bun install
|
|
53
|
+
|
|
54
|
+
# 启动开发服务器
|
|
55
|
+
bun run dev
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
设置环境变量并启动 AI 编程工具:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Claude Code
|
|
62
|
+
ANTHROPIC_BASE_URL=http://localhost:25947/proxy claude
|
|
63
|
+
|
|
64
|
+
# OpenCode
|
|
65
|
+
LLM_BASE_URL=http://localhost:25947/proxy opencode
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
打开浏览器访问 http://localhost:25947 查看实时捕获的请求。
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 实时仪表盘 / Real-Time Dashboard
|
|
75
|
+
|
|
76
|
+
### 日志列表 / Log List
|
|
77
|
+
|
|
78
|
+
虚拟滚动列表展示每个被代理的请求,每条记录显示:
|
|
79
|
+
|
|
80
|
+
- **模型标签** — 如 `claude-sonnet-4-20250514`
|
|
81
|
+
- **API 格式** — Anthropic(橙色)/ OpenAI(蓝色)
|
|
82
|
+
- **响应状态** — 绿色 2xx / 黄色 4xx / 红色 5xx
|
|
83
|
+
- **Token 用量** — 输入 / 输出,自动 K/M 格式化
|
|
84
|
+
- **流式标识** — 区分流式与非流式响应
|
|
85
|
+
|
|
86
|
+
### 解析响应视图 / Parsed Response View
|
|
87
|
+
|
|
88
|
+
**Anthropic 响应:**
|
|
89
|
+
- 模型、停止原因、Token 用量
|
|
90
|
+
- 内容块分类渲染:文本(Markdown)、思考(可折叠紫色块)、工具调用(可折叠蓝色块)
|
|
91
|
+
|
|
92
|
+
**OpenAI 响应:**
|
|
93
|
+
- 模型、结束原因、Token 用量
|
|
94
|
+
- 推理内容(紫色块)、文本、函数调用
|
|
95
|
+
|
|
96
|
+
### SSE 流式数据 / SSE Streaming
|
|
97
|
+
|
|
98
|
+

|
|
99
|
+
|
|
100
|
+
流式响应显示:
|
|
101
|
+
- **SSE 数据块面板** — 懒加载,按索引分组
|
|
102
|
+
- **JSON 树查看器** — 类型颜色编码(字符串绿/数字黄/布尔蓝)
|
|
103
|
+
- **重建响应** — 从 SSE 片段重建完整 JSON
|
|
104
|
+
|
|
105
|
+
### 提供商测试 / Provider Testing
|
|
106
|
+
|
|
107
|
+

|
|
108
|
+
|
|
109
|
+
内置连接测试功能,同时测试非流式和流式连接,测试结果直接显示在日志列表中。
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 架构 / Architecture
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
AI Coding Tool → llm-inspector (:25947/proxy/*) → LLM Provider
|
|
117
|
+
↓
|
|
118
|
+
Web UI (:25947)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
| 模块 | 路径 | 职责 |
|
|
122
|
+
|------|------|------|
|
|
123
|
+
| 代理处理器 | `src/proxy/handler.ts` | HTTP 代理、请求/响应捕获、SSE 流式 |
|
|
124
|
+
| 格式处理器 | `src/proxy/formats/` | Anthropic/OpenAI 格式抽象 |
|
|
125
|
+
| 提供商管理 | `src/proxy/providers.ts` | 多提供商配置存储 |
|
|
126
|
+
| 格式协议 | `src/proxy/formats/anthropic/` `src/proxy/formats/openai/` | 格式特定解析器 |
|
|
127
|
+
| 客户端追踪 | `src/proxy/socketTracker.ts` | PID、CWD、项目名 |
|
|
128
|
+
| 日志存储 | `src/proxy/logger.ts`, `store.ts` | 内存缓冲区 + 磁盘持久化 |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 命令行 / CLI
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
llm-inspector [--port <端口>] [--open|--no-open]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
| 参数 | 默认值 | 说明 |
|
|
139
|
+
|------|--------|------|
|
|
140
|
+
| `--port`, `-p` | `25947` | 监听端口 |
|
|
141
|
+
| `--open` | `true` | 启动时自动打开浏览器 |
|
|
142
|
+
|
|
143
|
+
### 环境变量
|
|
144
|
+
|
|
145
|
+
| 变量 | 默认值 | 说明 |
|
|
146
|
+
|------|--------|------|
|
|
147
|
+
| `PORT` | `25947` | 服务器端口 |
|
|
148
|
+
| `LOG_DIR` | `~/.llm-inspector/logs/` | 日志存储目录 |
|
|
149
|
+
| `LOG_RETENTION_DAYS` | `7` | 日志保留天数 |
|
|
150
|
+
| `CHUNKS_DIR` | `~/.llm-inspector/chunks/` | SSE 数据块存储 |
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 直接测试 / Direct Testing
|
|
155
|
+
|
|
156
|
+
不通过 AI 编程工具,直接用 curl 测试提供商连接:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Anthropic
|
|
160
|
+
curl http://localhost:25947/proxy/v1/messages \
|
|
161
|
+
-H 'content-type: application/json' \
|
|
162
|
+
-d '{"model":"claude-sonnet-4-20250514","max_tokens":100,"messages":[{"role":"user","content":"hello"}]}'
|
|
163
|
+
|
|
164
|
+
# OpenAI
|
|
165
|
+
curl http://localhost:25947/proxy/v1/chat/completions \
|
|
166
|
+
-H 'content-type: application/json' \
|
|
167
|
+
-d '{"model":"gpt-4o-mini","max_tokens":100,"messages":[{"role":"user","content":"hello"}]}'
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 开发 / Development
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# 类型检查、Lint、格式化
|
|
176
|
+
bun run check
|
|
177
|
+
|
|
178
|
+
# 生产构建
|
|
179
|
+
bun run build
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 发布 / Publishing
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# 1. 更新版本号
|
|
188
|
+
git commit -m "chore: bump version"
|
|
189
|
+
git tag v<version>
|
|
190
|
+
|
|
191
|
+
# 2. 推送代码和标签
|
|
192
|
+
git push origin main --tags
|
|
193
|
+
|
|
194
|
+
# 3. 发布到 npm
|
|
195
|
+
npm publish --access public --provenance
|
|
196
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tonyclaw/llm-inspector",
|
|
3
|
+
"version": "1.6.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "LLM API proxy inspector — captures and displays requests/responses from AI coding tools in a web UI",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"claude",
|
|
12
|
+
"anthropic",
|
|
13
|
+
"openai",
|
|
14
|
+
"proxy",
|
|
15
|
+
"api-inspector",
|
|
16
|
+
"debugging",
|
|
17
|
+
"llm",
|
|
18
|
+
"ai-coding-tools"
|
|
19
|
+
],
|
|
20
|
+
"bin": {
|
|
21
|
+
"llm-inspector": "src/cli.ts"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"src",
|
|
25
|
+
"!src/**/*.test.ts",
|
|
26
|
+
"!src/**/*.stories.tsx",
|
|
27
|
+
"!src/**/__fixtures__",
|
|
28
|
+
"!src/routeTree.gen.ts",
|
|
29
|
+
"styles",
|
|
30
|
+
".output"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "vite dev",
|
|
34
|
+
"start": "bun src/cli.ts",
|
|
35
|
+
"build": "vite build",
|
|
36
|
+
"prepublishOnly": "bun run build",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"lint": "eslint .",
|
|
39
|
+
"format": "biome format --write .",
|
|
40
|
+
"format:check": "biome format .",
|
|
41
|
+
"knip": "knip",
|
|
42
|
+
"check": "bun format && bun typecheck && bun lint && bun knip",
|
|
43
|
+
"prepare": "husky",
|
|
44
|
+
"ladle": "ladle serve",
|
|
45
|
+
"ladle:build": "ladle build"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@radix-ui/react-dialog": "^1.1.14",
|
|
49
|
+
"@radix-ui/react-select": "^2.2.6",
|
|
50
|
+
"@tailwindcss/typography": "^0.5.19",
|
|
51
|
+
"@tanstack/react-router": "^1.160.2",
|
|
52
|
+
"@tanstack/react-start": "^1.161.0",
|
|
53
|
+
"@tanstack/react-virtual": "^3.13.26",
|
|
54
|
+
"class-variance-authority": "^0.7.1",
|
|
55
|
+
"cleye": "^2.2.1",
|
|
56
|
+
"clsx": "^2.1.1",
|
|
57
|
+
"conf": "^15.1.0",
|
|
58
|
+
"jszip": "^3.10.1",
|
|
59
|
+
"lucide-react": "^0.563.0",
|
|
60
|
+
"radix-ui": "^1.4.3",
|
|
61
|
+
"react": "^19",
|
|
62
|
+
"react-dom": "^19",
|
|
63
|
+
"react-markdown": "^10.1.0",
|
|
64
|
+
"tailwind-merge": "^3.4.0",
|
|
65
|
+
"tw-animate-css": "^1.4.0",
|
|
66
|
+
"zod": "^4.3.6"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@biomejs/biome": "^2.3.14",
|
|
70
|
+
"@eslint/js": "^10.0.1",
|
|
71
|
+
"@ladle/react": "^5.1.1",
|
|
72
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
73
|
+
"@types/bun": "latest",
|
|
74
|
+
"@types/react": "^19",
|
|
75
|
+
"@types/react-dom": "^19",
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
77
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
78
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
79
|
+
"eslint": "^9.32.0",
|
|
80
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
81
|
+
"eslint-plugin-functional": "^9.0.2",
|
|
82
|
+
"eslint-plugin-unicorn": "^63.0.0",
|
|
83
|
+
"husky": "^9.1.7",
|
|
84
|
+
"knip": "^5.83.1",
|
|
85
|
+
"nitro": "^3.0.1-20260217-092337-b28fa21a",
|
|
86
|
+
"tailwindcss": "^4.1.11",
|
|
87
|
+
"typescript": "^5.9.3",
|
|
88
|
+
"vite": "^7.3.1",
|
|
89
|
+
"vite-tsconfig-paths": "^6.1.1"
|
|
90
|
+
}
|
|
91
|
+
}
|