tokmon 0.28.2 → 0.28.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.
Files changed (56) hide show
  1. package/README.md +156 -234
  2. package/THIRD_PARTY_NOTICES.md +62 -0
  3. package/dist/{bootstrap-ink-IMT3S5HU.js → bootstrap-ink-WG4WG3R2.js} +1579 -1136
  4. package/dist/chunk-5B3XCEMC.js +294 -0
  5. package/dist/chunk-7CH6S7BR.js +447 -0
  6. package/dist/{chunk-LCAHTRGP.js → chunk-CFKUZCMB.js} +56 -29
  7. package/dist/{chunk-LKYOWBD4.js → chunk-FLANGRI6.js} +21 -42
  8. package/dist/chunk-HNWEJ6MS.js +1094 -0
  9. package/dist/{chunk-WUK3MQUB.js → chunk-JZSZEHVD.js} +167 -10
  10. package/dist/{chunk-6ZEW2M6P.js → chunk-P57DVFNH.js} +125 -25
  11. package/dist/chunk-TN6V7XSL.js +512 -0
  12. package/dist/chunk-UYPDMVW5.js +21 -0
  13. package/dist/{cli-command-DCENRCO3.js → cli-command-I4GRR3MF.js} +249 -15
  14. package/dist/cli.js +6 -6
  15. package/dist/{config-HXFJTNLM.js → config-3DGZ47F7.js} +23 -3
  16. package/dist/daemon-ZXV3V5CS.js +384 -0
  17. package/dist/daemon-handle-G4OGPFR3.js +11 -0
  18. package/dist/server-EPSH52DR.js +12 -0
  19. package/dist/web/assets/{Area-CMXvOw33.js → Area-stRnp8Km.js} +1 -1
  20. package/dist/web/assets/analytics-moZZt9L_.js +2 -0
  21. package/dist/web/assets/breakdown-km9w7myU.js +4 -0
  22. package/dist/web/assets/button-DrX04Cc2.js +1 -0
  23. package/dist/web/assets/{chart-cZoLgpmG.js → chart-D0CtuL2k.js} +1 -1
  24. package/dist/web/assets/explore-B11uNJV1.js +22 -0
  25. package/dist/web/assets/index-RDhXsCNG.js +83 -0
  26. package/dist/web/assets/index-ZmOS8p9O.css +1 -0
  27. package/dist/web/assets/models-DYbZnY34.js +2 -0
  28. package/dist/web/assets/overview-CruICbfJ.js +2 -0
  29. package/dist/web/assets/panel-xckM3_GC.js +1 -0
  30. package/dist/web/assets/settings-sheet-G-BTSIF6.js +1 -0
  31. package/dist/web/assets/share-sheet-weIdd4DW.js +2 -0
  32. package/dist/web/assets/timeline-BHgniliZ.js +1 -0
  33. package/dist/web/index.html +30 -4
  34. package/package.json +13 -4
  35. package/site/THIRD_PARTY_NOTICES.md +83 -0
  36. package/site/public/fonts/OFL.txt +93 -0
  37. package/dist/chunk-44ZSQEOS.js +0 -299
  38. package/dist/chunk-HP5UZCXP.js +0 -436
  39. package/dist/chunk-J3JW3RFP.js +0 -196
  40. package/dist/chunk-M7XMV36F.js +0 -275
  41. package/dist/daemon-6Y4O7NXS.js +0 -241
  42. package/dist/daemon-handle-GVCYVDPO.js +0 -10
  43. package/dist/server-GXXOWUVZ.js +0 -11
  44. package/dist/web/assets/analytics-DqdZXOJL.js +0 -2
  45. package/dist/web/assets/breakdown-kOSSJ3mI.js +0 -4
  46. package/dist/web/assets/explore-vcsM8K9I.js +0 -22
  47. package/dist/web/assets/index-BErCXT7f.css +0 -1
  48. package/dist/web/assets/index-DH3dOnbg.js +0 -83
  49. package/dist/web/assets/models-B5ikm83_.js +0 -2
  50. package/dist/web/assets/overview-DD1kP8CP.js +0 -2
  51. package/dist/web/assets/panel-DTQBwExW.js +0 -1
  52. package/dist/web/assets/primitives-C36qJlA2.js +0 -1
  53. package/dist/web/assets/settings-sheet-_i2zTQjf.js +0 -1
  54. package/dist/web/assets/share-sheet-BLHmrFbm.js +0 -2
  55. package/dist/web/assets/timeline-B4uG-Emo.js +0 -1
  56. package/dist/web/assets/use-dialog-trap-bfaXEMz9.js +0 -1
@@ -0,0 +1,93 @@
1
+ JetBrains Mono
2
+ Copyright 2020 The JetBrains Mono Project Authors
3
+ (https://github.com/JetBrains/JetBrainsMono)
4
+
5
+ Departure Mono
6
+ Copyright 2022-2024 Helena Zhang (https://helenazhang.com)
7
+
8
+ Both font families are distributed under the SIL Open Font License,
9
+ Version 1.1. The license is copied below and is also available with a FAQ at:
10
+ https://openfontlicense.org
11
+
12
+ -----------------------------------------------------------
13
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
14
+ -----------------------------------------------------------
15
+
16
+ PREAMBLE
17
+ The goals of the Open Font License (OFL) are to stimulate worldwide
18
+ development of collaborative font projects, to support the font creation
19
+ efforts of academic and linguistic communities, and to provide a free and
20
+ open framework in which fonts may be shared and improved in partnership
21
+ with others.
22
+
23
+ The OFL allows the licensed fonts to be used, studied, modified and
24
+ redistributed freely as long as they are not sold by themselves. The fonts,
25
+ including any derivative works, can be bundled, embedded, redistributed
26
+ and/or sold with any software provided that any reserved names are not used
27
+ by derivative works. The fonts and derivatives, however, cannot be released
28
+ under any other type of license. The requirement for fonts to remain under
29
+ this license does not apply to any document created using the fonts or their
30
+ derivatives.
31
+
32
+ DEFINITIONS
33
+ "Font Software" refers to the set of files released by the Copyright
34
+ Holder(s) under this license and clearly marked as such. This may include
35
+ source files, build scripts and documentation.
36
+
37
+ "Reserved Font Name" refers to any names specified as such after the
38
+ copyright statement(s).
39
+
40
+ "Original Version" refers to the collection of Font Software components as
41
+ distributed by the Copyright Holder(s).
42
+
43
+ "Modified Version" refers to any derivative made by adding to, deleting,
44
+ or substituting -- in part or in whole -- any of the components of the
45
+ Original Version, by changing formats or by porting the Font Software to a
46
+ new environment.
47
+
48
+ "Author" refers to any designer, engineer, programmer, technical writer or
49
+ other person who contributed to the Font Software.
50
+
51
+ PERMISSION & CONDITIONS
52
+ Permission is hereby granted, free of charge, to any person obtaining a copy
53
+ of the Font Software, to use, study, copy, merge, embed, modify, redistribute,
54
+ and sell modified and unmodified copies of the Font Software, subject to the
55
+ following conditions:
56
+
57
+ 1) Neither the Font Software nor any of its individual components, in
58
+ Original or Modified Versions, may be sold by itself.
59
+
60
+ 2) Original or Modified Versions of the Font Software may be bundled,
61
+ redistributed and/or sold with any software, provided that each copy contains
62
+ the above copyright notice and this license. These can be included either as
63
+ stand-alone text files, human-readable headers or in the appropriate
64
+ machine-readable metadata fields within text or binary files as long as those
65
+ fields can be easily viewed by the user.
66
+
67
+ 3) No Modified Version of the Font Software may use the Reserved Font Name(s)
68
+ unless explicit written permission is granted by the corresponding Copyright
69
+ Holder. This restriction only applies to the primary font name as presented
70
+ to the users.
71
+
72
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
73
+ Software shall not be used to promote, endorse or advertise any Modified
74
+ Version, except to acknowledge the contribution(s) of the Copyright Holder(s)
75
+ and the Author(s) or with their explicit written permission.
76
+
77
+ 5) The Font Software, modified or unmodified, in part or in whole, must be
78
+ distributed entirely under this license, and must not be distributed under
79
+ any other license. The requirement for fonts to remain under this license
80
+ does not apply to any document created using the Font Software.
81
+
82
+ TERMINATION
83
+ This license becomes null and void if any of the above conditions are not met.
84
+
85
+ DISCLAIMER
86
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
87
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
88
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
89
+ TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR
90
+ ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL,
91
+ INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF
92
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE
93
+ THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -1,299 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- PROVIDERS,
4
- PROVIDER_ORDER,
5
- identityFromIdToken,
6
- readClaudeIdentity,
7
- readJson
8
- } from "./chunk-LCAHTRGP.js";
9
- import {
10
- expandHome,
11
- slugify
12
- } from "./chunk-HP5UZCXP.js";
13
-
14
- // src/accounts.ts
15
- import { existsSync, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
16
- import { homedir } from "os";
17
- import { basename, join as join2, resolve } from "path";
18
-
19
- // src/providers/codex/identity.ts
20
- import { readFileSync } from "fs";
21
- import { join } from "path";
22
- function codexAuthPaths(homeDir) {
23
- return [join(homeDir, ".codex", "auth.json"), join(homeDir, "auth.json")];
24
- }
25
- function readCodexIdentity(homeDir) {
26
- for (const path of codexAuthPaths(homeDir)) {
27
- try {
28
- const parsed = JSON.parse(readFileSync(path, "utf-8"));
29
- const { email, displayName, payload } = identityFromIdToken(parsed?.tokens?.id_token);
30
- if (!payload) continue;
31
- return { email, displayName };
32
- } catch {
33
- }
34
- }
35
- return {};
36
- }
37
-
38
- // src/accounts.ts
39
- function accountKey(providerId, homeDir) {
40
- return `${providerId}:${homeDir ? resolve(expandHome(homeDir)) : homedir()}`;
41
- }
42
- function uniqueId(base, used) {
43
- let id = slugify(base) || "account";
44
- if (!used.has(id)) {
45
- used.add(id);
46
- return id;
47
- }
48
- for (let i = 2; i < 1e3; i++) {
49
- const next = `${id}_${i}`;
50
- if (!used.has(next)) {
51
- used.add(next);
52
- return next;
53
- }
54
- }
55
- id = `${id}_${Date.now()}`;
56
- used.add(id);
57
- return id;
58
- }
59
- function hasClaudeState(homeDir) {
60
- return existsSync(join2(homeDir, ".claude.json")) || existsSync(join2(homeDir, ".claude", ".credentials.json")) || existsSync(join2(homeDir, ".claude", "projects")) || existsSync(join2(homeDir, ".config", "claude", ".credentials.json")) || existsSync(join2(homeDir, ".config", "claude", "projects"));
61
- }
62
- function candidateAlternateHomes(prefix) {
63
- const home = homedir();
64
- let entries;
65
- try {
66
- entries = readdirSync(home);
67
- } catch {
68
- return [];
69
- }
70
- const out = [];
71
- const pattern = new RegExp(`^\\.${prefix}[_-]`);
72
- for (const name of entries) {
73
- if (!pattern.test(name)) continue;
74
- const path = join2(home, name);
75
- try {
76
- if (!statSync(path).isDirectory()) continue;
77
- out.push(path);
78
- } catch {
79
- }
80
- }
81
- return out.sort();
82
- }
83
- function labelForClaudeHome(homeDir) {
84
- const identity = readClaudeIdentity(homeDir);
85
- if (identity.email) return `Claude ${identity.email}`;
86
- if (identity.displayName) return `Claude ${identity.displayName}`;
87
- const raw = basename(homeDir).replace(/^\.claude[_-]?/, "").replace(/[_-]+/g, " ").trim();
88
- return raw ? `Claude ${raw}` : "Claude";
89
- }
90
- function hasCodexAuth(homeDir) {
91
- for (const path of codexAuthPaths(homeDir)) {
92
- try {
93
- const parsed = JSON.parse(readFileSync2(path, "utf-8"));
94
- const accessToken = parsed?.tokens?.access_token;
95
- if (typeof accessToken === "string" && accessToken.trim()) return true;
96
- } catch {
97
- }
98
- }
99
- return false;
100
- }
101
- function labelForCodexHome(homeDir) {
102
- const identity = readCodexIdentity(homeDir);
103
- if (identity.email) return `Codex ${identity.email}`;
104
- if (identity.displayName) return `Codex ${identity.displayName}`;
105
- const raw = basename(homeDir).replace(/^\.codex[_-]?/, "").replace(/[_-]+/g, " ").trim();
106
- return raw ? `Codex ${raw}` : "Codex";
107
- }
108
- function discoverClaudeAccounts(usedIds) {
109
- const provider = PROVIDERS.claude;
110
- const out = [];
111
- for (const homeDir of candidateAlternateHomes("claude")) {
112
- if (!hasClaudeState(homeDir)) continue;
113
- const suffix = basename(homeDir).replace(/^\.claude[_-]?/, "") || basename(homeDir);
114
- out.push({
115
- id: uniqueId(`claude_${suffix}`, usedIds),
116
- providerId: "claude",
117
- name: labelForClaudeHome(homeDir),
118
- color: provider.color,
119
- homeDir
120
- });
121
- }
122
- return out;
123
- }
124
- function discoverCodexAccounts(usedIds) {
125
- const provider = PROVIDERS.codex;
126
- const out = [];
127
- for (const homeDir of candidateAlternateHomes("codex")) {
128
- if (!hasCodexAuth(homeDir)) continue;
129
- const suffix = basename(homeDir).replace(/^\.codex[_-]?/, "") || basename(homeDir);
130
- out.push({
131
- id: uniqueId(`codex_${suffix}`, usedIds),
132
- providerId: "codex",
133
- name: labelForCodexHome(homeDir),
134
- color: provider.color,
135
- homeDir
136
- });
137
- }
138
- return out;
139
- }
140
- function discoverProviderAccounts(providerId, usedIds) {
141
- if (providerId === "claude") return discoverClaudeAccounts(usedIds);
142
- if (providerId === "codex") return discoverCodexAccounts(usedIds);
143
- return [];
144
- }
145
- function buildAccounts(config, detected) {
146
- const out = [];
147
- const usedIds = new Set(config.accounts.map((a) => a.id));
148
- const seenKeys = /* @__PURE__ */ new Set();
149
- const add = (account) => {
150
- const key = accountKey(account.providerId, account.homeDir);
151
- if (seenKeys.has(key)) return;
152
- seenKeys.add(key);
153
- out.push(account);
154
- };
155
- for (const pid of PROVIDER_ORDER) {
156
- if (config.disabledProviders.includes(pid)) continue;
157
- const provider = PROVIDERS[pid];
158
- const configured = config.accounts.filter((a) => a.providerId === pid);
159
- for (const a of configured) {
160
- add({
161
- id: a.id,
162
- providerId: pid,
163
- name: a.name,
164
- color: a.color || provider.color,
165
- homeDir: a.homeDir && a.homeDir !== "~" ? expandHome(a.homeDir) : void 0
166
- });
167
- }
168
- const discovered = discoverProviderAccounts(pid, usedIds);
169
- if (detected.includes(pid)) {
170
- add({ id: pid, providerId: pid, name: provider.name, color: provider.color, homeDir: void 0 });
171
- }
172
- for (const account of discovered) {
173
- add(account);
174
- }
175
- }
176
- return out;
177
- }
178
- function accountsByProvider(accounts) {
179
- const groups = [];
180
- for (const pid of PROVIDER_ORDER) {
181
- const list = accounts.filter((a) => a.providerId === pid);
182
- if (list.length > 0) groups.push({ provider: pid, accounts: list });
183
- }
184
- return groups;
185
- }
186
-
187
- // src/shared/colors.ts
188
- var FALLBACK_HEX = "#8d9090";
189
- var NAMED_HEX = {
190
- green: "#6caa71",
191
- greenBright: "#79be7e",
192
- cyan: "#7ccbcd",
193
- cyanBright: "#84dde0",
194
- blue: "#6d96b4",
195
- blueBright: "#67b5ed",
196
- magenta: "#bd7bcd",
197
- magentaBright: "#d389e5",
198
- yellow: "#c4ac62",
199
- yellowBright: "#d9c074",
200
- red: "#b45648",
201
- redBright: "#cf6a5a",
202
- white: "#dee5eb",
203
- whiteBright: "#f3f5f5",
204
- gray: FALLBACK_HEX,
205
- grey: FALLBACK_HEX
206
- };
207
- var PROVIDER_HEX = {
208
- claude: NAMED_HEX.green,
209
- codex: NAMED_HEX.cyan,
210
- cursor: NAMED_HEX.magenta,
211
- copilot: NAMED_HEX.white,
212
- pi: NAMED_HEX.blue,
213
- opencode: NAMED_HEX.yellow,
214
- antigravity: NAMED_HEX.red,
215
- gemini: NAMED_HEX.greenBright,
216
- grok: NAMED_HEX.yellowBright
217
- };
218
- function namedHex(name) {
219
- if (!name) return FALLBACK_HEX;
220
- if (name.startsWith("#")) return name;
221
- return NAMED_HEX[name] ?? FALLBACK_HEX;
222
- }
223
- function colorHex(accountColor, providerColorName) {
224
- if (accountColor) {
225
- if (accountColor.startsWith("#")) return accountColor;
226
- const named = NAMED_HEX[accountColor];
227
- if (named) return named;
228
- }
229
- return namedHex(providerColorName);
230
- }
231
- var MODEL_PALETTE = [
232
- "#00d7ff",
233
- "#00d787",
234
- "#e6b450",
235
- "#d75f87",
236
- "#5f87ff",
237
- "#af87ff",
238
- "#5fd7a7",
239
- "#ff8787",
240
- "#d7af5f",
241
- "#87d7ff",
242
- "#d787d7",
243
- "#9ee493",
244
- "#ffb454",
245
- "#7aa2f7",
246
- "#bb9af7"
247
- ];
248
- var modelColorCache = /* @__PURE__ */ new Map();
249
- function modelColor(name) {
250
- const cached = modelColorCache.get(name);
251
- if (cached) return cached;
252
- let hash = 0;
253
- for (let i = 0; i < name.length; i++) hash = hash * 31 + name.charCodeAt(i) >>> 0;
254
- const color = MODEL_PALETTE[hash % MODEL_PALETTE.length];
255
- modelColorCache.set(name, color);
256
- return color;
257
- }
258
- var TOKEN_BUCKET = {
259
- input: NAMED_HEX.blue,
260
- output: NAMED_HEX.green,
261
- cacheCreate: NAMED_HEX.yellow,
262
- cacheRead: NAMED_HEX.cyan
263
- };
264
-
265
- // src/peak.ts
266
- async function fetchPeak() {
267
- try {
268
- const res = await fetch("https://promoclock.co/api/status", {
269
- headers: { "Accept": "application/json", "User-Agent": "tokmon" },
270
- signal: AbortSignal.timeout(3e3)
271
- });
272
- if (!res.ok) return null;
273
- const data = await readJson(res);
274
- if (!data) return null;
275
- let state;
276
- if (data.isPeak === true || data.status === "peak") state = "peak";
277
- else if (data.isWeekend === true || data.status === "weekend") state = "weekend";
278
- else if (data.isOffPeak === true || data.status === "off_peak" || data.status === "off-peak") state = "off-peak";
279
- else return null;
280
- const minutesUntilChange = typeof data.minutesUntilChange === "number" && Number.isFinite(data.minutesUntilChange) ? data.minutesUntilChange : null;
281
- return {
282
- state,
283
- label: state === "peak" ? "Peak" : state === "weekend" ? "Weekend" : "Off-Peak",
284
- minutesUntilChange,
285
- changesAt: minutesUntilChange !== null ? new Date(Date.now() + minutesUntilChange * 6e4).toISOString() : null
286
- };
287
- } catch {
288
- return null;
289
- }
290
- }
291
-
292
- export {
293
- buildAccounts,
294
- accountsByProvider,
295
- namedHex,
296
- colorHex,
297
- modelColor,
298
- fetchPeak
299
- };