@hasna/economy 0.2.16 → 0.2.18
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/LICENSE +186 -13
- package/README.md +186 -13
- package/dashboard/dist/assets/index-5mUN0CPj.css +1 -0
- package/dashboard/dist/assets/index-L1FgNQ4t.js +93 -0
- package/dashboard/dist/index.html +14 -0
- package/dashboard/dist/logo.jpg +0 -0
- package/dashboard/dist/vite.svg +1 -0
- package/dist/cli/index.js +131 -757
- package/dist/db/database.d.ts +1 -23
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/pg-migrations.d.ts.map +1 -1
- package/dist/index.js +51 -180
- package/dist/ingest/claude.d.ts +1 -6
- package/dist/ingest/claude.d.ts.map +1 -1
- package/dist/ingest/codex.d.ts +1 -1
- package/dist/ingest/codex.d.ts.map +1 -1
- package/dist/ingest/gemini.d.ts +1 -1
- package/dist/ingest/gemini.d.ts.map +1 -1
- package/dist/lib/pricing.d.ts +1 -1
- package/dist/lib/pricing.d.ts.map +1 -1
- package/dist/lib/webhooks.d.ts +1 -1
- package/dist/lib/webhooks.d.ts.map +1 -1
- package/dist/mcp/index.js +381 -574
- package/dist/server/index.d.ts +0 -1
- package/dist/server/index.js +60 -331
- package/dist/server/serve.d.ts +1 -1
- package/dist/server/serve.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -4
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +7 -3
- package/dist/ingest/billing.d.ts +0 -18
- package/dist/ingest/billing.d.ts.map +0 -1
- package/dist/lib/package-metadata.d.ts +0 -8
- package/dist/lib/package-metadata.d.ts.map +0 -1
package/dist/db/database.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SqliteAdapter as Database } from '@hasna/cloud';
|
|
2
2
|
import type { EconomyRequest, EconomySession, EconomyProject, Budget, BudgetStatus, CostSummary, ModelBreakdown, ProjectBreakdown, Period, SessionFilter } from '../types/index.js';
|
|
3
|
-
export declare function getMachineId(): string;
|
|
4
3
|
export declare function getDataDir(): string;
|
|
5
4
|
export declare function getDbPath(): string;
|
|
6
5
|
export declare function openDatabase(dbPath?: string, skipSeed?: boolean): Database;
|
|
@@ -9,7 +8,7 @@ export declare function upsertSession(db: Database, session: EconomySession): vo
|
|
|
9
8
|
export declare function rollupSession(db: Database, sessionId: string): void;
|
|
10
9
|
export declare function querySessions(db: Database, filter?: SessionFilter): EconomySession[];
|
|
11
10
|
export declare function queryTopSessions(db: Database, n?: number, agent?: string): EconomySession[];
|
|
12
|
-
export declare function querySummary(db: Database, period: Period
|
|
11
|
+
export declare function querySummary(db: Database, period: Period): CostSummary;
|
|
13
12
|
export declare function queryModelBreakdown(db: Database): ModelBreakdown[];
|
|
14
13
|
export declare function queryProjectBreakdown(db: Database): ProjectBreakdown[];
|
|
15
14
|
export declare function queryDailyBreakdown(db: Database, days?: number): Array<{
|
|
@@ -48,27 +47,6 @@ export declare function getGoalStatuses(db: Database): GoalStatus[];
|
|
|
48
47
|
export declare function getIngestState(db: Database, source: string, key: string): string | null;
|
|
49
48
|
export declare function setIngestState(db: Database, source: string, key: string, value: string): void;
|
|
50
49
|
export declare function queryRequestsSince(db: Database, since: string): EconomyRequest[];
|
|
51
|
-
export interface BillingDaily {
|
|
52
|
-
date: string;
|
|
53
|
-
provider: 'anthropic' | 'openai' | string;
|
|
54
|
-
description: string;
|
|
55
|
-
cost_usd: number;
|
|
56
|
-
updated_at: string;
|
|
57
|
-
}
|
|
58
|
-
export declare function upsertBillingDaily(db: Database, row: BillingDaily): void;
|
|
59
|
-
export declare function clearBillingRange(db: Database, provider: string, fromDate: string, toDate: string): void;
|
|
60
|
-
export declare function queryBillingSummary(db: Database, period: Period): {
|
|
61
|
-
total_usd: number;
|
|
62
|
-
by_provider: Record<string, number>;
|
|
63
|
-
};
|
|
64
|
-
export interface MachineInfo {
|
|
65
|
-
machine_id: string;
|
|
66
|
-
sessions: number;
|
|
67
|
-
requests: number;
|
|
68
|
-
total_cost_usd: number;
|
|
69
|
-
last_active: string;
|
|
70
|
-
}
|
|
71
|
-
export declare function listMachines(db: Database): MachineInfo[];
|
|
72
50
|
export interface DbModelPricing {
|
|
73
51
|
model: string;
|
|
74
52
|
input_per_1m: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-migrations.d.ts","sourceRoot":"","sources":["../../src/db/pg-migrations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"pg-migrations.d.ts","sourceRoot":"","sources":["../../src/db/pg-migrations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,aAAa,EAAE,MAAM,EAmGjC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -77,7 +77,6 @@ var DEFAULT_PRICING;
|
|
|
77
77
|
var init_pricing = __esm(() => {
|
|
78
78
|
init_database();
|
|
79
79
|
DEFAULT_PRICING = {
|
|
80
|
-
"claude-opus-4-7": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
81
80
|
"claude-opus-4-6": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
82
81
|
"claude-opus-4-5": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
83
82
|
"claude-sonnet-4-6": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
@@ -88,55 +87,28 @@ var init_pricing = __esm(() => {
|
|
|
88
87
|
"claude-3-opus": { inputPer1M: 15, outputPer1M: 75, cacheReadPer1M: 1.5, cacheWritePer1M: 18.75 },
|
|
89
88
|
"claude-3-sonnet": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
90
89
|
"claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25, cacheReadPer1M: 0.03, cacheWritePer1M: 0.3 },
|
|
91
|
-
"gemini-3.1-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0.31, cacheWritePer1M: 0 },
|
|
92
|
-
"gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
93
|
-
"gemini-2.5-flash": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
94
90
|
"gemini-2.0-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
91
|
+
"gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
95
92
|
"gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
96
93
|
"gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
97
|
-
"gpt-5.4": { inputPer1M: 2.5, outputPer1M: 15, cacheReadPer1M: 0.25, cacheWritePer1M: 0 },
|
|
98
|
-
"gpt-5.4-pro": { inputPer1M: 30, outputPer1M: 180, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
99
|
-
"gpt-5.4-mini": { inputPer1M: 0.75, outputPer1M: 4.5, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
100
94
|
"gpt-5.3-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
101
|
-
"gpt-5.3-chat": { inputPer1M: 2, outputPer1M: 8, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
102
95
|
"gpt-5.2-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
103
96
|
"gpt-5-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
104
|
-
"gpt-5-mini": { inputPer1M: 0.3, outputPer1M: 1.2, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
105
|
-
"gpt-5.2": { inputPer1M: 2, outputPer1M: 8, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
106
97
|
"gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
107
98
|
"gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
108
99
|
o1: { inputPer1M: 15, outputPer1M: 60, cacheReadPer1M: 7.5, cacheWritePer1M: 0 },
|
|
109
100
|
"o1-mini": { inputPer1M: 3, outputPer1M: 12, cacheReadPer1M: 1.5, cacheWritePer1M: 0 },
|
|
110
101
|
o3: { inputPer1M: 10, outputPer1M: 40, cacheReadPer1M: 2.5, cacheWritePer1M: 0 },
|
|
111
102
|
"o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.55, cacheWritePer1M: 0 },
|
|
112
|
-
"o4-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.275, cacheWritePer1M: 0 }
|
|
113
|
-
"qwen3.6-plus": { inputPer1M: 0.8, outputPer1M: 2, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
114
|
-
"qwen3.6": { inputPer1M: 0.3, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
115
|
-
"minimax-m2.7": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
116
|
-
"minimax-m2.7-highspeed": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
117
|
-
"minimax-m1": { inputPer1M: 0.2, outputPer1M: 1.1, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
118
|
-
"grok-3": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
119
|
-
"grok-3-mini": { inputPer1M: 0.3, outputPer1M: 0.5, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
120
|
-
"glm-5.1": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
121
|
-
"glm-5": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
122
|
-
"kimi-k2": { inputPer1M: 0.6, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 }
|
|
103
|
+
"o4-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.275, cacheWritePer1M: 0 }
|
|
123
104
|
};
|
|
124
105
|
});
|
|
125
106
|
|
|
126
107
|
// src/db/database.ts
|
|
127
108
|
import { SqliteAdapter as Database } from "@hasna/cloud";
|
|
128
109
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from "fs";
|
|
129
|
-
import { hostname } from "os";
|
|
130
110
|
import { homedir } from "os";
|
|
131
111
|
import { join } from "path";
|
|
132
|
-
function getMachineId() {
|
|
133
|
-
if (process.env["ECONOMY_MACHINE_ID"])
|
|
134
|
-
return process.env["ECONOMY_MACHINE_ID"];
|
|
135
|
-
const h = hostname().toLowerCase();
|
|
136
|
-
if (h.startsWith("spark") || h.startsWith("apple"))
|
|
137
|
-
return h.split(".")[0];
|
|
138
|
-
return h.split(".")[0];
|
|
139
|
-
}
|
|
140
112
|
function getDataDir() {
|
|
141
113
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || homedir();
|
|
142
114
|
const newDir = join(home, ".hasna", "economy");
|
|
@@ -169,7 +141,6 @@ function openDatabase(dbPath, skipSeed = false) {
|
|
|
169
141
|
}
|
|
170
142
|
const db = new Database(path);
|
|
171
143
|
db.exec("PRAGMA journal_mode = WAL");
|
|
172
|
-
db.exec("PRAGMA busy_timeout = 5000");
|
|
173
144
|
db.exec("PRAGMA foreign_keys = ON");
|
|
174
145
|
initSchema(db);
|
|
175
146
|
if (!skipSeed) {
|
|
@@ -191,8 +162,7 @@ function initSchema(db) {
|
|
|
191
162
|
cost_usd REAL NOT NULL DEFAULT 0,
|
|
192
163
|
duration_ms INTEGER DEFAULT 0,
|
|
193
164
|
timestamp TEXT NOT NULL,
|
|
194
|
-
source_request_id TEXT
|
|
195
|
-
machine_id TEXT DEFAULT ''
|
|
165
|
+
source_request_id TEXT
|
|
196
166
|
);
|
|
197
167
|
|
|
198
168
|
CREATE TABLE IF NOT EXISTS sessions (
|
|
@@ -204,8 +174,7 @@ function initSchema(db) {
|
|
|
204
174
|
ended_at TEXT,
|
|
205
175
|
total_cost_usd REAL DEFAULT 0,
|
|
206
176
|
total_tokens INTEGER DEFAULT 0,
|
|
207
|
-
request_count INTEGER DEFAULT 0
|
|
208
|
-
machine_id TEXT DEFAULT ''
|
|
177
|
+
request_count INTEGER DEFAULT 0
|
|
209
178
|
);
|
|
210
179
|
|
|
211
180
|
CREATE TABLE IF NOT EXISTS projects (
|
|
@@ -270,27 +239,6 @@ function initSchema(db) {
|
|
|
270
239
|
machine_id TEXT,
|
|
271
240
|
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
272
241
|
);
|
|
273
|
-
|
|
274
|
-
CREATE TABLE IF NOT EXISTS billing_daily (
|
|
275
|
-
date TEXT NOT NULL,
|
|
276
|
-
provider TEXT NOT NULL,
|
|
277
|
-
description TEXT DEFAULT '',
|
|
278
|
-
cost_usd REAL NOT NULL DEFAULT 0,
|
|
279
|
-
updated_at TEXT NOT NULL,
|
|
280
|
-
PRIMARY KEY (date, provider, description)
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
CREATE INDEX IF NOT EXISTS idx_billing_date ON billing_daily(date);
|
|
284
|
-
CREATE INDEX IF NOT EXISTS idx_billing_provider ON billing_daily(provider);
|
|
285
|
-
`);
|
|
286
|
-
const cols = db.prepare(`PRAGMA table_info(requests)`).all();
|
|
287
|
-
if (!cols.some((c) => c.name === "machine_id")) {
|
|
288
|
-
db.exec(`ALTER TABLE requests ADD COLUMN machine_id TEXT DEFAULT ''`);
|
|
289
|
-
db.exec(`ALTER TABLE sessions ADD COLUMN machine_id TEXT DEFAULT ''`);
|
|
290
|
-
}
|
|
291
|
-
db.exec(`
|
|
292
|
-
CREATE INDEX IF NOT EXISTS idx_requests_machine ON requests(machine_id);
|
|
293
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_machine ON sessions(machine_id);
|
|
294
242
|
`);
|
|
295
243
|
}
|
|
296
244
|
function periodWhere(period) {
|
|
@@ -300,11 +248,11 @@ function periodWhere(period) {
|
|
|
300
248
|
case "yesterday":
|
|
301
249
|
return `DATE(timestamp) = DATE('now', '-1 day')`;
|
|
302
250
|
case "week":
|
|
303
|
-
return `timestamp >= DATE('now', '
|
|
251
|
+
return `timestamp >= DATE('now', '-7 days')`;
|
|
304
252
|
case "month":
|
|
305
|
-
return `timestamp >= DATE('now', '
|
|
253
|
+
return `timestamp >= DATE('now', '-30 days')`;
|
|
306
254
|
case "year":
|
|
307
|
-
return `timestamp >= DATE('now', '
|
|
255
|
+
return `timestamp >= DATE('now', '-365 days')`;
|
|
308
256
|
case "all":
|
|
309
257
|
return "1=1";
|
|
310
258
|
}
|
|
@@ -316,11 +264,11 @@ function sessionPeriodWhere(period) {
|
|
|
316
264
|
case "yesterday":
|
|
317
265
|
return `DATE(started_at) = DATE('now', '-1 day')`;
|
|
318
266
|
case "week":
|
|
319
|
-
return `started_at >= DATE('now', '
|
|
267
|
+
return `started_at >= DATE('now', '-7 days')`;
|
|
320
268
|
case "month":
|
|
321
|
-
return `started_at >= DATE('now', '
|
|
269
|
+
return `started_at >= DATE('now', '-30 days')`;
|
|
322
270
|
case "year":
|
|
323
|
-
return `started_at >= DATE('now', '
|
|
271
|
+
return `started_at >= DATE('now', '-365 days')`;
|
|
324
272
|
case "all":
|
|
325
273
|
return "1=1";
|
|
326
274
|
}
|
|
@@ -330,17 +278,17 @@ function upsertRequest(db, req) {
|
|
|
330
278
|
INSERT OR REPLACE INTO requests
|
|
331
279
|
(id, agent, session_id, model, input_tokens, output_tokens,
|
|
332
280
|
cache_read_tokens, cache_create_tokens, cost_usd, duration_ms,
|
|
333
|
-
timestamp, source_request_id
|
|
334
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
|
335
|
-
`).run(req.id, req.agent, req.session_id, req.model, req.input_tokens, req.output_tokens, req.cache_read_tokens, req.cache_create_tokens, req.cost_usd, req.duration_ms, req.timestamp, req.source_request_id
|
|
281
|
+
timestamp, source_request_id)
|
|
282
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
283
|
+
`).run(req.id, req.agent, req.session_id, req.model, req.input_tokens, req.output_tokens, req.cache_read_tokens, req.cache_create_tokens, req.cost_usd, req.duration_ms, req.timestamp, req.source_request_id);
|
|
336
284
|
}
|
|
337
285
|
function upsertSession(db, session) {
|
|
338
286
|
db.prepare(`
|
|
339
287
|
INSERT OR REPLACE INTO sessions
|
|
340
288
|
(id, agent, project_path, project_name, started_at, ended_at,
|
|
341
|
-
total_cost_usd, total_tokens, request_count
|
|
342
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?,
|
|
343
|
-
`).run(session.id, session.agent, session.project_path, session.project_name, session.started_at, session.ended_at ?? null, session.total_cost_usd, session.total_tokens, session.request_count
|
|
289
|
+
total_cost_usd, total_tokens, request_count)
|
|
290
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
291
|
+
`).run(session.id, session.agent, session.project_path, session.project_name, session.started_at, session.ended_at ?? null, session.total_cost_usd, session.total_tokens, session.request_count);
|
|
344
292
|
}
|
|
345
293
|
function rollupSession(db, sessionId) {
|
|
346
294
|
db.prepare(`
|
|
@@ -370,10 +318,6 @@ function querySessions(db, filter = {}) {
|
|
|
370
318
|
conditions.push("started_at >= ?");
|
|
371
319
|
params.push(filter.since);
|
|
372
320
|
}
|
|
373
|
-
if (filter.machine) {
|
|
374
|
-
conditions.push("machine_id = ?");
|
|
375
|
-
params.push(filter.machine);
|
|
376
|
-
}
|
|
377
321
|
if (filter.search) {
|
|
378
322
|
const q = `%${filter.search}%`;
|
|
379
323
|
conditions.push("(project_name LIKE ? OR agent LIKE ? OR id LIKE ?)");
|
|
@@ -392,25 +336,24 @@ function queryTopSessions(db, n = 10, agent) {
|
|
|
392
336
|
}
|
|
393
337
|
return db.prepare(`SELECT * FROM sessions ORDER BY total_cost_usd DESC LIMIT ?`).all(n);
|
|
394
338
|
}
|
|
395
|
-
function querySummary(db, period
|
|
339
|
+
function querySummary(db, period) {
|
|
396
340
|
const rWhere = periodWhere(period);
|
|
397
341
|
const sWhere = sessionPeriodWhere(period);
|
|
398
|
-
const machineClause = machine ? ` AND machine_id = '${machine.replace(/'/g, "''")}'` : "";
|
|
399
342
|
const r = db.prepare(`
|
|
400
343
|
SELECT COALESCE(SUM(cost_usd), 0) as total_usd,
|
|
401
344
|
COUNT(*) as requests,
|
|
402
345
|
COALESCE(SUM(input_tokens + output_tokens + cache_read_tokens + cache_create_tokens), 0) as tokens
|
|
403
|
-
FROM requests WHERE ${rWhere}
|
|
346
|
+
FROM requests WHERE ${rWhere}
|
|
404
347
|
`).get();
|
|
405
348
|
const codexTotals = db.prepare(`
|
|
406
349
|
SELECT COALESCE(SUM(total_cost_usd), 0) as cost_usd,
|
|
407
350
|
COALESCE(SUM(total_tokens), 0) as tokens,
|
|
408
351
|
COUNT(*) as sessions
|
|
409
352
|
FROM sessions
|
|
410
|
-
WHERE ${sWhere}
|
|
353
|
+
WHERE ${sWhere}
|
|
411
354
|
AND id NOT IN (SELECT DISTINCT session_id FROM requests)
|
|
412
355
|
`).get();
|
|
413
|
-
const sessionCount = db.prepare(`SELECT COUNT(*) as sessions FROM sessions WHERE ${sWhere}
|
|
356
|
+
const sessionCount = db.prepare(`SELECT COUNT(*) as sessions FROM sessions WHERE ${sWhere}`).get();
|
|
414
357
|
return {
|
|
415
358
|
total_usd: r.total_usd + codexTotals.cost_usd,
|
|
416
359
|
requests: r.requests,
|
|
@@ -432,39 +375,19 @@ function queryModelBreakdown(db) {
|
|
|
432
375
|
}
|
|
433
376
|
function queryProjectBreakdown(db) {
|
|
434
377
|
return db.prepare(`
|
|
435
|
-
WITH labeled AS (
|
|
436
|
-
SELECT
|
|
437
|
-
s.id,
|
|
438
|
-
s.project_path,
|
|
439
|
-
s.total_cost_usd,
|
|
440
|
-
s.started_at,
|
|
441
|
-
COALESCE(
|
|
442
|
-
NULLIF(s.project_name, ''),
|
|
443
|
-
CASE
|
|
444
|
-
WHEN s.project_path LIKE '%/%'
|
|
445
|
-
THEN substr(s.project_path, length(rtrim(s.project_path, replace(s.project_path, '/', ''))) + 1)
|
|
446
|
-
ELSE s.project_path
|
|
447
|
-
END
|
|
448
|
-
) as label
|
|
449
|
-
FROM sessions s
|
|
450
|
-
WHERE s.project_path != '' OR s.project_name != ''
|
|
451
|
-
)
|
|
452
378
|
SELECT
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
COUNT(DISTINCT
|
|
456
|
-
|
|
457
|
-
COALESCE(
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
MAX(l.started_at) as last_active
|
|
466
|
-
FROM labeled l
|
|
467
|
-
GROUP BY l.label
|
|
379
|
+
s.project_path,
|
|
380
|
+
COALESCE(p.name, s.project_name) as project_name,
|
|
381
|
+
COUNT(DISTINCT s.id) as sessions,
|
|
382
|
+
COUNT(r.id) as requests,
|
|
383
|
+
COALESCE(SUM(r.cost_usd), COALESCE(SUM(s.total_cost_usd), 0)) as cost_usd,
|
|
384
|
+
COALESCE(SUM(r.input_tokens + r.output_tokens + r.cache_read_tokens + r.cache_create_tokens), 0) as total_tokens,
|
|
385
|
+
MAX(s.started_at) as last_active
|
|
386
|
+
FROM sessions s
|
|
387
|
+
LEFT JOIN projects p ON p.path = s.project_path OR p.name = s.project_name
|
|
388
|
+
LEFT JOIN requests r ON r.session_id = s.id
|
|
389
|
+
WHERE s.project_path != '' OR s.project_name != ''
|
|
390
|
+
GROUP BY s.project_path
|
|
468
391
|
ORDER BY cost_usd DESC
|
|
469
392
|
`).all();
|
|
470
393
|
}
|
|
@@ -584,40 +507,6 @@ function setIngestState(db, source, key, value) {
|
|
|
584
507
|
function queryRequestsSince(db, since) {
|
|
585
508
|
return db.prepare(`SELECT * FROM requests WHERE timestamp > ? ORDER BY timestamp ASC`).all(since);
|
|
586
509
|
}
|
|
587
|
-
function upsertBillingDaily(db, row) {
|
|
588
|
-
db.prepare(`
|
|
589
|
-
INSERT OR REPLACE INTO billing_daily (date, provider, description, cost_usd, updated_at)
|
|
590
|
-
VALUES (?, ?, ?, ?, ?)
|
|
591
|
-
`).run(row.date, row.provider, row.description, row.cost_usd, row.updated_at);
|
|
592
|
-
}
|
|
593
|
-
function clearBillingRange(db, provider, fromDate, toDate) {
|
|
594
|
-
db.prepare(`DELETE FROM billing_daily WHERE provider = ? AND date >= ? AND date <= ?`).run(provider, fromDate, toDate);
|
|
595
|
-
}
|
|
596
|
-
function queryBillingSummary(db, period) {
|
|
597
|
-
const where = period === "today" ? `date = DATE('now')` : period === "yesterday" ? `date = DATE('now', '-1 day')` : period === "week" ? `date >= DATE('now', 'weekday 0', '-7 days')` : period === "month" ? `date >= DATE('now', 'start of month')` : period === "year" ? `date >= DATE('now', 'start of year')` : "1=1";
|
|
598
|
-
const rows = db.prepare(`SELECT provider, SUM(cost_usd) as cost FROM billing_daily WHERE ${where} GROUP BY provider`).all();
|
|
599
|
-
const by_provider = {};
|
|
600
|
-
let total = 0;
|
|
601
|
-
for (const r of rows) {
|
|
602
|
-
by_provider[r.provider] = r.cost;
|
|
603
|
-
total += r.cost;
|
|
604
|
-
}
|
|
605
|
-
return { total_usd: total, by_provider };
|
|
606
|
-
}
|
|
607
|
-
function listMachines(db) {
|
|
608
|
-
return db.prepare(`
|
|
609
|
-
SELECT
|
|
610
|
-
s.machine_id,
|
|
611
|
-
COUNT(DISTINCT s.id) as sessions,
|
|
612
|
-
COALESCE((SELECT COUNT(*) FROM requests r WHERE r.machine_id = s.machine_id), 0) as requests,
|
|
613
|
-
COALESCE(SUM(s.total_cost_usd), 0) as total_cost_usd,
|
|
614
|
-
MAX(s.started_at) as last_active
|
|
615
|
-
FROM sessions s
|
|
616
|
-
WHERE s.machine_id != ''
|
|
617
|
-
GROUP BY s.machine_id
|
|
618
|
-
ORDER BY total_cost_usd DESC
|
|
619
|
-
`).all();
|
|
620
|
-
}
|
|
621
510
|
function upsertModelPricing(db, p) {
|
|
622
511
|
db.prepare(`
|
|
623
512
|
INSERT OR REPLACE INTO model_pricing
|
|
@@ -635,11 +524,11 @@ function deleteModelPricing(db, model) {
|
|
|
635
524
|
db.prepare(`DELETE FROM model_pricing WHERE model = ?`).run(model);
|
|
636
525
|
}
|
|
637
526
|
function seedModelPricing(db, defaults) {
|
|
638
|
-
const existing =
|
|
527
|
+
const existing = db.prepare(`SELECT COUNT(*) as count FROM model_pricing`).get();
|
|
528
|
+
if (existing.count > 0)
|
|
529
|
+
return;
|
|
639
530
|
const now = new Date().toISOString();
|
|
640
531
|
for (const [model, p] of Object.entries(defaults)) {
|
|
641
|
-
if (existing.has(model))
|
|
642
|
-
continue;
|
|
643
532
|
upsertModelPricing(db, {
|
|
644
533
|
model,
|
|
645
534
|
input_per_1m: p.inputPer1M,
|
|
@@ -880,8 +769,7 @@ import { join as join3, basename } from "path";
|
|
|
880
769
|
function autoDetectProject(cwd, projects) {
|
|
881
770
|
return projects.find((p) => cwd === p.path || cwd.startsWith(p.path + "/"));
|
|
882
771
|
}
|
|
883
|
-
var
|
|
884
|
-
var TAKUMI_PROJECTS_DIR = join3(homedir2(), ".takumi", "projects");
|
|
772
|
+
var PROJECTS_DIR = join3(homedir2(), ".claude", "projects");
|
|
885
773
|
function dirNameToPath(dirName) {
|
|
886
774
|
return dirName.replace(/^-/, "/").replace(/-/g, "/").replace(/\/\//g, "/-");
|
|
887
775
|
}
|
|
@@ -901,36 +789,29 @@ function collectJsonlFiles(projectDir) {
|
|
|
901
789
|
return files;
|
|
902
790
|
}
|
|
903
791
|
async function ingestClaude(db, verbose = false, _telemetryDir) {
|
|
904
|
-
|
|
905
|
-
}
|
|
906
|
-
async function ingestTakumi(db, verbose = false) {
|
|
907
|
-
return ingestJsonlProjects(db, TAKUMI_PROJECTS_DIR, "takumi", verbose);
|
|
908
|
-
}
|
|
909
|
-
async function ingestJsonlProjects(db, projectsDir, agentName, verbose = false) {
|
|
910
|
-
if (!existsSync3(projectsDir)) {
|
|
792
|
+
if (!existsSync3(PROJECTS_DIR)) {
|
|
911
793
|
if (verbose)
|
|
912
|
-
console.log(
|
|
794
|
+
console.log("Claude projects dir not found:", PROJECTS_DIR);
|
|
913
795
|
return { files: 0, requests: 0, sessions: 0 };
|
|
914
796
|
}
|
|
915
|
-
const machineId = getMachineId();
|
|
916
797
|
let totalFiles = 0;
|
|
917
798
|
let totalRequests = 0;
|
|
918
799
|
const touchedSessions = new Set;
|
|
919
800
|
const registeredProjects = db.prepare(`SELECT path, name FROM projects ORDER BY LENGTH(path) DESC`).all();
|
|
920
|
-
const projectDirs = readdirSync2(
|
|
801
|
+
const projectDirs = readdirSync2(PROJECTS_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
921
802
|
for (const projectDirEntry of projectDirs) {
|
|
922
|
-
const projectDirPath = join3(
|
|
803
|
+
const projectDirPath = join3(PROJECTS_DIR, projectDirEntry.name);
|
|
923
804
|
const projectPath = dirNameToPath(projectDirEntry.name);
|
|
924
805
|
const jsonlFiles = collectJsonlFiles(projectDirPath);
|
|
925
806
|
for (const filePath of jsonlFiles) {
|
|
926
|
-
const stateKey = filePath.replace(
|
|
807
|
+
const stateKey = filePath.replace(PROJECTS_DIR, "");
|
|
927
808
|
let fileMtime = "0";
|
|
928
809
|
try {
|
|
929
810
|
fileMtime = statSync2(filePath).mtimeMs.toString();
|
|
930
811
|
} catch {
|
|
931
812
|
continue;
|
|
932
813
|
}
|
|
933
|
-
const processed = getIngestState(db,
|
|
814
|
+
const processed = getIngestState(db, "claude", stateKey);
|
|
934
815
|
if (processed === fileMtime)
|
|
935
816
|
continue;
|
|
936
817
|
let lines;
|
|
@@ -971,10 +852,10 @@ async function ingestJsonlProjects(db, projectsDir, agentName, verbose = false)
|
|
|
971
852
|
if (inputTokens + outputTokens + cacheWriteTokens === 0)
|
|
972
853
|
continue;
|
|
973
854
|
const costUsd = computeCostFromDb(db, model, inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens);
|
|
974
|
-
const reqId =
|
|
855
|
+
const reqId = `claude-${sessionId}-${timestamp}`;
|
|
975
856
|
upsertRequest(db, {
|
|
976
857
|
id: reqId,
|
|
977
|
-
agent:
|
|
858
|
+
agent: "claude",
|
|
978
859
|
session_id: sessionId,
|
|
979
860
|
model,
|
|
980
861
|
input_tokens: inputTokens,
|
|
@@ -984,8 +865,7 @@ async function ingestJsonlProjects(db, projectsDir, agentName, verbose = false)
|
|
|
984
865
|
cost_usd: costUsd,
|
|
985
866
|
duration_ms: 0,
|
|
986
867
|
timestamp,
|
|
987
|
-
source_request_id: reqId
|
|
988
|
-
machine_id: machineId
|
|
868
|
+
source_request_id: reqId
|
|
989
869
|
});
|
|
990
870
|
if (!touchedSessions.has(sessionId)) {
|
|
991
871
|
const existing = db.prepare(`SELECT id FROM sessions WHERE id = ?`).get(sessionId);
|
|
@@ -994,15 +874,14 @@ async function ingestJsonlProjects(db, projectsDir, agentName, verbose = false)
|
|
|
994
874
|
const detectedProject = autoDetectProject(effectiveCwd, registeredProjects);
|
|
995
875
|
const session = {
|
|
996
876
|
id: sessionId,
|
|
997
|
-
agent:
|
|
877
|
+
agent: "claude",
|
|
998
878
|
project_path: detectedProject ? detectedProject.path : effectiveCwd,
|
|
999
879
|
project_name: detectedProject ? detectedProject.name : "",
|
|
1000
880
|
started_at: timestamp,
|
|
1001
881
|
ended_at: null,
|
|
1002
882
|
total_cost_usd: 0,
|
|
1003
883
|
total_tokens: 0,
|
|
1004
|
-
request_count: 0
|
|
1005
|
-
machine_id: machineId
|
|
884
|
+
request_count: 0
|
|
1006
885
|
};
|
|
1007
886
|
upsertSession(db, session);
|
|
1008
887
|
}
|
|
@@ -1010,7 +889,7 @@ async function ingestJsonlProjects(db, projectsDir, agentName, verbose = false)
|
|
|
1010
889
|
}
|
|
1011
890
|
totalRequests++;
|
|
1012
891
|
}
|
|
1013
|
-
setIngestState(db,
|
|
892
|
+
setIngestState(db, "claude", stateKey, fileMtime);
|
|
1014
893
|
totalFiles++;
|
|
1015
894
|
}
|
|
1016
895
|
}
|
|
@@ -1024,7 +903,7 @@ init_database();
|
|
|
1024
903
|
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
1025
904
|
import { homedir as homedir3 } from "os";
|
|
1026
905
|
import { join as join4, basename as basename2 } from "path";
|
|
1027
|
-
import { Database as
|
|
906
|
+
import { Database as Database2 } from "bun:sqlite";
|
|
1028
907
|
var CODEX_DB_PATH = join4(homedir3(), ".codex", "state_5.sqlite");
|
|
1029
908
|
var CODEX_CONFIG_PATH = join4(homedir3(), ".codex", "config.toml");
|
|
1030
909
|
function readCodexModel() {
|
|
@@ -1044,11 +923,10 @@ async function ingestCodex(db, verbose = false) {
|
|
|
1044
923
|
console.log("Codex DB not found:", CODEX_DB_PATH);
|
|
1045
924
|
return { sessions: 0 };
|
|
1046
925
|
}
|
|
1047
|
-
const machineId = getMachineId();
|
|
1048
926
|
let codexDb = null;
|
|
1049
927
|
let ingested = 0;
|
|
1050
928
|
try {
|
|
1051
|
-
codexDb = new
|
|
929
|
+
codexDb = new Database2(CODEX_DB_PATH, { readonly: true });
|
|
1052
930
|
const threads = codexDb.prepare(`SELECT id, cwd, created_at, updated_at, tokens_used, title FROM threads WHERE tokens_used > 0`).all();
|
|
1053
931
|
for (const thread of threads) {
|
|
1054
932
|
const stateKey = thread.id;
|
|
@@ -1069,8 +947,7 @@ async function ingestCodex(db, verbose = false) {
|
|
|
1069
947
|
ended_at: endedAt,
|
|
1070
948
|
total_cost_usd: costUsd,
|
|
1071
949
|
total_tokens: thread.tokens_used,
|
|
1072
|
-
request_count: 1
|
|
1073
|
-
machine_id: machineId
|
|
950
|
+
request_count: 1
|
|
1074
951
|
});
|
|
1075
952
|
setIngestState(db, "codex", stateKey, "done");
|
|
1076
953
|
ingested++;
|
|
@@ -1089,7 +966,6 @@ export {
|
|
|
1089
966
|
upsertModelPricing,
|
|
1090
967
|
upsertGoal,
|
|
1091
968
|
upsertBudget,
|
|
1092
|
-
upsertBillingDaily,
|
|
1093
969
|
setIngestState,
|
|
1094
970
|
setActiveModel,
|
|
1095
971
|
seedModelPricing,
|
|
@@ -1102,22 +978,18 @@ export {
|
|
|
1102
978
|
queryProjectBreakdown,
|
|
1103
979
|
queryModelBreakdown,
|
|
1104
980
|
queryDailyBreakdown,
|
|
1105
|
-
queryBillingSummary,
|
|
1106
981
|
openDatabase,
|
|
1107
982
|
normalizeModelName,
|
|
1108
983
|
listProjects,
|
|
1109
984
|
listModelPricing,
|
|
1110
|
-
listMachines,
|
|
1111
985
|
listGoals,
|
|
1112
986
|
listBudgets,
|
|
1113
|
-
ingestTakumi,
|
|
1114
987
|
ingestCodex,
|
|
1115
988
|
ingestClaude,
|
|
1116
989
|
getProject,
|
|
1117
990
|
getPricingFromDb,
|
|
1118
991
|
getPricing,
|
|
1119
992
|
getModelPricing,
|
|
1120
|
-
getMachineId,
|
|
1121
993
|
getIngestState,
|
|
1122
994
|
getGoalStatuses,
|
|
1123
995
|
getDbPath,
|
|
@@ -1132,7 +1004,6 @@ export {
|
|
|
1132
1004
|
deleteBudget,
|
|
1133
1005
|
computeCostFromDb,
|
|
1134
1006
|
computeCost,
|
|
1135
|
-
clearBillingRange,
|
|
1136
1007
|
clearActiveModel,
|
|
1137
1008
|
DEFAULT_PRICING,
|
|
1138
1009
|
DEFAULT_MODEL
|
package/dist/ingest/claude.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Database } from 'bun:sqlite';
|
|
2
2
|
export declare function ingestClaude(db: Database, verbose?: boolean, _telemetryDir?: string): Promise<{
|
|
3
3
|
files: number;
|
|
4
4
|
requests: number;
|
|
5
5
|
sessions: number;
|
|
6
6
|
}>;
|
|
7
|
-
export declare function ingestTakumi(db: Database, verbose?: boolean): Promise<{
|
|
8
|
-
files: number;
|
|
9
|
-
requests: number;
|
|
10
|
-
sessions: number;
|
|
11
|
-
}>;
|
|
12
7
|
//# sourceMappingURL=claude.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/ingest/claude.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/ingest/claude.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AA2DrC,wBAAsB,YAAY,CAChC,EAAE,EAAE,QAAQ,EACZ,OAAO,UAAQ,EACf,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA2HhE"}
|
package/dist/ingest/codex.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/ingest/codex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/ingest/codex.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAkBrC,iBAAS,cAAc,IAAI,MAAM,CAShC;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAyD9F;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
package/dist/ingest/gemini.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../src/ingest/gemini.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../src/ingest/gemini.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AA0BrC,wBAAsB,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA2EjG"}
|
package/dist/lib/pricing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Database } from 'bun:sqlite';
|
|
2
2
|
import type { ModelPricing } from '../types/index.js';
|
|
3
3
|
export declare const DEFAULT_PRICING: Record<string, ModelPricing>;
|
|
4
4
|
export declare function normalizeModelName(raw: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/lib/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/lib/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKrD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CA6BxD,CAAA;AAGD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKtD;AAGD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAEtD;AAGD,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAuBjF;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAO7D;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,eAAe,SAAI,EACnB,gBAAgB,SAAI,GACnB,MAAM,CASR;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,eAAe,SAAI,EACnB,gBAAgB,SAAI,GACnB,MAAM,CASR"}
|
package/dist/lib/webhooks.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/lib/webhooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/lib/webhooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBtE"}
|