@tickrmeter/ai-usage 0.1.3 → 0.1.4
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 +16 -0
- package/dist/codex.js +16 -19
- package/dist/storage.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,22 @@ Privacy-preserving personal subscription monitoring for Codex / ChatGPT and Clau
|
|
|
17
17
|
The initial `npx` command installs a fixed copy under `~/.tickrmeter-ai/app`. Scheduled runs invoke that fixed version, never `npx ...@latest`.
|
|
18
18
|
On Windows, a standard per-user Startup entry starts the installed Node CLI once at sign-in. The CLI launches one background agent that performs the five-minute sync without recurring console windows. The helper does not install or execute hidden VBS, WScript, or PowerShell wrappers.
|
|
19
19
|
|
|
20
|
+
## Update an existing installation
|
|
21
|
+
|
|
22
|
+
Installed helpers do not update automatically. Run this once on the computer where the helper is already connected:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx @tickrmeter/ai-usage@0.1.4 sync
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This replaces the fixed installed copy, preserves the existing TickrMeter connection, and uploads a fresh snapshot. No new pairing code is needed. On Windows, sign out and back in afterward, or restart the computer, so the already-running background agent also loads the updated code. Other platforms use the updated copy at the next scheduled run.
|
|
29
|
+
|
|
30
|
+
### Version 0.1.4
|
|
31
|
+
|
|
32
|
+
- Preserve separate Codex allowance buckets even when their reset times and durations match.
|
|
33
|
+
- Prefer the current keyed allowance data over a duplicate legacy view, with a legacy fallback when that bucket is absent.
|
|
34
|
+
- Keep main Codex, Spark, and reserve windows distinct so the TickrMeter backend can select the main weekly allowance correctly. Percentages from different allowances are not added together.
|
|
35
|
+
|
|
20
36
|
## Commands
|
|
21
37
|
|
|
22
38
|
```text
|
package/dist/codex.js
CHANGED
|
@@ -43,35 +43,32 @@ const normalizeWindow = (id, value) => {
|
|
|
43
43
|
};
|
|
44
44
|
const collectWindows = (rateResponse) => {
|
|
45
45
|
const candidates = [];
|
|
46
|
-
const addRateLimits = (
|
|
46
|
+
const addRateLimits = (limitId, limits) => {
|
|
47
47
|
if (!limits || typeof limits !== "object" || Array.isArray(limits))
|
|
48
48
|
return;
|
|
49
|
+
if ("usedPercent" in limits) {
|
|
50
|
+
candidates.push([limitId, limits]);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
49
53
|
for (const [key, value] of Object.entries(limits)) {
|
|
50
54
|
if (value && typeof value === "object" && "usedPercent" in value)
|
|
51
|
-
candidates.push([`${
|
|
55
|
+
candidates.push([`${limitId}:${key}`, value]);
|
|
52
56
|
}
|
|
53
57
|
};
|
|
54
|
-
addRateLimits("", rateResponse?.rateLimits);
|
|
55
58
|
const byId = rateResponse?.rateLimitsByLimitId;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const buckets = byId && typeof byId === "object" && !Array.isArray(byId) ? byId : {};
|
|
60
|
+
for (const [limitId, entry] of Object.entries(buckets)) {
|
|
61
|
+
addRateLimits(limitId, entry?.rateLimits || entry);
|
|
62
|
+
}
|
|
63
|
+
// The keyed view is authoritative; the legacy view is only a fallback for its bucket.
|
|
64
|
+
const legacy = rateResponse?.rateLimits;
|
|
65
|
+
const legacyId = typeof legacy?.limitId === "string" && legacy.limitId.trim() ? legacy.limitId : "codex";
|
|
66
|
+
if (!Object.prototype.hasOwnProperty.call(buckets, legacyId)) {
|
|
67
|
+
addRateLimits(legacyId, legacy);
|
|
62
68
|
}
|
|
63
|
-
const seen = new Set();
|
|
64
69
|
return candidates
|
|
65
70
|
.map(([id, value]) => normalizeWindow(id, value))
|
|
66
|
-
.filter((window) =>
|
|
67
|
-
if (!window)
|
|
68
|
-
return false;
|
|
69
|
-
const identity = `${window.windowDurationMins || "unknown"}:${window.resetsAt || window.id}`;
|
|
70
|
-
if (seen.has(identity))
|
|
71
|
-
return false;
|
|
72
|
-
seen.add(identity);
|
|
73
|
-
return true;
|
|
74
|
-
});
|
|
71
|
+
.filter((window) => window !== null);
|
|
75
72
|
};
|
|
76
73
|
const safeCount = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
77
74
|
const findWindowsCodexDesktopExecutable = (rootDirectory) => {
|
package/dist/storage.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.removeLocalBridgeCredential = exports.installFixedCliCopy = exports.writ
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
-
exports.CLI_VERSION = "0.1.
|
|
10
|
+
exports.CLI_VERSION = "0.1.4";
|
|
11
11
|
const getDataDir = () => process.env.TICKRMETER_AI_HOME || path_1.default.join(os_1.default.homedir(), ".tickrmeter-ai");
|
|
12
12
|
exports.getDataDir = getDataDir;
|
|
13
13
|
const getConfigPath = () => path_1.default.join((0, exports.getDataDir)(), "config.json");
|