@hasna/economy 0.5.2 → 0.5.4

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 (48) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +4 -2
  3. package/dist/chunks/{billing-bkpxy4kv.js → billing-22az60hy.js} +2 -2
  4. package/dist/chunks/{config-j9mv3ehk.js → config-hsp7ndhj.js} +2 -2
  5. package/dist/chunks/{index-npsjjv96.js → index-9arv0b1j.js} +162 -36
  6. package/dist/chunks/{index-hesxq90g.js → index-9wa1f2kv.js} +1 -1
  7. package/dist/chunks/{index-zpvea08j.js → index-c7h2rxx1.js} +38 -12
  8. package/dist/chunks/{index-9d2aky06.js → index-ct3zdefz.js} +3 -3
  9. package/dist/chunks/{index-k540hfww.js → index-dk5rq1rq.js} +1 -1
  10. package/dist/chunks/{index-ez9thsr7.js → index-f5jv6q5q.js} +38 -12
  11. package/dist/chunks/{index-dj3tctqh.js → index-n1wwqxfe.js} +14 -13
  12. package/dist/chunks/{index-kzwqw3ve.js → index-nheq2nrz.js} +2 -2
  13. package/dist/chunks/{index-2hwzmfgv.js → index-vajzfzgv.js} +38 -12
  14. package/dist/chunks/{open-projects-6z4pq6mx.js → open-projects-8qm46m3d.js} +1 -1
  15. package/dist/chunks/{pricing-vf2pycmh.js → pricing-462f8xkm.js} +1 -1
  16. package/dist/chunks/{pricing-f80p81gr.js → pricing-k9wsjwbz.js} +1 -1
  17. package/dist/chunks/{pricing-y21mcjsa.js → pricing-vxejj1qa.js} +1 -1
  18. package/dist/chunks/{serve-p2yarhm8.js → serve-ra46ms69.js} +18 -10
  19. package/dist/chunks/{sqlite-store-st99garx.js → sqlite-store-13nhr1z0.js} +2 -2
  20. package/dist/chunks/{sqlite-store-501f32ts.js → sqlite-store-gamn65xp.js} +2 -2
  21. package/dist/chunks/{sqlite-store-fq4natnf.js → sqlite-store-ht6frztj.js} +2 -2
  22. package/dist/chunks/{tui-x64hjfrh.js → tui-a1tvcw2j.js} +4 -4
  23. package/dist/chunks/{watch-bxstjpbx.js → watch-rvd3dn6r.js} +5 -5
  24. package/dist/chunks/{webhooks-k4fh2t9c.js → webhooks-nw4daw9y.js} +20 -9
  25. package/dist/cli/index.js +27 -27
  26. package/dist/db/database.d.ts +2 -2
  27. package/dist/db/database.d.ts.map +1 -1
  28. package/dist/db/sync-pg.d.ts.map +1 -1
  29. package/dist/index.js +15 -14
  30. package/dist/lib/accounts-store.d.ts +25 -1
  31. package/dist/lib/accounts-store.d.ts.map +1 -1
  32. package/dist/lib/accounts.d.ts.map +1 -1
  33. package/dist/lib/analytics.d.ts +1 -1
  34. package/dist/lib/analytics.d.ts.map +1 -1
  35. package/dist/lib/periods.d.ts +20 -1
  36. package/dist/lib/periods.d.ts.map +1 -1
  37. package/dist/lib/spikes.d.ts +3 -3
  38. package/dist/lib/spikes.d.ts.map +1 -1
  39. package/dist/lib/subscriptions-registry.d.ts +26 -0
  40. package/dist/lib/subscriptions-registry.d.ts.map +1 -0
  41. package/dist/lib/test-keychain-fixture.d.ts +3 -2
  42. package/dist/lib/test-keychain-fixture.d.ts.map +1 -1
  43. package/dist/mcp/index.js +245 -118
  44. package/dist/otel/index.js +56 -27
  45. package/dist/server/index.js +246 -77
  46. package/dist/server/service-operations.d.ts.map +1 -1
  47. package/dist/server/service-worker.js +237 -68
  48. package/package.json +1 -1
@@ -2384,7 +2384,7 @@ import { join as join3, basename } from "path";
2384
2384
  // src/lib/accounts-store.ts
2385
2385
  import { homedir as homedir2 } from "os";
2386
2386
  import { join as join2 } from "path";
2387
- import { z } from "zod";
2387
+ import { z as z2 } from "zod";
2388
2388
  import { resolveClientTransport, resolveCredential } from "@hasna/contracts/client";
2389
2389
 
2390
2390
  // src/lib/cloud-storage.ts
@@ -2515,32 +2515,61 @@ function economyCloudStorage(env = process.env) {
2515
2515
  return cache;
2516
2516
  }
2517
2517
 
2518
- // src/lib/accounts-store.ts
2519
- var profileNameSchema = z.string().min(1).max(64).regex(/^[a-z0-9][a-z0-9-]*$/, "must be lowercase alphanumeric/hyphen and start with a letter or digit");
2518
+ // src/lib/subscriptions-registry.ts
2519
+ import { execFile } from "child_process";
2520
+ import { promisify } from "util";
2521
+ import { isAbsolute } from "path";
2522
+ import { z } from "zod";
2523
+ var execute = promisify(execFile);
2524
+ var nonempty = z.string().min(1);
2520
2525
  var profileSchema = z.object({
2521
- name: z.string(),
2522
- tool: z.string(),
2526
+ name: nonempty,
2527
+ tool: nonempty,
2523
2528
  email: z.string().optional(),
2524
2529
  displayName: z.string().optional(),
2525
- dir: z.string(),
2530
+ dir: nonempty.refine(isAbsolute).refine((value) => !/[\0\r\n]/.test(value)),
2531
+ createdAt: nonempty,
2532
+ lastUsedAt: z.string().optional(),
2526
2533
  description: z.string().optional(),
2527
- createdAt: z.string(),
2528
- lastUsedAt: z.string().optional()
2534
+ active: z.boolean(),
2535
+ applied: z.boolean(),
2536
+ switchedAway: z.object({ profile: nonempty, email: z.string().optional() }).optional()
2529
2537
  });
2530
- var toolDefSchema = z.object({
2531
- id: z.string(),
2532
- label: z.string(),
2533
- envVar: z.string(),
2534
- defaultDir: z.string(),
2535
- bin: z.string()
2538
+ var toolsSchema = z.array(z.object({
2539
+ id: nonempty,
2540
+ label: nonempty,
2541
+ envVar: nonempty,
2542
+ defaultDir: nonempty,
2543
+ bin: nonempty
2544
+ }));
2545
+
2546
+ // src/lib/accounts-store.ts
2547
+ var profileNameSchema = z2.string().min(1).max(64).regex(/^[a-z0-9][a-z0-9-]*$/, "must be lowercase alphanumeric/hyphen and start with a letter or digit");
2548
+ var profileSchema2 = z2.object({
2549
+ name: z2.string(),
2550
+ tool: z2.string(),
2551
+ email: z2.string().optional(),
2552
+ displayName: z2.string().optional(),
2553
+ dir: z2.string(),
2554
+ description: z2.string().optional(),
2555
+ createdAt: z2.string(),
2556
+ lastUsedAt: z2.string().optional(),
2557
+ switchedAway: z2.object({ profile: z2.string().min(1), email: z2.string().optional() }).optional()
2536
2558
  });
2537
- var storeSchema = z.object({
2538
- version: z.literal(1),
2539
- current: z.record(z.string(), z.string()).default({}),
2540
- applied: z.record(z.string(), z.string()).default({}),
2541
- toolLocks: z.record(z.string(), z.string()).default({}),
2542
- profiles: z.array(profileSchema).default([]),
2543
- tools: z.array(toolDefSchema).default([])
2559
+ var toolDefSchema = z2.object({
2560
+ id: z2.string(),
2561
+ label: z2.string(),
2562
+ envVar: z2.string(),
2563
+ defaultDir: z2.string(),
2564
+ bin: z2.string()
2565
+ });
2566
+ var storeSchema = z2.object({
2567
+ version: z2.literal(1),
2568
+ current: z2.record(z2.string(), z2.string()).default({}),
2569
+ applied: z2.record(z2.string(), z2.string()).default({}),
2570
+ toolLocks: z2.record(z2.string(), z2.string()).default({}),
2571
+ profiles: z2.array(profileSchema2).default([]),
2572
+ tools: z2.array(toolDefSchema).default([])
2544
2573
  });
2545
2574
  var BUILTIN_TOOLS = [
2546
2575
  { id: "claude", label: "Claude Code", envVar: "CLAUDE_CONFIG_DIR", defaultDir: join2(homedir2(), ".claude"), bin: "claude" },
@@ -3345,11 +3374,11 @@ async function withIngestJournalLock(directory, action) {
3345
3374
  }
3346
3375
 
3347
3376
  // src/lib/ingest-journal-operation.ts
3348
- import { z as z2 } from "zod";
3349
- var ingestJournalOperationSchema = z2.discriminatedUnion("action", [
3350
- z2.object({ action: z2.literal("status") }).strict(),
3351
- z2.object({ action: z2.literal("reconcile") }).strict(),
3352
- z2.object({ action: z2.literal("maintain"), confirm: z2.literal(true), limit: z2.number().int().min(1).max(32).default(32) }).strict()
3377
+ import { z as z3 } from "zod";
3378
+ var ingestJournalOperationSchema = z3.discriminatedUnion("action", [
3379
+ z3.object({ action: z3.literal("status") }).strict(),
3380
+ z3.object({ action: z3.literal("reconcile") }).strict(),
3381
+ z3.object({ action: z3.literal("maintain"), confirm: z3.literal(true), limit: z3.number().int().min(1).max(32).default(32) }).strict()
3353
3382
  ]);
3354
3383
 
3355
3384
  // src/lib/cloud-ingest.ts
@@ -3458,7 +3487,7 @@ async function pushIngestRows(cloud, scratch) {
3458
3487
  // package.json
3459
3488
  var package_default = {
3460
3489
  name: "@hasna/economy",
3461
- version: "0.5.2",
3490
+ version: "0.5.4",
3462
3491
  description: "AI coding cost tracker \u2014 CLI + MCP server + REST API for Claude Code, Codex, OpenCode, Cursor, Pi, and Hermes, with legacy Gemini CLI session and Gemini API billing ingestion",
3463
3492
  repository: {
3464
3493
  type: "git",