@hasna/economy 0.2.24 → 0.2.25

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 CHANGED
@@ -106,6 +106,12 @@ Full sync also imports active project metadata from `@hasna/projects` when the r
106
106
 
107
107
  Account attribution is automatic when `@hasna/accounts` has a matching active, applied, or env-dir profile for the agent. You can also force attribution for a process with `ECONOMY_ACCOUNT=tool:name` or agent-specific overrides such as `ECONOMY_CODEX_ACCOUNT=codex:work`.
108
108
 
109
+ Session drilldown can be scoped to an account key, account name, or email:
110
+
111
+ ```bash
112
+ economy sessions --account work@example.com
113
+ ```
114
+
109
115
  Account breakdowns report `api_equivalent_usd` for the API list-price value of the usage, plus `billable_usd`/`metered_api_usd` for known direct API spend and `subscription_included_usd` for usage covered by a subscription.
110
116
 
111
117
  Subscription plans can be configured locally and are used by savings calculations:
@@ -180,7 +186,7 @@ Common endpoints:
180
186
 
181
187
  - `GET /health`
182
188
  - `GET /api/summary?period=today`
183
- - `GET /api/sessions?agent=codex&limit=20`
189
+ - `GET /api/sessions?agent=codex&account=work@example.com&limit=20`
184
190
  - `GET /api/sessions/:id/requests`
185
191
  - `GET /api/models`
186
192
  - `GET /api/projects?period=month`
@@ -206,11 +212,11 @@ Common endpoints:
206
212
 
207
213
  Budget, goal, and subscription mutation endpoints validate agent scopes against `claude`, `takumi`, `codex`, `gemini`, `opencode`, `cursor`, `pi`, and `hermes`.
208
214
 
209
- The server also serves the built dashboard when `dashboard/dist` is present.
215
+ 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.
210
216
 
211
217
  ## Native macOS Menubar
212
218
 
213
- The `menubar/` app is a native SwiftUI `MenuBarExtra` app, not Electron. It targets Swift 5.9+ and macOS 14+, and talks to the REST API exposed by `economy-serve`. It shows today/week/month spend, token and request counts, top agents, top accounts, top projects, subscription savings, usage snapshots, recent sessions, and fleet status. The default server URL is `http://127.0.0.1:3456`.
219
+ The `menubar/` app is a native SwiftUI `MenuBarExtra` app, not Electron. It targets Swift 5.9+ and macOS 14+, and talks to the REST API exposed by `economy-serve`. It shows today/week/month spend, token and request counts, top agents, top accounts, top projects, active subscription plans, subscription savings, multi-agent usage snapshots, recent sessions, and fleet status. The default server URL is `http://127.0.0.1:3456`.
214
220
 
215
221
  Build it on macOS:
216
222
 
package/dist/cli/index.js CHANGED
@@ -6790,7 +6790,7 @@ program.command("month").description("Cost summary for this month").action(async
6790
6790
  await autoSync();
6791
6791
  printSummary("This Month", "month");
6792
6792
  });
6793
- program.command("sessions").description("List coding sessions with costs").option("--agent <agent>", "Filter by agent (claude|takumi|codex|gemini)").option("--project <path>", "Filter by project path").option("--machine <id>", "Filter by machine hostname (e.g. spark01, apple01)").option("--limit <n>", "Number of sessions", "20").option("--format <fmt>", "Output format: table|compact|csv|json", "table").option("--since <date>", "Filter sessions since date or relative (e.g. 2026-03-01, 7d, 30d)").option("--search <query>", "Search by project name, session id prefix, or agent").action(async (opts) => {
6793
+ program.command("sessions").description("List coding sessions with costs").option("--agent <agent>", "Filter by agent (claude|takumi|codex|gemini)").option("--project <path>", "Filter by project path").option("--account <query>", "Filter by account key, name, or email").option("--machine <id>", "Filter by machine hostname (e.g. spark01, apple01)").option("--limit <n>", "Number of sessions", "20").option("--format <fmt>", "Output format: table|compact|csv|json", "table").option("--since <date>", "Filter sessions since date or relative (e.g. 2026-03-01, 7d, 30d)").option("--search <query>", "Search by project name, session id prefix, or agent").action(async (opts) => {
6794
6794
  const limit = parsePositiveCliInteger(opts.limit ?? "20", "--limit");
6795
6795
  const agent = parseOptionalCliAgent(opts.agent);
6796
6796
  await autoSync();
@@ -6799,6 +6799,7 @@ program.command("sessions").description("List coding sessions with costs").optio
6799
6799
  let sessions = querySessions(db, {
6800
6800
  agent,
6801
6801
  project: opts.project,
6802
+ account: opts.account,
6802
6803
  machine: opts.machine,
6803
6804
  limit,
6804
6805
  since: sinceDate,
package/dist/mcp/index.js CHANGED
@@ -3450,7 +3450,7 @@ var TOOL_NAMES = [
3450
3450
  ];
3451
3451
  var TOOL_DESCRIPTIONS = {
3452
3452
  get_cost_summary: "period(today|week|month|year|all), machine?(hostname) -> {total_usd, sessions, requests, tokens, summary}",
3453
- get_sessions: `agent(${AGENTS.join("|")}), project(partial), machine?(hostname), limit(20) -> compact session table`,
3453
+ get_sessions: `agent(${AGENTS.join("|")}), project(partial), account?(key/name/email), machine?(hostname), limit(20) -> compact session table`,
3454
3454
  get_top_sessions: `n(10), agent(${AGENTS.join("|")}) -> top sessions by cost`,
3455
3455
  list_machines: "no params -> machine_id, sessions, requests, cost, last_active",
3456
3456
  get_model_breakdown: "no params -> model, requests, tokens, cost",
@@ -3524,15 +3524,17 @@ server.tool("get_cost_summary", "Cost summary (total_usd, sessions, requests, to
3524
3524
  ].join(`
3525
3525
  `));
3526
3526
  });
3527
- server.tool("get_sessions", "List sessions. Returns compact table. Params: agent, project, machine, limit(20)", {
3527
+ server.tool("get_sessions", "List sessions. Returns compact table. Params: agent, project, account, machine, limit(20)", {
3528
3528
  agent: z.enum(AGENTS).optional(),
3529
3529
  project: z.string().optional(),
3530
+ account: z.string().optional(),
3530
3531
  machine: z.string().optional(),
3531
3532
  limit: z.number().int().positive().max(100).optional()
3532
- }, async ({ agent, project, machine, limit }) => {
3533
+ }, async ({ agent, project, account, machine, limit }) => {
3533
3534
  const sessions = querySessions(db, {
3534
3535
  agent,
3535
3536
  project,
3537
+ account,
3536
3538
  machine,
3537
3539
  limit: limit ?? 20
3538
3540
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/economy",
3
- "version": "0.2.24",
3
+ "version": "0.2.25",
4
4
  "description": "AI coding cost tracker — CLI + MCP server + REST API + web dashboard for Claude Code, Codex, Gemini, OpenCode, Cursor, Pi, and Hermes",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",