@hasna/economy 0.3.9 → 0.3.12

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 (142) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/cli/brains.d.ts +3 -0
  3. package/dist/cli/brains.d.ts.map +1 -0
  4. package/dist/cli/commands/brief.d.ts +11 -0
  5. package/dist/cli/commands/brief.d.ts.map +1 -0
  6. package/dist/cli/commands/completion.d.ts +2 -0
  7. package/dist/cli/commands/completion.d.ts.map +1 -0
  8. package/dist/cli/commands/extras.d.ts +4 -0
  9. package/dist/cli/commands/extras.d.ts.map +1 -0
  10. package/dist/cli/commands/menubar.d.ts +7 -0
  11. package/dist/cli/commands/menubar.d.ts.map +1 -0
  12. package/dist/cli/commands/notification.d.ts +8 -0
  13. package/dist/cli/commands/notification.d.ts.map +1 -0
  14. package/dist/cli/commands/todos.d.ts +29 -0
  15. package/dist/cli/commands/todos.d.ts.map +1 -0
  16. package/dist/cli/commands/tui.d.ts +26 -0
  17. package/dist/cli/commands/tui.d.ts.map +1 -0
  18. package/dist/cli/commands/watch.d.ts +10 -0
  19. package/dist/cli/commands/watch.d.ts.map +1 -0
  20. package/dist/cli/index.d.ts +3 -0
  21. package/dist/cli/index.d.ts.map +1 -0
  22. package/dist/cli/index.js +12204 -0
  23. package/dist/db/cloud.d.ts +45 -0
  24. package/dist/db/cloud.d.ts.map +1 -0
  25. package/dist/db/database.d.ts +157 -0
  26. package/dist/db/database.d.ts.map +1 -0
  27. package/dist/db/dialect.d.ts +13 -0
  28. package/dist/db/dialect.d.ts.map +1 -0
  29. package/dist/db/pg-migrate.d.ts +30 -0
  30. package/dist/db/pg-migrate.d.ts.map +1 -0
  31. package/dist/db/pg-migrations.d.ts +7 -0
  32. package/dist/db/pg-migrations.d.ts.map +1 -0
  33. package/dist/db/pg-sync-worker.d.ts +2 -0
  34. package/dist/db/pg-sync-worker.d.ts.map +1 -0
  35. package/dist/db/sqlite-adapter.d.ts +36 -0
  36. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  37. package/dist/db/sync-pg.d.ts +43 -0
  38. package/dist/db/sync-pg.d.ts.map +1 -0
  39. package/dist/index.d.ts +3 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +3406 -0
  42. package/dist/ingest/billing.d.ts +27 -0
  43. package/dist/ingest/billing.d.ts.map +1 -0
  44. package/dist/ingest/claude-quota.d.ts +5 -0
  45. package/dist/ingest/claude-quota.d.ts.map +1 -0
  46. package/dist/ingest/claude.d.ts +18 -0
  47. package/dist/ingest/claude.d.ts.map +1 -0
  48. package/dist/ingest/codex-quota.d.ts +5 -0
  49. package/dist/ingest/codex-quota.d.ts.map +1 -0
  50. package/dist/ingest/codex.d.ts +8 -0
  51. package/dist/ingest/codex.d.ts.map +1 -0
  52. package/dist/ingest/cursor.d.ts +6 -0
  53. package/dist/ingest/cursor.d.ts.map +1 -0
  54. package/dist/ingest/gemini.d.ts +6 -0
  55. package/dist/ingest/gemini.d.ts.map +1 -0
  56. package/dist/ingest/hermes.d.ts +6 -0
  57. package/dist/ingest/hermes.d.ts.map +1 -0
  58. package/dist/ingest/loops.d.ts +6 -0
  59. package/dist/ingest/loops.d.ts.map +1 -0
  60. package/dist/ingest/opencode.d.ts +7 -0
  61. package/dist/ingest/opencode.d.ts.map +1 -0
  62. package/dist/ingest/otel.d.ts +33 -0
  63. package/dist/ingest/otel.d.ts.map +1 -0
  64. package/dist/ingest/pi.d.ts +7 -0
  65. package/dist/ingest/pi.d.ts.map +1 -0
  66. package/dist/ingest/plugin.d.ts +17 -0
  67. package/dist/ingest/plugin.d.ts.map +1 -0
  68. package/dist/lib/accounts.d.ts +11 -0
  69. package/dist/lib/accounts.d.ts.map +1 -0
  70. package/dist/lib/agents.d.ts +11 -0
  71. package/dist/lib/agents.d.ts.map +1 -0
  72. package/dist/lib/analytics.d.ts +68 -0
  73. package/dist/lib/analytics.d.ts.map +1 -0
  74. package/dist/lib/billing-diff.d.ts +61 -0
  75. package/dist/lib/billing-diff.d.ts.map +1 -0
  76. package/dist/lib/brief.d.ts +72 -0
  77. package/dist/lib/brief.d.ts.map +1 -0
  78. package/dist/lib/cloud-ingest.d.ts +57 -0
  79. package/dist/lib/cloud-ingest.d.ts.map +1 -0
  80. package/dist/lib/cloud-storage.d.ts +48 -0
  81. package/dist/lib/cloud-storage.d.ts.map +1 -0
  82. package/dist/lib/config.d.ts +13 -0
  83. package/dist/lib/config.d.ts.map +1 -0
  84. package/dist/lib/contracts-client/index.d.ts +3 -0
  85. package/dist/lib/contracts-client/index.d.ts.map +1 -0
  86. package/dist/lib/contracts-client/storage.d.ts +3 -0
  87. package/dist/lib/contracts-client/storage.d.ts.map +1 -0
  88. package/dist/lib/contracts-client/transport.d.ts +2 -0
  89. package/dist/lib/contracts-client/transport.d.ts.map +1 -0
  90. package/dist/lib/gatherer.d.ts +21 -0
  91. package/dist/lib/gatherer.d.ts.map +1 -0
  92. package/dist/lib/model-config.d.ts +8 -0
  93. package/dist/lib/model-config.d.ts.map +1 -0
  94. package/dist/lib/open-projects.d.ts +27 -0
  95. package/dist/lib/open-projects.d.ts.map +1 -0
  96. package/dist/lib/package-metadata.d.ts +8 -0
  97. package/dist/lib/package-metadata.d.ts.map +1 -0
  98. package/dist/lib/paths.d.ts +20 -0
  99. package/dist/lib/paths.d.ts.map +1 -0
  100. package/dist/lib/periods.d.ts +6 -0
  101. package/dist/lib/periods.d.ts.map +1 -0
  102. package/dist/lib/pricing.d.ts +13 -0
  103. package/dist/lib/pricing.d.ts.map +1 -0
  104. package/dist/lib/savings.d.ts +17 -0
  105. package/dist/lib/savings.d.ts.map +1 -0
  106. package/dist/lib/serve-auth.d.ts +4 -0
  107. package/dist/lib/serve-auth.d.ts.map +1 -0
  108. package/dist/lib/spikes.d.ts +18 -0
  109. package/dist/lib/spikes.d.ts.map +1 -0
  110. package/dist/lib/store/index.d.ts +303 -0
  111. package/dist/lib/store/index.d.ts.map +1 -0
  112. package/dist/lib/sync-all.d.ts +28 -0
  113. package/dist/lib/sync-all.d.ts.map +1 -0
  114. package/dist/lib/sync-maintenance.d.ts +15 -0
  115. package/dist/lib/sync-maintenance.d.ts.map +1 -0
  116. package/dist/lib/watch-paths.d.ts +3 -0
  117. package/dist/lib/watch-paths.d.ts.map +1 -0
  118. package/dist/lib/webhooks.d.ts +3 -0
  119. package/dist/lib/webhooks.d.ts.map +1 -0
  120. package/dist/mcp/http.d.ts +14 -0
  121. package/dist/mcp/http.d.ts.map +1 -0
  122. package/dist/mcp/index.d.ts +3 -0
  123. package/dist/mcp/index.d.ts.map +1 -0
  124. package/dist/mcp/index.js +5997 -0
  125. package/dist/mcp/server.d.ts +4 -0
  126. package/dist/mcp/server.d.ts.map +1 -0
  127. package/dist/openapi.d.ts +3 -0
  128. package/dist/openapi.d.ts.map +1 -0
  129. package/dist/otel/index.d.ts +3 -0
  130. package/dist/otel/index.d.ts.map +1 -0
  131. package/dist/otel/index.js +1464 -0
  132. package/dist/server/index.d.ts +3 -0
  133. package/dist/server/index.d.ts.map +1 -0
  134. package/dist/server/index.js +8360 -0
  135. package/dist/server/pg-sync-worker.js +31 -0
  136. package/dist/server/serve.d.ts +42 -0
  137. package/dist/server/serve.d.ts.map +1 -0
  138. package/dist/types/index.d.ts +240 -0
  139. package/dist/types/index.d.ts.map +1 -0
  140. package/docs/cli.md +3 -3
  141. package/docs/mcp.md +1 -1
  142. package/package.json +7 -5
@@ -0,0 +1,27 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export declare function syncAnthropicBilling(db: Database, opts?: {
3
+ days?: number;
4
+ fromDate?: string;
5
+ toDate?: string;
6
+ }): Promise<{
7
+ days: number;
8
+ totalUsd: number;
9
+ }>;
10
+ export declare function syncOpenAIBilling(db: Database, opts?: {
11
+ days?: number;
12
+ fromDate?: string;
13
+ toDate?: string;
14
+ }): Promise<{
15
+ days: number;
16
+ totalUsd: number;
17
+ }>;
18
+ export declare function syncGeminiBilling(db: Database, opts?: {
19
+ days?: number;
20
+ fromDate?: string;
21
+ toDate?: string;
22
+ }): Promise<{
23
+ days: number;
24
+ totalUsd: number;
25
+ skipped?: string;
26
+ }>;
27
+ //# sourceMappingURL=billing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/ingest/billing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AA+IxE,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,QAAQ,EACZ,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/D,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAuD7C;AAeD,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,QAAQ,EACZ,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/D,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAqD7C;AAED,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,QAAQ,EACZ,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/D,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAwC/D"}
@@ -0,0 +1,5 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export declare function ingestClaudeQuota(db: Database, verbose?: boolean): Promise<{
3
+ snapshots: number;
4
+ }>;
5
+ //# sourceMappingURL=claude-quota.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-quota.d.ts","sourceRoot":"","sources":["../../src/ingest/claude-quota.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAqExE,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CA6FrG"}
@@ -0,0 +1,18 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ import type { Agent } from '../types/index.js';
3
+ export declare function ingestClaude(db: Database, verbose?: boolean, projectsDir?: string): Promise<{
4
+ files: number;
5
+ requests: number;
6
+ sessions: number;
7
+ }>;
8
+ export declare function ingestTakumi(db: Database, verbose?: boolean, projectsDir?: string): Promise<{
9
+ files: number;
10
+ requests: number;
11
+ sessions: number;
12
+ }>;
13
+ export declare function ingestJsonlProjects(db: Database, projectsDir: string, agentName: Agent, verbose?: boolean): Promise<{
14
+ files: number;
15
+ requests: number;
16
+ sessions: number;
17
+ }>;
18
+ //# sourceMappingURL=claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/ingest/claude.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAYxE,OAAO,KAAK,EAAkB,KAAK,EAAE,MAAM,mBAAmB,CAAA;AA+D9D,wBAAsB,YAAY,CAChC,EAAE,EAAE,QAAQ,EACZ,OAAO,UAAQ,EACf,WAAW,SAAsB,GAChC,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhE;AAED,wBAAsB,YAAY,CAChC,EAAE,EAAE,QAAQ,EACZ,OAAO,UAAQ,EACf,WAAW,SAAsB,GAChC,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhE;AAED,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,KAAK,EAChB,OAAO,UAAQ,GACd,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAyIhE"}
@@ -0,0 +1,5 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export declare function ingestCodexQuota(db: Database, verbose?: boolean): Promise<{
3
+ snapshots: number;
4
+ }>;
5
+ //# sourceMappingURL=codex-quota.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-quota.d.ts","sourceRoot":"","sources":["../../src/ingest/codex-quota.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAmFxE,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAoFpG"}
@@ -0,0 +1,8 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ declare function readCodexModel(configPath?: string): string;
3
+ export declare function ingestCodex(db: Database, verbose?: boolean): Promise<{
4
+ sessions: number;
5
+ requests: number;
6
+ }>;
7
+ export { readCodexModel };
8
+ //# sourceMappingURL=codex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/ingest/codex.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AA4FxE,iBAAS,cAAc,CAAC,UAAU,SAAoB,GAAG,MAAM,CAS9D;AAwGD,wBAAsB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA+FhH;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export declare function ingestCursor(db: Database, verbose?: boolean): Promise<{
3
+ requests: number;
4
+ snapshots: number;
5
+ }>;
6
+ //# sourceMappingURL=cursor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/ingest/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAsCxE,wBAAsB,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAqGlH"}
@@ -0,0 +1,6 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export declare function ingestGemini(db: Database, verbose?: boolean): Promise<{
3
+ sessions: number;
4
+ requests: number;
5
+ }>;
6
+ //# sourceMappingURL=gemini.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../src/ingest/gemini.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAoGxE,wBAAsB,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgInH"}
@@ -0,0 +1,6 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export declare function ingestHermes(db: Database, verbose?: boolean): Promise<{
3
+ sessions: number;
4
+ requests: number;
5
+ }>;
6
+ //# sourceMappingURL=hermes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hermes.d.ts","sourceRoot":"","sources":["../../src/ingest/hermes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAiCxE,wBAAsB,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA2EjH"}
@@ -0,0 +1,6 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export declare function ingestLoops(db: Database, verbose?: boolean): Promise<{
3
+ sessions: number;
4
+ requests: number;
5
+ }>;
6
+ //# sourceMappingURL=loops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loops.d.ts","sourceRoot":"","sources":["../../src/ingest/loops.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AA4IxE,wBAAsB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA+FhH"}
@@ -0,0 +1,7 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export declare function ingestOpenCode(db: Database, verbose?: boolean): Promise<{
3
+ files: number;
4
+ requests: number;
5
+ sessions: number;
6
+ }>;
7
+ //# sourceMappingURL=opencode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/ingest/opencode.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AA8CxE,wBAAsB,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAmFlI"}
@@ -0,0 +1,33 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ import type { CostBasis, CostCenterKind, EconomyAgent } from '../types/index.js';
3
+ export interface OtelIngestRow {
4
+ agent: EconomyAgent;
5
+ session_id: string;
6
+ model: string;
7
+ cost_usd: number;
8
+ input_tokens: number;
9
+ output_tokens: number;
10
+ timestamp: string;
11
+ source_request_id: string;
12
+ cost_basis?: CostBasis;
13
+ cost_center?: string;
14
+ cost_center_kind?: CostCenterKind;
15
+ cost_center_id?: string;
16
+ attribution_tag?: string;
17
+ project_path?: string;
18
+ project_name?: string;
19
+ repo?: string;
20
+ account_key?: string;
21
+ account_tool?: string;
22
+ account_name?: string;
23
+ account_email?: string;
24
+ account_source?: string;
25
+ }
26
+ /** Parse OTLP/HTTP JSON metrics into normalized ingest rows. */
27
+ export declare function parseOtlpMetrics(body: unknown): OtelIngestRow[];
28
+ export declare function parseSimpleIngest(body: unknown): OtelIngestRow | null;
29
+ export declare function ingestOtelRows(db: Database, rows: OtelIngestRow[]): Promise<{
30
+ requests: number;
31
+ sessions: number;
32
+ }>;
33
+ //# sourceMappingURL=otel.d.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EAAE,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA4DzH"}
@@ -0,0 +1,7 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export declare function ingestPi(db: Database, verbose?: boolean): Promise<{
3
+ files: number;
4
+ requests: number;
5
+ sessions: number;
6
+ }>;
7
+ //# sourceMappingURL=pi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../src/ingest/pi.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAwCxE,wBAAsB,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA8E5H"}
@@ -0,0 +1,17 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ import type { Agent } from '../lib/agents.js';
3
+ export interface IngestResult {
4
+ requests: number;
5
+ sessions: number;
6
+ skipped?: number;
7
+ }
8
+ export interface IngestPlugin {
9
+ agent: Agent;
10
+ /** Human-readable source label for doctor/status. */
11
+ source: string;
12
+ ingest(db: Database, verbose?: boolean): Promise<IngestResult>;
13
+ }
14
+ export declare function registerIngestPlugin(plugin: IngestPlugin): void;
15
+ export declare function getIngestPlugin(agent: Agent): IngestPlugin | undefined;
16
+ export declare function listIngestPlugins(): IngestPlugin[];
17
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/ingest/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,KAAK,CAAA;IACZ,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;CAC/D;AAID,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAE/D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,GAAG,SAAS,CAEtE;AAED,wBAAgB,iBAAiB,IAAI,YAAY,EAAE,CAElD"}
@@ -0,0 +1,11 @@
1
+ import type { Agent } from './agents.js';
2
+ export interface AccountAttribution {
3
+ account_key: string;
4
+ account_tool: string;
5
+ account_name: string;
6
+ account_email?: string;
7
+ account_source: 'override' | 'env' | 'applied' | 'current';
8
+ }
9
+ export declare function resolveAccountForAgent(agent: Agent, env?: NodeJS.ProcessEnv): Promise<AccountAttribution | null>;
10
+ export declare function withAccount<T extends object>(record: T, account: AccountAttribution | null): T & Partial<AccountAttribution>;
11
+ //# sourceMappingURL=accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/lib/accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,CAAA;CAC3D;AAqFD,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAwBpC;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAC1C,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,kBAAkB,GAAG,IAAI,GACjC,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAUjC"}
@@ -0,0 +1,11 @@
1
+ export declare const AGENTS: readonly ["claude", "takumi", "codex", "gemini", "opencode", "cursor", "pi", "hermes"];
2
+ export type Agent = (typeof AGENTS)[number];
3
+ export declare const INGEST_AGENTS: readonly ["claude", "takumi", "codex", "gemini", "opencode", "cursor", "pi", "hermes"];
4
+ export declare const LEGACY_AGENTS: readonly ["claude", "takumi", "codex", "gemini"];
5
+ export declare const COST_BASIS: readonly ["metered_api", "subscription_included", "estimated", "unknown"];
6
+ export type CostBasis = (typeof COST_BASIS)[number];
7
+ export declare function isAgent(value: string): value is Agent;
8
+ export declare function parseAgent(value: string | undefined, option: string): Agent | undefined;
9
+ export declare function requireAgent(value: string | undefined, option: string, fallback?: Agent): Agent;
10
+ export declare function agentColor(agent: string): 'blue' | 'yellow' | 'green' | 'magenta' | 'cyan' | 'white';
11
+ //# sourceMappingURL=agents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/lib/agents.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,wFAST,CAAA;AAEV,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3C,eAAO,MAAM,aAAa,wFAAS,CAAA;AAEnC,eAAO,MAAM,aAAa,kDAA8E,CAAA;AAExG,eAAO,MAAM,UAAU,2EAKb,CAAA;AAEV,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnD,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,KAAK,CAErD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAIvF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,CAI/F;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAQpG"}
@@ -0,0 +1,68 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ export interface ProjectDetailModel {
3
+ model: string;
4
+ requests: number;
5
+ cost_usd: number;
6
+ }
7
+ export interface ProjectDetailSession {
8
+ id: string;
9
+ total_cost_usd: number;
10
+ started_at: string;
11
+ }
12
+ export interface ProjectDetail {
13
+ project_name: string;
14
+ project_path: string;
15
+ total_cost_usd: number;
16
+ total_tokens: number;
17
+ sessions: number;
18
+ daily: Array<{
19
+ date: string;
20
+ cost_usd: number;
21
+ }>;
22
+ models: ProjectDetailModel[];
23
+ top_sessions: ProjectDetailSession[];
24
+ }
25
+ /** Detailed breakdown for a single project matched by name or path substring. */
26
+ export declare function queryProjectDetail(db: Database, nameOrPath: string): ProjectDetail | null;
27
+ export type ExportType = 'sessions' | 'requests';
28
+ /** Raw rows for a CSV export. CSV formatting stays in the caller. */
29
+ export declare function queryExportRows(db: Database, type: ExportType, period: string): Array<Record<string, unknown>>;
30
+ export interface RangeStats {
31
+ cost: number;
32
+ requests: number;
33
+ tokens: number;
34
+ sessions: number;
35
+ }
36
+ /** Cost/request/token/session totals for an inclusive [from,to] date range. */
37
+ export declare function queryRangeStats(db: Database, from: string, to: string): RangeStats;
38
+ export interface ForecastData {
39
+ day_of_month: number;
40
+ days_in_month: number;
41
+ spent_so_far_usd: number;
42
+ daily_avg_usd: number;
43
+ projected_usd: number;
44
+ last7_daily_avg_usd: number;
45
+ last7_projected_usd: number;
46
+ cheapest_day: {
47
+ date: string;
48
+ cost_usd: number;
49
+ } | null;
50
+ most_expensive_day: {
51
+ date: string;
52
+ cost_usd: number;
53
+ } | null;
54
+ }
55
+ /** End-of-month projection based on current burn rate. */
56
+ export declare function queryForecast(db: Database, now?: Date): ForecastData;
57
+ export interface ModelEfficiency {
58
+ model: string;
59
+ input: number;
60
+ output: number;
61
+ cache_read: number;
62
+ cache_write: number;
63
+ requests: number;
64
+ cost: number;
65
+ }
66
+ /** Per-model token efficiency (output/input ratio, cache hit %, cost/1k out). */
67
+ export declare function queryModelEfficiency(db: Database): ModelEfficiency[];
68
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/lib/analytics.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAIxE,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,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DAA0D;AAC1D,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,GAAE,IAAiB,GAAG,YAAY,CAkChF;AAID,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,GAAG,eAAe,EAAE,CAWpE"}
@@ -0,0 +1,61 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ import type { Period } from '../types/index.js';
3
+ export interface BillingDiffRow {
4
+ agent: string;
5
+ estimated_usd: number;
6
+ actual_usd: number;
7
+ delta_usd: number;
8
+ delta_pct: number;
9
+ }
10
+ /**
11
+ * Why a drift percentage could not be computed. `null` means it could.
12
+ *
13
+ * - `no_billing_records` — no provider billing rows exist for the period at
14
+ * all. Nothing was imported; there is no "actual" to compare against.
15
+ * - `zero_actual_billing` — rows exist but total $0.00, so the denominator is
16
+ * still absent even though the import ran.
17
+ */
18
+ export type BillingDiffIncomparableReason = 'no_billing_records' | 'zero_actual_billing';
19
+ /**
20
+ * Estimated-vs-actual drift as a percentage, or `null` when there is no actual
21
+ * to divide by.
22
+ *
23
+ * Returning `null` rather than `0` is the point. Three call sites independently
24
+ * wrote `actual > 0 ? (delta / actual) * 100 : 0`, and every one of them then
25
+ * rendered the fallback as a measured "0.0%" — reporting perfect agreement for
26
+ * the case where nothing was there to agree with.
27
+ */
28
+ export declare function billingDeltaPct(estimatedUsd: number, actualUsd: number): number | null;
29
+ export interface BillingDiffSummary {
30
+ period: Period;
31
+ estimated_usd: number;
32
+ actual_usd: number;
33
+ delta_usd: number;
34
+ delta_pct: number;
35
+ threshold_pct: number;
36
+ is_alert: boolean;
37
+ /**
38
+ * Whether `delta_pct` is a measurement at all. False means the two sides
39
+ * could not be compared, and `delta_pct` carries 0 only because the type is
40
+ * a number — read this before reporting the percentage as agreement.
41
+ */
42
+ comparable: boolean;
43
+ incomparable_reason: BillingDiffIncomparableReason | null;
44
+ by_agent: BillingDiffRow[];
45
+ by_provider: Record<string, number>;
46
+ }
47
+ export declare function queryBillingDiff(db: Database, period: Period, thresholdPct?: number): BillingDiffSummary;
48
+ /**
49
+ * The health verdict `economy doctor` reports for billing drift.
50
+ *
51
+ * Kept beside the diff rather than in the CLI because the interesting case is
52
+ * a semantic one: an unmeasurable drift must not render as a measured 0.0%.
53
+ * A check that cannot distinguish "the sides agree" from "there is nothing to
54
+ * compare" cannot fail, and this one is consulted to decide whether the rest
55
+ * of the tool's numbers are trustworthy.
56
+ */
57
+ export declare function billingDriftCheck(diff: BillingDiffSummary): {
58
+ ok: boolean;
59
+ msg: string;
60
+ };
61
+ //# sourceMappingURL=billing-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-diff.d.ts","sourceRoot":"","sources":["../../src/lib/billing-diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAExE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GAAG,oBAAoB,GAAG,qBAAqB,CAAA;AAExF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGtF;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAA;IACnB,mBAAmB,EAAE,6BAA6B,GAAG,IAAI,CAAA;IACzD,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACpC;AAED,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,YAAY,SAAK,GAChB,kBAAkB,CAsDpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAYxF"}
@@ -0,0 +1,72 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ type BriefPeriod = 'today' | 'week';
3
+ export interface BriefTotals {
4
+ sessions: number;
5
+ requests: number;
6
+ input_tokens: number;
7
+ output_tokens: number;
8
+ cache_read_tokens: number;
9
+ cache_create_tokens: number;
10
+ cache_create_5m_tokens: number;
11
+ cache_create_1h_tokens: number;
12
+ total_tokens: number;
13
+ cost_usd: number;
14
+ last_active: string | null;
15
+ }
16
+ export interface BriefPeriodSummary extends BriefTotals {
17
+ label: string;
18
+ period: BriefPeriod | 'since';
19
+ since?: string;
20
+ }
21
+ export interface BriefMachineRow extends BriefTotals {
22
+ machine_id: string;
23
+ last_data_at: string | null;
24
+ last_data_age: string;
25
+ }
26
+ export interface BriefAgentRow extends BriefTotals {
27
+ agent: string;
28
+ }
29
+ export interface BriefAccountRow extends BriefTotals {
30
+ account_key: string;
31
+ account_tool: string;
32
+ account_name: string;
33
+ account_email: string | null;
34
+ account_source: string;
35
+ }
36
+ export interface BriefFreshnessMachine {
37
+ machine_id: string;
38
+ max_request_at: string | null;
39
+ request_age: string;
40
+ last_merge_sync_at: string | null;
41
+ merge_sync_age: string;
42
+ }
43
+ export interface EconomyBrief {
44
+ generated_at: string;
45
+ machine: string;
46
+ since: {
47
+ input: string;
48
+ timestamp: string;
49
+ label: string;
50
+ };
51
+ summaries: BriefPeriodSummary[];
52
+ machines: BriefMachineRow[];
53
+ agents: BriefAgentRow[];
54
+ accounts: BriefAccountRow[];
55
+ freshness: {
56
+ machines: BriefFreshnessMachine[];
57
+ max_request_line: string;
58
+ merge_sync_line: string;
59
+ };
60
+ }
61
+ export interface BriefOptions {
62
+ since?: string;
63
+ machine?: string;
64
+ now?: Date;
65
+ currentMachineId?: string;
66
+ localSyncAt?: Date;
67
+ }
68
+ /** Human-readable age of a timestamp relative to now (never/<1m/Nm/Nh/Nd). */
69
+ export declare function formatAge(timestamp: string | null | undefined, now: Date): string;
70
+ export declare function buildBrief(db: Database, opts?: BriefOptions): EconomyBrief;
71
+ export {};
72
+ //# sourceMappingURL=brief.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brief.d.ts","sourceRoot":"","sources":["../../src/lib/brief.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAUxE,KAAK,WAAW,GAAG,OAAO,GAAG,MAAM,CAAA;AAEnC,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB,EAAE,MAAM,CAAA;IACzB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,sBAAsB,EAAE,MAAM,CAAA;IAC9B,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AAA;IACvB,QAAQ,EAAE,eAAe,EAAE,CAAA;IAC3B,SAAS,EAAE;QACT,QAAQ,EAAE,qBAAqB,EAAE,CAAA;QACjC,gBAAgB,EAAE,MAAM,CAAA;QACxB,eAAe,EAAE,MAAM,CAAA;KACxB,CAAA;CACF;AAcD,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,WAAW,CAAC,EAAE,IAAI,CAAA;CACnB;AAyBD,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,EAAE,IAAI,GAAG,MAAM,CAWjF;AAsmBD,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAE,YAAiB,GAAG,YAAY,CAmD9E"}
@@ -0,0 +1,57 @@
1
+ import type { SyncAllResult } from './sync-all.js';
2
+ import type { ActiveEconomyCloudStorage } from './cloud-storage.js';
3
+ import type { SyncOptions } from '../types/index.js';
4
+ /** Machine-local mtime cache path (override for tests via HASNA_ECONOMY_INGEST_CACHE). */
5
+ export declare function getIngestCachePath(): string;
6
+ export interface CloudSyncOptions extends SyncOptions {
7
+ /** Claude/Takumi JSONL root override (tests). */
8
+ projectsDir?: string;
9
+ /** Ingest-state cache path override (tests). Defaults to getIngestCachePath(). */
10
+ cachePath?: string;
11
+ /** Re-process every file (ignore the mtime cache). */
12
+ force?: boolean;
13
+ /** Tag this run's rows with the current machine id. */
14
+ backfillMachine?: boolean;
15
+ /** Recalculate zero-cost requests from pricing before pushing. */
16
+ recalculate?: boolean;
17
+ }
18
+ export interface CloudSyncResult extends SyncAllResult {
19
+ /** True when at least one row was pushed to the shared API in this run. */
20
+ posted: boolean;
21
+ /** Per-table row counts accepted by /v1/ingest (absent when nothing posted). */
22
+ ingested?: Record<string, number>;
23
+ /** Total rows accepted by /v1/ingest (absent when nothing posted). */
24
+ total?: number;
25
+ }
26
+ /**
27
+ * Cloud-client equivalent of `economy sync`: read this machine's on-box
28
+ * provider files, ingest them through the existing readers, and push the
29
+ * produced rows to the shared API. Returns the same per-source result shape as
30
+ * the local syncAll, plus what the server accepted.
31
+ */
32
+ export declare function syncAllToCloud(cloud: ActiveEconomyCloudStorage, opts?: CloudSyncOptions): Promise<CloudSyncResult>;
33
+ export interface CloudBillingSyncOptions {
34
+ days?: number;
35
+ anthropic?: boolean;
36
+ openai?: boolean;
37
+ gemini?: boolean;
38
+ }
39
+ export interface CloudBillingSyncResult {
40
+ /** Per-provider outcome; a provider failure does not stop the others. */
41
+ providers: Record<string, {
42
+ ok: boolean;
43
+ days?: number;
44
+ totalUsd?: number;
45
+ error?: string;
46
+ }>;
47
+ totalUsd: number;
48
+ posted: boolean;
49
+ ingested?: Record<string, number>;
50
+ total?: number;
51
+ }
52
+ /**
53
+ * Cloud-client equivalent of `economy billing sync`: fetch provider billing
54
+ * from the provider APIs and push the billing_daily rows to the shared API.
55
+ */
56
+ export declare function billingSyncToCloud(cloud: ActiveEconomyCloudStorage, opts?: CloudBillingSyncOptions): Promise<CloudBillingSyncResult>;
57
+ //# sourceMappingURL=cloud-ingest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-ingest.d.ts","sourceRoot":"","sources":["../../src/lib/cloud-ingest.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAKpD,0FAA0F;AAC1F,wBAAgB,kBAAkB,IAAI,MAAM,CAG3C;AA6CD,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,iDAAiD;IACjD,WAAW,CAAC,EAAE,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4B,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA+B9I"}
@@ -0,0 +1,48 @@
1
+ import { resolveStorageClient, type HasnaStorageClient } from "./contracts-client/storage.js";
2
+ /** Transport overrides (test injection: fetchImpl, headers, timeout, retry). */
3
+ type StorageClientOverrides = Parameters<typeof resolveStorageClient>[2];
4
+ /** The economy app slug used for the HASNA_<APP>_* env lookups. */
5
+ export declare const ECONOMY_APP = "economy";
6
+ export type EconomyCloudStorage = {
7
+ /** True when reads/writes must go to the cloud HTTP API. */
8
+ readonly active: true;
9
+ /** The ready HTTP storage client. */
10
+ readonly client: HasnaStorageClient;
11
+ } | {
12
+ readonly active: false;
13
+ readonly client: null;
14
+ };
15
+ /**
16
+ * Resolve the economy client storage transport for the current environment.
17
+ *
18
+ * Returns `{ active: true, client }` only when the contracts seam resolves to
19
+ * the http transport (HASNA_ECONOMY_API_URL + HASNA_ECONOMY_API_KEY set).
20
+ * Otherwise `{ active: false }` (local store). Throws when an API URL is set
21
+ * without a key (the seam reports the resolution as misconfigured).
22
+ */
23
+ export declare function resolveEconomyCloudStorage(env?: NodeJS.ProcessEnv, overrides?: StorageClientOverrides): EconomyCloudStorage;
24
+ /** Memoized {@link resolveEconomyCloudStorage} for the process lifetime. */
25
+ export declare function economyCloudStorage(env?: NodeJS.ProcessEnv): EconomyCloudStorage;
26
+ /** Test-only: drop the memoized resolution so a new env can be resolved. */
27
+ export declare function resetEconomyCloudStorageCache(): void;
28
+ /** Active cloud storage (narrowed so `client` is non-null). */
29
+ export type ActiveEconomyCloudStorage = Extract<EconomyCloudStorage, {
30
+ active: true;
31
+ }>;
32
+ /** Query params accepted by the read helpers below. */
33
+ export type CloudQuery = Record<string, string | number | boolean | null | undefined>;
34
+ /**
35
+ * Read a collection resource from the cloud API and return the extracted array
36
+ * (the serve envelope's `data`/`items`). Used by the read commands (sessions,
37
+ * top, breakdown, accounts) so they render cloud data — never the local store —
38
+ * when the client is on the http transport.
39
+ */
40
+ export declare function cloudListItems<T = unknown>(storage: ActiveEconomyCloudStorage, resource: string, query?: CloudQuery): Promise<T[]>;
41
+ /**
42
+ * Read a single (non-collection) resource and return the unwrapped `data`
43
+ * payload (e.g. `/usage` -> `{ snapshots, summary }`). Falls back to the raw
44
+ * body if the server does not use the `{ data }` envelope.
45
+ */
46
+ export declare function cloudObject<T = unknown>(storage: ActiveEconomyCloudStorage, path: string, query?: CloudQuery): Promise<T>;
47
+ export {};
48
+ //# sourceMappingURL=cloud-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-storage.d.ts","sourceRoot":"","sources":["../../src/lib/cloud-storage.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAE9F,gFAAgF;AAChF,KAAK,sBAAsB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzE,mEAAmE;AACnE,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,MAAM,MAAM,mBAAmB,GAC3B;IACE,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;CACrC,GACD;IACE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;CACvB,CAAC;AAIN;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,SAAS,CAAC,EAAE,sBAAsB,GACjC,mBAAmB,CAKrB;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,mBAAmB,CAG7F;AAED,4EAA4E;AAC5E,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD;AAED,+DAA+D;AAC/D,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AAEvF,uDAAuD;AACvD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAYtF;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,CAAC,GAAG,OAAO,EAC9C,OAAO,EAAE,yBAAyB,EAClC,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,CAAC,EAAE,CAAC,CAId;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,OAAO,EAC3C,OAAO,EAAE,yBAAyB,EAClC,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,CAAC,CAAC,CAOZ"}
@@ -0,0 +1,13 @@
1
+ export interface EconomyConfig {
2
+ port: number;
3
+ 'default-period': string;
4
+ 'auto-sync': boolean;
5
+ 'sync-interval': number;
6
+ 'alert-thresholds': number[];
7
+ 'webhook-url': string | null;
8
+ }
9
+ export declare function loadConfig(): EconomyConfig;
10
+ export declare function saveConfig(config: EconomyConfig): void;
11
+ export declare function getConfigValue(key: string): unknown;
12
+ export declare function setConfigValue(key: string, value: string): void;
13
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,OAAO,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAWD,wBAAgB,UAAU,IAAI,aAAa,CAS1C;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAKtD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAW/D"}
@@ -0,0 +1,3 @@
1
+ export * from "./transport.js";
2
+ export * from "./storage.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/contracts-client/index.ts"],"names":[],"mappings":"AAEA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { resolveStorageClient } from "@hasna/contracts/client/storage";
2
+ export type { HasnaStorageClient } from "@hasna/contracts/client/storage";
3
+ //# sourceMappingURL=storage.d.ts.map