@hasna/economy 0.2.13 → 0.2.15
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/dist/cli/index.js +134 -97
- package/dist/db/database.d.ts.map +1 -1
- package/dist/index.js +24 -5
- package/dist/lib/pricing.d.ts.map +1 -1
- package/dist/mcp/index.js +24 -5
- package/dist/server/index.js +24 -5
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -79,6 +79,7 @@ var DEFAULT_PRICING;
|
|
|
79
79
|
var init_pricing = __esm(() => {
|
|
80
80
|
init_database();
|
|
81
81
|
DEFAULT_PRICING = {
|
|
82
|
+
"claude-opus-4-7": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
82
83
|
"claude-opus-4-6": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
83
84
|
"claude-opus-4-5": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
84
85
|
"claude-sonnet-4-6": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
@@ -89,24 +90,79 @@ var init_pricing = __esm(() => {
|
|
|
89
90
|
"claude-3-opus": { inputPer1M: 15, outputPer1M: 75, cacheReadPer1M: 1.5, cacheWritePer1M: 18.75 },
|
|
90
91
|
"claude-3-sonnet": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
91
92
|
"claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25, cacheReadPer1M: 0.03, cacheWritePer1M: 0.3 },
|
|
92
|
-
"gemini-
|
|
93
|
+
"gemini-3.1-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0.31, cacheWritePer1M: 0 },
|
|
93
94
|
"gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
95
|
+
"gemini-2.5-flash": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
96
|
+
"gemini-2.0-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
94
97
|
"gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
95
98
|
"gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
99
|
+
"gpt-5.4": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 0.625, cacheWritePer1M: 0 },
|
|
100
|
+
"gpt-5.4-pro": { inputPer1M: 5, outputPer1M: 20, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
101
|
+
"gpt-5.4-mini": { inputPer1M: 0.3, outputPer1M: 1.2, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
96
102
|
"gpt-5.3-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
103
|
+
"gpt-5.3-chat": { inputPer1M: 2, outputPer1M: 8, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
97
104
|
"gpt-5.2-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
98
105
|
"gpt-5-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
106
|
+
"gpt-5-mini": { inputPer1M: 0.3, outputPer1M: 1.2, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
107
|
+
"gpt-5.2": { inputPer1M: 2, outputPer1M: 8, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
99
108
|
"gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
100
109
|
"gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
101
110
|
o1: { inputPer1M: 15, outputPer1M: 60, cacheReadPer1M: 7.5, cacheWritePer1M: 0 },
|
|
102
111
|
"o1-mini": { inputPer1M: 3, outputPer1M: 12, cacheReadPer1M: 1.5, cacheWritePer1M: 0 },
|
|
103
112
|
o3: { inputPer1M: 10, outputPer1M: 40, cacheReadPer1M: 2.5, cacheWritePer1M: 0 },
|
|
104
113
|
"o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.55, cacheWritePer1M: 0 },
|
|
105
|
-
"o4-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.275, cacheWritePer1M: 0 }
|
|
114
|
+
"o4-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.275, cacheWritePer1M: 0 },
|
|
115
|
+
"qwen3.6-plus": { inputPer1M: 0.8, outputPer1M: 2, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
116
|
+
"qwen3.6": { inputPer1M: 0.3, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
117
|
+
"minimax-m2.7": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
118
|
+
"minimax-m2.7-highspeed": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
119
|
+
"minimax-m1": { inputPer1M: 0.2, outputPer1M: 1.1, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
120
|
+
"grok-3": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
121
|
+
"grok-3-mini": { inputPer1M: 0.3, outputPer1M: 0.5, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
122
|
+
"glm-5.1": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
123
|
+
"glm-5": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
124
|
+
"kimi-k2": { inputPer1M: 0.6, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 }
|
|
106
125
|
};
|
|
107
126
|
});
|
|
108
127
|
|
|
109
128
|
// src/db/database.ts
|
|
129
|
+
var exports_database = {};
|
|
130
|
+
__export(exports_database, {
|
|
131
|
+
upsertSession: () => upsertSession,
|
|
132
|
+
upsertRequest: () => upsertRequest,
|
|
133
|
+
upsertProject: () => upsertProject,
|
|
134
|
+
upsertModelPricing: () => upsertModelPricing,
|
|
135
|
+
upsertGoal: () => upsertGoal,
|
|
136
|
+
upsertBudget: () => upsertBudget,
|
|
137
|
+
setIngestState: () => setIngestState,
|
|
138
|
+
seedModelPricing: () => seedModelPricing,
|
|
139
|
+
rollupSession: () => rollupSession,
|
|
140
|
+
queryTopSessions: () => queryTopSessions,
|
|
141
|
+
querySummary: () => querySummary,
|
|
142
|
+
querySessions: () => querySessions,
|
|
143
|
+
queryRequestsSince: () => queryRequestsSince,
|
|
144
|
+
queryProjectBreakdown: () => queryProjectBreakdown,
|
|
145
|
+
queryModelBreakdown: () => queryModelBreakdown,
|
|
146
|
+
queryDailyBreakdown: () => queryDailyBreakdown,
|
|
147
|
+
openDatabase: () => openDatabase,
|
|
148
|
+
listProjects: () => listProjects,
|
|
149
|
+
listModelPricing: () => listModelPricing,
|
|
150
|
+
listMachines: () => listMachines,
|
|
151
|
+
listGoals: () => listGoals,
|
|
152
|
+
listBudgets: () => listBudgets,
|
|
153
|
+
getProject: () => getProject,
|
|
154
|
+
getModelPricing: () => getModelPricing,
|
|
155
|
+
getMachineId: () => getMachineId,
|
|
156
|
+
getIngestState: () => getIngestState,
|
|
157
|
+
getGoalStatuses: () => getGoalStatuses,
|
|
158
|
+
getDbPath: () => getDbPath,
|
|
159
|
+
getDataDir: () => getDataDir,
|
|
160
|
+
getBudgetStatuses: () => getBudgetStatuses,
|
|
161
|
+
deleteProject: () => deleteProject,
|
|
162
|
+
deleteModelPricing: () => deleteModelPricing,
|
|
163
|
+
deleteGoal: () => deleteGoal,
|
|
164
|
+
deleteBudget: () => deleteBudget
|
|
165
|
+
});
|
|
110
166
|
import { SqliteAdapter as Database } from "@hasna/cloud";
|
|
111
167
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from "fs";
|
|
112
168
|
import { hostname } from "os";
|
|
@@ -566,11 +622,11 @@ function deleteModelPricing(db, model) {
|
|
|
566
622
|
db.prepare(`DELETE FROM model_pricing WHERE model = ?`).run(model);
|
|
567
623
|
}
|
|
568
624
|
function seedModelPricing(db, defaults) {
|
|
569
|
-
const existing = db.prepare(`SELECT
|
|
570
|
-
if (existing.count > 0)
|
|
571
|
-
return;
|
|
625
|
+
const existing = new Set(db.prepare(`SELECT model FROM model_pricing`).all().map((r) => r.model));
|
|
572
626
|
const now = new Date().toISOString();
|
|
573
627
|
for (const [model, p] of Object.entries(defaults)) {
|
|
628
|
+
if (existing.has(model))
|
|
629
|
+
continue;
|
|
574
630
|
upsertModelPricing(db, {
|
|
575
631
|
model,
|
|
576
632
|
input_per_1m: p.inputPer1M,
|
|
@@ -2054,7 +2110,7 @@ program.action(async () => {
|
|
|
2054
2110
|
}
|
|
2055
2111
|
console.log();
|
|
2056
2112
|
});
|
|
2057
|
-
program.command("sync").description("Ingest cost data from Claude Code, Codex, and Gemini").option("--claude", "Only ingest Claude Code telemetry").option("--takumi", "Only ingest Takumi sessions").option("--codex", "Only ingest Codex sessions").option("--gemini", "Only ingest Gemini CLI sessions").option("-v, --verbose", "Verbose output").option("--force", "Force re-process all files (ignore mtime cache)").option("--backfill-machine", "Tag existing records that have no machine_id with current hostname").action(async (opts) => {
|
|
2113
|
+
program.command("sync").description("Ingest cost data from Claude Code, Codex, and Gemini").option("--claude", "Only ingest Claude Code telemetry").option("--takumi", "Only ingest Takumi sessions").option("--codex", "Only ingest Codex sessions").option("--gemini", "Only ingest Gemini CLI sessions").option("-v, --verbose", "Verbose output").option("--force", "Force re-process all files (ignore mtime cache)").option("--backfill-machine", "Tag existing records that have no machine_id with current hostname").option("--recalculate", "Recalculate costs for all requests with cost_usd = 0").action(async (opts) => {
|
|
2058
2114
|
const db = openDatabase();
|
|
2059
2115
|
ensurePricingSeeded(db);
|
|
2060
2116
|
if (opts.force) {
|
|
@@ -2093,6 +2149,29 @@ program.command("sync").description("Ingest cost data from Claude Code, Codex, a
|
|
|
2093
2149
|
const sessCount = db.prepare(`UPDATE sessions SET machine_id = ? WHERE machine_id = '' OR machine_id IS NULL`).run(machine);
|
|
2094
2150
|
console.log(chalk4.cyan(`\u2192 Backfilled machine_id='${machine}': ${reqCount.changes} requests, ${sessCount.changes} sessions`));
|
|
2095
2151
|
}
|
|
2152
|
+
if (opts.recalculate) {
|
|
2153
|
+
const { computeCostFromDb: computeCostFromDb2 } = await Promise.resolve().then(() => (init_pricing(), exports_pricing));
|
|
2154
|
+
const zeroRows = db.prepare(`SELECT id, model, input_tokens, output_tokens, cache_read_tokens, cache_create_tokens FROM requests WHERE cost_usd = 0 AND (input_tokens > 0 OR output_tokens > 0)`).all();
|
|
2155
|
+
let fixed = 0;
|
|
2156
|
+
for (const r of zeroRows) {
|
|
2157
|
+
const cost = computeCostFromDb2(db, r.model, r.input_tokens, r.output_tokens, r.cache_read_tokens, r.cache_create_tokens);
|
|
2158
|
+
if (cost > 0) {
|
|
2159
|
+
db.prepare(`UPDATE requests SET cost_usd = ? WHERE id = ?`).run(cost, r.id);
|
|
2160
|
+
fixed++;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
if (fixed > 0) {
|
|
2164
|
+
const touchedSessions = new Set(zeroRows.map((r) => {
|
|
2165
|
+
const row = db.prepare(`SELECT session_id FROM requests WHERE id = ?`).get(r.id);
|
|
2166
|
+
return row?.session_id;
|
|
2167
|
+
}).filter(Boolean));
|
|
2168
|
+
const { rollupSession: rollupSession2 } = await Promise.resolve().then(() => (init_database(), exports_database));
|
|
2169
|
+
for (const sid of touchedSessions) {
|
|
2170
|
+
rollupSession2(db, sid);
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
console.log(chalk4.cyan(`\u2192 Recalculated: ${fixed}/${zeroRows.length} zero-cost requests now have pricing`));
|
|
2174
|
+
}
|
|
2096
2175
|
try {
|
|
2097
2176
|
const { checkAndFireWebhooks: checkAndFireWebhooks2 } = await Promise.resolve().then(() => (init_webhooks(), exports_webhooks));
|
|
2098
2177
|
await checkAndFireWebhooks2(db);
|
|
@@ -2858,24 +2937,34 @@ program.command("remove <type> <id>").alias("rm").description("Remove a record.
|
|
|
2858
2937
|
process.exit(1);
|
|
2859
2938
|
}
|
|
2860
2939
|
});
|
|
2940
|
+
var CLOUD_RDS_HOST = "hasnaxyz-prod-opensource.c4limg0qgqvk.us-east-1.rds.amazonaws.com";
|
|
2941
|
+
var CLOUD_RDS_USER = "hasna_admin";
|
|
2942
|
+
var CLOUD_RDS_DB = "economy";
|
|
2943
|
+
var CLOUD_TABLES = ["requests", "sessions", "projects", "budgets", "goals", "model_pricing"];
|
|
2944
|
+
async function getCloudPassword() {
|
|
2945
|
+
if (process.env["ECONOMY_PG_PASSWORD"])
|
|
2946
|
+
return process.env["ECONOMY_PG_PASSWORD"];
|
|
2947
|
+
const { execSync: exec } = await import("child_process");
|
|
2948
|
+
const secretJson = exec(`aws --profile hasna-xyz-hq secretsmanager get-secret-value --secret-id 'rds!db-7a451ce6-83a9-40fa-b24a-81e5d5943511' --query SecretString --output text`, { timeout: 1e4, encoding: "utf-8" });
|
|
2949
|
+
return JSON.parse(secretJson).password;
|
|
2950
|
+
}
|
|
2951
|
+
async function getCloudPg() {
|
|
2952
|
+
const { PgAdapterAsync } = await import("@hasna/cloud");
|
|
2953
|
+
const pw = encodeURIComponent(await getCloudPassword());
|
|
2954
|
+
return new PgAdapterAsync(`postgresql://${CLOUD_RDS_USER}:${pw}@${CLOUD_RDS_HOST}:5432/${CLOUD_RDS_DB}?sslmode=require`);
|
|
2955
|
+
}
|
|
2861
2956
|
var cloudCmd = program.command("cloud").description("Cross-machine sync via cloud PostgreSQL");
|
|
2862
2957
|
cloudCmd.command("push").description("Push local economy data to cloud PostgreSQL").option("--tables <tables>", "Comma-separated table names (default: all)").action(async (opts) => {
|
|
2863
|
-
const { syncPush,
|
|
2958
|
+
const { syncPush, SqliteAdapter } = await import("@hasna/cloud");
|
|
2864
2959
|
const { PG_MIGRATIONS: PG_MIGRATIONS2 } = await Promise.resolve().then(() => (init_pg_migrations(), exports_pg_migrations));
|
|
2865
|
-
const
|
|
2866
|
-
if (!config.rds?.host) {
|
|
2867
|
-
console.error(chalk4.red("Cloud not configured. Set RDS host in ~/.hasna/cloud.json"));
|
|
2868
|
-
process.exit(1);
|
|
2869
|
-
}
|
|
2870
|
-
const connStr = `postgresql://${config.rds.username}:${process.env[config.rds.password_env] ?? ""}@${config.rds.host}:${config.rds.port ?? 5432}/economy?sslmode=require`;
|
|
2960
|
+
const cloud = await getCloudPg();
|
|
2871
2961
|
const local = new SqliteAdapter(getDbPath());
|
|
2872
|
-
const cloud = new PgAdapterAsync(connStr);
|
|
2873
2962
|
process.stdout.write(chalk4.cyan("\u2192 Running PG migrations... "));
|
|
2874
2963
|
for (const sql of PG_MIGRATIONS2) {
|
|
2875
2964
|
await cloud.run(sql);
|
|
2876
2965
|
}
|
|
2877
2966
|
console.log(chalk4.green("\u2713"));
|
|
2878
|
-
const tableList = opts.tables ? opts.tables.split(",").map((t) => t.trim()) :
|
|
2967
|
+
const tableList = opts.tables ? opts.tables.split(",").map((t) => t.trim()) : CLOUD_TABLES;
|
|
2879
2968
|
process.stdout.write(chalk4.cyan(`\u2192 Pushing ${tableList.join(", ")}... `));
|
|
2880
2969
|
const results = await syncPush(local, cloud, { tables: tableList });
|
|
2881
2970
|
const totalRows = results.reduce((s, r) => s + r.rowsWritten, 0);
|
|
@@ -2886,22 +2975,16 @@ cloudCmd.command("push").description("Push local economy data to cloud PostgreSQ
|
|
|
2886
2975
|
\u2713 Push complete from ${getMachineId()}`));
|
|
2887
2976
|
});
|
|
2888
2977
|
cloudCmd.command("pull").description("Pull cloud PostgreSQL data to local").option("--tables <tables>", "Comma-separated table names (default: all)").action(async (opts) => {
|
|
2889
|
-
const { syncPull,
|
|
2978
|
+
const { syncPull, SqliteAdapter } = await import("@hasna/cloud");
|
|
2890
2979
|
const { PG_MIGRATIONS: PG_MIGRATIONS2 } = await Promise.resolve().then(() => (init_pg_migrations(), exports_pg_migrations));
|
|
2891
|
-
const
|
|
2892
|
-
if (!config.rds?.host) {
|
|
2893
|
-
console.error(chalk4.red("Cloud not configured. Set RDS host in ~/.hasna/cloud.json"));
|
|
2894
|
-
process.exit(1);
|
|
2895
|
-
}
|
|
2896
|
-
const connStr = `postgresql://${config.rds.username}:${process.env[config.rds.password_env] ?? ""}@${config.rds.host}:${config.rds.port ?? 5432}/economy?sslmode=require`;
|
|
2980
|
+
const cloud = await getCloudPg();
|
|
2897
2981
|
const local = new SqliteAdapter(getDbPath());
|
|
2898
|
-
const cloud = new PgAdapterAsync(connStr);
|
|
2899
2982
|
process.stdout.write(chalk4.cyan("\u2192 Running PG migrations... "));
|
|
2900
2983
|
for (const sql of PG_MIGRATIONS2) {
|
|
2901
2984
|
await cloud.run(sql);
|
|
2902
2985
|
}
|
|
2903
2986
|
console.log(chalk4.green("\u2713"));
|
|
2904
|
-
const tableList = opts.tables ? opts.tables.split(",").map((t) => t.trim()) :
|
|
2987
|
+
const tableList = opts.tables ? opts.tables.split(",").map((t) => t.trim()) : CLOUD_TABLES;
|
|
2905
2988
|
process.stdout.write(chalk4.cyan(`\u2192 Pulling ${tableList.join(", ")}... `));
|
|
2906
2989
|
const results = await syncPull(cloud, local, { tables: tableList });
|
|
2907
2990
|
const totalRows = results.reduce((s, r) => s + r.rowsWritten, 0);
|
|
@@ -2911,90 +2994,44 @@ cloudCmd.command("pull").description("Pull cloud PostgreSQL data to local").opti
|
|
|
2911
2994
|
console.log(chalk4.bold.green(`
|
|
2912
2995
|
\u2713 Pull complete to ${getMachineId()}`));
|
|
2913
2996
|
});
|
|
2914
|
-
cloudCmd.command("sync").description("Full sync: ingest local
|
|
2915
|
-
|
|
2916
|
-
console.log(chalk4.bold.cyan(` Cloud Sync \u2014 ${thisMachine}
|
|
2997
|
+
cloudCmd.command("sync").description("Full sync: ingest local \u2192 push to cloud \u2192 pull from cloud").action(async () => {
|
|
2998
|
+
console.log(chalk4.bold.cyan(` Cloud Sync \u2014 ${getMachineId()}
|
|
2917
2999
|
`));
|
|
2918
3000
|
process.stdout.write(chalk4.cyan("\u2192 Ingesting local data... "));
|
|
2919
3001
|
await autoSync();
|
|
2920
3002
|
console.log(chalk4.green("\u2713"));
|
|
2921
|
-
const
|
|
2922
|
-
const
|
|
2923
|
-
const
|
|
2924
|
-
const
|
|
2925
|
-
const
|
|
2926
|
-
|
|
2927
|
-
const tmpDir = join9(process.env["TMPDIR"] ?? "/tmp", "economy-sync");
|
|
2928
|
-
mkdirSync4(tmpDir, { recursive: true });
|
|
2929
|
-
const isLinux = process.platform === "linux";
|
|
2930
|
-
const remoteDbPath = isLinux ? ".hasna/economy/economy.db" : ".hasna/economy/economy.db";
|
|
2931
|
-
for (const machine of remoteMachines) {
|
|
2932
|
-
const localCopy = join9(tmpDir, `${machine}.db`);
|
|
2933
|
-
process.stdout.write(chalk4.cyan(`\u2192 Fetching from ${machine}... `));
|
|
2934
|
-
try {
|
|
2935
|
-
exec(`scp -o ConnectTimeout=5 -o StrictHostKeyChecking=no ${machine}:~/${remoteDbPath} "${localCopy}" 2>/dev/null`, { timeout: 30000 });
|
|
2936
|
-
if (!existsSync8(localCopy)) {
|
|
2937
|
-
console.log(chalk4.yellow("skipped (no file)"));
|
|
2938
|
-
continue;
|
|
2939
|
-
}
|
|
2940
|
-
const { SqliteAdapter } = await import("@hasna/cloud");
|
|
2941
|
-
const remoteDb = new SqliteAdapter(localCopy);
|
|
2942
|
-
remoteDb.exec("PRAGMA busy_timeout = 5000");
|
|
2943
|
-
const sessions = remoteDb.prepare("SELECT * FROM sessions").all();
|
|
2944
|
-
let sCount = 0;
|
|
2945
|
-
for (const s of sessions) {
|
|
2946
|
-
const existing = db.prepare("SELECT id FROM sessions WHERE id = ?").get(s["id"]);
|
|
2947
|
-
if (!existing) {
|
|
2948
|
-
db.prepare(`INSERT OR IGNORE INTO sessions (id, agent, project_path, project_name, started_at, ended_at, total_cost_usd, total_tokens, request_count, machine_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(s["id"], s["agent"], s["project_path"], s["project_name"], s["started_at"], s["ended_at"], s["total_cost_usd"], s["total_tokens"], s["request_count"], s["machine_id"] || machine);
|
|
2949
|
-
sCount++;
|
|
2950
|
-
}
|
|
2951
|
-
}
|
|
2952
|
-
let rCount = 0;
|
|
2953
|
-
try {
|
|
2954
|
-
const cols = remoteDb.prepare("PRAGMA table_info(requests)").all();
|
|
2955
|
-
const hasMachineCol = cols.some((c) => c.name === "machine_id");
|
|
2956
|
-
const requests = remoteDb.prepare("SELECT * FROM requests").all();
|
|
2957
|
-
for (const r of requests) {
|
|
2958
|
-
const existing = db.prepare("SELECT id FROM requests WHERE id = ?").get(r["id"]);
|
|
2959
|
-
if (!existing) {
|
|
2960
|
-
db.prepare(`INSERT OR IGNORE INTO requests (id, agent, session_id, model, input_tokens, output_tokens, cache_read_tokens, cache_create_tokens, cost_usd, duration_ms, timestamp, source_request_id, machine_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(r["id"], r["agent"], r["session_id"], r["model"], r["input_tokens"], r["output_tokens"], r["cache_read_tokens"], r["cache_create_tokens"], r["cost_usd"], r["duration_ms"], r["timestamp"], r["source_request_id"], hasMachineCol ? r["machine_id"] || machine : machine);
|
|
2961
|
-
rCount++;
|
|
2962
|
-
}
|
|
2963
|
-
}
|
|
2964
|
-
} catch {}
|
|
2965
|
-
remoteDb.close();
|
|
2966
|
-
try {
|
|
2967
|
-
unlinkSync(localCopy);
|
|
2968
|
-
} catch {}
|
|
2969
|
-
console.log(chalk4.green(`\u2713 ${sCount} sessions, ${rCount} requests`));
|
|
2970
|
-
} catch (e) {
|
|
2971
|
-
console.log(chalk4.yellow(`skipped (${e instanceof Error ? e.message.split(`
|
|
2972
|
-
`)[0] : "unreachable"})`));
|
|
2973
|
-
try {
|
|
2974
|
-
unlinkSync(localCopy);
|
|
2975
|
-
} catch {}
|
|
2976
|
-
}
|
|
3003
|
+
const { syncPush, syncPull, SqliteAdapter } = await import("@hasna/cloud");
|
|
3004
|
+
const { PG_MIGRATIONS: PG_MIGRATIONS2 } = await Promise.resolve().then(() => (init_pg_migrations(), exports_pg_migrations));
|
|
3005
|
+
const cloud = await getCloudPg();
|
|
3006
|
+
const local = new SqliteAdapter(getDbPath());
|
|
3007
|
+
for (const sql of PG_MIGRATIONS2) {
|
|
3008
|
+
await cloud.run(sql);
|
|
2977
3009
|
}
|
|
3010
|
+
process.stdout.write(chalk4.cyan("\u2192 Pushing local \u2192 cloud... "));
|
|
3011
|
+
const pushResults = await syncPush(local, cloud, { tables: CLOUD_TABLES });
|
|
3012
|
+
console.log(chalk4.green(`\u2713 ${pushResults.reduce((s, r) => s + r.rowsWritten, 0)} rows`));
|
|
3013
|
+
process.stdout.write(chalk4.cyan("\u2192 Pulling cloud \u2192 local... "));
|
|
3014
|
+
const pullResults = await syncPull(cloud, local, { tables: CLOUD_TABLES });
|
|
3015
|
+
console.log(chalk4.green(`\u2713 ${pullResults.reduce((s, r) => s + r.rowsWritten, 0)} rows`));
|
|
3016
|
+
local.close();
|
|
3017
|
+
await cloud.close();
|
|
2978
3018
|
console.log(chalk4.bold.green(`
|
|
2979
3019
|
\u2713 Cloud sync complete`));
|
|
2980
3020
|
});
|
|
2981
3021
|
cloudCmd.command("status").description("Check cloud connection status").action(async () => {
|
|
2982
|
-
const { PgAdapterAsync, getCloudConfig } = await import("@hasna/cloud");
|
|
2983
|
-
const config = getCloudConfig();
|
|
2984
3022
|
console.log();
|
|
2985
|
-
console.log(` Mode: ${chalk4.white(config.mode)}`);
|
|
2986
3023
|
console.log(` Machine: ${chalk4.white(getMachineId())}`);
|
|
2987
|
-
console.log(` RDS Host: ${chalk4.white(
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
}
|
|
3024
|
+
console.log(` RDS Host: ${chalk4.white(CLOUD_RDS_HOST)}`);
|
|
3025
|
+
console.log(` Database: ${chalk4.white(CLOUD_RDS_DB)}`);
|
|
3026
|
+
try {
|
|
3027
|
+
const cloud = await getCloudPg();
|
|
3028
|
+
await cloud.get("SELECT 1 as ok");
|
|
3029
|
+
const tables = await cloud.all("SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
|
|
3030
|
+
console.log(` PostgreSQL: ${chalk4.green("connected")}`);
|
|
3031
|
+
console.log(` Tables: ${chalk4.white(tables.map((t) => t.tablename).join(", ") || "(none)")}`);
|
|
3032
|
+
await cloud.close();
|
|
3033
|
+
} catch (err2) {
|
|
3034
|
+
console.log(` PostgreSQL: ${chalk4.red(`failed \u2014 ${err2 instanceof Error ? err2.message : String(err2)}`)}`);
|
|
2998
3035
|
}
|
|
2999
3036
|
console.log();
|
|
3000
3037
|
});
|
|
@@ -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;AAKxD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,MAAM,EACN,YAAY,EACZ,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,MA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MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,WAAW,EAAE,CAaxD;AAID,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,cAAc,GAAG,IAAI,CAMxE;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAElF;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,cAAc,EAAE,CAE/D;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEpE;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,CAgB3K"}
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,7 @@ 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 },
|
|
80
81
|
"claude-opus-4-6": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
81
82
|
"claude-opus-4-5": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
82
83
|
"claude-sonnet-4-6": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
@@ -87,20 +88,38 @@ var init_pricing = __esm(() => {
|
|
|
87
88
|
"claude-3-opus": { inputPer1M: 15, outputPer1M: 75, cacheReadPer1M: 1.5, cacheWritePer1M: 18.75 },
|
|
88
89
|
"claude-3-sonnet": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
89
90
|
"claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25, cacheReadPer1M: 0.03, cacheWritePer1M: 0.3 },
|
|
90
|
-
"gemini-
|
|
91
|
+
"gemini-3.1-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0.31, cacheWritePer1M: 0 },
|
|
91
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
|
+
"gemini-2.0-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
92
95
|
"gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
93
96
|
"gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
97
|
+
"gpt-5.4": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 0.625, cacheWritePer1M: 0 },
|
|
98
|
+
"gpt-5.4-pro": { inputPer1M: 5, outputPer1M: 20, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
99
|
+
"gpt-5.4-mini": { inputPer1M: 0.3, outputPer1M: 1.2, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
94
100
|
"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 },
|
|
95
102
|
"gpt-5.2-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
96
103
|
"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 },
|
|
97
106
|
"gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
98
107
|
"gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
99
108
|
o1: { inputPer1M: 15, outputPer1M: 60, cacheReadPer1M: 7.5, cacheWritePer1M: 0 },
|
|
100
109
|
"o1-mini": { inputPer1M: 3, outputPer1M: 12, cacheReadPer1M: 1.5, cacheWritePer1M: 0 },
|
|
101
110
|
o3: { inputPer1M: 10, outputPer1M: 40, cacheReadPer1M: 2.5, cacheWritePer1M: 0 },
|
|
102
111
|
"o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.55, cacheWritePer1M: 0 },
|
|
103
|
-
"o4-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.275, 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 }
|
|
104
123
|
};
|
|
105
124
|
});
|
|
106
125
|
|
|
@@ -564,11 +583,11 @@ function deleteModelPricing(db, model) {
|
|
|
564
583
|
db.prepare(`DELETE FROM model_pricing WHERE model = ?`).run(model);
|
|
565
584
|
}
|
|
566
585
|
function seedModelPricing(db, defaults) {
|
|
567
|
-
const existing = db.prepare(`SELECT
|
|
568
|
-
if (existing.count > 0)
|
|
569
|
-
return;
|
|
586
|
+
const existing = new Set(db.prepare(`SELECT model FROM model_pricing`).all().map((r) => r.model));
|
|
570
587
|
const now = new Date().toISOString();
|
|
571
588
|
for (const [model, p] of Object.entries(defaults)) {
|
|
589
|
+
if (existing.has(model))
|
|
590
|
+
continue;
|
|
572
591
|
upsertModelPricing(db, {
|
|
573
592
|
model,
|
|
574
593
|
input_per_1m: p.inputPer1M,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/lib/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKrD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/lib/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKrD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAqDxD,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/mcp/index.js
CHANGED
|
@@ -78,6 +78,7 @@ var DEFAULT_PRICING;
|
|
|
78
78
|
var init_pricing = __esm(() => {
|
|
79
79
|
init_database();
|
|
80
80
|
DEFAULT_PRICING = {
|
|
81
|
+
"claude-opus-4-7": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
81
82
|
"claude-opus-4-6": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
82
83
|
"claude-opus-4-5": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
83
84
|
"claude-sonnet-4-6": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
@@ -88,20 +89,38 @@ var init_pricing = __esm(() => {
|
|
|
88
89
|
"claude-3-opus": { inputPer1M: 15, outputPer1M: 75, cacheReadPer1M: 1.5, cacheWritePer1M: 18.75 },
|
|
89
90
|
"claude-3-sonnet": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
90
91
|
"claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25, cacheReadPer1M: 0.03, cacheWritePer1M: 0.3 },
|
|
91
|
-
"gemini-
|
|
92
|
+
"gemini-3.1-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0.31, cacheWritePer1M: 0 },
|
|
92
93
|
"gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
94
|
+
"gemini-2.5-flash": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
95
|
+
"gemini-2.0-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
93
96
|
"gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
94
97
|
"gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
98
|
+
"gpt-5.4": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 0.625, cacheWritePer1M: 0 },
|
|
99
|
+
"gpt-5.4-pro": { inputPer1M: 5, outputPer1M: 20, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
100
|
+
"gpt-5.4-mini": { inputPer1M: 0.3, outputPer1M: 1.2, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
95
101
|
"gpt-5.3-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
102
|
+
"gpt-5.3-chat": { inputPer1M: 2, outputPer1M: 8, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
96
103
|
"gpt-5.2-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
97
104
|
"gpt-5-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
105
|
+
"gpt-5-mini": { inputPer1M: 0.3, outputPer1M: 1.2, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
106
|
+
"gpt-5.2": { inputPer1M: 2, outputPer1M: 8, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
98
107
|
"gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
99
108
|
"gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
100
109
|
o1: { inputPer1M: 15, outputPer1M: 60, cacheReadPer1M: 7.5, cacheWritePer1M: 0 },
|
|
101
110
|
"o1-mini": { inputPer1M: 3, outputPer1M: 12, cacheReadPer1M: 1.5, cacheWritePer1M: 0 },
|
|
102
111
|
o3: { inputPer1M: 10, outputPer1M: 40, cacheReadPer1M: 2.5, cacheWritePer1M: 0 },
|
|
103
112
|
"o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.55, cacheWritePer1M: 0 },
|
|
104
|
-
"o4-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.275, cacheWritePer1M: 0 }
|
|
113
|
+
"o4-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.275, cacheWritePer1M: 0 },
|
|
114
|
+
"qwen3.6-plus": { inputPer1M: 0.8, outputPer1M: 2, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
115
|
+
"qwen3.6": { inputPer1M: 0.3, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
116
|
+
"minimax-m2.7": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
117
|
+
"minimax-m2.7-highspeed": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
118
|
+
"minimax-m1": { inputPer1M: 0.2, outputPer1M: 1.1, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
119
|
+
"grok-3": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
120
|
+
"grok-3-mini": { inputPer1M: 0.3, outputPer1M: 0.5, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
121
|
+
"glm-5.1": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
122
|
+
"glm-5": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
123
|
+
"kimi-k2": { inputPer1M: 0.6, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 }
|
|
105
124
|
};
|
|
106
125
|
});
|
|
107
126
|
|
|
@@ -528,11 +547,11 @@ function getModelPricing(db, model) {
|
|
|
528
547
|
return db.prepare(`SELECT * FROM model_pricing WHERE model = ?`).get(model);
|
|
529
548
|
}
|
|
530
549
|
function seedModelPricing(db, defaults) {
|
|
531
|
-
const existing = db.prepare(`SELECT
|
|
532
|
-
if (existing.count > 0)
|
|
533
|
-
return;
|
|
550
|
+
const existing = new Set(db.prepare(`SELECT model FROM model_pricing`).all().map((r) => r.model));
|
|
534
551
|
const now = new Date().toISOString();
|
|
535
552
|
for (const [model, p] of Object.entries(defaults)) {
|
|
553
|
+
if (existing.has(model))
|
|
554
|
+
continue;
|
|
536
555
|
upsertModelPricing(db, {
|
|
537
556
|
model,
|
|
538
557
|
input_per_1m: p.inputPer1M,
|
package/dist/server/index.js
CHANGED
|
@@ -79,6 +79,7 @@ var DEFAULT_PRICING;
|
|
|
79
79
|
var init_pricing = __esm(() => {
|
|
80
80
|
init_database();
|
|
81
81
|
DEFAULT_PRICING = {
|
|
82
|
+
"claude-opus-4-7": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
82
83
|
"claude-opus-4-6": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
83
84
|
"claude-opus-4-5": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25 },
|
|
84
85
|
"claude-sonnet-4-6": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
@@ -89,20 +90,38 @@ var init_pricing = __esm(() => {
|
|
|
89
90
|
"claude-3-opus": { inputPer1M: 15, outputPer1M: 75, cacheReadPer1M: 1.5, cacheWritePer1M: 18.75 },
|
|
90
91
|
"claude-3-sonnet": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75 },
|
|
91
92
|
"claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25, cacheReadPer1M: 0.03, cacheWritePer1M: 0.3 },
|
|
92
|
-
"gemini-
|
|
93
|
+
"gemini-3.1-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0.31, cacheWritePer1M: 0 },
|
|
93
94
|
"gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
95
|
+
"gemini-2.5-flash": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
96
|
+
"gemini-2.0-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
94
97
|
"gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
95
98
|
"gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
99
|
+
"gpt-5.4": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 0.625, cacheWritePer1M: 0 },
|
|
100
|
+
"gpt-5.4-pro": { inputPer1M: 5, outputPer1M: 20, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
101
|
+
"gpt-5.4-mini": { inputPer1M: 0.3, outputPer1M: 1.2, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
96
102
|
"gpt-5.3-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
103
|
+
"gpt-5.3-chat": { inputPer1M: 2, outputPer1M: 8, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
97
104
|
"gpt-5.2-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
98
105
|
"gpt-5-codex": { inputPer1M: 1.75, outputPer1M: 14, cacheReadPer1M: 0.44, cacheWritePer1M: 0 },
|
|
106
|
+
"gpt-5-mini": { inputPer1M: 0.3, outputPer1M: 1.2, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
107
|
+
"gpt-5.2": { inputPer1M: 2, outputPer1M: 8, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
99
108
|
"gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
100
109
|
"gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0.075, cacheWritePer1M: 0 },
|
|
101
110
|
o1: { inputPer1M: 15, outputPer1M: 60, cacheReadPer1M: 7.5, cacheWritePer1M: 0 },
|
|
102
111
|
"o1-mini": { inputPer1M: 3, outputPer1M: 12, cacheReadPer1M: 1.5, cacheWritePer1M: 0 },
|
|
103
112
|
o3: { inputPer1M: 10, outputPer1M: 40, cacheReadPer1M: 2.5, cacheWritePer1M: 0 },
|
|
104
113
|
"o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.55, cacheWritePer1M: 0 },
|
|
105
|
-
"o4-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.275, cacheWritePer1M: 0 }
|
|
114
|
+
"o4-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cacheReadPer1M: 0.275, cacheWritePer1M: 0 },
|
|
115
|
+
"qwen3.6-plus": { inputPer1M: 0.8, outputPer1M: 2, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
116
|
+
"qwen3.6": { inputPer1M: 0.3, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
117
|
+
"minimax-m2.7": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
118
|
+
"minimax-m2.7-highspeed": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
119
|
+
"minimax-m1": { inputPer1M: 0.2, outputPer1M: 1.1, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
120
|
+
"grok-3": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
121
|
+
"grok-3-mini": { inputPer1M: 0.3, outputPer1M: 0.5, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
122
|
+
"glm-5.1": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
123
|
+
"glm-5": { inputPer1M: 0.7, outputPer1M: 0.7, cacheReadPer1M: 0, cacheWritePer1M: 0 },
|
|
124
|
+
"kimi-k2": { inputPer1M: 0.6, outputPer1M: 0.6, cacheReadPer1M: 0, cacheWritePer1M: 0 }
|
|
106
125
|
};
|
|
107
126
|
});
|
|
108
127
|
|
|
@@ -557,11 +576,11 @@ function deleteModelPricing(db, model) {
|
|
|
557
576
|
db.prepare(`DELETE FROM model_pricing WHERE model = ?`).run(model);
|
|
558
577
|
}
|
|
559
578
|
function seedModelPricing(db, defaults) {
|
|
560
|
-
const existing = db.prepare(`SELECT
|
|
561
|
-
if (existing.count > 0)
|
|
562
|
-
return;
|
|
579
|
+
const existing = new Set(db.prepare(`SELECT model FROM model_pricing`).all().map((r) => r.model));
|
|
563
580
|
const now = new Date().toISOString();
|
|
564
581
|
for (const [model, p] of Object.entries(defaults)) {
|
|
582
|
+
if (existing.has(model))
|
|
583
|
+
continue;
|
|
565
584
|
upsertModelPricing(db, {
|
|
566
585
|
model,
|
|
567
586
|
input_per_1m: p.inputPer1M,
|
package/package.json
CHANGED