llmtap 0.1.4 → 0.1.7
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/README.md +29 -0
- package/dist/dashboard/assets/Costs-a6RxtEyD.js +1 -0
- package/dist/dashboard/assets/Dashboard-Dc3SbA3o.js +1 -0
- package/dist/dashboard/assets/DataTable-WlvwCpLc.js +1 -0
- package/dist/dashboard/assets/GettingStartedPanel-D2-E8-3Q.js +18 -0
- package/dist/dashboard/assets/Models-BwTqYNmO.js +1 -0
- package/dist/dashboard/assets/Sessions-PuU5TiOR.js +3 -0
- package/dist/dashboard/assets/Settings-Dsgny2rQ.js +6 -0
- package/dist/dashboard/assets/StatusDot-D69CfzT5.js +1 -0
- package/dist/dashboard/assets/TraceDetail-_YLBxcmc.js +17 -0
- package/dist/dashboard/assets/Traces-B5znc91x.js +1 -0
- package/dist/dashboard/assets/accordion-DZ-R65JQ.js +1 -0
- package/dist/dashboard/assets/constants-OlSc-7iA.js +1 -0
- package/dist/dashboard/assets/content-BRoZVvRJ.js +2 -0
- package/dist/dashboard/assets/format-wxLsIVjs.js +1 -0
- package/dist/dashboard/assets/icons-mXW2t-HS.js +1 -0
- package/dist/dashboard/assets/index-BjX-ME4E.js +14 -0
- package/dist/dashboard/assets/index-C98gdeiH.css +1 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/dashboard/assets/motion-DSHPdBNu.js +17 -0
- package/dist/dashboard/assets/number-ticker-DAf-8EjI.js +1 -0
- package/dist/dashboard/assets/provider-colors-BhO_XSTV.js +1 -0
- package/dist/dashboard/assets/query-DVWnIZNd.js +4 -0
- package/dist/dashboard/assets/select-DxzgyWz-.js +1 -0
- package/dist/dashboard/assets/statistics-with-status-grid-DE7T_RSi.js +1 -0
- package/dist/dashboard/assets/ui-BFiKdTjl.js +51 -0
- package/dist/dashboard/index.html +6 -2
- package/dist/index.js +332 -107
- package/dist/index.js.map +1 -1
- package/package.json +27 -14
- package/dist/dashboard/assets/BarChart-C6HDCruv.js +0 -1
- package/dist/dashboard/assets/Costs-CbzbCKu_.js +0 -4
- package/dist/dashboard/assets/Dashboard-CnMusiwU.js +0 -9
- package/dist/dashboard/assets/Models-C1x1xboT.js +0 -1
- package/dist/dashboard/assets/Sessions-Bh-4XfWy.js +0 -3
- package/dist/dashboard/assets/Settings-DzwivrGY.js +0 -6
- package/dist/dashboard/assets/StatusDot-CjYDb6xj.js +0 -1
- package/dist/dashboard/assets/TraceDetail-C0tQsZ-6.js +0 -17
- package/dist/dashboard/assets/Traces-D6m-Ef3q.js +0 -1
- package/dist/dashboard/assets/chart-styles-BD7W97c9.js +0 -61
- package/dist/dashboard/assets/clock-BEYeaSdD.js +0 -1
- package/dist/dashboard/assets/coins-BmXTNwva.js +0 -1
- package/dist/dashboard/assets/constants-BzCnW506.js +0 -1
- package/dist/dashboard/assets/content-DqloWqre.js +0 -2
- package/dist/dashboard/assets/download-B-39NUBC.js +0 -1
- package/dist/dashboard/assets/format-CNuIwzac.js +0 -1
- package/dist/dashboard/assets/gauge-CfqhcKwk.js +0 -1
- package/dist/dashboard/assets/index-BuSUiwyD.css +0 -1
- package/dist/dashboard/assets/index-M3DwcRrc.js +0 -66
- package/dist/dashboard/assets/layers-BQ0MpYqk.js +0 -1
- package/dist/dashboard/assets/orbit-eg7lcPsM.js +0 -1
- package/dist/dashboard/assets/provider-colors-DcHYMgVv.js +0 -1
- package/dist/dashboard/assets/zap-DjNN7wJp.js +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/commands/start.ts","../src/commands/reset.ts","../src/commands/export.ts","../src/commands/status.ts","../src/commands/tail.ts","../src/commands/doctor.ts","../src/commands/stats.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { startCommand } from \"./commands/start.js\";\nimport { resetCommand } from \"./commands/reset.js\";\nimport { exportCommand } from \"./commands/export.js\";\nimport { statusCommand } from \"./commands/status.js\";\nimport { tailCommand } from \"./commands/tail.js\";\nimport { doctorCommand } from \"./commands/doctor.js\";\nimport { statsCommand } from \"./commands/stats.js\";\nimport { VERSION } from \"@llmtap/shared\";\n\nconst program = new Command();\n\nprogram\n .name(\"llmtap\")\n .description(\"DevTools for AI Agents - See every LLM call, trace agent workflows, track costs\")\n .version(VERSION);\n\nprogram\n .command(\"start\", { isDefault: true })\n .description(\"Start the LLMTap collector and dashboard\")\n .option(\"-p, --port <port>\", \"Port number\", \"4781\")\n .option(\"-H, --host <host>\", \"Host to bind to (use 0.0.0.0 to expose to network)\", \"127.0.0.1\")\n .option(\"-q, --quiet\", \"Suppress server logs\")\n .option(\"--demo\", \"Seed demo data on startup\")\n .option(\"--no-open\", \"Don't open browser automatically\")\n .option(\"-r, --retention <days>\", \"Auto-delete data older than N days (0 = keep forever)\")\n .action(startCommand);\n\nprogram\n .command(\"status\")\n .description(\"Show collector status, database info, and span count\")\n .action(statusCommand);\n\nprogram\n .command(\"reset\")\n .description(\"Clear all stored data\")\n .action(resetCommand);\n\nprogram\n .command(\"export\")\n .description(\"Export traces as JSON, CSV, or OTLP\")\n .option(\"-o, --output <path>\", \"Output file path\", \"llmtap-export.json\")\n .option(\"-f, --format <format>\", \"Output format (json, csv, or otlp)\", \"json\")\n .option(\"-l, --limit <count>\", \"Number of traces/spans to export\", \"100\")\n .option(\"-e, --endpoint <url>\", \"OTLP endpoint to forward spans to (e.g. http://localhost:4318/v1/traces)\")\n .option(\"-s, --service <name>\", \"service.name for OTLP export\", \"llmtap\")\n .action(exportCommand);\n\nprogram\n .command(\"tail\")\n .description(\"Stream traces to terminal in real-time\")\n .option(\"-f, --format <format>\", \"Output format (pretty or json)\", \"pretty\")\n .action(tailCommand);\n\nprogram\n .command(\"doctor\")\n .description(\"Diagnose common setup issues\")\n .action(doctorCommand);\n\nprogram\n .command(\"stats\")\n .description(\"Show quick terminal stats (cost, models, errors)\")\n .option(\"-p, --period <hours>\", \"Time period in hours\", \"24\")\n .option(\"--host <url>\", \"Collector URL\", \"http://localhost:4781\")\n .action(statsCommand);\n\nprogram.parse();\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport chalk from \"chalk\";\nimport open from \"open\";\nimport { startServer, getOtlpEndpoint } from \"@llmtap/collector\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\ninterface StartOptions {\n port: string;\n host: string;\n quiet?: boolean;\n open?: boolean;\n demo?: boolean;\n retention?: string;\n}\n\nexport async function startCommand(options: StartOptions): Promise<void> {\n const port = parseInt(options.port, 10);\n const retentionDays = options.retention\n ? parseInt(options.retention, 10)\n : undefined;\n\n // Resolve dashboard dist path\n // 1. Bundled inside CLI dist (for npm publish): dist/dashboard/\n // 2. Monorepo sibling (for local dev): ../../dashboard/dist/\n const bundledPath = path.resolve(__dirname, \"dashboard\");\n const monorepoPath = path.resolve(__dirname, \"..\", \"..\", \"dashboard\", \"dist\");\n const dashboardPath = fs.existsSync(bundledPath) ? bundledPath : monorepoPath;\n\n console.log(\"\");\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap\") + chalk.gray(\" - DevTools for AI Agents\"));\n console.log(\"\");\n\n try {\n const host = options.host;\n\n if (host === \"0.0.0.0\") {\n console.log(chalk.yellow(\" ⚠ Binding to 0.0.0.0 — the collector will be accessible from your network\"));\n console.log(\"\");\n }\n\n const address = await startServer({\n port,\n host,\n dashboardPath,\n quiet: options.quiet,\n demo: options.demo,\n retentionDays,\n });\n\n const url = `http://${host === \"0.0.0.0\" ? \"localhost\" : host}:${port}`;\n\n console.log(chalk.green(\" Ready!\"));\n console.log(\"\");\n console.log(` ${chalk.gray(\"Dashboard:\")} ${chalk.cyan(url)}`);\n console.log(` ${chalk.gray(\"API:\")} ${chalk.cyan(`${url}/v1`)}`);\n console.log(` ${chalk.gray(\"Health:\")} ${chalk.cyan(`${url}/health`)}`);\n if (retentionDays && retentionDays > 0) {\n console.log(` ${chalk.gray(\"Retention:\")} ${chalk.yellow(`${retentionDays} days`)}`);\n }\n const otlpTarget = getOtlpEndpoint();\n if (otlpTarget) {\n console.log(` ${chalk.gray(\"OTLP:\")} ${chalk.cyan(otlpTarget)} ${chalk.green(\"(auto-forwarding)\")}`);\n }\n console.log(\"\");\n console.log(chalk.gray(\" Press Ctrl+C to stop\"));\n console.log(\"\");\n\n // Open browser\n if (options.open !== false) {\n try {\n await open(url);\n } catch {\n // Ignore if browser can't be opened\n }\n }\n } catch (err: unknown) {\n const error = err as Error;\n if (error.message?.includes(\"EADDRINUSE\")) {\n console.error(chalk.red(` Port ${port} is already in use.`));\n console.error(chalk.gray(` Try: npx llmtap --port ${port + 1}`));\n } else if (\n error.message?.includes(\"better-sqlite3\") ||\n error.message?.includes(\"MODULE_NOT_FOUND\") ||\n error.message?.includes(\"node-gyp\") ||\n error.message?.includes(\"prebuild-install\") ||\n error.message?.includes(\"Cannot find module\")\n ) {\n console.error(chalk.red(\" Failed to load native SQLite module (better-sqlite3).\"));\n console.error(\"\");\n console.error(chalk.yellow(\" This usually means your Node.js version doesn't have prebuilt binaries.\"));\n console.error(\"\");\n console.error(chalk.white(\" How to fix:\"));\n console.error(chalk.gray(\" 1. Use Node.js LTS (v18, v20, or v22) — prebuilt binaries are available\"));\n console.error(chalk.gray(\" → nvm install --lts && nvm use --lts\"));\n console.error(chalk.gray(\" 2. Or install C++ build tools for your platform:\"));\n console.error(chalk.gray(\" → Windows: npm install -g windows-build-tools\"));\n console.error(chalk.gray(\" → macOS: xcode-select --install\"));\n console.error(chalk.gray(\" → Linux: sudo apt install build-essential python3\"));\n console.error(\"\");\n console.error(chalk.gray(` Your Node.js version: ${process.version}`));\n } else {\n console.error(chalk.red(` Failed to start: ${error.message}`));\n }\n process.exit(1);\n }\n}\n","import chalk from \"chalk\";\nimport { resetDb } from \"@llmtap/collector\";\n\nexport async function resetCommand(): Promise<void> {\n try {\n resetDb();\n console.log(chalk.green(\" Data cleared successfully.\"));\n } catch (err: unknown) {\n const error = err as Error;\n console.error(chalk.red(` Failed to reset: ${error.message}`));\n process.exit(1);\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport chalk from \"chalk\";\nimport { getDb } from \"@llmtap/collector\";\nimport { spansToOtlp } from \"@llmtap/shared\";\nimport type { Span } from \"@llmtap/shared\";\n\ninterface ExportOptions {\n output: string;\n limit: string;\n format: string;\n endpoint?: string;\n service?: string;\n}\n\nfunction safeParse(v: unknown): unknown {\n if (!v || typeof v !== \"string\") return undefined;\n try { return JSON.parse(v); } catch { return undefined; }\n}\n\nfunction rowToSpan(row: Record<string, unknown>): Span {\n return {\n ...row,\n parentSpanId: (row.parentSpanId as string) ?? undefined,\n endTime: (row.endTime as number) ?? undefined,\n duration: (row.duration as number) ?? undefined,\n responseModel: (row.responseModel as string) ?? undefined,\n temperature: (row.temperature as number) ?? undefined,\n maxTokens: (row.maxTokens as number) ?? undefined,\n topP: (row.topP as number) ?? undefined,\n inputMessages: safeParse(row.inputMessages) as Span[\"inputMessages\"],\n outputMessages: safeParse(row.outputMessages) as Span[\"outputMessages\"],\n toolCalls: safeParse(row.toolCalls) as Span[\"toolCalls\"],\n tags: safeParse(row.tags) as Record<string, string> | undefined,\n errorType: (row.errorType as string) ?? undefined,\n errorMessage: (row.errorMessage as string) ?? undefined,\n sessionId: (row.sessionId as string) ?? undefined,\n userId: (row.userId as string) ?? undefined,\n } as Span;\n}\n\nexport async function exportCommand(options: ExportOptions): Promise<void> {\n try {\n const db = getDb();\n const limit = parseInt(options.limit, 10);\n const format = options.format ?? \"json\";\n\n if (format === \"otlp\") {\n return await exportOtlp(db, limit, options);\n }\n\n // Get traces\n const traces = db\n .prepare(\n `\n SELECT\n traceId,\n MIN(name) as name,\n MIN(startTime) as startTime,\n MAX(endTime) as endTime,\n CASE WHEN SUM(CASE WHEN status = 'error' THEN 1 ELSE 0 END) > 0\n THEN 'error' ELSE 'ok' END as status,\n COUNT(*) as spanCount,\n COALESCE(SUM(totalTokens), 0) as totalTokens,\n COALESCE(SUM(totalCost), 0) as totalCost\n FROM spans\n GROUP BY traceId\n ORDER BY startTime DESC\n LIMIT ?\n `\n )\n .all(limit) as Array<Record<string, unknown>>;\n\n // Get spans for each trace\n const getSpans = db.prepare(\"SELECT * FROM spans WHERE traceId = ? ORDER BY startTime ASC\");\n const exportData = traces.map((trace) => ({\n ...trace,\n spans: (getSpans.all(trace.traceId) as Array<Record<string, unknown>>).map((span) => ({\n ...span,\n inputMessages: safeParse(span.inputMessages),\n outputMessages: safeParse(span.outputMessages),\n toolCalls: safeParse(span.toolCalls),\n tags: safeParse(span.tags),\n })),\n }));\n\n let output: string;\n let ext: string;\n\n if (format === \"csv\") {\n ext = \"csv\";\n const headers = [\n \"traceId\", \"name\", \"status\", \"spanCount\", \"totalTokens\", \"totalCost\",\n \"startTime\", \"endTime\",\n ];\n const rows = traces.map((t) =>\n headers.map((h) => {\n const val = t[h];\n const s = String(val ?? \"\");\n return s.includes(\",\") || s.includes('\"') || s.includes(\"\\n\") ? `\"${s.replace(/\"/g, '\"\"')}\"` : s;\n }).join(\",\")\n );\n output = [headers.join(\",\"), ...rows].join(\"\\n\");\n } else {\n ext = \"json\";\n output = JSON.stringify(exportData, null, 2);\n }\n\n const defaultOutput = options.output === \"llmtap-export.json\" && format === \"csv\"\n ? \"llmtap-export.csv\"\n : options.output;\n const outputPath = path.resolve(defaultOutput);\n fs.writeFileSync(outputPath, output);\n\n console.log(chalk.green(` Exported ${traces.length} traces as ${ext.toUpperCase()} to ${outputPath}`));\n } catch (err: unknown) {\n const error = err as Error;\n console.error(chalk.red(` Export failed: ${error.message}`));\n process.exit(1);\n }\n}\n\nasync function exportOtlp(\n db: ReturnType<typeof getDb>,\n limit: number,\n options: ExportOptions\n): Promise<void> {\n const rows = db\n .prepare(\"SELECT * FROM spans ORDER BY startTime DESC LIMIT ?\")\n .all(limit) as Array<Record<string, unknown>>;\n\n const spans = rows.map(rowToSpan);\n const otlp = spansToOtlp(spans, options.service ?? \"llmtap\");\n\n // If --endpoint is provided, forward to OTLP collector\n if (options.endpoint) {\n console.log(chalk.blue(` Forwarding ${spans.length} spans to ${options.endpoint}...`));\n try {\n const res = await fetch(options.endpoint, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(otlp),\n signal: AbortSignal.timeout(30000),\n });\n if (!res.ok) {\n const body = await res.text().catch(() => \"\");\n console.error(chalk.red(` OTLP endpoint returned ${res.status}: ${body.slice(0, 200)}`));\n process.exit(1);\n }\n console.log(chalk.green(` Successfully forwarded ${spans.length} spans to OTLP endpoint`));\n } catch (err) {\n console.error(chalk.red(` Failed to reach OTLP endpoint: ${err instanceof Error ? err.message : String(err)}`));\n process.exit(1);\n }\n return;\n }\n\n // Otherwise write to file\n const outputPath = path.resolve(\n options.output === \"llmtap-export.json\" ? \"llmtap-export.otlp.json\" : options.output\n );\n fs.writeFileSync(outputPath, JSON.stringify(otlp, null, 2));\n console.log(chalk.green(` Exported ${spans.length} spans as OTLP JSON to ${outputPath}`));\n console.log(chalk.dim(` Import into Jaeger, Grafana Tempo, Datadog, or any OTLP-compatible backend`));\n}\n","import chalk from \"chalk\";\r\n\r\nexport async function statusCommand(): Promise<void> {\r\n try {\r\n const res = await fetch(\"http://localhost:4781/v1/db-info\", {\r\n signal: AbortSignal.timeout(3000),\r\n });\r\n\r\n if (!res.ok) {\r\n console.error(chalk.red(\" Collector responded with an error.\"));\r\n process.exit(1);\r\n }\r\n\r\n const info = (await res.json()) as {\r\n path: string;\r\n sizeBytes: number;\r\n spanCount: number;\r\n traceCount: number;\r\n oldestSpan: number | null;\r\n newestSpan: number | null;\r\n walMode: string;\r\n };\r\n\r\n const formatBytes = (bytes: number) => {\r\n if (bytes === 0) return \"0 B\";\r\n const units = [\"B\", \"KB\", \"MB\", \"GB\"];\r\n const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);\r\n return `${(bytes / Math.pow(1024, i)).toFixed(i === 0 ? 0 : 1)} ${units[i]}`;\r\n };\r\n\r\n console.log(\"\");\r\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap\") + chalk.green(\" — Running\"));\r\n console.log(\"\");\r\n console.log(` ${chalk.gray(\"Spans:\")} ${chalk.white(info.spanCount.toLocaleString())}`);\r\n console.log(` ${chalk.gray(\"Traces:\")} ${chalk.white(info.traceCount.toLocaleString())}`);\r\n console.log(` ${chalk.gray(\"DB size:\")} ${chalk.white(formatBytes(info.sizeBytes))}`);\r\n console.log(` ${chalk.gray(\"WAL mode:\")} ${chalk.white(info.walMode.toUpperCase())}`);\r\n console.log(` ${chalk.gray(\"DB path:\")} ${chalk.white(info.path)}`);\r\n\r\n if (info.oldestSpan && info.newestSpan) {\r\n const oldest = new Date(info.oldestSpan).toLocaleString();\r\n const newest = new Date(info.newestSpan).toLocaleString();\r\n console.log(` ${chalk.gray(\"Data range:\")} ${chalk.white(`${oldest} — ${newest}`)}`);\r\n }\r\n console.log(\"\");\r\n } catch {\r\n console.log(\"\");\r\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap\") + chalk.red(\" — Not running\"));\r\n console.log(\"\");\r\n console.log(chalk.gray(\" Start the collector with: \") + chalk.cyan(\"npx llmtap\"));\r\n console.log(\"\");\r\n }\r\n}\r\n","import chalk from \"chalk\";\r\n\r\ninterface TailOptions {\r\n format: string;\r\n}\r\n\r\nexport async function tailCommand(options: TailOptions): Promise<void> {\r\n const format = options.format ?? \"pretty\";\r\n const url = \"http://localhost:4781/v1/stream\";\r\n\r\n console.log(\"\");\r\n console.log(\r\n chalk.bold.hex(\"#6366f1\")(\" LLMTap\") +\r\n chalk.gray(\" — Streaming traces in real-time\")\r\n );\r\n console.log(chalk.gray(\" Press Ctrl+C to stop\"));\r\n console.log(\"\");\r\n\r\n try {\r\n const res = await fetch(url, {\r\n headers: { Accept: \"text/event-stream\" },\r\n });\r\n\r\n if (!res.ok || !res.body) {\r\n console.error(chalk.red(\" Could not connect to collector.\"));\r\n console.error(chalk.gray(\" Make sure the collector is running: npx llmtap\"));\r\n process.exit(1);\r\n }\r\n\r\n const decoder = new TextDecoder();\r\n const reader = res.body.getReader();\r\n let buffer = \"\";\r\n\r\n while (true) {\r\n const { done, value } = await reader.read();\r\n if (done) break;\r\n\r\n buffer += decoder.decode(value, { stream: true });\r\n const lines = buffer.split(\"\\n\");\r\n buffer = lines.pop() ?? \"\";\r\n\r\n for (const line of lines) {\r\n if (!line.startsWith(\"data: \")) continue;\r\n const json = line.slice(6).trim();\r\n if (!json) continue;\r\n\r\n try {\r\n const span = JSON.parse(json) as {\r\n spanId: string;\r\n traceId: string;\r\n name: string;\r\n providerName: string;\r\n requestModel: string;\r\n duration?: number;\r\n totalTokens: number;\r\n totalCost: number;\r\n status: string;\r\n errorMessage?: string;\r\n };\r\n\r\n if (format === \"json\") {\r\n console.log(json);\r\n } else {\r\n const dur = span.duration ? `${span.duration}ms` : \"...\";\r\n const cost =\r\n span.totalCost > 0 ? `$${span.totalCost.toFixed(4)}` : \"$0\";\r\n const statusIcon =\r\n span.status === \"error\" ? chalk.red(\"ERR\") : chalk.green(\"OK \");\r\n\r\n console.log(\r\n ` ${statusIcon} ${chalk.gray(dur.padStart(7))} ${chalk.cyan(span.providerName.padEnd(10))} ${chalk.white(span.requestModel.padEnd(24))} ${chalk.yellow(String(span.totalTokens).padStart(6) + \" tok\")} ${chalk.green(cost.padStart(8))} ${chalk.gray(span.name)}`\r\n );\r\n if (span.errorMessage) {\r\n console.log(\r\n ` ${chalk.red(\"→ \" + span.errorMessage.slice(0, 120))}`\r\n );\r\n }\r\n }\r\n } catch {\r\n // Skip malformed events\r\n }\r\n }\r\n }\r\n } catch {\r\n console.error(chalk.red(\" Could not connect to collector.\"));\r\n console.error(chalk.gray(\" Make sure the collector is running: npx llmtap\"));\r\n process.exit(1);\r\n }\r\n}\r\n","import chalk from \"chalk\";\r\n\r\nexport async function doctorCommand(): Promise<void> {\r\n console.log(\"\");\r\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap Doctor\"));\r\n console.log(chalk.gray(\" Checking your setup...\"));\r\n console.log(\"\");\r\n\r\n const checks: { label: string; status: \"ok\" | \"warn\" | \"fail\"; detail: string }[] = [];\r\n\r\n // Check 1: Node.js version\r\n const nodeVersion = process.version;\r\n const major = parseInt(nodeVersion.slice(1), 10);\r\n if (major >= 18) {\r\n checks.push({ label: \"Node.js version\", status: \"ok\", detail: nodeVersion });\r\n } else {\r\n checks.push({ label: \"Node.js version\", status: \"fail\", detail: `${nodeVersion} (requires >= 18)` });\r\n }\r\n\r\n // Check 2: Collector running\r\n try {\r\n const res = await fetch(\"http://localhost:4781/health\", {\r\n signal: AbortSignal.timeout(3000),\r\n });\r\n if (res.ok) {\r\n checks.push({ label: \"Collector\", status: \"ok\", detail: \"Running on port 4781\" });\r\n } else {\r\n checks.push({ label: \"Collector\", status: \"fail\", detail: `Responded with HTTP ${res.status}` });\r\n }\r\n } catch {\r\n checks.push({ label: \"Collector\", status: \"warn\", detail: \"Not running (start with: npx llmtap)\" });\r\n }\r\n\r\n // Check 3: Database accessible\r\n try {\r\n const res = await fetch(\"http://localhost:4781/v1/db-info\", {\r\n signal: AbortSignal.timeout(3000),\r\n });\r\n if (res.ok) {\r\n const info = (await res.json()) as { sizeBytes: number; spanCount: number; walMode: string };\r\n checks.push({\r\n label: \"Database\",\r\n status: info.walMode === \"wal\" ? \"ok\" : \"warn\",\r\n detail: `${info.spanCount} spans, WAL=${info.walMode.toUpperCase()}`,\r\n });\r\n }\r\n } catch {\r\n checks.push({ label: \"Database\", status: \"warn\", detail: \"Cannot check (collector not running)\" });\r\n }\r\n\r\n // Check 4: SDK installed\r\n try {\r\n await import(\"@llmtap/sdk\");\r\n checks.push({ label: \"@llmtap/sdk\", status: \"ok\", detail: \"Installed\" });\r\n } catch {\r\n checks.push({ label: \"@llmtap/sdk\", status: \"warn\", detail: \"Not found in current project (install with: npm i @llmtap/sdk)\" });\r\n }\r\n\r\n // Check 5: Port available\r\n if (checks.find((c) => c.label === \"Collector\")?.status !== \"ok\") {\r\n try {\r\n // Try connecting to port 4781 to see if something else is using it\r\n const res = await fetch(\"http://localhost:4781\", {\r\n signal: AbortSignal.timeout(1000),\r\n });\r\n if (!res.ok) {\r\n checks.push({ label: \"Port 4781\", status: \"warn\", detail: \"Something is running but not LLMTap\" });\r\n }\r\n } catch {\r\n checks.push({ label: \"Port 4781\", status: \"ok\", detail: \"Available\" });\r\n }\r\n }\r\n\r\n // Display results\r\n for (const check of checks) {\r\n const icon =\r\n check.status === \"ok\"\r\n ? chalk.green(\" ✓\")\r\n : check.status === \"warn\"\r\n ? chalk.yellow(\" !\")\r\n : chalk.red(\" ✗\");\r\n const label = chalk.white(check.label.padEnd(20));\r\n const detail =\r\n check.status === \"ok\"\r\n ? chalk.gray(check.detail)\r\n : check.status === \"warn\"\r\n ? chalk.yellow(check.detail)\r\n : chalk.red(check.detail);\r\n console.log(`${icon} ${label} ${detail}`);\r\n }\r\n\r\n const failCount = checks.filter((c) => c.status === \"fail\").length;\r\n const warnCount = checks.filter((c) => c.status === \"warn\").length;\r\n console.log(\"\");\r\n if (failCount > 0) {\r\n console.log(chalk.red(` ${failCount} issue(s) found. Fix them to use LLMTap.`));\r\n } else if (warnCount > 0) {\r\n console.log(chalk.yellow(` ${warnCount} warning(s). Everything should still work.`));\r\n } else {\r\n console.log(chalk.green(\" All checks passed!\"));\r\n }\r\n console.log(\"\");\r\n}\r\n","import chalk from \"chalk\";\r\n\r\ninterface StatsResponse {\r\n totalTraces: number;\r\n totalSpans: number;\r\n totalTokens: number;\r\n totalCost: number;\r\n avgDuration: number;\r\n errorCount: number;\r\n errorRate: number;\r\n byProvider: { provider: string; spanCount: number; totalTokens: number; totalCost: number; avgDuration: number }[];\r\n byModel: { model: string; provider: string; spanCount: number; totalTokens: number; totalCost: number; avgDuration: number }[];\r\n}\r\n\r\nexport async function statsCommand(options: { period?: string; host?: string }): Promise<void> {\r\n const period = Number(options.period ?? \"24\");\r\n const host = options.host ?? \"http://localhost:4781\";\r\n\r\n try {\r\n const res = await fetch(`${host}/v1/stats?period=${period}`);\r\n if (!res.ok) {\r\n console.error(chalk.red(`Error: Collector returned HTTP ${res.status}`));\r\n console.error(chalk.dim(\"Is the collector running? Try: npx llmtap start\"));\r\n process.exit(1);\r\n }\r\n\r\n const stats = (await res.json()) as StatsResponse;\r\n\r\n console.log(\"\");\r\n console.log(chalk.bold.white(` LLMTap Stats — Last ${period}h`));\r\n console.log(chalk.dim(\" ─────────────────────────────────\"));\r\n console.log(\"\");\r\n\r\n // Summary\r\n const errorPct = (stats.errorRate * 100).toFixed(1);\r\n console.log(` ${chalk.dim(\"Traces\")} ${chalk.bold.white(String(stats.totalTraces))}`);\r\n console.log(` ${chalk.dim(\"Spans\")} ${chalk.bold.white(String(stats.totalSpans))}`);\r\n console.log(` ${chalk.dim(\"Tokens\")} ${chalk.bold.white(stats.totalTokens.toLocaleString())}`);\r\n console.log(` ${chalk.dim(\"Total Cost\")} ${chalk.bold.green(\"$\" + stats.totalCost.toFixed(4))}`);\r\n console.log(` ${chalk.dim(\"Avg Latency\")} ${chalk.white(formatMs(stats.avgDuration))}`);\r\n console.log(\r\n ` ${chalk.dim(\"Error Rate\")} ${\r\n stats.errorRate > 0.05\r\n ? chalk.bold.red(errorPct + \"%\")\r\n : chalk.green(errorPct + \"%\")\r\n } ${chalk.dim(`(${stats.errorCount} errors)`)}`\r\n );\r\n\r\n // Top providers\r\n if (stats.byProvider.length > 0) {\r\n console.log(\"\");\r\n console.log(chalk.bold.white(\" Top Providers\"));\r\n console.log(chalk.dim(\" ─────────────────────────────────\"));\r\n for (const p of stats.byProvider.slice(0, 5)) {\r\n const bar = makeBar(p.totalCost, stats.totalCost, 20);\r\n console.log(\r\n ` ${chalk.cyan(p.provider.padEnd(12))} ${chalk.dim(String(p.spanCount).padStart(5) + \" calls\")} ${chalk.green(\"$\" + p.totalCost.toFixed(4).padStart(8))} ${chalk.dim(bar)}`\r\n );\r\n }\r\n }\r\n\r\n // Top models\r\n if (stats.byModel.length > 0) {\r\n console.log(\"\");\r\n console.log(chalk.bold.white(\" Top Models\"));\r\n console.log(chalk.dim(\" ─────────────────────────────────\"));\r\n for (const m of stats.byModel.slice(0, 8)) {\r\n const bar = makeBar(m.totalCost, stats.totalCost, 20);\r\n console.log(\r\n ` ${chalk.white(m.model.padEnd(28).slice(0, 28))} ${chalk.dim(String(m.spanCount).padStart(5) + \" calls\")} ${chalk.green(\"$\" + m.totalCost.toFixed(4).padStart(8))} ${chalk.dim(bar)}`\r\n );\r\n }\r\n }\r\n\r\n console.log(\"\");\r\n } catch (err) {\r\n if (err instanceof TypeError && (err as NodeJS.ErrnoException).cause) {\r\n console.error(chalk.red(\"Error: Cannot connect to collector\"));\r\n console.error(chalk.dim(\"Is the collector running? Try: npx llmtap start\"));\r\n } else {\r\n console.error(chalk.red(\"Error:\"), err instanceof Error ? err.message : err);\r\n }\r\n process.exit(1);\r\n }\r\n}\r\n\r\nfunction formatMs(ms: number): string {\r\n if (ms < 1000) return `${Math.round(ms)}ms`;\r\n return `${(ms / 1000).toFixed(2)}s`;\r\n}\r\n\r\nfunction makeBar(value: number, total: number, width: number): string {\r\n if (total <= 0) return \"\";\r\n const filled = Math.max(Math.round((value / total) * width), 1);\r\n return \"█\".repeat(filled) + \"░\".repeat(width - filled);\r\n}\r\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,qBAAqB;AAC9B,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAA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A0C,EACtD,OAAO,qBAAqB,eAAe,MAAM,EACjD,OAAO,qBAAqB,sDAAsD,WAAW,EAC7F,OAAO,eAAe,sBAAsB,EAC5C,OAAO,UAAU,2BAA2B,EAC5C,OAAO,aAAa,kCAAkC,EACtD,OAAO,0BAA0B,uDAAuD,EACxF,OAAO,YAAY;AAEtB,QACG,QAAQ,QAAQ,EAChB,YAAY,sDAAsD,EAClE,OAAO,aAAa;AAEvB,QACG,QAAQ,OAAO,EACf,YAAY,uBAAuB,EACnC,OAAO,YAAY;AAEtB,QACG,QAAQ,QAAQ,EAChB,YAAY,qCAAqC,EACjD,OAAO,uBAAuB,oBAAoB,oBAAoB,EACtE,OAAO,yBAAyB,sCAAsC,MAAM,EAC5E,OAAO,uBAAuB,oCAAoC,KAAK,EACvE,OAAO,wBAAwB,0EAA0E,EACzG,OAAO,wBAAwB,gCAAgC,QAAQ,EACvE,OAAO,aAAa;AAEvB,QACG,QAAQ,MAAM,EACd,YAAY,wCAAwC,EACpD,OAAO,yBAAyB,kCAAkC,QAAQ,EAC1E,OAAO,WAAW;AAErB,QACG,QAAQ,QAAQ,EAChB,YAAY,8BAA8B,EAC1C,OAAO,aAAa;AAEvB,QACG,QAAQ,OAAO,EACf,YAAY,kDAAkD,EAC9D,OAAO,wBAAwB,wBAAwB,IAAI,EAC3D,OAAO,gBAAgB,iBAAiB,uBAAuB,EAC/D,OAAO,YAAY;AAEtB,QAAQ,MAAM;","names":["chalk","fs","path","chalk","chalk","chalk","chalk","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/start.ts","../src/commands/reset.ts","../src/commands/export.ts","../src/commands/backup.ts","../src/lib/collector.ts","../src/commands/restore.ts","../src/commands/import.ts","../src/lib/data.ts","../src/commands/status.ts","../src/commands/tail.ts","../src/commands/doctor.ts","../src/commands/stats.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { startCommand } from \"./commands/start.js\";\nimport { resetCommand } from \"./commands/reset.js\";\nimport { exportCommand } from \"./commands/export.js\";\nimport { backupCommand } from \"./commands/backup.js\";\nimport { restoreCommand } from \"./commands/restore.js\";\nimport { importCommand } from \"./commands/import.js\";\nimport { statusCommand } from \"./commands/status.js\";\nimport { tailCommand } from \"./commands/tail.js\";\nimport { doctorCommand } from \"./commands/doctor.js\";\nimport { statsCommand } from \"./commands/stats.js\";\nimport { VERSION } from \"@llmtap/shared\";\n\nconst program = new Command();\n\nprogram\n .name(\"llmtap\")\n .description(\"DevTools for AI Agents - See every LLM call, trace agent workflows, track costs\")\n .version(VERSION);\n\nprogram\n .command(\"start\", { isDefault: true })\n .description(\"Start the LLMTap collector and dashboard\")\n .option(\"-p, --port <port>\", \"Port number\", \"4781\")\n .option(\"-H, --host <host>\", \"Host to bind to (use 0.0.0.0 to expose to network)\", \"127.0.0.1\")\n .option(\"-q, --quiet\", \"Suppress server logs\")\n .option(\"--demo\", \"Seed demo data on startup\")\n .option(\"--no-open\", \"Don't open browser automatically\")\n .option(\"-r, --retention <days>\", \"Auto-delete data older than N days (0 = keep forever)\")\n .action(startCommand);\n\nprogram\n .command(\"status\")\n .description(\"Show collector status, database info, and span count\")\n .option(\"--host <url>\", \"Collector URL\", \"http://localhost:4781\")\n .action(statusCommand);\n\nprogram\n .command(\"reset\")\n .description(\"Clear all stored data\")\n .action(resetCommand);\n\nprogram\n .command(\"export\")\n .description(\"Export traces as JSON, CSV, or OTLP\")\n .option(\"-o, --output <path>\", \"Output file path\", \"llmtap-export.json\")\n .option(\"-f, --format <format>\", \"Output format (json, csv, or otlp)\", \"json\")\n .option(\"-l, --limit <count>\", \"Number of traces/spans to export\", \"100\")\n .option(\"-e, --endpoint <url>\", \"OTLP endpoint to forward spans to (e.g. http://localhost:4318/v1/traces)\")\n .option(\"-s, --service <name>\", \"service.name for OTLP export\", \"llmtap\")\n .action(exportCommand);\n\nprogram\n .command(\"backup\")\n .description(\"Create a portable SQLite backup of your local LLMTap data\")\n .option(\"-o, --output <path>\", \"Backup output path\")\n .action(backupCommand);\n\nprogram\n .command(\"restore <input>\")\n .description(\"Restore the local LLMTap database from a backup file\")\n .option(\"--host <url>\", \"Collector URL to check before restoring\", \"http://localhost:4781\")\n .action(restoreCommand);\n\nprogram\n .command(\"import <input>\")\n .description(\"Import LLMTap JSON exports back into local storage\")\n .option(\"--replace\", \"Replace the existing local database contents before importing\")\n .option(\"--host <url>\", \"Collector URL for live ingest when running\", \"http://localhost:4781\")\n .action(importCommand);\n\nprogram\n .command(\"tail\")\n .description(\"Stream traces to terminal in real-time\")\n .option(\"-f, --format <format>\", \"Output format (pretty or json)\", \"pretty\")\n .action(tailCommand);\n\nprogram\n .command(\"doctor\")\n .description(\"Diagnose common setup issues\")\n .option(\"--host <url>\", \"Collector URL\", \"http://localhost:4781\")\n .action(doctorCommand);\n\nprogram\n .command(\"stats\")\n .description(\"Show quick terminal stats (cost, models, errors)\")\n .option(\"-p, --period <hours>\", \"Time period in hours\", \"24\")\n .option(\"--host <url>\", \"Collector URL\", \"http://localhost:4781\")\n .action(statsCommand);\n\nprogram.parse();\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport chalk from \"chalk\";\nimport open from \"open\";\nimport { startServer, getOtlpEndpoint } from \"@llmtap/collector\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\ninterface StartOptions {\n port: string;\n host: string;\n quiet?: boolean;\n open?: boolean;\n demo?: boolean;\n retention?: string;\n}\n\nexport async function startCommand(options: StartOptions): Promise<void> {\n const port = parseInt(options.port, 10);\n const retentionDays = options.retention\n ? parseInt(options.retention, 10)\n : undefined;\n\n // Resolve dashboard dist path\n // 1. Bundled inside CLI dist (for npm publish): dist/dashboard/\n // 2. Monorepo sibling (for local dev): ../../dashboard/dist/\n const bundledPath = path.resolve(__dirname, \"dashboard\");\n const monorepoPath = path.resolve(__dirname, \"..\", \"..\", \"dashboard\", \"dist\");\n const dashboardPath = fs.existsSync(bundledPath) ? bundledPath : monorepoPath;\n\n console.log(\"\");\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap\") + chalk.gray(\" - DevTools for AI Agents\"));\n console.log(\"\");\n\n try {\n const host = options.host;\n\n if (host === \"0.0.0.0\") {\n console.log(chalk.yellow(\" ⚠ Binding to 0.0.0.0 — the collector will be accessible from your network\"));\n console.log(\"\");\n }\n\n const address = await startServer({\n port,\n host,\n dashboardPath,\n quiet: options.quiet,\n demo: options.demo,\n retentionDays,\n });\n\n const url = `http://${host === \"0.0.0.0\" ? \"localhost\" : host}:${port}`;\n\n console.log(chalk.green(\" Ready!\"));\n console.log(\"\");\n console.log(` ${chalk.gray(\"Dashboard:\")} ${chalk.cyan(url)}`);\n console.log(` ${chalk.gray(\"API:\")} ${chalk.cyan(`${url}/v1`)}`);\n console.log(` ${chalk.gray(\"Health:\")} ${chalk.cyan(`${url}/health`)}`);\n if (retentionDays && retentionDays > 0) {\n console.log(` ${chalk.gray(\"Retention:\")} ${chalk.yellow(`${retentionDays} days`)}`);\n }\n const otlpTarget = getOtlpEndpoint();\n if (otlpTarget) {\n console.log(` ${chalk.gray(\"OTLP:\")} ${chalk.cyan(otlpTarget)} ${chalk.green(\"(auto-forwarding)\")}`);\n }\n console.log(\"\");\n console.log(chalk.gray(\" Press Ctrl+C to stop\"));\n console.log(\"\");\n\n // Open browser\n if (options.open !== false) {\n try {\n await open(url);\n } catch {\n // Ignore if browser can't be opened\n }\n }\n } catch (err: unknown) {\n const error = err as Error;\n if (error.message?.includes(\"EADDRINUSE\")) {\n console.error(chalk.red(` Port ${port} is already in use.`));\n console.error(chalk.gray(` Try: npx llmtap --port ${port + 1}`));\n } else if (\n error.message?.includes(\"better-sqlite3\") ||\n error.message?.includes(\"MODULE_NOT_FOUND\") ||\n error.message?.includes(\"node-gyp\") ||\n error.message?.includes(\"prebuild-install\") ||\n error.message?.includes(\"Cannot find module\")\n ) {\n console.error(chalk.red(\" Failed to load native SQLite module (better-sqlite3).\"));\n console.error(\"\");\n console.error(chalk.yellow(\" This usually means your Node.js version doesn't have prebuilt binaries.\"));\n console.error(\"\");\n console.error(chalk.white(\" How to fix:\"));\n console.error(chalk.gray(\" 1. Use Node.js LTS (v18, v20, or v22) — prebuilt binaries are available\"));\n console.error(chalk.gray(\" → nvm install --lts && nvm use --lts\"));\n console.error(chalk.gray(\" 2. Or install C++ build tools for your platform:\"));\n console.error(chalk.gray(\" → Windows: npm install -g windows-build-tools\"));\n console.error(chalk.gray(\" → macOS: xcode-select --install\"));\n console.error(chalk.gray(\" → Linux: sudo apt install build-essential python3\"));\n console.error(\"\");\n console.error(chalk.gray(` Your Node.js version: ${process.version}`));\n } else {\n console.error(chalk.red(` Failed to start: ${error.message}`));\n }\n process.exit(1);\n }\n}\n","import chalk from \"chalk\";\nimport { resetDb } from \"@llmtap/collector\";\n\nexport async function resetCommand(): Promise<void> {\n try {\n resetDb();\n console.log(chalk.green(\" Data cleared successfully.\"));\n } catch (err: unknown) {\n const error = err as Error;\n console.error(chalk.red(` Failed to reset: ${error.message}`));\n process.exit(1);\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport chalk from \"chalk\";\nimport { getDb } from \"@llmtap/collector\";\nimport { spansToOtlp } from \"@llmtap/shared\";\nimport type { Span } from \"@llmtap/shared\";\n\ninterface ExportOptions {\n output: string;\n limit: string;\n format: string;\n endpoint?: string;\n service?: string;\n}\n\nfunction safeParse(v: unknown): unknown {\n if (!v || typeof v !== \"string\") return undefined;\n try { return JSON.parse(v); } catch { return undefined; }\n}\n\nfunction rowToSpan(row: Record<string, unknown>): Span {\n return {\n ...row,\n parentSpanId: (row.parentSpanId as string) ?? undefined,\n endTime: (row.endTime as number) ?? undefined,\n duration: (row.duration as number) ?? undefined,\n responseModel: (row.responseModel as string) ?? undefined,\n temperature: (row.temperature as number) ?? undefined,\n maxTokens: (row.maxTokens as number) ?? undefined,\n topP: (row.topP as number) ?? undefined,\n inputMessages: safeParse(row.inputMessages) as Span[\"inputMessages\"],\n outputMessages: safeParse(row.outputMessages) as Span[\"outputMessages\"],\n toolCalls: safeParse(row.toolCalls) as Span[\"toolCalls\"],\n tags: safeParse(row.tags) as Record<string, string> | undefined,\n errorType: (row.errorType as string) ?? undefined,\n errorMessage: (row.errorMessage as string) ?? undefined,\n sessionId: (row.sessionId as string) ?? undefined,\n userId: (row.userId as string) ?? undefined,\n } as Span;\n}\n\nexport async function exportCommand(options: ExportOptions): Promise<void> {\n try {\n const db = getDb();\n const limit = parseInt(options.limit, 10);\n const format = options.format ?? \"json\";\n\n if (format === \"otlp\") {\n return await exportOtlp(db, limit, options);\n }\n\n // Get traces\n const traces = db\n .prepare(\n `\n SELECT\n traceId,\n MIN(name) as name,\n MIN(startTime) as startTime,\n MAX(endTime) as endTime,\n CASE WHEN SUM(CASE WHEN status = 'error' THEN 1 ELSE 0 END) > 0\n THEN 'error' ELSE 'ok' END as status,\n COUNT(*) as spanCount,\n COALESCE(SUM(totalTokens), 0) as totalTokens,\n COALESCE(SUM(totalCost), 0) as totalCost\n FROM spans\n GROUP BY traceId\n ORDER BY startTime DESC\n LIMIT ?\n `\n )\n .all(limit) as Array<Record<string, unknown>>;\n\n // Get spans for each trace\n const getSpans = db.prepare(\"SELECT * FROM spans WHERE traceId = ? ORDER BY startTime ASC\");\n const exportData = traces.map((trace) => ({\n ...trace,\n spans: (getSpans.all(trace.traceId) as Array<Record<string, unknown>>).map((span) => ({\n ...span,\n inputMessages: safeParse(span.inputMessages),\n outputMessages: safeParse(span.outputMessages),\n toolCalls: safeParse(span.toolCalls),\n tags: safeParse(span.tags),\n })),\n }));\n\n let output: string;\n let ext: string;\n\n if (format === \"csv\") {\n ext = \"csv\";\n const headers = [\n \"traceId\", \"name\", \"status\", \"spanCount\", \"totalTokens\", \"totalCost\",\n \"startTime\", \"endTime\",\n ];\n const rows = traces.map((t) =>\n headers.map((h) => {\n const val = t[h];\n const s = String(val ?? \"\");\n return s.includes(\",\") || s.includes('\"') || s.includes(\"\\n\") ? `\"${s.replace(/\"/g, '\"\"')}\"` : s;\n }).join(\",\")\n );\n output = [headers.join(\",\"), ...rows].join(\"\\n\");\n } else {\n ext = \"json\";\n output = JSON.stringify(exportData, null, 2);\n }\n\n const defaultOutput = options.output === \"llmtap-export.json\" && format === \"csv\"\n ? \"llmtap-export.csv\"\n : options.output;\n const outputPath = path.resolve(defaultOutput);\n fs.writeFileSync(outputPath, output);\n\n console.log(chalk.green(` Exported ${traces.length} traces as ${ext.toUpperCase()} to ${outputPath}`));\n } catch (err: unknown) {\n const error = err as Error;\n console.error(chalk.red(` Export failed: ${error.message}`));\n process.exit(1);\n }\n}\n\nasync function exportOtlp(\n db: ReturnType<typeof getDb>,\n limit: number,\n options: ExportOptions\n): Promise<void> {\n const rows = db\n .prepare(\"SELECT * FROM spans ORDER BY startTime DESC LIMIT ?\")\n .all(limit) as Array<Record<string, unknown>>;\n\n const spans = rows.map(rowToSpan);\n const otlp = spansToOtlp(spans, options.service ?? \"llmtap\");\n\n // If --endpoint is provided, forward to OTLP collector\n if (options.endpoint) {\n console.log(chalk.blue(` Forwarding ${spans.length} spans to ${options.endpoint}...`));\n try {\n const res = await fetch(options.endpoint, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(otlp),\n signal: AbortSignal.timeout(30000),\n });\n if (!res.ok) {\n const body = await res.text().catch(() => \"\");\n console.error(chalk.red(` OTLP endpoint returned ${res.status}: ${body.slice(0, 200)}`));\n process.exit(1);\n }\n console.log(chalk.green(` Successfully forwarded ${spans.length} spans to OTLP endpoint`));\n } catch (err) {\n console.error(chalk.red(` Failed to reach OTLP endpoint: ${err instanceof Error ? err.message : String(err)}`));\n process.exit(1);\n }\n return;\n }\n\n // Otherwise write to file\n const outputPath = path.resolve(\n options.output === \"llmtap-export.json\" ? \"llmtap-export.otlp.json\" : options.output\n );\n fs.writeFileSync(outputPath, JSON.stringify(otlp, null, 2));\n console.log(chalk.green(` Exported ${spans.length} spans as OTLP JSON to ${outputPath}`));\n console.log(chalk.dim(` Import into Jaeger, Grafana Tempo, Datadog, or any OTLP-compatible backend`));\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport chalk from \"chalk\";\nimport { backupDb, getDbPath } from \"@llmtap/collector\";\nimport { formatBytes } from \"../lib/collector.js\";\n\ninterface BackupOptions {\n output?: string;\n}\n\nexport async function backupCommand(options: BackupOptions): Promise<void> {\n try {\n const sourcePath = getDbPath();\n const stamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const output = options.output?.trim() || `llmtap-backup-${stamp}.db`;\n const backupPath = backupDb(output);\n const sizeBytes = fs.statSync(backupPath).size;\n\n console.log(\"\");\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap Backup\"));\n console.log(\"\");\n console.log(` ${chalk.gray(\"Source:\")} ${chalk.white(sourcePath)}`);\n console.log(` ${chalk.gray(\"Backup file:\")} ${chalk.white(path.resolve(backupPath))}`);\n console.log(` ${chalk.gray(\"Size:\")} ${chalk.white(formatBytes(sizeBytes))}`);\n console.log(\"\");\n console.log(chalk.green(\" Backup completed.\"));\n console.log(\"\");\n } catch (err) {\n const error = err as Error;\n console.error(chalk.red(` Backup failed: ${error.message}`));\n process.exit(1);\n }\n}\n","export interface CollectorDbInfo {\n path: string;\n sizeBytes: number;\n spanCount: number;\n traceCount: number;\n oldestSpan: number | null;\n newestSpan: number | null;\n walMode: string;\n}\n\nexport async function isCollectorRunning(baseUrl = \"http://localhost:4781\"): Promise<boolean> {\n try {\n const res = await fetch(`${baseUrl}/health`, {\n signal: AbortSignal.timeout(1500),\n });\n return res.ok;\n } catch {\n return false;\n }\n}\n\nexport async function fetchCollectorDbInfo(\n baseUrl = \"http://localhost:4781\"\n): Promise<CollectorDbInfo | null> {\n try {\n const res = await fetch(`${baseUrl}/v1/db-info`, {\n signal: AbortSignal.timeout(3000),\n });\n if (!res.ok) return null;\n return (await res.json()) as CollectorDbInfo;\n } catch {\n return null;\n }\n}\n\nexport async function ingestSpans(\n spans: unknown[],\n baseUrl = \"http://localhost:4781\",\n batchSize = 250\n): Promise<number> {\n let accepted = 0;\n\n for (let index = 0; index < spans.length; index += batchSize) {\n const batch = spans.slice(index, index + batchSize);\n const res = await fetch(`${baseUrl}/v1/spans`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ spans: batch }),\n signal: AbortSignal.timeout(10000),\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => \"\");\n throw new Error(`Collector import failed with HTTP ${res.status}${body ? `: ${body.slice(0, 200)}` : \"\"}`);\n }\n\n const payload = (await res.json()) as { accepted?: number };\n accepted += payload.accepted ?? batch.length;\n }\n\n return accepted;\n}\n\nexport function formatBytes(bytes: number): string {\n if (bytes === 0) return \"0 B\";\n const units = [\"B\", \"KB\", \"MB\", \"GB\"];\n const index = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);\n return `${(bytes / Math.pow(1024, index)).toFixed(index === 0 ? 0 : 1)} ${units[index]}`;\n}\n","import chalk from \"chalk\";\nimport { restoreDb } from \"@llmtap/collector\";\nimport { isCollectorRunning } from \"../lib/collector.js\";\n\ninterface RestoreOptions {\n host?: string;\n}\n\nexport async function restoreCommand(inputPath: string, options: RestoreOptions): Promise<void> {\n const host = options.host ?? \"http://localhost:4781\";\n\n try {\n if (await isCollectorRunning(host)) {\n console.error(chalk.red(\" Restore blocked: the collector is currently running.\"));\n console.error(chalk.yellow(\" Stop LLMTap first, then run restore again.\"));\n process.exit(1);\n }\n\n const restoredPath = restoreDb(inputPath);\n\n console.log(\"\");\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap Restore\"));\n console.log(\"\");\n console.log(` ${chalk.gray(\"Backup:\")} ${chalk.white(inputPath)}`);\n console.log(` ${chalk.gray(\"Restored to:\")} ${chalk.white(restoredPath)}`);\n console.log(\"\");\n console.log(chalk.green(\" Restore completed. Start LLMTap to inspect the restored data.\"));\n console.log(\"\");\n } catch (err) {\n const error = err as Error;\n console.error(chalk.red(` Restore failed: ${error.message}`));\n process.exit(1);\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport chalk from \"chalk\";\nimport { insertSpans, resetDb } from \"@llmtap/collector\";\nimport { ingestSpans, isCollectorRunning } from \"../lib/collector.js\";\nimport { normalizeImportPayload, summarizeImportedSpans } from \"../lib/data.js\";\n\ninterface ImportOptions {\n replace?: boolean;\n host?: string;\n}\n\nexport async function importCommand(inputPath: string, options: ImportOptions): Promise<void> {\n try {\n const resolvedPath = path.resolve(inputPath);\n const file = fs.readFileSync(resolvedPath, \"utf8\");\n const payload = JSON.parse(file) as unknown;\n const spans = normalizeImportPayload(payload);\n const summary = summarizeImportedSpans(spans);\n const host = options.host ?? \"http://localhost:4781\";\n const collectorRunning = await isCollectorRunning(host);\n\n if (options.replace) {\n if (collectorRunning) {\n console.error(chalk.red(\" Replace import blocked: the collector is currently running.\"));\n console.error(chalk.yellow(\" Stop LLMTap first, then rerun with --replace.\"));\n process.exit(1);\n }\n resetDb();\n }\n\n const accepted = collectorRunning\n ? await ingestSpans(spans, host)\n : insertSpans(spans);\n\n console.log(\"\");\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap Import\"));\n console.log(\"\");\n console.log(` ${chalk.gray(\"File:\")} ${chalk.white(resolvedPath)}`);\n console.log(` ${chalk.gray(\"Trace count:\")} ${chalk.white(summary.traceCount.toLocaleString())}`);\n console.log(` ${chalk.gray(\"Span count:\")} ${chalk.white(summary.spanCount.toLocaleString())}`);\n console.log(` ${chalk.gray(\"Mode:\")} ${chalk.white(collectorRunning ? \"Live ingest via collector\" : \"Direct local database import\")}`);\n if (options.replace) {\n console.log(` ${chalk.gray(\"Replace:\")} ${chalk.white(\"Yes\")}`);\n }\n console.log(\"\");\n console.log(chalk.green(` Imported ${accepted.toLocaleString()} spans.`));\n console.log(\"\");\n } catch (err) {\n const error = err as Error;\n console.error(chalk.red(` Import failed: ${error.message}`));\n process.exit(1);\n }\n}\n","import type { SpanInput } from \"@llmtap/shared\";\n\ninterface TraceExportShape {\n traceId?: unknown;\n spans?: unknown;\n}\n\nfunction isSpanCandidate(value: unknown): value is SpanInput {\n if (!value || typeof value !== \"object\") return false;\n const span = value as Record<string, unknown>;\n return (\n typeof span.spanId === \"string\" &&\n typeof span.traceId === \"string\" &&\n typeof span.name === \"string\" &&\n typeof span.operationName === \"string\" &&\n typeof span.providerName === \"string\" &&\n typeof span.requestModel === \"string\" &&\n typeof span.startTime === \"number\" &&\n typeof span.status === \"string\"\n );\n}\n\nfunction collectFromArray(items: unknown[]): SpanInput[] {\n if (items.every(isSpanCandidate)) {\n return items;\n }\n\n const spans = items.flatMap((item) => {\n if (!item || typeof item !== \"object\") return [];\n const trace = item as TraceExportShape;\n return Array.isArray(trace.spans) ? trace.spans.filter(isSpanCandidate) : [];\n });\n\n return spans;\n}\n\nexport function normalizeImportPayload(payload: unknown): SpanInput[] {\n if (Array.isArray(payload)) {\n const spans = collectFromArray(payload);\n if (spans.length > 0) return spans;\n }\n\n if (payload && typeof payload === \"object\") {\n const record = payload as Record<string, unknown>;\n if (Array.isArray(record.spans)) {\n const spans = record.spans.filter(isSpanCandidate);\n if (spans.length > 0) return spans;\n }\n if (Array.isArray(record.traces)) {\n const spans = collectFromArray(record.traces);\n if (spans.length > 0) return spans;\n }\n }\n\n throw new Error(\n \"Unsupported import file. Expected LLMTap JSON export with traces[].spans or a raw spans array.\"\n );\n}\n\nexport function summarizeImportedSpans(spans: SpanInput[]): {\n spanCount: number;\n traceCount: number;\n} {\n return {\n spanCount: spans.length,\n traceCount: new Set(spans.map((span) => span.traceId)).size,\n };\n}\n","import chalk from \"chalk\";\nimport { fetchCollectorDbInfo, formatBytes } from \"../lib/collector.js\";\n\ninterface StatusOptions {\n host?: string;\n}\n\nexport async function statusCommand(options: StatusOptions = {}): Promise<void> {\n try {\n const info = await fetchCollectorDbInfo(options.host ?? \"http://localhost:4781\");\n\n if (!info) {\n console.error(chalk.red(\" Collector responded with an error.\"));\n process.exit(1);\n }\n\n console.log(\"\");\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap\") + chalk.green(\" - Running\"));\n console.log(\"\");\n console.log(` ${chalk.gray(\"Spans:\")} ${chalk.white(info.spanCount.toLocaleString())}`);\n console.log(` ${chalk.gray(\"Traces:\")} ${chalk.white(info.traceCount.toLocaleString())}`);\n console.log(` ${chalk.gray(\"DB size:\")} ${chalk.white(formatBytes(info.sizeBytes))}`);\n console.log(` ${chalk.gray(\"WAL mode:\")} ${chalk.white(info.walMode.toUpperCase())}`);\n console.log(` ${chalk.gray(\"DB path:\")} ${chalk.white(info.path)}`);\n\n if (info.oldestSpan && info.newestSpan) {\n const oldest = new Date(info.oldestSpan).toLocaleString();\n const newest = new Date(info.newestSpan).toLocaleString();\n console.log(` ${chalk.gray(\"Data range:\")} ${chalk.white(`${oldest} - ${newest}`)}`);\n }\n console.log(\"\");\n } catch {\n console.log(\"\");\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap\") + chalk.red(\" - Not running\"));\n console.log(\"\");\n console.log(chalk.gray(\" Start the collector with: \") + chalk.cyan(\"npx llmtap\"));\n console.log(\"\");\n }\n}\n","import chalk from \"chalk\";\r\n\r\ninterface TailOptions {\r\n format: string;\r\n}\r\n\r\nexport async function tailCommand(options: TailOptions): Promise<void> {\r\n const format = options.format ?? \"pretty\";\r\n const url = \"http://localhost:4781/v1/stream\";\r\n\r\n console.log(\"\");\r\n console.log(\r\n chalk.bold.hex(\"#6366f1\")(\" LLMTap\") +\r\n chalk.gray(\" — Streaming traces in real-time\")\r\n );\r\n console.log(chalk.gray(\" Press Ctrl+C to stop\"));\r\n console.log(\"\");\r\n\r\n try {\r\n const res = await fetch(url, {\r\n headers: { Accept: \"text/event-stream\" },\r\n });\r\n\r\n if (!res.ok || !res.body) {\r\n console.error(chalk.red(\" Could not connect to collector.\"));\r\n console.error(chalk.gray(\" Make sure the collector is running: npx llmtap\"));\r\n process.exit(1);\r\n }\r\n\r\n const decoder = new TextDecoder();\r\n const reader = res.body.getReader();\r\n let buffer = \"\";\r\n\r\n while (true) {\r\n const { done, value } = await reader.read();\r\n if (done) break;\r\n\r\n buffer += decoder.decode(value, { stream: true });\r\n const lines = buffer.split(\"\\n\");\r\n buffer = lines.pop() ?? \"\";\r\n\r\n for (const line of lines) {\r\n if (!line.startsWith(\"data: \")) continue;\r\n const json = line.slice(6).trim();\r\n if (!json) continue;\r\n\r\n try {\r\n const span = JSON.parse(json) as {\r\n spanId: string;\r\n traceId: string;\r\n name: string;\r\n providerName: string;\r\n requestModel: string;\r\n duration?: number;\r\n totalTokens: number;\r\n totalCost: number;\r\n status: string;\r\n errorMessage?: string;\r\n };\r\n\r\n if (format === \"json\") {\r\n console.log(json);\r\n } else {\r\n const dur = span.duration ? `${span.duration}ms` : \"...\";\r\n const cost =\r\n span.totalCost > 0 ? `$${span.totalCost.toFixed(4)}` : \"$0\";\r\n const statusIcon =\r\n span.status === \"error\" ? chalk.red(\"ERR\") : chalk.green(\"OK \");\r\n\r\n console.log(\r\n ` ${statusIcon} ${chalk.gray(dur.padStart(7))} ${chalk.cyan(span.providerName.padEnd(10))} ${chalk.white(span.requestModel.padEnd(24))} ${chalk.yellow(String(span.totalTokens).padStart(6) + \" tok\")} ${chalk.green(cost.padStart(8))} ${chalk.gray(span.name)}`\r\n );\r\n if (span.errorMessage) {\r\n console.log(\r\n ` ${chalk.red(\"→ \" + span.errorMessage.slice(0, 120))}`\r\n );\r\n }\r\n }\r\n } catch {\r\n // Skip malformed events\r\n }\r\n }\r\n }\r\n } catch {\r\n console.error(chalk.red(\" Could not connect to collector.\"));\r\n console.error(chalk.gray(\" Make sure the collector is running: npx llmtap\"));\r\n process.exit(1);\r\n }\r\n}\r\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport chalk from \"chalk\";\nimport { getDbDirPath, getDbPath } from \"@llmtap/collector\";\nimport { fetchCollectorDbInfo, formatBytes, isCollectorRunning } from \"../lib/collector.js\";\n\ntype CheckStatus = \"ok\" | \"warn\" | \"fail\";\n\ninterface Check {\n label: string;\n status: CheckStatus;\n detail: string;\n}\n\ninterface DoctorOptions {\n host?: string;\n}\n\nfunction formatCheck(check: Check): string {\n const icon =\n check.status === \"ok\"\n ? chalk.green(\" OK \")\n : check.status === \"warn\"\n ? chalk.yellow(\" ! \")\n : chalk.red(\" X \");\n\n const label = chalk.white(check.label.padEnd(20));\n const detail =\n check.status === \"ok\"\n ? chalk.gray(check.detail)\n : check.status === \"warn\"\n ? chalk.yellow(check.detail)\n : chalk.red(check.detail);\n\n return `${icon}${label} ${detail}`;\n}\n\nfunction hasLocalSdkInstall(): boolean {\n try {\n const requireFromCwd = createRequire(path.join(process.cwd(), \"__llmtap__.js\"));\n requireFromCwd.resolve(\"@llmtap/sdk\");\n return true;\n } catch {\n return false;\n }\n}\n\nfunction findPackageJson(): { hasPackageJson: boolean; path?: string } {\n const packageJsonPath = path.join(process.cwd(), \"package.json\");\n return fs.existsSync(packageJsonPath)\n ? { hasPackageJson: true, path: packageJsonPath }\n : { hasPackageJson: false };\n}\n\nexport async function doctorCommand(options: DoctorOptions = {}): Promise<void> {\n const host = options.host ?? \"http://localhost:4781\";\n const checks: Check[] = [];\n const nextSteps: string[] = [];\n\n console.log(\"\");\n console.log(chalk.bold.hex(\"#6366f1\")(\" LLMTap Doctor\"));\n console.log(chalk.gray(` Checking runtime, storage, and onboarding state at ${host}`));\n console.log(\"\");\n\n const nodeVersion = process.version;\n const major = parseInt(nodeVersion.slice(1), 10);\n checks.push(\n major >= 18\n ? { label: \"Node.js version\", status: \"ok\", detail: nodeVersion }\n : { label: \"Node.js version\", status: \"fail\", detail: `${nodeVersion} (requires Node 18 or newer)` }\n );\n\n const collectorRunning = await isCollectorRunning(host);\n if (collectorRunning) {\n checks.push({ label: \"Collector\", status: \"ok\", detail: `Running at ${host}` });\n } else {\n checks.push({ label: \"Collector\", status: \"warn\", detail: \"Not running right now\" });\n nextSteps.push(\"Start LLMTap with `npx llmtap` to open the dashboard and collector.\");\n }\n\n const dbDir = getDbDirPath();\n const dbPath = getDbPath();\n const dbDirExists = fs.existsSync(dbDir);\n const dbFileExists = fs.existsSync(dbPath);\n\n checks.push(\n dbDirExists\n ? { label: \"DB directory\", status: \"ok\", detail: dbDir }\n : { label: \"DB directory\", status: \"warn\", detail: `Not created yet (${dbDir})` }\n );\n\n if (dbDirExists) {\n try {\n fs.accessSync(dbDir, fs.constants.R_OK | fs.constants.W_OK);\n checks.push({ label: \"DB permissions\", status: \"ok\", detail: \"Readable and writable\" });\n } catch {\n checks.push({ label: \"DB permissions\", status: \"fail\", detail: \"Current user cannot read/write the data directory\" });\n }\n }\n\n if (dbFileExists) {\n const stat = fs.statSync(dbPath);\n checks.push({ label: \"DB file\", status: \"ok\", detail: `${dbPath} (${formatBytes(stat.size)})` });\n } else {\n checks.push({ label: \"DB file\", status: \"warn\", detail: `No local database yet (${dbPath})` });\n }\n\n const dbInfo = collectorRunning ? await fetchCollectorDbInfo(host) : null;\n if (collectorRunning && dbInfo) {\n const spanSummary =\n dbInfo.spanCount > 0\n ? `${dbInfo.spanCount.toLocaleString()} spans across ${dbInfo.traceCount.toLocaleString()} traces`\n : \"Collector is healthy, but no spans have been captured yet\";\n checks.push({\n label: \"Collector data\",\n status: dbInfo.spanCount > 0 ? \"ok\" : \"warn\",\n detail: `${spanSummary}; WAL=${dbInfo.walMode.toUpperCase()}`,\n });\n if (dbInfo.spanCount === 0) {\n nextSteps.push(\"Wrap your LLM client with `@llmtap/sdk`, make one model call, then refresh the dashboard.\");\n }\n } else if (collectorRunning) {\n checks.push({ label: \"Collector data\", status: \"warn\", detail: \"Collector is up, but /v1/db-info did not respond cleanly\" });\n }\n\n const packageJson = findPackageJson();\n if (packageJson.hasPackageJson) {\n checks.push({ label: \"Project root\", status: \"ok\", detail: packageJson.path! });\n } else {\n checks.push({ label: \"Project root\", status: \"warn\", detail: \"No package.json in the current directory\" });\n nextSteps.push(\"Run `doctor` from the app you want to instrument so LLMTap can verify local dependencies.\");\n }\n\n if (hasLocalSdkInstall()) {\n checks.push({ label: \"@llmtap/sdk\", status: \"ok\", detail: \"Installed in the current project\" });\n } else {\n checks.push({ label: \"@llmtap/sdk\", status: \"warn\", detail: \"Not installed in the current project\" });\n nextSteps.push(\"Install the SDK in your app with `npm i @llmtap/sdk` or `pnpm add @llmtap/sdk`.\");\n }\n\n for (const check of checks) {\n console.log(formatCheck(check));\n }\n\n const failCount = checks.filter((check) => check.status === \"fail\").length;\n const warnCount = checks.filter((check) => check.status === \"warn\").length;\n\n console.log(\"\");\n if (nextSteps.length > 0) {\n console.log(chalk.bold.white(\" Next steps\"));\n for (const step of nextSteps) {\n console.log(chalk.gray(` - ${step}`));\n }\n console.log(\"\");\n }\n\n if (failCount > 0) {\n console.log(chalk.red(` ${failCount} blocking issue(s) found.`));\n } else if (warnCount > 0) {\n console.log(chalk.yellow(` ${warnCount} warning(s) found.`));\n } else {\n console.log(chalk.green(\" All checks passed.\"));\n }\n console.log(\"\");\n}\n","import chalk from \"chalk\";\r\n\r\ninterface StatsResponse {\r\n totalTraces: number;\r\n totalSpans: number;\r\n totalTokens: number;\r\n totalCost: number;\r\n avgDuration: number;\r\n errorCount: number;\r\n errorRate: number;\r\n byProvider: { provider: string; spanCount: number; totalTokens: number; totalCost: number; avgDuration: number }[];\r\n byModel: { model: string; provider: string; spanCount: number; totalTokens: number; totalCost: number; avgDuration: number }[];\r\n}\r\n\r\nexport async function statsCommand(options: { period?: string; host?: string }): Promise<void> {\r\n const period = Number(options.period ?? \"24\");\r\n const host = options.host ?? \"http://localhost:4781\";\r\n\r\n try {\r\n const res = await fetch(`${host}/v1/stats?period=${period}`);\r\n if (!res.ok) {\r\n console.error(chalk.red(`Error: Collector returned HTTP ${res.status}`));\r\n console.error(chalk.dim(\"Is the collector running? Try: npx llmtap start\"));\r\n process.exit(1);\r\n }\r\n\r\n const stats = (await res.json()) as StatsResponse;\r\n\r\n console.log(\"\");\r\n console.log(chalk.bold.white(` LLMTap Stats — Last ${period}h`));\r\n console.log(chalk.dim(\" ─────────────────────────────────\"));\r\n console.log(\"\");\r\n\r\n // Summary\r\n const errorPct = (stats.errorRate * 100).toFixed(1);\r\n console.log(` ${chalk.dim(\"Traces\")} ${chalk.bold.white(String(stats.totalTraces))}`);\r\n console.log(` ${chalk.dim(\"Spans\")} ${chalk.bold.white(String(stats.totalSpans))}`);\r\n console.log(` ${chalk.dim(\"Tokens\")} ${chalk.bold.white(stats.totalTokens.toLocaleString())}`);\r\n console.log(` ${chalk.dim(\"Total Cost\")} ${chalk.bold.green(\"$\" + stats.totalCost.toFixed(4))}`);\r\n console.log(` ${chalk.dim(\"Avg Latency\")} ${chalk.white(formatMs(stats.avgDuration))}`);\r\n console.log(\r\n ` ${chalk.dim(\"Error Rate\")} ${\r\n stats.errorRate > 0.05\r\n ? chalk.bold.red(errorPct + \"%\")\r\n : chalk.green(errorPct + \"%\")\r\n } ${chalk.dim(`(${stats.errorCount} errors)`)}`\r\n );\r\n\r\n // Top providers\r\n if (stats.byProvider.length > 0) {\r\n console.log(\"\");\r\n console.log(chalk.bold.white(\" Top Providers\"));\r\n console.log(chalk.dim(\" ─────────────────────────────────\"));\r\n for (const p of stats.byProvider.slice(0, 5)) {\r\n const bar = makeBar(p.totalCost, stats.totalCost, 20);\r\n console.log(\r\n ` ${chalk.cyan(p.provider.padEnd(12))} ${chalk.dim(String(p.spanCount).padStart(5) + \" calls\")} ${chalk.green(\"$\" + p.totalCost.toFixed(4).padStart(8))} ${chalk.dim(bar)}`\r\n );\r\n }\r\n }\r\n\r\n // Top models\r\n if (stats.byModel.length > 0) {\r\n console.log(\"\");\r\n console.log(chalk.bold.white(\" Top Models\"));\r\n console.log(chalk.dim(\" ─────────────────────────────────\"));\r\n for (const m of stats.byModel.slice(0, 8)) {\r\n const bar = makeBar(m.totalCost, stats.totalCost, 20);\r\n console.log(\r\n ` ${chalk.white(m.model.padEnd(28).slice(0, 28))} ${chalk.dim(String(m.spanCount).padStart(5) + \" calls\")} ${chalk.green(\"$\" + m.totalCost.toFixed(4).padStart(8))} ${chalk.dim(bar)}`\r\n );\r\n }\r\n }\r\n\r\n console.log(\"\");\r\n } catch (err) {\r\n if (err instanceof TypeError && (err as NodeJS.ErrnoException).cause) {\r\n console.error(chalk.red(\"Error: Cannot connect to collector\"));\r\n console.error(chalk.dim(\"Is the collector running? Try: npx llmtap start\"));\r\n } else {\r\n console.error(chalk.red(\"Error:\"), err instanceof Error ? err.message : err);\r\n }\r\n process.exit(1);\r\n }\r\n}\r\n\r\nfunction formatMs(ms: number): string {\r\n if (ms < 1000) return `${Math.round(ms)}ms`;\r\n return `${(ms / 1000).toFixed(2)}s`;\r\n}\r\n\r\nfunction makeBar(value: number, total: number, width: number): string {\r\n if (total <= 0) return \"\";\r\n const filled = Math.max(Math.round((value / total) * width), 1);\r\n return \"█\".repeat(filled) + \"░\".repeat(width - filled);\r\n}\r\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,qBAAqB;AAC9B,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAAS,aAAa,uBAAuB;AAE7C,IAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAW7D,eAAsB,aAAa,SAAsC;AACvE,QAAM,OAAO,SAAS,QAAQ,MAAM,EAAE;AACtC,QAAM,gBAAgB,QAAQ,YAC1B,SAAS,QAAQ,WAAW,EAAE,IAC9B;AAKJ,QAAM,cAAc,KAAK,QAAQ,WAAW,WAAW;AACvD,QAAM,eAAe,KAAK,QAAQ,WAAW,MAAM,MAAM,aAAa,MAAM;AAC5E,QAAM,gBAAgB,GAAG,WAAW,WAAW,IAAI,cAAc;AAEjE,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,MAAM,KAAK,IAAI,SAAS,EAAE,UAAU,IAAI,MAAM,KAAK,2BAA2B,CAAC;AAC3F,UAAQ,IAAI,EAAE;AAEd,MAAI;AACF,UAAM,OAAO,QAAQ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AQ,EACvE,OAAO,aAAa;AAEvB,QACG,QAAQ,QAAQ,EAChB,YAAY,2DAA2D,EACvE,OAAO,uBAAuB,oBAAoB,EAClD,OAAO,aAAa;AAEvB,QACG,QAAQ,iBAAiB,EACzB,YAAY,sDAAsD,EAClE,OAAO,gBAAgB,2CAA2C,uBAAuB,EACzF,OAAO,cAAc;AAExB,QACG,QAAQ,gBAAgB,EACxB,YAAY,oDAAoD,EAChE,OAAO,aAAa,+DAA+D,EACnF,OAAO,gBAAgB,8CAA8C,uBAAuB,EAC5F,OAAO,aAAa;AAEvB,QACG,QAAQ,MAAM,EACd,YAAY,wCAAwC,EACpD,OAAO,yBAAyB,kCAAkC,QAAQ,EAC1E,OAAO,WAAW;AAErB,QACG,QAAQ,QAAQ,EAChB,YAAY,8BAA8B,EAC1C,OAAO,gBAAgB,iBAAiB,uBAAuB,EAC/D,OAAO,aAAa;AAEvB,QACG,QAAQ,OAAO,EACf,YAAY,kDAAkD,EAC9D,OAAO,wBAAwB,wBAAwB,IAAI,EAC3D,OAAO,gBAAgB,iBAAiB,uBAAuB,EAC/D,OAAO,YAAY;AAEtB,QAAQ,MAAM;","names":["chalk","fs","path","chalk","fs","path","chalk","fs","chalk","path","chalk","chalk","fs","path","chalk","resetDb","path","fs","chalk","resetDb","chalk","chalk","chalk","fs","path","chalk","getDbPath","chalk","path","fs","getDbPath","chalk"]}
|
package/package.json
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llmtap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "DevTools for AI Agents - See every LLM call, trace agent workflows, track costs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"llmtap": "./dist/index.js"
|
|
8
8
|
},
|
|
9
|
-
"files": [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"build": "tsup",
|
|
13
|
-
"postbuild": "node -e \"const fs=require('fs');const path=require('path');const src=path.resolve(__dirname,'..','dashboard','dist');const dst=path.resolve(__dirname,'dist','dashboard');if(fs.existsSync(src)){fs.cpSync(src,dst,{recursive:true});console.log('Dashboard bundled into CLI dist')}else{console.log('Dashboard dist not found at',src)}\"",
|
|
14
|
-
"clean": "rimraf dist"
|
|
15
|
-
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
16
12
|
"dependencies": {
|
|
17
|
-
"@llmtap/collector": "
|
|
18
|
-
"@llmtap/shared": "
|
|
13
|
+
"@llmtap/collector": "^0.1.4",
|
|
14
|
+
"@llmtap/shared": "^0.1.4",
|
|
19
15
|
"chalk": "^5.4.0",
|
|
20
16
|
"commander": "^13.0.0",
|
|
21
17
|
"open": "^10.1.0"
|
|
@@ -24,11 +20,21 @@
|
|
|
24
20
|
"@types/node": "^25.4.0",
|
|
25
21
|
"rimraf": "^6.0.0",
|
|
26
22
|
"tsup": "^8.4.0",
|
|
27
|
-
"typescript": "^5.7.0"
|
|
23
|
+
"typescript": "^5.7.0",
|
|
24
|
+
"vitest": "^3.0.0"
|
|
28
25
|
},
|
|
29
26
|
"keywords": [
|
|
30
|
-
"llm",
|
|
31
|
-
"
|
|
27
|
+
"llm",
|
|
28
|
+
"ai",
|
|
29
|
+
"agent",
|
|
30
|
+
"observability",
|
|
31
|
+
"devtools",
|
|
32
|
+
"openai",
|
|
33
|
+
"anthropic",
|
|
34
|
+
"gemini",
|
|
35
|
+
"groq",
|
|
36
|
+
"tracing",
|
|
37
|
+
"debugging"
|
|
32
38
|
],
|
|
33
39
|
"engines": {
|
|
34
40
|
"node": ">=18"
|
|
@@ -38,5 +44,12 @@
|
|
|
38
44
|
"type": "git",
|
|
39
45
|
"url": "https://github.com/DivyaanshuXD/LLMTap",
|
|
40
46
|
"directory": "packages/cli"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"prebuild": "node -e \"\"",
|
|
50
|
+
"build": "tsup",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"postbuild": "node -e \"const fs=require('fs');const path=require('path');const src=path.resolve(__dirname,'..','dashboard','dist');const dst=path.resolve(__dirname,'dist','dashboard');if(fs.existsSync(src)){fs.cpSync(src,dst,{recursive:true});console.log('Dashboard bundled into CLI dist')}else{console.log('Dashboard dist not found at',src)}\"",
|
|
53
|
+
"clean": "rimraf dist"
|
|
41
54
|
}
|
|
42
|
-
}
|
|
55
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as a,N as i,X as s,Y as t,n as e}from"./chart-styles-BD7W97c9.js";var x=a({chartName:"BarChart",GraphicalChild:i,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:s},{axisType:"yAxis",AxisComp:t}],formatAxisMap:e});export{x as B};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{c as le,a as E,R as f,q as He,r as be,j as s,m as D,f as st,g as ot}from"./index-M3DwcRrc.js";import{u as lt,P as ct,b as I,a as ut,c as dt}from"./format-CNuIwzac.js";import{f as j,r as We,p as ft,q as Ze,s as pt,g as M,v as je,w as S,L as O,x as Ge,y as Ae,z as Ue,D as mt,C as ht,b as Z,j as z,S as vt,A as xt,B as yt,a as Oe,d as gt,i as q,e as bt,u as jt,G as At,E as ne,F as kt,H as Xe,I as Pt,J as re,K as Ne,l as wt,M as Ot,R as _e,o as Nt,X as _t,Y as St,T as Se,t as Te,N as Tt}from"./chart-styles-BD7W97c9.js";import{a as Re}from"./provider-colors-DcHYMgVv.js";import{C as Rt}from"./coins-BmXTNwva.js";import{Z as Et}from"./zap-DjNN7wJp.js";import{B as Lt}from"./BarChart-C6HDCruv.js";import{O as It}from"./orbit-eg7lcPsM.js";import{L as $t}from"./layers-BQ0MpYqk.js";const Ct=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Ee=le("chart-column",Ct);const Dt=[["path",{d:"M13 16H8",key:"wsln4y"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z",key:"ycz6yz"}]],Mt=le("receipt-text",Dt);const Bt=[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]],Ft=le("timer-reset",Bt);const Kt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]],Vt=le("wallet-cards",Kt);var zt=["points","className","baseLinePoints","connectNulls"];function H(){return H=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},H.apply(this,arguments)}function qt(r,e){if(r==null)return{};var n=Ht(r,e),t,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(a=0;a<o.length;a++)t=o[a],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(r,t)&&(n[t]=r[t])}return n}function Ht(r,e){if(r==null)return{};var n={};for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if(e.indexOf(t)>=0)continue;n[t]=r[t]}return n}function Le(r){return Ut(r)||Gt(r)||Zt(r)||Wt()}function Wt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zt(r,e){if(r){if(typeof r=="string")return ve(r,e);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor&&(n=r.constructor.name),n==="Map"||n==="Set")return Array.from(r);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ve(r,e)}}function Gt(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Ut(r){if(Array.isArray(r))return ve(r)}function ve(r,e){(e==null||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}var Ie=function(e){return e&&e.x===+e.x&&e.y===+e.y},Xt=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=[[]];return e.forEach(function(t){Ie(t)?n[n.length-1].push(t):n[n.length-1].length>0&&n.push([])}),Ie(e[0])&&n[n.length-1].push(e[0]),n[n.length-1].length<=0&&(n=n.slice(0,-1)),n},J=function(e,n){var t=Xt(e);n&&(t=[t.reduce(function(o,i){return[].concat(Le(o),Le(i))},[])]);var a=t.map(function(o){return o.reduce(function(i,l,d){return"".concat(i).concat(d===0?"M":"L").concat(l.x,",").concat(l.y)},"")}).join("");return t.length===1?"".concat(a,"Z"):a},Yt=function(e,n,t){var a=J(e,t);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(J(n.reverse(),t).slice(1))},Jt=function(e){var n=e.points,t=e.className,a=e.baseLinePoints,o=e.connectNulls,i=qt(e,zt);if(!n||!n.length)return null;var l=E("recharts-polygon",t);if(a&&a.length){var d=i.stroke&&i.stroke!=="none",c=Yt(n,a,o);return f.createElement("g",{className:l},f.createElement("path",H({},j(i,!0),{fill:c.slice(-1)==="Z"?i.fill:"none",stroke:"none",d:c})),d?f.createElement("path",H({},j(i,!0),{fill:"none",d:J(n,o)})):null,d?f.createElement("path",H({},j(i,!0),{fill:"none",d:J(a,o)})):null)}var p=J(n,o);return f.createElement("path",H({},j(i,!0),{fill:p.slice(-1)==="Z"?i.fill:"none",className:l,d:p}))},pe,$e;function Qt(){if($e)return pe;$e=1;var r=We(),e=ft(),n=Ze();function t(a,o){return a&&a.length?r(a,n(o,2),e):void 0}return pe=t,pe}var er=Qt();const tr=He(er);var me,Ce;function rr(){if(Ce)return me;Ce=1;var r=We(),e=Ze(),n=pt();function t(a,o){return a&&a.length?r(a,e(o,2),n):void 0}return me=t,me}var nr=rr();const ar=He(nr);var ir=["cx","cy","angle","ticks","axisLine"],sr=["ticks","tick","angle","tickFormatter","stroke"];function G(r){"@babel/helpers - typeof";return G=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},G(r)}function Q(){return Q=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},Q.apply(this,arguments)}function De(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),n.push.apply(n,t)}return n}function $(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?De(Object(n),!0).forEach(function(t){ce(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):De(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function Me(r,e){if(r==null)return{};var n=or(r,e),t,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(a=0;a<o.length;a++)t=o[a],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(r,t)&&(n[t]=r[t])}return n}function or(r,e){if(r==null)return{};var n={};for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if(e.indexOf(t)>=0)continue;n[t]=r[t]}return n}function lr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Be(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,Je(t.key),t)}}function cr(r,e,n){return e&&Be(r.prototype,e),n&&Be(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function ur(r,e,n){return e=ie(e),dr(r,Ye()?Reflect.construct(e,n||[],ie(r).constructor):e.apply(r,n))}function dr(r,e){if(e&&(G(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return fr(r)}function fr(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Ye(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ye=function(){return!!r})()}function ie(r){return ie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ie(r)}function pr(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&xe(r,e)}function xe(r,e){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},xe(r,e)}function ce(r,e,n){return e=Je(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function Je(r){var e=mr(r,"string");return G(e)=="symbol"?e:e+""}function mr(r,e){if(G(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e);if(G(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}var ue=(function(r){function e(){return lr(this,e),ur(this,e,arguments)}return pr(e,r),cr(e,[{key:"getTickValueCoord",value:function(t){var a=t.coordinate,o=this.props,i=o.angle,l=o.cx,d=o.cy;return S(l,d,a,i)}},{key:"getTickTextAnchor",value:function(){var t=this.props.orientation,a;switch(t){case"left":a="end";break;case"right":a="start";break;default:a="middle";break}return a}},{key:"getViewBox",value:function(){var t=this.props,a=t.cx,o=t.cy,i=t.angle,l=t.ticks,d=tr(l,function(p){return p.coordinate||0}),c=ar(l,function(p){return p.coordinate||0});return{cx:a,cy:o,startAngle:i,endAngle:i,innerRadius:c.coordinate||0,outerRadius:d.coordinate||0}}},{key:"renderAxisLine",value:function(){var t=this.props,a=t.cx,o=t.cy,i=t.angle,l=t.ticks,d=t.axisLine,c=Me(t,ir),p=l.reduce(function(m,u){return[Math.min(m[0],u.coordinate),Math.max(m[1],u.coordinate)]},[1/0,-1/0]),h=S(a,o,p[0],i),y=S(a,o,p[1],i),A=$($($({},j(c,!1)),{},{fill:"none"},j(d,!1)),{},{x1:h.x,y1:h.y,x2:y.x,y2:y.y});return f.createElement("line",Q({className:"recharts-polar-radius-axis-line"},A))}},{key:"renderTicks",value:function(){var t=this,a=this.props,o=a.ticks,i=a.tick,l=a.angle,d=a.tickFormatter,c=a.stroke,p=Me(a,sr),h=this.getTickTextAnchor(),y=j(p,!1),A=j(i,!1),m=o.map(function(u,x){var g=t.getTickValueCoord(u),b=$($($($({textAnchor:h,transform:"rotate(".concat(90-l,", ").concat(g.x,", ").concat(g.y,")")},y),{},{stroke:"none",fill:c},A),{},{index:x},g),{},{payload:u});return f.createElement(O,Q({className:E("recharts-polar-radius-axis-tick",Ge(i)),key:"tick-".concat(u.coordinate)},Ae(t.props,u,x)),e.renderTickItem(i,b,d?d(u.value,x):u.value))});return f.createElement(O,{className:"recharts-polar-radius-axis-ticks"},m)}},{key:"render",value:function(){var t=this.props,a=t.ticks,o=t.axisLine,i=t.tick;return!a||!a.length?null:f.createElement(O,{className:E("recharts-polar-radius-axis",this.props.className)},o&&this.renderAxisLine(),i&&this.renderTicks(),Ue.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(t,a,o){var i;return f.isValidElement(t)?i=f.cloneElement(t,a):M(t)?i=t(a):i=f.createElement(je,Q({},a,{className:"recharts-polar-radius-axis-tick-value"}),o),i}}])})(be.PureComponent);ce(ue,"displayName","PolarRadiusAxis");ce(ue,"axisType","radiusAxis");ce(ue,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function U(r){"@babel/helpers - typeof";return U=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(r)}function B(){return B=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},B.apply(this,arguments)}function Fe(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),n.push.apply(n,t)}return n}function C(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Fe(Object(n),!0).forEach(function(t){de(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Fe(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function hr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Ke(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,et(t.key),t)}}function vr(r,e,n){return e&&Ke(r.prototype,e),n&&Ke(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function xr(r,e,n){return e=se(e),yr(r,Qe()?Reflect.construct(e,n||[],se(r).constructor):e.apply(r,n))}function yr(r,e){if(e&&(U(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return gr(r)}function gr(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Qe(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Qe=function(){return!!r})()}function se(r){return se=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},se(r)}function br(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&ye(r,e)}function ye(r,e){return ye=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},ye(r,e)}function de(r,e,n){return e=et(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function et(r){var e=jr(r,"string");return U(e)=="symbol"?e:e+""}function jr(r,e){if(U(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e);if(U(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}var Ar=Math.PI/180,Ve=1e-5,fe=(function(r){function e(){return hr(this,e),xr(this,e,arguments)}return br(e,r),vr(e,[{key:"getTickLineCoord",value:function(t){var a=this.props,o=a.cx,i=a.cy,l=a.radius,d=a.orientation,c=a.tickSize,p=c||8,h=S(o,i,l,t.coordinate),y=S(o,i,l+(d==="inner"?-1:1)*p,t.coordinate);return{x1:h.x,y1:h.y,x2:y.x,y2:y.y}}},{key:"getTickTextAnchor",value:function(t){var a=this.props.orientation,o=Math.cos(-t.coordinate*Ar),i;return o>Ve?i=a==="outer"?"start":"end":o<-Ve?i=a==="outer"?"end":"start":i="middle",i}},{key:"renderAxisLine",value:function(){var t=this.props,a=t.cx,o=t.cy,i=t.radius,l=t.axisLine,d=t.axisLineType,c=C(C({},j(this.props,!1)),{},{fill:"none"},j(l,!1));if(d==="circle")return f.createElement(mt,B({className:"recharts-polar-angle-axis-line"},c,{cx:a,cy:o,r:i}));var p=this.props.ticks,h=p.map(function(y){return S(a,o,i,y.coordinate)});return f.createElement(Jt,B({className:"recharts-polar-angle-axis-line"},c,{points:h}))}},{key:"renderTicks",value:function(){var t=this,a=this.props,o=a.ticks,i=a.tick,l=a.tickLine,d=a.tickFormatter,c=a.stroke,p=j(this.props,!1),h=j(i,!1),y=C(C({},p),{},{fill:"none"},j(l,!1)),A=o.map(function(m,u){var x=t.getTickLineCoord(m),g=t.getTickTextAnchor(m),b=C(C(C({textAnchor:g},p),{},{stroke:"none",fill:c},h),{},{index:u,payload:m,x:x.x2,y:x.y2});return f.createElement(O,B({className:E("recharts-polar-angle-axis-tick",Ge(i)),key:"tick-".concat(m.coordinate)},Ae(t.props,m,u)),l&&f.createElement("line",B({className:"recharts-polar-angle-axis-tick-line"},y,x)),i&&e.renderTickItem(i,b,d?d(m.value,u):m.value))});return f.createElement(O,{className:"recharts-polar-angle-axis-ticks"},A)}},{key:"render",value:function(){var t=this.props,a=t.ticks,o=t.radius,i=t.axisLine;return o<=0||!a||!a.length?null:f.createElement(O,{className:E("recharts-polar-angle-axis",this.props.className)},i&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(t,a,o){var i;return f.isValidElement(t)?i=f.cloneElement(t,a):M(t)?i=t(a):i=f.createElement(je,B({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),i}}])})(be.PureComponent);de(fe,"displayName","PolarAngleAxis");de(fe,"axisType","angleAxis");de(fe,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var ae;function X(r){"@babel/helpers - typeof";return X=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},X(r)}function W(){return W=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},W.apply(this,arguments)}function ze(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),n.push.apply(n,t)}return n}function v(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ze(Object(n),!0).forEach(function(t){P(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):ze(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function kr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function qe(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,rt(t.key),t)}}function Pr(r,e,n){return e&&qe(r.prototype,e),n&&qe(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function wr(r,e,n){return e=oe(e),Or(r,tt()?Reflect.construct(e,n||[],oe(r).constructor):e.apply(r,n))}function Or(r,e){if(e&&(X(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Nr(r)}function Nr(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function tt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(tt=function(){return!!r})()}function oe(r){return oe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},oe(r)}function _r(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&ge(r,e)}function ge(r,e){return ge=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},ge(r,e)}function P(r,e,n){return e=rt(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function rt(r){var e=Sr(r,"string");return X(e)=="symbol"?e:e+""}function Sr(r,e){if(X(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e);if(X(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}var T=(function(r){function e(n){var t;return kr(this,e),t=wr(this,e,[n]),P(t,"pieRef",null),P(t,"sectorRefs",[]),P(t,"id",jt("recharts-pie-")),P(t,"handleAnimationEnd",function(){var a=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),M(a)&&a()}),P(t,"handleAnimationStart",function(){var a=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),M(a)&&a()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return _r(e,r),Pr(e,[{key:"isActiveIndex",value:function(t){var a=this.props.activeIndex;return Array.isArray(a)?a.indexOf(t)!==-1:t===a}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var a=this.props.isAnimationActive;if(a&&!this.state.isAnimationFinished)return null;var o=this.props,i=o.label,l=o.labelLine,d=o.dataKey,c=o.valueKey,p=j(this.props,!1),h=j(i,!1),y=j(l,!1),A=i&&i.offsetRadius||20,m=t.map(function(u,x){var g=(u.startAngle+u.endAngle)/2,b=S(u.cx,u.cy,u.outerRadius+A,g),w=v(v(v(v({},p),u),{},{stroke:"none"},h),{},{index:x,textAnchor:e.getTextAnchor(b.x,u.cx)},b),F=v(v(v(v({},p),u),{},{fill:"none",stroke:u.fill},y),{},{index:x,points:[S(u.cx,u.cy,u.outerRadius,g),b]}),N=d;return Z(d)&&Z(c)?N="value":Z(d)&&(N=c),f.createElement(O,{key:"label-".concat(u.startAngle,"-").concat(u.endAngle,"-").concat(u.midAngle,"-").concat(x)},l&&e.renderLabelLineItem(l,F,"line"),e.renderLabelItem(i,w,z(u,N)))});return f.createElement(O,{className:"recharts-pie-labels"},m)}},{key:"renderSectorsStatically",value:function(t){var a=this,o=this.props,i=o.activeShape,l=o.blendStroke,d=o.inactiveShape;return t.map(function(c,p){if(c?.startAngle===0&&c?.endAngle===0&&t.length!==1)return null;var h=a.isActiveIndex(p),y=d&&a.hasActiveIndex()?d:null,A=h?i:y,m=v(v({},c),{},{stroke:l?c.fill:c.stroke,tabIndex:-1});return f.createElement(O,W({ref:function(x){x&&!a.sectorRefs.includes(x)&&a.sectorRefs.push(x)},tabIndex:-1,className:"recharts-pie-sector"},Ae(a.props,c,p),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(p)}),f.createElement(vt,W({option:A,isActive:h,shapeType:"sector"},m)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,a=this.props,o=a.sectors,i=a.isAnimationActive,l=a.animationBegin,d=a.animationDuration,c=a.animationEasing,p=a.animationId,h=this.state,y=h.prevSectors,A=h.prevIsAnimationActive;return f.createElement(xt,{begin:l,duration:d,isActive:i,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(p,"-").concat(A),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(m){var u=m.t,x=[],g=o&&o[0],b=g.startAngle;return o.forEach(function(w,F){var N=y&&y[F],L=F>0?yt(w,"paddingAngle",0):0;if(N){var Y=Oe(N.endAngle-N.startAngle,w.endAngle-w.startAngle),k=v(v({},w),{},{startAngle:b+L,endAngle:b+Y(u)+L});x.push(k),b=k.endAngle}else{var K=w.endAngle,_=w.startAngle,ee=Oe(0,K-_),te=ee(u),R=v(v({},w),{},{startAngle:b+L,endAngle:b+te+L});x.push(R),b=R.endAngle}}),f.createElement(O,null,t.renderSectorsStatically(x))})}},{key:"attachKeyboardHandlers",value:function(t){var a=this;t.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var i=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"ArrowRight":{var l=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,a=t.sectors,o=t.isAnimationActive,i=this.state.prevSectors;return o&&a&&a.length&&(!i||!gt(i,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,a=this.props,o=a.hide,i=a.sectors,l=a.className,d=a.label,c=a.cx,p=a.cy,h=a.innerRadius,y=a.outerRadius,A=a.isAnimationActive,m=this.state.isAnimationFinished;if(o||!i||!i.length||!q(c)||!q(p)||!q(h)||!q(y))return null;var u=E("recharts-pie",l);return f.createElement(O,{tabIndex:this.props.rootTabIndex,className:u,ref:function(g){t.pieRef=g}},this.renderSectors(),d&&this.renderLabels(i),Ue.renderCallByParent(this.props,null,!1),(!A||m)&&bt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,a){return a.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==a.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:t.sectors!==a.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,a){return t>a?"start":t<a?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,a,o){if(f.isValidElement(t))return f.cloneElement(t,a);if(M(t))return t(a);var i=E("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return f.createElement(ht,W({},a,{key:o,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,a,o){if(f.isValidElement(t))return f.cloneElement(t,a);var i=o;if(M(t)&&(i=t(a),f.isValidElement(i)))return i;var l=E("recharts-pie-label-text",typeof t!="boolean"&&!M(t)?t.className:"");return f.createElement(je,W({},a,{alignmentBaseline:"middle",className:l}),i)}}])})(be.PureComponent);ae=T;P(T,"displayName","Pie");P(T,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!At.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});P(T,"parseDeltaAngle",function(r,e){var n=ne(e-r),t=Math.min(Math.abs(e-r),360);return n*t});P(T,"getRealPieData",function(r){var e=r.data,n=r.children,t=j(r,!1),a=kt(n,Xe);return e&&e.length?e.map(function(o,i){return v(v(v({payload:o},t),o),a&&a[i]&&a[i].props)}):a&&a.length?a.map(function(o){return v(v({},t),o.props)}):[]});P(T,"parseCoordinateOfPie",function(r,e){var n=e.top,t=e.left,a=e.width,o=e.height,i=Pt(a,o),l=t+re(r.cx,a,a/2),d=n+re(r.cy,o,o/2),c=re(r.innerRadius,i,0),p=re(r.outerRadius,i,i*.8),h=r.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:l,cy:d,innerRadius:c,outerRadius:p,maxRadius:h}});P(T,"getComposedData",function(r){var e=r.item,n=r.offset,t=e.type.defaultProps!==void 0?v(v({},e.type.defaultProps),e.props):e.props,a=ae.getRealPieData(t);if(!a||!a.length)return null;var o=t.cornerRadius,i=t.startAngle,l=t.endAngle,d=t.paddingAngle,c=t.dataKey,p=t.nameKey,h=t.valueKey,y=t.tooltipType,A=Math.abs(t.minAngle),m=ae.parseCoordinateOfPie(t,n),u=ae.parseDeltaAngle(i,l),x=Math.abs(u),g=c;Z(c)&&Z(h)?(Ne(!1,`Use "dataKey" to specify the value of pie,
|
|
3
|
-
the props "valueKey" will be deprecated in 1.1.0`),g="value"):Z(c)&&(Ne(!1,`Use "dataKey" to specify the value of pie,
|
|
4
|
-
the props "valueKey" will be deprecated in 1.1.0`),g=h);var b=a.filter(function(k){return z(k,g,0)!==0}).length,w=(x>=360?b:b-1)*d,F=x-b*A-w,N=a.reduce(function(k,K){var _=z(K,g,0);return k+(q(_)?_:0)},0),L;if(N>0){var Y;L=a.map(function(k,K){var _=z(k,g,0),ee=z(k,p,K),te=(q(_)?_:0)/N,R;K?R=Y.endAngle+ne(u)*d*(_!==0?1:0):R=i;var ke=R+ne(u)*((_!==0?A:0)+te*F),Pe=(R+ke)/2,we=(m.innerRadius+m.outerRadius)/2,at=[{name:ee,value:_,payload:k,dataKey:g,type:y}],it=S(m.cx,m.cy,we,Pe);return Y=v(v(v({percent:te,cornerRadius:o,name:ee,tooltipPayload:at,midAngle:Pe,middleRadius:we,tooltipPosition:it},k),m),{},{value:z(k,g),startAngle:R,endAngle:ke,payload:k,paddingAngle:ne(u)*d}),Y})}return v(v({},m),{},{sectors:L,data:a})});var Tr=wt({chartName:"PieChart",GraphicalChild:T,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:fe},{axisType:"radiusAxis",AxisComp:ue}],formatAxisMap:Ot,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const V=["#34d399","#38bdf8","#818cf8","#f59e0b","#f97316","#f472b6"],nt={container:{transition:{staggerChildren:.08}},item:{hidden:{opacity:0,y:20,scale:.97},show:{opacity:1,y:0,scale:1,transition:{duration:.4,ease:[.22,1,.36,1]}}}};function he({label:r,value:e,sub:n,icon:t,gradient:a}){return s.jsxs(D.div,{variants:nt.item,className:"metric-card",children:[s.jsx("div",{className:`metric-orb ${a}`,children:t}),s.jsxs("div",{children:[s.jsx("div",{className:"hud-label",children:r}),s.jsx("div",{className:"mt-1 text-3xl font-semibold tracking-[-0.04em] text-white",children:e}),n&&s.jsx("div",{className:"mt-2 text-sm text-slate-400",children:n})]})]})}function Fr(){const{data:r,isLoading:e}=lt({queryKey:["stats"],queryFn:()=>ot(24)}),n=r?.byModel??[],t=r?.byProvider??[],a=n.map(i=>({name:i.model.length>22?`${i.model.slice(0,20)}...`:i.model,cost:Number(i.totalCost.toFixed(6)),tokens:i.totalTokens,calls:i.spanCount})),o=t.map(i=>({name:i.provider,value:Number(i.totalCost.toFixed(6))}));return e?s.jsxs("div",{className:"mx-auto max-w-[1500px] space-y-8",children:[s.jsx("div",{className:"skeleton-panel h-44 rounded-[28px]"}),s.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[...Array(3)].map((i,l)=>s.jsxs("div",{className:"metric-card",children:[s.jsx("div",{className:"skeleton-panel h-12 w-12 rounded-2xl"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"skeleton-panel h-3 w-20 rounded-full"}),s.jsx("div",{className:"skeleton-panel h-8 w-28 rounded-full"})]})]},l))})]}):s.jsxs(ct,{eyebrow:"Economic Layer",title:"Understand where every token is converting into spend.",description:"The economics view is now built like a cost cockpit. It surfaces burn concentration, provider mix, and the models that are consuming budget fastest.",aside:s.jsxs("div",{className:"insight-panel",children:[s.jsx(st,{}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[s.jsx("div",{className:"hud-label",children:"Highest model spend"}),s.jsx("div",{className:"mt-2 text-base font-medium text-white",children:n[0]?.model??"Awaiting traffic"}),s.jsx("div",{className:"mt-1 text-sm text-slate-400",children:n[0]?`${I(n[0].totalCost)} across ${n[0].spanCount} calls`:"No model cost data yet"})]}),s.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[s.jsx("div",{className:"hud-label",children:"Provider spread"}),s.jsxs("div",{className:"mt-2 text-base font-medium text-white",children:[t.length," active providers"]}),s.jsx("div",{className:"mt-1 text-sm text-slate-400",children:"Cost dominance becomes obvious here before it becomes expensive."})]})]})]}),children:[s.jsxs(D.div,{className:"grid grid-cols-1 gap-4 md:grid-cols-3",variants:nt.container,initial:"hidden",animate:"show",children:[s.jsx(he,{icon:s.jsx(Rt,{className:"h-5 w-5"}),label:"Total Cost",value:I(r?.totalCost??0),sub:"Accumulated over the last 24 hours",gradient:"bg-[linear-gradient(135deg,rgba(250,204,21,0.18),rgba(249,115,22,0.18))] text-amber-200"}),s.jsx(he,{icon:s.jsx(Et,{className:"h-5 w-5"}),label:"Token Volume",value:ut(r?.totalTokens??0),sub:`${r?.totalSpans??0} model calls observed`,gradient:"bg-[linear-gradient(135deg,rgba(56,189,248,0.18),rgba(168,85,247,0.18))] text-sky-200"}),s.jsx(he,{icon:s.jsx(Vt,{className:"h-5 w-5"}),label:"Models in Rotation",value:String(n.length),sub:`${t.length} providers contributing to spend`,gradient:"bg-[linear-gradient(135deg,rgba(52,211,153,0.18),rgba(14,165,233,0.18))] text-emerald-200"})]}),s.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_minmax(360px,0.9fr)]",children:[s.jsxs(D.div,{className:"dashboard-shell rounded-[26px] px-5 py-5",initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.15,duration:.35},children:[s.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"hud-label",children:"Model ranking"}),s.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Cost by model"})]}),s.jsxs("span",{className:"status-chip",children:[s.jsx(Mt,{className:"h-3.5 w-3.5 text-sky-300"}),s.jsx("span",{children:"Spend concentration"})]})]}),a.length>0?s.jsx("div",{className:"relative min-h-[320px]",children:s.jsx(_e,{width:"100%",height:Math.max(320,a.length*58),children:s.jsxs(Lt,{data:a,layout:"vertical",children:[s.jsx(Nt,{stroke:"rgba(148,163,184,0.08)",horizontal:!1}),s.jsx(_t,{type:"number",tick:{fontSize:11,fill:"#94a3b8"},axisLine:!1,tickLine:!1,tickFormatter:i=>I(i)}),s.jsx(St,{type:"category",dataKey:"name",tick:{fontSize:11,fill:"#cbd5e1"},axisLine:!1,tickLine:!1,width:160}),s.jsx(Se,{contentStyle:Te,formatter:i=>[I(i),"Cost"]}),s.jsx(Tt,{dataKey:"cost",fill:"#34d399",radius:[0,10,10,0]})]})})}):s.jsxs("div",{className:"empty-state h-[320px]",children:[s.jsx(Ee,{className:"h-8 w-8 text-slate-500"}),s.jsx("div",{className:"text-base font-medium text-white",children:"No cost data yet"}),s.jsx("div",{className:"text-center text-sm text-slate-400",children:"Model spend will stack up here as soon as traffic hits the collector."})]})]}),s.jsxs(D.div,{className:"dashboard-shell rounded-[26px] px-5 py-5",initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.2,duration:.35},children:[s.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"hud-label",children:"Provider mix"}),s.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Who is taking the budget"})]}),s.jsx(It,{className:"h-4 w-4 text-sky-300"})]}),o.length>0?s.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-center",children:[s.jsx(_e,{width:"100%",height:260,className:"lg:max-w-[260px]",children:s.jsxs(Tr,{children:[s.jsx(T,{data:o,cx:"50%",cy:"50%",innerRadius:62,outerRadius:96,paddingAngle:3,dataKey:"value",strokeWidth:0,children:o.map((i,l)=>s.jsx(Xe,{fill:V[l%V.length]},`cell-${l}`))}),s.jsx(Se,{contentStyle:Te,formatter:i=>[I(i),"Cost"]})]})}),s.jsx("div",{className:"flex-1 space-y-3",children:o.map((i,l)=>s.jsx("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-3.5",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:V[l%V.length],boxShadow:`0 0 10px ${V[l%V.length]}50`}}),s.jsx("span",{className:"flex-1 text-sm font-medium capitalize text-white",children:i.name}),s.jsx("span",{className:"font-mono text-xs text-slate-400",children:I(i.value)})]})},i.name))})]}):s.jsxs("div",{className:"empty-state h-[260px]",children:[s.jsx($t,{className:"h-8 w-8 text-slate-500"}),s.jsx("div",{className:"text-base font-medium text-white",children:"No providers yet"}),s.jsx("div",{className:"text-center text-sm text-slate-400",children:"Provider allocation appears here as soon as at least one model call is captured."})]})]})]}),n.length>0?s.jsxs(D.div,{className:"dashboard-shell overflow-hidden rounded-[26px] px-4 py-4 sm:px-5",initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.25,duration:.35},children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3 px-1",children:[s.jsxs("div",{children:[s.jsx("div",{className:"hud-label",children:"Detailed ledger"}),s.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Breakdown by model"})]}),s.jsxs("span",{className:"status-chip",children:[s.jsx(Ft,{className:"h-3.5 w-3.5 text-sky-300"}),s.jsxs("span",{children:[n.length," models"]})]})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full border-separate border-spacing-y-2 text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-[0.18em] text-slate-500",children:[s.jsx("th",{className:"px-4 py-2",children:"Model"}),s.jsx("th",{className:"px-4 py-2",children:"Provider"}),s.jsx("th",{className:"px-4 py-2 text-right",children:"Calls"}),s.jsx("th",{className:"px-4 py-2 text-right",children:"Tokens"}),s.jsx("th",{className:"px-4 py-2 text-right",children:"Cost"}),s.jsx("th",{className:"px-4 py-2 text-right",children:"Avg Duration"})]})}),s.jsx("tbody",{children:n.map((i,l)=>s.jsxs(D.tr,{className:"rounded-2xl border border-white/6 bg-white/4",initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.03*l,duration:.3},children:[s.jsx("td",{className:"rounded-l-2xl px-4 py-4 font-mono text-xs font-semibold text-slate-100",children:i.model}),s.jsx("td",{className:"px-4 py-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Re[i.provider]??"#a855f6",boxShadow:`0 0 10px ${Re[i.provider]??"#a855f6"}`}}),s.jsx("span",{className:"text-xs font-medium capitalize text-slate-200",children:i.provider})]})}),s.jsx("td",{className:"px-4 py-4 text-right",children:s.jsx("span",{className:"inline-flex items-center justify-center rounded-md border border-white/8 bg-slate-950/70 px-2 py-0.5 font-mono text-xs text-slate-400",children:i.spanCount})}),s.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs text-slate-300",children:i.totalTokens.toLocaleString()}),s.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs font-semibold text-white",children:I(i.totalCost)}),s.jsx("td",{className:"rounded-r-2xl px-4 py-4 text-right font-mono text-xs text-slate-500",children:i.avgDuration?dt(i.avgDuration):"-"})]},`${i.provider}-${i.model}`))})]})})]}):s.jsx(D.div,{className:"dashboard-shell rounded-[26px] p-16",initial:{opacity:0},animate:{opacity:1},children:s.jsxs("div",{className:"empty-state",children:[s.jsx(Ee,{className:"h-8 w-8 text-slate-500"}),s.jsx("div",{className:"text-base font-medium text-white",children:"No cost data yet"}),s.jsx("div",{className:"max-w-sm text-center text-sm text-slate-400",children:"Start making traced model calls and the economic layer will fill in automatically."})]})})]})}export{Fr as default};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{c as le,R as b,a as Ae,r as T,j as e,b as De,u as Le,d as Te,C as Ee,m as Me,X as Re,S as Ie,L as $e,T as ce,e as ze,f as Be,g as Fe,h as qe,i as He}from"./index-M3DwcRrc.js";import{u as ae,f as Ve,P as We,a as se,b as q,c as de,d as me}from"./format-CNuIwzac.js";import{C as Ke,S as Ge,A as Xe}from"./StatusDot-CjYDb6xj.js";import{P as he,A as ue,C as Ye,a as Ue,b as xe,B as pe}from"./constants-BzCnW506.js";import{f as H,L as X,m as Q,i as W,C as re,A as Qe,a as V,b as fe,c as Ze,d as ve,h as Je,e as et,u as tt,g as ie,G as at,j as be,k as ge,D as st,l as rt,X as ke,Y as Se,n as it,R as nt,o as lt,T as ot,t as ct}from"./chart-styles-BD7W97c9.js";import{G as dt}from"./gauge-CfqhcKwk.js";import{O as mt}from"./orbit-eg7lcPsM.js";const ht=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],ut=le("lightbulb",ht);const xt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],ye=le("shield-alert",xt);const pt=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Z=le("trending-up",pt);var ft=["layout","type","stroke","connectNulls","isRange","ref"],vt=["key"],Pe;function K(t){"@babel/helpers - typeof";return K=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},K(t)}function Oe(t,s){if(t==null)return{};var r=bt(t,s),a,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)a=o[n],!(s.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(r[a]=t[a])}return r}function bt(t,s){if(t==null)return{};var r={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(s.indexOf(a)>=0)continue;r[a]=t[a]}return r}function F(){return F=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},F.apply(this,arguments)}function je(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);s&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,a)}return r}function R(t){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?je(Object(r),!0).forEach(function(a){D(t,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):je(Object(r)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(r,a))})}return t}function gt(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Ne(t,s){for(var r=0;r<s.length;r++){var a=s[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,_e(a.key),a)}}function yt(t,s,r){return s&&Ne(t.prototype,s),r&&Ne(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function jt(t,s,r){return s=ee(s),Nt(t,Ce()?Reflect.construct(s,r||[],ee(t).constructor):s.apply(t,r))}function Nt(t,s){if(s&&(K(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return wt(t)}function wt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ce(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ce=function(){return!!t})()}function ee(t){return ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ee(t)}function At(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(s&&s.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),s&&ne(t,s)}function ne(t,s){return ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},ne(t,s)}function D(t,s,r){return s=_e(s),s in t?Object.defineProperty(t,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[s]=r,t}function _e(t){var s=kt(t,"string");return K(s)=="symbol"?s:s+""}function kt(t,s){if(K(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var a=r.call(t,s);if(K(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var I=(function(t){function s(){var r;gt(this,s);for(var a=arguments.length,n=new Array(a),o=0;o<a;o++)n[o]=arguments[o];return r=jt(this,s,[].concat(n)),D(r,"state",{isAnimationFinished:!0}),D(r,"id",tt("recharts-area-")),D(r,"handleAnimationEnd",function(){var l=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),ie(l)&&l()}),D(r,"handleAnimationStart",function(){var l=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),ie(l)&&l()}),r}return At(s,t),yt(s,[{key:"renderDots",value:function(a,n,o){var l=this.props.isAnimationActive,c=this.state.isAnimationFinished;if(l&&!c)return null;var m=this.props,d=m.dot,h=m.points,u=m.dataKey,p=H(this.props,!1),x=H(d,!0),N=h.map(function(y,P){var g=R(R(R({key:"dot-".concat(P),r:3},p),x),{},{index:P,cx:y.x,cy:y.y,dataKey:u,value:y.value,payload:y.payload,points:h});return s.renderDotItem(d,g)}),k={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(o,")"):null};return b.createElement(X,F({className:"recharts-area-dots"},k),N)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,o=n.baseLine,l=n.points,c=n.strokeWidth,m=l[0].x,d=l[l.length-1].x,h=a*Math.abs(m-d),u=Q(l.map(function(p){return p.y||0}));return W(o)&&typeof o=="number"?u=Math.max(o,u):o&&Array.isArray(o)&&o.length&&(u=Math.max(Q(o.map(function(p){return p.y||0})),u)),W(u)?b.createElement("rect",{x:m<d?m:m-h,y:0,width:h,height:Math.floor(u+(c?parseInt("".concat(c),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,o=n.baseLine,l=n.points,c=n.strokeWidth,m=l[0].y,d=l[l.length-1].y,h=a*Math.abs(m-d),u=Q(l.map(function(p){return p.x||0}));return W(o)&&typeof o=="number"?u=Math.max(o,u):o&&Array.isArray(o)&&o.length&&(u=Math.max(Q(o.map(function(p){return p.x||0})),u)),W(u)?b.createElement("rect",{x:0,y:m<d?m:m-h,width:u+(c?parseInt("".concat(c),10):1),height:Math.floor(h)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,o,l){var c=this.props,m=c.layout,d=c.type,h=c.stroke,u=c.connectNulls,p=c.isRange;c.ref;var x=Oe(c,ft);return b.createElement(X,{clipPath:o?"url(#clipPath-".concat(l,")"):null},b.createElement(re,F({},H(x,!0),{points:a,connectNulls:u,type:d,baseLine:n,layout:m,stroke:"none",className:"recharts-area-area"})),h!=="none"&&b.createElement(re,F({},H(this.props,!1),{className:"recharts-area-curve",layout:m,type:d,connectNulls:u,fill:"none",points:a})),h!=="none"&&p&&b.createElement(re,F({},H(this.props,!1),{className:"recharts-area-curve",layout:m,type:d,connectNulls:u,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var o=this,l=this.props,c=l.points,m=l.baseLine,d=l.isAnimationActive,h=l.animationBegin,u=l.animationDuration,p=l.animationEasing,x=l.animationId,N=this.state,k=N.prevPoints,y=N.prevBaseLine;return b.createElement(Qe,{begin:h,duration:u,isActive:d,easing:p,from:{t:0},to:{t:1},key:"area-".concat(x),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(P){var g=P.t;if(k){var S=k.length/c.length,v=c.map(function(w,E){var C=Math.floor(E*S);if(k[C]){var A=k[C],_=V(A.x,w.x),$=V(A.y,w.y);return R(R({},w),{},{x:_(g),y:$(g)})}return w}),f;if(W(m)&&typeof m=="number"){var j=V(y,m);f=j(g)}else if(fe(m)||Ze(m)){var O=V(y,0);f=O(g)}else f=m.map(function(w,E){var C=Math.floor(E*S);if(y[C]){var A=y[C],_=V(A.x,w.x),$=V(A.y,w.y);return R(R({},w),{},{x:_(g),y:$(g)})}return w});return o.renderAreaStatically(v,f,a,n)}return b.createElement(X,null,b.createElement("defs",null,b.createElement("clipPath",{id:"animationClipPath-".concat(n)},o.renderClipRect(g))),b.createElement(X,{clipPath:"url(#animationClipPath-".concat(n,")")},o.renderAreaStatically(c,m,a,n)))})}},{key:"renderArea",value:function(a,n){var o=this.props,l=o.points,c=o.baseLine,m=o.isAnimationActive,d=this.state,h=d.prevPoints,u=d.prevBaseLine,p=d.totalLength;return m&&l&&l.length&&(!h&&p>0||!ve(h,l)||!ve(u,c))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(l,c,a,n)}},{key:"render",value:function(){var a,n=this.props,o=n.hide,l=n.dot,c=n.points,m=n.className,d=n.top,h=n.left,u=n.xAxis,p=n.yAxis,x=n.width,N=n.height,k=n.isAnimationActive,y=n.id;if(o||!c||!c.length)return null;var P=this.state.isAnimationFinished,g=c.length===1,S=Ae("recharts-area",m),v=u&&u.allowDataOverflow,f=p&&p.allowDataOverflow,j=v||f,O=fe(y)?this.id:y,w=(a=H(l,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},E=w.r,C=E===void 0?3:E,A=w.strokeWidth,_=A===void 0?2:A,$=Je(l)?l:{},G=$.clipDot,Y=G===void 0?!0:G,z=C*2+_;return b.createElement(X,{className:S},v||f?b.createElement("defs",null,b.createElement("clipPath",{id:"clipPath-".concat(O)},b.createElement("rect",{x:v?h:h-x/2,y:f?d:d-N/2,width:v?x:x*2,height:f?N:N*2})),!Y&&b.createElement("clipPath",{id:"clipPath-dots-".concat(O)},b.createElement("rect",{x:h-z/2,y:d-z/2,width:x+z,height:N+z}))):null,g?null:this.renderArea(j,O),(l||g)&&this.renderDots(j,Y,O),(!k||P)&&et.renderCallByParent(this.props,c))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])})(T.PureComponent);Pe=I;D(I,"displayName","Area");D(I,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!at.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});D(I,"getBaseValue",function(t,s,r,a){var n=t.layout,o=t.baseValue,l=s.props.baseValue,c=l??o;if(W(c)&&typeof c=="number")return c;var m=n==="horizontal"?a:r,d=m.scale.domain();if(m.type==="number"){var h=Math.max(d[0],d[1]),u=Math.min(d[0],d[1]);return c==="dataMin"?u:c==="dataMax"||h<0?h:Math.max(Math.min(d[0],d[1]),0)}return c==="dataMin"?d[0]:c==="dataMax"?d[1]:d[0]});D(I,"getComposedData",function(t){var s=t.props,r=t.item,a=t.xAxis,n=t.yAxis,o=t.xAxisTicks,l=t.yAxisTicks,c=t.bandSize,m=t.dataKey,d=t.stackedData,h=t.dataStartIndex,u=t.displayedData,p=t.offset,x=s.layout,N=d&&d.length,k=Pe.getBaseValue(s,r,a,n),y=x==="horizontal",P=!1,g=u.map(function(v,f){var j;N?j=d[h+f]:(j=be(v,m),Array.isArray(j)?P=!0:j=[k,j]);var O=j[1]==null||N&&be(v,m)==null;return y?{x:ge({axis:a,ticks:o,bandSize:c,entry:v,index:f}),y:O?null:n.scale(j[1]),value:j,payload:v}:{x:O?null:a.scale(j[1]),y:ge({axis:n,ticks:l,bandSize:c,entry:v,index:f}),value:j,payload:v}}),S;return N||P?S=g.map(function(v){var f=Array.isArray(v.value)?v.value[0]:null;return y?{x:v.x,y:f!=null&&v.y!=null?n.scale(f):null}:{x:f!=null?a.scale(f):null,y:v.y}}):S=y?n.scale(k):a.scale(k),R({points:g,baseLine:S,layout:x,isRange:P},p)});D(I,"renderDotItem",function(t,s){var r;if(b.isValidElement(t))r=b.cloneElement(t,s);else if(ie(t))r=t(s);else{var a=Ae("recharts-area-dot",typeof t!="boolean"?t.className:""),n=s.key,o=Oe(s,vt);r=b.createElement(st,F({},o,{key:n,className:a}))}return r});var St=rt({chartName:"AreaChart",GraphicalChild:I,axisComponents:[{axisType:"xAxis",AxisComp:ke},{axisType:"yAxis",AxisComp:Se}],formatAxisMap:it});function Pt({children:t,className:s,spotlightColor:r="rgba(52, 211, 153, 0.15)"}){const a=T.useRef(null),[n,o]=T.useState({x:0,y:0}),[l,c]=T.useState(0);function m(d){if(!a.current)return;const h=a.current.getBoundingClientRect();o({x:d.clientX-h.left,y:d.clientY-h.top})}return e.jsxs("div",{ref:a,onMouseMove:m,onMouseEnter:()=>c(1),onMouseLeave:()=>c(0),className:De("relative overflow-hidden",s),children:[e.jsx("div",{className:"pointer-events-none absolute -inset-px opacity-0 transition-opacity duration-300",style:{opacity:l,background:`radial-gradient(600px circle at ${n.x}px ${n.y}px, ${r}, transparent 40%)`}}),t]})}const we=[12,25,50,100];function J({label:t,value:s,detail:r,accent:a,icon:n}){return e.jsxs(Pt,{className:"metric-card",children:[e.jsx("div",{className:`metric-orb ${a}`,children:n}),e.jsxs("div",{children:[e.jsx("div",{className:"hud-label",children:t}),e.jsx("div",{className:"mt-1 text-3xl font-semibold tracking-[-0.04em] text-white",children:s}),e.jsx("div",{className:"mt-1 text-sm text-slate-400",children:r})]})]})}function Mt(){const[t,s]=Le(),r=t.get("q")??"",a=T.useDeferredValue(r),n=t.get("provider")??"",o=t.get("status"),l=o==="ok"||o==="error"?o:"",c=Number(t.get("periodHours")??"24"),m=Number(t.get("pageSize")??"12"),d=we.includes(m)?m:12,h=Math.max(1,Number(t.get("page")??"1")||1),u=(h-1)*d,p=T.useMemo(()=>({limit:d,offset:u,q:a.trim()||void 0,provider:n||void 0,status:l||void 0,periodHours:he.some(i=>i.value===c)?c:24}),[a,d,u,c,n,l]),{data:x}=ae({queryKey:["stats",p.periodHours],queryFn:()=>Fe(p.periodHours??24)}),{data:N,isLoading:k}=ae({queryKey:["traces",p],queryFn:()=>qe(p)}),{data:y}=ae({queryKey:["insights"],queryFn:He,refetchInterval:6e4}),P=y?.insights??[],g=N?.traces??[],S=N?.total??0,v=Math.max(1,Math.ceil(S/d)),[f,j]=T.useState(null),[O,w]=T.useState("desc");function E(i){f===i?w(L=>L==="asc"?"desc":"asc"):(j(i),w("desc"))}const C=T.useMemo(()=>f?[...g].sort((i,L)=>{const U=i[f]??0,B=L[f]??0;return O==="asc"?U-B:B-U}):g,[g,f,O]),A=x?.byProvider[0],_=C[0],$=[...new Set(x?.byProvider.map(i=>i.provider)??[])],G=x?.costOverTime.map(i=>({time:Ve(i.timestamp),cost:i.cost}))??[],Y=x&&x.totalSpans>0?x.totalCost/x.totalSpans:0,z=r.length>0||n.length>0||l.length>0||p.periodHours!==24;function M(i,L=!0){s(U=>{const B=new URLSearchParams(U);for(const[oe,te]of Object.entries(i))te===void 0||te===""?B.delete(oe):B.set(oe,String(te));return L&&B.delete("page"),B},{replace:!0})}return e.jsxs(We,{eyebrow:"Flight Deck",title:"Read the behavior of every model call like a live system.",description:"The dashboard should act like an operator console. This version adds a real trace search surface, URL-synced filters, and paginated queue control.",aside:e.jsxs("div",{className:"insight-panel",children:[e.jsx(Be,{}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Dominant provider"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("div",{className:"text-lg font-medium capitalize text-white",children:A?.provider??"Awaiting traffic"}),e.jsx(mt,{className:"h-4 w-4 text-sky-300"})]}),e.jsx("div",{className:"mt-1 text-sm text-slate-400",children:A?`${A.spanCount} calls, ${q(A.totalCost)} spend`:"No provider activity yet"})]}),e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Latest trace"}),e.jsx("div",{className:"mt-2 text-base font-medium text-white",children:_?.name??"No recent traces"}),e.jsx("div",{className:"mt-1 text-sm text-slate-400",children:_?`${me(_.startTime)} / ${_.spanCount} spans`:"Start sending spans to populate the deck"})]})]})]}),children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(J,{label:"Trace Volume",value:se(x?.totalTraces??0),detail:`${x?.totalSpans??0} spans in window`,icon:e.jsx(Te,{className:"h-5 w-5"}),accent:"bg-[linear-gradient(135deg,rgba(52,211,153,0.18),rgba(14,165,233,0.18))] text-emerald-200"}),e.jsx(J,{label:"Token Throughput",value:se(x?.totalTokens??0),detail:"Token load across the active filter window",icon:e.jsx(Ee,{className:"h-5 w-5"}),accent:"bg-[linear-gradient(135deg,rgba(56,189,248,0.18),rgba(168,85,247,0.18))] text-sky-200"}),e.jsx(J,{label:"Spend Velocity",value:q(x?.totalCost??0),detail:`${q(Y)} average cost per call`,icon:e.jsx(Z,{className:"h-5 w-5"}),accent:"bg-[linear-gradient(135deg,rgba(251,191,36,0.18),rgba(249,115,22,0.18))] text-amber-200"}),e.jsx(J,{label:"Risk Surface",value:`${Math.round((x?.errorRate??0)*100)}%`,detail:`${x?.errorCount??0} failing calls`,icon:e.jsx(ye,{className:"h-5 w-5"}),accent:"bg-[linear-gradient(135deg,rgba(244,63,94,0.18),rgba(168,85,247,0.18))] text-rose-200"})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.5fr)_minmax(320px,0.95fr)]",children:[e.jsxs("section",{className:"dashboard-shell rounded-[26px] px-5 py-5 sm:px-6",children:[e.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"hud-label",children:"Economic pulse"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Cost gradient"})]}),e.jsxs("div",{className:"status-chip",children:[e.jsx(dt,{className:"h-3.5 w-3.5 text-sky-300"}),e.jsxs("span",{children:[p.periodHours,"h window"]})]})]}),G.length>0?e.jsx(nt,{width:"100%",height:320,children:e.jsxs(St,{data:G,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"dashboardCostFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#34d399",stopOpacity:.35}),e.jsx("stop",{offset:"100%",stopColor:"#38bdf8",stopOpacity:0})]})}),e.jsx(lt,{stroke:"rgba(148,163,184,0.08)",vertical:!1}),e.jsx(ke,{dataKey:"time",tick:{fontSize:11,fill:"#94a3b8"},axisLine:!1,tickLine:!1}),e.jsx(Se,{tick:{fontSize:11,fill:"#94a3b8"},axisLine:!1,tickLine:!1,width:54}),e.jsx(ot,{contentStyle:ct,formatter:i=>[q(i),"Cost"]}),e.jsx(I,{type:"monotone",dataKey:"cost",stroke:"#34d399",fill:"url(#dashboardCostFill)",strokeWidth:2.6,dot:!1})]})}):e.jsxs("div",{className:"empty-state h-[320px]",children:[e.jsx(Z,{className:"h-8 w-8 text-slate-500"}),e.jsx("div",{className:"text-base font-medium text-white",children:"No cost movement yet"})]})]}),e.jsxs("section",{className:"dashboard-shell rounded-[26px] px-5 py-5 sm:px-6",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("div",{className:"hud-label",children:"Provider pressure"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Allocation by provider"})]}),e.jsx("div",{className:"space-y-4",children:(x?.byProvider??[]).map(i=>{const L=(x?.totalCost??0)>0?i.totalCost/(x?.totalCost??1)*100:0;return e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium capitalize text-white",children:i.provider}),e.jsxs("div",{className:"text-xs text-slate-400",children:[i.spanCount," calls / ",se(i.totalTokens)," tokens"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:q(i.totalCost)}),e.jsx("div",{className:"text-xs text-slate-500",children:de(i.avgDuration)})]})]}),e.jsx("div",{className:"mt-3 h-2 overflow-hidden rounded-full bg-slate-900/80",children:e.jsx(Me.div,{className:"h-full w-full origin-left rounded-full bg-[linear-gradient(90deg,#34d399,#38bdf8)]",initial:{scaleX:0},animate:{scaleX:Math.max(L,4)/100},transition:{duration:.5,ease:"easeOut"}})})]},i.provider)})})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.45fr)_minmax(320px,0.85fr)]",children:[e.jsxs("section",{className:"dashboard-shell rounded-[26px] px-4 py-4 sm:px-5 sm:py-5",children:[e.jsxs("div",{className:"mb-4 rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(7,14,26,0.95),rgba(4,8,18,0.98))] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"hud-label",children:"Search console"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Trace dispatch queue"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"status-chip",children:[S," matches"]}),e.jsxs("button",{type:"button",onClick:()=>M({q:void 0,provider:void 0,status:void 0,periodHours:void 0}),disabled:!z,className:"status-chip transition-colors hover:border-white/16 hover:bg-white/8 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(Re,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Clear"})]})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 xl:grid-cols-[minmax(0,1.7fr)_repeat(3,minmax(0,0.7fr))]",children:[e.jsxs("label",{className:"relative block",children:[e.jsx(Ie,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-500"}),e.jsx("input",{value:r,onChange:i=>M({q:i.target.value||void 0}),placeholder:"Search traces, models, providers, errors",className:"w-full rounded-2xl border border-white/8 bg-white/4 py-3 pl-10 pr-4 text-sm text-white placeholder:text-slate-500 focus:border-emerald-400/30 focus:bg-white/6 focus:outline-none"})]}),e.jsxs("select",{value:n,onChange:i=>M({provider:i.target.value||void 0}),className:"w-full rounded-2xl border border-white/8 bg-white/4 px-4 py-3 text-sm text-white focus:border-sky-400/30 focus:bg-white/6 focus:outline-none",children:[e.jsx("option",{value:"",children:"All providers"}),$.map(i=>e.jsx("option",{value:i,children:i},i))]}),e.jsxs("select",{value:l,onChange:i=>M({status:i.target.value||void 0}),className:"w-full rounded-2xl border border-white/8 bg-white/4 px-4 py-3 text-sm text-white focus:border-emerald-400/30 focus:bg-white/6 focus:outline-none",children:[e.jsx("option",{value:"",children:"All states"}),e.jsx("option",{value:"ok",children:"Healthy only"}),e.jsx("option",{value:"error",children:"Errors only"})]}),e.jsx("select",{value:String(p.periodHours??24),onChange:i=>M({periodHours:Number(i.target.value)===24?void 0:Number(i.target.value)}),className:"w-full rounded-2xl border border-white/8 bg-white/4 px-4 py-3 text-sm text-white focus:border-amber-400/30 focus:bg-white/6 focus:outline-none",children:he.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]})]}),k?e.jsx("div",{className:"empty-state h-[280px] text-slate-500",children:"Loading trace queue..."}):C.length===0&&!z?e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-6 sm:p-8",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx(ue,{className:"h-10 w-10 text-amber-400/60"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-semibold text-white",children:"No traces recorded yet"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"Get started in 3 steps — takes under a minute."})]})]}),e.jsxs("div",{className:"mx-auto mt-6 flex max-w-3xl flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl border border-white/6 bg-white/3 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-amber-400/20 text-[10px] font-bold text-amber-400",children:"1"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-amber-400",children:"Install the SDK"})]}),e.jsx("pre",{className:"overflow-x-auto rounded-lg bg-black/40 p-3 text-sm leading-relaxed text-green-400 select-all",children:"npm install @llmtap/sdk"})]}),e.jsxs("div",{className:"rounded-xl border border-white/6 bg-white/3 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-amber-400/20 text-[10px] font-bold text-amber-400",children:"2"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-amber-400",children:"Wrap your client & use normally"})]}),e.jsx("pre",{className:"overflow-x-auto rounded-lg bg-black/40 p-3 text-sm leading-relaxed text-green-400 select-all whitespace-pre",children:`import { wrap } from "@llmtap/sdk";
|
|
2
|
-
import OpenAI from "openai";
|
|
3
|
-
|
|
4
|
-
const client = wrap(new OpenAI());
|
|
5
|
-
|
|
6
|
-
const res = await client.chat.completions.create({
|
|
7
|
-
model: "gpt-4o-mini",
|
|
8
|
-
messages: [{ role: "user", content: "Hello!" }],
|
|
9
|
-
});`})]}),e.jsxs("div",{className:"rounded-xl border border-white/6 bg-white/3 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-amber-400/20 text-[10px] font-bold text-amber-400",children:"3"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-amber-400",children:"Start the collector"})]}),e.jsx("pre",{className:"overflow-x-auto rounded-lg bg-black/40 p-3 text-sm leading-relaxed text-green-400 select-all",children:"npx llmtap"}),e.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Run your app and traces will appear here automatically."})]})]}),e.jsx("div",{className:"mx-auto mt-4 max-w-3xl rounded-lg border border-white/4 bg-white/2 px-4 py-2.5",children:e.jsxs("p",{className:"text-center text-xs text-slate-500",children:["Works with ",e.jsx("span",{className:"text-slate-400",children:"OpenAI"}),", ",e.jsx("span",{className:"text-slate-400",children:"Anthropic"}),", ",e.jsx("span",{className:"text-slate-400",children:"Google Gemini"}),", ",e.jsx("span",{className:"text-slate-400",children:"DeepSeek"}),", ",e.jsx("span",{className:"text-slate-400",children:"Groq"}),", ",e.jsx("span",{className:"text-slate-400",children:"Together"}),", ",e.jsx("span",{className:"text-slate-400",children:"Fireworks"}),", ",e.jsx("span",{className:"text-slate-400",children:"OpenRouter"}),", and any OpenAI-compatible provider."]})})]}):C.length===0?e.jsxs("div",{className:"empty-state h-[280px]",children:[e.jsx(ue,{className:"h-8 w-8 text-slate-500"}),e.jsx("div",{className:"text-base font-medium text-white",children:"No traces match these filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-separate border-spacing-y-2 text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-[0.18em] text-slate-500",children:[e.jsx("th",{className:"px-4 py-2",children:"State"}),e.jsx("th",{className:"px-4 py-2",children:"Trace"}),[["spanCount","Spans"],["totalTokens","Tokens"],["totalCost","Cost"],["startTime","When"]].map(([i,L])=>e.jsx("th",{className:"px-4 py-2 text-right",children:e.jsxs("button",{type:"button",onClick:()=>E(i),className:"inline-flex items-center gap-1 transition-colors hover:text-slate-300",children:[L,f===i?O==="asc"?e.jsx(Ye,{className:"h-3 w-3"}):e.jsx(Ke,{className:"h-3 w-3"}):e.jsx(Ue,{className:"h-3 w-3 opacity-30"})]})},i))]})}),e.jsx("tbody",{children:C.map(i=>e.jsxs("tr",{className:"rounded-2xl border border-white/6 bg-white/4",children:[e.jsx("td",{className:"rounded-l-2xl px-4 py-4",children:e.jsx(Ge,{status:i.status})}),e.jsx("td",{className:"px-4 py-4",children:e.jsxs($e,{to:`/trace/${i.traceId}`,className:"group inline-flex max-w-[380px] flex-col gap-1 text-sm font-medium text-white transition-colors hover:text-emerald-300",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("span",{className:"truncate",children:i.name}),e.jsx(xe,{className:"h-3.5 w-3.5 opacity-0 transition-all group-hover:translate-x-0.5 group-hover:opacity-100"})]}),e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-[0.16em] text-slate-500",children:[i.traceId.slice(0,12),i.totalDuration?` / ${de(i.totalDuration)}`:""]})]})}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs text-slate-300",children:i.spanCount}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs text-slate-300",children:i.totalTokens.toLocaleString()}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs text-slate-300",children:q(i.totalCost)}),e.jsx("td",{className:"rounded-r-2xl px-4 py-4 text-right text-xs text-slate-500",children:me(i.startTime)})]},i.traceId))})]})}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"text-xs text-slate-500",children:S>0?`Showing ${u+1}-${Math.min(u+C.length,S)} of ${S}`:"Awaiting traces"}),e.jsx("select",{value:String(d),onChange:i=>M({pageSize:Number(i.target.value)===12?void 0:Number(i.target.value)}),className:"rounded-xl border border-white/8 bg-white/4 px-2 py-1.5 text-xs text-slate-300 focus:border-emerald-400/30 focus:outline-none",children:we.map(i=>e.jsxs("option",{value:i,children:[i," / page"]},i))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(pe,{variant:"outline",size:"sm",onClick:()=>M({page:h>2?h-1:void 0},!1),disabled:h<=1,children:[e.jsx(Xe,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Previous"})]}),e.jsxs(pe,{variant:"outline",size:"sm",onClick:()=>M({page:h+1},!1),disabled:h>=v,children:[e.jsx("span",{children:"Next"}),e.jsx(xe,{className:"h-3.5 w-3.5"})]})]})]})]})]}),e.jsxs("section",{className:"dashboard-shell rounded-[26px] px-5 py-5",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("div",{className:"hud-label",children:"Intelligence layer"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Insights"})]}),e.jsx("div",{className:"space-y-4",children:P.length>0?P.map(i=>e.jsxs("div",{className:`rounded-2xl border p-4 ${i.severity==="critical"?"border-rose-400/20 bg-rose-500/8":i.severity==="warning"?"border-amber-400/20 bg-amber-500/8":"border-white/6 bg-white/4"}`,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[i.type==="cost_anomaly"&&e.jsx(ce,{className:"h-4 w-4 text-amber-300"}),i.type==="error_pattern"&&e.jsx(ye,{className:"h-4 w-4 text-rose-300"}),i.type==="model_recommendation"&&e.jsx(ut,{className:"h-4 w-4 text-sky-300"}),i.type==="token_waste"&&e.jsx(Z,{className:"h-4 w-4 text-purple-300"}),i.title]}),i.metric&&e.jsx("span",{className:"shrink-0 rounded-full border border-white/10 bg-white/6 px-2 py-0.5 text-[10px] font-mono text-slate-400",children:i.metric})]}),e.jsx("p",{className:"text-sm leading-6 text-slate-400",children:i.description})]},i.id)):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(ze,{className:"h-4 w-4 text-sky-300"}),"Health read"]}),e.jsx("p",{className:"text-sm leading-6 text-slate-400",children:(x?.errorRate??0)>.05?"Error rate is elevated. Start with the most recent failed trace and inspect provider or tool payloads.":"Error pressure is currently low. Use this window to compare provider cost drift and latency patterns."})]}),e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(Z,{className:"h-4 w-4 text-emerald-300"}),"Spend insight"]}),e.jsx("p",{className:"text-sm leading-6 text-slate-400",children:A?`${A.provider} currently leads cost share. If that is unexpected, inspect the filtered queue for bursty workflows.`:"Provider concentration will appear here once traces land."})]}),e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(ce,{className:"h-4 w-4 text-amber-300"}),"Queue focus"]}),e.jsx("p",{className:"text-sm leading-6 text-slate-400",children:_?`Latest traffic is "${_.name}". Open it to inspect hierarchy, timing, and payload shape.`:"No active traces yet. Generate a request through an instrumented client to validate the pipeline."})]})]})})]})]})]})}export{Mt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,m as a,C as v,f as g,g as w}from"./index-M3DwcRrc.js";import{u as k,P as C,a as d,b as i,c as l}from"./format-CNuIwzac.js";import{R as o,o as c,X as x,Y as m,T as h,t as p,N as j}from"./chart-styles-BD7W97c9.js";import{a as y}from"./provider-colors-DcHYMgVv.js";import{L}from"./layers-BQ0MpYqk.js";import{C as S}from"./clock-BEYeaSdD.js";import{B as f}from"./BarChart-C6HDCruv.js";import{G as M}from"./gauge-CfqhcKwk.js";function q(){const{data:u,isLoading:N}=k({queryKey:["stats",168],queryFn:()=>w(168)}),s=u?.byModel??[],r=s.map(t=>({name:t.model.length>20?`${t.model.slice(0,18)}...`:t.model,p50:t.avgDuration})),n=s.map(t=>({name:t.model.length>20?`${t.model.slice(0,18)}...`:t.model,tokens:t.totalTokens}));return N?e.jsxs("div",{className:"mx-auto max-w-[1500px] space-y-8",children:[e.jsx("div",{className:"skeleton-panel h-44 rounded-[28px]"}),e.jsx("div",{className:"skeleton-panel h-80 rounded-[24px]"})]}):e.jsx(C,{eyebrow:"Model Intelligence",title:"Every model. Every metric. One surface.",description:"Compare cost, token volume, latency, and call frequency across all models in your rotation. Identify the models consuming the most budget and the ones delivering the best performance.",aside:e.jsxs("div",{className:"insight-panel",children:[e.jsx(g,{}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Models active"}),e.jsx("div",{className:"mt-2 text-lg font-medium text-white",children:s.length}),e.jsxs("div",{className:"mt-1 text-sm text-slate-400",children:["Across ",new Set(s.map(t=>t.provider)).size," providers"]})]}),e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Highest cost model"}),e.jsx("div",{className:"mt-2 text-base font-medium text-white",children:s[0]?.model??"No data"}),e.jsx("div",{className:"mt-1 text-sm text-slate-400",children:s[0]?i(s[0].totalCost):"-"})]})]})]}),children:s.length>0?e.jsxs(e.Fragment,{children:[e.jsxs(a.div,{className:"dashboard-shell overflow-hidden rounded-[26px] px-4 py-4 sm:px-5",initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.35},children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3 px-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"hud-label",children:"Model roster"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Performance by model"})]}),e.jsxs("span",{className:"status-chip",children:[e.jsx(L,{className:"h-3.5 w-3.5 text-sky-300"}),e.jsxs("span",{children:[s.length," models"]})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-separate border-spacing-y-2 text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-[0.18em] text-slate-500",children:[e.jsx("th",{className:"px-4 py-2",children:"Model"}),e.jsx("th",{className:"px-4 py-2",children:"Provider"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Calls"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Tokens"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Cost"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Avg Latency"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Cost/Call"})]})}),e.jsx("tbody",{children:s.map((t,b)=>e.jsxs(a.tr,{className:"rounded-2xl border border-white/6 bg-white/4",initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.03*b,duration:.3},children:[e.jsx("td",{className:"rounded-l-2xl px-4 py-4",children:e.jsx("div",{className:"font-mono text-xs font-semibold text-slate-100",children:t.model})}),e.jsx("td",{className:"px-4 py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:y[t.provider]??"#a855f6",boxShadow:`0 0 10px ${y[t.provider]??"#a855f6"}`}}),e.jsx("span",{className:"text-xs font-medium capitalize text-slate-200",children:t.provider})]})}),e.jsx("td",{className:"px-4 py-4 text-right",children:e.jsx("span",{className:"inline-flex items-center justify-center rounded-md border border-white/8 bg-slate-950/70 px-2 py-0.5 font-mono text-xs text-slate-400",children:t.spanCount})}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs text-slate-300",children:d(t.totalTokens)}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs font-semibold text-white",children:i(t.totalCost)}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs text-slate-400",children:t.avgDuration?l(t.avgDuration):"-"}),e.jsx("td",{className:"rounded-r-2xl px-4 py-4 text-right font-mono text-xs text-slate-500",children:t.spanCount>0?i(t.totalCost/t.spanCount):"-"})]},`${t.provider}-${t.model}`))})]})})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-2",children:[e.jsxs(a.div,{className:"dashboard-shell rounded-[26px] px-5 py-5",initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.1,duration:.35},children:[e.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"hud-label",children:"Latency profile"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Average latency by model"})]}),e.jsx(S,{className:"h-4 w-4 text-sky-300"})]}),e.jsx(o,{width:"100%",height:Math.max(280,r.length*52),children:e.jsxs(f,{data:r,layout:"vertical",children:[e.jsx(c,{stroke:"rgba(148,163,184,0.08)",horizontal:!1}),e.jsx(x,{type:"number",tick:{fontSize:11,fill:"#94a3b8"},axisLine:!1,tickLine:!1,tickFormatter:t=>l(t)}),e.jsx(m,{type:"category",dataKey:"name",tick:{fontSize:11,fill:"#cbd5e1"},axisLine:!1,tickLine:!1,width:150}),e.jsx(h,{contentStyle:p,formatter:t=>[l(t),"Avg latency"]}),e.jsx(j,{dataKey:"p50",fill:"#38bdf8",radius:[0,10,10,0]})]})})]}),e.jsxs(a.div,{className:"dashboard-shell rounded-[26px] px-5 py-5",initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.15,duration:.35},children:[e.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"hud-label",children:"Token distribution"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Token volume by model"})]}),e.jsx(v,{className:"h-4 w-4 text-emerald-300"})]}),e.jsx(o,{width:"100%",height:Math.max(280,n.length*52),children:e.jsxs(f,{data:n,layout:"vertical",children:[e.jsx(c,{stroke:"rgba(148,163,184,0.08)",horizontal:!1}),e.jsx(x,{type:"number",tick:{fontSize:11,fill:"#94a3b8"},axisLine:!1,tickLine:!1,tickFormatter:t=>d(t)}),e.jsx(m,{type:"category",dataKey:"name",tick:{fontSize:11,fill:"#cbd5e1"},axisLine:!1,tickLine:!1,width:150}),e.jsx(h,{contentStyle:p,formatter:t=>[t.toLocaleString(),"Tokens"]}),e.jsx(j,{dataKey:"tokens",fill:"#34d399",radius:[0,10,10,0]})]})})]})]})]}):e.jsx("div",{className:"dashboard-shell rounded-[26px] p-16",children:e.jsxs("div",{className:"empty-state",children:[e.jsx(M,{className:"h-8 w-8 text-slate-500"}),e.jsx("div",{className:"text-base font-medium text-white",children:"No models tracked yet"}),e.jsx("div",{className:"max-w-sm text-center text-sm text-slate-400",children:"Start sending traced API calls and model metrics will populate automatically."})]})})})}export{q as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{c as h,j as e,m as l,M as n,T as p,f as j,t as u}from"./index-M3DwcRrc.js";import{u as N,P as y,a as g,b as o,d as x}from"./format-CNuIwzac.js";const f=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],b=h("users",f);function k(){const{data:r,isLoading:d}=N({queryKey:["sessions"],queryFn:()=>u(168)}),a=r?.sessions??[],i=r?.total??0,c=a.reduce((s,t)=>s+t.totalCost,0),m=a.reduce((s,t)=>s+t.traceCount,0);return d?e.jsxs("div",{className:"mx-auto max-w-[1500px] space-y-8",children:[e.jsx("div",{className:"skeleton-panel h-44 rounded-[28px]"}),e.jsx("div",{className:"skeleton-panel h-80 rounded-[24px]"})]}):e.jsx(y,{eyebrow:"Session Fabric",title:"Multi-turn conversations, grouped and measured.",description:"Sessions collect related traces into logical units. Track total cost and token volume across entire user conversations, multi-step agent runs, or workflow pipelines.",aside:e.jsxs("div",{className:"insight-panel",children:[e.jsx(j,{}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Active sessions"}),e.jsx("div",{className:"mt-2 text-lg font-medium text-white",children:i}),e.jsxs("div",{className:"mt-1 text-sm text-slate-400",children:[m," traces across all sessions"]})]}),e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Session spend"}),e.jsx("div",{className:"mt-2 text-base font-medium text-white",children:o(c)}),e.jsx("div",{className:"mt-1 text-sm text-slate-400",children:"Combined cost across visible sessions"})]})]})]}),children:a.length>0?e.jsxs(l.div,{className:"dashboard-shell overflow-hidden rounded-[26px] px-4 py-4 sm:px-5",initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.35},children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3 px-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"hud-label",children:"Session registry"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Tracked sessions"})]}),e.jsxs("span",{className:"status-chip",children:[e.jsx(b,{className:"h-3.5 w-3.5 text-sky-300"}),e.jsxs("span",{children:[i," sessions"]})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-separate border-spacing-y-2 text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-[0.18em] text-slate-500",children:[e.jsx("th",{className:"px-4 py-2",children:"Session ID"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Traces"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Spans"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Tokens"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Cost"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Errors"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"First Seen"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Last Active"})]})}),e.jsx("tbody",{children:a.map((s,t)=>e.jsxs(l.tr,{className:"rounded-2xl border border-white/6 bg-white/4",initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.03*t,duration:.3},children:[e.jsx("td",{className:"rounded-l-2xl px-4 py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n,{className:"h-4 w-4 text-sky-300"}),e.jsx("span",{className:"font-mono text-xs font-semibold text-slate-100",children:s.sessionId.length>28?`${s.sessionId.slice(0,26)}...`:s.sessionId})]})}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs text-slate-300",children:s.traceCount}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs text-slate-300",children:s.spanCount}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs text-slate-300",children:g(s.totalTokens)}),e.jsx("td",{className:"px-4 py-4 text-right font-mono text-xs font-semibold text-white",children:o(s.totalCost)}),e.jsx("td",{className:"px-4 py-4 text-right",children:s.errorCount>0?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-rose-400/20 bg-rose-400/10 px-2 py-0.5 text-[10px] font-bold text-rose-300",children:[e.jsx(p,{className:"h-3 w-3"}),s.errorCount]}):e.jsx("span",{className:"font-mono text-xs text-slate-500",children:"0"})}),e.jsx("td",{className:"px-4 py-4 text-right text-xs text-slate-500",children:x(s.firstSeen)}),e.jsx("td",{className:"rounded-r-2xl px-4 py-4 text-right text-xs text-slate-500",children:x(s.lastSeen)})]},s.sessionId))})]})})]}):e.jsx("div",{className:"dashboard-shell rounded-[26px] p-16",children:e.jsxs("div",{className:"empty-state",children:[e.jsx(n,{className:"h-8 w-8 text-slate-500"}),e.jsx("div",{className:"text-base font-medium text-white",children:"No sessions tracked yet"}),e.jsxs("div",{className:"max-w-md text-center text-sm text-slate-400",children:["Sessions appear when you pass a ",e.jsx("code",{className:"rounded bg-white/8 px-1.5 py-0.5 font-mono text-emerald-300",children:"sessionId"})," to the SDK. This groups related traces into logical conversations or workflows."]}),e.jsx("pre",{className:"mt-4 max-w-lg rounded-2xl border border-white/8 bg-white/4 p-4 text-left font-mono text-xs text-slate-300",children:`import { init } from "@llmtap/sdk";
|
|
2
|
-
|
|
3
|
-
init({ sessionId: "user-session-123" });`})]})})})}export{k as default};
|