@tonyclaw/agent-inspector 2.0.36 → 2.0.37

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 (30) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/{CompareDrawer-Bg2mo0NZ.js → CompareDrawer-nEHCEVP4.js} +1 -1
  3. package/.output/public/assets/{ProxyViewerContainer-C_Lq5T5V.js → ProxyViewerContainer-BstBIX2B.js} +35 -35
  4. package/.output/public/assets/{ReplayDialog-Bns-ayOg.js → ReplayDialog-CUnBdt1Q.js} +1 -1
  5. package/.output/public/assets/{RequestAnatomy-BBcPAIWx.js → RequestAnatomy-BU9VT2Sw.js} +1 -1
  6. package/.output/public/assets/{ResponseView-DSRS3rHt.js → ResponseView-amxuKPKY.js} +1 -1
  7. package/.output/public/assets/{StreamingChunkSequence-CzZxKE5-.js → StreamingChunkSequence-DpscrQM2.js} +1 -1
  8. package/.output/public/assets/_sessionId-7c9bsOFT.js +1 -0
  9. package/.output/public/assets/index-B7a5OmIO.js +1 -0
  10. package/.output/public/assets/{main-BVKRHBUl.js → main-D56QvEyw.js} +2 -2
  11. package/.output/server/_libs/lucide-react.mjs +114 -94
  12. package/.output/server/{_sessionId-Dsd36Yhc.mjs → _sessionId-ChwEDyI4.mjs} +2 -2
  13. package/.output/server/_ssr/{CompareDrawer-BbJ5UdYD.mjs → CompareDrawer-Ce2590rK.mjs} +3 -3
  14. package/.output/server/_ssr/{ProxyViewerContainer-7igCY291.mjs → ProxyViewerContainer-D6xM8A0S.mjs} +797 -781
  15. package/.output/server/_ssr/{ReplayDialog-CgWweshq.mjs → ReplayDialog-CB4KOlLe.mjs} +4 -4
  16. package/.output/server/_ssr/{RequestAnatomy-BAyM_j7a.mjs → RequestAnatomy-CsWV3W03.mjs} +3 -3
  17. package/.output/server/_ssr/{ResponseView-iZQH7EYu.mjs → ResponseView-BuCCV3LU.mjs} +3 -3
  18. package/.output/server/_ssr/{StreamingChunkSequence-BU6hyHMg.mjs → StreamingChunkSequence-C5dE7V1d.mjs} +2 -2
  19. package/.output/server/_ssr/{index-D7QF4E6v.mjs → index-BeIi0CPv.mjs} +2 -2
  20. package/.output/server/_ssr/index.mjs +2 -2
  21. package/.output/server/_ssr/{router-DLLY6gv_.mjs → router-Ca2MCyUX.mjs} +78 -71
  22. package/.output/server/{_tanstack-start-manifest_v-CHmIZaVV.mjs → _tanstack-start-manifest_v-CBAJfSAX.mjs} +1 -1
  23. package/.output/server/index.mjs +60 -60
  24. package/package.json +1 -1
  25. package/src/components/ProxyViewer.tsx +42 -8
  26. package/src/components/proxy-viewer/ConversationHeader.tsx +10 -6
  27. package/src/proxy/formats/registry.ts +7 -1
  28. package/src/proxy/store.ts +14 -11
  29. package/.output/public/assets/_sessionId-DurHDwM1.js +0 -1
  30. package/.output/public/assets/index-sGphugFR.js +0 -1
@@ -18,6 +18,7 @@ import { cn, formatTokens } from "../../lib/utils";
18
18
  import type { CapturedLog } from "../../proxy/schemas";
19
19
  import { Badge } from "../ui/badge";
20
20
  import { ConfirmDialog } from "../ui/confirm-dialog";
21
+ import { resolveLogFormat } from "./log-formats";
21
22
 
22
23
  const API_FORMAT_LABELS: Record<"anthropic" | "openai" | "unknown", string> = {
23
24
  anthropic: "Anthropic",
@@ -231,11 +232,13 @@ export type ConversationGroupData = {
231
232
  };
232
233
 
233
234
  export function getGroupApiFormat(logs: CapturedLog[]): "anthropic" | "openai" | "unknown" {
234
- const firstNonUnknown = logs.find((l) => l.apiFormat !== "unknown");
235
- if (firstNonUnknown !== undefined) {
236
- return firstNonUnknown.apiFormat;
235
+ for (const log of logs) {
236
+ const apiFormat = resolveLogFormat(log);
237
+ if (apiFormat !== "unknown") {
238
+ return apiFormat;
239
+ }
237
240
  }
238
- return logs[0]?.apiFormat ?? "unknown";
241
+ return "unknown";
239
242
  }
240
243
 
241
244
  /**
@@ -248,8 +251,9 @@ export function hasMixedApiFormat(logs: CapturedLog[]): boolean {
248
251
  let hasAnthropic = false;
249
252
  let hasOpenai = false;
250
253
  for (const log of logs) {
251
- if (log.apiFormat === "anthropic") hasAnthropic = true;
252
- else if (log.apiFormat === "openai") hasOpenai = true;
254
+ const apiFormat = resolveLogFormat(log);
255
+ if (apiFormat === "anthropic") hasAnthropic = true;
256
+ else if (apiFormat === "openai") hasOpenai = true;
253
257
  if (hasAnthropic && hasOpenai) return true;
254
258
  }
255
259
  return false;
@@ -31,6 +31,12 @@ class FormatRegistryImpl {
31
31
  return format === undefined ? undefined : this.handlers.get(format);
32
32
  }
33
33
 
34
+ /** Get the wire format matching a request path without requiring handlers. */
35
+ getFormatByPath(path: string): RequestFormat | undefined {
36
+ const messagesPath = path.split("?")[0] ?? "";
37
+ return this.pathMap.get(messagesPath);
38
+ }
39
+
34
40
  /** Detect format from request body content */
35
41
  detectFormat(rawBody: string | null): RequestFormat {
36
42
  if (rawBody === null) return "unknown";
@@ -57,7 +63,7 @@ export function formatForPath(path: string): FormatHandler | null {
57
63
  * simple message-only calls.
58
64
  */
59
65
  export function requestFormatForPath(path: string): RequestFormat {
60
- return formatForPath(path)?.format ?? "unknown";
66
+ return formatRegistry.getFormatByPath(path) ?? "unknown";
61
67
  }
62
68
 
63
69
  // Register known paths
@@ -34,6 +34,7 @@ import type { SessionInfo, SessionLogSummary } from "../lib/sessionInfoContract"
34
34
  import { buildSessionInfo, buildSessionLogSummary } from "./sessionInfo";
35
35
  import type { CapturedLog } from "./schemas";
36
36
  import { CapturedLogSchema } from "./schemas";
37
+ import { requestFormatForPath } from "./formats/registry";
37
38
  import {
38
39
  clearSessionRegistry,
39
40
  getLogSessionId,
@@ -109,14 +110,16 @@ function evictOldestIfNeeded(): void {
109
110
  }
110
111
  }
111
112
 
112
- function normalizeLogSession(log: CapturedLog): CapturedLog {
113
+ function normalizeLog(log: CapturedLog): CapturedLog {
113
114
  const sessionId = getLogSessionId(log);
114
- if (sessionId === log.sessionId) return log;
115
- return { ...log, sessionId };
115
+ const pathFormat = requestFormatForPath(log.path);
116
+ const apiFormat = pathFormat === "unknown" ? log.apiFormat : pathFormat;
117
+ if (sessionId === log.sessionId && apiFormat === log.apiFormat) return log;
118
+ return { ...log, sessionId, apiFormat };
116
119
  }
117
120
 
118
121
  function addToCache(log: CapturedLog): void {
119
- const cachedLog = normalizeLogSession(log);
122
+ const cachedLog = normalizeLog(log);
120
123
  // If updating an existing entry, remove first to reset insertion order
121
124
  if (memoryCache.has(cachedLog.id)) {
122
125
  memoryCache.delete(cachedLog.id);
@@ -174,12 +177,12 @@ export async function addTestLogEntry(entry: Omit<CapturedLog, "id">): Promise<C
174
177
  isTest: entry.isTest,
175
178
  });
176
179
 
177
- const log: CapturedLog = {
180
+ const log: CapturedLog = normalizeLog({
178
181
  id,
179
182
  ...entry,
180
183
  sessionId: session.id,
181
184
  streamingChunksPath,
182
- };
185
+ });
183
186
 
184
187
  await runWithLogWriteLock(async () => {
185
188
  const logFile = getCurrentLogFile();
@@ -218,7 +221,7 @@ export async function createLog(
218
221
  clientInfo,
219
222
  });
220
223
 
221
- const log: CapturedLog = {
224
+ const log: CapturedLog = normalizeLog({
222
225
  id,
223
226
  timestamp: new Date().toISOString(),
224
227
  method,
@@ -249,7 +252,7 @@ export async function createLog(
249
252
  clientCwd: clientInfo?.cwd ?? null,
250
253
  clientProjectFolder: clientInfo?.projectFolder ?? null,
251
254
  streamingChunksPath: null,
252
- };
255
+ });
253
256
 
254
257
  // Write to disk and update index
255
258
  await runWithLogWriteLock(async () => {
@@ -308,7 +311,7 @@ export async function getLogById(id: number): Promise<CapturedLog | null> {
308
311
  const parsed: unknown = JSON.parse(line);
309
312
  const result = CapturedLogSchema.safeParse(parsed);
310
313
  if (result.success) {
311
- const log = normalizeLogSession(result.data);
314
+ const log = normalizeLog(result.data);
312
315
  addToCache(log);
313
316
  observeSessionLog(log);
314
317
  return log;
@@ -348,7 +351,7 @@ async function scanLogFileForId(filePath: string, id: number): Promise<CapturedL
348
351
  if (desc !== undefined && typeof desc.value === "number" && desc.value === id) {
349
352
  const result = CapturedLogSchema.safeParse(parsed);
350
353
  if (result.success) {
351
- lastMatch = normalizeLogSession(result.data);
354
+ lastMatch = normalizeLog(result.data);
352
355
  if (result.data.responseStatus !== null) {
353
356
  return lastMatch;
354
357
  }
@@ -412,7 +415,7 @@ async function visitPersistedLogFile(
412
415
  const parsed: unknown = JSON.parse(line);
413
416
  const result = CapturedLogSchema.safeParse(parsed);
414
417
  if (result.success) {
415
- const log = normalizeLogSession(result.data);
418
+ const log = normalizeLog(result.data);
416
419
  visitor(log);
417
420
  }
418
421
  } catch {
@@ -1 +0,0 @@
1
- import{R as s,j as e}from"./main-BVKRHBUl.js";import{P as i}from"./ProxyViewerContainer-C_Lq5T5V.js";function t(){const{sessionId:o}=s.useParams();return e.jsx(i,{initialSessionId:o},o)}export{t as component};
@@ -1 +0,0 @@
1
- import{P as o}from"./ProxyViewerContainer-C_Lq5T5V.js";import"./main-BVKRHBUl.js";const r=o;export{r as component};