@hasna/economy 0.5.7 → 0.5.9
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 +15 -0
- package/dist/chunks/{billing-22az60hy.js → billing-7twygmtj.js} +2 -2
- package/dist/chunks/{config-hsp7ndhj.js → config-mjgbekxj.js} +2 -2
- package/dist/chunks/{index-9wa1f2kv.js → index-7ek4r0ww.js} +1 -1
- package/dist/chunks/{index-z2n5y111.js → index-92x56q4h.js} +5 -4
- package/dist/chunks/{index-wq7c4wqs.js → index-970htsxe.js} +2 -2
- package/dist/chunks/{index-vajzfzgv.js → index-ep1pkyr3.js} +1 -1
- package/dist/chunks/{index-dk5rq1rq.js → index-gtjqy0kd.js} +1 -1
- package/dist/chunks/{index-b6c649mq.js → index-spwpgdbb.js} +82 -7
- package/dist/chunks/{index-c7h2rxx1.js → index-t0n32g8r.js} +1 -1
- package/dist/chunks/{index-6yr4hb72.js → index-twkdyrw4.js} +2 -2
- package/dist/chunks/{index-f5jv6q5q.js → index-zgvmrqyc.js} +1 -1
- package/dist/chunks/{open-projects-8qm46m3d.js → open-projects-bj561k5j.js} +1 -1
- package/dist/chunks/{pricing-k9wsjwbz.js → pricing-bkgvzpe9.js} +1 -1
- package/dist/chunks/{pricing-462f8xkm.js → pricing-bn88mhqk.js} +1 -1
- package/dist/chunks/{pricing-vxejj1qa.js → pricing-nt31hf53.js} +1 -1
- package/dist/chunks/{serve-ms8dvf7e.js → serve-tmv8zgvh.js} +14 -8
- package/dist/chunks/{sqlite-store-ht6frztj.js → sqlite-store-8t4anw98.js} +2 -2
- package/dist/chunks/{sqlite-store-13nhr1z0.js → sqlite-store-jfy0e8b6.js} +2 -2
- package/dist/chunks/{sqlite-store-gamn65xp.js → sqlite-store-r219qrjt.js} +2 -2
- package/dist/chunks/{tui-9t7340wd.js → tui-j8brj3wf.js} +4 -4
- package/dist/chunks/{watch-t6ssnx30.js → watch-ksn2mezm.js} +5 -5
- package/dist/chunks/{webhooks-nw4daw9y.js → webhooks-td46p6gk.js} +2 -2
- package/dist/cli/index.js +38 -32
- package/dist/cost-imports/contract.d.ts +84 -0
- package/dist/cost-imports/contract.d.ts.map +1 -0
- package/dist/cost-imports/decimal.d.ts +6 -0
- package/dist/cost-imports/decimal.d.ts.map +1 -0
- package/dist/cost-imports/providers.d.ts +4 -0
- package/dist/cost-imports/providers.d.ts.map +1 -0
- package/dist/index.js +72 -12
- package/dist/lib/analytics.d.ts +3 -0
- package/dist/lib/analytics.d.ts.map +1 -1
- package/dist/lib/comparison-contract.d.ts +8 -0
- package/dist/lib/comparison-contract.d.ts.map +1 -0
- package/dist/lib/comparison-test-contract.d.ts +3 -0
- package/dist/lib/comparison-test-contract.d.ts.map +1 -0
- package/dist/lib/ingest-journal-maintenance.d.ts.map +1 -1
- package/dist/lib/store/index.d.ts.map +1 -1
- package/dist/mcp/index.js +75 -15
- package/dist/otel/index.js +7 -5
- package/dist/server/index.js +40 -6
- package/dist/server/service-operations.d.ts.map +1 -1
- package/dist/server/service-worker.js +40 -6
- package/docs/comparison-coverage.md +30 -0
- package/docs/ingest-journal.md +5 -1
- package/native/README.md +48 -0
- package/native/Tools/pair-qr.py +6 -1
- package/native/Tools/pair-qr.swift +19 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Give each journal recovery transaction its own bounded deadline so slow storage does not interrupt healthy collection, and stop ingestion whenever cleanup leaves unresolved recovery state.
|
|
8
|
+
|
|
9
|
+
## 0.5.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Recognize macOS login shells when opening private QR setup, while continuing to refuse captured agent terminals.
|
|
14
|
+
- Preserve the QR camera permission description in iPhone archives and refuse native device artifacts that omit it.
|
|
15
|
+
- Keep unknown historical billing and pricing explicit in comparison reports. Preserve usage counts, expose known monetary subtotals and coverage, and refuse unsupported hosted responses or incomplete percentage comparisons.
|
|
16
|
+
- Support an explicit private release Keychain for native Mac signing and notarization with credentials projected in memory.
|
|
17
|
+
|
|
3
18
|
## 0.5.7
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
syncAnthropicBilling,
|
|
4
4
|
syncGeminiBilling,
|
|
5
5
|
syncOpenAIBilling
|
|
6
|
-
} from "./index-
|
|
7
|
-
import"./index-
|
|
6
|
+
} from "./index-gtjqy0kd.js";
|
|
7
|
+
import"./index-zgvmrqyc.js";
|
|
8
8
|
import"./index-p35cyhc4.js";
|
|
9
9
|
export {
|
|
10
10
|
syncOpenAIBilling,
|
|
@@ -13,8 +13,9 @@ import {
|
|
|
13
13
|
queryRangeStats,
|
|
14
14
|
querySavingsSummary,
|
|
15
15
|
requireCurrentBillingDiffSummary,
|
|
16
|
+
requireCurrentRangeStats,
|
|
16
17
|
requireCurrentSavingsReport
|
|
17
|
-
} from "./index-
|
|
18
|
+
} from "./index-spwpgdbb.js";
|
|
18
19
|
import {
|
|
19
20
|
deleteBudget,
|
|
20
21
|
deleteGoal,
|
|
@@ -59,7 +60,7 @@ import {
|
|
|
59
60
|
upsertSubscription,
|
|
60
61
|
usageSnapshotFilterForPeriod,
|
|
61
62
|
validateIngest
|
|
62
|
-
} from "./index-
|
|
63
|
+
} from "./index-zgvmrqyc.js";
|
|
63
64
|
import {
|
|
64
65
|
__require
|
|
65
66
|
} from "./index-p35cyhc4.js";
|
|
@@ -92,7 +93,7 @@ class LocalStore {
|
|
|
92
93
|
_db;
|
|
93
94
|
async db() {
|
|
94
95
|
if (!this._db) {
|
|
95
|
-
const { openDatabase } = await import("./sqlite-store-
|
|
96
|
+
const { openDatabase } = await import("./sqlite-store-r219qrjt.js");
|
|
96
97
|
this._db = openDatabase();
|
|
97
98
|
ensurePricingSeeded(this._db);
|
|
98
99
|
}
|
|
@@ -369,7 +370,7 @@ class ApiStore {
|
|
|
369
370
|
return cloudListItems(this.cloud, "export", q({ type, period }));
|
|
370
371
|
}
|
|
371
372
|
async rangeStats(from, to) {
|
|
372
|
-
return cloudObject(this.cloud, "/compare", q({ from, to }));
|
|
373
|
+
return requireCurrentRangeStats(await cloudObject(this.cloud, "/compare", q({ from, to })), from, to);
|
|
373
374
|
}
|
|
374
375
|
async forecast() {
|
|
375
376
|
return cloudObject(this.cloud, "/forecast");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
LOCAL_STORAGE_OPT_IN_KEYS
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-spwpgdbb.js";
|
|
5
5
|
import {
|
|
6
6
|
assessCostFromDb,
|
|
7
7
|
getIngestState,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
upsertSession,
|
|
20
20
|
upsertSubscription,
|
|
21
21
|
upsertUsageSnapshot
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-zgvmrqyc.js";
|
|
23
23
|
import {
|
|
24
24
|
__require
|
|
25
25
|
} from "./index-p35cyhc4.js";
|
|
@@ -3430,4 +3430,4 @@ function computeCostWithPricing(model, pricing, inputTokens, outputTokens, cache
|
|
|
3430
3430
|
return (inputTokens * effective.inputPer1M + outputTokens * effective.outputPer1M + cacheReadTokens * effective.cacheReadPer1M + cacheWriteTokens * effective.cacheWritePer1M + cacheWrite1hTokens * (effective.cacheWrite1hPer1M ?? effective.cacheWritePer1M) + cacheStorageTokenHours * (effective.cacheStoragePer1MHour ?? 0)) / 1e6;
|
|
3431
3431
|
}
|
|
3432
3432
|
|
|
3433
|
-
export { observationId, subscriptionId, scanReceiptId, AGENTS, MAX_INGEST_ROWS, MAX_INGEST_BYTES, stableJson, canonicalIngestBodyHash, validateIngest, resolveReportingInterval, calendarPeriodBounds, calendarPeriodWhere, usageSnapshotFilterForPeriod, sessionOverlapWhere, dataDir, cacheDir, getMachineId, getHomeDir, getResolverDataRoot, getLegacyDataRoot, adoptResolverDataRoot, getExactDataRoot, getDataDir, getDbPath, initSchema, upsertCostCenter, getCostCenter, upsertRequest, upsertSession, rollupSession, querySessions, queryTopSessions, querySummary, queryZeroCostTokenizedModels, queryModelBreakdown, queryAgentBreakdown, queryProjectBreakdown, queryAccountBreakdown, queryCostCenterBreakdown, queryProjectBreakdownSince, queryAgentBreakdownSince, queryModelBreakdownSince, queryAccountBreakdownSince, queryDailyBreakdown, queryHourlyBreakdown, upsertProject, getProject, listProjects, deleteProject, upsertBudget, listBudgets, deleteBudget, getBudgetStatuses, upsertGoal, deleteGoal, listGoals, getGoalStatuses, getIngestState, loadIngestState, setIngestState, queryRequestsSince, insertFeedback, upsertBillingDaily, clearBillingRange, queryBillingSummary, countBillingRecords, getSessionDetail, listMachines, upsertModelPricing, getModelPricing, listModelPricing, deleteModelPricing, seedModelPricing, upsertSubscription, listSubscriptions, deleteSubscription, upsertUsageSnapshot, upsertScanReceipt, queryScanReceipts, queryUsageSnapshots, listMachineRegistry, dedupeRequests, bulkIngest, DEFAULT_PRICING, normalizeModelName, ensurePricingSeeded, getPricingFromDb, getPricing, computeCost, computeCostFromDb, UnknownModelPricingError, assessCostFromDb, getPricingFromRows, estimateCostFromRows, assessCostFromRows, formatReportedUsd, formatPlanMoney, hasKnownUsagePrice, requireCurrentCostSummary, formatSummaryValue, formatSummaryCoverage, requireCurrentBillingSummary, formatBillingValue };
|
|
3433
|
+
export { observationId, subscriptionId, scanReceiptId, AGENTS, MAX_INGEST_ROWS, MAX_INGEST_BYTES, stableJson, canonicalIngestBodyHash, validateIngest, resolveReportingInterval, calendarPeriodBounds, calendarPeriodWhere, usageSnapshotFilterForPeriod, sessionOverlapWhere, dataDir, cacheDir, getMachineId, getHomeDir, getResolverDataRoot, getLegacyDataRoot, adoptResolverDataRoot, getExactDataRoot, getDataDir, getDbPath, initSchema, upsertCostCenter, getCostCenter, upsertRequest, upsertSession, rollupSession, querySessions, queryTopSessions, querySummary, queryZeroCostTokenizedModels, queryModelBreakdown, queryAgentBreakdown, queryProjectBreakdown, queryAccountBreakdown, queryCostCenterBreakdown, queryProjectBreakdownSince, queryAgentBreakdownSince, queryModelBreakdownSince, queryAccountBreakdownSince, queryDailyBreakdown, queryHourlyBreakdown, upsertProject, getProject, listProjects, deleteProject, upsertBudget, listBudgets, deleteBudget, getBudgetStatuses, upsertGoal, deleteGoal, listGoals, getGoalStatuses, getIngestState, loadIngestState, setIngestState, queryRequestsSince, insertFeedback, upsertBillingDaily, clearBillingRange, queryBillingSummary, countBillingRecords, getSessionDetail, listMachines, upsertModelPricing, getModelPricing, listModelPricing, deleteModelPricing, seedModelPricing, upsertSubscription, listSubscriptions, deleteSubscription, upsertUsageSnapshot, upsertScanReceipt, queryScanReceipts, queryUsageSnapshots, listMachineRegistry, dedupeRequests, bulkIngest, DEFAULT_PRICING, normalizeModelName, ensurePricingSeeded, getPricingFromDb, getPricing, computeCost, computeCostFromDb, UnknownModelPricingError, assessCostFromDb, getPricingFromRows, estimateCostFromRows, assessCostFromRows, formatReportedUsd, formatPlanMoney, hasKnownUsagePrice, buildCostSummary, requireCurrentCostSummary, formatSummaryValue, formatSummaryCoverage, requireCurrentBillingSummary, formatBillingValue };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
+
buildCostSummary,
|
|
3
4
|
calendarPeriodBounds,
|
|
4
5
|
calendarPeriodWhere,
|
|
5
6
|
formatBillingValue,
|
|
6
7
|
formatReportedUsd,
|
|
8
|
+
formatSummaryValue,
|
|
7
9
|
hasKnownUsagePrice,
|
|
8
10
|
listMachineRegistry,
|
|
9
11
|
listMachines,
|
|
@@ -16,11 +18,75 @@ import {
|
|
|
16
18
|
requireCurrentCostSummary,
|
|
17
19
|
resolveReportingInterval,
|
|
18
20
|
sessionOverlapWhere
|
|
19
|
-
} from "./index-
|
|
21
|
+
} from "./index-zgvmrqyc.js";
|
|
22
|
+
|
|
23
|
+
// src/lib/comparison-contract.ts
|
|
24
|
+
function comparisonDateBounds(from, to) {
|
|
25
|
+
const valid = (value) => /^\d{4}-\d{2}-\d{2}$/.test(value) && Number.isFinite(Date.parse(value + "T00:00:00Z")) && new Date(value + "T00:00:00Z").toISOString().slice(0, 10) === value;
|
|
26
|
+
if (!valid(from) || !valid(to) || from > to) {
|
|
27
|
+
throw new RangeError("from and to must be real YYYY-MM-DD UTC dates with from <= to");
|
|
28
|
+
}
|
|
29
|
+
const end = new Date(to + "T00:00:00Z");
|
|
30
|
+
end.setUTCDate(end.getUTCDate() + 1);
|
|
31
|
+
const exclusive = end.toISOString().slice(0, 10);
|
|
32
|
+
if (!valid(exclusive))
|
|
33
|
+
throw new RangeError("to exceeds the supported UTC date range");
|
|
34
|
+
return { time_zone: "UTC", start_date: from, end_date_exclusive: exclusive };
|
|
35
|
+
}
|
|
36
|
+
function requireCurrentRangeStats(value, from, to) {
|
|
37
|
+
if (!value || typeof value !== "object")
|
|
38
|
+
throw new Error("COMPARISON_REPORT_UNAVAILABLE: Invalid response");
|
|
39
|
+
const report = value;
|
|
40
|
+
let money;
|
|
41
|
+
try {
|
|
42
|
+
money = requireCurrentCostSummary(report.money);
|
|
43
|
+
} catch {
|
|
44
|
+
throw new Error("COMPARISON_REPORT_UNAVAILABLE: The service must support comparison coverage");
|
|
45
|
+
}
|
|
46
|
+
for (const key of ["sessions", "requests", "tokens"]) {
|
|
47
|
+
if (!Number.isSafeInteger(report[key]) || report[key] < 0)
|
|
48
|
+
throw new Error("COMPARISON_REPORT_UNAVAILABLE: Invalid " + key);
|
|
49
|
+
}
|
|
50
|
+
if (report.cost !== money.total_usd || report.requests !== money.request_rows || report.tokens !== money.tokens || money.session_only_sessions !== 0 || money.session_only_value_usd !== 0 || money.requests !== money.request_rows) {
|
|
51
|
+
throw new Error("COMPARISON_REPORT_UNAVAILABLE: Inconsistent monetary coverage");
|
|
52
|
+
}
|
|
53
|
+
const knownRows = money.request_rows - money.unknown_price_requests;
|
|
54
|
+
const completeness = money.request_rows === 0 ? "no_records" : money.unknown_price_requests === 0 ? "complete" : knownRows > 0 ? "partial" : "unavailable";
|
|
55
|
+
if (money.completeness !== completeness || knownRows === 0 && money.total_usd !== 0 || money.sessions > money.request_rows || money.request_rows === 0 && money.tokens !== 0) {
|
|
56
|
+
throw new Error("COMPARISON_REPORT_UNAVAILABLE: Inconsistent request coverage");
|
|
57
|
+
}
|
|
58
|
+
const bounds = money.period_bounds;
|
|
59
|
+
if (!bounds.start_date || !bounds.end_date_exclusive || bounds.start_date >= bounds.end_date_exclusive) {
|
|
60
|
+
throw new Error("COMPARISON_REPORT_UNAVAILABLE: Missing comparison dates");
|
|
61
|
+
}
|
|
62
|
+
if (from !== undefined || to !== undefined) {
|
|
63
|
+
const expected = comparisonDateBounds(from, to);
|
|
64
|
+
if (bounds.start_date !== expected.start_date || bounds.end_date_exclusive !== expected.end_date_exclusive) {
|
|
65
|
+
throw new Error("COMPARISON_REPORT_UNAVAILABLE: Response dates do not match the requested range");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return report;
|
|
69
|
+
}
|
|
70
|
+
function formatComparisonValue(report) {
|
|
71
|
+
return formatSummaryValue(requireCurrentRangeStats(report).money);
|
|
72
|
+
}
|
|
73
|
+
function comparisonValueChange(left, right) {
|
|
74
|
+
requireCurrentRangeStats(left);
|
|
75
|
+
requireCurrentRangeStats(right);
|
|
76
|
+
const a = left.money.complete_total_usd, b = right.money.complete_total_usd;
|
|
77
|
+
if (a === null || b === null)
|
|
78
|
+
return "unavailable (incomplete usage value)";
|
|
79
|
+
if (b === 0)
|
|
80
|
+
return "unavailable (zero baseline)";
|
|
81
|
+
const change = (a - b) / b * 100;
|
|
82
|
+
if (!Number.isFinite(change))
|
|
83
|
+
return "unavailable (outside supported range)";
|
|
84
|
+
return (change >= 0 ? "+" : "") + change.toFixed(1) + "% usage value";
|
|
85
|
+
}
|
|
20
86
|
// package.json
|
|
21
87
|
var package_default = {
|
|
22
88
|
name: "@hasna/economy",
|
|
23
|
-
version: "0.5.
|
|
89
|
+
version: "0.5.9",
|
|
24
90
|
description: "AI coding cost tracker \u2014 CLI + MCP server + REST API for Claude Code, Codex, OpenCode, Cursor, Pi, and Hermes, with legacy Gemini CLI session and Gemini API billing ingestion",
|
|
25
91
|
repository: {
|
|
26
92
|
type: "git",
|
|
@@ -1281,11 +1347,20 @@ function queryExportRows(db, type, period) {
|
|
|
1281
1347
|
return db.prepare(`SELECT * FROM economy_effective_sessions WHERE ${where} ORDER BY started_at DESC`).all();
|
|
1282
1348
|
}
|
|
1283
1349
|
function queryRangeStats(db, from, to) {
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1286
|
-
|
|
1350
|
+
const bounds = comparisonDateBounds(from, to);
|
|
1351
|
+
const groups = db.prepare(`
|
|
1352
|
+
SELECT cost_basis, model, CASE WHEN cost_usd = 0 THEN 1 WHEN cost_usd < 0 THEN 2 ELSE 0 END AS zero_cost,
|
|
1353
|
+
SUM(cost_usd) AS cost_usd, COUNT(*) AS requests,
|
|
1354
|
+
COALESCE(SUM(input_tokens),0) AS input_tokens, COALESCE(SUM(output_tokens),0) AS output_tokens,
|
|
1355
|
+
COALESCE(SUM(cache_read_tokens),0) AS cache_read_tokens, COALESCE(SUM(cache_create_tokens),0) AS cache_create_tokens,
|
|
1356
|
+
COALESCE(SUM(cache_create_1h_tokens),0) AS cache_create_1h_tokens
|
|
1357
|
+
FROM economy_effective_requests WHERE DATE(timestamp) BETWEEN ? AND ?
|
|
1358
|
+
GROUP BY cost_basis, model, CASE WHEN cost_usd = 0 THEN 1 WHEN cost_usd < 0 THEN 2 ELSE 0 END
|
|
1359
|
+
`).all(from, to);
|
|
1360
|
+
const requestSessions = db.prepare("SELECT COUNT(DISTINCT session_id) AS sessions FROM economy_effective_requests WHERE DATE(timestamp) BETWEEN ? AND ?").get(from, to);
|
|
1361
|
+
const money = buildCostSummary("all", bounds, groups, { sessions: 0, requests: 0, tokens: 0, cost_usd: 0 }, requestSessions.sessions, listModelPricing(db));
|
|
1287
1362
|
const s = db.prepare(`SELECT COUNT(*) as sessions FROM economy_effective_sessions WHERE DATE(started_at) BETWEEN ? AND ?`).get(from, to);
|
|
1288
|
-
return { cost:
|
|
1363
|
+
return { cost: money.total_usd, money, requests: money.request_rows, tokens: money.tokens, sessions: s.sessions };
|
|
1289
1364
|
}
|
|
1290
1365
|
function queryForecast(db, now = new Date) {
|
|
1291
1366
|
const month = resolveReportingInterval({ kind: "calendar", period: "month" }, now);
|
|
@@ -1322,4 +1397,4 @@ function queryModelEfficiency(db) {
|
|
|
1322
1397
|
FROM economy_effective_requests GROUP BY model ORDER BY cost DESC`).all();
|
|
1323
1398
|
}
|
|
1324
1399
|
|
|
1325
|
-
export { packageMetadata, requireCurrentSavingsReport, querySavingsSummary, queryBillingDiff, requireCurrentBillingDiffSummary, billingDriftCheck, buildBrief, queryProjectDetail, queryExportRows, queryRangeStats, queryForecast, queryModelEfficiency, LOCAL_STORAGE_OPT_IN_KEYS, economyCloudStorage, cloudListItems, cloudObject, economyTransportReport };
|
|
1400
|
+
export { requireCurrentRangeStats, formatComparisonValue, comparisonValueChange, packageMetadata, requireCurrentSavingsReport, querySavingsSummary, queryBillingDiff, requireCurrentBillingDiffSummary, billingDriftCheck, buildBrief, queryProjectDetail, queryExportRows, queryRangeStats, queryForecast, queryModelEfficiency, LOCAL_STORAGE_OPT_IN_KEYS, economyCloudStorage, cloudListItems, cloudObject, economyTransportReport };
|
|
@@ -3395,4 +3395,4 @@ function computeCostWithPricing(model, pricing, inputTokens, outputTokens, cache
|
|
|
3395
3395
|
return (inputTokens * effective.inputPer1M + outputTokens * effective.outputPer1M + cacheReadTokens * effective.cacheReadPer1M + cacheWriteTokens * effective.cacheWritePer1M + cacheWrite1hTokens * (effective.cacheWrite1hPer1M ?? effective.cacheWritePer1M) + cacheStorageTokenHours * (effective.cacheStoragePer1MHour ?? 0)) / 1e6;
|
|
3396
3396
|
}
|
|
3397
3397
|
|
|
3398
|
-
export { __require, AGENTS, COST_BASIS, isAgent, subscriptionId, MAX_INGEST_BYTES, stableJson, canonicalIngestBodyHash, validateIngest, resolveReportingInterval, calendarPeriodBounds, calendarPeriodWhere, usageSnapshotFilterForPeriod, sessionOverlapWhere, dataDir, cacheDir, getMachineId, getHomeDir, getResolverDataRoot, getLegacyDataRoot, adoptResolverDataRoot, getExactDataRoot, getDataDir, getDbPath, initSchema, upsertCostCenter, getCostCenter, upsertRequest, upsertSession, rollupSession, querySessions, queryTopSessions, querySummary, queryZeroCostTokenizedModels, queryModelBreakdown, queryAgentBreakdown, queryProjectBreakdown, queryAccountBreakdown, queryCostCenterBreakdown, queryProjectBreakdownSince, queryAgentBreakdownSince, queryModelBreakdownSince, queryAccountBreakdownSince, queryDailyBreakdown, queryHourlyBreakdown, upsertProject, getProject, listProjects, deleteProject, upsertBudget, listBudgets, deleteBudget, getBudgetStatuses, upsertGoal, deleteGoal, listGoals, getGoalStatuses, getIngestState, loadIngestState, setIngestState, queryRequestsSince, insertFeedback, upsertBillingDaily, clearBillingRange, queryBillingSummary, countBillingRecords, getSessionDetail, listMachines, upsertModelPricing, getModelPricing, listModelPricing, deleteModelPricing, seedModelPricing, upsertSubscription, listSubscriptions, deleteSubscription, upsertUsageSnapshot, upsertScanReceipt, queryScanReceipts, queryUsageSnapshots, listMachineRegistry, dedupeRequests, bulkIngest, DEFAULT_PRICING, normalizeModelName, ensurePricingSeeded, getPricingFromDb, getPricing, computeCost, computeCostFromDb, UnknownModelPricingError, assessCostFromDb, getPricingFromRows, estimateCostFromRows, assessCostFromRows, hasKnownUsagePrice, requireCurrentCostSummary, requireCurrentBillingSummary };
|
|
3398
|
+
export { __require, AGENTS, COST_BASIS, isAgent, subscriptionId, MAX_INGEST_BYTES, stableJson, canonicalIngestBodyHash, validateIngest, resolveReportingInterval, calendarPeriodBounds, calendarPeriodWhere, usageSnapshotFilterForPeriod, sessionOverlapWhere, dataDir, cacheDir, getMachineId, getHomeDir, getResolverDataRoot, getLegacyDataRoot, adoptResolverDataRoot, getExactDataRoot, getDataDir, getDbPath, initSchema, upsertCostCenter, getCostCenter, upsertRequest, upsertSession, rollupSession, querySessions, queryTopSessions, querySummary, queryZeroCostTokenizedModels, queryModelBreakdown, queryAgentBreakdown, queryProjectBreakdown, queryAccountBreakdown, queryCostCenterBreakdown, queryProjectBreakdownSince, queryAgentBreakdownSince, queryModelBreakdownSince, queryAccountBreakdownSince, queryDailyBreakdown, queryHourlyBreakdown, upsertProject, getProject, listProjects, deleteProject, upsertBudget, listBudgets, deleteBudget, getBudgetStatuses, upsertGoal, deleteGoal, listGoals, getGoalStatuses, getIngestState, loadIngestState, setIngestState, queryRequestsSince, insertFeedback, upsertBillingDaily, clearBillingRange, queryBillingSummary, countBillingRecords, getSessionDetail, listMachines, upsertModelPricing, getModelPricing, listModelPricing, deleteModelPricing, seedModelPricing, upsertSubscription, listSubscriptions, deleteSubscription, upsertUsageSnapshot, upsertScanReceipt, queryScanReceipts, queryUsageSnapshots, listMachineRegistry, dedupeRequests, bulkIngest, DEFAULT_PRICING, normalizeModelName, ensurePricingSeeded, getPricingFromDb, getPricing, computeCost, computeCostFromDb, UnknownModelPricingError, assessCostFromDb, getPricingFromRows, estimateCostFromRows, assessCostFromRows, hasKnownUsagePrice, buildCostSummary, requireCurrentCostSummary, requireCurrentBillingSummary };
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
} from "./index-w3bvv0ns.js";
|
|
5
5
|
import {
|
|
6
6
|
getStore
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-92x56q4h.js";
|
|
8
8
|
import {
|
|
9
9
|
formatReportedUsd,
|
|
10
10
|
formatSummaryCoverage,
|
|
11
11
|
formatSummaryValue
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-zgvmrqyc.js";
|
|
13
13
|
|
|
14
14
|
// src/cli/commands/tui.ts
|
|
15
15
|
import chalk from "chalk";
|
|
@@ -3463,4 +3463,4 @@ function computeCostWithPricing(model, pricing, inputTokens, outputTokens, cache
|
|
|
3463
3463
|
return (inputTokens * effective.inputPer1M + outputTokens * effective.outputPer1M + cacheReadTokens * effective.cacheReadPer1M + cacheWriteTokens * effective.cacheWritePer1M + cacheWrite1hTokens * (effective.cacheWrite1hPer1M ?? effective.cacheWritePer1M) + cacheStorageTokenHours * (effective.cacheStoragePer1MHour ?? 0)) / 1e6;
|
|
3464
3464
|
}
|
|
3465
3465
|
|
|
3466
|
-
export { OBSERVATION_PG_MIGRATIONS, IngestError, observationId, subscriptionId, scanReceiptId, AGENTS, isAgent, parseAgent, MAX_INGEST_ROWS, MAX_INGEST_BYTES, stableJson, canonicalIngestBodyHash, validateIngest, INGEST_SCHEMA_SQL, LEGACY_PG_SQL, reconcileIngestReceipt, resolveReportingInterval, calendarPeriodBounds, calendarPeriodWhere, usageSnapshotFilterForPeriod, sessionOverlapWhere, dataDir, cacheDir, getMachineId, getHomeDir, getResolverDataRoot, getLegacyDataRoot, adoptResolverDataRoot, getExactDataRoot, getDataDir, getDbPath, initSchema, upsertCostCenter, getCostCenter, upsertRequest, upsertSession, rollupSession, querySessions, queryTopSessions, querySummary, queryZeroCostTokenizedModels, queryModelBreakdown, queryAgentBreakdown, queryProjectBreakdown, queryAccountBreakdown, queryCostCenterBreakdown, queryProjectBreakdownSince, queryAgentBreakdownSince, queryModelBreakdownSince, queryAccountBreakdownSince, queryDailyBreakdown, queryHourlyBreakdown, upsertProject, getProject, listProjects, deleteProject, upsertBudget, listBudgets, deleteBudget, getBudgetStatuses, upsertGoal, deleteGoal, listGoals, getGoalStatuses, getIngestState, loadIngestState, setIngestState, queryRequestsSince, insertFeedback, upsertBillingDaily, clearBillingRange, queryBillingSummary, countBillingRecords, getSessionDetail, listMachines, upsertModelPricing, getModelPricing, listModelPricing, deleteModelPricing, seedModelPricing, upsertSubscription, listSubscriptions, deleteSubscription, upsertUsageSnapshot, upsertScanReceipt, queryScanReceipts, queryUsageSnapshots, listMachineRegistry, dedupeRequests, bulkIngest, DEFAULT_PRICING, normalizeModelName, ensurePricingSeeded, getPricingFromDb, getPricing, computeCost, computeCostFromDb, UnknownModelPricingError, assessCostFromDb, getPricingFromRows, estimateCostFromRows, assessCostFromRows, formatReportedUsd, formatPlanMoney, hasKnownUsagePrice, requireCurrentCostSummary, formatSummaryValue, formatSummaryCoverage, requireCurrentBillingSummary, formatBillingValue };
|
|
3466
|
+
export { OBSERVATION_PG_MIGRATIONS, IngestError, observationId, subscriptionId, scanReceiptId, AGENTS, isAgent, parseAgent, MAX_INGEST_ROWS, MAX_INGEST_BYTES, stableJson, canonicalIngestBodyHash, validateIngest, INGEST_SCHEMA_SQL, LEGACY_PG_SQL, reconcileIngestReceipt, resolveReportingInterval, calendarPeriodBounds, calendarPeriodWhere, usageSnapshotFilterForPeriod, sessionOverlapWhere, dataDir, cacheDir, getMachineId, getHomeDir, getResolverDataRoot, getLegacyDataRoot, adoptResolverDataRoot, getExactDataRoot, getDataDir, getDbPath, initSchema, upsertCostCenter, getCostCenter, upsertRequest, upsertSession, rollupSession, querySessions, queryTopSessions, querySummary, queryZeroCostTokenizedModels, queryModelBreakdown, queryAgentBreakdown, queryProjectBreakdown, queryAccountBreakdown, queryCostCenterBreakdown, queryProjectBreakdownSince, queryAgentBreakdownSince, queryModelBreakdownSince, queryAccountBreakdownSince, queryDailyBreakdown, queryHourlyBreakdown, upsertProject, getProject, listProjects, deleteProject, upsertBudget, listBudgets, deleteBudget, getBudgetStatuses, upsertGoal, deleteGoal, listGoals, getGoalStatuses, getIngestState, loadIngestState, setIngestState, queryRequestsSince, insertFeedback, upsertBillingDaily, clearBillingRange, queryBillingSummary, countBillingRecords, getSessionDetail, listMachines, upsertModelPricing, getModelPricing, listModelPricing, deleteModelPricing, seedModelPricing, upsertSubscription, listSubscriptions, deleteSubscription, upsertUsageSnapshot, upsertScanReceipt, queryScanReceipts, queryUsageSnapshots, listMachineRegistry, dedupeRequests, bulkIngest, DEFAULT_PRICING, normalizeModelName, ensurePricingSeeded, getPricingFromDb, getPricing, computeCost, computeCostFromDb, UnknownModelPricingError, assessCostFromDb, getPricingFromRows, estimateCostFromRows, assessCostFromRows, formatReportedUsd, formatPlanMoney, hasKnownUsagePrice, buildCostSummary, requireCurrentCostSummary, formatSummaryValue, formatSummaryCoverage, requireCurrentBillingSummary, formatBillingValue };
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./index-w3bvv0ns.js";
|
|
6
6
|
import {
|
|
7
7
|
syncAll
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-970htsxe.js";
|
|
9
9
|
import {
|
|
10
10
|
buildBrief,
|
|
11
11
|
packageMetadata,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
queryProjectDetail,
|
|
17
17
|
queryRangeStats,
|
|
18
18
|
querySavingsSummary
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-spwpgdbb.js";
|
|
20
20
|
import {
|
|
21
21
|
AGENTS,
|
|
22
22
|
INGEST_SCHEMA_SQL,
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
upsertProject,
|
|
68
68
|
upsertSubscription,
|
|
69
69
|
usageSnapshotFilterForPeriod
|
|
70
|
-
} from "./index-
|
|
70
|
+
} from "./index-zgvmrqyc.js";
|
|
71
71
|
import {
|
|
72
72
|
__require
|
|
73
73
|
} from "./index-p35cyhc4.js";
|
|
@@ -3910,7 +3910,7 @@ function createDataHandler(db, actorId) {
|
|
|
3910
3910
|
if (providers.some((provider) => !allowedProviders.has(provider)))
|
|
3911
3911
|
return err("invalid billing provider");
|
|
3912
3912
|
const results = {};
|
|
3913
|
-
const { syncAnthropicBilling, syncOpenAIBilling, syncGeminiBilling } = await import("./billing-
|
|
3913
|
+
const { syncAnthropicBilling, syncOpenAIBilling, syncGeminiBilling } = await import("./billing-7twygmtj.js");
|
|
3914
3914
|
async function capture(provider, fn) {
|
|
3915
3915
|
try {
|
|
3916
3916
|
results[provider] = await fn();
|
|
@@ -4065,7 +4065,7 @@ function createDataHandler(db, actorId) {
|
|
|
4065
4065
|
const results = {};
|
|
4066
4066
|
if (sources === "all") {
|
|
4067
4067
|
try {
|
|
4068
|
-
const { syncOpenProjectsRegistry } = await import("./open-projects-
|
|
4068
|
+
const { syncOpenProjectsRegistry } = await import("./open-projects-bj561k5j.js");
|
|
4069
4069
|
results["projects"] = await syncOpenProjectsRegistry(db);
|
|
4070
4070
|
} catch {}
|
|
4071
4071
|
}
|
|
@@ -4073,7 +4073,7 @@ function createDataHandler(db, actorId) {
|
|
|
4073
4073
|
const syncResult = await syncAll(db, selected);
|
|
4074
4074
|
Object.assign(results, syncResult);
|
|
4075
4075
|
try {
|
|
4076
|
-
const { checkAndFireWebhooks } = await import("./webhooks-
|
|
4076
|
+
const { checkAndFireWebhooks } = await import("./webhooks-td46p6gk.js");
|
|
4077
4077
|
await checkAndFireWebhooks(db);
|
|
4078
4078
|
} catch {}
|
|
4079
4079
|
return ok(results);
|
|
@@ -4097,7 +4097,7 @@ function createDataHandler(db, actorId) {
|
|
|
4097
4097
|
return err("invalid JSON body");
|
|
4098
4098
|
const result = bulkIngest(db, body, { actorId });
|
|
4099
4099
|
try {
|
|
4100
|
-
const { checkAndFireWebhooks } = await import("./webhooks-
|
|
4100
|
+
const { checkAndFireWebhooks } = await import("./webhooks-td46p6gk.js");
|
|
4101
4101
|
if (body["budget_mode"] !== "create")
|
|
4102
4102
|
await checkAndFireWebhooks(db);
|
|
4103
4103
|
} catch {}
|
|
@@ -4150,7 +4150,13 @@ function createDataHandler(db, actorId) {
|
|
|
4150
4150
|
const to = url.searchParams.get("to")?.trim();
|
|
4151
4151
|
if (!from || !to)
|
|
4152
4152
|
return err("from and to are required (YYYY-MM-DD)");
|
|
4153
|
-
|
|
4153
|
+
try {
|
|
4154
|
+
return ok(queryRangeStats(db, from, to));
|
|
4155
|
+
} catch (error) {
|
|
4156
|
+
if (error instanceof RangeError)
|
|
4157
|
+
return err(error.message);
|
|
4158
|
+
throw error;
|
|
4159
|
+
}
|
|
4154
4160
|
}
|
|
4155
4161
|
if (path === "/api/forecast" && method === "GET") {
|
|
4156
4162
|
return ok(queryForecast(db));
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
upsertSession,
|
|
71
71
|
upsertSubscription,
|
|
72
72
|
upsertUsageSnapshot
|
|
73
|
-
} from "./index-
|
|
73
|
+
} from "./index-t0n32g8r.js";
|
|
74
74
|
|
|
75
75
|
// src/db/sqlite-adapter.ts
|
|
76
76
|
import { Database } from "bun:sqlite";
|
|
@@ -178,7 +178,7 @@ function openDatabase(dbPath, skipSeed = false) {
|
|
|
178
178
|
}
|
|
179
179
|
}, `opening ${path}`);
|
|
180
180
|
if (!skipSeed) {
|
|
181
|
-
import("./pricing-
|
|
181
|
+
import("./pricing-bkgvzpe9.js").then(({ ensurePricingSeeded }) => ensurePricingSeeded(db)).catch(() => {});
|
|
182
182
|
}
|
|
183
183
|
return db;
|
|
184
184
|
}
|
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
upsertSession,
|
|
70
70
|
upsertSubscription,
|
|
71
71
|
upsertUsageSnapshot
|
|
72
|
-
} from "./index-
|
|
72
|
+
} from "./index-ep1pkyr3.js";
|
|
73
73
|
import {
|
|
74
74
|
__require
|
|
75
75
|
} from "./index-p35cyhc4.js";
|
|
@@ -180,7 +180,7 @@ function openDatabase(dbPath, skipSeed = false) {
|
|
|
180
180
|
}
|
|
181
181
|
}, `opening ${path}`);
|
|
182
182
|
if (!skipSeed) {
|
|
183
|
-
import("./pricing-
|
|
183
|
+
import("./pricing-nt31hf53.js").then(({ ensurePricingSeeded }) => ensurePricingSeeded(db)).catch(() => {});
|
|
184
184
|
}
|
|
185
185
|
return db;
|
|
186
186
|
}
|
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
upsertSession,
|
|
70
70
|
upsertSubscription,
|
|
71
71
|
upsertUsageSnapshot
|
|
72
|
-
} from "./index-
|
|
72
|
+
} from "./index-zgvmrqyc.js";
|
|
73
73
|
import {
|
|
74
74
|
__require
|
|
75
75
|
} from "./index-p35cyhc4.js";
|
|
@@ -180,7 +180,7 @@ function openDatabase(dbPath, skipSeed = false) {
|
|
|
180
180
|
}
|
|
181
181
|
}, `opening ${path}`);
|
|
182
182
|
if (!skipSeed) {
|
|
183
|
-
import("./pricing-
|
|
183
|
+
import("./pricing-bn88mhqk.js").then(({ ensurePricingSeeded }) => ensurePricingSeeded(db)).catch(() => {});
|
|
184
184
|
}
|
|
185
185
|
return db;
|
|
186
186
|
}
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
printStatusLine,
|
|
7
7
|
printWaybarJson,
|
|
8
8
|
runTui
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-twkdyrw4.js";
|
|
10
10
|
import"./index-w3bvv0ns.js";
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
11
|
+
import"./index-92x56q4h.js";
|
|
12
|
+
import"./index-spwpgdbb.js";
|
|
13
|
+
import"./index-zgvmrqyc.js";
|
|
14
14
|
import"./index-p35cyhc4.js";
|
|
15
15
|
export {
|
|
16
16
|
runTui,
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import {
|
|
3
3
|
agentPaths,
|
|
4
4
|
syncAll
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-970htsxe.js";
|
|
6
6
|
import {
|
|
7
7
|
getStore,
|
|
8
8
|
isCloudStore
|
|
9
|
-
} from "./index-
|
|
10
|
-
import"./index-
|
|
9
|
+
} from "./index-92x56q4h.js";
|
|
10
|
+
import"./index-spwpgdbb.js";
|
|
11
11
|
import {
|
|
12
12
|
formatSummaryValue
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-zgvmrqyc.js";
|
|
14
14
|
import {
|
|
15
15
|
__require
|
|
16
16
|
} from "./index-p35cyhc4.js";
|
|
@@ -86,7 +86,7 @@ function agentLabel(agent) {
|
|
|
86
86
|
async function watchCosts(opts) {
|
|
87
87
|
const store = getStore();
|
|
88
88
|
const cloud = isCloudStore();
|
|
89
|
-
const db = cloud ? null : (await import("./sqlite-store-
|
|
89
|
+
const db = cloud ? null : (await import("./sqlite-store-r219qrjt.js")).openDatabase();
|
|
90
90
|
let lastCheck = new Date(Date.now() - opts.interval * 1000).toISOString();
|
|
91
91
|
const lines = [];
|
|
92
92
|
const MAX_LINES = 20;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
loadConfig
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-7ek4r0ww.js";
|
|
5
5
|
import {
|
|
6
6
|
getBudgetStatuses,
|
|
7
7
|
getIngestState,
|
|
8
8
|
resolveReportingInterval,
|
|
9
9
|
setIngestState
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-zgvmrqyc.js";
|
|
11
11
|
import"./index-p35cyhc4.js";
|
|
12
12
|
|
|
13
13
|
// src/lib/spikes.ts
|