@tonyclaw/llm-inspector 1.18.2 → 1.19.1

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 (42) hide show
  1. package/.output/cli.js +903 -139
  2. package/.output/nitro.json +1 -1
  3. package/.output/public/assets/{CompareDrawer-C-4ypEWs.js → CompareDrawer-DtERUdIt.js} +1 -1
  4. package/.output/public/assets/ProxyViewerContainer-DfxRK7Nt.js +101 -0
  5. package/.output/public/assets/{ReplayDialog-CyBKOgba.js → ReplayDialog-VMsGnJSI.js} +1 -1
  6. package/.output/public/assets/{RequestAnatomy-C0IrVQ3q.js → RequestAnatomy-Cx_vluvK.js} +1 -1
  7. package/.output/public/assets/{ResponseView-MogToC4i.js → ResponseView-5F8Ms5z4.js} +1 -1
  8. package/.output/public/assets/{StreamingChunkSequence-ClhUhT-s.js → StreamingChunkSequence-CKDCWfu9.js} +1 -1
  9. package/.output/public/assets/_sessionId-C-aKd1Ky.js +1 -0
  10. package/.output/public/assets/index-B8ttyigz.js +1 -0
  11. package/.output/public/assets/index-DeJyypsp.css +1 -0
  12. package/.output/public/assets/{json-viewer-BicGakI5.js → json-viewer-CztuZ9cT.js} +2 -2
  13. package/.output/public/assets/{main-Be2qqUUW.js → main-CR9IJlz1.js} +2 -2
  14. package/.output/server/_libs/lucide-react.mjs +93 -72
  15. package/.output/server/{_sessionId-DhKJIdQC.mjs → _sessionId-DvWQaDEm.mjs} +2 -2
  16. package/.output/server/_ssr/{CompareDrawer-BGUgukJ8.mjs → CompareDrawer-C5FsxSDS.mjs} +4 -4
  17. package/.output/server/_ssr/{ProxyViewerContainer--3K3o3Sm.mjs → ProxyViewerContainer-v0cvR8f5.mjs} +354 -343
  18. package/.output/server/_ssr/{ReplayDialog-Bo86xZI4.mjs → ReplayDialog-C3KOv9OW.mjs} +4 -4
  19. package/.output/server/_ssr/{RequestAnatomy-jRU5qgwB.mjs → RequestAnatomy-BYRe33eG.mjs} +3 -3
  20. package/.output/server/_ssr/{ResponseView-DdO_-79a.mjs → ResponseView-va7yQDeL.mjs} +4 -4
  21. package/.output/server/_ssr/{StreamingChunkSequence-BigLwhh4.mjs → StreamingChunkSequence-BJlI-gWl.mjs} +3 -3
  22. package/.output/server/_ssr/{index-BHG6vOnr.mjs → index-CS0fA2GT.mjs} +2 -2
  23. package/.output/server/_ssr/index.mjs +2 -2
  24. package/.output/server/_ssr/{json-viewer-B4c_WjXD.mjs → json-viewer-Dg8rqrxL.mjs} +9 -5
  25. package/.output/server/_ssr/{router-DVixpJO-.mjs → router-D_Boe9Bu.mjs} +3 -3
  26. package/.output/server/{_tanstack-start-manifest_v-BbvWUF4v.mjs → _tanstack-start-manifest_v-KFXyNRGC.mjs} +1 -1
  27. package/.output/server/index.mjs +65 -65
  28. package/package.json +2 -1
  29. package/src/cli/detect-tools.ts +146 -0
  30. package/src/cli/onboard.ts +229 -0
  31. package/src/cli/templates/command-onboard.ts +17 -0
  32. package/src/cli/templates/skill-onboard.ts +458 -0
  33. package/src/cli.ts +193 -163
  34. package/src/components/ProxyViewer.tsx +153 -142
  35. package/src/components/proxy-viewer/LogEntry.tsx +136 -157
  36. package/src/components/proxy-viewer/LogEntryHeader.tsx +147 -66
  37. package/src/components/proxy-viewer/useCopyFeedback.ts +36 -0
  38. package/src/components/ui/json-viewer.tsx +12 -0
  39. package/.output/public/assets/ProxyViewerContainer-WRenRpeh.js +0 -101
  40. package/.output/public/assets/_sessionId-BO47oA3Z.js +0 -1
  41. package/.output/public/assets/index-BRvz6-L6.css +0 -1
  42. package/.output/public/assets/index-Btw8ec7-.js +0 -1
@@ -0,0 +1,458 @@
1
+ /**
2
+ * Renders `~/.claude/skills/llm-inspector-onboard/SKILL.md` for the
3
+ * `llm-inspector onboard` subcommand. The body is a multi-phase teaching
4
+ * workflow with `EXPLAIN / DO / PAUSE` markers — Claude reads it and walks
5
+ * the user through real actions (start the proxy, hit /api/health, post a
6
+ * test request, poll /api/logs) instead of just printing a static tutorial.
7
+ *
8
+ * The template embeds platform-aware shell snippets inline (bash + PowerShell
9
+ * side-by-side). Skills are pure Markdown — they can't `require()` from the
10
+ * package at runtime, so the duplication is the price of portability.
11
+ *
12
+ * All PowerShell snippets that use `$env:` variables are written so they
13
+ * work when invoked via the Bash tool. The pattern is:
14
+ * powershell -Command '<single-quoted block with $env:LITERAL>'
15
+ * NOT
16
+ * powershell -Command "<double-quoted block with escaped \$env:>"
17
+ * The latter collapses `$env:` to a literal in bash before PowerShell sees
18
+ * it, producing garbled paths. Single-quoted bash arguments pass through
19
+ * to PowerShell unchanged.
20
+ */
21
+
22
+ export type SkillOnboardContext = {
23
+ /** Package version (from `package.json`), stamped into the frontmatter. */
24
+ readonly version: string;
25
+ /** The default proxy port (mirrors `DEFAULT_PORT` in `src/cli.ts`). */
26
+ readonly port: number;
27
+ /**
28
+ * One-line "detected tools" summary written into the Preflight phase so the
29
+ * skill's instructions match the user's actual environment. Empty string
30
+ * means "no known tool detected — fall through to the curl example".
31
+ */
32
+ readonly detectedSummary: string;
33
+ };
34
+
35
+ /** The 9 phase headings the spec requires. The validator checks for these. */
36
+ export const REQUIRED_PHASE_HEADINGS = [
37
+ "Phase 0: Idempotency check",
38
+ "Preflight",
39
+ "Phase 1: Welcome",
40
+ "Phase 2: Provider setup",
41
+ "Phase 3: Start proxy",
42
+ "Phase 4: Wire tool",
43
+ "Phase 4.5: Wire MCP server",
44
+ "Phase 5: First capture",
45
+ "Phase 6: Tour & wrap",
46
+ ] as const;
47
+
48
+ export function renderSkillOnboard(ctx: SkillOnboardContext): string {
49
+ const { version, port, detectedSummary } = ctx;
50
+ return `---
51
+ name: llm-inspector-onboard
52
+ description: Guided setup for llm-inspector v${version} — start the proxy, wire your AI coding tool, capture your first request, and learn the Web UI.
53
+ metadata:
54
+ author: llm-inspector
55
+ version: ${version}
56
+ ---
57
+
58
+ # llm-inspector onboard
59
+
60
+ Guide the user from "I just installed llm-inspector" to "I can see my AI tool's traffic in the Web UI". This is a teaching experience — you'll do real work in their environment while explaining each step.
61
+
62
+ Environment detected by the installer:
63
+ ${detectedSummary || " (no known AI tool detected — the user can still use the generic curl example in Phase 4)"}
64
+
65
+ Default proxy port: \`${port}\` (override with \`PORT=<n> llm-inspector\` or \`--port <n>\`).
66
+
67
+ > **PAUSE protocol.** Every \`**PAUSE**\` marker in this skill is a real stop.
68
+ > Use the \`AskUserQuestion\` tool to actually wait for the user before
69
+ > continuing. Do not stream past a PAUSE based on context — the user has
70
+ > not seen your output yet. Each PAUSE in the body below includes a sample
71
+ > question you can adapt.
72
+
73
+ ---
74
+
75
+ ## Phase 0: Idempotency check
76
+
77
+ **EXPLAIN:** "Before we do anything, let me see what's already set up. If some of the steps are already done, we can skip them."
78
+
79
+ **DO:** Probe the three pieces of state this skill touches. Use targeted checks — do **not** read large JSON files into the conversation.
80
+
81
+ \`\`\`bash
82
+ # 1. Is the proxy already up?
83
+ curl -fsS "http://localhost:${port}/api/health" 2>/dev/null && echo "PROXY: up" || echo "PROXY: down"
84
+
85
+ # 2. Does the config have a real provider key?
86
+ CFG="$HOME/.llm-inspector/config.json"
87
+ if [ -f "$CFG" ]; then
88
+ if grep -qE '"apiKey"[[:space:]]*:[[:space:]]*"(sk-[^"]+|REPLACE|REPLACE_)' "$CFG" 2>/dev/null; then
89
+ echo "CONFIG: has key (no REPLACE placeholder)"
90
+ else
91
+ echo "CONFIG: missing or has placeholder key"
92
+ fi
93
+ else
94
+ echo "CONFIG: file does not exist"
95
+ fi
96
+
97
+ # 3. Is the MCP server already wired? (project .mcp.json wins)
98
+ PROJ_MCP=".mcp.json"
99
+ HOME_MCP="$HOME/.claude.json"
100
+ if [ -f "$PROJ_MCP" ] && grep -q '"llm-inspector"' "$PROJ_MCP"; then
101
+ echo "MCP: wired in $PROJ_MCP"
102
+ elif [ -f "$HOME_MCP" ] && grep -q '"llm-inspector"' "$HOME_MCP"; then
103
+ echo "MCP: wired in $HOME_MCP"
104
+ else
105
+ echo "MCP: not wired"
106
+ fi
107
+ \`\`\`
108
+
109
+ \`\`\`powershell
110
+ # Windows PowerShell — single-quoted so $env: expands correctly
111
+ $port = ${port}
112
+ $cfg = Join-Path $env:USERPROFILE '.llm-inspector/config.json'
113
+
114
+ # 1. Is the proxy already up?
115
+ try {
116
+ $null = Invoke-RestMethod -Uri "http://localhost:$port/api/health" -TimeoutSec 2 -ErrorAction Stop
117
+ Write-Host 'PROXY: up'
118
+ } catch {
119
+ Write-Host 'PROXY: down'
120
+ }
121
+
122
+ # 2. Does the config have a real provider key?
123
+ if (Test-Path $cfg) {
124
+ $content = Get-Content $cfg -Raw
125
+ if ($content -match '"apiKey"[[:space:]]*:[[:space:]]*"(sk-[^"]+)"') {
126
+ Write-Host 'CONFIG: has key'
127
+ } elseif ($content -match 'REPLACE') {
128
+ Write-Host 'CONFIG: has placeholder key'
129
+ } else {
130
+ Write-Host 'CONFIG: missing key'
131
+ }
132
+ } else {
133
+ Write-Host 'CONFIG: file does not exist'
134
+ }
135
+
136
+ # 3. Is the MCP server already wired? (project .mcp.json wins)
137
+ $projMcp = Join-Path (Get-Location) '.mcp.json'
138
+ $homeMcp = Join-Path $env:USERPROFILE '.claude.json'
139
+ if ((Test-Path $projMcp) -and (Select-String -Path $projMcp -Pattern 'llm-inspector' -Quiet)) {
140
+ Write-Host "MCP: wired in $projMcp"
141
+ } elseif ((Test-Path $homeMcp) -and (Select-String -Path $homeMcp -Pattern 'llm-inspector' -Quiet)) {
142
+ Write-Host "MCP: wired in $homeMcp"
143
+ } else {
144
+ Write-Host 'MCP: not wired'
145
+ }
146
+ \`\`\`
147
+
148
+ **DO:** Summarize the three checks in one line, then use \`AskUserQuestion\` to ask whether to skip the corresponding phases.
149
+
150
+ > **PAUSE** — call \`AskUserQuestion\` with:
151
+ > - header: \`Skip done\`
152
+ > - question: \`Proxy/CONFIG/MCP state: <summary>. Skip the phases that are already done?\`
153
+ > - options: \`["Yes, skip what's done", "No, walk me through everything again"]\`
154
+ > Wait for the answer before moving to Preflight.
155
+
156
+ ---
157
+
158
+ ## Preflight
159
+
160
+ **EXPLAIN:** "Quick env sanity check — make sure Node and Claude Code are present."
161
+
162
+ **DO:** Run the platform-appropriate commands below.
163
+
164
+ \`\`\`bash
165
+ # Unix / macOS / WSL
166
+ node --version # expect >= 18
167
+ command -v claude >/dev/null && echo "claude-code: present" || echo "claude-code: not detected"
168
+ \`\`\`
169
+
170
+ \`\`\`powershell
171
+ # Windows PowerShell — single-quoted so $env: expands correctly
172
+ node --version # expect >= 18
173
+ $null = Get-Command claude -ErrorAction SilentlyContinue
174
+ if ($null) { Write-Host 'claude-code: present' } else { Write-Host 'claude-code: not detected' }
175
+ \`\`\`
176
+
177
+ > **PAUSE** — if Node is older than 18, ask the user to install a newer version (https://nodejs.org) before continuing. Use \`AskUserQuestion\` with header \`Node version\`.
178
+
179
+ ---
180
+
181
+ ## Phase 1: Welcome
182
+
183
+ **EXPLAIN:**
184
+
185
+ \`\`\`
186
+ ## Welcome to llm-inspector!
187
+
188
+ llm-inspector is a transparent HTTP proxy + Web UI for AI coding tools. Point your tool at it, and you'll see every request and response — system prompts, tool definitions, message history, SSE streaming chunks, and token counts — captured live in a browser tab.
189
+
190
+ **What we'll do in the next ~10 minutes:**
191
+ 1. Add your first LLM provider (Anthropic or OpenAI key)
192
+ 2. Start the proxy
193
+ 3. Wire your AI tool to use it
194
+ 4. Capture a first request end-to-end
195
+ 5. Tour the key UI affordances
196
+
197
+ Ready? Let's start with the provider.
198
+ \`\`\`
199
+
200
+ > **PAUSE** — use \`AskUserQuestion\` with header \`Ready?\` and options \`["Yes, let's go", "Wait, I have a question"]\`. Wait for the user before continuing.
201
+
202
+ ---
203
+
204
+ ## Phase 2: Provider setup
205
+
206
+ **EXPLAIN:** "A 'provider' is an upstream LLM endpoint — Anthropic, OpenAI, MiniMax, etc. llm-inspector routes each request to the right upstream based on the model name. You need at least one provider configured for the proxy to forward traffic."
207
+
208
+ **DO:** First, re-check whether the config already has a real key (Phase 0 may have raced with a manual edit). Use the same \`grep -qE '"apiKey":"sk-' "$HOME/.llm-inspector/config.json"\` (bash) or \`Select-String\` (PowerShell) check from Phase 0. If a real key is present, skip the rest of this phase.
209
+
210
+ **DO:** If no real key, ask the user for the provider type and API key via \`AskUserQuestion\`. The question should be a free-form text field (no fixed options) — the API key is a secret, so don't echo it back in the question UI.
211
+
212
+ \`\`\`bash
213
+ # After collecting the key, write the config
214
+ mkdir -p "$HOME/.llm-inspector"
215
+ cat > "$HOME/.llm-inspector/config.json" <<'JSON'
216
+ {
217
+ "providers": [
218
+ {
219
+ "id": "anthropic",
220
+ "type": "anthropic",
221
+ "apiKey": "REPLACE_ME_BEFORE_WRITING",
222
+ "baseUrl": "https://api.anthropic.com"
223
+ }
224
+ ]
225
+ }
226
+ JSON
227
+ # Then patch the apiKey with the user-provided value (use jq if available)
228
+ \`\`\`
229
+
230
+ \`\`\`powershell
231
+ # Windows PowerShell — single-quoted so $env: expands correctly
232
+ $dir = Join-Path $env:USERPROFILE '.llm-inspector'
233
+ $file = Join-Path $dir 'config.json'
234
+ New-Item -ItemType Directory -Force -Path $dir | Out-Null
235
+ @'
236
+ {
237
+ "providers": [
238
+ {
239
+ "id": "anthropic",
240
+ "type": "anthropic",
241
+ "apiKey": "REPLACE_ME_BEFORE_WRITING",
242
+ "baseUrl": "https://api.anthropic.com"
243
+ }
244
+ ]
245
+ }
246
+ '@ | Set-Content -Path $file -Encoding UTF8
247
+ # Then patch the apiKey with the user-provided value
248
+ \`\`\`
249
+
250
+ **DO:** Patch the placeholder with the actual key using \`jq\` (preferred) or a simple \`sed\`. Then read the file back to confirm the key is no longer \`REPLACE_ME_BEFORE_WRITING\`.
251
+
252
+ **DO:** If the user declines to provide a key in the AskUserQuestion (selects "Skip for now"), do **not** write a placeholder config. Tell the user that Phase 5 (First capture) will be skipped, and that they can re-run the skill after adding a key.
253
+
254
+ > **PAUSE** — use \`AskUserQuestion\` with header \`Provider key\` and options \`["Key is in, continue", "Skip for now, I'll add it later"]\`. Wait for the answer.
255
+
256
+ ---
257
+
258
+ ## Phase 3: Start proxy
259
+
260
+ **EXPLAIN:** "Time to start the proxy. It binds to port ${port} by default, kills any process already on that port, and prints the URL."
261
+
262
+ **DO:** Skip this phase entirely if the Phase 0 health check already reported \`PROXY: up\` and the user opted to skip done phases.
263
+
264
+ **DO:** Otherwise, start the proxy in the background. On Windows, the npm shim is a \`.cmd\`/PowerShell file — \`Start-Process -FilePath "llm-inspector"\` returns "Invalid Win32 application" because Windows can't decide which shim to run. Use \`cmd /c start /B\` to background it through the cmd interpreter.
265
+
266
+ \`\`\`bash
267
+ # Unix / macOS / WSL
268
+ nohup llm-inspector --no-open > /tmp/llm-inspector.log 2>&1 &
269
+ \`\`\`
270
+
271
+ \`\`\`powershell
272
+ # Windows PowerShell — single-quoted so $env: expands correctly.
273
+ # Locate the binary on PATH first (works for npm, pnpm, yarn, volta, fnm).
274
+ # If not on PATH, fall back to the common npm global shim at $env:APPDATA.
275
+ # As a last resort, let cmd /c resolve it through PATHEXT.
276
+ $log = Join-Path $env:TEMP 'llm-inspector.log'
277
+ $err = Join-Path $env:TEMP 'llm-inspector.err.log'
278
+ $found = Get-Command llm-inspector -ErrorAction SilentlyContinue
279
+ if ($found) {
280
+ $shim = $found.Source
281
+ $args = '--no-open'
282
+ } elseif (Test-Path (Join-Path $env:APPDATA 'npm/llm-inspector.cmd')) {
283
+ $shim = Join-Path $env:APPDATA 'npm/llm-inspector.cmd'
284
+ $args = '--no-open'
285
+ } else {
286
+ # bin not on PATH and not at the default npm prefix — let cmd resolve it
287
+ $shim = 'cmd.exe'
288
+ $args = '/c','start','/B','llm-inspector','--no-open'
289
+ }
290
+ Start-Process -FilePath $shim -ArgumentList $args -RedirectStandardOutput $log -RedirectStandardError $err -WindowStyle Hidden
291
+ \`\`\`
292
+
293
+ Then wait for the port to be ready:
294
+
295
+ \`\`\`bash
296
+ for i in $(seq 1 20); do
297
+ curl -fsS "http://localhost:${port}/api/health" >/dev/null 2>&1 && echo "ready" && break
298
+ sleep 0.5
299
+ done
300
+ \`\`\`
301
+
302
+ **DO:** Hit the health endpoint to confirm the proxy is alive:
303
+
304
+ \`\`\`bash
305
+ curl -sS "http://localhost:${port}/api/health"
306
+ \`\`\`
307
+
308
+ > **PAUSE** — if the health check fails, show the user the log file (\`/tmp/llm-inspector.log\` or \`%TEMP%\\llm-inspector.log\`) and diagnose. Common issues: another process on the port, firewall, missing providers. Use \`AskUserQuestion\` with header \`Proxy up?\` and options \`["Yes, proxy is up", "No, I see an error in the log"]\`. Wait for the answer.
309
+
310
+ ---
311
+
312
+ ## Phase 4: Wire tool
313
+
314
+ **EXPLAIN:** "Now we tell your AI tool to send traffic through the proxy instead of directly to the upstream API. The exact env var depends on which tool you have."
315
+
316
+ **DO:** Based on the \`Environment detected\` block at the top of this skill, print the matching wiring command. Examples for each supported tool:
317
+
318
+ \`\`\`bash
319
+ # Claude Code
320
+ export ANTHROPIC_BASE_URL=http://localhost:${port}/proxy
321
+ claude
322
+
323
+ # OpenCode
324
+ export LLM_BASE_URL=http://localhost:${port}/proxy
325
+ opencode
326
+
327
+ # MiMo Code
328
+ export OPENAI_BASE_URL=http://localhost:${port}/proxy
329
+ mimo
330
+
331
+ # Cursor / Cody — set the OpenAI base URL in each tool's settings panel to http://localhost:${port}/proxy
332
+ \`\`\`
333
+
334
+ For a tool that wasn't auto-detected, fall through to the generic curl test in the next phase — the user can wire their tool later.
335
+
336
+ > **PAUSE** — use \`AskUserQuestion\` with header \`Tool wired?\` and options \`["Yes, env var is set, claude is running", "No, I'm going to use the curl test instead"]\`. Wait for the answer.
337
+
338
+ ---
339
+
340
+ ## Phase 4.5: Wire MCP server
341
+
342
+ **EXPLAIN:** "The proxy also exposes an MCP server at \`http://localhost:${port}/api/mcp\`. Your AI agent can query logs, replay requests, and test providers through it — no need to leave the editor."
343
+
344
+ **DO:** Skip this phase if Phase 0 reported \`MCP: wired in <path>\` and the user opted to skip done phases.
345
+
346
+ **DO:** Otherwise, check the project-level \`.mcp.json\` first (preferred — modern Claude Code convention), then fall back to \`~/.claude.json\`. Use the \`Read\` tool to inspect; do **not** \`cat\` a 40 KB file into the conversation.
347
+
348
+ If neither has an \`llm-inspector\` entry, add one. The simplest path is to write to project \`.mcp.json\` (create it if missing):
349
+
350
+ \`\`\`json
351
+ // .mcp.json (project root)
352
+ {
353
+ "mcpServers": {
354
+ "llm-inspector": {
355
+ "type": "http",
356
+ "url": "http://localhost:${port}/api/mcp"
357
+ }
358
+ }
359
+ }
360
+ \`\`\`
361
+
362
+ If \`mcpServers\` already exists in \`.mcp.json\`, merge the \`llm-inspector\` key into it via the \`Edit\` tool — do not overwrite other entries. If you can't create a project \`.mcp.json\` (no project root, permission, etc.), fall back to merging into \`~/.claude.json\` using the same \`Read\`/\`Edit\` pattern.
363
+
364
+ **DO:** Verify the handshake. The MCP \`initialize\` request should return 200 with a \`serverInfo\` payload — that proves the server is mounted and reachable:
365
+
366
+ \`\`\`bash
367
+ curl -sS -X POST "http://localhost:${port}/api/mcp" \\
368
+ -H "Content-Type: application/json" \\
369
+ -H "Accept: application/json, text/event-stream" \\
370
+ -d '{
371
+ "jsonrpc": "2.0",
372
+ "id": 1,
373
+ "method": "initialize",
374
+ "params": {
375
+ "protocolVersion": "2025-03-26",
376
+ "capabilities": {},
377
+ "clientInfo": { "name": "onboard-check", "version": "0" }
378
+ }
379
+ }' | grep -o '"name":"llm-inspector"' && echo "handshake OK"
380
+ \`\`\`
381
+
382
+ The \`grep -o '"name":"llm-inspector"'\` extracts only the serverInfo name — do not dump the full response. If the server returns session IDs, store the \`mcp-session-id\` header from the first response and use it for the follow-up \`tools/list\` call.
383
+
384
+ > **PAUSE** — use \`AskUserQuestion\` with header \`MCP OK?\` and options \`["Yes, handshake returned 200", "No, the call failed"]\`. Wait for the answer.
385
+
386
+ ---
387
+
388
+ ## Phase 5: First capture
389
+
390
+ **EXPLAIN:** "Let's prove the proxy works end-to-end. We'll send one real request through it and confirm the log shows up in the API."
391
+
392
+ **DO:** First, re-check the config. If the \`apiKey\` is still a \`REPLACE_ME_BEFORE_WRITING\` placeholder (user opted out in Phase 2), **skip the capture test** and tell the user to fill in their key and re-run the skill. A 401 from the upstream is fine if they did provide a real key — the proxy will still log the request.
393
+
394
+ Fire a minimal Anthropic-format request through the proxy:
395
+
396
+ \`\`\`bash
397
+ curl -sS -X POST "http://localhost:${port}/proxy/v1/messages" \\
398
+ -H "Content-Type: application/json" \\
399
+ -H "anthropic-version: 2023-06-01" \\
400
+ -H "x-api-key: \${LLM_INSPECTOR_API_KEY:-sk-no-key-needed-for-routing}" \\
401
+ -d '{"model":"claude-3-5-sonnet-20241022","max_tokens":1,"messages":[{"role":"user","content":"ping"}]}' \\
402
+ -o /tmp/llm-inspector-capture.json -w 'STATUS:%{http_code}\\n'
403
+ \`\`\`
404
+
405
+ **DO:** Poll the logs API for up to 5 seconds. A 200 with at least one entry means the request reached the proxy:
406
+
407
+ \`\`\`bash
408
+ for i in $(seq 1 10); do
409
+ resp=$(curl -sS "http://localhost:${port}/api/logs?limit=1")
410
+ count=$(echo "$resp" | grep -o '"total":[0-9]*' | head -1 | grep -o '[0-9]*$')
411
+ if [ "\${count:-0}" -ge 1 ]; then
412
+ echo "captured"
413
+ echo "$resp" | head -c 400
414
+ break
415
+ fi
416
+ sleep 0.5
417
+ done
418
+ \`\`\`
419
+
420
+ **DO:** Diagnose the response based on the actual status and body. **Do not** default to "auth failure" for every 4xx.
421
+
422
+ | Status | Body hint | Meaning |
423
+ |--------|-----------|---------|
424
+ | 200 | normal | Real success — the upstream returned data |
425
+ | 401 | \`"unauthorized"\` or similar | Upstream rejected the key (expected with a test key) |
426
+ | 403 | \`"Request not allowed"\` | **Proxy's allowlist** — not an auth failure, the proxy rejected the model/config. Show the user the proxy log. |
427
+ | 403 | other text | Could be upstream ACL — different problem |
428
+ | 5xx | anything | Upstream network error |
429
+
430
+ > **PAUSE** — use \`AskUserQuestion\` with header \`Captured?\` and options matching the diagnosis above. Wait for the answer.
431
+
432
+ ---
433
+
434
+ ## Phase 6: Tour & wrap
435
+
436
+ **EXPLAIN:** "Everything's working. Here's the cheat sheet for the Web UI and the supporting surfaces:"
437
+
438
+ - **Web UI**: \`http://localhost:${port}/\` — collapsible log rows, per-tab Copy/Expand in the log header, Diff with Raw (request body), Diff with Previous (compare adjacent requests), Replay (re-send a request), Export (JSON ZIP).
439
+ - **MCP server**: \`http://localhost:${port}/api/mcp\` — connect from your coding agent to query logs, replay, and test providers without leaving the editor. Look for the "MCP Ready" badge in the Web UI header.
440
+ - **REST API**: \`/api/logs\`, \`/api/sessions\`, \`/api/providers\` — for scripting and shell-based inspection.
441
+ - **Stop the proxy**:
442
+
443
+ \`\`\`bash
444
+ # Unix / macOS
445
+ lsof -ti:${port} | xargs -r kill -9
446
+
447
+ # Windows PowerShell — single-quoted so $env: expands correctly
448
+ Get-NetTCPConnection -LocalPort $port | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force }
449
+ \`\`\`
450
+
451
+ - **Re-run onboard**: \`llm-inspector onboard --force\` refreshes this skill.
452
+ - **Full docs**: see the project README (linked from the Web UI footer).
453
+
454
+ > **PAUSE** — use \`AskUserQuestion\` with header \`All set?\` and options \`["All set, I'm done", "Wait, I want to revisit a phase"]\`. Wait for the answer.
455
+
456
+ You're done. Happy inspecting.
457
+ `;
458
+ }