codex-token-tracker-nodejs16 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # Changelog
2
+
3
+ All notable changes to `codex-token-tracker-nodejs16`.
4
+
5
+ This package is the Node 16 build of [`codex-token-tracker`](https://www.npmjs.com/package/codex-token-tracker)
6
+ and carries **the same version number**, because it is built from the same sources. For what changed in the
7
+ application itself, see [that package's changelog](https://github.com/CharryLee0426/codex_team_token_tracker/blob/main/packages/menubar/CHANGELOG.md).
8
+ Entries here cover only what is specific to the Node 16 build.
9
+
10
+ ## 0.2.1 — 2026-09-02
11
+
12
+ First release. Feature-identical to `codex-token-tracker` 0.2.1, installable on Node 16.8+.
13
+
14
+ ### Added
15
+
16
+ - **Runs on Node 16.8 or newer** — and unchanged on Node 18 / 20 / 22, so a team can standardise on this
17
+ package if some machines are pinned to an old runtime.
18
+ - **`dist/node16-polyfill.js`**, prepended to every Node-side bundle so it runs before any application or
19
+ vendored code evaluates. It installs `fetch`/`Headers`/`Request`/`Response`/`FormData`/`File` from
20
+ [undici](https://github.com/nodejs/undici) (the implementation Node 18 adopted as its built-in fetch),
21
+ `Blob` from `node:buffer`, the stream classes from `node:stream/web`, WebCrypto `crypto` from
22
+ `node:crypto`, and `structuredClone` via `node:v8`. Each is installed only when absent, so the polyfill is
23
+ a no-op on newer Node and inside Electron.
24
+ - **`codex-token-tracker-node16`** as a third command name, for machines where the shared
25
+ `codex-token-tracker` / `codex-tracker` names would be ambiguous.
26
+ - **`test:node16`**, which runs the upstream suites against this package's own bundle on a real Node 16
27
+ binary (`node:test` is mapped onto a shim, since Node 16 has no test runner).
28
+
29
+ ### Notes
30
+
31
+ - No application source of its own: the build bundles `../menubar/src`, so this package cannot drift from
32
+ the Node 20 one. `scripts/sync-version.mjs` keeps the version aligned on every build.
33
+ - The renderer is built for Chromium 108 (Electron 22) rather than Chromium 128, so the popover still
34
+ renders if an older Electron has to be used on an older OS.
35
+ - Hermes SQLite session sources are skipped, as they require `node:sqlite`. Not a regression — that module
36
+ landed in Node 22.5, so the Node 20 build skips them as well.
37
+ - `codex-tracker update` checks and installs `codex-token-tracker-nodejs16`. Its update cache is stored
38
+ separately from the Node 20 build's, so the two never report each other's published version.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Codex Token Tracker contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # codex-token-tracker-nodejs16
2
+
3
+ The **Node.js 16 build** of [`codex-token-tracker`](https://www.npmjs.com/package/codex-token-tracker) — the
4
+ menu bar / system tray app and headless agent that tracks OpenAI Codex token usage, cache hits, model mix
5
+ and API-equivalent cost, and syncs it to your team dashboard.
6
+
7
+ Same app, same features, same version number. The only difference is the runtime it can be installed on:
8
+
9
+ | | `codex-token-tracker` | `codex-token-tracker-nodejs16` |
10
+ |---|---|---|
11
+ | Node | 20 or newer | **16.8 or newer** (also runs on 18 / 20 / 22) |
12
+ | Features | all | all |
13
+ | Dashboard / wire protocol | identical | identical |
14
+
15
+ **Use the regular package unless your machine is pinned to Node 16.** This one exists for build boxes and
16
+ older dev machines whose OS cannot go past Node 16.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install -g codex-token-tracker-nodejs16
22
+ codex-tracker # menu bar app, or headless agent where there is no display
23
+ ```
24
+
25
+ It installs the same `codex-token-tracker` and `codex-tracker` commands as the regular package, plus
26
+ `codex-token-tracker-node16` if you need to disambiguate. Because the command names overlap, install **one
27
+ of the two packages per machine**, not both.
28
+
29
+ Everything else — commands, configuration, sources, sync, rate limits, what gets uploaded — is documented in
30
+ the [main README](https://github.com/CharryLee0426/codex_team_token_tracker/tree/main/packages/menubar#readme).
31
+
32
+ ## Why a separate package
33
+
34
+ Node 16 reached end of life in September 2023 and never shipped a global `fetch`. Rather than hold the main
35
+ package back, the Node 16 support lives here:
36
+
37
+ - **One source tree.** This package contains no application code. Its build bundles `../menubar/src` — the
38
+ exact same sources the Node 20 package ships — so the two cannot drift apart in features.
39
+ - **`target: node16`.** esbuild downlevels any syntax Node 16 cannot parse.
40
+ - **A polyfill prelude.** `dist/node16-polyfill.js` is prepended to every Node-side bundle and installs the
41
+ web globals Node 16 lacks, sourced from [undici](https://github.com/nodejs/undici) — which is the very
42
+ implementation Node 18 adopted as its built-in `fetch`:
43
+
44
+ | Global | Source | Missing before |
45
+ |---|---|---|
46
+ | `fetch`, `Headers`, `Request`, `Response`, `FormData`, `File` | `undici` | Node 18 |
47
+ | `Blob` | `node:buffer` | Node 18 |
48
+ | `ReadableStream`, `WritableStream`, `TransformStream` | `node:stream/web` | Node 18 |
49
+ | `crypto` (WebCrypto) | `node:crypto` | Node 19 |
50
+ | `structuredClone` | `node:v8` | Node 17 |
51
+
52
+ Every one is installed **only if absent**, so the same bundle is unchanged on newer Node and inside
53
+ Electron — where the polyfill is a no-op.
54
+
55
+ ## Requirements and caveats
56
+
57
+ - **Node >= 16.8.** 16.8 is the first release undici's `fetch` supports; 16.20.2 is the last 16.x. Running an
58
+ older Node prints a clear message instead of a syntax error.
59
+ - **Electron is optional.** It is only needed for the menu bar UI, it brings its own modern Node, and it
60
+ installs fine under Node 16 (`electron` itself requires only Node >= 12.20). Without a usable Electron or a
61
+ display, the app automatically runs headless — `codex-tracker agent` — which does all the tracking and
62
+ uploading. If your OS is too old for Electron 38, install an older one alongside it
63
+ (`npm i -g electron@22`); the renderer is built for Chromium 108 so it still works.
64
+ - **Hermes SQLite sources are skipped**, because they need `node:sqlite`. This is not a regression: that
65
+ module only arrived in Node 22.5, so the Node 20 build skips them too.
66
+ - **Self-update stays on this package.** `codex-tracker update` checks and installs
67
+ `codex-token-tracker-nodejs16`, never the Node 20 package.
68
+
69
+ ## Development
70
+
71
+ Built from the monorepo; it needs `../menubar/src` present.
72
+
73
+ ```bash
74
+ pnpm --filter codex-token-tracker-nodejs16 build # dev build
75
+ pnpm --filter codex-token-tracker-nodejs16 build:release # what prepack/publish runs
76
+ pnpm --filter codex-token-tracker-nodejs16 typecheck
77
+ pnpm --filter codex-token-tracker-nodejs16 test # suites on the current Node
78
+ pnpm --filter codex-token-tracker-nodejs16 test:node16 # suites on a real Node 16
79
+ ```
80
+
81
+ `test:node16` finds the newest Node 16 under `~/.nvm/versions/node`, or uses `NODE16_BIN`. It runs the
82
+ upstream suites against the node16 bundle, with `node:test` mapped onto a small shim since Node 16 has no
83
+ test runner.
84
+
85
+ ### End-to-end
86
+
87
+ ```bash
88
+ pnpm e2e:node16 # from the repo root
89
+ pnpm e2e:node16:gui # also downloads Electron (~100 MB) and launches the tray app
90
+ ```
91
+
92
+ This does what a user does: builds a release, packs a tarball, installs it with **Node 16's own npm**
93
+ under `--engine-strict`, and drives the installed binary on a real Node 16 — 35 checks across the
94
+ polyfill, the CLI surface, the self-updater and a headless agent cycle.
95
+
96
+ The load-bearing assertion is **differential**: the same synthetic Codex fixtures are fed to both the
97
+ Node 16 build (on Node 16) and the Node 20 build (on your Node), and the two `status --json` reports must
98
+ be byte-identical once timestamps are masked. A port that silently drops a source, mis-parses a number or
99
+ takes a different branch cannot pass that.
100
+
101
+ The run is hermetic — `CODEX_TRACKER_HOME` sends config, state and the update cache to a temp dir (so the
102
+ run is signed out and **nothing can upload**), `CODEX_HOME` and friends point the scanner at fixtures
103
+ rather than your real sessions, and local stub servers stand in for the npm registry and the dashboard, so
104
+ it needs no network. It restores your dev builds and deletes its scratch directory on the way out; pass
105
+ `--keep` to inspect it.
106
+
107
+ The version is kept identical to `codex-token-tracker` by `scripts/sync-version.mjs`, which every build runs.
108
+
109
+ ## License
110
+
111
+ MIT © Chen Li
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ // Kept to ES5 syntax on purpose: this file has to parse on whatever ancient Node the user typed the
4
+ // command with, so that a too-old runtime produces the message below instead of a SyntaxError.
5
+ var v = process.versions.node.split(".");
6
+ var major = parseInt(v[0], 10);
7
+ var minor = parseInt(v[1], 10);
8
+ if (major < 16 || (major === 16 && minor < 8)) {
9
+ console.error(
10
+ "codex-token-tracker-nodejs16 requires Node >= 16.8 (this is Node " +
11
+ process.versions.node +
12
+ ").\nNode 16.8 is the first release its bundled fetch implementation supports; 16.20.2 is the last 16.x."
13
+ );
14
+ process.exit(1);
15
+ }
16
+ // dist/cli.js begins by requiring dist/node16-polyfill.js (injected as an esbuild banner), which
17
+ // installs fetch and the other web globals Node 16 lacks before any application code runs.
18
+ require("../dist/cli.js");