@tokentop/ttop 0.2.2
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/LICENSE +21 -0
- package/README.md +273 -0
- package/bin/ttop.js +49 -0
- package/package.json +68 -0
- package/src/agents/aggregator.ts +176 -0
- package/src/agents/costing.ts +74 -0
- package/src/agents/index.ts +12 -0
- package/src/agents/types.ts +71 -0
- package/src/cli.ts +167 -0
- package/src/config/schema.test.ts +166 -0
- package/src/config/schema.ts +165 -0
- package/src/demo/simulator.ts +745 -0
- package/src/plugins/agents/index.ts +2 -0
- package/src/plugins/auth-sources.ts +186 -0
- package/src/plugins/lifecycle.ts +177 -0
- package/src/plugins/loader.test.ts +195 -0
- package/src/plugins/loader.ts +282 -0
- package/src/plugins/notification-bus.ts +153 -0
- package/src/plugins/notifications/index.ts +2 -0
- package/src/plugins/notifications/terminal-bell.ts +66 -0
- package/src/plugins/notifications/visual-flash.ts +57 -0
- package/src/plugins/npm-installer.ts +164 -0
- package/src/plugins/plugin-context-factory.ts +67 -0
- package/src/plugins/plugin-host.ts +205 -0
- package/src/plugins/providers/anthropic.ts +325 -0
- package/src/plugins/providers/antigravity.ts +309 -0
- package/src/plugins/providers/codex.ts +250 -0
- package/src/plugins/providers/gemini.ts +391 -0
- package/src/plugins/providers/github-copilot.ts +194 -0
- package/src/plugins/providers/index.ts +12 -0
- package/src/plugins/providers/minimax.ts +223 -0
- package/src/plugins/providers/openai-api.ts +250 -0
- package/src/plugins/providers/opencode-zen.ts +125 -0
- package/src/plugins/providers/perplexity.ts +177 -0
- package/src/plugins/providers/zai.ts +225 -0
- package/src/plugins/registry.ts +251 -0
- package/src/plugins/sandbox-guard.test.ts +191 -0
- package/src/plugins/sandbox-guard.ts +155 -0
- package/src/plugins/sandbox.ts +138 -0
- package/src/plugins/themes/catppuccin-latte.ts +45 -0
- package/src/plugins/themes/catppuccin-mocha.ts +45 -0
- package/src/plugins/themes/claude-code.ts +45 -0
- package/src/plugins/themes/dracula.ts +45 -0
- package/src/plugins/themes/github-light.ts +45 -0
- package/src/plugins/themes/gruvbox-dark.ts +45 -0
- package/src/plugins/themes/gruvbox-light.ts +45 -0
- package/src/plugins/themes/index.ts +15 -0
- package/src/plugins/themes/kanagawa.ts +45 -0
- package/src/plugins/themes/nord.ts +45 -0
- package/src/plugins/themes/one-dark.ts +45 -0
- package/src/plugins/themes/opencode.ts +47 -0
- package/src/plugins/themes/rose-pine-dawn.ts +45 -0
- package/src/plugins/themes/rose-pine.ts +45 -0
- package/src/plugins/themes/solarized-light.ts +45 -0
- package/src/plugins/themes/tokyo-night.ts +49 -0
- package/src/plugins/types/agent.ts +108 -0
- package/src/plugins/types/base.ts +267 -0
- package/src/plugins/types/index.ts +19 -0
- package/src/plugins/types/notification.ts +51 -0
- package/src/plugins/types/provider.ts +233 -0
- package/src/plugins/types/theme.ts +70 -0
- package/src/plugins/update-checker.ts +177 -0
- package/src/pricing/estimator.test.ts +181 -0
- package/src/pricing/estimator.ts +80 -0
- package/src/pricing/fallback.test.ts +71 -0
- package/src/pricing/fallback.ts +62 -0
- package/src/pricing/index.ts +66 -0
- package/src/pricing/models-dev.ts +130 -0
- package/src/storage/database.ts +613 -0
- package/src/storage/db.ts +64 -0
- package/src/storage/index.ts +66 -0
- package/src/storage/migrations/index.ts +189 -0
- package/src/storage/paths.ts +24 -0
- package/src/storage/repos/agentSessions.ts +210 -0
- package/src/storage/repos/providerSnapshots.ts +116 -0
- package/src/storage/repos/usageEvents.ts +334 -0
- package/src/storage/types.ts +288 -0
- package/src/tui/App.tsx +381 -0
- package/src/tui/components/CommandPalette.tsx +166 -0
- package/src/tui/components/DebugConsole.tsx +161 -0
- package/src/tui/components/DebugPanel.tsx +660 -0
- package/src/tui/components/FooterHints.tsx +22 -0
- package/src/tui/components/GhostProviderCard.tsx +45 -0
- package/src/tui/components/Header.tsx +125 -0
- package/src/tui/components/HelpOverlay.tsx +45 -0
- package/src/tui/components/InlineGauge.tsx +34 -0
- package/src/tui/components/InlineSparkline.tsx +78 -0
- package/src/tui/components/KpiStrip.tsx +246 -0
- package/src/tui/components/LimitGauge.tsx +186 -0
- package/src/tui/components/ModalBackdrop.tsx +42 -0
- package/src/tui/components/ProviderAggregateStrip.tsx +200 -0
- package/src/tui/components/ProviderCard.tsx +309 -0
- package/src/tui/components/ProviderDetailPanel.tsx +237 -0
- package/src/tui/components/ProviderLimitsPanel.tsx +308 -0
- package/src/tui/components/ProvidersList.tsx +380 -0
- package/src/tui/components/SessionDetailsDrawer.tsx +317 -0
- package/src/tui/components/SessionsTable.tsx +401 -0
- package/src/tui/components/SettingsModal.tsx +587 -0
- package/src/tui/components/SidebarBreakdown.tsx +87 -0
- package/src/tui/components/Skeleton.tsx +102 -0
- package/src/tui/components/SmartSidebar.tsx +644 -0
- package/src/tui/components/Sparkline.tsx +180 -0
- package/src/tui/components/Spinner.tsx +36 -0
- package/src/tui/components/StatusBar.tsx +96 -0
- package/src/tui/components/ThemePicker.tsx +234 -0
- package/src/tui/components/Toast.tsx +61 -0
- package/src/tui/components/UsageGauge.tsx +80 -0
- package/src/tui/components/index.ts +5 -0
- package/src/tui/contexts/AgentSessionContext.tsx +307 -0
- package/src/tui/contexts/ConfigContext.tsx +141 -0
- package/src/tui/contexts/DashboardRuntimeContext.tsx +102 -0
- package/src/tui/contexts/DemoModeContext.tsx +60 -0
- package/src/tui/contexts/DrawerContext.tsx +42 -0
- package/src/tui/contexts/InputContext.tsx +30 -0
- package/src/tui/contexts/LogContext.tsx +150 -0
- package/src/tui/contexts/PluginContext.tsx +424 -0
- package/src/tui/contexts/RealTimeActivityContext.tsx +119 -0
- package/src/tui/contexts/StorageContext.tsx +233 -0
- package/src/tui/contexts/ThemeContext.tsx +95 -0
- package/src/tui/contexts/TimeWindowContext.tsx +158 -0
- package/src/tui/contexts/ToastContext.tsx +40 -0
- package/src/tui/contexts/index.ts +5 -0
- package/src/tui/createApp.tsx +47 -0
- package/src/tui/debug/captureFrame.ts +262 -0
- package/src/tui/debug/snapshot.tsx +644 -0
- package/src/tui/driver/assertions.ts +279 -0
- package/src/tui/driver/cli.ts +717 -0
- package/src/tui/driver/coverage.ts +204 -0
- package/src/tui/driver/demo-snapshot.ts +66 -0
- package/src/tui/driver/diff.ts +166 -0
- package/src/tui/driver/driver.ts +270 -0
- package/src/tui/driver/index.ts +53 -0
- package/src/tui/driver/recorder.ts +303 -0
- package/src/tui/driver/test-workflow.ts +115 -0
- package/src/tui/driver/test.ts +47 -0
- package/src/tui/hooks/index.ts +20 -0
- package/src/tui/hooks/useAnimatedValue.ts +113 -0
- package/src/tui/hooks/useDashboardKeyboard.ts +341 -0
- package/src/tui/hooks/useDashboardState.ts +116 -0
- package/src/tui/hooks/useEmaActivity.ts +223 -0
- package/src/tui/hooks/useEntranceAnimation.ts +62 -0
- package/src/tui/hooks/useExitAnimation.ts +137 -0
- package/src/tui/hooks/usePulse.ts +138 -0
- package/src/tui/hooks/useSafeRenderer.ts +24 -0
- package/src/tui/hooks/useValueFlash.ts +111 -0
- package/src/tui/index.tsx +50 -0
- package/src/tui/utils/providerColor.ts +32 -0
- package/src/tui/views/Dashboard.tsx +340 -0
- package/src/tui/views/HistoricalTrendsView.tsx +1431 -0
- package/src/tui/views/ProjectsView.tsx +1277 -0
- package/src/tui/views/RealTimeDashboard.tsx +393 -0
- package/src/tui/views/SettingsView.tsx +465 -0
- package/src/tui/views/index.ts +2 -0
- package/src/types/global.d.ts +5 -0
- package/src/types/opentui-test-utils.d.ts +18 -0
- package/src/utils/clipboard.ts +118 -0
- package/src/utils/currency.test.ts +106 -0
- package/src/utils/currency.ts +79 -0
- package/src/version.ts +1 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useColors } from '../contexts/ThemeContext.tsx';
|
|
3
|
+
import { interpolateColor } from '../hooks/useValueFlash.ts';
|
|
4
|
+
|
|
5
|
+
const SHIMMER_INTERVAL = 50;
|
|
6
|
+
const SHIMMER_WAVE_LENGTH = 8;
|
|
7
|
+
|
|
8
|
+
interface ShimmerSegment {
|
|
9
|
+
char: string;
|
|
10
|
+
color: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function useShimmer(length: number, baseColor: string, highlightColor: string): ShimmerSegment[] {
|
|
14
|
+
const [phase, setPhase] = useState(0);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const interval = setInterval(() => {
|
|
18
|
+
setPhase((p) => (p + 1) % (length + SHIMMER_WAVE_LENGTH));
|
|
19
|
+
}, SHIMMER_INTERVAL);
|
|
20
|
+
|
|
21
|
+
return () => clearInterval(interval);
|
|
22
|
+
}, [length]);
|
|
23
|
+
|
|
24
|
+
const segments: ShimmerSegment[] = [];
|
|
25
|
+
for (let i = 0; i < length; i++) {
|
|
26
|
+
const distFromWave = i - phase;
|
|
27
|
+
let intensity = 0;
|
|
28
|
+
|
|
29
|
+
if (distFromWave >= 0 && distFromWave < SHIMMER_WAVE_LENGTH) {
|
|
30
|
+
intensity = Math.sin((distFromWave / SHIMMER_WAVE_LENGTH) * Math.PI);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const color = intensity > 0
|
|
34
|
+
? interpolateColor(intensity, baseColor, highlightColor)
|
|
35
|
+
: baseColor;
|
|
36
|
+
|
|
37
|
+
segments.push({ char: '█', color });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return segments;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface SkeletonTextProps {
|
|
44
|
+
width?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function SkeletonText({ width = 10 }: SkeletonTextProps) {
|
|
48
|
+
const colors = useColors();
|
|
49
|
+
const segments = useShimmer(width, colors.borderMuted, colors.border);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<text>
|
|
53
|
+
{segments.map((seg, i) => (
|
|
54
|
+
<span key={i} fg={seg.color}>{seg.char}</span>
|
|
55
|
+
))}
|
|
56
|
+
</text>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface SkeletonGaugeProps {
|
|
61
|
+
barWidth?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function SkeletonGauge({ barWidth = 30 }: SkeletonGaugeProps) {
|
|
65
|
+
const colors = useColors();
|
|
66
|
+
const labelSegments = useShimmer(12, colors.borderMuted, colors.textSubtle);
|
|
67
|
+
const barSegments = useShimmer(barWidth, colors.borderMuted, colors.border);
|
|
68
|
+
const resetSegments = useShimmer(20, colors.borderMuted, colors.textSubtle);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<box flexDirection="column" width={40}>
|
|
72
|
+
<box flexDirection="row" justifyContent="space-between">
|
|
73
|
+
<text>
|
|
74
|
+
{labelSegments.map((seg, i) => (
|
|
75
|
+
<span key={i} fg={seg.color}>{seg.char}</span>
|
|
76
|
+
))}
|
|
77
|
+
</text>
|
|
78
|
+
<text fg={colors.textSubtle}>···</text>
|
|
79
|
+
</box>
|
|
80
|
+
<text>
|
|
81
|
+
{barSegments.map((seg, i) => (
|
|
82
|
+
<span key={i} fg={seg.color}>{seg.char}</span>
|
|
83
|
+
))}
|
|
84
|
+
</text>
|
|
85
|
+
<text>
|
|
86
|
+
{resetSegments.map((seg, i) => (
|
|
87
|
+
<span key={i} fg={seg.color}>{seg.char}</span>
|
|
88
|
+
))}
|
|
89
|
+
</text>
|
|
90
|
+
</box>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function SkeletonProviderContent() {
|
|
95
|
+
return (
|
|
96
|
+
<box flexDirection="column" gap={1}>
|
|
97
|
+
<SkeletonText width={8} />
|
|
98
|
+
<SkeletonGauge />
|
|
99
|
+
<SkeletonGauge />
|
|
100
|
+
</box>
|
|
101
|
+
);
|
|
102
|
+
}
|