one-more-token 0.5.1 → 0.6.0

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.
@@ -114,6 +114,38 @@
114
114
  }
115
115
  }
116
116
  ]
117
+ },
118
+ {
119
+ "id": "nan-gentle-deepseek",
120
+ "label": "NaN Gentle · DeepSeek V4 Flash",
121
+ "provider": "nan",
122
+ "monthlyPriceUsd": null,
123
+ "reviewedAt": "2026-11-23",
124
+ "windows": [
125
+ {
126
+ "kind": "monthly",
127
+ "limit": {
128
+ "unit": "tokens",
129
+ "value": 1000000000
130
+ }
131
+ }
132
+ ]
133
+ },
134
+ {
135
+ "id": "nan-gentle-glm53-flash",
136
+ "label": "NaN Gentle · GLM 5.3 Flash",
137
+ "provider": "nan",
138
+ "monthlyPriceUsd": null,
139
+ "reviewedAt": "2026-11-23",
140
+ "windows": [
141
+ {
142
+ "kind": "monthly",
143
+ "limit": {
144
+ "unit": "tokens",
145
+ "value": 500000000
146
+ }
147
+ }
148
+ ]
117
149
  }
118
150
  ]
119
151
  }
package/dist/main.js CHANGED
@@ -152,9 +152,9 @@ function nullish(input2) {
152
152
  return input2 === null || input2 === void 0;
153
153
  }
154
154
  function cleanRegex(source3) {
155
- const start = source3.startsWith("^") ? 1 : 0;
155
+ const start2 = source3.startsWith("^") ? 1 : 0;
156
156
  const end = source3.endsWith("$") ? source3.length - 1 : source3.length;
157
- return source3.slice(start, end);
157
+ return source3.slice(start2, end);
158
158
  }
159
159
  function floatSafeRemainder(val, step) {
160
160
  const ratio = val / step;
@@ -543,9 +543,9 @@ function sizeCaps(defChecks) {
543
543
  }
544
544
  return caps;
545
545
  }
546
- function attachSchema(issues, start, inst) {
546
+ function attachSchema(issues, start2, inst) {
547
547
  var _a3;
548
- for (let i = start; i < issues.length; i++) {
548
+ for (let i = start2; i < issues.length; i++) {
549
549
  (_a3 = issues[i]).schema ?? (_a3.schema = inst);
550
550
  }
551
551
  }
@@ -2279,10 +2279,10 @@ function capSize(inst, size) {
2279
2279
  if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
2280
2280
  for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
2281
2281
  if (n > max && ch._zod.def.when(payload)) {
2282
- const start = payload.issues.length;
2282
+ const start2 = payload.issues.length;
2283
2283
  ch._zod.check(payload);
2284
- payload.issues[start].continue = false;
2285
- attachSchema(payload.issues, start, inst);
2284
+ payload.issues[start2].continue = false;
2285
+ attachSchema(payload.issues, start2, inst);
2286
2286
  return payload;
2287
2287
  }
2288
2288
  }
@@ -20558,7 +20558,9 @@ var init_tables = __esm({
20558
20558
  position: external_exports.number().int().nonnegative(),
20559
20559
  subscription_id: id,
20560
20560
  provider: external_exports.string().min(1),
20561
- agent: nullable2(external_exports.string().min(1))
20561
+ agent: nullable2(external_exports.string().min(1)),
20562
+ /** Optional model narrowing (spec §5.1: NaN Gentle meters each model separately). */
20563
+ model: nullable2(external_exports.string().min(1))
20562
20564
  });
20563
20565
  QuotaWindowSchema = external_exports.object({
20564
20566
  id,
@@ -20901,8 +20903,8 @@ async function readSentAlertKeys(db) {
20901
20903
  );
20902
20904
  return new Set(
20903
20905
  rows.map((row) => {
20904
- const start = new Date(Number(row.ms)).toISOString();
20905
- return alertKey(String(row.alert_id), start);
20906
+ const start2 = new Date(Number(row.ms)).toISOString();
20907
+ return alertKey(String(row.alert_id), start2);
20906
20908
  })
20907
20909
  );
20908
20910
  }
@@ -21015,8 +21017,8 @@ var init_files = __esm({
21015
21017
  const sorted = [...list].sort((a, b) => a.validFrom.localeCompare(b.validFrom));
21016
21018
  for (let i = 1; i < sorted.length; i++) {
21017
21019
  const previousEnd = sorted[i - 1]?.validTo;
21018
- const start = sorted[i]?.validFrom ?? "";
21019
- if (previousEnd === null || previousEnd !== void 0 && previousEnd >= start) {
21020
+ const start2 = sorted[i]?.validFrom ?? "";
21021
+ if (previousEnd === null || previousEnd !== void 0 && previousEnd >= start2) {
21020
21022
  ctx.addIssue({ code: "custom", message: `overlapping validity for ${key2}` });
21021
21023
  }
21022
21024
  }
@@ -22070,11 +22072,11 @@ function rollingSpans(turns, length) {
22070
22072
  function monthlySpans(turns, anchor2, now, active) {
22071
22073
  const byStart = /* @__PURE__ */ new Map();
22072
22074
  const add2 = (ms3) => {
22073
- const { start, end } = monthlySpanAt(anchor2, ms3);
22074
- let span = byStart.get(start);
22075
+ const { start: start2, end } = monthlySpanAt(anchor2, ms3);
22076
+ let span = byStart.get(start2);
22075
22077
  if (!span) {
22076
- span = { start, end, turns: [] };
22077
- byStart.set(start, span);
22078
+ span = { start: start2, end, turns: [] };
22079
+ byStart.set(start2, span);
22078
22080
  }
22079
22081
  return span;
22080
22082
  };
@@ -22247,17 +22249,17 @@ function computeQuotas(input2) {
22247
22249
  now
22248
22250
  );
22249
22251
  });
22250
- const start = Math.max(from, activeFrom ?? from);
22252
+ const start2 = Math.max(from, activeFrom ?? from);
22251
22253
  const end = Math.min(to, activeTo ?? to);
22252
22254
  let apiEquivalentUsd = 0;
22253
22255
  let unpricedTurns = 0;
22254
22256
  for (const turn of own2) {
22255
- if (turn.ms < start || turn.ms >= end) continue;
22257
+ if (turn.ms < start2 || turn.ms >= end) continue;
22256
22258
  if (turn.computedCostUsd === null) unpricedTurns++;
22257
22259
  else apiEquivalentUsd += turn.computedCostUsd;
22258
22260
  }
22259
22261
  const price2 = plan.monthlyPriceUsd ?? null;
22260
- const paidUsd = price2 === null ? null : price2 * Math.max(0, end - start) / AVERAGE_MONTH;
22262
+ const paidUsd = price2 === null ? null : price2 * Math.max(0, end - start2) / AVERAGE_MONTH;
22261
22263
  return [
22262
22264
  {
22263
22265
  id: subscription.id,
@@ -22867,11 +22869,12 @@ async function syncUserSubscriptions(db, file2, plans) {
22867
22869
  subscription.endedAt ?? null
22868
22870
  ]);
22869
22871
  for (const rule of subscription.match) {
22870
- await db.run("INSERT INTO subscription_rules VALUES ($1, $2, $3, $4)", [
22872
+ await db.run("INSERT INTO subscription_rules VALUES ($1, $2, $3, $4, $5)", [
22871
22873
  position++,
22872
22874
  subscription.id,
22873
22875
  rule.provider,
22874
- rule.agent ?? null
22876
+ rule.agent ?? null,
22877
+ rule.model ?? null
22875
22878
  ]);
22876
22879
  }
22877
22880
  }
@@ -22894,7 +22897,11 @@ var init_config2 = __esm({
22894
22897
  startedAt: date7.optional(),
22895
22898
  endedAt: date7.optional(),
22896
22899
  match: external_exports.array(
22897
- external_exports.object({ provider: external_exports.string().min(1), agent: external_exports.string().min(1).optional() }).strict()
22900
+ external_exports.object({
22901
+ provider: external_exports.string().min(1),
22902
+ agent: external_exports.string().min(1).optional(),
22903
+ model: external_exports.string().min(1).optional()
22904
+ }).strict()
22898
22905
  ).min(1)
22899
22906
  }).strict();
22900
22907
  UserSubscriptionsFileSchema = external_exports.object({ version: external_exports.literal(1), subscriptions: external_exports.array(UserSubscriptionSchema) }).strict();
@@ -23223,7 +23230,7 @@ var init_db_queue = __esm({
23223
23230
  function summaryPeriod(params, now = Date.now()) {
23224
23231
  const froms = params.getAll("from");
23225
23232
  const tos = params.getAll("to");
23226
- let start = now - 7 * DAY3;
23233
+ let start2 = now - 7 * DAY3;
23227
23234
  let end = now;
23228
23235
  if (froms.length || tos.length) {
23229
23236
  if (froms.length !== 1 || tos.length !== 1) return null;
@@ -23232,12 +23239,12 @@ function summaryPeriod(params, now = Date.now()) {
23232
23239
  if (/\.\d{4,}/.test(value2)) return NaN;
23233
23240
  return Date.parse(value2);
23234
23241
  };
23235
- start = parse4(froms[0]);
23242
+ start2 = parse4(froms[0]);
23236
23243
  end = parse4(tos[0]);
23237
23244
  }
23238
- if (!Number.isFinite(start) || !Number.isFinite(end) || start >= end) return null;
23239
- if ((utcDay(end - 1) - utcDay(start)) / DAY3 + 1 > 366) return null;
23240
- const from = new Date(start).toISOString();
23245
+ if (!Number.isFinite(start2) || !Number.isFinite(end) || start2 >= end) return null;
23246
+ if ((utcDay(end - 1) - utcDay(start2)) / DAY3 + 1 > 366) return null;
23247
+ const from = new Date(start2).toISOString();
23241
23248
  const to = new Date(end).toISOString();
23242
23249
  if (from.length !== 24 || to.length !== 24) return null;
23243
23250
  return { from, to };
@@ -23727,19 +23734,19 @@ var init_url = __esm({
23727
23734
  tryDecodeURI = (str) => tryDecode(str, decodeURI);
23728
23735
  getPath = (request) => {
23729
23736
  const url2 = request.url;
23730
- const start = url2.indexOf("/", url2.indexOf(":") + 4);
23731
- let i = start;
23737
+ const start2 = url2.indexOf("/", url2.indexOf(":") + 4);
23738
+ let i = start2;
23732
23739
  for (; i < url2.length; i++) {
23733
23740
  const charCode = url2.charCodeAt(i);
23734
23741
  if (charCode === 37) {
23735
23742
  const queryIndex = url2.indexOf("?", i);
23736
23743
  const hashIndex = url2.indexOf("#", i);
23737
23744
  const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
23738
- const path = url2.slice(start, end);
23745
+ const path = url2.slice(start2, end);
23739
23746
  return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
23740
23747
  } else if (charCode === 63 || charCode === 35) break;
23741
23748
  }
23742
- return url2.slice(start, i);
23749
+ return url2.slice(start2, i);
23743
23750
  };
23744
23751
  getPathNoStrict = (request) => {
23745
23752
  const result = getPath(request);
@@ -29676,8 +29683,8 @@ async function monthlyData(db, period, options) {
29676
29683
  };
29677
29684
  }
29678
29685
  function monthPeriodBefore(period) {
29679
- const start = Date.parse(period.from);
29680
- const date8 = new Date(start);
29686
+ const start2 = Date.parse(period.from);
29687
+ const date8 = new Date(start2);
29681
29688
  const previous = Date.UTC(date8.getUTCFullYear(), date8.getUTCMonth() - 1, 1);
29682
29689
  return { from: new Date(previous).toISOString(), to: period.from };
29683
29690
  }
@@ -29878,11 +29885,11 @@ var init_dist2 = __esm({
29878
29885
  isHttpWhitespace = (code) => code === 9 || code === 10 || code === 13 || code === 32;
29879
29886
  normalizeHeaderValue = (value2) => {
29880
29887
  if (!isHttpWhitespace(value2.charCodeAt(0)) && !isHttpWhitespace(value2.charCodeAt(value2.length - 1))) return value2;
29881
- let start = 0;
29888
+ let start2 = 0;
29882
29889
  let end = value2.length;
29883
- while (start < end && isHttpWhitespace(value2.charCodeAt(start))) start++;
29884
- while (end > start && isHttpWhitespace(value2.charCodeAt(end - 1))) end--;
29885
- return value2.slice(start, end);
29890
+ while (start2 < end && isHttpWhitespace(value2.charCodeAt(start2))) start2++;
29891
+ while (end > start2 && isHttpWhitespace(value2.charCodeAt(end - 1))) end--;
29892
+ return value2.slice(start2, end);
29886
29893
  };
29887
29894
  forbiddenHeaderValue = /[\0\r\n]/;
29888
29895
  GlobalHeaders = globalThis.Headers;
@@ -31154,9 +31161,9 @@ var init_server = __esm({
31154
31161
 
31155
31162
  // src/start.ts
31156
31163
  import { exec } from "node:child_process";
31157
- import { existsSync } from "node:fs";
31164
+ import { existsSync, mkdirSync } from "node:fs";
31158
31165
  import { homedir as homedir4 } from "node:os";
31159
- import { join as join13 } from "node:path";
31166
+ import { dirname as dirname3, join as join13 } from "node:path";
31160
31167
  function defaultOpenBrowser(url2) {
31161
31168
  return new Promise((resolve) => {
31162
31169
  const command = process.platform === "darwin" ? `open ${JSON.stringify(url2)}` : process.platform === "win32" ? `start "" ${JSON.stringify(url2)}` : `xdg-open ${JSON.stringify(url2)}`;
@@ -31211,6 +31218,7 @@ ${detected.join("\n")}
31211
31218
  let db;
31212
31219
  let server;
31213
31220
  try {
31221
+ if (options.db !== ":memory:") mkdirSync(dirname3(options.db), { recursive: true });
31214
31222
  db = await openDatabase(options.db);
31215
31223
  await migrate(db);
31216
31224
  const home = io.env.HOME ?? homedir4();
@@ -31254,7 +31262,6 @@ var init_start = __esm({
31254
31262
  init_src();
31255
31263
  init_app();
31256
31264
  init_service7();
31257
- init_options();
31258
31265
  init_server();
31259
31266
  init_static();
31260
31267
  EXIT_OK = 0;
@@ -31275,26 +31282,28 @@ __export(cli_exports, {
31275
31282
  USAGE: () => USAGE,
31276
31283
  run: () => run2
31277
31284
  });
31278
- import { mkdirSync } from "node:fs";
31285
+ import { mkdirSync as mkdirSync2 } from "node:fs";
31279
31286
  import { homedir as homedir5 } from "node:os";
31280
- import { dirname as dirname3 } from "node:path";
31287
+ import { dirname as dirname4 } from "node:path";
31281
31288
  async function run2(argv, io, deps = { waitForShutdown: () => waitForSignal() }) {
31282
31289
  const [command, ...args] = argv;
31283
- if (command === void 0 || command === "--help" || command === "-h") {
31290
+ if (command === void 0) return start([], io, deps);
31291
+ if (command === "--help" || command === "-h") {
31284
31292
  io.stdout(USAGE);
31285
31293
  return EXIT_OK2;
31286
31294
  }
31287
31295
  if (command.startsWith("-")) {
31288
- return usageError(io, "omt", `unknown option "${command}"`);
31296
+ if (argv.includes("--help") || argv.includes("-h")) {
31297
+ io.stdout(USAGE);
31298
+ return EXIT_OK2;
31299
+ }
31300
+ return start(argv, io, deps);
31289
31301
  }
31290
31302
  switch (command) {
31291
31303
  case "serve":
31292
31304
  return serveCommand(args, io, deps);
31293
31305
  case "start":
31294
- return startCommand(args, io, {
31295
- waitForShutdown: deps.waitForShutdown ?? (() => waitForSignal()),
31296
- ...deps.openBrowser ? { openBrowser: deps.openBrowser } : {}
31297
- });
31306
+ return start(args, io, deps);
31298
31307
  case "ingest":
31299
31308
  return ingestCommand(args, io, deps);
31300
31309
  case "watch":
@@ -31313,6 +31322,12 @@ ${HELP_HINT}
31313
31322
  `);
31314
31323
  return EXIT_USAGE2;
31315
31324
  }
31325
+ function start(args, io, deps) {
31326
+ return startCommand(args, io, {
31327
+ waitForShutdown: deps.waitForShutdown ?? (() => waitForSignal()),
31328
+ ...deps.openBrowser ? { openBrowser: deps.openBrowser } : {}
31329
+ });
31330
+ }
31316
31331
  async function ingestCommand(args, io, deps) {
31317
31332
  const parsed = parseIngestOptions(args);
31318
31333
  if (!parsed.ok) return usageError(io, "omt ingest", parsed.error);
@@ -31405,7 +31420,7 @@ async function serveCommand(args, io, deps) {
31405
31420
  }
31406
31421
  }
31407
31422
  async function openMigratedDatabase(options) {
31408
- if (options.db !== ":memory:") mkdirSync(dirname3(options.db), { recursive: true });
31423
+ if (options.db !== ":memory:") mkdirSync2(dirname4(options.db), { recursive: true });
31409
31424
  const db = await openDatabase(options.db);
31410
31425
  try {
31411
31426
  await migrate(db);
@@ -31439,7 +31454,10 @@ var init_cli = __esm({
31439
31454
  HELP_HINT = "Run `omt --help` for usage.";
31440
31455
  USAGE = `One More Token: local dashboard for AI coding agent usage.
31441
31456
 
31442
- Usage: omt <command> [options]
31457
+ Usage: omt [<command>] [options]
31458
+
31459
+ With no command, omt runs "start": ingest local metrics, serve the dashboard
31460
+ and open it in the browser.
31443
31461
 
31444
31462
  Commands:
31445
31463
  start Ingest local agent metrics, serve the dashboard and open it in the browser
@@ -31494,10 +31512,10 @@ Global options:
31494
31512
  });
31495
31513
 
31496
31514
  // src/entry-npm.ts
31497
- import { dirname as dirname4, join as join14 } from "node:path";
31515
+ import { dirname as dirname5, join as join14 } from "node:path";
31498
31516
  import { fileURLToPath as fileURLToPath4 } from "node:url";
31499
- var here = dirname4(fileURLToPath4(import.meta.url));
31500
- var root = dirname4(here);
31517
+ var here = dirname5(fileURLToPath4(import.meta.url));
31518
+ var root = dirname5(here);
31501
31519
  process.env.OMT_DATA_DIR ??= join14(root, "data");
31502
31520
  process.env.OMT_WEB_DIST ??= join14(root, "web-dist");
31503
31521
  process.env.OMT_MIGRATIONS_DIR ??= join14(root, "migrations");
@@ -0,0 +1,22 @@
1
+ -- Subscription rules may narrow a provider rule to one model (spec §5.1: the NaN Gentle plan meters
2
+ -- each model with its own allowance). NULL keeps the rule covering every model of the provider.
3
+ ALTER TABLE subscription_rules ADD COLUMN model VARCHAR;
4
+
5
+ -- Rebuilt with the model condition; semantics otherwise identical to 005.
6
+ CREATE OR REPLACE VIEW turn_subscriptions AS
7
+ SELECT
8
+ t.id AS turn_id,
9
+ (
10
+ SELECT r.subscription_id
11
+ FROM subscription_rules r
12
+ JOIN subscriptions s ON s.id = r.subscription_id
13
+ WHERE r.provider = t.provider
14
+ AND (r.model IS NULL OR r.model = t.model)
15
+ AND (r.agent IS NULL OR r.agent = se.agent)
16
+ AND (s.started_at IS NULL OR CAST(t.ts AS DATE) >= s.started_at)
17
+ AND (s.ended_at IS NULL OR CAST(t.ts AS DATE) <= s.ended_at)
18
+ ORDER BY r.position
19
+ LIMIT 1
20
+ ) AS subscription_id
21
+ FROM turns t
22
+ LEFT JOIN sessions se ON se.id = t.session_id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one-more-token",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "One More Token: local dashboard for AI coding agent usage (omt start | serve | ingest | watch)",
5
5
  "license": "MIT",
6
6
  "type": "module",