codexmeter 1.0.20 → 1.0.22

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/README.md CHANGED
@@ -42,7 +42,7 @@ Data is read from `state_5.sqlite`, `logs_1.sqlite`, and rollout JSONL under `.c
42
42
 
43
43
  ## Requirements
44
44
 
45
- - Node.js 20.19+ or 22.12+
45
+ - Node.js 22.13+
46
46
  - A `.codex` directory (from Codex CLI usage)
47
47
  - Chrome, Chromium, or Edge for video export, or let CodexMeter download a single-use portable browser from the UI
48
48
 
package/bin/codexmeter.js CHANGED
@@ -21,6 +21,18 @@ function parseNumberEnv(name, defaultValue = undefined) {
21
21
  return Number.isFinite(value) && value > 0 ? value : defaultValue;
22
22
  }
23
23
 
24
+ function parseIsoDateOption(name, value) {
25
+ if (!value) return null;
26
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
27
+ program.error(`${name} must be a valid date in YYYY-MM-DD format`);
28
+ }
29
+ const ms = Date.parse(`${value}T00:00:00Z`);
30
+ if (!Number.isFinite(ms) || new Date(ms).toISOString().slice(0, 10) !== value) {
31
+ program.error(`${name} must be a valid date in YYYY-MM-DD format`);
32
+ }
33
+ return value;
34
+ }
35
+
24
36
  program
25
37
  .name('codexmeter')
26
38
  .description('Local telemetry dashboard for Codex CLI usage')
@@ -34,6 +46,11 @@ program
34
46
  .parse();
35
47
 
36
48
  const opts = program.opts();
49
+ const from = parseIsoDateOption('--from', opts.from);
50
+ const to = parseIsoDateOption('--to', opts.to);
51
+ if (from && to && from > to) {
52
+ program.error('--from must be earlier than or equal to --to');
53
+ }
37
54
 
38
55
  const ingestToggles = {
39
56
  ingestTiming: parseBooleanEnv('CODEXMETER_INGEST_TIMING'),
@@ -59,8 +76,8 @@ if (activeIngestToggles.length) {
59
76
  }
60
77
 
61
78
  const app = createServer(opts.codexHome, {
62
- from: opts.from,
63
- to: opts.to,
79
+ from,
80
+ to,
64
81
  repo: opts.repo,
65
82
  agentFamily: opts.agentFamily,
66
83
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,