@tokentop/ttop 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -5
- package/package.json +8 -5
- package/src/agents/aggregator.ts +39 -19
- package/src/agents/costing.ts +11 -9
- package/src/agents/index.ts +7 -9
- package/src/agents/types.ts +2 -2
- package/src/cli.ts +28 -23
- package/src/config/schema.test.ts +42 -40
- package/src/config/schema.ts +26 -26
- package/src/demo/simulator.ts +161 -122
- package/src/plugins/agents/index.ts +2 -2
- package/src/plugins/auth-sources.ts +42 -38
- package/src/plugins/lifecycle.ts +42 -38
- package/src/plugins/loader.test.ts +49 -49
- package/src/plugins/loader.ts +67 -63
- package/src/plugins/notification-bus.ts +21 -16
- package/src/plugins/notifications/index.ts +2 -2
- package/src/plugins/notifications/terminal-bell.ts +36 -23
- package/src/plugins/notifications/visual-flash.ts +31 -19
- package/src/plugins/npm-installer.ts +23 -25
- package/src/plugins/plugin-context-factory.ts +10 -10
- package/src/plugins/plugin-host.ts +12 -5
- package/src/plugins/providers/anthropic.ts +64 -57
- package/src/plugins/providers/antigravity.ts +81 -69
- package/src/plugins/providers/codex.ts +42 -42
- package/src/plugins/providers/gemini.ts +106 -87
- package/src/plugins/providers/github-copilot.ts +49 -45
- package/src/plugins/providers/index.ts +10 -12
- package/src/plugins/providers/minimax.ts +50 -44
- package/src/plugins/providers/openai-api.ts +82 -62
- package/src/plugins/providers/opencode-zen.ts +46 -39
- package/src/plugins/providers/perplexity.ts +55 -46
- package/src/plugins/providers/zai.ts +68 -57
- package/src/plugins/registry.ts +80 -71
- package/src/plugins/sandbox-guard.test.ts +45 -48
- package/src/plugins/sandbox-guard.ts +20 -25
- package/src/plugins/sandbox.ts +26 -48
- package/src/plugins/themes/catppuccin-latte.ts +29 -29
- package/src/plugins/themes/catppuccin-mocha.ts +29 -29
- package/src/plugins/themes/claude-code.ts +29 -29
- package/src/plugins/themes/dracula.ts +29 -29
- package/src/plugins/themes/github-light.ts +29 -29
- package/src/plugins/themes/gruvbox-dark.ts +29 -29
- package/src/plugins/themes/gruvbox-light.ts +29 -29
- package/src/plugins/themes/index.ts +15 -15
- package/src/plugins/themes/kanagawa.ts +29 -29
- package/src/plugins/themes/nord.ts +29 -29
- package/src/plugins/themes/one-dark.ts +29 -29
- package/src/plugins/themes/opencode.ts +31 -31
- package/src/plugins/themes/rose-pine-dawn.ts +29 -29
- package/src/plugins/themes/rose-pine.ts +29 -29
- package/src/plugins/themes/solarized-light.ts +29 -29
- package/src/plugins/themes/tokyo-night.ts +29 -29
- package/src/plugins/types/agent.ts +5 -5
- package/src/plugins/types/base.ts +35 -24
- package/src/plugins/types/index.ts +9 -9
- package/src/plugins/types/notification.ts +12 -12
- package/src/plugins/types/provider.ts +12 -8
- package/src/plugins/types/theme.ts +31 -23
- package/src/plugins/update-checker.ts +6 -6
- package/src/pricing/estimator.test.ts +39 -44
- package/src/pricing/estimator.ts +7 -13
- package/src/pricing/fallback.test.ts +30 -34
- package/src/pricing/fallback.ts +54 -27
- package/src/pricing/index.ts +18 -12
- package/src/pricing/models-dev.ts +6 -6
- package/src/storage/database.ts +56 -46
- package/src/storage/db.ts +12 -12
- package/src/storage/index.ts +44 -45
- package/src/storage/migrations/index.ts +2 -2
- package/src/storage/paths.ts +13 -13
- package/src/storage/persistence-service.ts +206 -0
- package/src/storage/repos/agentSessions.ts +33 -23
- package/src/storage/repos/providerSnapshots.ts +5 -5
- package/src/storage/repos/usageEvents.ts +40 -28
- package/src/storage/retention.ts +146 -0
- package/src/storage/types.ts +5 -5
- package/src/tui/App.tsx +180 -137
- package/src/tui/components/CommandPalette.tsx +46 -34
- package/src/tui/components/DebugConsole.tsx +39 -33
- package/src/tui/components/DebugPanel.tsx +314 -183
- package/src/tui/components/FooterHints.tsx +2 -2
- package/src/tui/components/GhostProviderCard.tsx +37 -35
- package/src/tui/components/Header.tsx +68 -35
- package/src/tui/components/HelpOverlay.tsx +99 -29
- package/src/tui/components/InlineGauge.tsx +10 -7
- package/src/tui/components/InlineSparkline.tsx +17 -11
- package/src/tui/components/KpiStrip.tsx +128 -98
- package/src/tui/components/LimitGauge.tsx +96 -59
- package/src/tui/components/ModalBackdrop.tsx +4 -4
- package/src/tui/components/ProviderAggregateStrip.tsx +69 -38
- package/src/tui/components/ProviderCard.tsx +232 -226
- package/src/tui/components/ProviderDetailPanel.tsx +133 -58
- package/src/tui/components/ProviderLimitsPanel.tsx +126 -89
- package/src/tui/components/ProvidersList.tsx +215 -126
- package/src/tui/components/SessionDetailsDrawer.tsx +191 -94
- package/src/tui/components/SessionsTable.tsx +320 -169
- package/src/tui/components/SettingsModal.tsx +593 -269
- package/src/tui/components/SidebarBreakdown.tsx +30 -16
- package/src/tui/components/Skeleton.tsx +24 -17
- package/src/tui/components/SmartSidebar.tsx +360 -258
- package/src/tui/components/Sparkline.tsx +64 -52
- package/src/tui/components/Spinner.tsx +3 -3
- package/src/tui/components/StatusBar.tsx +27 -27
- package/src/tui/components/ThemePicker.tsx +67 -66
- package/src/tui/components/Toast.tsx +9 -6
- package/src/tui/components/UsageGauge.tsx +10 -13
- package/src/tui/components/index.ts +5 -5
- package/src/tui/contexts/AgentSessionContext.tsx +164 -151
- package/src/tui/contexts/ConfigContext.tsx +15 -13
- package/src/tui/contexts/DashboardRuntimeContext.tsx +26 -26
- package/src/tui/contexts/DemoModeContext.tsx +22 -15
- package/src/tui/contexts/DrawerContext.tsx +11 -9
- package/src/tui/contexts/InputContext.tsx +2 -2
- package/src/tui/contexts/LogContext.tsx +62 -47
- package/src/tui/contexts/PluginContext.tsx +238 -183
- package/src/tui/contexts/RealTimeActivityContext.tsx +70 -36
- package/src/tui/contexts/StorageContext.tsx +95 -149
- package/src/tui/contexts/ThemeContext.tsx +21 -16
- package/src/tui/contexts/TimeWindowContext.tsx +72 -61
- package/src/tui/contexts/ToastContext.tsx +10 -7
- package/src/tui/contexts/index.ts +9 -5
- package/src/tui/createApp.tsx +8 -12
- package/src/tui/debug/captureFrame.ts +25 -28
- package/src/tui/debug/snapshot.tsx +179 -162
- package/src/tui/driver/assertions.ts +30 -22
- package/src/tui/driver/cli.ts +231 -221
- package/src/tui/driver/coverage.ts +27 -44
- package/src/tui/driver/demo-snapshot.ts +33 -33
- package/src/tui/driver/diff.ts +26 -32
- package/src/tui/driver/driver.ts +43 -48
- package/src/tui/driver/index.ts +36 -40
- package/src/tui/driver/recorder.ts +37 -48
- package/src/tui/driver/test-workflow.ts +51 -51
- package/src/tui/driver/test.ts +25 -25
- package/src/tui/hooks/index.ts +24 -20
- package/src/tui/hooks/useAnimatedValue.ts +13 -18
- package/src/tui/hooks/useDashboardKeyboard.ts +118 -98
- package/src/tui/hooks/useDashboardState.ts +26 -24
- package/src/tui/hooks/useEmaActivity.ts +82 -74
- package/src/tui/hooks/useEntranceAnimation.ts +11 -11
- package/src/tui/hooks/useExitAnimation.ts +7 -3
- package/src/tui/hooks/usePulse.ts +4 -4
- package/src/tui/hooks/useSafeRenderer.ts +5 -5
- package/src/tui/hooks/useSessionEnrichedProviders.ts +150 -0
- package/src/tui/hooks/useValueFlash.ts +10 -14
- package/src/tui/index.tsx +29 -6
- package/src/tui/shutdown.ts +19 -0
- package/src/tui/utils/providerColor.ts +1 -1
- package/src/tui/views/Dashboard.tsx +164 -102
- package/src/tui/views/HistoricalTrendsView.tsx +579 -250
- package/src/tui/views/ProjectsView.tsx +495 -243
- package/src/tui/views/RealTimeDashboard.tsx +176 -116
- package/src/tui/views/SettingsView.tsx +225 -189
- package/src/tui/views/index.ts +2 -2
- package/src/types/opentui-test-utils.d.ts +7 -7
- package/src/utils/clipboard.ts +29 -29
- package/src/utils/currency.test.ts +53 -53
- package/src/utils/currency.ts +35 -32
- package/src/version.ts +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useMemo } from
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import type { AgentSessionAggregate, AgentSessionStream } from "../../agents/types.ts";
|
|
3
|
+
import { useColors } from "../contexts/ThemeContext.tsx";
|
|
4
4
|
|
|
5
5
|
interface SidebarBreakdownProps {
|
|
6
6
|
sessions: AgentSessionAggregate[];
|
|
7
|
-
focusedPanel:
|
|
7
|
+
focusedPanel: "sessions" | "sidebar" | "limits";
|
|
8
8
|
getProviderColor: (id: string) => string;
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -22,21 +22,23 @@ export function SidebarBreakdown({
|
|
|
22
22
|
const { modelStats, modelProviders } = useMemo(() => {
|
|
23
23
|
const stats: Record<string, number> = {};
|
|
24
24
|
const providers: Record<string, string> = {};
|
|
25
|
-
sessions.forEach(s => {
|
|
25
|
+
sessions.forEach((s) => {
|
|
26
26
|
s.streams.forEach((st: AgentSessionStream) => {
|
|
27
27
|
stats[st.modelId] = (stats[st.modelId] || 0) + (st.costUsd ?? 0);
|
|
28
28
|
if (!providers[st.modelId]) providers[st.modelId] = st.providerId;
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
return {
|
|
32
|
-
modelStats: Object.entries(stats)
|
|
32
|
+
modelStats: Object.entries(stats)
|
|
33
|
+
.sort(([, a], [, b]) => b - a)
|
|
34
|
+
.slice(0, 5),
|
|
33
35
|
modelProviders: providers,
|
|
34
36
|
};
|
|
35
37
|
}, [sessions]);
|
|
36
38
|
|
|
37
39
|
const providerStats = useMemo(() => {
|
|
38
40
|
const stats: Record<string, number> = {};
|
|
39
|
-
sessions.forEach(s => {
|
|
41
|
+
sessions.forEach((s) => {
|
|
40
42
|
s.streams.forEach((st: AgentSessionStream) => {
|
|
41
43
|
stats[st.providerId] = (stats[st.providerId] || 0) + (st.costUsd ?? 0);
|
|
42
44
|
});
|
|
@@ -52,21 +54,27 @@ export function SidebarBreakdown({
|
|
|
52
54
|
width={35}
|
|
53
55
|
gap={1}
|
|
54
56
|
border
|
|
55
|
-
borderStyle={focusedPanel ===
|
|
56
|
-
borderColor={focusedPanel ===
|
|
57
|
+
borderStyle={focusedPanel === "sidebar" ? "double" : "single"}
|
|
58
|
+
borderColor={focusedPanel === "sidebar" ? colors.primary : colors.border}
|
|
57
59
|
overflow="hidden"
|
|
58
60
|
>
|
|
59
61
|
<box flexDirection="column" padding={1} flexGrow={1} overflow="hidden">
|
|
60
|
-
<text height={1} fg={colors.textMuted} marginBottom={1}>
|
|
62
|
+
<text height={1} fg={colors.textMuted} marginBottom={1}>
|
|
63
|
+
MODEL BREAKDOWN
|
|
64
|
+
</text>
|
|
61
65
|
{modelStats.map(([modelId, cost]) => (
|
|
62
66
|
<box key={modelId} flexDirection="column" marginBottom={1}>
|
|
63
67
|
<box flexDirection="row" justifyContent="space-between" height={1}>
|
|
64
|
-
<text height={1} fg={colors.text}>
|
|
65
|
-
|
|
68
|
+
<text height={1} fg={colors.text}>
|
|
69
|
+
{(modelId.length > 15 ? modelId.slice(0, 14) + "…" : modelId).padEnd(18)}
|
|
70
|
+
</text>
|
|
71
|
+
<text height={1} fg={colors.textMuted}>
|
|
72
|
+
{formatCurrency(cost).padStart(7)}
|
|
73
|
+
</text>
|
|
66
74
|
</box>
|
|
67
75
|
<box flexDirection="row" height={1}>
|
|
68
76
|
<text height={1} fg={getProviderColor(modelProviders[modelId] ?? modelId)}>
|
|
69
|
-
{
|
|
77
|
+
{"█".repeat(Math.ceil((cost / maxModelCost) * 20)).padEnd(20)}
|
|
70
78
|
</text>
|
|
71
79
|
</box>
|
|
72
80
|
</box>
|
|
@@ -74,11 +82,17 @@ export function SidebarBreakdown({
|
|
|
74
82
|
</box>
|
|
75
83
|
|
|
76
84
|
<box flexDirection="column" padding={1} flexGrow={1} overflow="hidden">
|
|
77
|
-
<text height={1} fg={colors.textMuted} marginBottom={1}>
|
|
85
|
+
<text height={1} fg={colors.textMuted} marginBottom={1}>
|
|
86
|
+
BY PROVIDER
|
|
87
|
+
</text>
|
|
78
88
|
{providerStats.map(([provider, cost]) => (
|
|
79
89
|
<box key={provider} flexDirection="row" justifyContent="space-between" height={1}>
|
|
80
|
-
<text height={1} fg={getProviderColor(provider)}>
|
|
81
|
-
|
|
90
|
+
<text height={1} fg={getProviderColor(provider)}>
|
|
91
|
+
{provider.padEnd(18)}
|
|
92
|
+
</text>
|
|
93
|
+
<text height={1} fg={colors.text}>
|
|
94
|
+
{formatCurrency(cost).padStart(7)}
|
|
95
|
+
</text>
|
|
82
96
|
</box>
|
|
83
97
|
))}
|
|
84
98
|
</box>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useColors } from
|
|
3
|
-
import { interpolateColor } from
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useColors } from "../contexts/ThemeContext.tsx";
|
|
3
|
+
import { interpolateColor } from "../hooks/useValueFlash.ts";
|
|
4
4
|
|
|
5
5
|
const SHIMMER_INTERVAL = 50;
|
|
6
6
|
const SHIMMER_WAVE_LENGTH = 8;
|
|
@@ -25,18 +25,17 @@ function useShimmer(length: number, baseColor: string, highlightColor: string):
|
|
|
25
25
|
for (let i = 0; i < length; i++) {
|
|
26
26
|
const distFromWave = i - phase;
|
|
27
27
|
let intensity = 0;
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
if (distFromWave >= 0 && distFromWave < SHIMMER_WAVE_LENGTH) {
|
|
30
30
|
intensity = Math.sin((distFromWave / SHIMMER_WAVE_LENGTH) * Math.PI);
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
const color =
|
|
34
|
-
? interpolateColor(intensity, baseColor, highlightColor)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
segments.push({ char: '█', color });
|
|
32
|
+
|
|
33
|
+
const color =
|
|
34
|
+
intensity > 0 ? interpolateColor(intensity, baseColor, highlightColor) : baseColor;
|
|
35
|
+
|
|
36
|
+
segments.push({ char: "█", color });
|
|
38
37
|
}
|
|
39
|
-
|
|
38
|
+
|
|
40
39
|
return segments;
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -47,11 +46,13 @@ interface SkeletonTextProps {
|
|
|
47
46
|
export function SkeletonText({ width = 10 }: SkeletonTextProps) {
|
|
48
47
|
const colors = useColors();
|
|
49
48
|
const segments = useShimmer(width, colors.borderMuted, colors.border);
|
|
50
|
-
|
|
49
|
+
|
|
51
50
|
return (
|
|
52
51
|
<text>
|
|
53
52
|
{segments.map((seg, i) => (
|
|
54
|
-
<span key={i} fg={seg.color}>
|
|
53
|
+
<span key={i} fg={seg.color}>
|
|
54
|
+
{seg.char}
|
|
55
|
+
</span>
|
|
55
56
|
))}
|
|
56
57
|
</text>
|
|
57
58
|
);
|
|
@@ -66,25 +67,31 @@ export function SkeletonGauge({ barWidth = 30 }: SkeletonGaugeProps) {
|
|
|
66
67
|
const labelSegments = useShimmer(12, colors.borderMuted, colors.textSubtle);
|
|
67
68
|
const barSegments = useShimmer(barWidth, colors.borderMuted, colors.border);
|
|
68
69
|
const resetSegments = useShimmer(20, colors.borderMuted, colors.textSubtle);
|
|
69
|
-
|
|
70
|
+
|
|
70
71
|
return (
|
|
71
72
|
<box flexDirection="column" width={40}>
|
|
72
73
|
<box flexDirection="row" justifyContent="space-between">
|
|
73
74
|
<text>
|
|
74
75
|
{labelSegments.map((seg, i) => (
|
|
75
|
-
<span key={i} fg={seg.color}>
|
|
76
|
+
<span key={i} fg={seg.color}>
|
|
77
|
+
{seg.char}
|
|
78
|
+
</span>
|
|
76
79
|
))}
|
|
77
80
|
</text>
|
|
78
81
|
<text fg={colors.textSubtle}>···</text>
|
|
79
82
|
</box>
|
|
80
83
|
<text>
|
|
81
84
|
{barSegments.map((seg, i) => (
|
|
82
|
-
<span key={i} fg={seg.color}>
|
|
85
|
+
<span key={i} fg={seg.color}>
|
|
86
|
+
{seg.char}
|
|
87
|
+
</span>
|
|
83
88
|
))}
|
|
84
89
|
</text>
|
|
85
90
|
<text>
|
|
86
91
|
{resetSegments.map((seg, i) => (
|
|
87
|
-
<span key={i} fg={seg.color}>
|
|
92
|
+
<span key={i} fg={seg.color}>
|
|
93
|
+
{seg.char}
|
|
94
|
+
</span>
|
|
88
95
|
))}
|
|
89
96
|
</text>
|
|
90
97
|
</box>
|