Files
buzz/desktop/package.json
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7andWill Pfleger 4d18b8630a feat(desktop): add Agent Usage UI backed by the NIP-AM local archive
Adds a rolling token/cost usage view for agents, sourced from the local
NIP-AM metrics archive. Covers the Agents overview and a focused
per-agent subview in the profile panel, with the per-agent breakdown
grouped by (harness, model) so the same model under two harnesses
renders as two distinct rows.

Backend:
- get_agent_usage_series Tauri command (archive/agent_usage.rs): reads
  the local SQLite archive over a sliding 7/30-day window, aggregates
  by (agent_pubkey, session_id, harness, model), and returns a
  serialized AgentUsageSeries response.
- archive/metric_store.rs: MetricIndexRow + insert_metric_index_row
  with turn/cumulative token + cost + cache-read fields; query layer
  produces AgentMetricRow slices.
- store_migrations.rs: M1 (harness column + index rebuild) and M2
  (cache-read columns: turn_cache_read_tokens,
  cumulative_cache_read_tokens). M2 runs before M1 so the rebuild
  always operates against the full schema. All migrations are
  idempotent via marker guard.
- archive/mod.rs: pipeline integration — AgentMetricRow ingestion,
  persistedAgentMetrics notifier, archiveSyncManager wiring.
- tauriArchive.ts: wire types + Tauri command bridge.
- archiveSyncManager.ts: persistedAgentMetrics notifier.

Agent-side first-turn accounting (buzz-acp):
- UsageTracker::seed_zero_baseline() seeds a zero baseline for
  sessions this process just spawned, so the first turn of a fresh
  session reports reliable deltas. Re-attached sessions are not seeded;
  their true prior cumulative is unknown. Seeding is idempotent via
  entry().or_insert(). acp.rs call sites are immediately after
  create_session_and_apply_model() on both channel and heartbeat paths.

UI:
- desktop/src/features/agent-usage/: AgentUsageDailyBars (recharts),
  AgentUsageRangeTabs (7/30-day preset + custom), AgentUsageFocusedView
  (per-agent breakdown by harness/model), AgentUsageSection (wires
  overview + focused view). hooks.ts: data fetch and memoised series.
  lib/agentUsage.ts: bucket math, formatter, caveat detection,
  DisplayTotal, sortModelsByKnownTotal.
- Profile panel: canViewUsage/onOpenUsage threaded; BarChart3 ingress
  row in the Info tab. AgentsView/AgentsScreen reordered.
- ProfilePanelContext: usage navigation state.
- e2eBridge.ts + tests/helpers/bridge.ts: get_agent_usage_series mock
  handler + fixture types.
- agent-usage.spec.ts: 19-test Playwright spec (loading, empty, bars,
  range switch, error/retry, focused view, caveats, cache-invalidation).
- agent-usage-screenshots.spec.ts: 3-test screenshot spec.
- playwright.config.ts: agent-usage specs added to suite.
- package.json: recharts dependency.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-07-31 20:19:31 -04:00

104 lines
3.6 KiB
JSON

{
"name": "buzz",
"private": true,
"version": "0.5.2",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:e2e": "tsc && vite build --mode e2e",
"typecheck": "tsc --noEmit",
"check:file-sizes": "node ./scripts/check-file-sizes.mjs",
"check:px-text": "node ./scripts/check-px-text.mjs",
"check:pubkey-truncation": "node ./scripts/check-pubkey-truncation.mjs",
"lint": "biome lint .",
"check": "biome check . && pnpm check:file-sizes && pnpm check:px-text && pnpm check:pubkey-truncation",
"format": "biome format --write .",
"test": "node --import ./test-loader.mjs --experimental-strip-types --test \"src/**/*.test.mjs\"",
"preview": "vite preview",
"tauri": "tauri",
"test:e2e": "pnpm build:e2e && playwright test",
"test:e2e:smoke": "pnpm build:e2e && playwright test --project=smoke",
"test:e2e:integration": "pnpm build:e2e && playwright test --project=integration",
"test:e2e:report": "playwright show-report",
"tauri:build": "tauri build"
},
"dependencies": {
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@emoji-mart/data": "^1.2.1",
"@emoji-mart/react": "^1.1.1",
"@fontsource-variable/inter": "^5.2.8",
"@mediapipe/tasks-vision": "^0.10.35",
"@radix-ui/react-alert-dialog": "^1.1.15",
"@radix-ui/react-avatar": "^1.1.11",
"@radix-ui/react-checkbox": "^1.3.3",
"@radix-ui/react-context-menu": "^2.2.16",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-dropdown-menu": "^2.1.16",
"@radix-ui/react-focus-scope": "^1.1.8",
"@radix-ui/react-popover": "^1.1.15",
"@radix-ui/react-separator": "^1.1.8",
"@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-switch": "^1.2.6",
"@radix-ui/react-tabs": "^1.1.13",
"@radix-ui/react-toggle": "^1.1.10",
"@radix-ui/react-tooltip": "^1.2.8",
"@tanstack/react-query": "^5.90.21",
"@tanstack/react-router": "^1.168.10",
"@tanstack/react-virtual": "^3.14.2",
"@tauri-apps/api": "~2.11",
"@tauri-apps/plugin-notification": "^2.3.3",
"@tauri-apps/plugin-opener": "~2.5",
"@tauri-apps/plugin-process": "^2.3.1",
"@tauri-apps/plugin-updater": "^2.10.0",
"@tiptap/core": "^3.22.3",
"@tiptap/extension-link": "^3.22.3",
"@tiptap/extension-placeholder": "^3.22.3",
"@tiptap/pm": "^3.22.3",
"@tiptap/react": "^3.22.3",
"@tiptap/starter-kit": "^3.22.3",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"embla-carousel-react": "^8.6.0",
"emoji-mart": "^5.6.0",
"jdenticon": "^3.3.0",
"lucide-react": "^1.0.0",
"motion": "^12.38.0",
"qrcode": "^1.5.4",
"qrcode.react": "^4.2.0",
"react": "^19.1.0",
"react-diff-view": "^3.3.2",
"react-dom": "^19.1.0",
"react-markdown": "^10.1.0",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1",
"shiki": "^4.0.2",
"sonner": "^2.0.7",
"tailwind-merge": "^3.5.0",
"tiptap-markdown": "^0.9.0",
"upng-js": "^2.1.0",
"virtua": "0.49.3",
"yaml": "^2.8.3",
"zod": "^4.4.3"
},
"devDependencies": {
"@noble/hashes": "^2.0.1",
"@playwright/test": "^1.58.2",
"@tailwindcss/postcss": "^4.3.0",
"@tanstack/router-plugin": "^1.167.12",
"@tanstack/virtual-file-routes": "^1.161.7",
"@tauri-apps/cli": "~2.11",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"@vitejs/plugin-react": "^6.0.0",
"nostr-tools": "^2.23.3",
"postcss": "^8.5.8",
"tailwindcss": "^4.3.0",
"tw-animate-css": "^1.4.0",
"typescript": "~6.0.0",
"vite": "^8.0.0"
}
}