@hasna/economy 0.2.42 → 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/CHANGELOG.md +8 -0
- package/dashboard/README.md +73 -0
- package/dist/cli/commands/brief.d.ts +4 -69
- package/dist/cli/commands/brief.d.ts.map +1 -1
- package/dist/cli/commands/extras.d.ts.map +1 -1
- package/dist/cli/commands/tui.d.ts +21 -5
- package/dist/cli/commands/tui.d.ts.map +1 -1
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/index.js +8253 -6105
- package/dist/db/cloud.d.ts +28 -0
- package/dist/db/cloud.d.ts.map +1 -0
- package/dist/db/database.d.ts +18 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/pg-migrations.d.ts.map +1 -1
- package/dist/db/pg-sync-worker.d.ts +2 -0
- package/dist/db/pg-sync-worker.d.ts.map +1 -0
- package/dist/db/sync-pg.d.ts +23 -0
- package/dist/db/sync-pg.d.ts.map +1 -0
- package/dist/index.d.ts +1 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1855 -1613
- package/dist/lib/analytics.d.ts +68 -0
- package/dist/lib/analytics.d.ts.map +1 -0
- package/dist/lib/brief.d.ts +72 -0
- package/dist/lib/brief.d.ts.map +1 -0
- package/dist/lib/cloud-storage.d.ts +48 -0
- package/dist/lib/cloud-storage.d.ts.map +1 -0
- package/dist/lib/contracts-client/index.d.ts +3 -0
- package/dist/lib/contracts-client/index.d.ts.map +1 -0
- package/dist/lib/contracts-client/mode.d.ts +20 -0
- package/dist/lib/contracts-client/mode.d.ts.map +1 -0
- package/dist/lib/contracts-client/storage.d.ts +83 -0
- package/dist/lib/contracts-client/storage.d.ts.map +1 -0
- package/dist/lib/contracts-client/transport.d.ts +148 -0
- package/dist/lib/contracts-client/transport.d.ts.map +1 -0
- package/dist/lib/pricing.d.ts +3 -0
- package/dist/lib/pricing.d.ts.map +1 -1
- package/dist/lib/store/index.d.ts +283 -0
- package/dist/lib/store/index.d.ts.map +1 -0
- package/dist/lib/sync-all.d.ts +0 -2
- package/dist/lib/sync-all.d.ts.map +1 -1
- package/dist/mcp/http.d.ts.map +1 -1
- package/dist/mcp/index.js +1934 -536
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/openapi.d.ts +3 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/otel/index.js +21 -267
- package/dist/server/index.js +3145 -321
- package/dist/server/pg-sync-worker.js +31 -0
- package/dist/server/serve.d.ts +31 -1
- package/dist/server/serve.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +9 -4
- package/dashboard/dist/assets/charts-BtCbslx4.js +0 -36
- package/dashboard/dist/assets/index-BDmtt3RI.css +0 -1
- package/dashboard/dist/assets/index-BFwRLqg7.js +0 -6
- package/dashboard/dist/assets/vendor-Cz8jb743.js +0 -53
- package/dashboard/dist/index.html +0 -16
- package/dashboard/dist/logo.jpg +0 -0
- package/dashboard/dist/vite.svg +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this repository are tracked here. This project follows semantic versioning for published npm packages when practical.
|
|
4
4
|
|
|
5
|
+
## @hasna/economy 0.2.43 - 2026-07-06
|
|
6
|
+
|
|
7
|
+
- Added the self_hosted service surface: `economy-serve` foundation probes (`GET /health`, `/ready`, `/version` -> `{ status, version, mode }`) and a versioned `/v1` API covering summaries, sessions, breakdowns, budgets, goals, pricing, subscriptions, billing, and sync.
|
|
8
|
+
- Added API-key authentication for the internet-facing `/v1` surface via `@hasna/contracts/auth` (stateless HMAC verify + revocation check).
|
|
9
|
+
- Added Amendment A1 PURE-REMOTE cloud storage: the serve reads/writes the shared RDS Postgres directly through a worker-backed synchronous PG adapter (no local cache, no sync engine in the service).
|
|
10
|
+
- Added a typed SDK client generated from the serve OpenAPI (`ECONOMY_API_URL` + `ECONOMY_API_KEY`).
|
|
11
|
+
- Added the deploy surface: ARM64/bun `Dockerfile`, `docker-compose.yml`, `hasna.contract.json`, a `migrations/` directory + runner (`economy-serve migrate`).
|
|
12
|
+
|
|
5
13
|
## @hasna/economy 0.2.41 - 2026-06-24
|
|
6
14
|
|
|
7
15
|
- Added root open-source project files for release notes, security reporting, contributing guidance, and conduct expectations.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default defineConfig([
|
|
20
|
+
globalIgnores(['dist']),
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{ts,tsx}'],
|
|
23
|
+
extends: [
|
|
24
|
+
// Other configs...
|
|
25
|
+
|
|
26
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
27
|
+
tseslint.configs.recommendedTypeChecked,
|
|
28
|
+
// Alternatively, use this for stricter rules
|
|
29
|
+
tseslint.configs.strictTypeChecked,
|
|
30
|
+
// Optionally, add this for stylistic rules
|
|
31
|
+
tseslint.configs.stylisticTypeChecked,
|
|
32
|
+
|
|
33
|
+
// Other configs...
|
|
34
|
+
],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
// other options...
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// eslint.config.js
|
|
50
|
+
import reactX from 'eslint-plugin-react-x'
|
|
51
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
52
|
+
|
|
53
|
+
export default defineConfig([
|
|
54
|
+
globalIgnores(['dist']),
|
|
55
|
+
{
|
|
56
|
+
files: ['**/*.{ts,tsx}'],
|
|
57
|
+
extends: [
|
|
58
|
+
// Other configs...
|
|
59
|
+
// Enable lint rules for React
|
|
60
|
+
reactX.configs['recommended-typescript'],
|
|
61
|
+
// Enable lint rules for React DOM
|
|
62
|
+
reactDom.configs.recommended,
|
|
63
|
+
],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parserOptions: {
|
|
66
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
+
tsconfigRootDir: import.meta.dirname,
|
|
68
|
+
},
|
|
69
|
+
// other options...
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
```
|
|
@@ -1,76 +1,11 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import
|
|
3
|
-
type
|
|
4
|
-
export
|
|
5
|
-
sessions: number;
|
|
6
|
-
requests: number;
|
|
7
|
-
input_tokens: number;
|
|
8
|
-
output_tokens: number;
|
|
9
|
-
cache_read_tokens: number;
|
|
10
|
-
cache_create_tokens: number;
|
|
11
|
-
cache_create_5m_tokens: number;
|
|
12
|
-
cache_create_1h_tokens: number;
|
|
13
|
-
total_tokens: number;
|
|
14
|
-
cost_usd: number;
|
|
15
|
-
last_active: string | null;
|
|
16
|
-
}
|
|
17
|
-
export interface BriefPeriodSummary extends BriefTotals {
|
|
18
|
-
label: string;
|
|
19
|
-
period: BriefPeriod | 'since';
|
|
20
|
-
since?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface BriefMachineRow extends BriefTotals {
|
|
23
|
-
machine_id: string;
|
|
24
|
-
last_data_at: string | null;
|
|
25
|
-
last_data_age: string;
|
|
26
|
-
}
|
|
27
|
-
export interface BriefAgentRow extends BriefTotals {
|
|
28
|
-
agent: string;
|
|
29
|
-
}
|
|
30
|
-
export interface BriefAccountRow extends BriefTotals {
|
|
31
|
-
account_key: string;
|
|
32
|
-
account_tool: string;
|
|
33
|
-
account_name: string;
|
|
34
|
-
account_email: string | null;
|
|
35
|
-
account_source: string;
|
|
36
|
-
}
|
|
37
|
-
export interface BriefFreshnessMachine {
|
|
38
|
-
machine_id: string;
|
|
39
|
-
max_request_at: string | null;
|
|
40
|
-
request_age: string;
|
|
41
|
-
last_merge_sync_at: string | null;
|
|
42
|
-
merge_sync_age: string;
|
|
43
|
-
}
|
|
44
|
-
export interface EconomyBrief {
|
|
45
|
-
generated_at: string;
|
|
46
|
-
machine: string;
|
|
47
|
-
since: {
|
|
48
|
-
input: string;
|
|
49
|
-
timestamp: string;
|
|
50
|
-
label: string;
|
|
51
|
-
};
|
|
52
|
-
summaries: BriefPeriodSummary[];
|
|
53
|
-
machines: BriefMachineRow[];
|
|
54
|
-
agents: BriefAgentRow[];
|
|
55
|
-
accounts: BriefAccountRow[];
|
|
56
|
-
freshness: {
|
|
57
|
-
machines: BriefFreshnessMachine[];
|
|
58
|
-
max_request_line: string;
|
|
59
|
-
merge_sync_line: string;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
interface BriefOptions {
|
|
63
|
-
since?: string;
|
|
64
|
-
machine?: string;
|
|
65
|
-
now?: Date;
|
|
66
|
-
currentMachineId?: string;
|
|
67
|
-
localSyncAt?: Date;
|
|
68
|
-
}
|
|
2
|
+
import { formatAge } from '../../lib/brief.js';
|
|
3
|
+
import type { EconomyBrief } from '../../lib/brief.js';
|
|
4
|
+
export type { EconomyBrief } from '../../lib/brief.js';
|
|
69
5
|
interface BriefCommandDeps {
|
|
70
6
|
beforeRead?: () => void | Promise<void>;
|
|
71
7
|
}
|
|
72
|
-
export declare function buildBrief(db: Database, opts?: BriefOptions): EconomyBrief;
|
|
73
8
|
export declare function renderBriefText(brief: EconomyBrief): string;
|
|
9
|
+
export { formatAge };
|
|
74
10
|
export declare function registerBriefCommand(program: Command, deps?: BriefCommandDeps): void;
|
|
75
|
-
export {};
|
|
76
11
|
//# sourceMappingURL=brief.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brief.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/brief.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"brief.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/brief.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAGV,YAAY,EACb,MAAM,oBAAoB,CAAA;AAE3B,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,UAAU,gBAAgB;IACxB,UAAU,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxC;AA4CD,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAyE3D;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA;AAEpB,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,GAAE,gBAAqB,GAAG,IAAI,CAgCxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extras.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/extras.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"extras.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/extras.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAsCnC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmR/D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+B5D"}
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { type EconomyStore } from '../../lib/store/index.js';
|
|
2
|
+
import type { SavingsSummary } from '../../lib/savings.js';
|
|
3
|
+
import type { CostSummary } from '../../types/index.js';
|
|
4
|
+
/** Everything the status surfaces need, gathered through the Store (never sqlite
|
|
5
|
+
* directly) so local and self_hosted/cloud render the same numbers. */
|
|
6
|
+
export interface StatusData {
|
|
7
|
+
today: CostSummary;
|
|
8
|
+
week: CostSummary;
|
|
9
|
+
month: CostSummary;
|
|
10
|
+
savings: SavingsSummary;
|
|
11
|
+
machineCount: number;
|
|
12
|
+
topAgent: string;
|
|
13
|
+
quota: string | null;
|
|
14
|
+
transport: EconomyStore['transport'];
|
|
15
|
+
}
|
|
16
|
+
/** Collect the status snapshot from the active Store transport. */
|
|
17
|
+
export declare function gatherStatusData(store?: EconomyStore): Promise<StatusData>;
|
|
18
|
+
export declare function buildStatusLine(data: StatusData): string;
|
|
19
|
+
export declare function buildWaybarJson(data: StatusData): Record<string, unknown>;
|
|
20
|
+
export declare function printStatusLine(): Promise<void>;
|
|
21
|
+
export declare function printWaybarJson(): Promise<void>;
|
|
6
22
|
export declare function runTui(opts: {
|
|
7
23
|
watch?: boolean;
|
|
8
24
|
interval?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/tui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/tui.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAkB,WAAW,EAAiB,MAAM,sBAAsB,CAAA;AAMtF;uEACuE;AACvE,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,WAAW,CAAA;IAClB,IAAI,EAAE,WAAW,CAAA;IACjB,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,CAAA;CACrC;AAmBD,mEAAmE;AACnE,wBAAsB,gBAAgB,CAAC,KAAK,GAAE,YAAyB,GAAG,OAAO,CAAC,UAAU,CAAC,CAoB5F;AAQD,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAUxD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzE;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAErD;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAErD;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/watch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/watch.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAGjD,UAAU,YAAY;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AA4BD,wBAAsB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0GlE"}
|