@tokentop/ttop 0.5.0 → 0.6.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.
Files changed (51) hide show
  1. package/README.md +7 -6
  2. package/package.json +8 -6
  3. package/src/agents/aggregator.test.ts +306 -0
  4. package/src/agents/aggregator.ts +40 -5
  5. package/src/cli.ts +14 -0
  6. package/src/demo/simulator.ts +1 -1
  7. package/src/plugins/agents/index.ts +1 -0
  8. package/src/plugins/lifecycle.ts +1 -1
  9. package/src/plugins/plugin-host.test.ts +197 -0
  10. package/src/plugins/plugin-host.ts +45 -1
  11. package/src/plugins/providers/anthropic.test.ts +202 -0
  12. package/src/plugins/providers/anthropic.ts +19 -0
  13. package/src/plugins/providers/antigravity.ts +16 -0
  14. package/src/plugins/providers/chutes.ts +16 -0
  15. package/src/plugins/providers/codex.ts +16 -0
  16. package/src/plugins/providers/gemini.ts +16 -0
  17. package/src/plugins/providers/github-copilot.ts +16 -0
  18. package/src/plugins/providers/minimax.ts +16 -0
  19. package/src/plugins/providers/openai-api.ts +52 -0
  20. package/src/plugins/providers/perplexity.ts +10 -1
  21. package/src/plugins/providers/zai.ts +16 -0
  22. package/src/pricing/fallback.ts +4 -0
  23. package/src/tui/App.tsx +16 -8
  24. package/src/tui/components/HelpOverlay.tsx +1 -1
  25. package/src/tui/components/LimitGauge.tsx +12 -4
  26. package/src/tui/components/ProviderCard.tsx +38 -22
  27. package/src/tui/components/ProviderLimitsPanel.tsx +5 -0
  28. package/src/tui/components/SessionsTable.tsx +54 -36
  29. package/src/tui/components/Skeleton.tsx +9 -6
  30. package/src/tui/components/SortOverlay.tsx +167 -0
  31. package/src/tui/components/Spinner.tsx +16 -11
  32. package/src/tui/contexts/AgentSessionContext.tsx +69 -16
  33. package/src/tui/contexts/PluginContext.tsx +64 -10
  34. package/src/tui/contexts/ThemeContext.tsx +4 -1
  35. package/src/tui/createApp.tsx +2 -0
  36. package/src/tui/hooks/index.ts +1 -0
  37. package/src/tui/hooks/useAnimatedValue.ts +29 -26
  38. package/src/tui/hooks/useAnimationTick.ts +93 -0
  39. package/src/tui/hooks/useDashboardKeyboard.ts +11 -4
  40. package/src/tui/hooks/useEntranceAnimation.ts +16 -10
  41. package/src/tui/hooks/usePulse.ts +13 -7
  42. package/src/tui/hooks/useValueFlash.ts +25 -33
  43. package/src/tui/index.tsx +4 -0
  44. package/src/tui/types/projectSort.ts +35 -0
  45. package/src/tui/types/sort.ts +61 -0
  46. package/src/tui/views/ProjectsView.tsx +104 -38
  47. package/src/tui/views/RealTimeDashboard.tsx +91 -8
  48. package/src/utils/__tests__/error-category.test.ts +147 -0
  49. package/src/utils/currency.ts +4 -2
  50. package/src/utils/error-category.ts +91 -0
  51. package/src/version.ts +1 -1
@@ -0,0 +1,91 @@
1
+ export type ProviderErrorCategory =
2
+ | "auth"
3
+ | "rate_limit"
4
+ | "timeout"
5
+ | "network"
6
+ | "insufficient_credits"
7
+ | "unknown";
8
+
9
+ export function classifyProviderError(error: string): ProviderErrorCategory {
10
+ const lower = error.toLowerCase();
11
+
12
+ // Auth errors: expired tokens, invalid credentials, scope issues
13
+ if (
14
+ lower.includes("expired") ||
15
+ lower.includes("re-authenticate") ||
16
+ lower.includes("invalid") ||
17
+ lower.includes("unauthorized") ||
18
+ lower.includes("scope") ||
19
+ lower.includes("authentication failed") ||
20
+ lower.includes("authorization failed") ||
21
+ lower.includes("check api key") ||
22
+ lower.includes("api key required") ||
23
+ lower.includes("token required") ||
24
+ lower.includes("not configured") ||
25
+ lower.includes("sign in") ||
26
+ lower.includes("refresh failed") ||
27
+ lower.includes("not enabled") ||
28
+ lower.includes("configure") ||
29
+ /\b401\b/.test(lower) ||
30
+ /\b403\b/.test(lower)
31
+ ) {
32
+ return "auth";
33
+ }
34
+
35
+ // Rate limits
36
+ if (
37
+ lower.includes("rate limit") ||
38
+ lower.includes("too many requests") ||
39
+ /\b429\b/.test(lower)
40
+ ) {
41
+ return "rate_limit";
42
+ }
43
+
44
+ // Insufficient credits
45
+ if (lower.includes("insufficient") || lower.includes("credits") || /\b402\b/.test(lower)) {
46
+ return "insufficient_credits";
47
+ }
48
+
49
+ // Timeouts
50
+ if (
51
+ lower.includes("timeout") ||
52
+ lower.includes("timed out") ||
53
+ lower.includes("etimedout") ||
54
+ lower.includes("aborted")
55
+ ) {
56
+ return "timeout";
57
+ }
58
+
59
+ // Network errors
60
+ if (
61
+ lower.includes("econnrefused") ||
62
+ lower.includes("enotfound") ||
63
+ lower.includes("network") ||
64
+ lower.includes("fetch failed") ||
65
+ lower.includes("dns") ||
66
+ lower.includes("econnreset")
67
+ ) {
68
+ return "network";
69
+ }
70
+
71
+ return "unknown";
72
+ }
73
+
74
+ interface ErrorCategoryDisplay {
75
+ label: string;
76
+ icon: string;
77
+ isWarning: boolean;
78
+ }
79
+
80
+ const CATEGORY_DISPLAY: Record<ProviderErrorCategory, ErrorCategoryDisplay> = {
81
+ auth: { label: "AUTH", icon: "\u26B7", isWarning: true },
82
+ rate_limit: { label: "RATE", icon: "\u29D7", isWarning: true },
83
+ timeout: { label: "TIME", icon: "\u29D7", isWarning: true },
84
+ insufficient_credits: { label: "CRED", icon: "\u2717", isWarning: true },
85
+ network: { label: "NET", icon: "\u2717", isWarning: false },
86
+ unknown: { label: "ERR", icon: "\u2717", isWarning: false },
87
+ };
88
+
89
+ export function getErrorCategoryDisplay(category: ProviderErrorCategory): ErrorCategoryDisplay {
90
+ return CATEGORY_DISPLAY[category];
91
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.5.0"; // x-release-please-version
1
+ export const VERSION = "0.6.0"; // x-release-please-version