@hasna/economy 0.3.7 → 0.3.9

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 (141) hide show
  1. package/CHANGELOG.md +33 -4
  2. package/README.md +28 -61
  3. package/dashboard/README.md +17 -64
  4. package/docs/README.md +12 -0
  5. package/docs/cli.md +88 -0
  6. package/docs/configuration.md +88 -0
  7. package/docs/ingestion.md +47 -0
  8. package/docs/mcp.md +65 -0
  9. package/docs/otel.md +53 -0
  10. package/docs/rest-api.md +89 -0
  11. package/package.json +6 -7
  12. package/dist/cli/brains.d.ts +0 -3
  13. package/dist/cli/brains.d.ts.map +0 -1
  14. package/dist/cli/commands/brief.d.ts +0 -11
  15. package/dist/cli/commands/brief.d.ts.map +0 -1
  16. package/dist/cli/commands/completion.d.ts +0 -2
  17. package/dist/cli/commands/completion.d.ts.map +0 -1
  18. package/dist/cli/commands/extras.d.ts +0 -4
  19. package/dist/cli/commands/extras.d.ts.map +0 -1
  20. package/dist/cli/commands/menubar.d.ts +0 -7
  21. package/dist/cli/commands/menubar.d.ts.map +0 -1
  22. package/dist/cli/commands/notification.d.ts +0 -8
  23. package/dist/cli/commands/notification.d.ts.map +0 -1
  24. package/dist/cli/commands/todos.d.ts +0 -29
  25. package/dist/cli/commands/todos.d.ts.map +0 -1
  26. package/dist/cli/commands/tui.d.ts +0 -26
  27. package/dist/cli/commands/tui.d.ts.map +0 -1
  28. package/dist/cli/commands/watch.d.ts +0 -10
  29. package/dist/cli/commands/watch.d.ts.map +0 -1
  30. package/dist/cli/index.d.ts +0 -3
  31. package/dist/cli/index.d.ts.map +0 -1
  32. package/dist/cli/index.js +0 -12304
  33. package/dist/db/cloud.d.ts +0 -28
  34. package/dist/db/cloud.d.ts.map +0 -1
  35. package/dist/db/database.d.ts +0 -150
  36. package/dist/db/database.d.ts.map +0 -1
  37. package/dist/db/pg-migrations.d.ts +0 -7
  38. package/dist/db/pg-migrations.d.ts.map +0 -1
  39. package/dist/db/pg-sync-worker.d.ts +0 -2
  40. package/dist/db/pg-sync-worker.d.ts.map +0 -1
  41. package/dist/db/sync-pg.d.ts +0 -43
  42. package/dist/db/sync-pg.d.ts.map +0 -1
  43. package/dist/index.d.ts +0 -3
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/index.js +0 -3729
  46. package/dist/ingest/billing.d.ts +0 -27
  47. package/dist/ingest/billing.d.ts.map +0 -1
  48. package/dist/ingest/claude-quota.d.ts +0 -5
  49. package/dist/ingest/claude-quota.d.ts.map +0 -1
  50. package/dist/ingest/claude.d.ts +0 -18
  51. package/dist/ingest/claude.d.ts.map +0 -1
  52. package/dist/ingest/codex-quota.d.ts +0 -5
  53. package/dist/ingest/codex-quota.d.ts.map +0 -1
  54. package/dist/ingest/codex.d.ts +0 -8
  55. package/dist/ingest/codex.d.ts.map +0 -1
  56. package/dist/ingest/cursor.d.ts +0 -6
  57. package/dist/ingest/cursor.d.ts.map +0 -1
  58. package/dist/ingest/gemini.d.ts +0 -6
  59. package/dist/ingest/gemini.d.ts.map +0 -1
  60. package/dist/ingest/hermes.d.ts +0 -6
  61. package/dist/ingest/hermes.d.ts.map +0 -1
  62. package/dist/ingest/loops.d.ts +0 -6
  63. package/dist/ingest/loops.d.ts.map +0 -1
  64. package/dist/ingest/opencode.d.ts +0 -7
  65. package/dist/ingest/opencode.d.ts.map +0 -1
  66. package/dist/ingest/otel.d.ts +0 -33
  67. package/dist/ingest/otel.d.ts.map +0 -1
  68. package/dist/ingest/pi.d.ts +0 -7
  69. package/dist/ingest/pi.d.ts.map +0 -1
  70. package/dist/ingest/plugin.d.ts +0 -17
  71. package/dist/ingest/plugin.d.ts.map +0 -1
  72. package/dist/lib/accounts.d.ts +0 -11
  73. package/dist/lib/accounts.d.ts.map +0 -1
  74. package/dist/lib/agents.d.ts +0 -11
  75. package/dist/lib/agents.d.ts.map +0 -1
  76. package/dist/lib/analytics.d.ts +0 -68
  77. package/dist/lib/analytics.d.ts.map +0 -1
  78. package/dist/lib/billing-diff.d.ts +0 -22
  79. package/dist/lib/billing-diff.d.ts.map +0 -1
  80. package/dist/lib/brief.d.ts +0 -72
  81. package/dist/lib/brief.d.ts.map +0 -1
  82. package/dist/lib/cloud-storage.d.ts +0 -48
  83. package/dist/lib/cloud-storage.d.ts.map +0 -1
  84. package/dist/lib/config.d.ts +0 -13
  85. package/dist/lib/config.d.ts.map +0 -1
  86. package/dist/lib/contracts-client/index.d.ts +0 -3
  87. package/dist/lib/contracts-client/index.d.ts.map +0 -1
  88. package/dist/lib/contracts-client/mode.d.ts +0 -20
  89. package/dist/lib/contracts-client/mode.d.ts.map +0 -1
  90. package/dist/lib/contracts-client/storage.d.ts +0 -83
  91. package/dist/lib/contracts-client/storage.d.ts.map +0 -1
  92. package/dist/lib/contracts-client/transport.d.ts +0 -148
  93. package/dist/lib/contracts-client/transport.d.ts.map +0 -1
  94. package/dist/lib/gatherer.d.ts +0 -21
  95. package/dist/lib/gatherer.d.ts.map +0 -1
  96. package/dist/lib/model-config.d.ts +0 -8
  97. package/dist/lib/model-config.d.ts.map +0 -1
  98. package/dist/lib/open-projects.d.ts +0 -19
  99. package/dist/lib/open-projects.d.ts.map +0 -1
  100. package/dist/lib/package-metadata.d.ts +0 -8
  101. package/dist/lib/package-metadata.d.ts.map +0 -1
  102. package/dist/lib/paths.d.ts +0 -20
  103. package/dist/lib/paths.d.ts.map +0 -1
  104. package/dist/lib/periods.d.ts +0 -6
  105. package/dist/lib/periods.d.ts.map +0 -1
  106. package/dist/lib/pricing.d.ts +0 -13
  107. package/dist/lib/pricing.d.ts.map +0 -1
  108. package/dist/lib/savings.d.ts +0 -17
  109. package/dist/lib/savings.d.ts.map +0 -1
  110. package/dist/lib/serve-auth.d.ts +0 -4
  111. package/dist/lib/serve-auth.d.ts.map +0 -1
  112. package/dist/lib/spikes.d.ts +0 -18
  113. package/dist/lib/spikes.d.ts.map +0 -1
  114. package/dist/lib/store/index.d.ts +0 -303
  115. package/dist/lib/store/index.d.ts.map +0 -1
  116. package/dist/lib/sync-all.d.ts +0 -28
  117. package/dist/lib/sync-all.d.ts.map +0 -1
  118. package/dist/lib/watch-paths.d.ts +0 -3
  119. package/dist/lib/watch-paths.d.ts.map +0 -1
  120. package/dist/lib/webhooks.d.ts +0 -3
  121. package/dist/lib/webhooks.d.ts.map +0 -1
  122. package/dist/mcp/http.d.ts +0 -14
  123. package/dist/mcp/http.d.ts.map +0 -1
  124. package/dist/mcp/index.d.ts +0 -3
  125. package/dist/mcp/index.d.ts.map +0 -1
  126. package/dist/mcp/index.js +0 -6193
  127. package/dist/mcp/server.d.ts +0 -4
  128. package/dist/mcp/server.d.ts.map +0 -1
  129. package/dist/openapi.d.ts +0 -3
  130. package/dist/openapi.d.ts.map +0 -1
  131. package/dist/otel/index.d.ts +0 -3
  132. package/dist/otel/index.d.ts.map +0 -1
  133. package/dist/otel/index.js +0 -1399
  134. package/dist/server/index.d.ts +0 -3
  135. package/dist/server/index.d.ts.map +0 -1
  136. package/dist/server/index.js +0 -7977
  137. package/dist/server/pg-sync-worker.js +0 -31
  138. package/dist/server/serve.d.ts +0 -42
  139. package/dist/server/serve.d.ts.map +0 -1
  140. package/dist/types/index.d.ts +0 -238
  141. package/dist/types/index.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
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.3.9 - 2026-08-04
6
+
7
+ Release-only bump. Four PRs merged after `0.3.8` and were never published, because
8
+ this repo has no workflow that runs `npm publish` — the registry sat at `0.3.8`
9
+ while `main` accumulated a contracts migration, a data-correctness fix and a
10
+ metadata correction.
11
+
12
+ **Breaking for server operators.** `HASNA_ECONOMY_STORAGE_MODE` (and the
13
+ `ECONOMY_STORAGE_MODE` alias) are retired for server backend selection. They are
14
+ now *rejected at startup with a migration hint* rather than normalized, so a
15
+ half-migrated deployment fails loudly instead of quietly serving the wrong store.
16
+ The server data backend is `sqlite | postgresql`, selected by the presence of
17
+ `HASNA_ECONOMY_DATABASE_URL` alone. If you set `HASNA_ECONOMY_STORAGE_MODE=cloud`
18
+ to reach Postgres, unset it and rely on the database URL.
19
+
20
+ - **#27** `fix(client)` — hard-fail a half-applied cloud flip instead of silently
21
+ serving local data. An `API_URL` set *without* an `API_KEY` previously resolved
22
+ to `local` with no warning, byte-identical to an unconfigured host: the CLI
23
+ served the local SQLite store while the operator had pointed it at the cloud
24
+ API — a different dataset rendered as plausible spend numbers. It now reports
25
+ `misconfigured` and refuses. An unconfigured machine (neither variable set)
26
+ stays silently local; that negative control is covered by a test.
27
+ - **#28** `fix(contracts)` — migrate `storage.mode` to `storage.backend` for
28
+ contract kit `0.9.0`; declare `hosting` and `serviceSurfaces` in
29
+ `hasna.contract.json`. Bumps `@hasna/contracts` `^0.4.2` -> `^0.9.0`.
30
+ - **#29** `fix(server)` — make the runtime speak the `0.9.0` backend vocabulary it
31
+ declares; `isCloudMode()` is replaced by `resolveEconomyServerBackend()` and
32
+ `isPostgresBackend()` (both internal — neither was ever exported from the
33
+ package root).
34
+ - **#30** `fix(package)` — describe Gemini CLI support as legacy rather than
35
+ active, and name the Gemini API billing ingest separately. Google retired the
36
+ Gemini CLI on 2026-06-18.
37
+
5
38
  ## @hasna/economy 0.3.7 - 2026-07-24
6
39
 
7
40
  Reconciliation release: `main` had diverged from the published npm line. The `0.3.x`
@@ -29,10 +62,6 @@ three-way merge that keeps **both** histories.
29
62
  (and with it the `cloud schedule install|status|remove` commands) and
30
63
  `src/lib/fleet-sync.ts`. The MCP `sync` tool no longer reports `cloud_pushed` /
31
64
  `cloud_pulled` because `SyncAllResult` no longer carries them.
32
- - Replaced the `@hasna/agent-registry` and `@hasna/mcp-harness` `file:../open-*`
33
- sibling pins with the registry ranges (`^0.1.0`) that every published tarball has
34
- carried anyway. `bun install`, `tsc` and `src/mcp/http.test.ts` no longer require
35
- unpublished sibling checkouts, and `package.json` now matches what actually ships.
36
65
  - Bumped strictly above the published `0.3.6` latest. (The `v0.3.6` tag commit itself
37
66
  carried `package.json` version `0.3.5`; the `0.3.6` publish bumped the registry
38
67
  without a follow-up commit.)
package/README.md CHANGED
@@ -39,6 +39,15 @@ Open the dashboard with:
39
39
  economy dashboard --port 3456
40
40
  ```
41
41
 
42
+ ## Documentation
43
+
44
+ - [CLI reference](docs/cli.md)
45
+ - [Ingestion sources and attribution](docs/ingestion.md)
46
+ - [Configuration, storage modes, and deployment](docs/configuration.md)
47
+ - [REST API](docs/rest-api.md)
48
+ - [MCP server](docs/mcp.md)
49
+ - [OTLP/HTTP sidecar](docs/otel.md)
50
+
42
51
  ## CLI Output Defaults
43
52
 
44
53
  Economy CLI commands are compact by default so agent terminals do not fill their context with full records. High-cardinality list and status commands show essential columns, cap row counts, and print a hint when more rows are available.
@@ -55,7 +64,7 @@ economy todos list --verbose
55
64
  economy todos show 9.7
56
65
  ```
57
66
 
58
- `--json` remains the machine-readable path for commands that support it. Human output may truncate rows or long text; use `--json`, `--verbose`, `--limit`, or a `show`/detail command for complete data.
67
+ `--json` remains the machine-readable path for commands that support it. Human output may truncate rows or long text; use `--json`, `--limit`, or a `show`/detail command for complete data. `--verbose` expands output where supported; its exact limit is command-specific (for example, `economy session --verbose` shows up to 50 requests).
59
68
 
60
69
  Status subcommands follow the same rule. For example, `economy goal status` prints a compact human summary by default and `economy goal status --limit 5` or `--verbose` controls how many goals are listed.
61
70
 
@@ -91,7 +100,7 @@ Gemini settings:
91
100
  }
92
101
  ```
93
102
 
94
- The MCP server exposes read tools for summaries, sessions, machines, pricing, daily spend, budgets, goals, provider billing, usage snapshots, savings, project/account/agent/cost-center breakdowns, and subscriptions. MCP tools are compact by default for agent context safety; high-cardinality tools accept `limit`, `verbose`, or `json=true` where raw structured output is useful. It also exposes mutation tools for budgets, pricing rows, goals, and subscriptions so coding agents can manage Economy data through the same validated surface as the CLI and REST API.
103
+ The MCP server exposes read tools for summaries, sessions, machines, pricing, daily spend, budgets, goals, provider billing, usage snapshots, savings, project/account/agent/cost-center breakdowns, and subscriptions. MCP tools are compact by default for agent context safety; high-cardinality tools accept `limit`, `verbose`, or `json=true` where raw structured output is useful. It also exposes mutation tools for budgets, pricing rows, goals, and subscriptions so coding agents can manage Economy data through the same validated surface as the CLI and REST API. See the [MCP guide](docs/mcp.md) for HTTP mode and the complete tool list.
95
104
 
96
105
  ## Ingest
97
106
 
@@ -125,7 +134,7 @@ economy sync --recalculate
125
134
  economy sync --backfill-machine
126
135
  ```
127
136
 
128
- Full sync also imports active project metadata from `@hasna/projects` when the registry is available. The Codex source reads both legacy `~/.codex/state_5.sqlite` and current Codewith `~/.codewith/state_5.sqlite` usage stores by default; explicit `HASNA_ECONOMY_CODEX_DB_PATH` and `HASNA_ECONOMY_CODEWITH_DB_PATH` values override those locations.
137
+ Full sync also imports active project metadata from `@hasna/projects` when the registry is available. The Codex source reads both `~/.codex/state_5.sqlite` and the Codewith store at `~/.codewith/state_5.sqlite` by default; explicit `HASNA_ECONOMY_CODEX_DB_PATH` and `HASNA_ECONOMY_CODEWITH_DB_PATH` values override those locations.
129
138
 
130
139
  Account attribution is automatic when `@hasna/accounts` has a matching active, applied, or env-dir profile for the agent. Account identity is the email address plus coding agent, so `work@example.com` under Codex and Claude is reported as two accounts. You can also force attribution for a process with `ECONOMY_ACCOUNT=tool:name` or agent-specific overrides such as `ECONOMY_CODEX_ACCOUNT=codex:work`.
131
140
 
@@ -157,7 +166,7 @@ curl -X POST http://127.0.0.1:4318/ingest \
157
166
  -d '{"source":"app","cost_center":"alumia","cost_center_kind":"app","project_path":"/workspace/alumia","model":"gpt-5-mini","cost_usd":0.12,"input_tokens":1200,"output_tokens":300}'
158
167
  ```
159
168
 
160
- Accepted `/ingest` attribution fields include `cost_center`, `cost_center_kind`, `cost_center_id`, `attribution_tag`, `project_path`, `repo`, `account_key`, `account_tool`, `account_name`, `account_email`, and explicit `cost_usd`.
169
+ Accepted `/ingest` attribution fields include `cost_center`, `cost_center_kind`, `cost_center_id`, `attribution_tag`, `project_path`, `repo`, `account_key`, `account_tool`, `account_name`, `account_email`, and explicit `cost_usd`. The [OTLP guide](docs/otel.md) documents both payload formats and all aliases.
161
170
 
162
171
  Subscription plans can be configured locally and are used by savings calculations:
163
172
 
@@ -187,7 +196,7 @@ OpenRouter-style model IDs ending in `:free` are treated as zero-cost variants e
187
196
 
188
197
  ## Billing
189
198
 
190
- Estimated costs can be reconciled with provider billing:
199
+ Estimated costs can be reconciled with provider billing in local mode:
191
200
 
192
201
  ```bash
193
202
  economy billing sync --days 31
@@ -228,37 +237,16 @@ Start the server:
228
237
  economy-serve --port 3456
229
238
  ```
230
239
 
231
- Common endpoints:
232
-
233
- - `GET /health`
234
- - `GET /api/summary?period=today`
235
- - `GET /api/sessions?agent=codex&account=work@example.com&limit=20`
236
- - `GET /api/sessions/:id/requests`
237
- - `GET /api/models`
238
- - `GET /api/projects?period=month`
239
- - `GET /api/breakdown?by=agent&period=month`
240
- - `GET /api/breakdown?by=cost-center&period=month`
241
- - `GET /api/breakdown?by=loop&period=month`
242
- - `GET /api/accounts?period=month`
243
- - `GET /api/usage?period=month`
244
- - `GET /api/savings?period=month`
245
- - `GET /api/subscriptions`
246
- - `POST /api/subscriptions`
247
- - `DELETE /api/subscriptions/:id`
248
- - `GET /api/budgets`
249
- - `POST /api/budgets`
250
- - `DELETE /api/budgets/:id`
251
- - `GET /api/pricing`
252
- - `POST /api/pricing`
253
- - `DELETE /api/pricing/:model`
254
- - `GET /api/goals`
255
- - `POST /api/goals`
256
- - `DELETE /api/goals/:id`
257
- - `GET /api/billing?period=month`
258
- - `POST /api/sync`
259
- - `POST /api/billing/sync`
260
-
261
- Budget, goal, and subscription mutation endpoints validate agent scopes against `claude`, `takumi`, `codex`, `gemini`, `opencode`, `cursor`, `pi`, and `hermes`.
240
+ The canonical API uses `/v1`; `/api` remains a legacy alias for the dashboard and older clients. For example:
241
+
242
+ - `GET /health`, `/ready`, `/version`, and `/openapi.json`
243
+ - `GET /v1/summary?period=today`
244
+ - `GET /v1/sessions?agent=codex&account=work@example.com&limit=20`
245
+ - `GET /v1/breakdown?by=cost-center&period=month`
246
+ - `POST /v1/budgets`, `/v1/goals`, `/v1/pricing`, and `/v1/subscriptions`
247
+ - `POST /v1/sync`, `/v1/billing/sync`, and `/v1/ingest`
248
+
249
+ See the [REST API reference](docs/rest-api.md) for every route, response envelopes, authentication, and legacy aliases. The server publishes the current generated contract at `/openapi.json`.
262
250
 
263
251
  The server also serves the built dashboard when `dashboard/dist` is present. The dashboard includes account-scoped session filtering, subscription plan create/update/delete controls in Savings, and savings/usage/account tables for subscription-aware cost analysis.
264
252
 
@@ -282,22 +270,13 @@ economy menubar stop
282
270
  economy menubar uninstall
283
271
  ```
284
272
 
285
- ## Cloud Sync
286
-
287
- Economy can push and pull local SQLite data through `@hasna/cloud` PostgreSQL sync:
288
-
289
- ```bash
290
- economy cloud status
291
- economy cloud push
292
- economy cloud pull
293
- economy cloud sync
294
- ```
295
-
296
273
  ## Data Directory
297
274
 
298
275
  Data is stored in `~/.hasna/economy/`.
299
276
 
300
- The main SQLite database lives at `~/.hasna/economy/economy.db`. Older `~/.economy/` data is auto-migrated on first open. Override the database path with `HASNA_ECONOMY_DB_PATH` or `ECONOMY_DB`.
277
+ The main SQLite database lives at `~/.hasna/economy/economy.db`. Older `~/.economy/` data is copied on first open when the new directory does not exist. Override the database path with `HASNA_ECONOMY_DB_PATH` or `ECONOMY_DB`.
278
+
279
+ For shared deployments, CLI and MCP can use a remote `/v1` API instead of local SQLite by setting `HASNA_ECONOMY_API_URL` and `HASNA_ECONOMY_API_KEY`. See [configuration](docs/configuration.md) for client resolution, server auth, Postgres mode, and all environment variables.
301
280
 
302
281
  ## Development
303
282
 
@@ -305,6 +284,7 @@ The main SQLite database lives at `~/.hasna/economy/economy.db`. Older `~/.econo
305
284
  bun test
306
285
  bun run typecheck
307
286
  bun run build
287
+ bun scripts/sync-openapi.ts
308
288
  cd dashboard && bun run lint
309
289
  cd menubar && swift build -c release
310
290
  ```
@@ -313,19 +293,6 @@ cd menubar && swift build -c release
313
293
 
314
294
  Economy is published under the Apache-2.0 license. See [CONTRIBUTING.md](CONTRIBUTING.md) for local development and release hygiene, [SECURITY.md](SECURITY.md) for vulnerability reporting, [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for community expectations, and [CHANGELOG.md](CHANGELOG.md) for release notes.
315
295
 
316
- ## HTTP mode
317
-
318
- Shared Streamable HTTP transport for multi-agent sessions (stdio remains the default):
319
-
320
- ```bash
321
- economy-mcp --http # http://127.0.0.1:8860/mcp
322
- MCP_HTTP=1 economy-mcp # same
323
- economy-mcp --http --port 8815 # explicit port
324
- ```
325
-
326
- - Health: `GET http://127.0.0.1:8860/health` -> `{"status":"ok","name":"economy"}`
327
- - Override port with `MCP_HTTP_PORT` or `--port`
328
-
329
296
  ## License
330
297
 
331
298
  Apache-2.0 -- see [LICENSE](LICENSE)
@@ -1,73 +1,26 @@
1
- # React + TypeScript + Vite
1
+ # Economy dashboard
2
2
 
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3
+ The dashboard is the React/Vite UI served by `economy-serve`. It covers overview, sessions, models, projects, budgets, goals, usage, accounts, savings, fleet, reconciliation, pricing, and provider billing.
4
4
 
5
- Currently, two official plugins are available:
5
+ ## Development
6
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
7
+ Run the API from the repository root, then start Vite:
9
8
 
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
- ])
9
+ ```bash
10
+ economy-serve --port 3456
11
+ cd dashboard
12
+ bun install
13
+ bun run dev
44
14
  ```
45
15
 
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:
16
+ The development build uses `http://localhost:3456` by default. Set `VITE_API_URL` at build/dev time to use another origin. The dashboard currently calls the server's legacy-compatible `/api` routes; the public canonical API is `/v1`.
47
17
 
48
- ```js
49
- // eslint.config.js
50
- import reactX from 'eslint-plugin-react-x'
51
- import reactDom from 'eslint-plugin-react-dom'
18
+ ## Validation
52
19
 
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
- ])
20
+ ```bash
21
+ bun test
22
+ bun run lint
23
+ bun run build
73
24
  ```
25
+
26
+ The root package build writes production assets to `dashboard/dist`; `economy-serve` serves those assets and provides SPA fallback routing.
package/docs/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # Economy documentation
2
+
3
+ Economy can run as an on-machine SQLite application or as a client of a shared self-hosted HTTP service. These guides describe the current command and network surfaces:
4
+
5
+ - [CLI reference](cli.md) — the `economy` command and the four installed binaries.
6
+ - [Ingestion](ingestion.md) — supported sources, default paths, sync behavior, billing, and account attribution.
7
+ - [Configuration and deployment](configuration.md) — data paths, environment variables, local/server modes, and authentication.
8
+ - [REST API](rest-api.md) — canonical `/v1` routes, request conventions, probes, and legacy aliases.
9
+ - [MCP server](mcp.md) — stdio/HTTP setup and the available tools.
10
+ - [OTLP sidecar](otel.md) — OTLP metrics and the simplified `/ingest` payload.
11
+
12
+ For generated API details, start `economy-serve` and open [`/openapi.json`](http://127.0.0.1:3456/openapi.json). The checked-in source is [`openapi/economy.json`](../openapi/economy.json).
package/docs/cli.md ADDED
@@ -0,0 +1,88 @@
1
+ # CLI reference
2
+
3
+ Installing `@hasna/economy` provides four binaries:
4
+
5
+ | Binary | Purpose |
6
+ | --- | --- |
7
+ | `economy` | Ingest, query, and manage Economy data. |
8
+ | `economy-mcp` | Run the MCP server over stdio or Streamable HTTP. |
9
+ | `economy-serve` | Serve the REST API and built dashboard, or migrate a self-hosted database. |
10
+ | `economy-otel` | Ingest OTLP/HTTP metrics or simplified cost events into local SQLite. |
11
+
12
+ Use `<binary> --help` and `economy <command> --help` for the exact help emitted by the installed version.
13
+
14
+ ## Core commands
15
+
16
+ The supported coding-agent values are `claude`, `takumi`, `codex`, `gemini`, `opencode`, `cursor`, `pi`, and `hermes`.
17
+
18
+ | Command | Current behavior and principal options |
19
+ | --- | --- |
20
+ | `economy sync` | Ingest every local source, or select sources with `--claude`, `--takumi`, `--codex`, `--gemini`, `--opencode`, `--cursor`, `--pi`, `--hermes`, or `--loops`. Maintenance flags are `--force`, `--backfill-machine`, and `--recalculate`; `--verbose` prints source details. |
21
+ | `economy today`, `week`, `month` | Auto-sync in local mode and print the corresponding summary. Auto-sync is skipped in cloud-client mode. |
22
+ | `economy sessions` | List sessions. Filters: `--agent`, `--project`, `--account`, `--machine`, `--since`, and `--search`; `--limit` defaults to 20; `--format` is `table`, `compact`, `csv`, or `json`. |
23
+ | `economy session <id>` | Show one session and its requests. IDs may be prefixes. `--limit` defaults to 20 and `--verbose` shows up to 50 requests. |
24
+ | `economy top` | Rank expensive sessions with `-n`, `--agent`, and `--since`. |
25
+ | `economy breakdown` | Group by `model`, `agent`, `project`, `account`, `cost-center`, `loop`, `app`, or `repo`; accepts `--since`, `--limit`, `--verbose`, and `--json`. |
26
+ | `economy accounts [period]` | Account/profile totals for `today`, `week`, `month`, `year`, or `all`; accepts `--limit`, `--verbose`, and `--json`. |
27
+ | `economy machines` | Machines represented in stored data; accepts `--limit` and `--verbose`. |
28
+ | `economy fleet` | Shared summary plus per-machine rows; accepts `--period`, `--limit`, `--verbose`, and `--json`. |
29
+ | `economy brief` | Fleet brief with `--since <24h|7d|ISO-date>`, `--machine <id|all>`, or `--json`. |
30
+ | `economy usage [period]` | Quota/usage snapshots with `--agent`, `--limit`, `--verbose`, or `--json`. |
31
+ | `economy savings [period]` | Subscription-versus-API-equivalent savings with `--agent` or `--json`. |
32
+ | `economy watch` | Poll recent costs, or use `--daemon` to sync watched local paths. Also accepts `--interval`, `--agent`, and macOS `--notify`. In cloud mode it streams the API and does not ingest local files. |
33
+ | `economy status` | Print one-line spend, fleet, storage, top-agent, and available quota status. |
34
+ | `economy doctor` | Check source paths/token availability, storage mode, pricing gaps, deduplication, and billing drift. |
35
+ | `economy init` | Print first-run local and cloud-client setup hints. |
36
+
37
+ Human output for high-cardinality commands is intentionally capped. Use the command's `--json`, `--verbose`, or `--limit` option when available. JSON output is complete; `--verbose` has command-specific semantics, so consult `--help`.
38
+
39
+ ## Analysis and export
40
+
41
+ | Command | Behavior |
42
+ | --- | --- |
43
+ | `economy export` | Export `sessions` or `requests` as CSV. `--period` accepts `today`, `week`, `month`, or `all`; `--output` writes a file instead of stdout. |
44
+ | `economy compare <period1> <period2>` | Compare `today`, `yesterday`, `week`, `lastweek`, `month`, or `lastmonth`. |
45
+ | `economy forecast` | Project the current month's total from the observed burn rate. |
46
+ | `economy efficiency` | Show output/input ratio, cache-hit percentage, and cost per 1,000 output tokens by model. |
47
+ | `economy estimate --model <id>` | Estimate cost from `--input` and `--output` token counts using the active pricing table. |
48
+ | `economy tui` | Terminal dashboard; `--watch` refreshes at `--interval` seconds. |
49
+ | `economy waybar` | Emit a Waybar-compatible JSON status object. |
50
+ | `economy bar tui`, `bar waybar` | Aliases for the TUI and Waybar commands. |
51
+
52
+ ## Data management
53
+
54
+ | Command group | Subcommands |
55
+ | --- | --- |
56
+ | `economy budget` | `set` (`--limit` required; optional `--project`, `--agent`, `--cost-center`, `--period`, `--alert`), `list` (`--limit`, `--verbose`), `remove <id>`. |
57
+ | `economy goal` | `set` (`--limit` required; optional `--period`, `--project`, `--agent`), `list`, `status`, `remove <id>`. List/status accept `--limit` and `--verbose`. |
58
+ | `economy project` | `add <path> [--name]`, `list`, `show <nameOrPath>`, `rename <path> <name>`, `remove <path>`. |
59
+ | `economy pricing` | `list`, `set <model>`, `remove <model>`. Set accepts `--input`, `--output`, `--cache-read`, `--cache-write`, `--cache-write-1h`, and `--cache-storage`. |
60
+ | `economy subscriptions` | `set` (requires `--provider` and `--plan`; optional `--agent`, `--fee`, `--included`), `list`, `remove <id>`. |
61
+ | `economy billing` | `sync` (`--days`, provider selectors), `show --period`, and `diff --period`. Provider sync is local-only. |
62
+ | `economy config` | Show config, `get <key>`, `set <key> <value>`, or `webhook-test`. See [configuration](configuration.md). |
63
+ | `economy remove <type> <id>` | Top-level alias for removing a `budget`, `project`, `goal`, or `pricing` row. Alias: `rm`. |
64
+
65
+ ## Integrations and utilities
66
+
67
+ | Command | Behavior |
68
+ | --- | --- |
69
+ | `economy serve --port <port>` | Start the REST API in-process. Equivalent server controls are documented under [`economy-serve`](configuration.md#rest-server). |
70
+ | `economy dashboard --port <port>` | Start the server when necessary and open the dashboard URL. |
71
+ | `economy mcp` | Print Claude Code, Codex, and Gemini MCP configuration; select one or use `--all`. |
72
+ | `economy completion <shell>` | Print completion for `bash`, `zsh`, or `fish`. |
73
+ | `economy menubar` | `install [--force]`, `start`, `stop`, or `uninstall` the macOS Economy Bar app. |
74
+ | `economy brains` | `gather`, `train`, `model [set|clear]`, and `status`. Fine-tuning requires the optional `@hasna/brains` package; gathering does not. |
75
+ | `economy events`, `economy webhooks` | Event emit/list/replay and event-subscription commands supplied by `@hasna/events`; use the nested `--help` for options. |
76
+ | `economy todos` | Display the bundled Economy roadmap, filter tasks, or show a task ID. This is project planning data, not live service status. |
77
+
78
+ ## Other binary help
79
+
80
+ ```text
81
+ economy-mcp [--http] [--port <port>]
82
+ economy-serve [--port <port>]
83
+ economy-serve migrate
84
+ economy-serve version
85
+ economy-otel [--port <port>]
86
+ ```
87
+
88
+ `economy-mcp` and `economy-serve` support `--version`. See [MCP](mcp.md), [configuration](configuration.md), and [OTLP](otel.md) for environment controls and endpoints.
@@ -0,0 +1,88 @@
1
+ # Configuration and deployment
2
+
3
+ ## Local data
4
+
5
+ The default data directory is `~/.hasna/economy/` and the SQLite database is `~/.hasna/economy/economy.db`. On first access, regular files in an older `~/.economy/` directory are copied when the new directory does not yet exist.
6
+
7
+ | Variable | Effect |
8
+ | --- | --- |
9
+ | `HASNA_ECONOMY_DB_PATH` | SQLite path; takes precedence over `ECONOMY_DB`. |
10
+ | `ECONOMY_DB` | Alternate SQLite path. `:memory:` is useful for tests. |
11
+ | `HASNA_ECONOMY_CONFIG_PATH` | Path to `config.json`; defaults under the data directory. |
12
+ | `ECONOMY_MACHINE_ID` | Machine identifier; otherwise Economy uses the normalized hostname. |
13
+ | `ECONOMY_TAG` | Fallback attribution tag on locally written sessions/requests. |
14
+
15
+ `economy config` reads and writes `config.json`. The defaults are `port=3456`, `default-period=today`, `auto-sync=true`, `sync-interval=30`, `alert-thresholds=[5,10,25,50,100]`, and `webhook-url=null`. At present, `webhook-url` drives budget notifications and `activeModel` drives `economy brains`; the other stored values are compatibility/settings metadata. Binary ports, periods, and watch intervals still come from command options or the environment described below.
16
+
17
+ ## Account attribution
18
+
19
+ For an agent token such as `CODEX`, Economy checks these explicit forms before consulting `@hasna/accounts`:
20
+
21
+ ```text
22
+ ECONOMY_CODEX_ACCOUNT_KEY or ECONOMY_CODEX_ACCOUNT
23
+ ECONOMY_ACCOUNT_KEY or ECONOMY_ACCOUNT
24
+ ```
25
+
26
+ Values may be `tool:name` (for example `codex:work`) or a bare name/email. The structured form is:
27
+
28
+ ```text
29
+ ECONOMY_CODEX_ACCOUNT_TOOL / _NAME / _EMAIL
30
+ ECONOMY_ACCOUNT_TOOL / _NAME / _EMAIL
31
+ ```
32
+
33
+ The same agent-specific pattern applies to all eight supported agents. Account keys use the tool plus normalized email when available, otherwise the profile name.
34
+
35
+ ## CLI/MCP cloud client
36
+
37
+ Local is the default. To route CLI and MCP data operations to a shared server, set:
38
+
39
+ ```bash
40
+ export HASNA_ECONOMY_API_URL=https://economy.example.com
41
+ export HASNA_ECONOMY_API_KEY='...'
42
+ ```
43
+
44
+ URL plus key is itself a cloud-mode signal. You may explicitly set `HASNA_ECONOMY_STORAGE_MODE=cloud`; `self_hosted`, `remote`, and `hybrid` are accepted deprecated aliases. The resolver also accepts `HASNA_ECONOMY_MODE`, `ECONOMY_STORAGE_MODE`, and `ECONOMY_MODE`, plus unprefixed `ECONOMY_API_URL`/`ECONOMY_API_KEY` aliases. An existing `/v1` suffix is normalized, otherwise it is appended. Cloud mode with no key or an invalid URL fails rather than reading an unintended local dataset.
45
+
46
+ In cloud-client mode, data commands use the HTTP API, and local auto-sync, explicit `economy sync`, and `economy billing sync` are skipped. Clients never need or use a Postgres DSN.
47
+
48
+ ## REST server
49
+
50
+ Start the local server with either:
51
+
52
+ ```bash
53
+ economy serve --port 3456
54
+ economy-serve --port 3456
55
+ ```
56
+
57
+ `ECONOMY_PORT` supplies the `economy-serve` default. `ECONOMY_BIND` (or `ECONOMY_HOST`) controls the local bind host. `ECONOMY_API_TOKEN` (or `HASNA_ECONOMY_API_TOKEN`) enables the local shared-token check; send it as `Authorization: Bearer ...` or `X-Economy-Token`.
58
+
59
+ Without a local token, the current server defaults to `0.0.0.0` and API routes are unauthenticated. Set a token and an intentional bind address before exposing a local-mode server to another host.
60
+
61
+ The server serves `dashboard/dist` and falls back to its `index.html` for non-API paths when those assets exist.
62
+
63
+ ## Self-hosted server
64
+
65
+ The server backend follows the database URL alone — `postgresql` when one of these is set, `sqlite` when none is:
66
+
67
+ ```text
68
+ HASNA_ECONOMY_DATABASE_URL
69
+ ECONOMY_DATABASE_URL
70
+ DATABASE_URL
71
+ ```
72
+
73
+ `HASNA_ECONOMY_STORAGE_MODE` (and `HASNA_ECONOMY_MODE`, `ECONOMY_STORAGE_MODE`, `ECONOMY_MODE`) no longer selects a backend: the server refuses to start and prints a migration hint. Delete it and set a DSN instead. This is server-only — the CLI/MCP client still reads the mode variable described above.
74
+
75
+ Apply migrations with `economy-serve migrate`. `ECONOMY_PG_POOL_MAX` defaults to 5. A non-loopback server also requires one of `HASNA_ECONOMY_API_SIGNING_KEY`, `HASNA_API_SIGNING_KEY`, or `API_KEY_SIGNING_SECRET`; API keys are then verified by `@hasna/contracts`. The signing secret belongs only on the server.
76
+
77
+ See [REST API authentication](rest-api.md#authentication) for request headers and open probes.
78
+
79
+ ## Other services
80
+
81
+ | Variable | Effect |
82
+ | --- | --- |
83
+ | `MCP_HTTP=1` | Run `economy-mcp` in Streamable HTTP mode instead of stdio. |
84
+ | `MCP_HTTP_PORT` | MCP HTTP port; default 8860 and overridden by `--port`. |
85
+ | `ECONOMY_OTEL_PORT` | OTLP sidecar port; default 4318 and overridden by `--port`. |
86
+ | `ECONOMY_OTEL_BIND` | OTLP sidecar bind host; default `127.0.0.1`. |
87
+
88
+ Source- and billing-specific environment variables are listed in [Ingestion](ingestion.md).
@@ -0,0 +1,47 @@
1
+ # Ingestion
2
+
3
+ `economy sync` imports local coding-agent usage into Economy's SQLite database. A sync with no source flag runs every source; one or more source flags limit the run. Reads such as `economy today` also auto-sync all local sources before querying.
4
+
5
+ In cloud-client mode, CLI and MCP reads/writes go directly to the shared HTTP API. Local `sync` and `billing sync` deliberately do nothing in that mode; ingest on a machine running in local mode, or use the authenticated server ingest endpoints.
6
+
7
+ ## Sources
8
+
9
+ | Source | Default input | Notes and overrides |
10
+ | --- | --- | --- |
11
+ | Claude Code | `~/.claude/projects/**/*.jsonl` | Imports assistant messages with usage, including cache tiers and supported pricing modifiers. Quota uses `~/.claude/.credentials.json`, `CLAUDE_OAUTH_TOKEN`, or `ANTHROPIC_OAUTH_TOKEN`. |
12
+ | Takumi | `~/.takumi/projects/**/*.jsonl` | Uses the same JSONL ingestion format as Claude. |
13
+ | Codex | `~/.codex/state_5.sqlite`, rollout JSONL, and `~/.codex/config.toml` | Overrides: `HASNA_ECONOMY_CODEX_DB_PATH`, `HASNA_ECONOMY_CODEX_CONFIG_PATH`. Quota uses `~/.codex/auth.json` or `CODEX_OAUTH_TOKEN`; `CODEX_USAGE_URL` can override the quota URL. |
14
+ | Codewith (reported as Codex) | `~/.codewith/state_5.sqlite` and `~/.codewith/config.toml` | Overrides: `HASNA_ECONOMY_CODEWITH_DB_PATH`, `HASNA_ECONOMY_CODEWITH_CONFIG_PATH`. An explicit Codex DB path disables default Codewith discovery unless a Codewith DB path is also explicit. |
15
+ | Gemini CLI | `~/.gemini/tmp` and `~/.gemini/history` | Overrides: `HASNA_ECONOMY_GEMINI_TMP_DIR`, `HASNA_ECONOMY_GEMINI_HISTORY_DIR`. |
16
+ | OpenCode | `~/.local/share/opencode/storage/message/**/*.json` | Imports assistant-message usage and uses the recorded cost when present. |
17
+ | Cursor | Cursor `/api/usage` and `/api/usage-summary` | Requires `CURSOR_SESSION_TOKEN` (or `CURSOR_API_TOKEN`). Creates daily usage snapshots and a subscription rollup when spend is present. |
18
+ | Pi | `~/.pi/agent/sessions/**/*.json` | Override with `PI_CODING_AGENT_SESSION_DIR`. Uses recorded turn cost; a missing cost remains zero until pricing is repaired or the source records one. |
19
+ | Hermes | `~/.hermes/state.db` | Imports session-level token and cost rollups. |
20
+ | OpenLoops | `~/.hasna/loops/loops.db` | Override with `HASNA_ECONOMY_LOOPS_DB_PATH`; price with `HASNA_ECONOMY_LOOPS_MODEL` or `ECONOMY_LOOPS_MODEL`. Imports orchestration/judge `goal_runs.tokens_used` only, into `loop:*` cost centers. |
21
+
22
+ Full, unfiltered sync also attempts to import active metadata from `@hasna/projects`. Missing files, optional registries, and unavailable quota credentials are skipped; use `--verbose` to see source-level diagnostics.
23
+
24
+ ## Incremental and repair behavior
25
+
26
+ File/database state is cached in the `ingest_state` table, and request IDs are upserted and deduplicated. Consequently, normal repeated syncs are incremental.
27
+
28
+ - `--force` clears the ingest-state entries for the supported sources and reprocesses them.
29
+ - `--backfill-machine` fills empty `machine_id` values with `ECONOMY_MACHINE_ID` or the normalized hostname.
30
+ - `--recalculate` prices token-bearing requests whose `cost_usd` is zero, then rerolls affected sessions. It reports buckets still missing usable pricing.
31
+ - Budget webhooks are checked after a CLI or REST sync. Failed deliveries remain eligible for a later retry.
32
+
33
+ ## Account and cost-center attribution
34
+
35
+ Economy first checks agent-specific overrides such as `ECONOMY_CODEX_ACCOUNT`, then generic `ECONOMY_ACCOUNT` overrides, then matching `@hasna/accounts` env-dir/applied/current profiles. An override may be `tool:name`, an email, or separate `*_ACCOUNT_TOOL`, `*_ACCOUNT_NAME`, and `*_ACCOUNT_EMAIL` fields. See [configuration](configuration.md#account-attribution).
36
+
37
+ Apps and services can report explicit project, repository, account, attribution-tag, and cost-center fields through [`economy-otel`](otel.md). `ECONOMY_TAG` supplies a fallback attribution tag for records written through the local database helpers.
38
+
39
+ ## Provider billing
40
+
41
+ `economy billing sync --days 31` imports ground-truth daily billing locally:
42
+
43
+ - Anthropic: `HASNAXYZ_ANTHROPIC_LIVE_ADMIN_API_KEY` or `ANTHROPIC_ADMIN_API_KEY`.
44
+ - OpenAI: `HASNAXYZ_OPENAI_LIVE_ADMIN_API_KEY` or `OPENAI_ADMIN_API_KEY`.
45
+ - Gemini export: `HASNA_ECONOMY_GEMINI_BILLING_EXPORT_PATH`, `HASNAXYZ_ECONOMY_GEMINI_BILLING_EXPORT_PATH`, or `GEMINI_BILLING_EXPORT_PATH`.
46
+
47
+ Gemini imports JSON arrays, objects with a `rows` array, JSONL, or simple CSV. `economy billing show` compares totals; `economy billing diff` applies the reconciliation threshold.
package/docs/mcp.md ADDED
@@ -0,0 +1,65 @@
1
+ # MCP server
2
+
3
+ `economy-mcp` uses stdio by default:
4
+
5
+ ```bash
6
+ claude mcp add --transport stdio --scope user economy -- economy-mcp
7
+ ```
8
+
9
+ Codex configuration:
10
+
11
+ ```toml
12
+ [mcp_servers.economy]
13
+ command = "economy-mcp"
14
+ args = []
15
+ ```
16
+
17
+ Gemini settings:
18
+
19
+ ```json
20
+ {
21
+ "mcpServers": {
22
+ "economy": { "command": "economy-mcp", "args": [] }
23
+ }
24
+ }
25
+ ```
26
+
27
+ `economy mcp --all` prints these snippets. The MCP server uses the same local-versus-cloud Store selection as the CLI; configure a shared API with `HASNA_ECONOMY_API_URL` and `HASNA_ECONOMY_API_KEY` as described in [configuration](configuration.md#climcp-cloud-client).
28
+
29
+ ## Streamable HTTP
30
+
31
+ ```bash
32
+ economy-mcp --http # http://127.0.0.1:8860/mcp
33
+ MCP_HTTP=1 economy-mcp # same
34
+ economy-mcp --http --port 8815
35
+ ```
36
+
37
+ `MCP_HTTP_PORT` supplies the default HTTP port. The transport binds to loopback, exposes `POST /mcp`, and exposes `GET /health`. Stdio remains the default when `--http`/`MCP_HTTP` is absent.
38
+
39
+ ## Tools
40
+
41
+ Discovery helpers:
42
+
43
+ - `search_tools`, `describe_tools`
44
+
45
+ Cost and activity reads:
46
+
47
+ - `get_cost_summary`, `get_sessions`, `get_session_detail`, `get_top_sessions`
48
+ - `get_model_breakdown`, `get_project_breakdown`, `get_agent_breakdown`, `get_account_breakdown`, `get_cost_center_breakdown`
49
+ - `get_daily`, `list_machines`, `get_usage`, `get_savings`, `get_billing_summary`
50
+
51
+ Management and estimation:
52
+
53
+ - `get_budget_status`, `set_budget`, `remove_budget`
54
+ - `get_goals`, `set_goal`, `remove_goal`
55
+ - `get_pricing`, `set_pricing`, `remove_pricing`, `estimate_cost`
56
+ - `list_subscriptions`, `set_subscription`, `remove_subscription`
57
+ - `sync`, `send_feedback`
58
+
59
+ Shared agent-registry tools:
60
+
61
+ - `register_agent`, `heartbeat`, `set_focus`, `list_agents`
62
+
63
+ High-cardinality tools return compact text by default. Where the schema offers them, use `limit`, `verbose=true`, or `json=true`. Limits are clamped to 100 for MCP calls.
64
+
65
+ The `sync` tool accepts `all`, any supported coding agent, or `loops`. It ingests on-box files only in local mode. In cloud-client mode it returns an explanatory no-op because all other data tools already use the shared API.