@ipv9/tokentracker-cli 0.39.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.
- package/LICENSE +21 -0
- package/README.ja.md +464 -0
- package/README.ko.md +464 -0
- package/README.md +476 -0
- package/README.zh-CN.md +469 -0
- package/bin/tracker.js +52 -0
- package/dashboard/dist/app-icon.png +0 -0
- package/dashboard/dist/apple-touch-icon.png +0 -0
- package/dashboard/dist/assets/ActivityHeatmap-BxBGHY1z.js +42 -0
- package/dashboard/dist/assets/Card-GROxUc_6.js +1 -0
- package/dashboard/dist/assets/DashboardPage-BZ5VFoBk.js +19 -0
- package/dashboard/dist/assets/DevicePage-CQts7ivB.js +1 -0
- package/dashboard/dist/assets/DialogTitle-DqFsk26U.js +1 -0
- package/dashboard/dist/assets/FadeIn-HBBXW_3q.js +1 -0
- package/dashboard/dist/assets/HeaderGithubStar-COD2HfaF.js +1 -0
- package/dashboard/dist/assets/IpCheckPage-Cn0l8-BQ.js +15 -0
- package/dashboard/dist/assets/LandingPage-CmV1BMU4.js +4356 -0
- package/dashboard/dist/assets/LeaderboardAvatar-CiIpWZwb.js +1 -0
- package/dashboard/dist/assets/LeaderboardPage-BU0mlR3g.js +6 -0
- package/dashboard/dist/assets/LeaderboardProfileModal-C49_3Xm9.js +72 -0
- package/dashboard/dist/assets/LeaderboardProfilePage-Bh1n0BAM.js +1 -0
- package/dashboard/dist/assets/LimitsPage-fZAmwLWT.js +2 -0
- package/dashboard/dist/assets/LocalOnlyNotice-D3rQdA-P.js +1 -0
- package/dashboard/dist/assets/LoginPage-enO4XP-c.js +1 -0
- package/dashboard/dist/assets/PopoverPopup-pitJEpN1.js +1 -0
- package/dashboard/dist/assets/Select-tT9x4ntD.js +1 -0
- package/dashboard/dist/assets/SelectItemText-C7F7eIm0.js +1 -0
- package/dashboard/dist/assets/SettingsPage-pDasZNU2.js +1 -0
- package/dashboard/dist/assets/SkillsPage-DEu7FY-2.js +1 -0
- package/dashboard/dist/assets/WidgetsPage-DGcO7rbp.js +1 -0
- package/dashboard/dist/assets/WrappedPage-D_1ID213.js +1 -0
- package/dashboard/dist/assets/agent-logos-DXQVg1xy.js +1 -0
- package/dashboard/dist/assets/arrow-up-right-DNLo92Ba.js +1 -0
- package/dashboard/dist/assets/download-DbBBBpJF.js +1 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-400-normal-BPBWmzPh.woff +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-400-normal-Ce5q_31Z.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-500-normal-CJBLNVQT.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-500-normal-mNhfPmgl.woff +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-700-normal-DH5Q319x.woff +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-700-normal-VCNRadI3.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-900-normal-BKC3PZkM.woff +0 -0
- package/dashboard/dist/assets/geist-mono-cyrillic-900-normal-DdrQ8KBw.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-400-normal-CoULgQGM.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-400-normal-LC9RFr9I.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-500-normal-D3o2eNa9.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-500-normal-DOxI7kZ4.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-700-normal-D6izGJRP.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-700-normal-QGw08Lff.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-900-normal-CmoKXrdK.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-900-normal-Cu5MFKsu.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-400-normal-Cgks_Qgx.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-400-normal-CxNRRMGd.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-500-normal-CQcGuCNt.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-500-normal-diTenJ8L.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-700-normal-BX9f1BHp.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-700-normal-YOllDaLV.woff2 +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-900-normal-Br6WNUGb.woff +0 -0
- package/dashboard/dist/assets/geist-mono-latin-ext-900-normal-CrmBTzU2.woff2 +0 -0
- package/dashboard/dist/assets/index-BeoRn2gJ.js +2 -0
- package/dashboard/dist/assets/info-Bh5qTz6k.js +1 -0
- package/dashboard/dist/assets/main-BIY3Nj6I.js +969 -0
- package/dashboard/dist/assets/main-G_F9Iu_x.css +1 -0
- package/dashboard/dist/assets/use-limits-display-prefs-B4iJ-bBc.js +1 -0
- package/dashboard/dist/assets/use-native-settings-DHjPFDv8.js +1 -0
- package/dashboard/dist/assets/use-usage-limits-odqe9OY7.js +1 -0
- package/dashboard/dist/assets/useCurrency-BsSZiZMP.js +1 -0
- package/dashboard/dist/assets/useOpenInteractionType-BQhgq4rv.js +12 -0
- package/dashboard/dist/brand-logos/antigravity.svg +1 -0
- package/dashboard/dist/brand-logos/claude-code.svg +1 -0
- package/dashboard/dist/brand-logos/codebuddy.svg +1 -0
- package/dashboard/dist/brand-logos/codex.svg +15 -0
- package/dashboard/dist/brand-logos/copilot.svg +1 -0
- package/dashboard/dist/brand-logos/cursor.svg +1 -0
- package/dashboard/dist/brand-logos/gemini.svg +1 -0
- package/dashboard/dist/brand-logos/grok.svg +1 -0
- package/dashboard/dist/brand-logos/hermes.svg +1 -0
- package/dashboard/dist/brand-logos/kilo.svg +4 -0
- package/dashboard/dist/brand-logos/kimi.svg +1 -0
- package/dashboard/dist/brand-logos/kiro.svg +1 -0
- package/dashboard/dist/brand-logos/openclaw.svg +22 -0
- package/dashboard/dist/brand-logos/opencode.svg +3 -0
- package/dashboard/dist/clawd/happy.svg +161 -0
- package/dashboard/dist/clawd/idle/collapse.svg +101 -0
- package/dashboard/dist/clawd/idle/doze.svg +72 -0
- package/dashboard/dist/clawd/idle/follow.svg +64 -0
- package/dashboard/dist/clawd/idle/living.svg +196 -0
- package/dashboard/dist/clawd/idle/look.svg +115 -0
- package/dashboard/dist/clawd/idle/yawn.svg +158 -0
- package/dashboard/dist/clawd/mini/alert.svg +129 -0
- package/dashboard/dist/clawd/mini/crabwalk.svg +76 -0
- package/dashboard/dist/clawd/mini/enter-sleep.svg +65 -0
- package/dashboard/dist/clawd/mini/enter.svg +115 -0
- package/dashboard/dist/clawd/mini/happy.svg +124 -0
- package/dashboard/dist/clawd/mini/idle-tight.svg +15 -0
- package/dashboard/dist/clawd/mini/idle.svg +83 -0
- package/dashboard/dist/clawd/mini/peek.svg +82 -0
- package/dashboard/dist/clawd/mini/sleep.svg +112 -0
- package/dashboard/dist/clawd/react/double.svg +108 -0
- package/dashboard/dist/clawd/react/drag.svg +102 -0
- package/dashboard/dist/clawd/react/left.svg +102 -0
- package/dashboard/dist/clawd/react/right.svg +102 -0
- package/dashboard/dist/clawd/sleep/collapse-sleep.svg +247 -0
- package/dashboard/dist/clawd/sleep/sleeping.svg +118 -0
- package/dashboard/dist/clawd/sleep/wake.svg +277 -0
- package/dashboard/dist/clawd/static-base.svg +21 -0
- package/dashboard/dist/clawd/status/disconnected.svg +136 -0
- package/dashboard/dist/clawd/status/error.svg +94 -0
- package/dashboard/dist/clawd/status/notification.svg +134 -0
- package/dashboard/dist/clawd/working/building.svg +231 -0
- package/dashboard/dist/clawd/working/carrying.svg +107 -0
- package/dashboard/dist/clawd/working/conducting.svg +118 -0
- package/dashboard/dist/clawd/working/confused.svg +113 -0
- package/dashboard/dist/clawd/working/debugger.svg +91 -0
- package/dashboard/dist/clawd/working/juggling.svg +82 -0
- package/dashboard/dist/clawd/working/overheated.svg +75 -0
- package/dashboard/dist/clawd/working/pushing.svg +125 -0
- package/dashboard/dist/clawd/working/sweeping.svg +79 -0
- package/dashboard/dist/clawd/working/thinking.svg +119 -0
- package/dashboard/dist/clawd/working/typing.svg +153 -0
- package/dashboard/dist/clawd/working/ultrathink.svg +166 -0
- package/dashboard/dist/clawd/working/wizard.svg +98 -0
- package/dashboard/dist/dashboard-dark.png +0 -0
- package/dashboard/dist/favicon-16.png +0 -0
- package/dashboard/dist/favicon-32.png +0 -0
- package/dashboard/dist/favicon.ico +0 -0
- package/dashboard/dist/feed.xml +34 -0
- package/dashboard/dist/icon-192.png +0 -0
- package/dashboard/dist/icon-512.png +0 -0
- package/dashboard/dist/index.html +355 -0
- package/dashboard/dist/llms.txt +53 -0
- package/dashboard/dist/neon_bg.png +0 -0
- package/dashboard/dist/robots.txt +7 -0
- package/dashboard/dist/share.html +140 -0
- package/dashboard/dist/sitemap.xml +27 -0
- package/dashboard/dist/widgets-overview.png +0 -0
- package/package.json +78 -0
- package/scripts/install-local-service.sh +140 -0
- package/scripts/uninstall-local-service.sh +21 -0
- package/src/cli.js +95 -0
- package/src/commands/device-login.js +161 -0
- package/src/commands/diagnostics.js +38 -0
- package/src/commands/doctor.js +96 -0
- package/src/commands/init.js +1195 -0
- package/src/commands/serve.js +351 -0
- package/src/commands/status.js +609 -0
- package/src/commands/sync.js +2285 -0
- package/src/commands/uninstall.js +189 -0
- package/src/commands/wrapped.js +150 -0
- package/src/lib/antigravity-paths.js +48 -0
- package/src/lib/browser-auth.js +281 -0
- package/src/lib/categorizer-utils.js +232 -0
- package/src/lib/claude-categorizer.js +1319 -0
- package/src/lib/claude-config.js +204 -0
- package/src/lib/cli-ui.js +179 -0
- package/src/lib/codex-config.js +350 -0
- package/src/lib/codex-context-breakdown.js +400 -0
- package/src/lib/codex-rollout-parser.js +623 -0
- package/src/lib/codex-token-refresh.js +112 -0
- package/src/lib/cursor-config.js +425 -0
- package/src/lib/debug-flags.js +7 -0
- package/src/lib/diagnostics.js +272 -0
- package/src/lib/doctor.js +338 -0
- package/src/lib/fs.js +91 -0
- package/src/lib/gemini-config.js +288 -0
- package/src/lib/grok-hook.js +351 -0
- package/src/lib/init-flow.js +42 -0
- package/src/lib/local-api.js +1861 -0
- package/src/lib/openclaw-hook.js +420 -0
- package/src/lib/openclaw-session-plugin.js +520 -0
- package/src/lib/opencode-config.js +99 -0
- package/src/lib/passive-mode.js +185 -0
- package/src/lib/pricing/curated-overrides.json +79 -0
- package/src/lib/pricing/index.js +143 -0
- package/src/lib/pricing/litellm-fetcher.js +172 -0
- package/src/lib/pricing/matcher.js +255 -0
- package/src/lib/pricing/seed-snapshot.json +1 -0
- package/src/lib/progress.js +76 -0
- package/src/lib/project-usage-purge.js +106 -0
- package/src/lib/prompt.js +24 -0
- package/src/lib/proxy-env.js +131 -0
- package/src/lib/rollout.js +8442 -0
- package/src/lib/runtime-config.js +122 -0
- package/src/lib/skill-usage.js +267 -0
- package/src/lib/skills-manager.js +1127 -0
- package/src/lib/source-metadata.js +48 -0
- package/src/lib/sqlite-reader.js +136 -0
- package/src/lib/static-server.js +59 -0
- package/src/lib/subscriptions.js +453 -0
- package/src/lib/tracker-paths.js +16 -0
- package/src/lib/upload-throttle.js +148 -0
- package/src/lib/usage-limits.js +1806 -0
- package/src/lib/wrapped-aggregator.js +225 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const os = require("node:os");
|
|
2
|
+
const path = require("node:path");
|
|
3
|
+
|
|
4
|
+
async function resolveTrackerPaths({ home = os.homedir() } = {}) {
|
|
5
|
+
const rootDir = path.join(home, ".tokentracker");
|
|
6
|
+
return {
|
|
7
|
+
rootDir,
|
|
8
|
+
trackerDir: path.join(rootDir, "tracker"),
|
|
9
|
+
binDir: path.join(rootDir, "bin"),
|
|
10
|
+
cacheDir: path.join(rootDir, "cache"),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
resolveTrackerPaths,
|
|
16
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const DEFAULTS = {
|
|
2
|
+
intervalMs: 30 * 60_000,
|
|
3
|
+
jitterMsMax: 60_000,
|
|
4
|
+
backlogBytes: 1_000_000,
|
|
5
|
+
batchSize: 300,
|
|
6
|
+
maxBatchesSmall: 2,
|
|
7
|
+
maxBatchesLarge: 4,
|
|
8
|
+
backoffInitialMs: 60_000,
|
|
9
|
+
backoffMaxMs: 30 * 60_000,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function normalizeState(raw) {
|
|
13
|
+
const s = raw && typeof raw === "object" ? raw : {};
|
|
14
|
+
return {
|
|
15
|
+
version: 1,
|
|
16
|
+
lastSuccessMs: toSafeInt(s.lastSuccessMs),
|
|
17
|
+
nextAllowedAtMs: toSafeInt(s.nextAllowedAtMs),
|
|
18
|
+
backoffUntilMs: toSafeInt(s.backoffUntilMs),
|
|
19
|
+
backoffStep: toSafeInt(s.backoffStep),
|
|
20
|
+
lastErrorAt: typeof s.lastErrorAt === "string" ? s.lastErrorAt : null,
|
|
21
|
+
lastError: typeof s.lastError === "string" ? s.lastError : null,
|
|
22
|
+
updatedAt: typeof s.updatedAt === "string" ? s.updatedAt : null,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function decideAutoUpload({ nowMs, pendingBytes, state, config }) {
|
|
27
|
+
const cfg = { ...DEFAULTS, ...(config || {}) };
|
|
28
|
+
const s = normalizeState(state);
|
|
29
|
+
const pending = Number(pendingBytes || 0);
|
|
30
|
+
|
|
31
|
+
if (pending <= 0) {
|
|
32
|
+
return {
|
|
33
|
+
allowed: false,
|
|
34
|
+
reason: "no-pending",
|
|
35
|
+
maxBatches: 0,
|
|
36
|
+
batchSize: cfg.batchSize,
|
|
37
|
+
blockedUntilMs: 0,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const blockedUntilMs = Math.max(s.nextAllowedAtMs || 0, s.backoffUntilMs || 0);
|
|
42
|
+
if (blockedUntilMs > 0 && nowMs < blockedUntilMs) {
|
|
43
|
+
return {
|
|
44
|
+
allowed: false,
|
|
45
|
+
reason: "throttled",
|
|
46
|
+
maxBatches: 0,
|
|
47
|
+
batchSize: cfg.batchSize,
|
|
48
|
+
blockedUntilMs,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const maxBatches = pending >= cfg.backlogBytes ? cfg.maxBatchesLarge : cfg.maxBatchesSmall;
|
|
53
|
+
return {
|
|
54
|
+
allowed: true,
|
|
55
|
+
reason: "allowed",
|
|
56
|
+
maxBatches,
|
|
57
|
+
batchSize: cfg.batchSize,
|
|
58
|
+
blockedUntilMs: 0,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function recordUploadSuccess({ nowMs, state, config, randInt }) {
|
|
63
|
+
const cfg = { ...DEFAULTS, ...(config || {}) };
|
|
64
|
+
const s = normalizeState(state);
|
|
65
|
+
const jitter =
|
|
66
|
+
typeof randInt === "function" ? randInt(0, cfg.jitterMsMax) : randomInt(0, cfg.jitterMsMax);
|
|
67
|
+
const nextAllowedAtMs = nowMs + cfg.intervalMs + jitter;
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
...s,
|
|
71
|
+
lastSuccessMs: nowMs,
|
|
72
|
+
nextAllowedAtMs,
|
|
73
|
+
backoffUntilMs: 0,
|
|
74
|
+
backoffStep: 0,
|
|
75
|
+
lastErrorAt: null,
|
|
76
|
+
lastError: null,
|
|
77
|
+
updatedAt: new Date(nowMs).toISOString(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function recordUploadFailure({ nowMs, state, error, config }) {
|
|
82
|
+
const cfg = { ...DEFAULTS, ...(config || {}) };
|
|
83
|
+
const s = normalizeState(state);
|
|
84
|
+
|
|
85
|
+
const retryAfterMs = toSafeInt(error?.retryAfterMs);
|
|
86
|
+
const status = toSafeInt(error?.status);
|
|
87
|
+
|
|
88
|
+
let backoffMs = 0;
|
|
89
|
+
if (retryAfterMs > 0) {
|
|
90
|
+
backoffMs = Math.min(cfg.backoffMaxMs, Math.max(cfg.backoffInitialMs, retryAfterMs));
|
|
91
|
+
} else {
|
|
92
|
+
const step = Math.min(10, Math.max(0, s.backoffStep || 0));
|
|
93
|
+
backoffMs = Math.min(cfg.backoffMaxMs, cfg.backoffInitialMs * Math.pow(2, step));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const backoffUntilMs = nowMs + backoffMs;
|
|
97
|
+
const nextAllowedAtMs = Math.max(s.nextAllowedAtMs || 0, backoffUntilMs);
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
...s,
|
|
101
|
+
nextAllowedAtMs,
|
|
102
|
+
backoffUntilMs,
|
|
103
|
+
backoffStep: Math.min(20, (s.backoffStep || 0) + 1),
|
|
104
|
+
lastErrorAt: new Date(nowMs).toISOString(),
|
|
105
|
+
lastError: truncate(String(error?.message || "upload failed"), 200),
|
|
106
|
+
updatedAt: new Date(nowMs).toISOString(),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function parseRetryAfterMs(headerValue, nowMs = Date.now()) {
|
|
111
|
+
if (typeof headerValue !== "string" || headerValue.trim().length === 0) return null;
|
|
112
|
+
const v = headerValue.trim();
|
|
113
|
+
const seconds = Number(v);
|
|
114
|
+
if (Number.isFinite(seconds) && seconds >= 0) return Math.floor(seconds * 1000);
|
|
115
|
+
const d = new Date(v);
|
|
116
|
+
if (Number.isNaN(d.getTime())) return null;
|
|
117
|
+
const delta = d.getTime() - nowMs;
|
|
118
|
+
return delta > 0 ? delta : 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function randomInt(min, maxInclusive) {
|
|
122
|
+
const lo = Math.floor(min);
|
|
123
|
+
const hi = Math.floor(maxInclusive);
|
|
124
|
+
if (hi <= lo) return lo;
|
|
125
|
+
return lo + Math.floor(Math.random() * (hi - lo + 1));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function toSafeInt(v) {
|
|
129
|
+
const n = Number(v);
|
|
130
|
+
if (!Number.isFinite(n)) return 0;
|
|
131
|
+
if (n <= 0) return 0;
|
|
132
|
+
return Math.floor(n);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function truncate(s, maxLen) {
|
|
136
|
+
if (typeof s !== "string") return "";
|
|
137
|
+
if (s.length <= maxLen) return s;
|
|
138
|
+
return s.slice(0, maxLen - 1) + "…";
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = {
|
|
142
|
+
DEFAULTS,
|
|
143
|
+
normalizeState,
|
|
144
|
+
decideAutoUpload,
|
|
145
|
+
recordUploadSuccess,
|
|
146
|
+
recordUploadFailure,
|
|
147
|
+
parseRetryAfterMs,
|
|
148
|
+
};
|