@hashimkarim/usagestat-darwin-arm64 2.0.0-alpha.3 → 2.3.2

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 (284) hide show
  1. package/native-manifest.json +1532 -134
  2. package/package.json +235 -2
  3. package/plugins/UPSTREAM-LICENSES.md +6 -2
  4. package/plugins/_provider-icons/LICENSE +21 -0
  5. package/plugins/_provider-icons/NOTICE +12 -0
  6. package/plugins/_provider-icons/licenses/CodexBar-MIT.txt +21 -0
  7. package/plugins/_provider-icons/licenses/LobeHub-MIT.txt +21 -0
  8. package/plugins/_provider-icons/licenses/UsageStat-Bar-MIT.txt +21 -0
  9. package/plugins/_provider-icons/manifest.json +1219 -0
  10. package/plugins/_provider-icons/provenance.json +269 -0
  11. package/plugins/_provider-icons/source.json +4 -0
  12. package/plugins/abacus-ai/icon-color.svg +18 -0
  13. package/plugins/abliteration/LICENSE +21 -0
  14. package/plugins/abliteration/icon.svg +5 -0
  15. package/plugins/abliteration/plugin.js +89 -0
  16. package/plugins/abliteration/plugin.json +24 -0
  17. package/plugins/aerostack/LICENSE +21 -0
  18. package/plugins/aerostack/icon.svg +1 -0
  19. package/plugins/aerostack/plugin.js +94 -0
  20. package/plugins/aerostack/plugin.json +24 -0
  21. package/plugins/aixy/LICENSE +21 -0
  22. package/plugins/aixy/icon.svg +1 -0
  23. package/plugins/aixy/plugin.js +266 -0
  24. package/plugins/aixy/plugin.json +32 -0
  25. package/plugins/antigravity/plugin.js +189 -65
  26. package/plugins/antigravity-cli/icon-color.svg +1 -0
  27. package/plugins/antigravity-cli/icon.svg +1 -3
  28. package/plugins/antigravity-cli/plugin.js +32 -20
  29. package/plugins/antigravity-ide/icon-color.svg +1 -0
  30. package/plugins/antigravity-ide/icon.svg +1 -3
  31. package/plugins/antigravity-ide/plugin.js +19 -7
  32. package/plugins/atlascloud/LICENSE +21 -0
  33. package/plugins/atlascloud/icon-color.svg +1 -0
  34. package/plugins/atlascloud/icon.svg +1 -0
  35. package/plugins/atlascloud/plugin.js +54 -0
  36. package/plugins/atlascloud/plugin.json +24 -0
  37. package/plugins/augment/icon-color.svg +14 -0
  38. package/plugins/bifrost/LICENSE +21 -0
  39. package/plugins/bifrost/icon.svg +3 -0
  40. package/plugins/bifrost/plugin.js +366 -0
  41. package/plugins/bifrost/plugin.json +31 -0
  42. package/plugins/chatbox/LICENSE +21 -0
  43. package/plugins/chatbox/icon.svg +4 -0
  44. package/plugins/chatbox/plugin.js +208 -0
  45. package/plugins/chatbox/plugin.json +24 -0
  46. package/plugins/claude/plugin.js +340 -153
  47. package/plugins/claude/plugin.json +1 -1
  48. package/plugins/claudeplatform/LICENSE +21 -0
  49. package/plugins/claudeplatform/icon.svg +3 -0
  50. package/plugins/claudeplatform/plugin.js +244 -0
  51. package/plugins/claudeplatform/plugin.json +25 -0
  52. package/plugins/clinepass/plugin.js +19 -3
  53. package/plugins/codebuff/icon-color.svg +92 -0
  54. package/plugins/coderabbit/plugin.js +25 -0
  55. package/plugins/coderabbit/plugin.json +12 -0
  56. package/plugins/codex/plugin.js +15 -8
  57. package/plugins/codex/plugin.json +11 -2
  58. package/plugins/command-code/icon-color.svg +3 -0
  59. package/plugins/command-code/plugin.js +7 -3
  60. package/plugins/copilot/icon.svg +1 -1
  61. package/plugins/copilot/plugin.json +1 -0
  62. package/plugins/cosmic/LICENSE +21 -0
  63. package/plugins/cosmic/icon.svg +1 -0
  64. package/plugins/cosmic/plugin.js +134 -0
  65. package/plugins/cosmic/plugin.json +32 -0
  66. package/plugins/crof/icon-color.svg +3 -0
  67. package/plugins/crofai/icon-color.svg +3 -0
  68. package/plugins/crofai/icon.svg +2 -15
  69. package/plugins/cursor/icon-color.svg +1 -0
  70. package/plugins/cursor/plugin.js +51 -14
  71. package/plugins/cursor-nightly/plugin.json +1 -1
  72. package/plugins/deepinfra/icon-color.svg +1 -0
  73. package/plugins/deepinfra/icon.svg +1 -4
  74. package/plugins/deepseek/plugin.js +150 -59
  75. package/plugins/deepseek/plugin.json +3 -1
  76. package/plugins/devin/plugin.js +3 -0
  77. package/plugins/devpass/LICENSE +21 -0
  78. package/plugins/devpass/icon.svg +3 -0
  79. package/plugins/devpass/plugin.js +120 -0
  80. package/plugins/devpass/plugin.json +24 -0
  81. package/plugins/elevenlabs/icon-color.svg +4 -0
  82. package/plugins/exa/LICENSE +21 -0
  83. package/plugins/exa/icon-color.svg +1 -0
  84. package/plugins/exa/icon.svg +1 -0
  85. package/plugins/exa/plugin.js +75 -0
  86. package/plugins/exa/plugin.json +32 -0
  87. package/plugins/factory/icon-color.svg +1 -0
  88. package/plugins/fal/LICENSE +21 -0
  89. package/plugins/fal/icon-color.svg +1 -0
  90. package/plugins/fal/icon.svg +1 -0
  91. package/plugins/fal/plugin.js +74 -0
  92. package/plugins/fal/plugin.json +24 -0
  93. package/plugins/fireworks-ai/icon-color.svg +1 -0
  94. package/plugins/fireworks-ai/icon.svg +1 -6
  95. package/plugins/flora/LICENSE +21 -0
  96. package/plugins/flora/icon.svg +4 -0
  97. package/plugins/flora/plugin.js +93 -0
  98. package/plugins/flora/plugin.json +32 -0
  99. package/plugins/futureagi/LICENSE +21 -0
  100. package/plugins/futureagi/icon.svg +24 -0
  101. package/plugins/futureagi/plugin.js +139 -0
  102. package/plugins/futureagi/plugin.json +32 -0
  103. package/plugins/gemini-apps/LICENSE +21 -0
  104. package/plugins/gemini-apps/icon-color.svg +1 -0
  105. package/plugins/gemini-apps/icon.svg +1 -0
  106. package/plugins/gemini-apps/plugin.js +141 -0
  107. package/plugins/gemini-apps/plugin.json +25 -0
  108. package/plugins/gitkraken/LICENSE +21 -0
  109. package/plugins/gitkraken/icon.svg +2 -0
  110. package/plugins/gitkraken/plugin.js +158 -0
  111. package/plugins/gitkraken/plugin.json +32 -0
  112. package/plugins/googledeveloper/LICENSE +21 -0
  113. package/plugins/googledeveloper/icon.svg +3 -0
  114. package/plugins/googledeveloper/plugin.js +204 -0
  115. package/plugins/googledeveloper/plugin.json +25 -0
  116. package/plugins/grok/icon-color.svg +1 -0
  117. package/plugins/groqcloud/icon-color.svg +1 -0
  118. package/plugins/helmcode/LICENSE +21 -0
  119. package/plugins/helmcode/icon.svg +5 -0
  120. package/plugins/helmcode/plugin.js +253 -0
  121. package/plugins/helmcode/plugin.json +32 -0
  122. package/plugins/huggingface/LICENSE +21 -0
  123. package/plugins/huggingface/icon-color.svg +1 -0
  124. package/plugins/huggingface/icon.svg +1 -0
  125. package/plugins/huggingface/plugin.js +298 -0
  126. package/plugins/huggingface/plugin.json +26 -0
  127. package/plugins/hyper/LICENSE +21 -0
  128. package/plugins/hyper/plugin.js +137 -0
  129. package/plugins/hyper/plugin.json +27 -0
  130. package/plugins/jetbrains-ai-assistant/LICENSE +22 -0
  131. package/plugins/jetbrains-ai-assistant/plugin.js +502 -16
  132. package/plugins/jetbrains-ai-assistant/plugin.json +27 -4
  133. package/plugins/kilo/icon-color.svg +1 -0
  134. package/plugins/kimi/plugin.js +54 -14
  135. package/plugins/kimi/plugin.json +46 -6
  136. package/plugins/langdock/LICENSE +21 -0
  137. package/plugins/langdock/icon.svg +4 -0
  138. package/plugins/langdock/plugin.js +106 -0
  139. package/plugins/langdock/plugin.json +25 -0
  140. package/plugins/linkup/LICENSE +21 -0
  141. package/plugins/linkup/icon.svg +10 -0
  142. package/plugins/linkup/plugin.js +46 -0
  143. package/plugins/linkup/plugin.json +24 -0
  144. package/plugins/litellm/plugin.js +54 -3
  145. package/plugins/lithosai/LICENSE +21 -0
  146. package/plugins/lithosai/icon.svg +1 -0
  147. package/plugins/lithosai/plugin.js +130 -0
  148. package/plugins/lithosai/plugin.json +26 -0
  149. package/plugins/llmman/LICENSE +21 -0
  150. package/plugins/llmman/icon.svg +4 -0
  151. package/plugins/llmman/plugin.js +138 -0
  152. package/plugins/llmman/plugin.json +31 -0
  153. package/plugins/longcat/icon-color.svg +1 -0
  154. package/plugins/longcat/icon.svg +1 -4
  155. package/plugins/manus/icon-color.svg +6 -0
  156. package/plugins/mimo/icon-color.svg +4 -0
  157. package/plugins/mimo/icon.svg +4 -1
  158. package/plugins/mistral/plugin.js +164 -27
  159. package/plugins/moonshot/icon-color.svg +1 -0
  160. package/plugins/munito/LICENSE +21 -0
  161. package/plugins/munito/icon.svg +7 -0
  162. package/plugins/munito/plugin.js +171 -0
  163. package/plugins/munito/plugin.json +24 -0
  164. package/plugins/muse/LICENSE +21 -0
  165. package/plugins/muse/icon.svg +3 -0
  166. package/plugins/muse/plugin.js +288 -0
  167. package/plugins/muse/plugin.json +34 -0
  168. package/plugins/museai/LICENSE +21 -0
  169. package/plugins/museai/icon.svg +3 -0
  170. package/plugins/museai/plugin.js +161 -0
  171. package/plugins/museai/plugin.json +26 -0
  172. package/plugins/nous/LICENSE +21 -0
  173. package/plugins/nous/icon-color.svg +1 -0
  174. package/plugins/nous/icon.svg +1 -0
  175. package/plugins/nous/plugin.js +129 -0
  176. package/plugins/nous/plugin.json +32 -0
  177. package/plugins/ollama/icon-color.svg +1 -0
  178. package/plugins/ollama/plugin.js +58 -0
  179. package/plugins/openai-api/icon-color.svg +1 -0
  180. package/plugins/opencode/icon-color.svg +1 -0
  181. package/plugins/opencode-go/icon-color.svg +1 -0
  182. package/plugins/opencode-go/plugin.js +104 -37
  183. package/plugins/opendesign/LICENSE +21 -0
  184. package/plugins/opendesign/icon.svg +4 -0
  185. package/plugins/opendesign/plugin.js +108 -0
  186. package/plugins/opendesign/plugin.json +25 -0
  187. package/plugins/openrouter/icon-color.svg +1 -0
  188. package/plugins/parallel/LICENSE +21 -0
  189. package/plugins/parallel/icon.svg +11 -0
  190. package/plugins/parallel/plugin.js +97 -0
  191. package/plugins/parallel/plugin.json +25 -0
  192. package/plugins/perplexity/LICENSE +22 -0
  193. package/plugins/perplexity/plugin.js +122 -0
  194. package/plugins/perplexity/plugin.json +36 -7
  195. package/plugins/pi/plugin.js +113 -0
  196. package/plugins/pi/plugin.json +11 -0
  197. package/plugins/qwencloud/LICENSE +21 -0
  198. package/plugins/qwencloud/icon-color.svg +1 -0
  199. package/plugins/qwencloud/icon.svg +1 -4
  200. package/plugins/qwencloud/plugin.js +197 -0
  201. package/plugins/qwencloud/plugin.json +17 -0
  202. package/plugins/raycast/LICENSE +21 -0
  203. package/plugins/raycast/icon.svg +4 -0
  204. package/plugins/raycast/plugin.js +179 -0
  205. package/plugins/raycast/plugin.json +32 -0
  206. package/plugins/replicate/LICENSE +21 -0
  207. package/plugins/replicate/icon-color.svg +1 -0
  208. package/plugins/replicate/icon.svg +1 -0
  209. package/plugins/replicate/plugin.js +170 -0
  210. package/plugins/replicate/plugin.json +25 -0
  211. package/plugins/sailresearch/LICENSE +21 -0
  212. package/plugins/sailresearch/icon.svg +4 -0
  213. package/plugins/sailresearch/plugin.js +104 -0
  214. package/plugins/sailresearch/plugin.json +24 -0
  215. package/plugins/siliconflow/LICENSE +21 -0
  216. package/plugins/siliconflow/icon.svg +3 -0
  217. package/plugins/siliconflow/plugin.js +87 -0
  218. package/plugins/siliconflow/plugin.json +32 -0
  219. package/plugins/sofya/LICENSE +21 -0
  220. package/plugins/sofya/icon.svg +3 -0
  221. package/plugins/sofya/plugin.js +86 -0
  222. package/plugins/sofya/plugin.json +24 -0
  223. package/plugins/soniox/LICENSE +21 -0
  224. package/plugins/soniox/icon.svg +3 -0
  225. package/plugins/soniox/plugin.js +103 -0
  226. package/plugins/soniox/plugin.json +24 -0
  227. package/plugins/synthetic/icon-color.svg +14 -0
  228. package/plugins/synthetic/plugin.js +12 -0
  229. package/plugins/synthetic/plugin.json +51 -9
  230. package/plugins/tavily/LICENSE +21 -0
  231. package/plugins/tavily/icon.svg +3 -0
  232. package/plugins/tavily/plugin.js +61 -0
  233. package/plugins/tavily/plugin.json +24 -0
  234. package/plugins/tinyapi/LICENSE +21 -0
  235. package/plugins/tinyapi/icon.svg +4 -0
  236. package/plugins/tinyapi/plugin.js +73 -0
  237. package/plugins/tinyapi/plugin.json +25 -0
  238. package/plugins/traecn/LICENSE +21 -0
  239. package/plugins/traecn/icon.svg +3 -0
  240. package/plugins/traecn/plugin.js +103 -0
  241. package/plugins/traecn/plugin.json +25 -0
  242. package/plugins/tripo/LICENSE +21 -0
  243. package/plugins/tripo/icon.svg +4 -0
  244. package/plugins/tripo/plugin.js +60 -0
  245. package/plugins/tripo/plugin.json +24 -0
  246. package/plugins/typesafe/LICENSE +21 -0
  247. package/plugins/typesafe/icon.svg +4 -0
  248. package/plugins/typesafe/plugin.js +181 -0
  249. package/plugins/typesafe/plugin.json +25 -0
  250. package/plugins/v0/LICENSE +21 -0
  251. package/plugins/v0/icon-color.svg +1 -0
  252. package/plugins/v0/icon.svg +1 -0
  253. package/plugins/v0/plugin.js +219 -0
  254. package/plugins/v0/plugin.json +32 -0
  255. package/plugins/venice/plugin.js +50 -1
  256. package/plugins/venice/plugin.json +2 -1
  257. package/plugins/vercel/LICENSE +21 -0
  258. package/plugins/vercel/icon-color.svg +1 -0
  259. package/plugins/vercel/icon.svg +1 -0
  260. package/plugins/vercel/plugin.js +202 -0
  261. package/plugins/vercel/plugin.json +54 -0
  262. package/plugins/windsurf/icon-color.svg +1 -0
  263. package/plugins/workbuddy/LICENSE +21 -0
  264. package/plugins/workbuddy/icon.svg +1 -0
  265. package/plugins/workbuddy/plugin.js +318 -0
  266. package/plugins/workbuddy/plugin.json +63 -0
  267. package/plugins/xai/icon-color.svg +1 -0
  268. package/plugins/xai/icon.svg +1 -7
  269. package/plugins/xai/plugin.js +9 -0
  270. package/plugins/xapi/LICENSE +21 -0
  271. package/plugins/xapi/icon.svg +1 -0
  272. package/plugins/xapi/plugin.js +90 -0
  273. package/plugins/xapi/plugin.json +25 -0
  274. package/plugins/xkiro/LICENSE +21 -0
  275. package/plugins/xkiro/icon.svg +1 -0
  276. package/plugins/xkiro/plugin.js +104 -0
  277. package/plugins/xkiro/plugin.json +24 -0
  278. package/plugins/zai/icon-color.svg +1 -0
  279. package/plugins/zai/plugin.js +5 -1
  280. package/plugins/zenmux/icon-color.svg +1 -0
  281. package/plugins/zenmux/icon.svg +1 -3
  282. package/usagestat +0 -0
  283. package/usagestatd +0 -0
  284. package/plugins/cursor-nightly/plugin.js +0 -1416
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Peter Steinberger
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.
@@ -0,0 +1,5 @@
1
+ <svg width="132" height="132" viewBox="0 0 132 132" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g transform="translate(8.5)">
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M57.5 0C54.9373 0 52.3747 0.6439 50.1323 1.9317L7.20752 26.8829C2.72284 29.4585 0 34.2878 0 39.439V92.561C0 97.712 2.72284 102.541 7.20752 105.117L50.1323 130.068C52.3747 131.356 54.9373 132 57.5 132C60.0627 132 62.6253 131.356 64.8677 130.068L107.792 105.117C112.277 102.541 115 97.712 115 92.561V39.439C115 34.2878 112.277 29.4585 107.792 26.8829L64.8677 1.9317C62.6253 0.6439 60.0627 0 57.5 0ZM57.5 23.8244L20.0055 43.7423L57.4199 64.8294V109.302H57.5L97.6901 86.0459V47.285L57.5 23.8244Z" fill="currentColor"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,253 @@
1
+ // Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
2
+ globalThis.__usagestat_bundled_options = {"labels":["Model quota","Model quota","Additional"],"defaults":{},"autoMode":"web"};
3
+ (function(defineProvider) {
4
+ // BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/helmcode.js
5
+ function _nullishCoalesce(lhs, rhsFn) {
6
+ if (lhs != null) {
7
+ return lhs;
8
+ } else {
9
+ return rhsFn();
10
+ }
11
+ }
12
+ function _optionalChain(ops) {
13
+ let lastAccessLHS = undefined;
14
+ let value = ops[0];
15
+ let i = 1;
16
+ while (i < ops.length) {
17
+ const op = ops[i];
18
+ const fn = ops[i + 1];
19
+ i += 2;
20
+ if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
21
+ return undefined;
22
+ }
23
+ if (op === "access" || op === "optionalAccess") {
24
+ lastAccessLHS = value;
25
+ value = fn(value);
26
+ } else if (op === "call" || op === "optionalCall") {
27
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
28
+ lastAccessLHS = undefined;
29
+ }
30
+ }
31
+ return value;
32
+ }
33
+ defineProvider({
34
+ id: "helmcode",
35
+ name: "Helmcode",
36
+ endpoints: ["https://cloud-api.helmcode.com", "https://cloud-api.nan.builders"],
37
+ settings: [{ key: "TENANT", title: "Manual cookie tenant", type: "plain" }],
38
+ capabilities: ["browser-cookies", "http-status"],
39
+ cookieDomains: ["helmcode.com", "cloud-api.helmcode.com", "nan.builders"],
40
+ async fetchUsage(ctx) {
41
+ const tenants = [
42
+ { domain: "helmcode.com", cookieDomain: "cloud-api.helmcode.com", name: "Helmcode Cloud" },
43
+ { domain: "nan.builders", cookieDomain: "nan.builders", name: "NaN Builders" },
44
+ ];
45
+ const policy = ctx.browser.availability(tenants[0].cookieDomain);
46
+ if (policy === "off") throw ctx.fail.missingCredential("Helmcode dashboard cookies are disabled.");
47
+ // A pasted header has no origin metadata. Never try it against both tenants.
48
+ const candidates = policy === "manual" ? [tenants[ctx.settings.get("TENANT") === "nanBuilders" ? 1 : 0]] : tenants;
49
+ const fail = (field) => {
50
+ throw ctx.fail.parseFailure(`Helmcode quota response format changed: ${field}`);
51
+ };
52
+ const object = (value) =>
53
+ value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
54
+ const parse = (body) => {
55
+ try {
56
+ return _nullishCoalesce(object(JSON.parse(body)), () => fail("expected object"));
57
+ } catch (error) {
58
+ void error;
59
+ return fail("invalid JSON");
60
+ }
61
+ };
62
+ const amount = (value, field, fractional = false) => {
63
+ const valid = fractional ? Number.isFinite(value) : Number.isSafeInteger(value);
64
+ if (typeof value !== "number" || !valid || value < 0) return fail(field);
65
+ return value;
66
+ };
67
+ async function* sessions() {
68
+ for (const tenant of candidates) {
69
+ const domains =
70
+ policy !== "manual" && tenant.domain !== tenant.cookieDomain
71
+ ? [tenant.domain, tenant.cookieDomain, tenant.domain]
72
+ : [tenant.cookieDomain];
73
+ // Try the old cache first, then API-host and parent-domain browser sessions.
74
+ for (const [index, domain] of domains.entries()) {
75
+ try {
76
+ for await (const session of ctx.browser.sessions(domain, {
77
+ cachedOnly: domains.length > 1 && index === 0,
78
+ })) {
79
+ yield { tenant, domain, session };
80
+ }
81
+ } catch (error) {
82
+ void error;
83
+ }
84
+ }
85
+ }
86
+ }
87
+ let rejected = false;
88
+ for await (const { tenant, domain, session } of sessions()) {
89
+ if (!session.header) continue;
90
+ const headers = {
91
+ Cookie: session.header,
92
+ Origin: `https://cloud.${tenant.domain}`,
93
+ Referer: `https://cloud.${tenant.domain}/dashboard`,
94
+ };
95
+ const get = (path, timeoutSeconds = 8) =>
96
+ ctx.http.get(`https://cloud-api.${tenant.domain}${path}`, { headers, timeoutSeconds });
97
+ const required = async (path, allowMissing = false) => {
98
+ const response = await get(path);
99
+ if ((response.status >= 300 && response.status < 400) || response.status === 401 || response.status === 403) {
100
+ ctx.browser.rejectCookie(domain, session);
101
+ rejected = true;
102
+ return undefined;
103
+ }
104
+ const seconds = Number(_nullishCoalesce(response.headers["retry-after"], () => 1));
105
+ const retryAfterSeconds = Number.isFinite(seconds) && seconds >= 0 ? Math.min(10, seconds) : 1;
106
+ if (response.status === 429) throw ctx.fail.rateLimited("Helmcode rate limit reached.", { retryAfterSeconds });
107
+ if (response.status === 408 || response.status >= 500)
108
+ throw ctx.fail.providerUnavailable("Helmcode dashboard is unavailable.", { retryAfterSeconds });
109
+ if ((response.status < 200 || response.status >= 300) && !(allowMissing && response.status === 404))
110
+ throw ctx.fail.apiFailure(`Helmcode dashboard returned HTTP ${response.status}.`);
111
+ return response;
112
+ };
113
+ const creditResponse = await required("/api/usage/credits", true);
114
+ if (!creditResponse) continue;
115
+ const credits = creditResponse.status === 404 ? undefined : parse(creditResponse.bodyText);
116
+ if (credits && typeof credits.enabled !== "boolean") return fail("enabled");
117
+ // Only an absent or explicitly disabled credit plan permits legacy token quotas.
118
+ if (_optionalChain([credits, "optionalAccess", (_) => _.enabled])) {
119
+ const allowance = amount(credits.allowanceCredits, "allowanceCredits", true);
120
+ const spent = amount(credits.usedCredits, "usedCredits", true);
121
+ if (allowance <= 0) return fail("allowanceCredits");
122
+ const start = typeof credits.periodStart === "string" ? ctx.date.iso(credits.periodStart) : undefined;
123
+ const end = typeof credits.periodEnd === "string" ? ctx.date.iso(credits.periodEnd) : undefined;
124
+ const format = (value, field) =>
125
+ value == null ? "—" : ctx.format.number(amount(value, field, true), { maximumFractionDigits: 3 });
126
+ const models = (Array.isArray(credits.models) ? credits.models : []).map((value) => {
127
+ const row = _nullishCoalesce(object(value), () => fail("credit model"));
128
+ if (typeof row.model !== "string" || !ctx.isDetailLabel(row.model)) return fail("credit model name");
129
+ return {
130
+ label: row.model,
131
+ value: format(row.creditsThisMonth, "creditsThisMonth"),
132
+ weight: format(row.approxCreditsPerMTokens, "approxCreditsPerMTokens"),
133
+ };
134
+ });
135
+ const rows = models.slice(0, 20).map(({ label, value }) => ({ label, value }));
136
+ if (models.length > 20) rows.push({ label: "Other models", value: "—" });
137
+ const planRows = [];
138
+ if (credits.packCredits != null)
139
+ planRows.push({ label: "Top-up credits", value: format(credits.packCredits, "packCredits") });
140
+ if (credits.frozen === true) planRows.push({ label: "Paused during grace period", value: "—" });
141
+ return {
142
+ primary: {
143
+ title: "Credits",
144
+ usedPercent: ctx.pct(spent, allowance),
145
+ resetsAt: end,
146
+ windowMinutes:
147
+ start && end && end > start ? Math.round((end.getTime() - start.getTime()) / 60000) : undefined,
148
+ quotaLimit: allowance,
149
+ quotaUnit: "credits",
150
+ resetDescription: `${format(spent, "usedCredits")} / ${format(allowance, "allowanceCredits")}`,
151
+ },
152
+ details: [
153
+ { title: "Credits used", rows },
154
+ {
155
+ title: "Credits per million tokens",
156
+ rows: models.slice(0, 20).map(({ label, weight }) => ({ label, value: weight })),
157
+ },
158
+ ...(planRows.length ? [{ title: "Credits", rows: planRows }] : []),
159
+ ],
160
+ identity: { organization: tenant.name, loginMethod: "Dashboard session" },
161
+ dataConfidence: "exact",
162
+ };
163
+ }
164
+ const response = await required("/api/usage/quota");
165
+ if (!response) continue;
166
+ const quota = parse(response.bodyText);
167
+ if (typeof quota.periodStart !== "string" || !Array.isArray(quota.models)) return fail("periodStart or models");
168
+ const optional = async (path) => {
169
+ try {
170
+ const result = await get(path, 2);
171
+ return result.status === 200 ? parse(result.bodyText) : undefined;
172
+ } catch (error) {
173
+ void error;
174
+ return undefined;
175
+ }
176
+ };
177
+ const billing = await optional("/api/billing");
178
+ const premium =
179
+ _optionalChain([
180
+ object,
181
+ "call",
182
+ (_2) => _2(_optionalChain([billing, "optionalAccess", (_3) => _3.subscription])),
183
+ "optionalAccess",
184
+ (_4) => _4.premium,
185
+ ]) === true;
186
+ const start = /^(\d{4})-(\d{2})-(\d{2})(?:T|$)/.exec(quota.periodStart);
187
+ const fallback =
188
+ start && Number(start[2]) >= 1 && Number(start[2]) <= 12 && Number(start[3]) >= 1 && Number(start[3]) <= 31
189
+ ? new Date(Date.UTC(Number(start[1]), Number(start[2]), 1))
190
+ : undefined;
191
+ const models = quota.models
192
+ .map((value) => {
193
+ const row = _nullishCoalesce(object(value), () => fail("model"));
194
+ if (typeof row.model !== "string" || !ctx.isDetailLabel(row.model)) return fail("model name");
195
+ const cap = amount(row.cap, "cap");
196
+ const used = amount(row.tokensUsed, "tokensUsed");
197
+ const credit = row.creditTokens == null ? 0 : amount(row.creditTokens, "creditTokens");
198
+ const hours = row.windowHours == null ? undefined : amount(row.windowHours, "windowHours");
199
+ if (hours !== undefined && (hours < 1 || hours > 525600 / 60)) return fail("windowHours");
200
+ let resetsAt = fallback;
201
+ if (typeof row.periodEnd === "string") {
202
+ try {
203
+ resetsAt = _nullishCoalesce(ctx.date.iso(row.periodEnd), () => fallback);
204
+ } catch (error) {
205
+ void error;
206
+ }
207
+ }
208
+ return { name: row.model, cap, used, credit, hours, resetsAt };
209
+ })
210
+ .filter((row) => row.cap > 0 && (row.hours === undefined || premium));
211
+ models.sort((a, b) => b.used / b.cap - a.used / a.cap || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
212
+ const windows = models.map((row) => ({
213
+ id: `helmcode-${row.name}`,
214
+ title: row.name,
215
+ window: {
216
+ usedPercent: ctx.pct(row.used, row.cap),
217
+ resetsAt: row.resetsAt,
218
+ windowMinutes: row.hours === undefined ? undefined : row.hours * 60,
219
+ resetDescription:
220
+ `${row.name} · ${ctx.format.number(row.used)} / ${ctx.format.number(row.cap)} tokens` +
221
+ (row.credit > 0 ? ` · ${ctx.format.number(row.credit)} credit-funded` : ""),
222
+ },
223
+ }));
224
+ let cost;
225
+ if (tenant.domain === "helmcode.com") {
226
+ const credits = await optional("/api/billing/credits");
227
+ const balance = _optionalChain([credits, "optionalAccess", (_5) => _5.balanceMicros]);
228
+ const currency =
229
+ _optionalChain([credits, "optionalAccess", (_6) => _6.currency]) == null
230
+ ? "EUR"
231
+ : typeof credits.currency === "string"
232
+ ? credits.currency.toUpperCase()
233
+ : "";
234
+ if (typeof balance === "number" && Number.isSafeInteger(balance) && /^[A-Z]{3}$/.test(currency))
235
+ cost = { used: Math.max(0, balance / 1e6), limit: 0, currency, period: "Prepaid balance" };
236
+ }
237
+ return {
238
+ primary: _optionalChain([windows, "access", (_7) => _7[0], "optionalAccess", (_8) => _8.window]),
239
+ extraWindows: windows.slice(1),
240
+ cost,
241
+ identity: { organization: tenant.name, loginMethod: "Dashboard session" },
242
+ dataConfidence: "exact",
243
+ };
244
+ }
245
+ if (rejected) throw ctx.fail.authenticationExpired("Helmcode dashboard session expired. Sign in again.");
246
+ throw ctx.fail.missingCredential(
247
+ `Sign in to cloud.helmcode.com or cloud.nan.builders. Supported browsers: ${ctx.browser.supportedBrowsers}. Or paste a Cookie header.`,
248
+ );
249
+ },
250
+ });
251
+
252
+ // END UPSTREAM
253
+ })(globalThis.defineProvider);
@@ -0,0 +1,32 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "helmcode",
4
+ "name": "Helmcode",
5
+ "version": "0.1.0",
6
+ "entry": "plugin.js",
7
+ "enabledByDefault": false,
8
+ "supportedModes": [
9
+ "web"
10
+ ],
11
+ "autoMode": "web",
12
+ "usageDashboardUrl": "https://cloud.helmcode.com/dashboard",
13
+ "webUrl": "https://helmcode.com",
14
+ "envVars": [
15
+ "HELMCODE_COOKIE"
16
+ ],
17
+ "setupFields": [
18
+ {
19
+ "key": "TENANT",
20
+ "title": "Manual cookie tenant",
21
+ "type": "string",
22
+ "description": "Provider-specific account or source selection."
23
+ }
24
+ ],
25
+ "upstream": {
26
+ "repository": "https://github.com/steipete/CodexBar",
27
+ "revision": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
28
+ "path": "Sources/CodexBarCore/Resources/Plugins/helmcode.js",
29
+ "sha256": "058d7d04a6d2fca8221a96aa6c451f4c6f4ad2a4653c9dd03d6b714a63f8c1dd",
30
+ "license": "MIT"
31
+ }
32
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Peter Steinberger
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.
@@ -0,0 +1 @@
1
+ <svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>HuggingFace</title><path d="M2.25 11.535c0-3.407 1.847-6.554 4.844-8.258a9.822 9.822 0 019.687 0c2.997 1.704 4.844 4.851 4.844 8.258 0 5.266-4.337 9.535-9.687 9.535S2.25 16.8 2.25 11.535z" fill="#FF9D0B"></path><path d="M11.938 20.086c4.797 0 8.687-3.829 8.687-8.551 0-4.722-3.89-8.55-8.687-8.55-4.798 0-8.688 3.828-8.688 8.55 0 4.722 3.89 8.55 8.688 8.55z" fill="#FFD21E"></path><path d="M11.875 15.113c2.457 0 3.25-2.156 3.25-3.263 0-.576-.393-.394-1.023-.089-.582.283-1.365.675-2.224.675-1.798 0-3.25-1.693-3.25-.586 0 1.107.79 3.263 3.25 3.263h-.003z" fill="#FF323D"></path><path d="M14.76 9.21c.32.108.445.753.767.585.447-.233.707-.708.659-1.204a1.235 1.235 0 00-.879-1.059 1.262 1.262 0 00-1.33.394c-.322.384-.377.92-.14 1.36.153.283.638-.177.925-.079l-.002.003zm-5.887 0c-.32.108-.448.753-.768.585a1.226 1.226 0 01-.658-1.204c.048-.495.395-.913.878-1.059a1.262 1.262 0 011.33.394c.322.384.377.92.14 1.36-.152.283-.64-.177-.925-.079l.003.003zm1.12 5.34a2.166 2.166 0 011.325-1.106c.07-.02.144.06.219.171l.192.306c.069.1.139.175.209.175.074 0 .15-.074.223-.172l.205-.302c.08-.11.157-.188.234-.165.537.168.986.536 1.25 1.026.932-.724 1.275-1.905 1.275-2.633 0-.508-.306-.426-.81-.19l-.616.296c-.52.24-1.148.48-1.824.48-.676 0-1.302-.24-1.823-.48l-.589-.283c-.52-.248-.838-.342-.838.177 0 .703.32 1.831 1.187 2.56l.18.14z" fill="#3A3B45"></path><path d="M17.812 10.366a.806.806 0 00.813-.8c0-.441-.364-.8-.813-.8a.806.806 0 00-.812.8c0 .442.364.8.812.8zm-11.624 0a.806.806 0 00.812-.8c0-.441-.364-.8-.812-.8a.806.806 0 00-.813.8c0 .442.364.8.813.8zM4.515 13.073c-.405 0-.765.162-1.017.46a1.455 1.455 0 00-.333.925 1.801 1.801 0 00-.485-.074c-.387 0-.737.146-.985.409a1.41 1.41 0 00-.2 1.722 1.302 1.302 0 00-.447.694c-.06.222-.12.69.2 1.166a1.267 1.267 0 00-.093 1.236c.238.533.81.958 1.89 1.405l.24.096c.768.3 1.473.492 1.478.494.89.243 1.808.375 2.732.394 1.465 0 2.513-.443 3.115-1.314.93-1.342.842-2.575-.274-3.763l-.151-.154c-.692-.684-1.155-1.69-1.25-1.912-.195-.655-.71-1.383-1.562-1.383-.46.007-.889.233-1.15.605-.25-.31-.495-.553-.715-.694a1.87 1.87 0 00-.993-.312zm14.97 0c.405 0 .767.162 1.017.46.216.262.333.588.333.925.158-.047.322-.071.487-.074.388 0 .738.146.985.409a1.41 1.41 0 01.2 1.722c.22.178.377.422.445.694.06.222.12.69-.2 1.166.244.37.279.836.093 1.236-.238.533-.81.958-1.889 1.405l-.239.096c-.77.3-1.475.492-1.48.494-.89.243-1.808.375-2.732.394-1.465 0-2.513-.443-3.115-1.314-.93-1.342-.842-2.575.274-3.763l.151-.154c.695-.684 1.157-1.69 1.252-1.912.195-.655.708-1.383 1.56-1.383.46.007.889.233 1.15.605.25-.31.495-.553.718-.694.244-.162.523-.265.814-.3l.176-.012z" fill="#FF9D0B"></path><path d="M9.785 20.132c.688-.994.638-1.74-.305-2.667-.945-.928-1.495-2.288-1.495-2.288s-.205-.788-.672-.714c-.468.074-.81 1.25.17 1.971.977.721-.195 1.21-.573.534-.375-.677-1.405-2.416-1.94-2.751-.532-.332-.907-.148-.782.541.125.687 2.357 2.35 2.14 2.707-.218.362-.983-.42-.983-.42S2.953 14.9 2.43 15.46c-.52.558.398 1.026 1.7 1.803 1.308.778 1.41.985 1.225 1.28-.187.295-3.07-2.1-3.34-1.083-.27 1.011 2.943 1.304 2.745 2.006-.2.7-2.265-1.324-2.685-.537-.425.79 2.913 1.718 2.94 1.725 1.075.276 3.813.859 4.77-.522zm4.432 0c-.687-.994-.64-1.74.305-2.667.943-.928 1.493-2.288 1.493-2.288s.205-.788.675-.714c.465.074.807 1.25-.17 1.971-.98.721.195 1.21.57.534.377-.677 1.407-2.416 1.94-2.751.532-.332.91-.148.782.541-.125.687-2.355 2.35-2.137 2.707.215.362.98-.42.98-.42S21.05 14.9 21.57 15.46c.52.558-.395 1.026-1.7 1.803-1.308.778-1.408.985-1.225 1.28.187.295 3.07-2.1 3.34-1.083.27 1.011-2.94 1.304-2.743 2.006.2.7 2.263-1.324 2.685-.537.423.79-2.912 1.718-2.94 1.725-1.077.276-3.815.859-4.77-.522z" fill="#FFD21E"></path></svg>
@@ -0,0 +1 @@
1
+ <svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>HuggingFace</title><path d="M16.781 3.277c2.997 1.704 4.844 4.851 4.844 8.258 0 .995-.155 1.955-.443 2.857a1.332 1.332 0 011.125.4 1.41 1.41 0 01.2 1.723c.204.165.352.385.428.632l.017.062c.06.222.12.69-.2 1.166.244.37.279.836.093 1.236-.255.57-.893 1.018-2.128 1.5l-.202.078-.131.048c-.478.173-.89.295-1.061.345l-.086.024c-.89.243-1.808.375-2.732.394-1.32 0-2.3-.36-2.923-1.067a9.852 9.852 0 01-3.18.018C9.778 21.647 8.802 22 7.494 22a11.249 11.249 0 01-2.541-.343l-.221-.06-.273-.08a16.574 16.574 0 01-1.175-.405c-1.237-.483-1.875-.93-2.13-1.501-.186-.4-.151-.867.093-1.236a1.42 1.42 0 01-.2-1.166c.069-.273.226-.516.447-.694a1.41 1.41 0 01.2-1.722c.233-.248.557-.391.917-.407l.078-.001a9.385 9.385 0 01-.44-2.85c0-3.407 1.847-6.554 4.844-8.258a9.822 9.822 0 019.687 0zM4.188 14.758c.125.687 2.357 2.35 2.14 2.707-.19.315-.796-.239-.948-.386l-.041-.04-.168-.147c-.561-.479-2.304-1.9-2.74-1.432-.43.46.119.859 1.055 1.42l.784.467.136.083c1.045.643 1.12.84.95 1.113-.188.295-3.07-2.1-3.34-1.083-.27 1.011 2.942 1.304 2.744 2.006-.2.7-2.265-1.324-2.685-.537-.425.79 2.913 1.718 2.94 1.725l.16.04.175.042c1.227.284 3.565.65 4.435-.604.673-.973.64-1.709-.248-2.61l-.057-.057c-.945-.928-1.495-2.288-1.495-2.288l-.017-.058-.025-.072c-.082-.22-.284-.639-.63-.584-.46.073-.798 1.21.12 1.933l.05.038c.977.721-.195 1.21-.573.534l-.058-.104-.143-.25c-.463-.799-1.282-2.111-1.739-2.397-.532-.332-.907-.148-.782.541zm14.842-.541c-.533.335-1.563 2.074-1.94 2.751a.613.613 0 01-.687.302.436.436 0 01-.176-.098.303.303 0 01-.049-.06l-.014-.028-.008-.02-.007-.019-.003-.013-.003-.017a.289.289 0 01-.004-.048c0-.12.071-.266.25-.427.026-.024.054-.047.084-.07l.047-.036c.022-.016.043-.032.063-.049.883-.71.573-1.81.131-1.917l-.031-.006-.056-.004a.368.368 0 00-.062.006l-.028.005-.042.014-.039.017-.028.015-.028.019-.036.027-.023.02c-.173.158-.273.428-.31.542l-.016.054s-.53 1.309-1.439 2.234l-.054.054c-.365.358-.596.69-.702 1.018-.143.437-.066.868.21 1.353.055.097.117.195.187.296.882 1.275 3.282.876 4.494.59l.286-.07.25-.074c.276-.084.736-.233 1.2-.42l.188-.077.065-.028.064-.028.124-.056.081-.038c.529-.252.964-.543.994-.827l.001-.036a.299.299 0 00-.037-.139c-.094-.176-.271-.212-.491-.168l-.045.01c-.044.01-.09.024-.136.04l-.097.035-.054.022c-.559.23-1.238.705-1.607.745h.006a.452.452 0 01-.05.003h-.024l-.024-.003-.023-.005c-.068-.016-.116-.06-.14-.142a.22.22 0 01-.005-.1c.062-.345.958-.595 1.713-.91l.066-.028c.528-.224.97-.483.985-.832v-.04a.47.47 0 00-.016-.098c-.048-.18-.175-.251-.36-.251-.785 0-2.55 1.36-2.92 1.36-.025 0-.048-.007-.058-.024a.6.6 0 01-.046-.088c-.1-.238.068-.462 1.06-1.066l.209-.126c.538-.32 1.01-.588 1.341-.831.29-.212.475-.406.503-.6l.003-.028c.008-.113-.038-.227-.147-.344a.266.266 0 00-.07-.054l-.034-.015-.013-.005a.403.403 0 00-.13-.02c-.162 0-.369.07-.595.18-.637.313-1.431.952-1.826 1.285l-.249.215-.033.033c-.08.078-.288.27-.493.386l-.071.037-.041.019a.535.535 0 01-.122.036h.005a.346.346 0 01-.031.003l.01-.001-.013.001c-.079.005-.145-.021-.19-.095a.113.113 0 01-.014-.065c.027-.465 2.034-1.991 2.152-2.642l.009-.048c.1-.65-.271-.817-.791-.493zM11.938 2.984c-4.798 0-8.688 3.829-8.688 8.55 0 .692.083 1.364.24 2.008l.008-.009c.252-.298.612-.46 1.017-.46.355.008.699.117.993.312.22.14.465.384.715.694.261-.372.69-.598 1.15-.605.852 0 1.367.728 1.562 1.383l.047.105.06.127c.192.396.595 1.139 1.143 1.68 1.06 1.04 1.324 2.115.8 3.266a8.865 8.865 0 002.024-.014c-.505-1.12-.26-2.17.74-3.186l.066-.066c.695-.684 1.157-1.69 1.252-1.912.195-.655.708-1.383 1.56-1.383.46.007.889.233 1.15.605.25-.31.495-.553.718-.694a1.87 1.87 0 01.99-.312c.357 0 .682.126.925.36.14-.61.215-1.245.215-1.898 0-4.722-3.89-8.55-8.687-8.55zm1.857 8.926l.439-.212c.553-.264.89-.383.89.152 0 1.093-.771 3.208-3.155 3.262h-.184c-2.325-.052-3.116-2.06-3.156-3.175l-.001-.087c0-1.107 1.452.586 3.25.586.716 0 1.379-.272 1.917-.526zm4.017-3.143c.45 0 .813.358.813.8 0 .441-.364.8-.813.8a.806.806 0 01-.812-.8c0-.442.364-.8.812-.8zm-11.624 0c.448 0 .812.358.812.8 0 .441-.364.8-.812.8a.806.806 0 01-.813-.8c0-.442.364-.8.813-.8zm7.79-.841c.32-.384.846-.54 1.33-.394.483.146.83.564.878 1.06.048.495-.212.97-.659 1.203-.322.168-.447-.477-.767-.585l.002-.003c-.287-.098-.772.362-.925.079a1.215 1.215 0 01.14-1.36zm-4.323 0c.322.384.377.92.14 1.36-.152.283-.64-.177-.925-.079l.003.003c-.108.036-.194.134-.273.24l-.118.165c-.11.15-.22.262-.377.18a1.226 1.226 0 01-.658-1.204c.048-.495.395-.913.878-1.059a1.262 1.262 0 011.33.394z"></path></svg>
@@ -0,0 +1,298 @@
1
+ // Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
2
+ globalThis.__usagestat_bundled_options = {"labels":["Inference","ZeroGPU","Additional"],"defaults":{},"autoMode":"web"};
3
+ (function(defineProvider) {
4
+ // BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/huggingface.js
5
+ function _nullishCoalesce(lhs, rhsFn) {
6
+ if (lhs != null) {
7
+ return lhs;
8
+ } else {
9
+ return rhsFn();
10
+ }
11
+ }
12
+ function _optionalChain(ops) {
13
+ let lastAccessLHS = undefined;
14
+ let value = ops[0];
15
+ let i = 1;
16
+ while (i < ops.length) {
17
+ const op = ops[i];
18
+ const fn = ops[i + 1];
19
+ i += 2;
20
+ if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
21
+ return undefined;
22
+ }
23
+ if (op === "access" || op === "optionalAccess") {
24
+ lastAccessLHS = value;
25
+ value = fn(value);
26
+ } else if (op === "call" || op === "optionalCall") {
27
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
28
+ lastAccessLHS = undefined;
29
+ }
30
+ }
31
+ return value;
32
+ }
33
+
34
+ defineProvider({
35
+ id: "huggingface",
36
+ name: "Hugging Face",
37
+ endpoints: ["https://huggingface.co"],
38
+ settings: [{ key: "HF_TOKEN", title: "Access token", type: "secure" }],
39
+ capabilities: ["browser-cookies", "http-status"],
40
+ cookieDomains: ["huggingface.co"],
41
+ async fetchUsage(ctx) {
42
+ const fail = (field) => {
43
+ throw ctx.fail.parseFailure(`Hugging Face billing response format changed: ${field}`);
44
+ };
45
+ const object = (value, field) => {
46
+ if (!value || typeof value !== "object" || Array.isArray(value)) return fail(field);
47
+ return value;
48
+ };
49
+ const number = (value, field) => {
50
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) return fail(field);
51
+ return value;
52
+ };
53
+ const optionalNumber = (value, field) => (value === undefined || value === null ? undefined : number(value, field));
54
+ const parse = (body) => {
55
+ let value;
56
+ try {
57
+ value = JSON.parse(body);
58
+ } catch (error) {
59
+ void error;
60
+ return fail("invalid JSON");
61
+ }
62
+ return object(value, "expected an object");
63
+ };
64
+ const date = (value) => {
65
+ if (value === undefined || value === null) return undefined;
66
+ if (typeof value === "number") {
67
+ if (!Number.isFinite(value) || value <= 0 || value > 64092211200) return undefined;
68
+ return ctx.date.unixSeconds(value);
69
+ }
70
+ if (typeof value === "string") {
71
+ try {
72
+ return ctx.date.iso(value);
73
+ } catch (error) {
74
+ void error;
75
+ }
76
+ }
77
+ return undefined;
78
+ };
79
+ const text = (value) => (typeof value === "string" ? value.trim() || undefined : undefined);
80
+ const userID = (profile) =>
81
+ profile.type === "user" && typeof profile.id === "string" && profile.id.trim() ? profile.id : undefined;
82
+ // Keep bearer authority off requests that verify the browser session.
83
+ const token = ctx.settings.getSecret("HF_TOKEN");
84
+ if (!token) throw ctx.fail.missingCredential("Missing Hugging Face access token.");
85
+ const apiHeaders = { Authorization: `Bearer ${token}`, "User-Agent": "CodexBar" };
86
+ const now = ctx.date.now();
87
+ const start = Math.floor(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1) / 1000);
88
+ const end = Math.floor(now.getTime() / 1000);
89
+ const response = await ctx.http.get(
90
+ `https://huggingface.co/api/settings/billing/usage-v2?startDate=${start}&endDate=${end}`,
91
+ { timeoutSeconds: 15, headers: apiHeaders },
92
+ );
93
+ if (response.status === 401) {
94
+ throw ctx.fail.authenticationExpired("Hugging Face rejected the token. Check that it is valid and not expired.");
95
+ }
96
+ if (response.status === 403) {
97
+ throw ctx.fail.permissionDenied(
98
+ "The Hugging Face token lacks billing access. Use a classic read token or enable Billing read on a fine-grained token.",
99
+ );
100
+ }
101
+ if (response.status === 429) throw ctx.fail.rateLimited("Hugging Face rate limit reached. Retry later.");
102
+ if (response.status >= 500)
103
+ throw ctx.fail.providerUnavailable(`Hugging Face API returned HTTP ${response.status}.`);
104
+ if (response.status < 200 || response.status >= 300) {
105
+ throw ctx.fail.apiFailure(`Hugging Face API returned HTTP ${response.status}.`);
106
+ }
107
+ const usage = object(parse(response.bodyText).usage, "missing usage");
108
+ const inference = object(usage.inferenceProviders, "missing inferenceProviders usage");
109
+ const gross = number(inference.usedNanoUsd, "usedNanoUsd") / 1e9;
110
+ const included = number(inference.includedNanoUsd, "includedNanoUsd") / 1e9;
111
+ const billable = Math.max(0, gross - included);
112
+ const limit = _nullishCoalesce(optionalNumber(inference.limitNanoUsd, "limitNanoUsd"), () => 0) / 1e9;
113
+ const requests = optionalNumber(inference.numRequests, "numRequests");
114
+ if (requests !== undefined && !Number.isSafeInteger(requests)) return fail("numRequests");
115
+ let secondary;
116
+ let gpuRows = [];
117
+ try {
118
+ const gpuResponse = await ctx.http.get("https://huggingface.co/api/spaces/zero-gpu/quota", {
119
+ timeoutSeconds: 2,
120
+ headers: apiHeaders,
121
+ });
122
+ if (gpuResponse.status >= 200 && gpuResponse.status < 300) {
123
+ const gpu = parse(gpuResponse.bodyText);
124
+ const total = number(gpu.base, "ZeroGPU base");
125
+ const remaining = number(gpu.current, "ZeroGPU current");
126
+ if (total > 0) {
127
+ const consumed = Math.max(0, total - remaining);
128
+ secondary = {
129
+ usedPercent: ctx.pct(consumed, total),
130
+ resetsAt: date(gpu.resetsAt),
131
+ resetDescription: "ZeroGPU quota",
132
+ };
133
+ const minutes = (seconds) =>
134
+ `${ctx.format.number(seconds / 60, {
135
+ minimumFractionDigits: seconds >= 600 ? 0 : 1,
136
+ maximumFractionDigits: seconds >= 600 ? 0 : 1,
137
+ })} min`;
138
+ gpuRows = [
139
+ { label: "GPU time used", value: minutes(consumed) },
140
+ { label: "GPU time remaining", value: minutes(remaining) },
141
+ ];
142
+ }
143
+ }
144
+ } catch (error) {
145
+ void error;
146
+ }
147
+ const cacheKey = "whoami-v2:" + token;
148
+ let identity = ctx.cache.get(cacheKey);
149
+ if (!identity || now.getTime() - identity.fetchedAt < 0 || now.getTime() - identity.fetchedAt >= 43200000) {
150
+ identity = undefined;
151
+ try {
152
+ const whoami = await ctx.http.get("https://huggingface.co/api/whoami-v2", {
153
+ timeoutSeconds: 2,
154
+ headers: apiHeaders,
155
+ });
156
+ if (whoami.status >= 200 && whoami.status < 300) {
157
+ const profile = parse(whoami.bodyText);
158
+ const username = text(profile.name);
159
+ const email = text(profile.email);
160
+ if (username || email || userID(profile)) {
161
+ identity = {
162
+ fetchedAt: now.getTime(),
163
+ userID: userID(profile),
164
+ username,
165
+ email,
166
+ plan: typeof profile.isPro === "boolean" ? (profile.isPro ? "PRO" : "Free") : undefined,
167
+ };
168
+ ctx.cache.set(cacheKey, identity, 43200);
169
+ }
170
+ }
171
+ } catch (error) {
172
+ void error;
173
+ }
174
+ }
175
+ let balance;
176
+ const availability = ctx.browser.availability("huggingface.co");
177
+ if (
178
+ _optionalChain([identity, "optionalAccess", (_2) => _2.userID]) &&
179
+ (availability === "available" || availability === "manual")
180
+ ) {
181
+ try {
182
+ const cookie = await ctx.browser.cookieHeader("huggingface.co");
183
+ const web = async (path, accept) => {
184
+ const result = await ctx.http.get(`https://huggingface.co${path}`, {
185
+ headers: { Cookie: cookie, Accept: accept },
186
+ timeoutSeconds: 2,
187
+ });
188
+ if (result.status === 401 || result.status === 403) ctx.browser.rejectCookie("huggingface.co");
189
+ if (result.status !== 200) return fail("wallet unavailable");
190
+ return result;
191
+ };
192
+ const billing = await web("/settings/billing", "text/html");
193
+ if (
194
+ !_optionalChain([
195
+ billing,
196
+ "access",
197
+ (_3) => _3.headers,
198
+ "access",
199
+ (_4) => _4["content-type"],
200
+ "optionalAccess",
201
+ (_5) => _5.toLowerCase,
202
+ "call",
203
+ (_6) => _6(),
204
+ "access",
205
+ (_7) => _7.includes,
206
+ "call",
207
+ (_8) => _8("text/html"),
208
+ ])
209
+ )
210
+ return fail("wallet content type");
211
+ const current = [];
212
+ const legacy = [];
213
+ const entities = new Map([
214
+ ["amp", "&"],
215
+ ["apos", "'"],
216
+ ["gt", ">"],
217
+ ["lt", "<"],
218
+ ["nbsp", "\u00a0"],
219
+ ["quot", '"'],
220
+ ]);
221
+ const decode = (raw) =>
222
+ raw.replace(/&([^;]*);/g, (_, entity) => {
223
+ const named = entities.get(entity);
224
+ if (named !== undefined) return named;
225
+ const scalar = /^#x[0-9a-f]+$/i.test(entity)
226
+ ? parseInt(entity.slice(2), 16)
227
+ : /^#[0-9]+$/.test(entity)
228
+ ? Number(entity.slice(1))
229
+ : NaN;
230
+ if (!Number.isInteger(scalar) || scalar > 0x10ffff || (scalar >= 0xd800 && scalar <= 0xdfff))
231
+ return fail("wallet HTML entity");
232
+ return String.fromCodePoint(scalar);
233
+ });
234
+ for (const tag of _nullishCoalesce(billing.bodyText.match(/<div\b[^>]*>/gi), () => [])) {
235
+ const props = /\bdata-props\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(tag);
236
+ if (!props) continue;
237
+ const payload = JSON.parse(
238
+ decode(
239
+ _nullishCoalesce(
240
+ _nullishCoalesce(props[1], () => props[2]),
241
+ () => props[3],
242
+ ),
243
+ ),
244
+ );
245
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) continue;
246
+ const entity = payload.entity;
247
+ if (entity && Object.prototype.hasOwnProperty.call(entity, "currentBalanceUsd")) {
248
+ if (entity.type !== "user") return fail("wallet entity type");
249
+ current.push(entity.currentBalanceUsd);
250
+ }
251
+ if (Object.prototype.hasOwnProperty.call(payload, "invoiceCreditsCents"))
252
+ legacy.push(payload.invoiceCreditsCents);
253
+ }
254
+ let candidate;
255
+ if (current.length) {
256
+ if (current.length !== 1) return fail("ambiguous current wallet");
257
+ candidate = number(current[0], "currentBalanceUsd");
258
+ } else {
259
+ if (legacy.length !== 1) return fail("missing or ambiguous legacy wallet");
260
+ const cents = number(legacy[0], "invoiceCreditsCents");
261
+ if (!Number.isSafeInteger(cents)) return fail("invoiceCreditsCents");
262
+ candidate = cents / 100;
263
+ }
264
+ // The billing page's display names are not ownership proof. Resolve the same cookie without a bearer.
265
+ const profile = parse((await web("/api/whoami-v2", "application/json")).bodyText);
266
+ if (userID(profile) === identity.userID) balance = candidate;
267
+ } catch (error) {
268
+ void error;
269
+ }
270
+ }
271
+ // usage-v2 reports a query interval; its cutoff is not a quota reset.
272
+ // HF's billing UI deducts includedNanoUsd from usedNanoUsd to calculate the charge.
273
+ const rows = [{ label: "Billable usage", value: ctx.format.usd(billable) }];
274
+ if (included > 0) {
275
+ rows.push({ label: "Gross inference usage", value: ctx.format.usd(gross) });
276
+ rows.push({ label: "Included inference amount", value: ctx.format.usd(included) });
277
+ }
278
+ if (limit > 0) rows.push({ label: "Spending limit", value: ctx.format.usd(limit) });
279
+ if (requests !== undefined) rows.push({ label: "Requests", value: String(requests) });
280
+ const details = [{ title: "Inference Providers", rows }];
281
+ if (gpuRows.length) details.push({ title: "ZeroGPU", rows: gpuRows });
282
+ if (balance !== undefined)
283
+ details.push({ title: "Credits", rows: [{ label: "Prepaid balance", value: ctx.format.usd(balance) }] });
284
+ return {
285
+ secondary,
286
+ cost: { used: billable, balance, limit: limit > 0 ? limit : undefined, currency: "USD", period: "This month" },
287
+ details,
288
+ identity:
289
+ identity && (identity.username || identity.email || identity.plan)
290
+ ? { email: identity.email, accountID: identity.username, loginMethod: identity.plan }
291
+ : undefined,
292
+ dataConfidence: "exact",
293
+ };
294
+ },
295
+ });
296
+
297
+ // END UPSTREAM
298
+ })(globalThis.defineProvider);