@hasna/economy 0.3.12 → 0.3.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,82 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.23
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [50473b8]
8
+ - @hasna/projects@0.1.145
9
+
10
+ ## 0.3.22
11
+
12
+ ### Patch Changes
13
+
14
+ - @hasna/projects@0.1.144
15
+
16
+ ## 0.3.21
17
+
18
+ ### Patch Changes
19
+
20
+ - @hasna/projects@0.1.143
21
+
22
+ ## 0.3.20
23
+
24
+ ### Patch Changes
25
+
26
+ - @hasna/projects@0.1.142
27
+
28
+ ## 0.3.19
29
+
30
+ ### Patch Changes
31
+
32
+ - @hasna/projects@0.1.141
33
+
34
+ ## 0.3.18
35
+
36
+ ### Patch Changes
37
+
38
+ - @hasna/projects@0.1.140
39
+
40
+ ## 0.3.17
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [247187d]
45
+ - @hasna/projects@0.1.139
46
+
47
+ ## 0.3.16
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies [554a5b9]
52
+ - @hasna/contracts@0.13.4
53
+ - @hasna/projects@0.1.138
54
+
55
+ ## 0.3.15
56
+
57
+ ### Patch Changes
58
+
59
+ - **Corrected release metadata.** This release is the first publish of the 0.3.13–0.3.15 wave. The dependency pins shipped here point at published versions: `@hasna/contracts` 0.13.3 with manifest `kitVersion` 0.13.3, and `@hasna/projects` 0.1.134 (the wave's original 0.1.137 pin was unpublished at release time and is not shipped). Internal-infra host literals were removed from shipped content (OpenAPI servers list, `economy init` help, storage-seam comment).
60
+ - c5232cc: fix: prepack typecheck resolves the optional @hasna/projects SDK as a runtime-only module (non-literal dynamic import), so the build no longer fails TS2307 against the unbuilt workspace member in a fresh checkout. Todos 029ceb00.
61
+ - @hasna/projects@0.1.134
62
+
63
+ ## 0.3.14
64
+
65
+ ### Patch Changes
66
+
67
+ - d7d615b: Pin @hasna/contracts to the published 0.13.1 (was ^0.13.0; 0.13.0 is unpublished, which makes the standard-suite conformance validator cannot-run); the ship-latest wave then moved the pin to the published 0.13.3, and the manifest shipped here declares kitVersion 0.13.3 with the economy-otel bin. Todos d175d558.
68
+ - @hasna/projects@0.1.136
69
+ - @hasna/contracts@0.13.3
70
+
71
+ ## 0.3.13
72
+
73
+ ### Patch Changes
74
+
75
+ - 94f40c27: economy serve boots despite auth-contract refusal — the serve process no longer aborts at startup when the contracts auth seam refuses (missing or rejected API key); it stays up and reports the refusal (I38-00556).
76
+ - Updated dependencies [5e32853]
77
+ - @hasna/contracts@0.13.2
78
+ - @hasna/projects@0.1.135
79
+
3
80
  ## 0.3.12
4
81
 
5
82
  ### Patch Changes
@@ -48,14 +125,14 @@ metadata correction.
48
125
 
49
126
  **Breaking for server operators.** `HASNA_ECONOMY_STORAGE_MODE` (and the
50
127
  `ECONOMY_STORAGE_MODE` alias) are retired for server backend selection. They are
51
- now *rejected at startup with a migration hint* rather than normalized, so a
128
+ now _rejected at startup with a migration hint_ rather than normalized, so a
52
129
  half-migrated deployment fails loudly instead of quietly serving the wrong store.
53
130
  The server data backend is `sqlite | postgresql`, selected by the presence of
54
131
  `HASNA_ECONOMY_DATABASE_URL` alone. If you set `HASNA_ECONOMY_STORAGE_MODE=cloud`
55
132
  to reach Postgres, unset it and rely on the database URL.
56
133
 
57
134
  - **#27** `fix(client)` — hard-fail a half-applied cloud flip instead of silently
58
- serving local data. An `API_URL` set *without* an `API_KEY` previously resolved
135
+ serving local data. An `API_URL` set _without_ an `API_KEY` previously resolved
59
136
  to `local` with no warning, byte-identical to an unconfigured host: the CLI
60
137
  served the local SQLite store while the operator had pointed it at the cloud
61
138
  API — a different dataset rendered as plausible spend numbers. It now reports
package/dist/cli/index.js CHANGED
@@ -76,15 +76,15 @@ var init_sqlite_adapter = () => {};
76
76
  // src/lib/pricing.ts
77
77
  var exports_pricing = {};
78
78
  __export(exports_pricing, {
79
- DEFAULT_PRICING: () => DEFAULT_PRICING,
80
- computeCost: () => computeCost,
81
- computeCostFromDb: () => computeCostFromDb,
82
- ensurePricingSeeded: () => ensurePricingSeeded,
83
- estimateCostFromRows: () => estimateCostFromRows,
84
- getPricing: () => getPricing,
85
- getPricingFromDb: () => getPricingFromDb,
79
+ normalizeModelName: () => normalizeModelName,
86
80
  getPricingFromRows: () => getPricingFromRows,
87
- normalizeModelName: () => normalizeModelName
81
+ getPricingFromDb: () => getPricingFromDb,
82
+ getPricing: () => getPricing,
83
+ estimateCostFromRows: () => estimateCostFromRows,
84
+ ensurePricingSeeded: () => ensurePricingSeeded,
85
+ computeCostFromDb: () => computeCostFromDb,
86
+ computeCost: () => computeCost,
87
+ DEFAULT_PRICING: () => DEFAULT_PRICING
88
88
  });
89
89
  function normalizeModelName(raw) {
90
90
  return raw.trim().toLowerCase().replace(/^models\//, "").replace(/^[a-z0-9_.-]+\//, "").replace(/:.+$/, "").replace(/-\d{8}$/, "").replace(/-\d{4}-\d{2}-\d{2}$/, "");
@@ -3845,12 +3845,12 @@ function isAuthorizedRequest(req, path) {
3845
3845
  // src/cli/commands/tui.ts
3846
3846
  var exports_tui = {};
3847
3847
  __export(exports_tui, {
3848
- buildStatusLine: () => buildStatusLine,
3849
- buildWaybarJson: () => buildWaybarJson,
3850
- gatherStatusData: () => gatherStatusData,
3851
- printStatusLine: () => printStatusLine,
3848
+ runTui: () => runTui,
3852
3849
  printWaybarJson: () => printWaybarJson,
3853
- runTui: () => runTui
3850
+ printStatusLine: () => printStatusLine,
3851
+ gatherStatusData: () => gatherStatusData,
3852
+ buildWaybarJson: () => buildWaybarJson,
3853
+ buildStatusLine: () => buildStatusLine
3854
3854
  });
3855
3855
  import chalk3 from "chalk";
3856
3856
  function fmt(usd) {
@@ -5691,9 +5691,9 @@ var init_sync_all = __esm(() => {
5691
5691
  // src/ingest/billing.ts
5692
5692
  var exports_billing = {};
5693
5693
  __export(exports_billing, {
5694
- syncAnthropicBilling: () => syncAnthropicBilling,
5694
+ syncOpenAIBilling: () => syncOpenAIBilling,
5695
5695
  syncGeminiBilling: () => syncGeminiBilling,
5696
- syncOpenAIBilling: () => syncOpenAIBilling
5696
+ syncAnthropicBilling: () => syncAnthropicBilling
5697
5697
  });
5698
5698
  import { readFileSync as readFileSync10 } from "fs";
5699
5699
  function getAnthropicAdminKey() {
@@ -5956,7 +5956,7 @@ __export(exports_open_projects, {
5956
5956
  async function syncOpenProjectsRegistry(db, listActiveProjects) {
5957
5957
  let listProjects2 = listActiveProjects;
5958
5958
  if (!listProjects2) {
5959
- const projectsApi = await import("@hasna/projects");
5959
+ const projectsApi = await import(PROJECTS_MODULE);
5960
5960
  listProjects2 = projectsApi.listProjects;
5961
5961
  }
5962
5962
  const projects = listProjects2({ status: "active", limit: 5000 });
@@ -5980,7 +5980,7 @@ async function syncOpenProjectsRegistry(db, listActiveProjects) {
5980
5980
  }
5981
5981
  return { imported, skipped };
5982
5982
  }
5983
- var resolveProjectPath = (project) => project.primary_path || project.path || "";
5983
+ var resolveProjectPath = (project) => project.primary_path || project.path || "", PROJECTS_MODULE = "@hasna/projects";
5984
5984
  var init_open_projects = __esm(() => {
5985
5985
  init_database();
5986
5986
  });
@@ -5988,10 +5988,10 @@ var init_open_projects = __esm(() => {
5988
5988
  // src/lib/config.ts
5989
5989
  var exports_config = {};
5990
5990
  __export(exports_config, {
5991
- getConfigValue: () => getConfigValue,
5992
- loadConfig: () => loadConfig2,
5991
+ setConfigValue: () => setConfigValue,
5993
5992
  saveConfig: () => saveConfig2,
5994
- setConfigValue: () => setConfigValue
5993
+ loadConfig: () => loadConfig2,
5994
+ getConfigValue: () => getConfigValue
5995
5995
  });
5996
5996
  import { existsSync as existsSync13, readFileSync as readFileSync11, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3 } from "fs";
5997
5997
  import { dirname as dirname2, join as join14 } from "path";
@@ -6593,13 +6593,9 @@ var init_openapi = __esm(() => {
6593
6593
  description: "AI coding cost tracker \u2014 self-hosted control plane. The server data backend is sqlite | postgresql, selected by the presence of a database URL; with postgresql the serve process reads AND writes PostgreSQL directly with API-key auth via @hasna/contracts. All /v1 routes require a valid `economy:*` scoped API key (x-api-key or Authorization: Bearer). The foundation probes /health, /ready, /version are open."
6594
6594
  },
6595
6595
  servers: [
6596
- {
6597
- url: "https://economy.hasna.xyz",
6598
- description: "prod"
6599
- },
6600
6596
  {
6601
6597
  url: "http://localhost:3456",
6602
- description: "local"
6598
+ description: "local (self-hosted default; set your own URL when deploying)"
6603
6599
  }
6604
6600
  ],
6605
6601
  security: [
@@ -8226,10 +8222,10 @@ var init_openapi = __esm(() => {
8226
8222
  // src/server/serve.ts
8227
8223
  var exports_serve = {};
8228
8224
  __export(exports_serve, {
8229
- createHandler: () => createHandler,
8230
- createServerFetch: () => createServerFetch,
8225
+ startServer: () => startServer,
8231
8226
  openApiDocument: () => openApiDocument,
8232
- startServer: () => startServer
8227
+ createServerFetch: () => createServerFetch,
8228
+ createHandler: () => createHandler
8233
8229
  });
8234
8230
  import { randomUUID as randomUUID2 } from "crypto";
8235
8231
  import { existsSync as existsSync16 } from "fs";
@@ -8824,7 +8820,7 @@ function startServer(port = 3456, options = {}) {
8824
8820
  handlerOptions.authenticator = verifyApiKey({
8825
8821
  app: APP,
8826
8822
  signingSecret,
8827
- isRevoked: keys.statusChecker(),
8823
+ keyStatus: keys.keyStatus,
8828
8824
  audit: (event) => log(JSON.stringify({ evt: "api_auth", outcome: event.outcome, kid: event.kid, reason: event.reason, path: event.path, status: event.status }))
8829
8825
  });
8830
8826
  } else if (!isLocalHost(hostname2)) {
@@ -8882,10 +8878,10 @@ var init_serve = __esm(() => {
8882
8878
  // src/cli/commands/menubar.ts
8883
8879
  var exports_menubar = {};
8884
8880
  __export(exports_menubar, {
8885
- menubarInstall: () => menubarInstall,
8886
- menubarStart: () => menubarStart,
8881
+ menubarUninstall: () => menubarUninstall,
8887
8882
  menubarStop: () => menubarStop,
8888
- menubarUninstall: () => menubarUninstall
8883
+ menubarStart: () => menubarStart,
8884
+ menubarInstall: () => menubarInstall
8889
8885
  });
8890
8886
  import chalk6 from "chalk";
8891
8887
  import { execFileSync as execFileSync3 } from "child_process";
@@ -10609,7 +10605,7 @@ function registerExtendedCommands(program) {
10609
10605
  console.log(" 7. Linux status: economy tui --watch | economy waybar");
10610
10606
  console.log();
10611
10607
  console.log(" Self-hosted/cloud mode (shared cloud API \u2014 reads/writes route to it):");
10612
- console.log(" a. API URL: export HASNA_ECONOMY_API_URL=https://economy.hasna.xyz/v1");
10608
+ console.log(" a. API URL: export HASNA_ECONOMY_API_URL=https://your-economy-host.example.com/v1");
10613
10609
  console.log(" b. API key: export HASNA_ECONOMY_API_KEY=<bearer key> (never a DB DSN)");
10614
10610
  console.log();
10615
10611
  });
package/dist/index.js CHANGED
@@ -74,15 +74,15 @@ var init_sqlite_adapter = () => {};
74
74
  // src/lib/pricing.ts
75
75
  var exports_pricing = {};
76
76
  __export(exports_pricing, {
77
- DEFAULT_PRICING: () => DEFAULT_PRICING,
78
- computeCost: () => computeCost,
79
- computeCostFromDb: () => computeCostFromDb,
80
- ensurePricingSeeded: () => ensurePricingSeeded,
81
- estimateCostFromRows: () => estimateCostFromRows,
82
- getPricing: () => getPricing,
83
- getPricingFromDb: () => getPricingFromDb,
77
+ normalizeModelName: () => normalizeModelName,
84
78
  getPricingFromRows: () => getPricingFromRows,
85
- normalizeModelName: () => normalizeModelName
79
+ getPricingFromDb: () => getPricingFromDb,
80
+ getPricing: () => getPricing,
81
+ estimateCostFromRows: () => estimateCostFromRows,
82
+ ensurePricingSeeded: () => ensurePricingSeeded,
83
+ computeCostFromDb: () => computeCostFromDb,
84
+ computeCost: () => computeCost,
85
+ DEFAULT_PRICING: () => DEFAULT_PRICING
86
86
  });
87
87
  function normalizeModelName(raw) {
88
88
  return raw.trim().toLowerCase().replace(/^models\//, "").replace(/^[a-z0-9_.-]+\//, "").replace(/:.+$/, "").replace(/-\d{8}$/, "").replace(/-\d{4}-\d{2}-\d{2}$/, "");
@@ -3396,11 +3396,11 @@ function isCloudStore(env = process.env) {
3396
3396
  return economyCloudStorage(env).active;
3397
3397
  }
3398
3398
  export {
3399
- AGENTS,
3400
- ApiStore,
3401
- COST_BASIS,
3402
- LocalStore,
3403
- getStore,
3399
+ isCloudStore,
3404
3400
  isAgent,
3405
- isCloudStore
3401
+ getStore,
3402
+ LocalStore,
3403
+ COST_BASIS,
3404
+ ApiStore,
3405
+ AGENTS
3406
3406
  };
@@ -1 +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,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AE,MAAM,EAAE,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,KAAK,gBAAgB,GAAG,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAAK,WAAW,EAAE,CAAA;AAIvF,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,QAAQ,EACZ,kBAAkB,CAAC,EAAE,gBAAgB,GACpC,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA4BhD"}
1
+ {"version":3,"file":"open-projects.d.ts","sourceRoot":"","sources":["../../src/lib/open-projects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAGxE;;;;;;GAMG;AACH,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,KAAK,gBAAgB,GAAG,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAAK,WAAW,EAAE,CAAA;AAgBvF,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,QAAQ,EACZ,kBAAkB,CAAC,EAAE,gBAAgB,GACpC,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA4BhD"}
package/dist/mcp/index.js CHANGED
@@ -76,15 +76,15 @@ var init_sqlite_adapter = () => {};
76
76
  // src/lib/pricing.ts
77
77
  var exports_pricing = {};
78
78
  __export(exports_pricing, {
79
- DEFAULT_PRICING: () => DEFAULT_PRICING,
80
- computeCost: () => computeCost,
81
- computeCostFromDb: () => computeCostFromDb,
82
- ensurePricingSeeded: () => ensurePricingSeeded,
83
- estimateCostFromRows: () => estimateCostFromRows,
84
- getPricing: () => getPricing,
85
- getPricingFromDb: () => getPricingFromDb,
79
+ normalizeModelName: () => normalizeModelName,
86
80
  getPricingFromRows: () => getPricingFromRows,
87
- normalizeModelName: () => normalizeModelName
81
+ getPricingFromDb: () => getPricingFromDb,
82
+ getPricing: () => getPricing,
83
+ estimateCostFromRows: () => estimateCostFromRows,
84
+ ensurePricingSeeded: () => ensurePricingSeeded,
85
+ computeCostFromDb: () => computeCostFromDb,
86
+ computeCost: () => computeCost,
87
+ DEFAULT_PRICING: () => DEFAULT_PRICING
88
88
  });
89
89
  function normalizeModelName(raw) {
90
90
  return raw.trim().toLowerCase().replace(/^models\//, "").replace(/^[a-z0-9_.-]+\//, "").replace(/:.+$/, "").replace(/-\d{8}$/, "").replace(/-\d{4}-\d{2}-\d{2}$/, "");
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAmmD/C,CAAA;AACD,eAAe,WAAW,CAAA"}
1
+ {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CA+lD/C,CAAA;AACD,eAAe,WAAW,CAAA"}
@@ -75,15 +75,15 @@ var init_sqlite_adapter = () => {};
75
75
  // src/lib/pricing.ts
76
76
  var exports_pricing = {};
77
77
  __export(exports_pricing, {
78
- DEFAULT_PRICING: () => DEFAULT_PRICING,
79
- computeCost: () => computeCost,
80
- computeCostFromDb: () => computeCostFromDb,
81
- ensurePricingSeeded: () => ensurePricingSeeded,
82
- estimateCostFromRows: () => estimateCostFromRows,
83
- getPricing: () => getPricing,
84
- getPricingFromDb: () => getPricingFromDb,
78
+ normalizeModelName: () => normalizeModelName,
85
79
  getPricingFromRows: () => getPricingFromRows,
86
- normalizeModelName: () => normalizeModelName
80
+ getPricingFromDb: () => getPricingFromDb,
81
+ getPricing: () => getPricing,
82
+ estimateCostFromRows: () => estimateCostFromRows,
83
+ ensurePricingSeeded: () => ensurePricingSeeded,
84
+ computeCostFromDb: () => computeCostFromDb,
85
+ computeCost: () => computeCost,
86
+ DEFAULT_PRICING: () => DEFAULT_PRICING
87
87
  });
88
88
  function normalizeModelName(raw) {
89
89
  return raw.trim().toLowerCase().replace(/^models\//, "").replace(/^[a-z0-9_.-]+\//, "").replace(/:.+$/, "").replace(/-\d{8}$/, "").replace(/-\d{4}-\d{2}-\d{2}$/, "");
@@ -76,15 +76,15 @@ var init_sqlite_adapter = () => {};
76
76
  // src/lib/pricing.ts
77
77
  var exports_pricing = {};
78
78
  __export(exports_pricing, {
79
- DEFAULT_PRICING: () => DEFAULT_PRICING,
80
- computeCost: () => computeCost,
81
- computeCostFromDb: () => computeCostFromDb,
82
- ensurePricingSeeded: () => ensurePricingSeeded,
83
- estimateCostFromRows: () => estimateCostFromRows,
84
- getPricing: () => getPricing,
85
- getPricingFromDb: () => getPricingFromDb,
79
+ normalizeModelName: () => normalizeModelName,
86
80
  getPricingFromRows: () => getPricingFromRows,
87
- normalizeModelName: () => normalizeModelName
81
+ getPricingFromDb: () => getPricingFromDb,
82
+ getPricing: () => getPricing,
83
+ estimateCostFromRows: () => estimateCostFromRows,
84
+ ensurePricingSeeded: () => ensurePricingSeeded,
85
+ computeCostFromDb: () => computeCostFromDb,
86
+ computeCost: () => computeCost,
87
+ DEFAULT_PRICING: () => DEFAULT_PRICING
88
88
  });
89
89
  function normalizeModelName(raw) {
90
90
  return raw.trim().toLowerCase().replace(/^models\//, "").replace(/^[a-z0-9_.-]+\//, "").replace(/:.+$/, "").replace(/-\d{8}$/, "").replace(/-\d{4}-\d{2}-\d{2}$/, "");
@@ -2512,8 +2512,8 @@ var init_sync_pg = () => {};
2512
2512
  // src/db/pg-migrate.ts
2513
2513
  var exports_pg_migrate = {};
2514
2514
  __export(exports_pg_migrate, {
2515
- applyPgMigrations: () => applyPgMigrations,
2516
- resolvePgSsl: () => resolvePgSsl
2515
+ resolvePgSsl: () => resolvePgSsl,
2516
+ applyPgMigrations: () => applyPgMigrations
2517
2517
  });
2518
2518
  import pg from "pg";
2519
2519
  function resolvePgSsl(dsn) {
@@ -2792,14 +2792,14 @@ var init_pg_migrations = __esm(() => {
2792
2792
  // src/db/cloud.ts
2793
2793
  var exports_cloud = {};
2794
2794
  __export(exports_cloud, {
2795
- authClientFromPool: () => authClientFromPool,
2796
- cloudMigrations: () => cloudMigrations,
2797
- createCloudPool: () => createCloudPool,
2798
- getCloudDatabaseUrl: () => getCloudDatabaseUrl,
2799
- isPostgresBackend: () => isPostgresBackend,
2800
- openCloudDatabase: () => openCloudDatabase,
2795
+ resolveSigningSecret: () => resolveSigningSecret,
2801
2796
  resolveEconomyServerBackend: () => resolveEconomyServerBackend,
2802
- resolveSigningSecret: () => resolveSigningSecret
2797
+ openCloudDatabase: () => openCloudDatabase,
2798
+ isPostgresBackend: () => isPostgresBackend,
2799
+ getCloudDatabaseUrl: () => getCloudDatabaseUrl,
2800
+ createCloudPool: () => createCloudPool,
2801
+ cloudMigrations: () => cloudMigrations,
2802
+ authClientFromPool: () => authClientFromPool
2803
2803
  });
2804
2804
  import pg2 from "pg";
2805
2805
  function assertNoRetiredBackendKey(env) {
@@ -2870,9 +2870,9 @@ var init_cloud = __esm(() => {
2870
2870
  // src/ingest/billing.ts
2871
2871
  var exports_billing = {};
2872
2872
  __export(exports_billing, {
2873
- syncAnthropicBilling: () => syncAnthropicBilling,
2873
+ syncOpenAIBilling: () => syncOpenAIBilling,
2874
2874
  syncGeminiBilling: () => syncGeminiBilling,
2875
- syncOpenAIBilling: () => syncOpenAIBilling
2875
+ syncAnthropicBilling: () => syncAnthropicBilling
2876
2876
  });
2877
2877
  import { readFileSync as readFileSync9 } from "fs";
2878
2878
  function getAnthropicAdminKey() {
@@ -3135,7 +3135,7 @@ __export(exports_open_projects, {
3135
3135
  async function syncOpenProjectsRegistry(db, listActiveProjects) {
3136
3136
  let listProjects2 = listActiveProjects;
3137
3137
  if (!listProjects2) {
3138
- const projectsApi = await import("@hasna/projects");
3138
+ const projectsApi = await import(PROJECTS_MODULE);
3139
3139
  listProjects2 = projectsApi.listProjects;
3140
3140
  }
3141
3141
  const projects = listProjects2({ status: "active", limit: 5000 });
@@ -3159,7 +3159,7 @@ async function syncOpenProjectsRegistry(db, listActiveProjects) {
3159
3159
  }
3160
3160
  return { imported, skipped };
3161
3161
  }
3162
- var resolveProjectPath = (project) => project.primary_path || project.path || "";
3162
+ var resolveProjectPath = (project) => project.primary_path || project.path || "", PROJECTS_MODULE = "@hasna/projects";
3163
3163
  var init_open_projects = __esm(() => {
3164
3164
  init_database();
3165
3165
  });
@@ -6006,13 +6006,9 @@ var openApiSpec = {
6006
6006
  description: "AI coding cost tracker \u2014 self-hosted control plane. The server data backend is sqlite | postgresql, selected by the presence of a database URL; with postgresql the serve process reads AND writes PostgreSQL directly with API-key auth via @hasna/contracts. All /v1 routes require a valid `economy:*` scoped API key (x-api-key or Authorization: Bearer). The foundation probes /health, /ready, /version are open."
6007
6007
  },
6008
6008
  servers: [
6009
- {
6010
- url: "https://economy.hasna.xyz",
6011
- description: "prod"
6012
- },
6013
6009
  {
6014
6010
  url: "http://localhost:3456",
6015
- description: "local"
6011
+ description: "local (self-hosted default; set your own URL when deploying)"
6016
6012
  }
6017
6013
  ],
6018
6014
  security: [
@@ -8236,7 +8232,7 @@ function startServer(port = 3456, options = {}) {
8236
8232
  handlerOptions.authenticator = verifyApiKey({
8237
8233
  app: APP,
8238
8234
  signingSecret,
8239
- isRevoked: keys.statusChecker(),
8235
+ keyStatus: keys.keyStatus,
8240
8236
  audit: (event) => log(JSON.stringify({ evt: "api_auth", outcome: event.outcome, kid: event.kid, reason: event.reason, path: event.path, status: event.status }))
8241
8237
  });
8242
8238
  } else if (!isLocalHost(hostname2)) {
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/server/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAgDxE,gFAAgF;AAChF,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGzD;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CACV,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GAC7F,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC/E;AAuBD,UAAU,kBAAkB;IAC1B,EAAE,CAAC,EAAE,QAAQ,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC;AA6ED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,SAAwB,IACzF,KAAK,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAwB7D;AAQD,MAAM,WAAW,cAAc;IAC7B;;w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;IACjB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC;AA6ED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,SAAwB,IACzF,KAAK,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAwB7D;AAQD,MAAM,WAAW,cAAc;IAC7B;;wEAEoE;IACpE,aAAa,CAAC,EAAE,gBAAgB,CAAA;IAChC,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAChE;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,GAAE,cAAmB,IACxC,KAAK,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAmhB/D;AAMD,wBAAgB,WAAW,CAAC,IAAI,SAAO,EAAE,OAAO,GAAE,kBAAuB,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,CAqDvG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/economy",
3
- "version": "0.3.12",
3
+ "version": "0.3.23",
4
4
  "description": "AI coding cost tracker — CLI + MCP server + REST API + web dashboard for Claude Code, Codex, OpenCode, Cursor, Pi, and Hermes, with legacy Gemini CLI session and Gemini API billing ingestion",
5
5
  "repository": {
6
6
  "type": "git",
@@ -74,10 +74,10 @@
74
74
  "dependencies": {
75
75
  "@hasna/accounts": "0.2.23",
76
76
  "@hasna/agent-registry": "^0.1.0",
77
- "@hasna/contracts": "^0.13.0",
77
+ "@hasna/contracts": "0.13.4",
78
78
  "@hasna/events": "^0.1.16",
79
79
  "@hasna/mcp-harness": "^0.1.0",
80
- "@hasna/projects": "0.1.134",
80
+ "@hasna/projects": "0.1.145",
81
81
  "@modelcontextprotocol/sdk": "^1.12.1",
82
82
  "chalk": "^5.4.1",
83
83
  "commander": "^13.1.0",