@tonyclaw/agent-inspector 3.1.4 → 3.1.5
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/backend/nitro.json +1 -1
- package/.output/cli.js +35 -12
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-CaWyNrmN.mjs → router-DoTLo_6Y.mjs} +105 -21
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-DK-lVFGz.js → CompareDrawer-BpwJlrGi.js} +1 -1
- package/.output/ui/assets/{InspectorPet-Bd56O0p-.js → InspectorPet-Bd4R1Uqu.js} +1 -1
- package/.output/ui/assets/ProxyViewerContainer-BV4-7dja.js +59 -0
- package/.output/ui/assets/{ReplayDialog-BioFH6jD.js → ReplayDialog-Ddb7XkVq.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-o8amClny.js → RequestAnatomy-Ddh3k5qQ.js} +1 -1
- package/.output/ui/assets/{ResponseView-6gzN1iRW.js → ResponseView-isgNqP5S.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-q7_3VMUe.js → StreamingChunkSequence-DwVYkfXk.js} +1 -1
- package/.output/ui/assets/{_sessionId-CTk1Vhy8.js → _sessionId-BuT3c4Zb.js} +1 -1
- package/.output/ui/assets/{_sessionId-Cwd8Jzq8.js → _sessionId-ChDHsnEX.js} +1 -1
- package/.output/ui/assets/{index-hluYwfXx.js → index-BGt5G4qW.js} +1 -1
- package/.output/ui/assets/{index-Rb-yjfPv.js → index-CbTMnV7Y.js} +1 -1
- package/.output/ui/assets/{index-BHmCRmME.js → index-fCRGsdC7.js} +1 -1
- package/.output/ui/assets/{index-MPPOjigU.js → index-feJFJxaj.js} +2 -2
- package/.output/ui/assets/{json-viewer-BIqit69y.js → json-viewer-B2jL8EW8.js} +1 -1
- package/.output/ui/assets/{jszip.min-olAf1G9u.js → jszip.min-_tcHnamX.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/.output/workers/logFinalizer.worker.js +19 -1
- package/.output/workers/sessionWorkerEntry.js +19 -1
- package/package.json +16 -11
- package/src/components/proxy-viewer/LogEntry.tsx +162 -24
- package/src/contracts/log.ts +1 -0
- package/src/proxy/handler.ts +36 -19
- package/src/proxy/logFinalizer.ts +67 -1
- package/src/proxy/logger.ts +21 -1
- package/.output/ui/assets/ProxyViewerContainer-BhmwJbt3.js +0 -59
package/.output/cli.js
CHANGED
|
@@ -20,7 +20,7 @@ var init_package = __esm({
|
|
|
20
20
|
"package.json"() {
|
|
21
21
|
package_default = {
|
|
22
22
|
name: "@tonyclaw/agent-inspector",
|
|
23
|
-
version: "3.1.
|
|
23
|
+
version: "3.1.5",
|
|
24
24
|
type: "module",
|
|
25
25
|
description: "Agent observability and knowledge capture layer for AI coding tools.",
|
|
26
26
|
license: "MIT",
|
|
@@ -78,13 +78,15 @@ var init_package = __esm({
|
|
|
78
78
|
dev: "node scripts/dev-decoupled.mjs",
|
|
79
79
|
"dev:ui": "vite dev --config vite.ui.config.ts",
|
|
80
80
|
"dev:backend": "node scripts/dev-backend.mjs",
|
|
81
|
-
"test:smoke": "bun scripts/run-test-suite.mjs smoke",
|
|
82
|
-
"test:fast": "bun scripts/run-test-suite.mjs smoke",
|
|
83
|
-
"test:unit": "bun scripts/run-test-suite.mjs unit",
|
|
84
|
-
"test:integration": "bun scripts/run-test-suite.mjs integration",
|
|
85
|
-
"test:changed": "bun scripts/run-test-suite.mjs changed",
|
|
86
|
-
"test:all": "bun scripts/run-test-suite.mjs all",
|
|
87
|
-
"test:compatibility-tooling": "node
|
|
81
|
+
"test:smoke": "node scripts/run-local-bun.mjs scripts/run-test-suite.mjs smoke",
|
|
82
|
+
"test:fast": "node scripts/run-local-bun.mjs scripts/run-test-suite.mjs smoke",
|
|
83
|
+
"test:unit": "node scripts/run-local-bun.mjs scripts/run-test-suite.mjs unit",
|
|
84
|
+
"test:integration": "node scripts/run-local-bun.mjs scripts/run-test-suite.mjs integration",
|
|
85
|
+
"test:changed": "node scripts/run-local-bun.mjs scripts/run-test-suite.mjs changed",
|
|
86
|
+
"test:all": "node scripts/run-local-bun.mjs scripts/run-test-suite.mjs all",
|
|
87
|
+
"test:compatibility-tooling": "node scripts/run-compatibility-tests.mjs ultra",
|
|
88
|
+
"test:compatibility-tooling:extended": "node scripts/run-compatibility-tests.mjs extended",
|
|
89
|
+
"test:compatibility-conformance": "node scripts/run-compatibility-tests.mjs conformance",
|
|
88
90
|
start: "node .output/cli.js",
|
|
89
91
|
"start:backend": "node .output/cli.js --backend-only --no-open",
|
|
90
92
|
"preview:ui": "vite preview --config vite.ui.config.ts",
|
|
@@ -126,6 +128,9 @@ var init_package = __esm({
|
|
|
126
128
|
lint: "eslint . --cache --cache-location .cache/eslintcache",
|
|
127
129
|
format: "biome format --write .",
|
|
128
130
|
"format:check": "biome format .",
|
|
131
|
+
"verify:ultra": "node scripts/compatibility/ultra-gate.mjs",
|
|
132
|
+
"verify:ultra:fresh": "node scripts/compatibility/ultra-gate.mjs --no-cache",
|
|
133
|
+
"verify:ultra:smoke": "npm run verify:ultra && npm run test:smoke",
|
|
129
134
|
"verify:fast": "bun scripts/run-static-checks.mjs --format && bun test:changed",
|
|
130
135
|
"extension:zip": "node scripts/pack-chrome-extension.mjs",
|
|
131
136
|
"extension:release": "node scripts/release-chrome-extension.mjs",
|
|
@@ -161,9 +166,9 @@ var init_package = __esm({
|
|
|
161
166
|
zod: "^4.4.3"
|
|
162
167
|
},
|
|
163
168
|
optionalDependencies: {
|
|
164
|
-
"@tonyclaw/agent-inspector-backend-darwin-arm64": "3.1.
|
|
165
|
-
"@tonyclaw/agent-inspector-backend-linux-x64-gnu": "3.1.
|
|
166
|
-
"@tonyclaw/agent-inspector-backend-win32-x64-msvc": "3.1.
|
|
169
|
+
"@tonyclaw/agent-inspector-backend-darwin-arm64": "3.1.5",
|
|
170
|
+
"@tonyclaw/agent-inspector-backend-linux-x64-gnu": "3.1.5",
|
|
171
|
+
"@tonyclaw/agent-inspector-backend-win32-x64-msvc": "3.1.5",
|
|
167
172
|
"better-sqlite3": "^12.11.1",
|
|
168
173
|
rcedit: "4.0.1"
|
|
169
174
|
},
|
|
@@ -22107,6 +22112,7 @@ var CaptureIncompleteReasonSchema = external_exports.enum([
|
|
|
22107
22112
|
"pipeline-closed",
|
|
22108
22113
|
"write-failed",
|
|
22109
22114
|
"finalize-failed",
|
|
22115
|
+
"finalize-timeout",
|
|
22110
22116
|
"upstream-stream-error",
|
|
22111
22117
|
"shutdown"
|
|
22112
22118
|
]);
|
|
@@ -23115,6 +23121,9 @@ async function initLogger() {
|
|
|
23115
23121
|
}
|
|
23116
23122
|
var loggerInitialization = null;
|
|
23117
23123
|
var applicationLogWriteQueue = Promise.resolve();
|
|
23124
|
+
var lastApplicationLogWriteFailureKey = null;
|
|
23125
|
+
var lastApplicationLogWriteFailureAt = 0;
|
|
23126
|
+
var APPLICATION_LOG_WRITE_FAILURE_SUPPRESS_MS = 5e3;
|
|
23118
23127
|
function ensureLoggerInitialized() {
|
|
23119
23128
|
if (loggerInitialization === null) loggerInitialization = initLogger();
|
|
23120
23129
|
return loggerInitialization;
|
|
@@ -23145,7 +23154,21 @@ async function writeAppLog(message) {
|
|
|
23145
23154
|
const write = async () => {
|
|
23146
23155
|
await initialization;
|
|
23147
23156
|
const result = await appendApplicationLogLine(logPath, line, getApplicationLogPolicy());
|
|
23148
|
-
if (!result.ok)
|
|
23157
|
+
if (!result.ok) {
|
|
23158
|
+
const key = `${logPath}:${String(result.reason)}`;
|
|
23159
|
+
const now = Date.now();
|
|
23160
|
+
if (key !== lastApplicationLogWriteFailureKey || now - lastApplicationLogWriteFailureAt >= APPLICATION_LOG_WRITE_FAILURE_SUPPRESS_MS) {
|
|
23161
|
+
lastApplicationLogWriteFailureKey = key;
|
|
23162
|
+
lastApplicationLogWriteFailureAt = now;
|
|
23163
|
+
writeStderrFallback(`[logger] Failed to write to ${logPath}:`, result.reason);
|
|
23164
|
+
}
|
|
23165
|
+
return;
|
|
23166
|
+
}
|
|
23167
|
+
if (lastApplicationLogWriteFailureKey !== null) {
|
|
23168
|
+
writeStderrFallback(`[logger] Application log writes recovered for ${logPath}:`, "ok");
|
|
23169
|
+
lastApplicationLogWriteFailureKey = null;
|
|
23170
|
+
lastApplicationLogWriteFailureAt = 0;
|
|
23171
|
+
}
|
|
23149
23172
|
};
|
|
23150
23173
|
applicationLogWriteQueue = applicationLogWriteQueue.then(write, write);
|
|
23151
23174
|
await applicationLogWriteQueue;
|
|
@@ -1162,7 +1162,7 @@ var getBaseManifest = getProdBaseManifest;
|
|
|
1162
1162
|
var createEarlyHintsForRequest = createEarlyHintsCollector;
|
|
1163
1163
|
async function loadEntries() {
|
|
1164
1164
|
const [routerEntry, startEntry, pluginAdapters] = await Promise.all([
|
|
1165
|
-
import("./router-
|
|
1165
|
+
import("./router-DoTLo_6Y.mjs"),
|
|
1166
1166
|
import("./start-COQu_AgD.mjs"),
|
|
1167
1167
|
import("./empty-plugin-adapters-BFgPZ6_d.mjs")
|
|
1168
1168
|
]);
|
|
@@ -430,6 +430,7 @@ const CaptureIncompleteReasonSchema = _enum([
|
|
|
430
430
|
"pipeline-closed",
|
|
431
431
|
"write-failed",
|
|
432
432
|
"finalize-failed",
|
|
433
|
+
"finalize-timeout",
|
|
433
434
|
"upstream-stream-error",
|
|
434
435
|
"shutdown"
|
|
435
436
|
]);
|
|
@@ -1493,6 +1494,9 @@ async function initLogger() {
|
|
|
1493
1494
|
}
|
|
1494
1495
|
let loggerInitialization = null;
|
|
1495
1496
|
let applicationLogWriteQueue = Promise.resolve();
|
|
1497
|
+
let lastApplicationLogWriteFailureKey = null;
|
|
1498
|
+
let lastApplicationLogWriteFailureAt = 0;
|
|
1499
|
+
const APPLICATION_LOG_WRITE_FAILURE_SUPPRESS_MS = 5e3;
|
|
1496
1500
|
function ensureLoggerInitialized() {
|
|
1497
1501
|
if (loggerInitialization === null) loggerInitialization = initLogger();
|
|
1498
1502
|
return loggerInitialization;
|
|
@@ -1523,7 +1527,21 @@ async function writeAppLog(message) {
|
|
|
1523
1527
|
const write = async () => {
|
|
1524
1528
|
await initialization;
|
|
1525
1529
|
const result = await appendApplicationLogLine(logPath, line, getApplicationLogPolicy());
|
|
1526
|
-
if (!result.ok)
|
|
1530
|
+
if (!result.ok) {
|
|
1531
|
+
const key = `${logPath}:${String(result.reason)}`;
|
|
1532
|
+
const now = Date.now();
|
|
1533
|
+
if (key !== lastApplicationLogWriteFailureKey || now - lastApplicationLogWriteFailureAt >= APPLICATION_LOG_WRITE_FAILURE_SUPPRESS_MS) {
|
|
1534
|
+
lastApplicationLogWriteFailureKey = key;
|
|
1535
|
+
lastApplicationLogWriteFailureAt = now;
|
|
1536
|
+
writeStderrFallback(`[logger] Failed to write to ${logPath}:`, result.reason);
|
|
1537
|
+
}
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
if (lastApplicationLogWriteFailureKey !== null) {
|
|
1541
|
+
writeStderrFallback(`[logger] Application log writes recovered for ${logPath}:`, "ok");
|
|
1542
|
+
lastApplicationLogWriteFailureKey = null;
|
|
1543
|
+
lastApplicationLogWriteFailureAt = 0;
|
|
1544
|
+
}
|
|
1527
1545
|
};
|
|
1528
1546
|
applicationLogWriteQueue = applicationLogWriteQueue.then(write, write);
|
|
1529
1547
|
await applicationLogWriteQueue;
|
|
@@ -6196,6 +6214,7 @@ function analyzeToolSchemaWarnings(input) {
|
|
|
6196
6214
|
return uniqueWarnings(warnings);
|
|
6197
6215
|
}
|
|
6198
6216
|
const DEFAULT_MAX_FINALIZE_STREAM_BYTES = 20 * 1024 * 1024;
|
|
6217
|
+
const DEFAULT_FINALIZE_JOB_TIMEOUT_MS = 15e3;
|
|
6199
6218
|
function resolveMaxFinalizeStreamBytes() {
|
|
6200
6219
|
const raw = process.env["AGENT_INSPECTOR_MAX_FINALIZE_STREAM_BYTES"];
|
|
6201
6220
|
if (raw === void 0 || raw === "") return DEFAULT_MAX_FINALIZE_STREAM_BYTES;
|
|
@@ -6203,6 +6222,13 @@ function resolveMaxFinalizeStreamBytes() {
|
|
|
6203
6222
|
if (!Number.isFinite(parsed) || parsed < 1) return DEFAULT_MAX_FINALIZE_STREAM_BYTES;
|
|
6204
6223
|
return Math.floor(parsed);
|
|
6205
6224
|
}
|
|
6225
|
+
function resolveFinalizeJobTimeoutMs() {
|
|
6226
|
+
const raw = process.env["AGENT_INSPECTOR_FINALIZE_JOB_TIMEOUT_MS"];
|
|
6227
|
+
if (raw === void 0 || raw === "") return DEFAULT_FINALIZE_JOB_TIMEOUT_MS;
|
|
6228
|
+
const parsed = Number(raw);
|
|
6229
|
+
if (!Number.isFinite(parsed) || parsed < 100) return DEFAULT_FINALIZE_JOB_TIMEOUT_MS;
|
|
6230
|
+
return Math.floor(parsed);
|
|
6231
|
+
}
|
|
6206
6232
|
function buildFileLogEntry(log, upstreamUrl) {
|
|
6207
6233
|
return {
|
|
6208
6234
|
timestamp: log.timestamp,
|
|
@@ -6550,6 +6576,39 @@ function buildFinalizeLogResult(job) {
|
|
|
6550
6576
|
}
|
|
6551
6577
|
}
|
|
6552
6578
|
}
|
|
6579
|
+
function buildFinalizeTimeoutResult(job, timeoutMs) {
|
|
6580
|
+
const log = cloneLog(job.log);
|
|
6581
|
+
const message = `Log finalization timed out after ${String(timeoutMs)}ms`;
|
|
6582
|
+
log.elapsedMs = job.elapsedMs;
|
|
6583
|
+
applyOptionalStreamingTiming(log, job);
|
|
6584
|
+
let fallbackStatus = 499;
|
|
6585
|
+
let cleanupRawStreamPath = null;
|
|
6586
|
+
switch (job.type) {
|
|
6587
|
+
case "non-streaming":
|
|
6588
|
+
case "streaming":
|
|
6589
|
+
fallbackStatus = job.responseStatus;
|
|
6590
|
+
cleanupRawStreamPath = job.type === "streaming" ? cleanupPathForRawStream(job.rawStream) : null;
|
|
6591
|
+
break;
|
|
6592
|
+
case "stream-abort":
|
|
6593
|
+
cleanupRawStreamPath = cleanupPathForRawStream(job.rawStream);
|
|
6594
|
+
break;
|
|
6595
|
+
default: {
|
|
6596
|
+
const _exhaustive = job;
|
|
6597
|
+
logger.error(`[logFinalizer] Unhandled timeout job type: ${JSON.stringify(_exhaustive)}`);
|
|
6598
|
+
}
|
|
6599
|
+
}
|
|
6600
|
+
log.responseStatus = log.responseStatus ?? fallbackStatus;
|
|
6601
|
+
log.responseText = log.responseText ?? message;
|
|
6602
|
+
log.captureIncomplete = true;
|
|
6603
|
+
log.captureIncompleteReason = "finalize-timeout";
|
|
6604
|
+
log.error = message;
|
|
6605
|
+
return {
|
|
6606
|
+
log,
|
|
6607
|
+
upstreamUrl: job.upstreamUrl,
|
|
6608
|
+
error: message,
|
|
6609
|
+
cleanupRawStreamPath
|
|
6610
|
+
};
|
|
6611
|
+
}
|
|
6553
6612
|
async function commitFinalizeLogResult(result) {
|
|
6554
6613
|
const persistedError = result.log.captureIncompleteReason === "upstream-stream-error" ? result.log.error ?? result.error ?? null : result.error ?? result.log.error ?? null;
|
|
6555
6614
|
result.log.error = persistedError;
|
|
@@ -6693,7 +6752,25 @@ function executeBuildInWorker(job) {
|
|
|
6693
6752
|
});
|
|
6694
6753
|
}
|
|
6695
6754
|
function executeFinalizeLogJob(job) {
|
|
6696
|
-
|
|
6755
|
+
const timeoutMs = resolveFinalizeJobTimeoutMs();
|
|
6756
|
+
let timeout = null;
|
|
6757
|
+
const buildPromise = resolveBuildPromise(job);
|
|
6758
|
+
const timeoutPromise = new Promise((resolve2) => {
|
|
6759
|
+
timeout = setTimeout(() => {
|
|
6760
|
+
logger.error(
|
|
6761
|
+
`[logFinalizer] Finalize job timed out for log #${job.log.id} after ${String(timeoutMs)}ms`
|
|
6762
|
+
);
|
|
6763
|
+
resolve2(buildFinalizeTimeoutResult(job, timeoutMs));
|
|
6764
|
+
}, timeoutMs);
|
|
6765
|
+
});
|
|
6766
|
+
void buildPromise.catch((err) => {
|
|
6767
|
+
logger.error(
|
|
6768
|
+
`[logFinalizer] Late finalize build failure for log #${job.log.id}:`,
|
|
6769
|
+
errorMessage$2(err)
|
|
6770
|
+
);
|
|
6771
|
+
});
|
|
6772
|
+
return Promise.race([buildPromise, timeoutPromise]).then(async (result) => {
|
|
6773
|
+
if (timeout !== null) clearTimeout(timeout);
|
|
6697
6774
|
await commitFinalizeLogResult(result);
|
|
6698
6775
|
if (result.error !== null && result.error !== "Client aborted") {
|
|
6699
6776
|
return Promise.reject(new Error(result.error));
|
|
@@ -9554,6 +9631,8 @@ function injectProviderAuth(headers, provider) {
|
|
|
9554
9631
|
const ALLOW_LOOPBACK$2 = process.env["AGENT_INSPECTOR_ALLOW_LOOPBACK"] === "1";
|
|
9555
9632
|
const EMPTY_UPSTREAM_BODY_ERROR = "Upstream response did not include a body";
|
|
9556
9633
|
const UPSTREAM_STREAM_ERROR = "Upstream stream terminated unexpectedly";
|
|
9634
|
+
const UPSTREAM_REQUEST_FAILED = "Proxy error: upstream request failed";
|
|
9635
|
+
const HEADER_ERROR_CODE = "x-agent-inspector-error-code";
|
|
9557
9636
|
function buildProxyHeaders(originalHeaders, captureRawHeaders) {
|
|
9558
9637
|
const rawHeaders = captureRawHeaders ? {} : void 0;
|
|
9559
9638
|
const headers = new Headers();
|
|
@@ -9614,23 +9693,21 @@ function configuredProviderUrlFields(provider) {
|
|
|
9614
9693
|
}
|
|
9615
9694
|
return fields;
|
|
9616
9695
|
}
|
|
9617
|
-
function
|
|
9696
|
+
function unsupportedProviderRoute(model, route, provider) {
|
|
9618
9697
|
if (model === null) {
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
return;
|
|
9698
|
+
const detail2 = `model could not be extracted; path=${route.normalizedPath}; protocol=${protocolLabel(route)}`;
|
|
9699
|
+
logger.warn(`[handler] Unsupported provider route: code=request-model-missing; ${detail2}`);
|
|
9700
|
+
return { code: "request-model-missing", detail: detail2 };
|
|
9623
9701
|
}
|
|
9624
9702
|
if (provider === null) {
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
return;
|
|
9703
|
+
const detail2 = `no Provider matched model=${model}; path=${route.normalizedPath}; protocol=${protocolLabel(route)}`;
|
|
9704
|
+
logger.warn(`[handler] Unsupported provider route: code=provider-not-found; ${detail2}`);
|
|
9705
|
+
return { code: "provider-not-found", detail: detail2 };
|
|
9629
9706
|
}
|
|
9630
9707
|
const configuredFields = configuredProviderUrlFields(provider);
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9708
|
+
const detail = `Provider "${provider.name}" (${provider.id}) matched model=${model}, but request path ${route.normalizedPath} requires ${protocolLabel(route)} via ${requiredProviderUrlField(route)}; configured URL fields=${configuredFields.length > 0 ? configuredFields.join(",") : "none"}`;
|
|
9709
|
+
logger.warn(`[handler] Unsupported provider route: code=provider-route-mismatch; ${detail}`);
|
|
9710
|
+
return { code: "provider-route-mismatch", detail };
|
|
9634
9711
|
}
|
|
9635
9712
|
async function readBodyWithLimit(req, limitBytes) {
|
|
9636
9713
|
if (req.body === null || req.method === "GET" || req.method === "HEAD") {
|
|
@@ -9884,8 +9961,13 @@ async function handleAdmittedProxy(req) {
|
|
|
9884
9961
|
const matchedProviderConfig = model !== null ? findProviderByModel(model) : null;
|
|
9885
9962
|
const route = describeApiRoute(parsed.apiPath);
|
|
9886
9963
|
if (model === null || matchedProviderConfig === null || !providerSupportsApiRoute(route, matchedProviderConfig)) {
|
|
9887
|
-
|
|
9888
|
-
return new Response("Forbidden: unsupported provider", {
|
|
9964
|
+
const unsupported = unsupportedProviderRoute(model, route, matchedProviderConfig);
|
|
9965
|
+
return new Response("Forbidden: unsupported provider", {
|
|
9966
|
+
status: STATUS_FORBIDDEN,
|
|
9967
|
+
headers: {
|
|
9968
|
+
[HEADER_ERROR_CODE]: unsupported.code
|
|
9969
|
+
}
|
|
9970
|
+
});
|
|
9889
9971
|
}
|
|
9890
9972
|
const upstreamBase = selectUpstreamBase(route, matchedProviderConfig);
|
|
9891
9973
|
const upstreamUrl = buildUpstreamUrl(upstreamBase, parsed.normalizedPath);
|
|
@@ -9958,12 +10040,14 @@ async function handleAdmittedProxy(req) {
|
|
|
9958
10040
|
await persistFinalizedLogUpdate(log);
|
|
9959
10041
|
return new Response("Client aborted", { status: 499 });
|
|
9960
10042
|
}
|
|
9961
|
-
|
|
10043
|
+
const upstreamError = errorMessage(err);
|
|
10044
|
+
logger.error(`[handler] Proxy error: ${req.method} ${parsed.apiPath}`, upstreamError);
|
|
9962
10045
|
log.responseStatus = STATUS_BAD_GATEWAY;
|
|
9963
|
-
log.responseText =
|
|
9964
|
-
|
|
10046
|
+
log.responseText = upstreamError;
|
|
10047
|
+
log.error = upstreamError;
|
|
10048
|
+
appendLogEntry({ ...buildFileLogEntry(log, upstreamUrl), error: upstreamError });
|
|
9965
10049
|
await persistFinalizedLogUpdate(log);
|
|
9966
|
-
return new Response(
|
|
10050
|
+
return new Response(UPSTREAM_REQUEST_FAILED, { status: STATUS_BAD_GATEWAY });
|
|
9967
10051
|
}
|
|
9968
10052
|
const isStream = upstreamRes.headers.get(HEADER_CONTENT_TYPE)?.includes(CONTENT_TYPE_EVENT_STREAM) ?? false;
|
|
9969
10053
|
if (!isStream) {
|
|
@@ -13633,7 +13717,7 @@ const Route$K = createFileRoute("/api/models")({
|
|
|
13633
13717
|
}
|
|
13634
13718
|
});
|
|
13635
13719
|
const name = "@tonyclaw/agent-inspector";
|
|
13636
|
-
const version = "3.1.
|
|
13720
|
+
const version = "3.1.5";
|
|
13637
13721
|
const packageJson = {
|
|
13638
13722
|
name,
|
|
13639
13723
|
version
|
package/.output/server/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ const assets = {
|
|
|
20
20
|
"/assets/index-D4LX-sw-.js": {
|
|
21
21
|
"type": "text/javascript; charset=utf-8",
|
|
22
22
|
"etag": '"4ca46-80Birfu694YvXXxcAJa6ekM4QWE"',
|
|
23
|
-
"mtime": "2026-07-
|
|
23
|
+
"mtime": "2026-07-18T08:49:42.190Z",
|
|
24
24
|
"size": 313926,
|
|
25
25
|
"path": "../backend-public/assets/index-D4LX-sw-.js"
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as t,x as f,C as z,E as ne}from"./index-MPPOjigU.js";import{c as re,g as A,r as D,a as R,X as ae,B as oe,R as ie,C as de,M as V,b as J,d as B,e as F,f as le,h as ce,L as ue}from"./ProxyViewerContainer-BhmwJbt3.js";const me=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],xe=re("equal",me),fe="";function y(e){if(e.length===0)return fe;let s="";for(let n=0;n<e.length;n++){const a=e[n];a!==void 0&&(typeof a=="number"?s+=`[${a}]`:n===0?s+=a:s+=`.${a}`)}return s}function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e){if(typeof e=="string")try{return C(JSON.parse(e))}catch{return{kind:"primitive",value:e}}return C(e)}function C(e){if(e===null)return{kind:"primitive",value:null};if(typeof e=="string")return{kind:"primitive",value:e};if(typeof e=="number")return{kind:"primitive",value:e};if(typeof e=="boolean")return{kind:"primitive",value:e};if(Array.isArray(e))return{kind:"array",value:e.map(s=>C(s))};if(pe(e)){const s={};for(const n of Object.keys(e).sort())s[n]=C(e[n]);return{kind:"object",value:s}}return{kind:"primitive",value:null}}function he(e,s){const n=[];return S([],e,s,n),n}function S(e,s,n,a){const c=y(e);if(q(s,n)){a.push({kind:"equal",path:c,value:s});return}if(s.kind!==n.kind){a.push({kind:"changed",path:c,left:s,right:n});return}if(s.kind==="primitive"&&n.kind==="primitive"){a.push({kind:"changed",path:c,left:s,right:n});return}if(s.kind==="object"&&n.kind==="object"){const l=Object.keys(s.value),r=Object.keys(n.value),o=new Set(r);for(const d of l){const x=s.value[d];if(x!==void 0)if(!o.has(d))a.push({kind:"removed",path:y([...e,d]),value:x});else{const h=n.value[d];if(h===void 0)continue;S([...e,d],x,h,a)}}for(const d of r){if(l.includes(d))continue;const x=n.value[d];x!==void 0&&a.push({kind:"added",path:y([...e,d]),value:x})}return}if(s.kind==="array"&&n.kind==="array"){const l=Math.min(s.value.length,n.value.length);for(let r=0;r<l;r++){const o=s.value[r],d=n.value[r];o===void 0||d===void 0||S([...e,r],o,d,a)}for(let r=l;r<n.value.length;r++){const o=n.value[r];o!==void 0&&a.push({kind:"added",path:y([...e,r]),value:o})}for(let r=l;r<s.value.length;r++){const o=s.value[r];o!==void 0&&a.push({kind:"removed",path:y([...e,r]),value:o})}}}function q(e,s){if(e.kind!==s.kind)return!1;if(e.kind==="primitive"&&s.kind==="primitive")return e.value===s.value;if(e.kind==="array"&&s.kind==="array"){if(e.value.length!==s.value.length)return!1;for(let n=0;n<e.value.length;n++){const a=e.value[n],c=s.value[n];if(a===void 0||c===void 0||!q(a,c))return!1}return!0}if(e.kind==="object"&&s.kind==="object"){const n=Object.keys(e.value),a=Object.keys(s.value);if(n.length!==a.length)return!1;for(const c of n){const l=e.value[c],r=s.value[c];if(l===void 0||r===void 0||!q(l,r))return!1}return!0}return!1}function v(e,s=80){let n;switch(e.kind){case"primitive":n=e.value===null?"null":JSON.stringify(e.value);break;case"array":n=`[… ${e.value.length} items]`;break;case"object":n=`{… ${Object.keys(e.value).length} keys}`;break}return n.length>s&&(n=`${n.slice(0,s-1)}…`),n}const be="flex flex-col gap-3 border-b border-border px-3 py-3 sm:flex-row sm:items-start sm:gap-4 sm:px-4",ge="grid min-w-0 grid-cols-1 gap-x-2 gap-y-0.5 px-3 py-2 text-xs md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]";function N(e,s=2){return JSON.stringify(T(e),null,s)}function T(e){switch(e.kind){case"primitive":return e.value;case"array":return e.value.map(T);case"object":{const s={};for(const[n,a]of Object.entries(e.value))s[n]=T(a);return s}}}function w({text:e,defaultExpandDepth:s}){return t.jsx(p.Suspense,{fallback:t.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:t.jsx(ue,{text:e,defaultExpandDepth:s})})}function _(e){if(e==="")return"";for(let s=e.length-1;s>=0;s--){const n=e[s];if(n==="."||n==="[")return e.substring(0,s)}return""}function K(e){return e.kind==="equal"&&(e.value.kind==="object"||e.value.kind==="array")}function ve(e){const s=[];let n=0;for(;n<e.length;){const a=e[n];if(a!==void 0&&K(a)){const c=_(a.path);let l=n+1;for(;l<e.length;){const r=e[l];if(r===void 0||!K(r)||_(r.path)!==c)break;l++}if(l-n>1){const r=[];for(let o=n;o<l;o++){const d=e[o];d!==void 0&&d.kind==="equal"&&r.push(d)}s.push({kind:"equal-run",ops:r}),n=l;continue}}a!==void 0&&s.push({kind:"single",op:a}),n++}return s}const H={added:{icon:J,accent:"text-status-success",bg:"bg-status-success/5 hover:bg-status-success/10",border:"border-l-status-success",label:"ADDED"},removed:{icon:V,accent:"text-status-danger",bg:"bg-status-danger/5 hover:bg-status-danger/10",border:"border-l-status-danger",label:"REMOVED"},changed:{icon:B,accent:"text-status-watch",bg:"bg-status-watch/5 hover:bg-status-watch/10",border:"border-l-status-watch",label:"CHANGED"},equal:{icon:xe,accent:"text-muted-foreground/70",bg:"bg-muted/20 hover:bg-muted/30",border:"border-l-muted-foreground/20",label:"EQUAL"}};function ke({ops:e,expanded:s,onToggle:n}){const a=e[0],c=e[e.length-1];if(a===void 0||c===void 0)return t.jsx("div",{className:"text-muted-foreground/40 text-xs",children:"—"});const l=a.path,r=c.path,o=e.length===1?l:`${l} … ${r}`,d=a.value.kind==="array"?`${e.length} equal arrays`:a.value.kind==="object"?`${e.length} equal objects`:"equal",x=H.equal;return t.jsxs("div",{className:f("border-l-4 rounded-sm",x.border,x.bg),children:[t.jsxs("button",{type:"button",onClick:n,className:"w-full text-left flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground cursor-pointer",children:[t.jsx(F,{className:f("size-3 transition-transform shrink-0",s&&"rotate-90")}),t.jsx(x.icon,{className:f("size-3 shrink-0",x.accent)}),t.jsx("span",{className:"font-mono truncate flex-1",title:`${l} … ${r}`,children:o}),t.jsx("span",{className:f("text-[10px] uppercase tracking-wider shrink-0",x.accent),children:x.label}),t.jsxs("span",{className:"text-muted-foreground/60 shrink-0",children:["(",d,")"]})]}),s&&t.jsx("div",{className:"ml-5 mt-1 mb-2 space-y-2 pr-2",children:e.map(h=>t.jsxs("div",{className:"border border-border/50 rounded p-2 bg-muted/20",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:h.path}),t.jsx(w,{text:N(h.value),defaultExpandDepth:0})]},h.path))})]})}function je({op:e,idx:s,copiedPath:n,onCopyPath:a,expanded:c,onToggle:l}){const r=H[e.kind],o=r.icon,d=e.kind==="added"||e.kind==="removed"?e.value.kind==="object"||e.value.kind==="array":e.kind==="changed"?e.left.kind==="object"||e.left.kind==="array"||e.right.kind==="object"||e.right.kind==="array":!1,x=e.kind==="changed"?[{text:v(e.left,400),tone:"text-status-danger line-through"},{text:v(e.right,400),tone:"text-status-success"}]:e.kind==="removed"?[{text:v(e.value,400),tone:"text-status-danger line-through"}]:e.kind==="added"?[{text:v(e.value,400),tone:"text-status-success"}]:[{text:v(e.value,400),tone:"text-muted-foreground"}],h=n===e.path&&e.path!=="";return t.jsxs("div",{"data-diff-idx":s,"data-diff-kind":e.kind,className:f("border-l-4 rounded-sm px-3 py-2 my-0.5 transition-colors",r.border,r.bg),children:[t.jsxs("button",{type:"button",onClick:l,disabled:!d,className:f("w-full flex items-center gap-2 text-xs text-left rounded-sm",d?"cursor-pointer":"cursor-default"),"aria-expanded":d?c:void 0,"aria-label":d?c?`Collapse ${e.path||"root"}`:`Expand ${e.path||"root"}`:void 0,children:[d?t.jsx(F,{className:f("size-3 shrink-0 transition-transform",r.accent,c&&"rotate-90")}):t.jsx("span",{className:"size-3 shrink-0","aria-hidden":"true"}),t.jsx(o,{className:f("size-3.5 shrink-0",r.accent),strokeWidth:2.5}),t.jsx("span",{className:"font-mono truncate flex-1 min-w-0",title:e.path||"(root)",children:e.path===""?"(root)":e.path}),t.jsx("span",{className:f("text-[9px] font-bold uppercase tracking-wider shrink-0 px-1.5 py-0.5 rounded",r.accent,e.kind==="equal"?"bg-muted/40":"bg-background/60"),children:r.label}),e.path!==""&&t.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),a(e.path)},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.stopPropagation(),b.preventDefault(),a(e.path))},className:f("shrink-0 p-1 rounded transition-colors cursor-pointer inline-flex items-center justify-center",h?"text-status-success":"text-muted-foreground/50 hover:text-foreground hover:bg-muted"),"aria-label":h?"Copied":"Copy",title:h?"Copied!":"Copy",children:h?t.jsx(le,{className:"size-3"}):t.jsx(ce,{className:"size-3"})})]}),x.map((b,E)=>t.jsx("div",{className:f("font-mono text-xs mt-1 break-all pl-5",b.tone),children:b.text},E)),t.jsx("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:c&&d?"2000px":"0"},"aria-hidden":!c,children:c&&d&&e.kind!=="equal"?t.jsx(ye,{op:e}):null})]})}function ye({op:e}){if(e.kind==="added"||e.kind==="removed")return t.jsx("div",{className:"pl-5 mt-2 border border-border/50 rounded p-2 bg-muted/20",children:t.jsx(w,{text:N(e.value),defaultExpandDepth:0})});const s=e.left.kind==="object"||e.left.kind==="array",n=e.right.kind==="object"||e.right.kind==="array";return!s&&!n?t.jsx("div",{className:"pl-5 mt-2 text-xs text-muted-foreground/70 italic",children:"Primitive values are shown inline above."}):t.jsxs("div",{className:"pl-5 mt-2 grid grid-cols-1 md:grid-cols-2 gap-2",children:[t.jsxs("div",{className:"rounded border border-status-danger/30 bg-status-danger/5 p-2",children:[t.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-status-danger",children:"Old"}),t.jsx(w,{text:N(e.left),defaultExpandDepth:0})]}),t.jsxs("div",{className:"rounded border border-status-success/30 bg-status-success/5 p-2",children:[t.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-status-success",children:"New"}),t.jsx(w,{text:N(e.right),defaultExpandDepth:0})]})]})}function Ne({counts:e,onJumpTo:s}){const n=e.added+e.removed+e.changed;return t.jsxs("div",{className:"px-4 py-2 border-b border-border bg-muted/20 flex items-center gap-2 text-xs flex-wrap",children:[t.jsxs("span",{className:"text-muted-foreground font-medium",children:[n," ",n===1?"change":"changes"]}),t.jsxs("button",{type:"button",onClick:()=>s("removed"),disabled:e.removed===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.removed>0?"border-status-danger/40 bg-status-danger/10 text-status-danger hover:bg-status-danger/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.removed>0?"Jump to first removed":"No removals",children:[t.jsx(V,{className:"size-3"}),e.removed," removed"]}),t.jsxs("button",{type:"button",onClick:()=>s("added"),disabled:e.added===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.added>0?"border-status-success/40 bg-status-success/10 text-status-success hover:bg-status-success/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.added>0?"Jump to first added":"No additions",children:[t.jsx(J,{className:"size-3"}),e.added," added"]}),t.jsxs("button",{type:"button",onClick:()=>s("changed"),disabled:e.changed===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.changed>0?"border-status-watch/40 bg-status-watch/10 text-status-watch hover:bg-status-watch/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.changed>0?"Jump to first changed":"No changes",children:[t.jsx(B,{className:"size-3"}),e.changed," changed"]})]})}function we({mode:e,onChange:s}){return t.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>s("unified"),"aria-pressed":e==="unified",className:f("flex items-center gap-1 px-2 py-1 text-xs transition-colors cursor-pointer",e==="unified"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Unified view (single column, emphasized diffs)",children:[t.jsx(ie,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>s("split"),"aria-pressed":e==="split",className:f("flex items-center gap-1 px-2 py-1 text-xs transition-colors border-l border-border cursor-pointer",e==="split"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Split view (path | left | right)",children:[t.jsx(de,{className:"size-3"}),"Split"]})]})}function M({log:e,side:s,displayNumber:n}){const a=R(e);return t.jsxs("div",{className:"flex-1 min-w-0 space-y-1 text-xs",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(oe,{variant:"outline",className:f("text-[10px] px-1.5 py-0 h-5 font-mono shrink-0",s==="left"?"border-status-danger/40 text-status-danger":"border-status-success/40 text-status-success"),children:s==="left"?"← Left":"Right →"}),t.jsxs("span",{className:"font-mono text-status-info",title:`Log ID ${String(e.id)}`,children:["#",n]}),e.model!==null&&t.jsx("span",{className:"min-w-0 truncate font-mono leading-snug text-muted-foreground",children:e.model})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 font-mono text-muted-foreground",children:[e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&t.jsxs("span",{className:"text-status-success",children:["KV Cache +",z(e.cacheCreationInputTokens)]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&t.jsxs("span",{className:"text-status-accent",children:["KV Cache ~",z(e.cacheReadInputTokens)]}),t.jsx("span",{className:"truncate",title:e.timestamp,children:e.timestamp})]}),t.jsxs("div",{className:"text-muted-foreground/70 font-mono truncate",title:a,children:["session: ",a]})]})}function Se({left:e,right:s,leftDisplayNumber:n,rightDisplayNumber:a,onClose:c}){const l=p.useRef(null),r=p.useRef(null),o=p.useRef(null),d=p.useMemo(()=>{const i=A(D(e)).analyzeRequest(e.rawRequestBody),u=A(D(s)).analyzeRequest(s.rawRequestBody),m=$(i.comparisonValue),g=$(u.comparisonValue);return he(m,g)},[e.apiFormat,e.path,e.rawRequestBody,s.apiFormat,s.path,s.rawRequestBody]),x=p.useMemo(()=>ve(d),[d]),h=p.useMemo(()=>{let i=0,u=0,m=0;for(const g of x)if(g.kind==="single")switch(g.op.kind){case"added":i++;break;case"removed":u++;break;case"changed":m++;break}return{added:i,removed:u,changed:m}},[x]),[b,E]=p.useState(new Set),U=i=>{E(u=>{const m=new Set(u);return m.has(i)?m.delete(i):m.add(i),m})},[G,I]=p.useState(new Set),Q=i=>{I(u=>{const m=new Set(u);return m.has(i)?m.delete(i):m.add(i),m})};p.useEffect(()=>{I(new Set)},[e.id,s.id]);const[O,W]=p.useState("unified"),P=p.useRef(null),[X,L]=p.useState(null),j=p.useRef(null),Y=i=>{ne(i).then(u=>{u&&(L(i),j.current!==null&&clearTimeout(j.current),j.current=setTimeout(()=>L(null),1500))})};p.useEffect(()=>()=>{j.current!==null&&clearTimeout(j.current)},[]);const Z=i=>{const u=x.findIndex(k=>k.kind==="single"&&k.op.kind===i);if(u===-1)return;const m=P.current;if(m===null)return;const g=m.querySelector(`[data-diff-idx="${u}"]`);g!==null&&g.scrollIntoView({behavior:"smooth",block:"center"})};p.useEffect(()=>{o.current=document.activeElement instanceof HTMLElement?document.activeElement:null,r.current?.focus();const i=m=>{m.key==="Escape"&&c()};document.addEventListener("keydown",i);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=u,o.current?.focus()}},[c]);const ee=i=>{if(i.stopPropagation(),i.key!=="Tab")return;const u=l.current;if(u===null)return;const m=Array.from(u.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')),g=m[0],k=m[m.length-1];if(!(g===void 0||k===void 0)){if(i.shiftKey&&document.activeElement===g){i.preventDefault(),k.focus();return}!i.shiftKey&&document.activeElement===k&&(i.preventDefault(),g.focus())}},te=R(e)===R(s),se=d.length===1&&d[0]?.kind==="equal";return t.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",role:"dialog","aria-modal":"true","aria-label":"Compare two log requests",children:[t.jsx("button",{type:"button",onClick:c,"aria-label":"Close compare drawer",className:"absolute inset-0 bg-black/40 cursor-default",tabIndex:-1}),t.jsxs("div",{ref:l,className:f("relative overflow-x-hidden bg-background border-l border-border shadow-xl","w-full md:w-[70vw] max-w-[1100px] flex flex-col h-full"),onClick:i=>i.stopPropagation(),onKeyDown:ee,children:[t.jsxs("div",{className:be,children:[t.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:[t.jsx(M,{log:e,side:"left",displayNumber:n}),t.jsx(M,{log:s,side:"right",displayNumber:a})]}),t.jsxs("div",{className:"flex w-full shrink-0 items-center justify-between gap-2 sm:w-auto sm:justify-start",children:[t.jsx(we,{mode:O,onChange:W}),t.jsx("button",{ref:r,type:"button",onClick:c,"aria-label":"Close",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted cursor-pointer",children:t.jsx(ae,{className:"size-4"})})]})]}),!te&&t.jsx("div",{className:"border-b border-border bg-warning/10 px-4 py-1.5 text-xs text-foreground",children:"Heads up: the two selected logs are from different sessions."}),se?t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex items-center justify-center text-muted-foreground text-sm",children:"The two Request payloads are identical."}):t.jsxs(t.Fragment,{children:[t.jsx(Ne,{counts:h,onJumpTo:Z}),t.jsx("div",{ref:P,className:"flex-1 min-h-0 overflow-y-auto",children:O==="unified"?t.jsx("div",{className:"px-3 py-2 space-y-0.5",children:x.map((i,u)=>{if(i.kind==="equal-run")return t.jsx(ke,{ops:i.ops,expanded:b.has(u),onToggle:()=>U(u)},`r${u}`);const m=i.op;return t.jsx(je,{op:m,idx:u,copiedPath:X,onCopyPath:Y,expanded:G.has(u),onToggle:()=>Q(u)},`o${u}`)})}):t.jsx(Ce,{grouped:x,left:e,right:s,leftDisplayNumber:n,rightDisplayNumber:a})})]})]})]})}function Ce({grouped:e,left:s,right:n,leftDisplayNumber:a,rightDisplayNumber:c}){return t.jsxs("div",{"data-compare-layout":"responsive-split",className:ge,children:[t.jsxs("div",{className:"col-span-1 mb-2 grid grid-cols-1 gap-x-2 gap-y-1 border-b border-border pb-2 text-[10px] uppercase tracking-wider text-muted-foreground md:col-span-3 md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]",children:[t.jsx("span",{children:"Path"}),t.jsxs("span",{title:`Log ID ${String(s.id)}`,children:["Left (Log #",a,")"]}),t.jsxs("span",{title:`Log ID ${String(n.id)}`,children:["Right (Log #",c,")"]})]}),e.map((l,r)=>{if(l.kind==="equal-run")return t.jsxs("div",{className:"col-span-1 px-2 py-1 text-xs text-muted-foreground/60 md:col-span-3",children:[l.ops.length," equal siblings collapsed — switch to Unified to expand"]},r);const o=l.op;return o.kind==="equal"?t.jsxs("div",{className:"col-span-1 grid min-w-0 grid-cols-1 gap-x-2 gap-y-1 px-2 py-0.5 text-muted-foreground md:col-span-3 md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]",children:[t.jsx("span",{className:"font-mono text-xs truncate",title:o.path,children:o.path}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)})]},r):o.kind==="added"?t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-success bg-status-success/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-status-success",children:["+ ",v(o.value,400)]})]},r):o.kind==="removed"?t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-danger bg-status-danger/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-status-danger line-through",children:["− ",v(o.value,400)]})]},r):t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-watch bg-status-watch/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:o.path}),t.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[t.jsx("div",{className:"font-mono break-all text-status-danger line-through",children:v(o.left,400)}),t.jsx("div",{className:"font-mono break-all text-status-success",children:v(o.right,400)})]})]},r)})]})}export{be as COMPARE_RESPONSIVE_HEADER_CLASS_NAME,ge as COMPARE_RESPONSIVE_SPLIT_CLASS_NAME,Se as CompareDrawer};
|
|
1
|
+
import{r as p,j as t,x as f,C as z,E as ne}from"./index-feJFJxaj.js";import{c as re,g as A,r as D,a as R,X as ae,B as oe,R as ie,C as de,M as V,b as J,d as B,e as F,f as le,h as ce,L as ue}from"./ProxyViewerContainer-BV4-7dja.js";const me=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],xe=re("equal",me),fe="";function y(e){if(e.length===0)return fe;let s="";for(let n=0;n<e.length;n++){const a=e[n];a!==void 0&&(typeof a=="number"?s+=`[${a}]`:n===0?s+=a:s+=`.${a}`)}return s}function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e){if(typeof e=="string")try{return C(JSON.parse(e))}catch{return{kind:"primitive",value:e}}return C(e)}function C(e){if(e===null)return{kind:"primitive",value:null};if(typeof e=="string")return{kind:"primitive",value:e};if(typeof e=="number")return{kind:"primitive",value:e};if(typeof e=="boolean")return{kind:"primitive",value:e};if(Array.isArray(e))return{kind:"array",value:e.map(s=>C(s))};if(pe(e)){const s={};for(const n of Object.keys(e).sort())s[n]=C(e[n]);return{kind:"object",value:s}}return{kind:"primitive",value:null}}function he(e,s){const n=[];return S([],e,s,n),n}function S(e,s,n,a){const c=y(e);if(q(s,n)){a.push({kind:"equal",path:c,value:s});return}if(s.kind!==n.kind){a.push({kind:"changed",path:c,left:s,right:n});return}if(s.kind==="primitive"&&n.kind==="primitive"){a.push({kind:"changed",path:c,left:s,right:n});return}if(s.kind==="object"&&n.kind==="object"){const l=Object.keys(s.value),r=Object.keys(n.value),o=new Set(r);for(const d of l){const x=s.value[d];if(x!==void 0)if(!o.has(d))a.push({kind:"removed",path:y([...e,d]),value:x});else{const h=n.value[d];if(h===void 0)continue;S([...e,d],x,h,a)}}for(const d of r){if(l.includes(d))continue;const x=n.value[d];x!==void 0&&a.push({kind:"added",path:y([...e,d]),value:x})}return}if(s.kind==="array"&&n.kind==="array"){const l=Math.min(s.value.length,n.value.length);for(let r=0;r<l;r++){const o=s.value[r],d=n.value[r];o===void 0||d===void 0||S([...e,r],o,d,a)}for(let r=l;r<n.value.length;r++){const o=n.value[r];o!==void 0&&a.push({kind:"added",path:y([...e,r]),value:o})}for(let r=l;r<s.value.length;r++){const o=s.value[r];o!==void 0&&a.push({kind:"removed",path:y([...e,r]),value:o})}}}function q(e,s){if(e.kind!==s.kind)return!1;if(e.kind==="primitive"&&s.kind==="primitive")return e.value===s.value;if(e.kind==="array"&&s.kind==="array"){if(e.value.length!==s.value.length)return!1;for(let n=0;n<e.value.length;n++){const a=e.value[n],c=s.value[n];if(a===void 0||c===void 0||!q(a,c))return!1}return!0}if(e.kind==="object"&&s.kind==="object"){const n=Object.keys(e.value),a=Object.keys(s.value);if(n.length!==a.length)return!1;for(const c of n){const l=e.value[c],r=s.value[c];if(l===void 0||r===void 0||!q(l,r))return!1}return!0}return!1}function v(e,s=80){let n;switch(e.kind){case"primitive":n=e.value===null?"null":JSON.stringify(e.value);break;case"array":n=`[… ${e.value.length} items]`;break;case"object":n=`{… ${Object.keys(e.value).length} keys}`;break}return n.length>s&&(n=`${n.slice(0,s-1)}…`),n}const be="flex flex-col gap-3 border-b border-border px-3 py-3 sm:flex-row sm:items-start sm:gap-4 sm:px-4",ge="grid min-w-0 grid-cols-1 gap-x-2 gap-y-0.5 px-3 py-2 text-xs md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]";function N(e,s=2){return JSON.stringify(T(e),null,s)}function T(e){switch(e.kind){case"primitive":return e.value;case"array":return e.value.map(T);case"object":{const s={};for(const[n,a]of Object.entries(e.value))s[n]=T(a);return s}}}function w({text:e,defaultExpandDepth:s}){return t.jsx(p.Suspense,{fallback:t.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:t.jsx(ue,{text:e,defaultExpandDepth:s})})}function _(e){if(e==="")return"";for(let s=e.length-1;s>=0;s--){const n=e[s];if(n==="."||n==="[")return e.substring(0,s)}return""}function K(e){return e.kind==="equal"&&(e.value.kind==="object"||e.value.kind==="array")}function ve(e){const s=[];let n=0;for(;n<e.length;){const a=e[n];if(a!==void 0&&K(a)){const c=_(a.path);let l=n+1;for(;l<e.length;){const r=e[l];if(r===void 0||!K(r)||_(r.path)!==c)break;l++}if(l-n>1){const r=[];for(let o=n;o<l;o++){const d=e[o];d!==void 0&&d.kind==="equal"&&r.push(d)}s.push({kind:"equal-run",ops:r}),n=l;continue}}a!==void 0&&s.push({kind:"single",op:a}),n++}return s}const H={added:{icon:J,accent:"text-status-success",bg:"bg-status-success/5 hover:bg-status-success/10",border:"border-l-status-success",label:"ADDED"},removed:{icon:V,accent:"text-status-danger",bg:"bg-status-danger/5 hover:bg-status-danger/10",border:"border-l-status-danger",label:"REMOVED"},changed:{icon:B,accent:"text-status-watch",bg:"bg-status-watch/5 hover:bg-status-watch/10",border:"border-l-status-watch",label:"CHANGED"},equal:{icon:xe,accent:"text-muted-foreground/70",bg:"bg-muted/20 hover:bg-muted/30",border:"border-l-muted-foreground/20",label:"EQUAL"}};function ke({ops:e,expanded:s,onToggle:n}){const a=e[0],c=e[e.length-1];if(a===void 0||c===void 0)return t.jsx("div",{className:"text-muted-foreground/40 text-xs",children:"—"});const l=a.path,r=c.path,o=e.length===1?l:`${l} … ${r}`,d=a.value.kind==="array"?`${e.length} equal arrays`:a.value.kind==="object"?`${e.length} equal objects`:"equal",x=H.equal;return t.jsxs("div",{className:f("border-l-4 rounded-sm",x.border,x.bg),children:[t.jsxs("button",{type:"button",onClick:n,className:"w-full text-left flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground cursor-pointer",children:[t.jsx(F,{className:f("size-3 transition-transform shrink-0",s&&"rotate-90")}),t.jsx(x.icon,{className:f("size-3 shrink-0",x.accent)}),t.jsx("span",{className:"font-mono truncate flex-1",title:`${l} … ${r}`,children:o}),t.jsx("span",{className:f("text-[10px] uppercase tracking-wider shrink-0",x.accent),children:x.label}),t.jsxs("span",{className:"text-muted-foreground/60 shrink-0",children:["(",d,")"]})]}),s&&t.jsx("div",{className:"ml-5 mt-1 mb-2 space-y-2 pr-2",children:e.map(h=>t.jsxs("div",{className:"border border-border/50 rounded p-2 bg-muted/20",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:h.path}),t.jsx(w,{text:N(h.value),defaultExpandDepth:0})]},h.path))})]})}function je({op:e,idx:s,copiedPath:n,onCopyPath:a,expanded:c,onToggle:l}){const r=H[e.kind],o=r.icon,d=e.kind==="added"||e.kind==="removed"?e.value.kind==="object"||e.value.kind==="array":e.kind==="changed"?e.left.kind==="object"||e.left.kind==="array"||e.right.kind==="object"||e.right.kind==="array":!1,x=e.kind==="changed"?[{text:v(e.left,400),tone:"text-status-danger line-through"},{text:v(e.right,400),tone:"text-status-success"}]:e.kind==="removed"?[{text:v(e.value,400),tone:"text-status-danger line-through"}]:e.kind==="added"?[{text:v(e.value,400),tone:"text-status-success"}]:[{text:v(e.value,400),tone:"text-muted-foreground"}],h=n===e.path&&e.path!=="";return t.jsxs("div",{"data-diff-idx":s,"data-diff-kind":e.kind,className:f("border-l-4 rounded-sm px-3 py-2 my-0.5 transition-colors",r.border,r.bg),children:[t.jsxs("button",{type:"button",onClick:l,disabled:!d,className:f("w-full flex items-center gap-2 text-xs text-left rounded-sm",d?"cursor-pointer":"cursor-default"),"aria-expanded":d?c:void 0,"aria-label":d?c?`Collapse ${e.path||"root"}`:`Expand ${e.path||"root"}`:void 0,children:[d?t.jsx(F,{className:f("size-3 shrink-0 transition-transform",r.accent,c&&"rotate-90")}):t.jsx("span",{className:"size-3 shrink-0","aria-hidden":"true"}),t.jsx(o,{className:f("size-3.5 shrink-0",r.accent),strokeWidth:2.5}),t.jsx("span",{className:"font-mono truncate flex-1 min-w-0",title:e.path||"(root)",children:e.path===""?"(root)":e.path}),t.jsx("span",{className:f("text-[9px] font-bold uppercase tracking-wider shrink-0 px-1.5 py-0.5 rounded",r.accent,e.kind==="equal"?"bg-muted/40":"bg-background/60"),children:r.label}),e.path!==""&&t.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),a(e.path)},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.stopPropagation(),b.preventDefault(),a(e.path))},className:f("shrink-0 p-1 rounded transition-colors cursor-pointer inline-flex items-center justify-center",h?"text-status-success":"text-muted-foreground/50 hover:text-foreground hover:bg-muted"),"aria-label":h?"Copied":"Copy",title:h?"Copied!":"Copy",children:h?t.jsx(le,{className:"size-3"}):t.jsx(ce,{className:"size-3"})})]}),x.map((b,E)=>t.jsx("div",{className:f("font-mono text-xs mt-1 break-all pl-5",b.tone),children:b.text},E)),t.jsx("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:c&&d?"2000px":"0"},"aria-hidden":!c,children:c&&d&&e.kind!=="equal"?t.jsx(ye,{op:e}):null})]})}function ye({op:e}){if(e.kind==="added"||e.kind==="removed")return t.jsx("div",{className:"pl-5 mt-2 border border-border/50 rounded p-2 bg-muted/20",children:t.jsx(w,{text:N(e.value),defaultExpandDepth:0})});const s=e.left.kind==="object"||e.left.kind==="array",n=e.right.kind==="object"||e.right.kind==="array";return!s&&!n?t.jsx("div",{className:"pl-5 mt-2 text-xs text-muted-foreground/70 italic",children:"Primitive values are shown inline above."}):t.jsxs("div",{className:"pl-5 mt-2 grid grid-cols-1 md:grid-cols-2 gap-2",children:[t.jsxs("div",{className:"rounded border border-status-danger/30 bg-status-danger/5 p-2",children:[t.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-status-danger",children:"Old"}),t.jsx(w,{text:N(e.left),defaultExpandDepth:0})]}),t.jsxs("div",{className:"rounded border border-status-success/30 bg-status-success/5 p-2",children:[t.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-status-success",children:"New"}),t.jsx(w,{text:N(e.right),defaultExpandDepth:0})]})]})}function Ne({counts:e,onJumpTo:s}){const n=e.added+e.removed+e.changed;return t.jsxs("div",{className:"px-4 py-2 border-b border-border bg-muted/20 flex items-center gap-2 text-xs flex-wrap",children:[t.jsxs("span",{className:"text-muted-foreground font-medium",children:[n," ",n===1?"change":"changes"]}),t.jsxs("button",{type:"button",onClick:()=>s("removed"),disabled:e.removed===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.removed>0?"border-status-danger/40 bg-status-danger/10 text-status-danger hover:bg-status-danger/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.removed>0?"Jump to first removed":"No removals",children:[t.jsx(V,{className:"size-3"}),e.removed," removed"]}),t.jsxs("button",{type:"button",onClick:()=>s("added"),disabled:e.added===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.added>0?"border-status-success/40 bg-status-success/10 text-status-success hover:bg-status-success/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.added>0?"Jump to first added":"No additions",children:[t.jsx(J,{className:"size-3"}),e.added," added"]}),t.jsxs("button",{type:"button",onClick:()=>s("changed"),disabled:e.changed===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.changed>0?"border-status-watch/40 bg-status-watch/10 text-status-watch hover:bg-status-watch/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.changed>0?"Jump to first changed":"No changes",children:[t.jsx(B,{className:"size-3"}),e.changed," changed"]})]})}function we({mode:e,onChange:s}){return t.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>s("unified"),"aria-pressed":e==="unified",className:f("flex items-center gap-1 px-2 py-1 text-xs transition-colors cursor-pointer",e==="unified"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Unified view (single column, emphasized diffs)",children:[t.jsx(ie,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>s("split"),"aria-pressed":e==="split",className:f("flex items-center gap-1 px-2 py-1 text-xs transition-colors border-l border-border cursor-pointer",e==="split"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Split view (path | left | right)",children:[t.jsx(de,{className:"size-3"}),"Split"]})]})}function M({log:e,side:s,displayNumber:n}){const a=R(e);return t.jsxs("div",{className:"flex-1 min-w-0 space-y-1 text-xs",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(oe,{variant:"outline",className:f("text-[10px] px-1.5 py-0 h-5 font-mono shrink-0",s==="left"?"border-status-danger/40 text-status-danger":"border-status-success/40 text-status-success"),children:s==="left"?"← Left":"Right →"}),t.jsxs("span",{className:"font-mono text-status-info",title:`Log ID ${String(e.id)}`,children:["#",n]}),e.model!==null&&t.jsx("span",{className:"min-w-0 truncate font-mono leading-snug text-muted-foreground",children:e.model})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 font-mono text-muted-foreground",children:[e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&t.jsxs("span",{className:"text-status-success",children:["KV Cache +",z(e.cacheCreationInputTokens)]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&t.jsxs("span",{className:"text-status-accent",children:["KV Cache ~",z(e.cacheReadInputTokens)]}),t.jsx("span",{className:"truncate",title:e.timestamp,children:e.timestamp})]}),t.jsxs("div",{className:"text-muted-foreground/70 font-mono truncate",title:a,children:["session: ",a]})]})}function Se({left:e,right:s,leftDisplayNumber:n,rightDisplayNumber:a,onClose:c}){const l=p.useRef(null),r=p.useRef(null),o=p.useRef(null),d=p.useMemo(()=>{const i=A(D(e)).analyzeRequest(e.rawRequestBody),u=A(D(s)).analyzeRequest(s.rawRequestBody),m=$(i.comparisonValue),g=$(u.comparisonValue);return he(m,g)},[e.apiFormat,e.path,e.rawRequestBody,s.apiFormat,s.path,s.rawRequestBody]),x=p.useMemo(()=>ve(d),[d]),h=p.useMemo(()=>{let i=0,u=0,m=0;for(const g of x)if(g.kind==="single")switch(g.op.kind){case"added":i++;break;case"removed":u++;break;case"changed":m++;break}return{added:i,removed:u,changed:m}},[x]),[b,E]=p.useState(new Set),U=i=>{E(u=>{const m=new Set(u);return m.has(i)?m.delete(i):m.add(i),m})},[G,I]=p.useState(new Set),Q=i=>{I(u=>{const m=new Set(u);return m.has(i)?m.delete(i):m.add(i),m})};p.useEffect(()=>{I(new Set)},[e.id,s.id]);const[O,W]=p.useState("unified"),P=p.useRef(null),[X,L]=p.useState(null),j=p.useRef(null),Y=i=>{ne(i).then(u=>{u&&(L(i),j.current!==null&&clearTimeout(j.current),j.current=setTimeout(()=>L(null),1500))})};p.useEffect(()=>()=>{j.current!==null&&clearTimeout(j.current)},[]);const Z=i=>{const u=x.findIndex(k=>k.kind==="single"&&k.op.kind===i);if(u===-1)return;const m=P.current;if(m===null)return;const g=m.querySelector(`[data-diff-idx="${u}"]`);g!==null&&g.scrollIntoView({behavior:"smooth",block:"center"})};p.useEffect(()=>{o.current=document.activeElement instanceof HTMLElement?document.activeElement:null,r.current?.focus();const i=m=>{m.key==="Escape"&&c()};document.addEventListener("keydown",i);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=u,o.current?.focus()}},[c]);const ee=i=>{if(i.stopPropagation(),i.key!=="Tab")return;const u=l.current;if(u===null)return;const m=Array.from(u.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')),g=m[0],k=m[m.length-1];if(!(g===void 0||k===void 0)){if(i.shiftKey&&document.activeElement===g){i.preventDefault(),k.focus();return}!i.shiftKey&&document.activeElement===k&&(i.preventDefault(),g.focus())}},te=R(e)===R(s),se=d.length===1&&d[0]?.kind==="equal";return t.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",role:"dialog","aria-modal":"true","aria-label":"Compare two log requests",children:[t.jsx("button",{type:"button",onClick:c,"aria-label":"Close compare drawer",className:"absolute inset-0 bg-black/40 cursor-default",tabIndex:-1}),t.jsxs("div",{ref:l,className:f("relative overflow-x-hidden bg-background border-l border-border shadow-xl","w-full md:w-[70vw] max-w-[1100px] flex flex-col h-full"),onClick:i=>i.stopPropagation(),onKeyDown:ee,children:[t.jsxs("div",{className:be,children:[t.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:[t.jsx(M,{log:e,side:"left",displayNumber:n}),t.jsx(M,{log:s,side:"right",displayNumber:a})]}),t.jsxs("div",{className:"flex w-full shrink-0 items-center justify-between gap-2 sm:w-auto sm:justify-start",children:[t.jsx(we,{mode:O,onChange:W}),t.jsx("button",{ref:r,type:"button",onClick:c,"aria-label":"Close",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted cursor-pointer",children:t.jsx(ae,{className:"size-4"})})]})]}),!te&&t.jsx("div",{className:"border-b border-border bg-warning/10 px-4 py-1.5 text-xs text-foreground",children:"Heads up: the two selected logs are from different sessions."}),se?t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex items-center justify-center text-muted-foreground text-sm",children:"The two Request payloads are identical."}):t.jsxs(t.Fragment,{children:[t.jsx(Ne,{counts:h,onJumpTo:Z}),t.jsx("div",{ref:P,className:"flex-1 min-h-0 overflow-y-auto",children:O==="unified"?t.jsx("div",{className:"px-3 py-2 space-y-0.5",children:x.map((i,u)=>{if(i.kind==="equal-run")return t.jsx(ke,{ops:i.ops,expanded:b.has(u),onToggle:()=>U(u)},`r${u}`);const m=i.op;return t.jsx(je,{op:m,idx:u,copiedPath:X,onCopyPath:Y,expanded:G.has(u),onToggle:()=>Q(u)},`o${u}`)})}):t.jsx(Ce,{grouped:x,left:e,right:s,leftDisplayNumber:n,rightDisplayNumber:a})})]})]})]})}function Ce({grouped:e,left:s,right:n,leftDisplayNumber:a,rightDisplayNumber:c}){return t.jsxs("div",{"data-compare-layout":"responsive-split",className:ge,children:[t.jsxs("div",{className:"col-span-1 mb-2 grid grid-cols-1 gap-x-2 gap-y-1 border-b border-border pb-2 text-[10px] uppercase tracking-wider text-muted-foreground md:col-span-3 md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]",children:[t.jsx("span",{children:"Path"}),t.jsxs("span",{title:`Log ID ${String(s.id)}`,children:["Left (Log #",a,")"]}),t.jsxs("span",{title:`Log ID ${String(n.id)}`,children:["Right (Log #",c,")"]})]}),e.map((l,r)=>{if(l.kind==="equal-run")return t.jsxs("div",{className:"col-span-1 px-2 py-1 text-xs text-muted-foreground/60 md:col-span-3",children:[l.ops.length," equal siblings collapsed — switch to Unified to expand"]},r);const o=l.op;return o.kind==="equal"?t.jsxs("div",{className:"col-span-1 grid min-w-0 grid-cols-1 gap-x-2 gap-y-1 px-2 py-0.5 text-muted-foreground md:col-span-3 md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]",children:[t.jsx("span",{className:"font-mono text-xs truncate",title:o.path,children:o.path}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)})]},r):o.kind==="added"?t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-success bg-status-success/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-status-success",children:["+ ",v(o.value,400)]})]},r):o.kind==="removed"?t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-danger bg-status-danger/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-status-danger line-through",children:["− ",v(o.value,400)]})]},r):t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-watch bg-status-watch/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:o.path}),t.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[t.jsx("div",{className:"font-mono break-all text-status-danger line-through",children:v(o.left,400)}),t.jsx("div",{className:"font-mono break-all text-status-success",children:v(o.right,400)})]})]},r)})]})}export{be as COMPARE_RESPONSIVE_HEADER_CLASS_NAME,ge as COMPARE_RESPONSIVE_SPLIT_CLASS_NAME,Se as CompareDrawer};
|