@hasna/economy 0.3.9 → 0.3.10
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 +12 -0
- package/dist/cli/brains.d.ts +3 -0
- package/dist/cli/brains.d.ts.map +1 -0
- package/dist/cli/commands/brief.d.ts +11 -0
- package/dist/cli/commands/brief.d.ts.map +1 -0
- package/dist/cli/commands/completion.d.ts +2 -0
- package/dist/cli/commands/completion.d.ts.map +1 -0
- package/dist/cli/commands/extras.d.ts +4 -0
- package/dist/cli/commands/extras.d.ts.map +1 -0
- package/dist/cli/commands/menubar.d.ts +7 -0
- package/dist/cli/commands/menubar.d.ts.map +1 -0
- package/dist/cli/commands/notification.d.ts +8 -0
- package/dist/cli/commands/notification.d.ts.map +1 -0
- package/dist/cli/commands/todos.d.ts +29 -0
- package/dist/cli/commands/todos.d.ts.map +1 -0
- package/dist/cli/commands/tui.d.ts +26 -0
- package/dist/cli/commands/tui.d.ts.map +1 -0
- package/dist/cli/commands/watch.d.ts +10 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +12493 -0
- package/dist/db/cloud.d.ts +47 -0
- package/dist/db/cloud.d.ts.map +1 -0
- package/dist/db/database.d.ts +157 -0
- package/dist/db/database.d.ts.map +1 -0
- package/dist/db/dialect.d.ts +13 -0
- package/dist/db/dialect.d.ts.map +1 -0
- package/dist/db/pg-migrate.d.ts +30 -0
- package/dist/db/pg-migrate.d.ts.map +1 -0
- package/dist/db/pg-migrations.d.ts +7 -0
- package/dist/db/pg-migrations.d.ts.map +1 -0
- package/dist/db/pg-sync-worker.d.ts +2 -0
- package/dist/db/pg-sync-worker.d.ts.map +1 -0
- package/dist/db/sqlite-adapter.d.ts +36 -0
- package/dist/db/sqlite-adapter.d.ts.map +1 -0
- package/dist/db/sync-pg.d.ts +43 -0
- package/dist/db/sync-pg.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3833 -0
- package/dist/ingest/billing.d.ts +27 -0
- package/dist/ingest/billing.d.ts.map +1 -0
- package/dist/ingest/claude-quota.d.ts +5 -0
- package/dist/ingest/claude-quota.d.ts.map +1 -0
- package/dist/ingest/claude.d.ts +18 -0
- package/dist/ingest/claude.d.ts.map +1 -0
- package/dist/ingest/codex-quota.d.ts +5 -0
- package/dist/ingest/codex-quota.d.ts.map +1 -0
- package/dist/ingest/codex.d.ts +8 -0
- package/dist/ingest/codex.d.ts.map +1 -0
- package/dist/ingest/cursor.d.ts +6 -0
- package/dist/ingest/cursor.d.ts.map +1 -0
- package/dist/ingest/gemini.d.ts +6 -0
- package/dist/ingest/gemini.d.ts.map +1 -0
- package/dist/ingest/hermes.d.ts +6 -0
- package/dist/ingest/hermes.d.ts.map +1 -0
- package/dist/ingest/loops.d.ts +6 -0
- package/dist/ingest/loops.d.ts.map +1 -0
- package/dist/ingest/opencode.d.ts +7 -0
- package/dist/ingest/opencode.d.ts.map +1 -0
- package/dist/ingest/otel.d.ts +33 -0
- package/dist/ingest/otel.d.ts.map +1 -0
- package/dist/ingest/pi.d.ts +7 -0
- package/dist/ingest/pi.d.ts.map +1 -0
- package/dist/ingest/plugin.d.ts +17 -0
- package/dist/ingest/plugin.d.ts.map +1 -0
- package/dist/lib/accounts.d.ts +11 -0
- package/dist/lib/accounts.d.ts.map +1 -0
- package/dist/lib/agents.d.ts +11 -0
- package/dist/lib/agents.d.ts.map +1 -0
- package/dist/lib/analytics.d.ts +68 -0
- package/dist/lib/analytics.d.ts.map +1 -0
- package/dist/lib/billing-diff.d.ts +61 -0
- package/dist/lib/billing-diff.d.ts.map +1 -0
- package/dist/lib/brief.d.ts +72 -0
- package/dist/lib/brief.d.ts.map +1 -0
- package/dist/lib/cloud-storage.d.ts +48 -0
- package/dist/lib/cloud-storage.d.ts.map +1 -0
- package/dist/lib/config.d.ts +13 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/contracts-client/index.d.ts +3 -0
- package/dist/lib/contracts-client/index.d.ts.map +1 -0
- package/dist/lib/contracts-client/mode.d.ts +20 -0
- package/dist/lib/contracts-client/mode.d.ts.map +1 -0
- package/dist/lib/contracts-client/storage.d.ts +83 -0
- package/dist/lib/contracts-client/storage.d.ts.map +1 -0
- package/dist/lib/contracts-client/transport.d.ts +148 -0
- package/dist/lib/contracts-client/transport.d.ts.map +1 -0
- package/dist/lib/gatherer.d.ts +21 -0
- package/dist/lib/gatherer.d.ts.map +1 -0
- package/dist/lib/model-config.d.ts +8 -0
- package/dist/lib/model-config.d.ts.map +1 -0
- package/dist/lib/open-projects.d.ts +27 -0
- package/dist/lib/open-projects.d.ts.map +1 -0
- package/dist/lib/package-metadata.d.ts +8 -0
- package/dist/lib/package-metadata.d.ts.map +1 -0
- package/dist/lib/paths.d.ts +20 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/periods.d.ts +6 -0
- package/dist/lib/periods.d.ts.map +1 -0
- package/dist/lib/pricing.d.ts +13 -0
- package/dist/lib/pricing.d.ts.map +1 -0
- package/dist/lib/savings.d.ts +17 -0
- package/dist/lib/savings.d.ts.map +1 -0
- package/dist/lib/serve-auth.d.ts +4 -0
- package/dist/lib/serve-auth.d.ts.map +1 -0
- package/dist/lib/spikes.d.ts +18 -0
- package/dist/lib/spikes.d.ts.map +1 -0
- package/dist/lib/store/index.d.ts +303 -0
- package/dist/lib/store/index.d.ts.map +1 -0
- package/dist/lib/sync-all.d.ts +28 -0
- package/dist/lib/sync-all.d.ts.map +1 -0
- package/dist/lib/watch-paths.d.ts +3 -0
- package/dist/lib/watch-paths.d.ts.map +1 -0
- package/dist/lib/webhooks.d.ts +3 -0
- package/dist/lib/webhooks.d.ts.map +1 -0
- package/dist/mcp/http.d.ts +14 -0
- package/dist/mcp/http.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +6274 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/openapi.d.ts +3 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/otel/index.d.ts +3 -0
- package/dist/otel/index.d.ts.map +1 -0
- package/dist/otel/index.js +1464 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +8327 -0
- package/dist/server/pg-sync-worker.js +31 -0
- package/dist/server/serve.d.ts +42 -0
- package/dist/server/serve.d.ts.map +1 -0
- package/dist/types/index.d.ts +238 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +3 -1
|
@@ -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":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AAS,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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../src/ingest/otel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAGxE,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,YAAY,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,iBAAiB,EAAE,MAAM,CAAA;IACzB,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gBAAgB,CAAC,EAAE,cAAc,CAAA;IACjC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AA2ID,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,EAAE,CA+F/D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAqBrE;AAkBD,wBAAsB,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA4DzH"}
|
|
@@ -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,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAChD,MAAM,EAAE,kBAAkB,EAAE,CAAA;IAC5B,YAAY,EAAE,oBAAoB,EAAE,CAAA;CACrC;AAED,iFAAiF;AACjF,w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AK,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,sBAAsB,EAAE,MAAM,CAAA;IAC9B,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAED,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,WAAW,GAAG,OAAO,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,GA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;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,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 mode=self_hosted/cloud AND
|
|
19
|
+
* HASNA_ECONOMY_API_URL + HASNA_ECONOMY_API_KEY are set. Otherwise
|
|
20
|
+
* `{ active: false }` (local store). Throws if cloud was requested but is
|
|
21
|
+
* 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 in self_hosted/cloud mode.
|
|
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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
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/contracts-client/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Environment map (subset of NodeJS.ProcessEnv). */
|
|
2
|
+
export type Env = Record<string, string | undefined>;
|
|
3
|
+
/** Runtime storage enum. `local | cloud` ONLY (Amendment A1: PURE REMOTE). */
|
|
4
|
+
export type StorageMode = "local" | "cloud";
|
|
5
|
+
/** Deprecated storage-mode aliases accepted at parse time and mapped to cloud. */
|
|
6
|
+
export declare const DEPRECATED_STORAGE_MODE_ALIASES: readonly ["remote", "hybrid", "self_hosted"];
|
|
7
|
+
export interface StorageModeNormalization {
|
|
8
|
+
mode: StorageMode;
|
|
9
|
+
/** The deprecated alias that was normalized to `cloud`, if any. */
|
|
10
|
+
deprecatedAlias: string | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Normalize a raw storage-mode string to the `local | cloud` runtime enum.
|
|
14
|
+
* Accepts deprecated aliases (`remote`, `hybrid`, `self_hosted`) and maps them
|
|
15
|
+
* to `cloud`. Throws on any other value.
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeStorageMode(value: string): StorageModeNormalization;
|
|
18
|
+
/** Upper-snake env token for an app name, e.g. `economy` -> `ECONOMY`. */
|
|
19
|
+
export declare function envToken(name: string): string;
|
|
20
|
+
//# sourceMappingURL=mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../../../src/lib/contracts-client/mode.ts"],"names":[],"mappings":"AAaA,qDAAqD;AACrD,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAErD,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC;AAE5C,kFAAkF;AAClF,eAAO,MAAM,+BAA+B,8CAA+C,CAAC;AAE5F,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,WAAW,CAAC;IAClB,mEAAmE;IACnE,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,wBAAwB,CAQ5E;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|