@moneysiren/app 0.1.0-alpha.10

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 (140) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -0
  3. package/dist/apps/cli/src/cli.d.ts +59 -0
  4. package/dist/apps/cli/src/cli.js +199 -0
  5. package/dist/apps/cli/src/commands/dashboard.d.ts +3 -0
  6. package/dist/apps/cli/src/commands/dashboard.js +239 -0
  7. package/dist/apps/cli/src/commands/doctor.d.ts +3 -0
  8. package/dist/apps/cli/src/commands/doctor.js +25 -0
  9. package/dist/apps/cli/src/commands/init.d.ts +3 -0
  10. package/dist/apps/cli/src/commands/init.js +18 -0
  11. package/dist/apps/cli/src/commands/install.d.ts +3 -0
  12. package/dist/apps/cli/src/commands/install.js +244 -0
  13. package/dist/apps/cli/src/commands/modes.d.ts +3 -0
  14. package/dist/apps/cli/src/commands/modes.js +73 -0
  15. package/dist/apps/cli/src/commands/notify.d.ts +3 -0
  16. package/dist/apps/cli/src/commands/notify.js +430 -0
  17. package/dist/apps/cli/src/commands/report.d.ts +3 -0
  18. package/dist/apps/cli/src/commands/report.js +206 -0
  19. package/dist/apps/cli/src/commands/runtime.d.ts +10 -0
  20. package/dist/apps/cli/src/commands/runtime.js +499 -0
  21. package/dist/apps/cli/src/commands/shared.d.ts +9 -0
  22. package/dist/apps/cli/src/commands/shared.js +29 -0
  23. package/dist/apps/cli/src/commands/summary.d.ts +3 -0
  24. package/dist/apps/cli/src/commands/summary.js +15 -0
  25. package/dist/apps/cli/src/commands/sync.d.ts +3 -0
  26. package/dist/apps/cli/src/commands/sync.js +393 -0
  27. package/dist/apps/cli/src/commands/theme.d.ts +3 -0
  28. package/dist/apps/cli/src/commands/theme.js +181 -0
  29. package/dist/apps/cli/src/desktop-runtime.d.ts +54 -0
  30. package/dist/apps/cli/src/desktop-runtime.js +720 -0
  31. package/dist/apps/cli/src/home.d.ts +7 -0
  32. package/dist/apps/cli/src/home.js +124 -0
  33. package/dist/apps/cli/src/index.d.ts +3 -0
  34. package/dist/apps/cli/src/index.js +14 -0
  35. package/dist/apps/cli/src/install-profile.d.ts +35 -0
  36. package/dist/apps/cli/src/install-profile.js +124 -0
  37. package/dist/apps/cli/src/install-selector.d.ts +10 -0
  38. package/dist/apps/cli/src/install-selector.js +66 -0
  39. package/dist/apps/cli/src/interactive.d.ts +3 -0
  40. package/dist/apps/cli/src/interactive.js +32 -0
  41. package/dist/apps/cli/src/postinstall.d.ts +3 -0
  42. package/dist/apps/cli/src/postinstall.js +42 -0
  43. package/dist/apps/cli/src/release-installer.d.ts +57 -0
  44. package/dist/apps/cli/src/release-installer.js +432 -0
  45. package/dist/apps/cli/src/runtime-adapter.d.ts +24 -0
  46. package/dist/apps/cli/src/runtime-adapter.js +185 -0
  47. package/dist/apps/cli/src/slash.d.ts +15 -0
  48. package/dist/apps/cli/src/slash.js +229 -0
  49. package/dist/apps/cli/src/summary-model.d.ts +51 -0
  50. package/dist/apps/cli/src/summary-model.js +136 -0
  51. package/dist/apps/cli/src/theme.d.ts +18 -0
  52. package/dist/apps/cli/src/theme.js +118 -0
  53. package/dist/apps/cli/src/version.d.ts +2 -0
  54. package/dist/apps/cli/src/version.js +2 -0
  55. package/dist/packages/config/src/index.d.ts +3 -0
  56. package/dist/packages/config/src/index.js +3 -0
  57. package/dist/packages/config/src/load.d.ts +3 -0
  58. package/dist/packages/config/src/load.js +80 -0
  59. package/dist/packages/config/src/schema.d.ts +49 -0
  60. package/dist/packages/config/src/schema.js +28 -0
  61. package/dist/packages/connectors/aws/src/cost-explorer.d.ts +34 -0
  62. package/dist/packages/connectors/aws/src/cost-explorer.js +43 -0
  63. package/dist/packages/connectors/aws/src/index.d.ts +35 -0
  64. package/dist/packages/connectors/aws/src/index.js +67 -0
  65. package/dist/packages/connectors/aws/src/normalize.d.ts +69 -0
  66. package/dist/packages/connectors/aws/src/normalize.js +141 -0
  67. package/dist/packages/connectors/aws/src/sdk-client.d.ts +6 -0
  68. package/dist/packages/connectors/aws/src/sdk-client.js +21 -0
  69. package/dist/packages/connectors/cloudflare/src/client.d.ts +23 -0
  70. package/dist/packages/connectors/cloudflare/src/client.js +107 -0
  71. package/dist/packages/connectors/cloudflare/src/index.d.ts +33 -0
  72. package/dist/packages/connectors/cloudflare/src/index.js +81 -0
  73. package/dist/packages/connectors/cloudflare/src/normalize.d.ts +113 -0
  74. package/dist/packages/connectors/cloudflare/src/normalize.js +288 -0
  75. package/dist/packages/connectors/mock/src/index.d.ts +58 -0
  76. package/dist/packages/connectors/mock/src/index.js +66 -0
  77. package/dist/packages/connectors/openai/src/index.d.ts +55 -0
  78. package/dist/packages/connectors/openai/src/index.js +169 -0
  79. package/dist/packages/connectors/openai/src/normalize.d.ts +91 -0
  80. package/dist/packages/connectors/openai/src/normalize.js +180 -0
  81. package/dist/packages/connectors/supabase/src/client.d.ts +22 -0
  82. package/dist/packages/connectors/supabase/src/client.js +132 -0
  83. package/dist/packages/connectors/supabase/src/index.d.ts +33 -0
  84. package/dist/packages/connectors/supabase/src/index.js +87 -0
  85. package/dist/packages/connectors/supabase/src/normalize.d.ts +106 -0
  86. package/dist/packages/connectors/supabase/src/normalize.js +266 -0
  87. package/dist/packages/core/src/collector.d.ts +12 -0
  88. package/dist/packages/core/src/collector.js +68 -0
  89. package/dist/packages/core/src/index.d.ts +5 -0
  90. package/dist/packages/core/src/index.js +4 -0
  91. package/dist/packages/core/src/provider.d.ts +18 -0
  92. package/dist/packages/core/src/provider.js +2 -0
  93. package/dist/packages/core/src/risk-engine.d.ts +9 -0
  94. package/dist/packages/core/src/risk-engine.js +4 -0
  95. package/dist/packages/core/src/snapshots.d.ts +49 -0
  96. package/dist/packages/core/src/snapshots.js +9 -0
  97. package/dist/packages/db/src/client.d.ts +11 -0
  98. package/dist/packages/db/src/client.js +14 -0
  99. package/dist/packages/db/src/index.d.ts +6 -0
  100. package/dist/packages/db/src/index.js +6 -0
  101. package/dist/packages/db/src/local-store.d.ts +161 -0
  102. package/dist/packages/db/src/local-store.js +623 -0
  103. package/dist/packages/db/src/migrate.d.ts +17 -0
  104. package/dist/packages/db/src/migrate.js +35 -0
  105. package/dist/packages/db/src/schema.d.ts +5 -0
  106. package/dist/packages/db/src/schema.js +120 -0
  107. package/dist/packages/db/src/sqlite-bin.d.ts +3 -0
  108. package/dist/packages/db/src/sqlite-bin.js +16 -0
  109. package/dist/packages/local-api/src/index.d.ts +2 -0
  110. package/dist/packages/local-api/src/index.js +2 -0
  111. package/dist/packages/local-api/src/server.d.ts +36 -0
  112. package/dist/packages/local-api/src/server.js +310 -0
  113. package/dist/packages/report/src/daily.d.ts +24 -0
  114. package/dist/packages/report/src/daily.js +9 -0
  115. package/dist/packages/report/src/index.d.ts +4 -0
  116. package/dist/packages/report/src/index.js +4 -0
  117. package/dist/packages/report/src/korean.d.ts +3 -0
  118. package/dist/packages/report/src/korean.js +62 -0
  119. package/dist/packages/report/src/slack.d.ts +34 -0
  120. package/dist/packages/report/src/slack.js +134 -0
  121. package/dist/packages/runtime/src/index.d.ts +2 -0
  122. package/dist/packages/runtime/src/index.js +2 -0
  123. package/dist/packages/runtime/src/runtime.d.ts +26 -0
  124. package/dist/packages/runtime/src/runtime.js +182 -0
  125. package/dist/packages/view-model/src/hud-model.d.ts +74 -0
  126. package/dist/packages/view-model/src/hud-model.js +295 -0
  127. package/dist/packages/view-model/src/index.d.ts +6 -0
  128. package/dist/packages/view-model/src/index.js +6 -0
  129. package/dist/packages/view-model/src/notification-preferences-model.d.ts +75 -0
  130. package/dist/packages/view-model/src/notification-preferences-model.js +400 -0
  131. package/dist/packages/view-model/src/notification-preferences.d.ts +6 -0
  132. package/dist/packages/view-model/src/notification-preferences.js +36 -0
  133. package/dist/packages/view-model/src/sync-state.d.ts +47 -0
  134. package/dist/packages/view-model/src/sync-state.js +140 -0
  135. package/dist/packages/view-model/src/usage-progress.d.ts +22 -0
  136. package/dist/packages/view-model/src/usage-progress.js +57 -0
  137. package/dist/packages/view-model/src/view-model.d.ts +215 -0
  138. package/dist/packages/view-model/src/view-model.js +826 -0
  139. package/package.json +40 -0
  140. package/scripts/postinstall.mjs +69 -0
@@ -0,0 +1,57 @@
1
+ const DEFAULT_WARNING_AT_PERCENT = 80;
2
+ const DEFAULT_CRITICAL_AT_PERCENT = 95;
3
+ export function usageProgressFromUsedPercent(value, thresholds = {}) {
4
+ const usedPercent = normalizePercent(value);
5
+ const warningAtPercent = thresholds.warningAtPercent ?? DEFAULT_WARNING_AT_PERCENT;
6
+ const criticalAtPercent = thresholds.criticalAtPercent ?? DEFAULT_CRITICAL_AT_PERCENT;
7
+ return {
8
+ usedPercent,
9
+ remainingPercent: usedPercent === null ? null : clampPercent(100 - usedPercent),
10
+ warningAtPercent,
11
+ criticalAtPercent,
12
+ };
13
+ }
14
+ export function usageProgressFromRemainingPercent(value, thresholds = {}) {
15
+ const remainingPercent = normalizePercent(value);
16
+ const warningAtPercent = thresholds.warningAtPercent ?? DEFAULT_WARNING_AT_PERCENT;
17
+ const criticalAtPercent = thresholds.criticalAtPercent ?? DEFAULT_CRITICAL_AT_PERCENT;
18
+ return {
19
+ usedPercent: remainingPercent === null ? null : clampPercent(100 - remainingPercent),
20
+ remainingPercent,
21
+ warningAtPercent,
22
+ criticalAtPercent,
23
+ };
24
+ }
25
+ export function usageProgressFromTokens(usedTokens, remainingTokens, thresholds = {}) {
26
+ const used = normalizeNonNegativeNumber(usedTokens);
27
+ const remaining = normalizeNonNegativeNumber(remainingTokens);
28
+ if (used === null || remaining === null) {
29
+ return usageProgressFromUsedPercent(null, thresholds);
30
+ }
31
+ const total = used + remaining;
32
+ return usageProgressFromUsedPercent(total <= 0 ? null : (used / total) * 100, thresholds);
33
+ }
34
+ export function usageProgressSeverity(progress) {
35
+ if (progress.usedPercent === null) {
36
+ return "info";
37
+ }
38
+ if (progress.usedPercent >= progress.criticalAtPercent) {
39
+ return "critical";
40
+ }
41
+ if (progress.usedPercent >= progress.warningAtPercent) {
42
+ return "warning";
43
+ }
44
+ return "info";
45
+ }
46
+ export function normalizePercent(value) {
47
+ return value === null || value === undefined || !Number.isFinite(value)
48
+ ? null
49
+ : clampPercent(value);
50
+ }
51
+ function normalizeNonNegativeNumber(value) {
52
+ return value === null || value === undefined || !Number.isFinite(value) || value < 0 ? null : value;
53
+ }
54
+ function clampPercent(value) {
55
+ return Math.max(0, Math.min(100, Number(value.toFixed(2))));
56
+ }
57
+ //# sourceMappingURL=usage-progress.js.map
@@ -0,0 +1,215 @@
1
+ import { type NotificationPreferences, type NotificationWidgetKey } from "./notification-preferences.js";
2
+ export interface LocalSafeEnvelope {
3
+ generatedAt: string;
4
+ localOnly: true;
5
+ secretsReturned: false;
6
+ }
7
+ export type ViewModelHealthStatus = "ok" | "degraded" | "down" | "unknown";
8
+ export type ViewModelRiskSeverity = "info" | "warning" | "critical";
9
+ export interface ViewModelProviderRecord {
10
+ key: string;
11
+ displayName: string;
12
+ }
13
+ export interface ViewModelUsageSnapshotRecord {
14
+ providerKey: string;
15
+ collectedAt: string;
16
+ service: string;
17
+ metric: string;
18
+ unit: string;
19
+ value: number;
20
+ }
21
+ export interface ViewModelBillingSnapshotRecord {
22
+ providerKey: string;
23
+ collectedAt: string;
24
+ amountMinor: number;
25
+ currency: string;
26
+ status: string;
27
+ }
28
+ export interface ViewModelServiceHealthSnapshotRecord {
29
+ providerKey: string;
30
+ collectedAt: string;
31
+ service: string;
32
+ status: ViewModelHealthStatus;
33
+ region?: string;
34
+ message?: string;
35
+ }
36
+ export interface ViewModelCostEstimateRecord {
37
+ providerKey: string;
38
+ collectedAt: string;
39
+ estimatedAmountMinor: number;
40
+ currency: string;
41
+ confidence: "low" | "medium" | "high";
42
+ }
43
+ export interface ViewModelAlertRecord {
44
+ providerKey?: string;
45
+ createdAt: string;
46
+ severity: ViewModelRiskSeverity;
47
+ category: string;
48
+ title: string;
49
+ message: string;
50
+ }
51
+ export interface ViewModelStore {
52
+ providers: readonly ViewModelProviderRecord[];
53
+ usageSnapshots: readonly ViewModelUsageSnapshotRecord[];
54
+ billingSnapshots: readonly ViewModelBillingSnapshotRecord[];
55
+ serviceHealthSnapshots: readonly ViewModelServiceHealthSnapshotRecord[];
56
+ costEstimates: readonly ViewModelCostEstimateRecord[];
57
+ alerts: readonly ViewModelAlertRecord[];
58
+ }
59
+ export type ViewModelReadStore = () => Promise<ViewModelStore>;
60
+ export interface OperationsOverview extends LocalSafeEnvelope {
61
+ source: "sqlite" | "empty";
62
+ summary: {
63
+ providerCount: number;
64
+ connectedProviderCount: number;
65
+ totalEstimatedAmountMinor: number;
66
+ totalBillingAmountMinor: number;
67
+ currency: string;
68
+ usageSnapshotCount: number;
69
+ costEstimateCount: number;
70
+ alertCount: number;
71
+ criticalAlertCount: number;
72
+ healthStatus: ViewModelHealthStatus;
73
+ };
74
+ providers: readonly OperationsOverviewProvider[];
75
+ alerts: readonly OperationsOverviewAlert[];
76
+ }
77
+ export interface OperationsOverviewProvider {
78
+ providerKey: string;
79
+ displayName: string;
80
+ estimatedAmountMinor: number;
81
+ billingAmountMinor: number;
82
+ currency: string;
83
+ usageSnapshotCount: number;
84
+ costEstimateCount: number;
85
+ latestCollectedAt: string | null;
86
+ healthStatus: ViewModelHealthStatus;
87
+ riskLevel: "low" | "warning" | "critical";
88
+ alertCount: number;
89
+ }
90
+ export interface OperationsOverviewAlert {
91
+ providerKey: string | null;
92
+ displayName: string | null;
93
+ severity: ViewModelRiskSeverity;
94
+ category: string;
95
+ title: string;
96
+ message: string;
97
+ createdAt: string;
98
+ }
99
+ export interface TodayLiveView extends LocalSafeEnvelope {
100
+ timezone: string;
101
+ dateKey: string;
102
+ cacheState: "empty" | "fresh" | "stale";
103
+ summary: {
104
+ providerCount: number;
105
+ includedProviderCount: number;
106
+ todayLiveAmountMinor: number | null;
107
+ currency: string;
108
+ };
109
+ providers: readonly TodayLiveProviderView[];
110
+ }
111
+ export interface TodayLiveProviderInput {
112
+ providerKey: string;
113
+ displayName: string;
114
+ checkedAt: string | null;
115
+ expiresAt?: string | null;
116
+ ttlSeconds?: number;
117
+ lastAttemptAt?: string | null;
118
+ lastSuccessAt?: string | null;
119
+ freshUntil?: string | null;
120
+ staleUntil?: string | null;
121
+ lastRefreshFailed?: boolean;
122
+ revision?: number;
123
+ message?: string;
124
+ freshness: "live" | "stale" | "error" | "unavailable" | "not_configured" | "locked";
125
+ confidence: "high" | "medium" | "low" | "none";
126
+ todayLiveAmountMinor: number | null;
127
+ currency: string;
128
+ included: boolean;
129
+ metrics?: readonly TodayLiveMetric[];
130
+ }
131
+ export interface TodayLiveProviderView extends TodayLiveProviderInput {
132
+ metrics: readonly TodayLiveMetric[];
133
+ }
134
+ export interface TodayLiveMetric {
135
+ key: string;
136
+ value: number;
137
+ unit: string;
138
+ resetAt?: string;
139
+ resetAtLatest?: string;
140
+ itemKey?: string;
141
+ accuracy?: "exact" | "estimated" | "bounded" | "unknown";
142
+ source?: string;
143
+ }
144
+ export interface NotificationDigest extends LocalSafeEnvelope {
145
+ title: string;
146
+ status: "ok" | "attention" | "critical";
147
+ suppressedReason: string | null;
148
+ items: readonly NotificationDigestItem[];
149
+ }
150
+ export interface NotificationDigestItem {
151
+ widgetKey: NotificationWidgetKey;
152
+ kind: "summary" | "live" | "risk" | "usage" | "health";
153
+ severity: ViewModelRiskSeverity;
154
+ label: string;
155
+ value: string;
156
+ numericValue?: number;
157
+ unit?: string;
158
+ usedPercent?: number;
159
+ remainingPercent?: number;
160
+ resetAt?: string;
161
+ resetAtLatest?: string;
162
+ providerKey?: string;
163
+ accuracy?: "exact" | "estimated" | "bounded" | "unknown";
164
+ freshness?: TodayLiveProviderView["freshness"];
165
+ confidence?: TodayLiveProviderView["confidence"];
166
+ clickPath?: string;
167
+ }
168
+ export interface TrayMenuModel extends LocalSafeEnvelope {
169
+ title: string;
170
+ subtitle: string;
171
+ status: "ok" | "attention" | "critical";
172
+ items: readonly TrayMenuItem[];
173
+ }
174
+ export interface TrayMenuItem {
175
+ id: string;
176
+ label: string;
177
+ enabled: boolean;
178
+ kind: "command" | "separator" | "status";
179
+ action?: string;
180
+ urlPath?: string;
181
+ durationMinutes?: number;
182
+ }
183
+ export interface ReadOperationsOverviewOptions {
184
+ now?: () => Date;
185
+ store?: ViewModelStore;
186
+ readStore?: ViewModelReadStore;
187
+ }
188
+ export interface ReadTodayLiveViewOptions extends ReadOperationsOverviewOptions {
189
+ timezone?: string;
190
+ liveProviders?: readonly TodayLiveProviderInput[];
191
+ }
192
+ export interface ReadNotificationDigestOptions extends ReadTodayLiveViewOptions {
193
+ overview?: OperationsOverview;
194
+ todayLive?: TodayLiveView;
195
+ notificationPreferences?: NotificationPreferences;
196
+ }
197
+ export interface ReadTrayMenuModelOptions extends ReadNotificationDigestOptions {
198
+ digest?: NotificationDigest;
199
+ }
200
+ export declare function readOperationsOverview(options?: ReadOperationsOverviewOptions): Promise<OperationsOverview>;
201
+ export declare function buildOperationsOverview(store: ViewModelStore, options: {
202
+ generatedAt: string;
203
+ }): OperationsOverview;
204
+ export declare function readTodayLiveView(options?: ReadTodayLiveViewOptions): Promise<TodayLiveView>;
205
+ export declare function buildTodayLiveView(store: ViewModelStore, options: {
206
+ generatedAt: string;
207
+ now: Date;
208
+ timezone: string;
209
+ liveProviders?: readonly TodayLiveProviderInput[];
210
+ }): TodayLiveView;
211
+ export declare function readNotificationDigest(options?: ReadNotificationDigestOptions): Promise<NotificationDigest>;
212
+ export declare function buildNotificationDigest(overview: OperationsOverview, todayLive: TodayLiveView, preferences?: NotificationPreferences): NotificationDigest;
213
+ export declare function readTrayMenuModel(options?: ReadTrayMenuModelOptions): Promise<TrayMenuModel>;
214
+ export declare function buildTrayMenuModel(digest: NotificationDigest): TrayMenuModel;
215
+ //# sourceMappingURL=view-model.d.ts.map