@tokentop/ttop 0.2.2 → 0.3.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 +32 -32
- 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 +29 -23
- package/src/plugins/notifications/visual-flash.ts +21 -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 +66 -57
- package/src/plugins/registry.ts +47 -43
- 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/repos/agentSessions.ts +33 -23
- package/src/storage/repos/providerSnapshots.ts +5 -5
- package/src/storage/repos/usageEvents.ts +40 -28
- 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 +295 -177
- 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 +313 -166
- package/src/tui/components/SettingsModal.tsx +231 -214
- 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 +193 -144
- 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 +232 -183
- package/src/tui/contexts/RealTimeActivityContext.tsx +70 -36
- package/src/tui/contexts/StorageContext.tsx +151 -117
- 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 +3 -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 +127 -102
- package/src/tui/views/HistoricalTrendsView.tsx +579 -250
- package/src/tui/views/ProjectsView.tsx +466 -237
- package/src/tui/views/RealTimeDashboard.tsx +150 -111
- package/src/tui/views/SettingsView.tsx +222 -191
- 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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { useTerminalDimensions } from "@opentui/react";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import type { ProviderState } from "../contexts/PluginContext.tsx";
|
|
4
|
+
import { useColors } from "../contexts/ThemeContext.tsx";
|
|
5
5
|
|
|
6
6
|
function pad(str: string, len: number): string {
|
|
7
|
-
return str.length >= len ? str.slice(0, len) : str +
|
|
7
|
+
return str.length >= len ? str.slice(0, len) : str + " ".repeat(len - str.length);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
function formatCost(val: number): string {
|
|
@@ -62,10 +62,13 @@ export function computeAggregates(providers: ProviderState[]): ProviderAggregate
|
|
|
62
62
|
|
|
63
63
|
if (p.usage?.cost) {
|
|
64
64
|
const cost = p.usage.cost;
|
|
65
|
-
const todayTotal =
|
|
65
|
+
const todayTotal =
|
|
66
|
+
cost.estimatedDaily?.total ?? cost.actual?.total ?? cost.estimated?.total ?? 0;
|
|
67
|
+
const mtdTotal =
|
|
68
|
+
cost.estimatedMonthly?.total ?? cost.actual?.total ?? cost.estimated?.total ?? 0;
|
|
66
69
|
costToday += todayTotal;
|
|
67
|
-
costMtd +=
|
|
68
|
-
if (cost.source ===
|
|
70
|
+
costMtd += mtdTotal;
|
|
71
|
+
if (cost.source === "estimated" || cost.estimatedDaily || cost.estimatedMonthly) {
|
|
69
72
|
costTodayEstimated = true;
|
|
70
73
|
costMtdEstimated = true;
|
|
71
74
|
}
|
|
@@ -122,48 +125,72 @@ export function ProviderAggregateStrip({ providers }: ProviderAggregateStripProp
|
|
|
122
125
|
|
|
123
126
|
const agg = useMemo(() => computeAggregates(providers), [providers]);
|
|
124
127
|
|
|
125
|
-
const costTodayStr = `${agg.costTodayEstimated ?
|
|
126
|
-
const costMtdStr = `${agg.costMtdEstimated ?
|
|
127
|
-
const tokensStr = `${agg.tokens24hEstimated ?
|
|
128
|
-
|
|
129
|
-
const trendStr =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
const costTodayStr = `${agg.costTodayEstimated ? "~" : ""}${formatCost(agg.costToday)}`;
|
|
129
|
+
const costMtdStr = `${agg.costMtdEstimated ? "~" : ""}${formatCost(agg.costMtd)}`;
|
|
130
|
+
const tokensStr = `${agg.tokens24hEstimated ? "~" : ""}${formatTokens(agg.totalTokens24h)}`;
|
|
131
|
+
|
|
132
|
+
const trendStr =
|
|
133
|
+
agg.trendVsYesterday !== null
|
|
134
|
+
? agg.trendVsYesterday >= 0
|
|
135
|
+
? `+${agg.trendVsYesterday.toFixed(0)}%`
|
|
136
|
+
: `${agg.trendVsYesterday.toFixed(0)}%`
|
|
137
|
+
: "—";
|
|
138
|
+
const trendColor =
|
|
139
|
+
agg.trendVsYesterday !== null
|
|
140
|
+
? agg.trendVsYesterday > 10
|
|
141
|
+
? colors.warning
|
|
142
|
+
: agg.trendVsYesterday < -10
|
|
143
|
+
? colors.success
|
|
144
|
+
: colors.textMuted
|
|
145
|
+
: colors.textSubtle;
|
|
135
146
|
|
|
136
147
|
return (
|
|
137
148
|
<box flexDirection="column" flexShrink={0}>
|
|
138
149
|
<box flexDirection="row" height={1} gap={2} paddingX={1}>
|
|
139
150
|
<text height={1}>
|
|
140
151
|
<span fg={colors.textMuted}>HEALTH </span>
|
|
141
|
-
{agg.okCount > 0 &&
|
|
142
|
-
|
|
143
|
-
|
|
152
|
+
{agg.okCount > 0 && (
|
|
153
|
+
<span fg={colors.success}>{pad(`${agg.okCount} ok`, isCompact ? 5 : 5)}</span>
|
|
154
|
+
)}
|
|
155
|
+
{agg.warnCount > 0 && (
|
|
156
|
+
<span fg={colors.warning}> {pad(`${agg.warnCount} warn`, isCompact ? 7 : 7)}</span>
|
|
157
|
+
)}
|
|
158
|
+
{agg.errCount > 0 && (
|
|
159
|
+
<span fg={colors.error}> {pad(`${agg.errCount} err`, isCompact ? 6 : 6)}</span>
|
|
160
|
+
)}
|
|
144
161
|
{agg.okCount === 0 && agg.warnCount === 0 && agg.errCount === 0 && (
|
|
145
162
|
<span fg={colors.textSubtle}>no providers</span>
|
|
146
163
|
)}
|
|
147
164
|
</text>
|
|
148
165
|
|
|
149
|
-
<text fg={colors.textSubtle} height={1}
|
|
166
|
+
<text fg={colors.textSubtle} height={1}>
|
|
167
|
+
│
|
|
168
|
+
</text>
|
|
150
169
|
|
|
151
170
|
<text height={1}>
|
|
152
171
|
<span fg={colors.textMuted}>TODAY </span>
|
|
153
|
-
<span fg={agg.costTodayEstimated ? colors.textMuted : colors.success}>
|
|
172
|
+
<span fg={agg.costTodayEstimated ? colors.textMuted : colors.success}>
|
|
173
|
+
{costTodayStr}
|
|
174
|
+
</span>
|
|
154
175
|
</text>
|
|
155
176
|
|
|
156
177
|
{!isCompact && (
|
|
157
178
|
<>
|
|
158
|
-
<text fg={colors.textSubtle} height={1}
|
|
179
|
+
<text fg={colors.textSubtle} height={1}>
|
|
180
|
+
│
|
|
181
|
+
</text>
|
|
159
182
|
<text height={1}>
|
|
160
183
|
<span fg={colors.textMuted}>MTD </span>
|
|
161
|
-
<span fg={agg.costMtdEstimated ? colors.textMuted : colors.success}>
|
|
184
|
+
<span fg={agg.costMtdEstimated ? colors.textMuted : colors.success}>
|
|
185
|
+
{costMtdStr}
|
|
186
|
+
</span>
|
|
162
187
|
</text>
|
|
163
188
|
</>
|
|
164
189
|
)}
|
|
165
190
|
|
|
166
|
-
<text fg={colors.textSubtle} height={1}
|
|
191
|
+
<text fg={colors.textSubtle} height={1}>
|
|
192
|
+
│
|
|
193
|
+
</text>
|
|
167
194
|
|
|
168
195
|
<text height={1}>
|
|
169
196
|
<span fg={colors.textMuted}>TOKENS </span>
|
|
@@ -173,18 +200,22 @@ export function ProviderAggregateStrip({ providers }: ProviderAggregateStripProp
|
|
|
173
200
|
|
|
174
201
|
<box flexDirection="row" height={1} gap={2} paddingX={1}>
|
|
175
202
|
{agg.hottestProvider && (
|
|
176
|
-
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
203
|
+
<>
|
|
204
|
+
<text height={1}>
|
|
205
|
+
<span fg={colors.textMuted}>HOTTEST </span>
|
|
206
|
+
<span fg={agg.hottestPercent >= 80 ? colors.warning : colors.text}>
|
|
207
|
+
{pad(agg.hottestProvider, isCompact ? 10 : 14)}
|
|
208
|
+
</span>
|
|
209
|
+
<span fg={agg.hottestPercent >= 80 ? colors.warning : colors.textMuted}>
|
|
210
|
+
{` ${Math.round(agg.hottestPercent)}%`}
|
|
211
|
+
</span>
|
|
212
|
+
</text>
|
|
186
213
|
|
|
187
|
-
|
|
214
|
+
<text fg={colors.textSubtle} height={1}>
|
|
215
|
+
│
|
|
216
|
+
</text>
|
|
217
|
+
</>
|
|
218
|
+
)}
|
|
188
219
|
|
|
189
220
|
<text height={1}>
|
|
190
221
|
<span fg={colors.textMuted}>vs YESTERDAY </span>
|
|
@@ -193,7 +224,7 @@ export function ProviderAggregateStrip({ providers }: ProviderAggregateStripProp
|
|
|
193
224
|
</box>
|
|
194
225
|
|
|
195
226
|
<box height={1} overflow="hidden">
|
|
196
|
-
<text fg={colors.border}>{
|
|
227
|
+
<text fg={colors.border}>{"─".repeat(300)}</text>
|
|
197
228
|
</box>
|
|
198
229
|
</box>
|
|
199
230
|
);
|