@tonyclaw/llm-inspector 1.14.9 → 1.15.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.
@@ -0,0 +1,456 @@
1
+ import type { JSX } from "react";
2
+ import { cn } from "../../lib/utils";
3
+
4
+ type CrabVariantProps = { className?: string; style?: React.CSSProperties };
5
+
6
+ function SvgShell({
7
+ className,
8
+ style,
9
+ d,
10
+ eyeStalks,
11
+ eyes,
12
+ legs,
13
+ extras,
14
+ }: CrabVariantProps & {
15
+ d: string;
16
+ eyeStalks: JSX.Element;
17
+ eyes: JSX.Element;
18
+ legs: JSX.Element;
19
+ extras?: JSX.Element;
20
+ }): JSX.Element {
21
+ return (
22
+ <svg
23
+ viewBox="0 0 24 24"
24
+ fill="none"
25
+ stroke="currentColor"
26
+ strokeWidth="1.5"
27
+ strokeLinecap="round"
28
+ strokeLinejoin="round"
29
+ aria-hidden="true"
30
+ style={style}
31
+ className={cn("inline-block size-5", className)}
32
+ >
33
+ <path d={d} />
34
+ {eyeStalks}
35
+ {eyes}
36
+ {legs}
37
+ {extras}
38
+ </svg>
39
+ );
40
+ }
41
+
42
+ // Shared legs
43
+ const StdLegs = (
44
+ <>
45
+ <line x1="6.5" y1="16" x2="4.5" y2="19.5" />
46
+ <line x1="9" y1="17.5" x2="8" y2="20.5" />
47
+ <line x1="15" y1="17.5" x2="16" y2="20.5" />
48
+ <line x1="17.5" y1="16" x2="19.5" y2="19.5" />
49
+ </>
50
+ );
51
+
52
+ const ShortLegs = (
53
+ <>
54
+ <line x1="7" y1="16" x2="5.5" y2="18.5" />
55
+ <line x1="9.5" y1="17" x2="8.5" y2="19.5" />
56
+ <line x1="14.5" y1="17" x2="15.5" y2="19.5" />
57
+ <line x1="17" y1="16" x2="18.5" y2="18.5" />
58
+ </>
59
+ );
60
+
61
+ // ── 1. Classic ──
62
+ function Crab1({ className }: CrabVariantProps): JSX.Element {
63
+ return (
64
+ <SvgShell
65
+ className={className}
66
+ d="M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z"
67
+ eyeStalks={
68
+ <>
69
+ <line x1="10" y1="7" x2="9.5" y2="5" />
70
+ <line x1="14" y1="7" x2="14.5" y2="5" />
71
+ </>
72
+ }
73
+ eyes={
74
+ <>
75
+ <circle cx="9.5" cy="4.5" r="0.9" fill="currentColor" stroke="none" />
76
+ <circle cx="14.5" cy="4.5" r="0.9" fill="currentColor" stroke="none" />
77
+ </>
78
+ }
79
+ legs={StdLegs}
80
+ extras={
81
+ <>
82
+ <path d="M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5" />
83
+ <path d="M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5" />
84
+ </>
85
+ }
86
+ />
87
+ );
88
+ }
89
+
90
+ // ── 2. Round (chubby) ──
91
+ function Crab2({ className }: CrabVariantProps): JSX.Element {
92
+ return (
93
+ <SvgShell
94
+ className={className}
95
+ d="M4 13 C4 7 7.5 5.5 12 5.5 C16.5 5.5 20 7 20 13 C20 17.5 16.5 19 12 19 C7.5 19 4 17.5 4 13 Z"
96
+ eyeStalks={
97
+ <>
98
+ <line x1="9.5" y1="6.5" x2="9.5" y2="4.5" />
99
+ <line x1="14.5" y1="6.5" x2="14.5" y2="4.5" />
100
+ </>
101
+ }
102
+ eyes={
103
+ <>
104
+ <circle cx="9.5" cy="4" r="1.1" fill="currentColor" stroke="none" />
105
+ <circle cx="14.5" cy="4" r="1.1" fill="currentColor" stroke="none" />
106
+ </>
107
+ }
108
+ legs={ShortLegs}
109
+ extras={
110
+ <>
111
+ <path d="M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12" />
112
+ <path d="M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12" />
113
+ </>
114
+ }
115
+ />
116
+ );
117
+ }
118
+
119
+ // ── 3. Wide (pancake) ──
120
+ function Crab3({ className }: CrabVariantProps): JSX.Element {
121
+ return (
122
+ <SvgShell
123
+ className={className}
124
+ d="M3 13.5 C3 8 7 6 12 6 C17 6 21 8 21 13.5 C21 17 17 19 12 19 C7 19 3 17 3 13.5 Z"
125
+ eyeStalks={
126
+ <>
127
+ <line x1="7" y1="7" x2="6.5" y2="4.5" />
128
+ <line x1="17" y1="7" x2="17.5" y2="4.5" />
129
+ </>
130
+ }
131
+ eyes={
132
+ <>
133
+ <circle cx="6.5" cy="4" r="0.8" fill="currentColor" stroke="none" />
134
+ <circle cx="17.5" cy="4" r="0.8" fill="currentColor" stroke="none" />
135
+ </>
136
+ }
137
+ legs={StdLegs}
138
+ extras={
139
+ <>
140
+ <path d="M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13" />
141
+ <path d="M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13" />
142
+ </>
143
+ }
144
+ />
145
+ );
146
+ }
147
+
148
+ // ── 4. Tall (stretch) ──
149
+ function Crab4({ className }: CrabVariantProps): JSX.Element {
150
+ return (
151
+ <SvgShell
152
+ className={className}
153
+ d="M6 14 C6 8 9 5.5 12 5.5 C15 5.5 18 8 18 14 C18 18 15 20 12 20 C9 20 6 18 6 14 Z"
154
+ eyeStalks={
155
+ <>
156
+ <line x1="10" y1="6.5" x2="10" y2="3.5" />
157
+ <line x1="14" y1="6.5" x2="14" y2="3.5" />
158
+ </>
159
+ }
160
+ eyes={
161
+ <>
162
+ <circle cx="10" cy="3" r="0.7" fill="currentColor" stroke="none" />
163
+ <circle cx="14" cy="3" r="0.7" fill="currentColor" stroke="none" />
164
+ </>
165
+ }
166
+ legs={
167
+ <>
168
+ <line x1="7" y1="17" x2="5" y2="20.5" />
169
+ <line x1="9.5" y1="18.5" x2="8.5" y2="21.5" />
170
+ <line x1="14.5" y1="18.5" x2="15.5" y2="21.5" />
171
+ <line x1="17" y1="17" x2="19" y2="20.5" />
172
+ </>
173
+ }
174
+ extras={
175
+ <>
176
+ <path d="M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12" />
177
+ <path d="M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12" />
178
+ </>
179
+ }
180
+ />
181
+ );
182
+ }
183
+
184
+ // ── 5. Spiky ──
185
+ function Crab5({ className }: CrabVariantProps): JSX.Element {
186
+ return (
187
+ <SvgShell
188
+ className={className}
189
+ d="M5 13 C5 9 8 7 12 7 L13 4 L14 7 C16 7 19 9 19 13 C19 16 16 18 13 18 L12 21 L11 18 C8 18 5 16 5 13 Z"
190
+ eyeStalks={
191
+ <>
192
+ <line x1="10" y1="7" x2="9.5" y2="5" />
193
+ <line x1="14" y1="7" x2="14.5" y2="5" />
194
+ </>
195
+ }
196
+ eyes={
197
+ <>
198
+ <circle cx="9.5" cy="4.5" r="0.8" fill="currentColor" stroke="none" />
199
+ <circle cx="14.5" cy="4.5" r="0.8" fill="currentColor" stroke="none" />
200
+ </>
201
+ }
202
+ legs={StdLegs}
203
+ extras={
204
+ <>
205
+ <path d="M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5" />
206
+ <path d="M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5" />
207
+ </>
208
+ }
209
+ />
210
+ );
211
+ }
212
+
213
+ // ── 6. Wink ──
214
+ function Crab6({ className }: CrabVariantProps): JSX.Element {
215
+ return (
216
+ <SvgShell
217
+ className={className}
218
+ d="M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z"
219
+ eyeStalks={
220
+ <>
221
+ <line x1="10" y1="7" x2="9.5" y2="5" />
222
+ <line x1="14" y1="7" x2="14.5" y2="5" />
223
+ </>
224
+ }
225
+ eyes={
226
+ <>
227
+ <circle cx="9.5" cy="4.5" r="0.9" fill="currentColor" stroke="none" />
228
+ <line x1="13.5" y1="4" x2="15.5" y2="5" />
229
+ </>
230
+ }
231
+ legs={StdLegs}
232
+ extras={
233
+ <>
234
+ <path d="M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5" />
235
+ <path d="M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5" />
236
+ </>
237
+ }
238
+ />
239
+ );
240
+ }
241
+
242
+ // ── 7. Sleepy ──
243
+ function Crab7({ className }: CrabVariantProps): JSX.Element {
244
+ return (
245
+ <SvgShell
246
+ className={className}
247
+ d="M5.5 13.5 C5.5 10 8.5 8 12 8 C15.5 8 18.5 10 18.5 13.5 C18.5 16 15.5 17.5 12 17.5 C8.5 17.5 5.5 16 5.5 13.5 Z"
248
+ eyeStalks={
249
+ <>
250
+ <line x1="10" y1="8" x2="10" y2="6" />
251
+ <line x1="14" y1="8" x2="14" y2="6" />
252
+ </>
253
+ }
254
+ eyes={
255
+ <>
256
+ <line x1="9" y1="6" x2="11" y2="6.5" />
257
+ <line x1="13" y1="6" x2="15" y2="6.5" />
258
+ </>
259
+ }
260
+ legs={ShortLegs}
261
+ extras={
262
+ <>
263
+ <path d="M6 11.5 C4.5 10.5 3 11 3.5 12.5 C4 13.5 5 13 5.5 12.5" />
264
+ <path d="M18 11.5 C19.5 10.5 21 11 20.5 12.5 C20 13.5 19 13 18.5 12.5" />
265
+ </>
266
+ }
267
+ />
268
+ );
269
+ }
270
+
271
+ // ── 8. Grumpy (angry brows) ──
272
+ function Crab8({ className }: CrabVariantProps): JSX.Element {
273
+ return (
274
+ <SvgShell
275
+ className={className}
276
+ d="M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z"
277
+ eyeStalks={
278
+ <>
279
+ <line x1="10" y1="7" x2="9.5" y2="5" />
280
+ <line x1="14" y1="7" x2="14.5" y2="5" />
281
+ </>
282
+ }
283
+ eyes={
284
+ <>
285
+ <circle cx="9.5" cy="4.5" r="0.7" fill="currentColor" stroke="none" />
286
+ <circle cx="14.5" cy="4.5" r="0.7" fill="currentColor" stroke="none" />
287
+ </>
288
+ }
289
+ legs={StdLegs}
290
+ extras={
291
+ <>
292
+ <path d="M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5" />
293
+ <path d="M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5" />
294
+ {/* Angry brows */}
295
+ <line x1="8.5" y1="4" x2="10.5" y2="4.5" />
296
+ <line x1="15.5" y1="4" x2="13.5" y2="4.5" />
297
+ {/* Frown */}
298
+ <path d="M9 15.5 C10 14.5 14 14.5 15 15.5" />
299
+ </>
300
+ }
301
+ />
302
+ );
303
+ }
304
+
305
+ // ── 9. Surprised ──
306
+ function Crab9({ className }: CrabVariantProps): JSX.Element {
307
+ return (
308
+ <SvgShell
309
+ className={className}
310
+ d="M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z"
311
+ eyeStalks={
312
+ <>
313
+ <line x1="10" y1="7" x2="9.5" y2="5" />
314
+ <line x1="14" y1="7" x2="14.5" y2="5" />
315
+ </>
316
+ }
317
+ eyes={
318
+ <>
319
+ <circle cx="9.5" cy="4.5" r="1.2" fill="none" stroke="currentColor" />
320
+ <circle cx="14.5" cy="4.5" r="1.2" fill="none" stroke="currentColor" />
321
+ </>
322
+ }
323
+ legs={StdLegs}
324
+ extras={
325
+ <>
326
+ <path d="M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5" />
327
+ <path d="M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5" />
328
+ {/* Open mouth */}
329
+ <ellipse cx="12" cy="15" rx="2" ry="1.5" fill="currentColor" stroke="none" />
330
+ </>
331
+ }
332
+ />
333
+ );
334
+ }
335
+
336
+ // ── 10. Happy (big smile) ──
337
+ function Crab10({ className }: CrabVariantProps): JSX.Element {
338
+ return (
339
+ <SvgShell
340
+ className={className}
341
+ d="M4.5 13 C4.5 8 7.5 6 12 6 C16.5 6 19.5 8 19.5 13 C19.5 17 16.5 18.5 12 18.5 C7.5 18.5 4.5 17 4.5 13 Z"
342
+ eyeStalks={
343
+ <>
344
+ <line x1="9.5" y1="7" x2="9" y2="5" />
345
+ <line x1="14.5" y1="7" x2="15" y2="5" />
346
+ </>
347
+ }
348
+ eyes={
349
+ <>
350
+ <circle cx="9" cy="4.5" r="1" fill="currentColor" stroke="none" />
351
+ <circle cx="15" cy="4.5" r="1" fill="currentColor" stroke="none" />
352
+ </>
353
+ }
354
+ legs={StdLegs}
355
+ extras={
356
+ <>
357
+ <path d="M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12" />
358
+ <path d="M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12" />
359
+ {/* Smile */}
360
+ <path d="M9 14.5 C10 16 14 16 15 14.5" />
361
+ {/* Rosy cheeks */}
362
+ <circle cx="7" cy="13" r="1" fill="currentColor" stroke="none" opacity="0.3" />
363
+ <circle cx="17" cy="13" r="1" fill="currentColor" stroke="none" opacity="0.3" />
364
+ </>
365
+ }
366
+ />
367
+ );
368
+ }
369
+
370
+ // ── 11. Cool (sunglasses) ──
371
+ function Crab11({ className }: CrabVariantProps): JSX.Element {
372
+ return (
373
+ <SvgShell
374
+ className={className}
375
+ d="M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z"
376
+ eyeStalks={
377
+ <>
378
+ <line x1="10" y1="7" x2="9.5" y2="5.5" />
379
+ <line x1="14" y1="7" x2="14.5" y2="5.5" />
380
+ </>
381
+ }
382
+ eyes={
383
+ <>
384
+ {/* Sunglasses bar */}
385
+ <line x1="7.5" y1="5.5" x2="16.5" y2="5.5" />
386
+ <rect x="7" y="5" width="4" height="2" rx="0.5" fill="currentColor" stroke="none" />
387
+ <rect x="13" y="5" width="4" height="2" rx="0.5" fill="currentColor" stroke="none" />
388
+ </>
389
+ }
390
+ legs={StdLegs}
391
+ extras={
392
+ <>
393
+ <path d="M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5" />
394
+ <path d="M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5" />
395
+ {/* Cool smile */}
396
+ <path d="M9.5 15 C10.5 16 13.5 16 14.5 15" />
397
+ </>
398
+ }
399
+ />
400
+ );
401
+ }
402
+
403
+ // ── 12. Baby (tiny, cute) ──
404
+ function Crab12({ className }: CrabVariantProps): JSX.Element {
405
+ return (
406
+ <SvgShell
407
+ className={className}
408
+ d="M7 13.5 C7 10.5 9.5 9 12 9 C14.5 9 17 10.5 17 13.5 C17 16 14.5 17.5 12 17.5 C9.5 17.5 7 16 7 13.5 Z"
409
+ eyeStalks={
410
+ <>
411
+ <line x1="10.5" y1="9.5" x2="10.5" y2="8" />
412
+ <line x1="13.5" y1="9.5" x2="13.5" y2="8" />
413
+ </>
414
+ }
415
+ eyes={
416
+ <>
417
+ <circle cx="10.5" cy="7.5" r="0.8" fill="currentColor" stroke="none" />
418
+ <circle cx="13.5" cy="7.5" r="0.8" fill="currentColor" stroke="none" />
419
+ </>
420
+ }
421
+ legs={
422
+ <>
423
+ <line x1="8" y1="16" x2="6.5" y2="18" />
424
+ <line x1="10" y1="17" x2="9.5" y2="19" />
425
+ <line x1="14" y1="17" x2="14.5" y2="19" />
426
+ <line x1="16" y1="16" x2="17.5" y2="18" />
427
+ </>
428
+ }
429
+ extras={
430
+ <>
431
+ <path d="M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13" />
432
+ <path d="M16.5 12 C17.5 11 18.5 11.5 18 13 C17.5 14 17 13.5 16.5 13" />
433
+ </>
434
+ }
435
+ />
436
+ );
437
+ }
438
+
439
+ export const crabVariants: ((props: CrabVariantProps) => JSX.Element)[] = [
440
+ Crab1,
441
+ Crab2,
442
+ Crab3,
443
+ Crab4,
444
+ Crab5,
445
+ Crab6,
446
+ Crab7,
447
+ Crab8,
448
+ Crab9,
449
+ Crab10,
450
+ Crab11,
451
+ Crab12,
452
+ ];
453
+
454
+ export function getCrabVariant(index: number): (props: CrabVariantProps) => JSX.Element {
455
+ return crabVariants[Math.abs(index) % crabVariants.length] ?? Crab1;
456
+ }
@@ -8,8 +8,10 @@ function isRecord(value: unknown): value is Record<string, unknown> {
8
8
 
9
9
  /**
10
10
  * Extracts the stop/finish reason from a captured log's response text.
11
- * Returns the raw stop_reason value for Anthropic, the finish_reason for
12
- * OpenAI, or null if the response is pending, malformed, or unrecognized.
11
+ * Detects the response body shape (Anthropic or OpenAI) independently of
12
+ * `log.apiFormat`, since the body shape may not match the declared format
13
+ * (e.g. an Anthropic-compatible endpoint returning Anthropic-shaped JSON
14
+ * while the request was classified as OpenAI).
13
15
  */
14
16
  export function extractStopReason(log: CapturedLog): StopReason {
15
17
  if (log.responseText === null) return null;
@@ -22,17 +24,16 @@ export function extractStopReason(log: CapturedLog): StopReason {
22
24
  }
23
25
  if (!isRecord(json)) return null;
24
26
 
25
- // Anthropic: { stop_reason: "end_turn" | "tool_use" | ... }
26
- if (log.apiFormat === "anthropic" && typeof json.stop_reason === "string") {
27
+ // Anthropic shape: { stop_reason: "end_turn" | "tool_use" | ... }
28
+ if (typeof json.stop_reason === "string") {
27
29
  if (json.stop_reason === "end_turn" || json.stop_reason === "tool_use") {
28
30
  return json.stop_reason;
29
31
  }
30
32
  return null;
31
33
  }
32
34
 
33
- // OpenAI: { choices: [{ finish_reason: "stop" | ... }] }
35
+ // OpenAI shape: { choices: [{ finish_reason: "stop" | ... }] }
34
36
  if (
35
- log.apiFormat === "openai" &&
36
37
  Array.isArray(json.choices) &&
37
38
  json.choices.length > 0 &&
38
39
  isRecord(json.choices[0]) &&
@@ -40,6 +40,9 @@
40
40
  --radius-md: calc(var(--radius) - 2px);
41
41
  --radius-lg: var(--radius);
42
42
  --radius-xl: calc(var(--radius) + 4px);
43
+ --animate-crab-crawl: crab-crawl-down 0.6s ease-in-out infinite;
44
+ --animate-crab-appear: crab-appear 300ms ease-out;
45
+ --animate-crab-settle: crab-settle 400ms ease-in-out;
43
46
  }
44
47
 
45
48
  :root {
@@ -111,6 +114,41 @@
111
114
  --sidebar-ring: oklch(0.556 0 0);
112
115
  }
113
116
 
117
+ @keyframes crab-crawl-down {
118
+ 0%, 100% {
119
+ transform: translateY(0px);
120
+ }
121
+ 25% {
122
+ transform: translateY(2px);
123
+ }
124
+ 75% {
125
+ transform: translateY(-1px);
126
+ }
127
+ }
128
+
129
+ @keyframes crab-appear {
130
+ 0% {
131
+ transform: scale(0.5);
132
+ opacity: 0;
133
+ }
134
+ 100% {
135
+ transform: scale(1);
136
+ opacity: 1;
137
+ }
138
+ }
139
+
140
+ @keyframes crab-settle {
141
+ 0% {
142
+ transform: scale(1);
143
+ }
144
+ 50% {
145
+ transform: scale(1.15);
146
+ }
147
+ 100% {
148
+ transform: scale(1);
149
+ }
150
+ }
151
+
114
152
  @layer base {
115
153
  * {
116
154
  @apply border-border outline-ring/50;