@hashimkarim/usagestat-darwin-arm64 2.0.0-alpha.4 → 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 (189) hide show
  1. package/native-manifest.json +873 -141
  2. package/package.json +124 -2
  3. package/plugins/abliteration/LICENSE +21 -0
  4. package/plugins/abliteration/icon.svg +5 -0
  5. package/plugins/abliteration/plugin.js +89 -0
  6. package/plugins/abliteration/plugin.json +24 -0
  7. package/plugins/aerostack/LICENSE +21 -0
  8. package/plugins/aerostack/icon.svg +1 -0
  9. package/plugins/aerostack/plugin.js +94 -0
  10. package/plugins/aerostack/plugin.json +24 -0
  11. package/plugins/aixy/icon.svg +1 -0
  12. package/plugins/aixy/plugin.js +5 -0
  13. package/plugins/aixy/plugin.json +9 -1
  14. package/plugins/antigravity/plugin.js +60 -26
  15. package/plugins/antigravity-cli/plugin.js +21 -5
  16. package/plugins/antigravity-ide/plugin.js +19 -7
  17. package/plugins/atlascloud/plugin.js +5 -0
  18. package/plugins/atlascloud/plugin.json +2 -1
  19. package/plugins/bifrost/icon.svg +3 -0
  20. package/plugins/bifrost/plugin.js +5 -0
  21. package/plugins/bifrost/plugin.json +9 -1
  22. package/plugins/chatbox/LICENSE +21 -0
  23. package/plugins/chatbox/icon.svg +4 -0
  24. package/plugins/chatbox/plugin.js +208 -0
  25. package/plugins/chatbox/plugin.json +24 -0
  26. package/plugins/claude/plugin.js +39 -2
  27. package/plugins/claudeplatform/LICENSE +21 -0
  28. package/plugins/claudeplatform/icon.svg +3 -0
  29. package/plugins/claudeplatform/plugin.js +244 -0
  30. package/plugins/claudeplatform/plugin.json +25 -0
  31. package/plugins/codex/plugin.js +14 -8
  32. package/plugins/codex/plugin.json +11 -2
  33. package/plugins/copilot/plugin.json +1 -0
  34. package/plugins/cosmic/LICENSE +21 -0
  35. package/plugins/cosmic/icon.svg +1 -0
  36. package/plugins/cosmic/plugin.js +134 -0
  37. package/plugins/cosmic/plugin.json +32 -0
  38. package/plugins/cursor/plugin.js +51 -14
  39. package/plugins/cursor-nightly/plugin.json +1 -1
  40. package/plugins/devpass/icon.svg +3 -0
  41. package/plugins/devpass/plugin.js +5 -0
  42. package/plugins/devpass/plugin.json +2 -1
  43. package/plugins/exa/LICENSE +21 -0
  44. package/plugins/exa/icon-color.svg +1 -0
  45. package/plugins/exa/icon.svg +1 -0
  46. package/plugins/exa/plugin.js +75 -0
  47. package/plugins/exa/plugin.json +32 -0
  48. package/plugins/fal/LICENSE +21 -0
  49. package/plugins/fal/icon-color.svg +1 -0
  50. package/plugins/fal/icon.svg +1 -0
  51. package/plugins/fal/plugin.js +74 -0
  52. package/plugins/fal/plugin.json +24 -0
  53. package/plugins/flora/LICENSE +21 -0
  54. package/plugins/flora/icon.svg +4 -0
  55. package/plugins/flora/plugin.js +93 -0
  56. package/plugins/flora/plugin.json +32 -0
  57. package/plugins/futureagi/LICENSE +21 -0
  58. package/plugins/futureagi/icon.svg +24 -0
  59. package/plugins/futureagi/plugin.js +139 -0
  60. package/plugins/futureagi/plugin.json +32 -0
  61. package/plugins/gemini-apps/LICENSE +1 -2
  62. package/plugins/gemini-apps/plugin.js +136 -465
  63. package/plugins/gemini-apps/plugin.json +13 -7
  64. package/plugins/gitkraken/icon.svg +2 -0
  65. package/plugins/gitkraken/plugin.js +5 -0
  66. package/plugins/gitkraken/plugin.json +9 -1
  67. package/plugins/googledeveloper/LICENSE +21 -0
  68. package/plugins/googledeveloper/icon.svg +3 -0
  69. package/plugins/googledeveloper/plugin.js +204 -0
  70. package/plugins/googledeveloper/plugin.json +25 -0
  71. package/plugins/helmcode/icon.svg +5 -0
  72. package/plugins/helmcode/plugin.js +121 -56
  73. package/plugins/helmcode/plugin.json +10 -2
  74. package/plugins/huggingface/plugin.js +6 -1
  75. package/plugins/huggingface/plugin.json +4 -3
  76. package/plugins/hyper/plugin.js +53 -47
  77. package/plugins/hyper/plugin.json +3 -2
  78. package/plugins/jetbrains-ai-assistant/LICENSE +22 -0
  79. package/plugins/jetbrains-ai-assistant/plugin.js +502 -16
  80. package/plugins/jetbrains-ai-assistant/plugin.json +27 -4
  81. package/plugins/kimi/plugin.js +54 -14
  82. package/plugins/kimi/plugin.json +46 -6
  83. package/plugins/langdock/LICENSE +21 -0
  84. package/plugins/langdock/icon.svg +4 -0
  85. package/plugins/langdock/plugin.js +106 -0
  86. package/plugins/langdock/plugin.json +25 -0
  87. package/plugins/linkup/LICENSE +21 -0
  88. package/plugins/linkup/icon.svg +10 -0
  89. package/plugins/linkup/plugin.js +46 -0
  90. package/plugins/linkup/plugin.json +24 -0
  91. package/plugins/lithosai/LICENSE +21 -0
  92. package/plugins/lithosai/icon.svg +1 -0
  93. package/plugins/lithosai/plugin.js +130 -0
  94. package/plugins/lithosai/plugin.json +26 -0
  95. package/plugins/llmman/icon.svg +4 -0
  96. package/plugins/llmman/plugin.js +5 -0
  97. package/plugins/llmman/plugin.json +9 -1
  98. package/plugins/mistral/plugin.js +54 -22
  99. package/plugins/munito/LICENSE +21 -0
  100. package/plugins/munito/icon.svg +7 -0
  101. package/plugins/munito/plugin.js +171 -0
  102. package/plugins/munito/plugin.json +24 -0
  103. package/plugins/muse/icon.svg +3 -0
  104. package/plugins/muse/plugin.js +98 -129
  105. package/plugins/muse/plugin.json +10 -2
  106. package/plugins/museai/LICENSE +21 -0
  107. package/plugins/museai/icon.svg +3 -0
  108. package/plugins/museai/plugin.js +161 -0
  109. package/plugins/museai/plugin.json +26 -0
  110. package/plugins/nous/plugin.js +5 -0
  111. package/plugins/nous/plugin.json +9 -1
  112. package/plugins/ollama/plugin.js +58 -0
  113. package/plugins/opencode-go/plugin.js +74 -25
  114. package/plugins/opendesign/LICENSE +21 -0
  115. package/plugins/opendesign/icon.svg +4 -0
  116. package/plugins/opendesign/plugin.js +108 -0
  117. package/plugins/opendesign/plugin.json +25 -0
  118. package/plugins/parallel/LICENSE +21 -0
  119. package/plugins/parallel/icon.svg +11 -0
  120. package/plugins/parallel/plugin.js +97 -0
  121. package/plugins/parallel/plugin.json +25 -0
  122. package/plugins/perplexity/LICENSE +22 -0
  123. package/plugins/perplexity/plugin.js +122 -0
  124. package/plugins/perplexity/plugin.json +36 -7
  125. package/plugins/qwencloud/LICENSE +21 -0
  126. package/plugins/qwencloud/plugin.js +197 -0
  127. package/plugins/qwencloud/plugin.json +17 -0
  128. package/plugins/raycast/icon.svg +4 -0
  129. package/plugins/raycast/plugin.js +6 -1
  130. package/plugins/raycast/plugin.json +10 -2
  131. package/plugins/replicate/plugin.js +5 -0
  132. package/plugins/replicate/plugin.json +2 -1
  133. package/plugins/sailresearch/LICENSE +21 -0
  134. package/plugins/sailresearch/icon.svg +4 -0
  135. package/plugins/sailresearch/plugin.js +104 -0
  136. package/plugins/sailresearch/plugin.json +24 -0
  137. package/plugins/siliconflow/LICENSE +21 -0
  138. package/plugins/siliconflow/icon.svg +3 -0
  139. package/plugins/siliconflow/plugin.js +87 -0
  140. package/plugins/siliconflow/plugin.json +32 -0
  141. package/plugins/sofya/LICENSE +21 -0
  142. package/plugins/sofya/icon.svg +3 -0
  143. package/plugins/sofya/plugin.js +86 -0
  144. package/plugins/sofya/plugin.json +24 -0
  145. package/plugins/soniox/LICENSE +21 -0
  146. package/plugins/soniox/icon.svg +3 -0
  147. package/plugins/soniox/plugin.js +103 -0
  148. package/plugins/soniox/plugin.json +24 -0
  149. package/plugins/synthetic/plugin.js +12 -0
  150. package/plugins/synthetic/plugin.json +51 -9
  151. package/plugins/tavily/LICENSE +21 -0
  152. package/plugins/tavily/icon.svg +3 -0
  153. package/plugins/tavily/plugin.js +61 -0
  154. package/plugins/tavily/plugin.json +24 -0
  155. package/plugins/tinyapi/LICENSE +21 -0
  156. package/plugins/tinyapi/icon.svg +4 -0
  157. package/plugins/tinyapi/plugin.js +73 -0
  158. package/plugins/tinyapi/plugin.json +25 -0
  159. package/plugins/traecn/LICENSE +21 -0
  160. package/plugins/traecn/icon.svg +3 -0
  161. package/plugins/traecn/plugin.js +103 -0
  162. package/plugins/traecn/plugin.json +25 -0
  163. package/plugins/tripo/LICENSE +21 -0
  164. package/plugins/tripo/icon.svg +4 -0
  165. package/plugins/tripo/plugin.js +60 -0
  166. package/plugins/tripo/plugin.json +24 -0
  167. package/plugins/typesafe/icon.svg +4 -0
  168. package/plugins/typesafe/plugin.js +85 -129
  169. package/plugins/typesafe/plugin.json +3 -2
  170. package/plugins/v0/plugin.js +5 -0
  171. package/plugins/v0/plugin.json +9 -1
  172. package/plugins/vercel/plugin.js +147 -0
  173. package/plugins/vercel/plugin.json +34 -3
  174. package/plugins/workbuddy/LICENSE +21 -0
  175. package/plugins/workbuddy/icon.svg +1 -0
  176. package/plugins/workbuddy/plugin.js +318 -0
  177. package/plugins/workbuddy/plugin.json +63 -0
  178. package/plugins/xai/plugin.js +9 -0
  179. package/plugins/xapi/LICENSE +21 -0
  180. package/plugins/xapi/icon.svg +1 -0
  181. package/plugins/xapi/plugin.js +90 -0
  182. package/plugins/xapi/plugin.json +25 -0
  183. package/plugins/xkiro/icon.svg +1 -0
  184. package/plugins/xkiro/plugin.js +5 -0
  185. package/plugins/xkiro/plugin.json +2 -1
  186. package/plugins/zai/plugin.js +5 -1
  187. package/usagestat +0 -0
  188. package/usagestatd +0 -0
  189. package/plugins/cursor-nightly/plugin.js +0 -1416
@@ -1,5 +1,7 @@
1
1
  // Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
2
2
  globalThis.__usagestat_bundled_options = {"labels":["Balance","Balance","Additional"],"defaults":{},"autoMode":"api"};
3
+ (function(defineProvider) {
4
+ // BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/vercel.js
3
5
  defineProvider({
4
6
  id: "vercel",
5
7
  name: "Vercel AI Gateway",
@@ -53,3 +55,148 @@ defineProvider({
53
55
  };
54
56
  },
55
57
  });
58
+
59
+ // END UPSTREAM
60
+ })(globalThis.defineProvider);
61
+ (function() { const credits=globalThis.__usagestat_plugin; let budget;
62
+ (function(defineProvider) {
63
+ // BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/vercel-budget.js
64
+ defineProvider({
65
+ id: "vercel",
66
+ name: "Vercel AI Gateway",
67
+ endpoints: ["https://api.vercel.com"],
68
+ auth: { type: "bearer", secret: "VERCEL_ACCESS_TOKEN" },
69
+ settings: [
70
+ { key: "VERCEL_ACCESS_TOKEN", title: "Vercel access token", type: "secure" },
71
+ { key: "VERCEL_TEAM_ID", title: "Team ID", type: "plain" },
72
+ ],
73
+ capabilities: ["http-status"],
74
+ async fetchUsage(ctx) {
75
+ const team = ctx.settings.get("VERCEL_TEAM_ID")?.trim();
76
+ if (!team) throw ctx.fail.missingCredential("Set the Vercel Team ID to read your personal budget.");
77
+ if (!/^[A-Za-z0-9_-]{1,128}$/.test(team)) {
78
+ throw ctx.fail.permissionDenied("Invalid Vercel Team ID. Enter the team ID or slug without spaces.");
79
+ }
80
+ function fail() {
81
+ throw ctx.fail.parseFailure("Vercel returned an unrecognized personal budget.");
82
+ }
83
+ async function read(url) {
84
+ const response = await ctx.http.get(url);
85
+ const message = `Vercel API returned HTTP ${response.status}.`;
86
+ if (response.status === 401) throw ctx.fail.authenticationExpired(message);
87
+ if (response.status === 403) throw ctx.fail.permissionDenied(message);
88
+ if (response.status === 429) {
89
+ const delay = Number(response.headers["retry-after"] ?? 1);
90
+ throw ctx.fail.rateLimited(message, {
91
+ retryAfterSeconds: Number.isFinite(delay) && delay >= 0 ? Math.min(delay, 10) : 1,
92
+ });
93
+ }
94
+ if (response.status >= 500) throw ctx.fail.providerUnavailable(message);
95
+ if (response.status !== 200) throw ctx.fail.apiFailure(message);
96
+ try {
97
+ return JSON.parse(response.bodyText);
98
+ } catch {
99
+ return fail();
100
+ }
101
+ }
102
+
103
+ const user = (await read("https://api.vercel.com/v2/user"))?.user;
104
+ if (typeof user?.id !== "string" || !user.id) return fail();
105
+
106
+ // At most 20 pages; the plugin deadline bounds slower teams.
107
+ const matches = [];
108
+ const cursors = new Set();
109
+ let cursor = null;
110
+ for (let page = 0; ; page += 1) {
111
+ const query =
112
+ `teamId=${encodeURIComponent(team)}&scopeType=user&limit=200` +
113
+ (cursor === null ? "" : `&cursor=${encodeURIComponent(cursor)}`);
114
+ const body = await read(`https://api.vercel.com/ai-gateway/budgets/list?${query}`);
115
+ if (!Array.isArray(body?.budgets)) return fail();
116
+ for (const budget of body.budgets) {
117
+ if (budget?.scopeType !== "user" || ![user.id, `usr_${user.id}`].includes(budget.scopeId)) continue;
118
+ if (typeof budget.active !== "boolean" || typeof budget.archived !== "boolean") return fail();
119
+ if (budget.source !== undefined && budget.source !== "default") return fail();
120
+ if (budget.active && !budget.archived) matches.push(budget);
121
+ }
122
+ const next = body.nextCursor;
123
+ if (next === undefined || next === null) break;
124
+ if (typeof next !== "string" || !next || cursors.has(next) || page >= 19) return fail();
125
+ cursors.add(next);
126
+ cursor = next;
127
+ }
128
+
129
+ const identity = {
130
+ email: typeof user.email === "string" ? user.email : null,
131
+ organization: team,
132
+ loginMethod: "Access token",
133
+ accountID: user.id,
134
+ };
135
+ const custom = matches.filter((budget) => budget.source !== "default");
136
+ const effective = custom.length > 0 ? custom : matches;
137
+ if (effective.length > 1) return fail();
138
+ const budget = effective[0];
139
+ if (!budget) {
140
+ return {
141
+ details: [{ title: "Personal budget", rows: [{ label: "No personal budget configured", value: "—" }] }],
142
+ identity,
143
+ dataConfidence: "exact",
144
+ };
145
+ }
146
+ const limit = budget.limitAmount;
147
+ const spent = budget.currentSpend;
148
+ if (typeof limit !== "number" || !Number.isFinite(limit) || limit <= 0) return fail();
149
+ if (typeof spent !== "number" || !Number.isFinite(spent) || spent < 0) return fail();
150
+
151
+ // Documented UTC boundaries: daily midnight, weekly Monday, monthly the 1st; `none` never resets.
152
+ const now = ctx.date.now();
153
+ const year = now.getUTCFullYear();
154
+ const month = now.getUTCMonth();
155
+ const day = now.getUTCDate();
156
+ let start = null;
157
+ let end = null;
158
+ if (budget.refreshPeriod === "daily") {
159
+ start = Date.UTC(year, month, day);
160
+ end = Date.UTC(year, month, day + 1);
161
+ } else if (budget.refreshPeriod === "weekly") {
162
+ start = Date.UTC(year, month, day - ((now.getUTCDay() + 6) % 7));
163
+ end = start + 7 * 24 * 60 * 60 * 1000;
164
+ } else if (budget.refreshPeriod === "monthly") {
165
+ start = Date.UTC(year, month, 1);
166
+ end = Date.UTC(year, month + 1, 1);
167
+ } else if (budget.refreshPeriod !== "none") {
168
+ return fail();
169
+ }
170
+ const spentText = ctx.format.usd(spent);
171
+ const limitText = ctx.format.usd(limit);
172
+ return {
173
+ primary: {
174
+ usedPercent: (spent / limit) * 100,
175
+ windowMinutes: start === null ? null : (end - start) / 60000,
176
+ resetsAt: end === null ? null : new Date(end),
177
+ resetDescription: `${spentText} / ${limitText}`,
178
+ },
179
+ details: [
180
+ {
181
+ title: "Personal budget",
182
+ rows: [
183
+ { label: "Spend", value: spentText },
184
+ { label: "Limit", value: limitText },
185
+ { label: "Remaining", value: ctx.format.usd(Math.max(0, limit - spent)) },
186
+ ],
187
+ },
188
+ ],
189
+ identity,
190
+ dataConfidence: "exact",
191
+ };
192
+ },
193
+ });
194
+
195
+ // END UPSTREAM
196
+ })(definition => { budget=globalThis.__usagestat_bundledProvider(definition,{"labels":["Personal budget","Additional","Additional"],"autoMode":"api","genericApiKey":false}); });
197
+ globalThis.__usagestat_plugin = {id:"vercel",probe(ctx) {
198
+ const selected=ctx.provider?.settings?.personalBudget;
199
+ if(selected!==undefined && typeof selected!=='boolean') throw new Error('personalBudget must be a boolean.');
200
+ return (selected===true ? budget : credits).probe(ctx);
201
+ }};
202
+ })();
@@ -11,13 +11,44 @@
11
11
  "autoMode": "api",
12
12
  "usageDashboardUrl": "https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway",
13
13
  "envVars": [
14
- "AI_GATEWAY_API_KEY"
14
+ "AI_GATEWAY_API_KEY",
15
+ "VERCEL_ACCESS_TOKEN",
16
+ "VERCEL_TEAM_ID"
17
+ ],
18
+ "setupFields": [
19
+ {
20
+ "key": "personalBudget",
21
+ "title": "Read personal budget",
22
+ "type": "boolean",
23
+ "description": "Use a Vercel access token and Team ID instead of AI Gateway key credits."
24
+ },
25
+ {
26
+ "key": "VERCEL_ACCESS_TOKEN",
27
+ "title": "Vercel access token",
28
+ "type": "string",
29
+ "description": "Separate account token; the AI Gateway API key is not used for budgets."
30
+ },
31
+ {
32
+ "key": "VERCEL_TEAM_ID",
33
+ "title": "Team ID",
34
+ "type": "string",
35
+ "description": "Team ID or slug whose personal budget belongs to the token user."
36
+ }
15
37
  ],
16
38
  "upstream": {
17
39
  "repository": "https://github.com/steipete/CodexBar",
18
- "revision": "78ba5a1e65e6859da59a21b799df95ab91bc0b89",
40
+ "revision": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
19
41
  "path": "Sources/CodexBarCore/Resources/Plugins/vercel.js",
20
42
  "sha256": "27b39f42709e93a2cfbf850171f198069553c99967f9b7ba6d16614862cb084a",
21
43
  "license": "MIT"
22
- }
44
+ },
45
+ "upstreamSources": [
46
+ {
47
+ "repository": "https://github.com/steipete/CodexBar",
48
+ "revision": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
49
+ "path": "Sources/CodexBarCore/Resources/Plugins/vercel-budget.js",
50
+ "sha256": "a65d3affe808517590edc33e4d15b813ba1fa870b4435ef18cb7c7195ab376ad",
51
+ "license": "MIT"
52
+ }
53
+ ]
23
54
  }
@@ -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 xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" fill-rule="evenodd"><path d="M18.777 1.647c.28-.02.536.114.972.51 1.018.926 2.437 2.828 3.318 4.452l.34.631.482.24.11.06v3.638a5.206 5.206 0 00-5.32-1.23c-.491.166-1.021.471-2.08 1.082l-6.09 3.516c-1.057.61-1.586.916-1.975 1.259a5.208 5.208 0 00-1.493 5.572c.165.49.471 1.02 1.082 2.08l.315.543h-3.26c-.685 0-1.34-.135-1.939-.377-.169-.956-.009-1.789.469-2.335.158-.18.164-.189.13-.493a11.846 11.846 0 01-.057-1.711l.02-.444-.667-1.18C2.1 15.622 1.445 14.078 1.192 12.9c-.133-.647-.125-.934.04-1.146.1-.128.427-.261.822-.334.994-.175 3.162-.017 5.575.41l.25.043.551-.487c.915-.81 1.522-1.264 2.641-1.962 1.167-.73 2.484-1.331 3.967-1.807l.476-.152.261-.688c.937-2.471 1.896-4.293 2.58-4.9.235-.21.25-.22.422-.23z"/><path d="M12.139 18.2a1.203 1.203 0 011.642.44l1.296 2.243a1.204 1.204 0 01-2.083 1.203l-1.296-2.243a1.203 1.203 0 01.44-1.644zM18.629 14.452a1.203 1.203 0 011.642.44l1.295 2.244a1.203 1.203 0 11-2.083 1.203l-1.295-2.243a1.203 1.203 0 01.44-1.644z"/></svg>
@@ -0,0 +1,318 @@
1
+ // Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
2
+ globalThis.__usagestat_bundled_options = {"labels":["Credits","Credits","Additional"],"defaults":{},"autoMode":"web"};
3
+ (function(defineProvider) {
4
+ // BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/workbuddy.js
5
+ function _nullishCoalesce(lhs, rhsFn) {
6
+ if (lhs != null) {
7
+ return lhs;
8
+ } else {
9
+ return rhsFn();
10
+ }
11
+ }
12
+ defineProvider({
13
+ id: "workbuddy",
14
+ name: "WorkBuddy",
15
+ endpoints: ["https://www.workbuddy.cn"],
16
+ settings: [
17
+ { key: "webTimeoutSeconds", title: "Web timeout", type: "plain" },
18
+ { key: "resetDeadlineMillis", title: "Reset lookup deadline", type: "plain" },
19
+ { key: "chromeMajorVersion", title: "Chrome major version", type: "plain" },
20
+ { key: "manualUserAgent", title: "User-Agent", type: "plain" },
21
+ { key: "manualUserAgentError", title: "Invalid User-Agent message", type: "plain" },
22
+ ],
23
+ capabilities: ["browser-cookies", "http-status"],
24
+ cookieDomains: ["workbuddy.cn", "www.workbuddy.cn"],
25
+ cookiePolicy: {
26
+ selection: "request-url",
27
+ cache: "validated-single-entry",
28
+ imports: "access-gated",
29
+ },
30
+ async fetchUsage(ctx) {
31
+ const origin = "https://www.workbuddy.cn";
32
+ const domain = "www.workbuddy.cn";
33
+ const policy = ctx.browser.availability(domain);
34
+ if (policy === "off") throw ctx.fail.missingCredential("WorkBuddy cookies are disabled.");
35
+ const manualUserAgent = policy === "manual" ? _nullishCoalesce(ctx.settings.get("manualUserAgent"), () => "") : "";
36
+ if (/[^\x20-\x7e]/.test(manualUserAgent)) {
37
+ throw ctx.fail.missingCredential(
38
+ _nullishCoalesce(
39
+ ctx.settings.get("manualUserAgentError"),
40
+ () => "Paste the WorkBuddy User-Agent as a single request header value.",
41
+ ),
42
+ );
43
+ }
44
+ const override = manualUserAgent.trim();
45
+ const timeoutRaw = Number(_nullishCoalesce(ctx.settings.get("webTimeoutSeconds"), () => "15"));
46
+ const timeoutSeconds = Number.isFinite(timeoutRaw) ? Math.min(30, Math.max(1, Math.round(timeoutRaw))) : 15;
47
+ // WorkBuddy binds the session to the browser User-Agent, and Chrome's reduced UA varies only by major version.
48
+ // The previous major covers an installed update that Chrome has not relaunched into yet.
49
+ const major = Number(_nullishCoalesce(ctx.settings.get("chromeMajorVersion"), () => ""));
50
+ const userAgent = (version) =>
51
+ `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${version}.0.0.0 Safari/537.36`;
52
+ const chromeUserAgents =
53
+ Number.isSafeInteger(major) && major > 1 ? [userAgent(major), userAgent(major - 1)] : [undefined];
54
+ const userAgents = override ? [override] : chromeUserAgents;
55
+
56
+ const fail = (field) => {
57
+ throw ctx.fail.parseFailure(`Invalid WorkBuddy billing response: ${field}`);
58
+ };
59
+ const object = (value, field) =>
60
+ value !== null && typeof value === "object" && !Array.isArray(value) ? value : fail(field);
61
+ // Billing amounts arrive as decimal strings ("500"); numbers are accepted for robustness.
62
+ const amount = (value, field) => {
63
+ if (typeof value === "number") return Number.isFinite(value) && value >= 0 ? value : fail(field);
64
+ if (typeof value !== "string" || !/^\d+(?:\.\d+)?$/.test(value.trim())) return fail(field);
65
+ const parsed = Number(value.trim());
66
+ return Number.isFinite(parsed) ? parsed : fail(field);
67
+ };
68
+ const text = (value) => (typeof value === "string" ? value.trim() || undefined : undefined);
69
+ const format = (value) => ctx.format.number(value, { maximumFractionDigits: 2 });
70
+ const decode = (bodyText, field) => {
71
+ let value;
72
+ try {
73
+ value = JSON.parse(bodyText);
74
+ } catch (error) {
75
+ void error;
76
+ return fail(field);
77
+ }
78
+ return object(value, field);
79
+ };
80
+
81
+ const sessionExpired = ctx.fail.authenticationExpired(
82
+ "WorkBuddy session expired. Sign in at www.workbuddy.cn or paste a fresh Cookie header.",
83
+ );
84
+ const post = async (session, agent, path, body, requestTimeout = timeoutSeconds) => {
85
+ const headers = {
86
+ Accept: "application/json",
87
+ Origin: origin,
88
+ Referer: `${origin}/profile/plans-usage`,
89
+ };
90
+ if (agent) headers["User-Agent"] = agent;
91
+ const response = await ctx.http.post(`${origin}${path}`, {
92
+ body,
93
+ timeoutSeconds: requestTimeout,
94
+ cookieSession: session.id,
95
+ headers,
96
+ });
97
+ if (response.status === 401) throw sessionExpired;
98
+ if (response.status === 403) throw ctx.fail.permissionDenied("WorkBuddy denied access to billing data.");
99
+ if (response.status === 429) throw ctx.fail.rateLimited("WorkBuddy billing requests are rate limited.");
100
+ if (response.status >= 500) {
101
+ throw ctx.fail.providerUnavailable(`WorkBuddy billing API returned HTTP ${response.status}.`);
102
+ }
103
+ if (response.status !== 200) throw ctx.fail.apiFailure(`WorkBuddy billing API returned HTTP ${response.status}.`);
104
+ const root = decode(response.bodyText, "expected a JSON object");
105
+ if (root.code !== 0) {
106
+ throw ctx.fail.apiFailure(`WorkBuddy billing API returned code ${String(root.code)}.`);
107
+ }
108
+ return object(root.data, "data");
109
+ };
110
+
111
+ // Cycle timestamps carry no zone; WorkBuddy uses China Standard Time.
112
+ const cycleEnd = (value) => {
113
+ const raw = text(value);
114
+ if (!raw) return undefined;
115
+ const match = /^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})$/.exec(raw);
116
+ if (!match) return undefined;
117
+ const end = ctx.date.iso(`${match[1]}T${match[2]}+08:00`);
118
+ // The dashboard refreshes one second after the inclusive end time.
119
+ return new Date(end.getTime() + 1000);
120
+ };
121
+ // Spent grants stay in the listing until their cycle ends. The dashboard reports the lapse of the
122
+ // grants that still carry credits, so a grant with nothing left must not bound the reward window.
123
+ const creditsLeft = (value) => {
124
+ try {
125
+ return amount(value, "CycleCapacityRemain");
126
+ } catch (error) {
127
+ void error;
128
+ return undefined;
129
+ }
130
+ };
131
+ // Package codes the WorkBuddy client sends for its paid and free listings (WorkBuddy 5.6.2).
132
+ const paidPackageCodes = [
133
+ "TCACA_code_002_AkiJS3ZHF5",
134
+ "TCACA_code_005_maRGyrHhw1",
135
+ "TCACA_code_003_FAnt7lcmRT",
136
+ "TCACA_code_023_4xbGhMrE6q",
137
+ "TCACA_code_026_BaESVICNoi",
138
+ "TCACA_code_027_0FCGVA6vSa",
139
+ "TCACA_code_009_0XmEQc2xOf",
140
+ "TCACA_code_038_OhvqZtiPKr",
141
+ "TCACA_code_036_lupO5WgNdG",
142
+ ];
143
+ const freePackageCodes = [
144
+ "TCACA_code_001_PqouKr6QWV",
145
+ "TCACA_code_008_cfWoLwvjU4",
146
+ "TCACA_code_035_ArVxJcGDsm",
147
+ "TCACA_code_006_DbXS0lrypC",
148
+ "TCACA_code_039_KRcQj7wUat",
149
+ "TCACA_code_040_mi9rCYg46x",
150
+ "TCACA_code_007_nzdH5h4Nl0",
151
+ "TCACA_code_028_NtpWi0jzXs",
152
+ "TCACA_code_037_WxOD3MpI2o",
153
+ "TCACA_code_029_6wCGEWquYy",
154
+ "TCACA_code_030_BjSt89qTvr",
155
+ ];
156
+ // Platform reward grants are aggregated under one package code in the summary. Only the free listing
157
+ // carries each grant's own cycle, so the reward expiry has to be read from there.
158
+ const benefitPackageCode = "TCACA_code_007_nzdH5h4Nl0";
159
+ // Reset and reward expiry are optional: a failed or unexpected package listing must not discard the balance.
160
+ const listings = async (session, agent, wantsRewards) => {
161
+ const now = ctx.date.now().getTime();
162
+ // Share five seconds across listings, retaining the host's margin for publishing the balance.
163
+ const hostDeadline = Number(ctx.settings.get("resetDeadlineMillis"));
164
+ const deadline = Math.min(Date.now() + 5000, hostDeadline > 0 ? hostDeadline : Infinity);
165
+ let paidReset;
166
+ let freeReset;
167
+ let rewardExpiry;
168
+ for (const [path, codes, isFree] of [
169
+ ["/billing/meter/get-user-resource-paid-packages", paidPackageCodes, false],
170
+ ["/billing/meter/get-user-resource-free-packages", freePackageCodes, true],
171
+ ]) {
172
+ const budget = (deadline - Date.now()) / 1000;
173
+ if (budget < 1) break;
174
+ try {
175
+ // The listings reject requests without package codes (HTTP 400, code 10001). Status 0 is valid, 3 used up.
176
+ const page = await post(
177
+ session,
178
+ agent,
179
+ path,
180
+ { PageNumber: 1, PageSize: 100, PackageCodes: codes, Status: [0, 3] },
181
+ Math.min(timeoutSeconds, budget),
182
+ );
183
+ if (Array.isArray(page.Accounts)) {
184
+ for (const raw of page.Accounts) {
185
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) continue;
186
+ const account = raw;
187
+ if (account.CapacityUnit !== "credits") continue;
188
+ const end = cycleEnd(account.CycleEndTime);
189
+ if (!end || end.getTime() <= now) continue;
190
+ if (isFree) {
191
+ // Reward grants expire piecewise; the earliest grant that still holds credits bounds the window.
192
+ const left = creditsLeft(account.CycleCapacityRemain);
193
+ if (
194
+ account.PackageCode === benefitPackageCode &&
195
+ left !== undefined &&
196
+ left > 0 &&
197
+ (!rewardExpiry || end.getTime() < rewardExpiry.getTime())
198
+ ) {
199
+ rewardExpiry = end;
200
+ }
201
+ // Reward grants expire; they never supply the allowance's fallback reset.
202
+ if (account.PackageCode !== benefitPackageCode && (!freeReset || end.getTime() < freeReset.getTime())) {
203
+ freeReset = end;
204
+ }
205
+ } else if (!paidReset || end.getTime() < paidReset.getTime()) {
206
+ paidReset = end;
207
+ }
208
+ }
209
+ }
210
+ } catch (error) {
211
+ if (error.transportClass === "cancelled") throw error;
212
+ }
213
+ // Paid cycles refill the allowance; free grants may expire earlier. The free listing is only
214
+ // worth a request when it answers the reset or bounds the reward window.
215
+ if (!isFree && paidReset && !wantsRewards) break;
216
+ }
217
+ return { reset: _nullishCoalesce(paidReset, () => freeReset), rewardExpiry };
218
+ };
219
+
220
+ let rejected = false;
221
+ for await (const session of ctx.browser.sessions(domain)) {
222
+ let summary;
223
+ let agent;
224
+ for (const candidate of userAgents) {
225
+ try {
226
+ summary = await post(session, candidate, "/billing/meter/get-user-resource-summary", {});
227
+ agent = candidate;
228
+ break;
229
+ } catch (error) {
230
+ if (error !== sessionExpired) throw error;
231
+ }
232
+ }
233
+ if (!summary) {
234
+ rejected = true;
235
+ ctx.browser.rejectCookie(domain, session);
236
+ if (policy === "manual") break;
237
+ continue;
238
+ }
239
+
240
+ if (!Array.isArray(summary.Packages)) return fail("Packages");
241
+ // The host caches an imported session only after the billing API accepts it.
242
+ if (policy !== "manual") ctx.browser.acceptCookie(domain, session);
243
+ let total = 0;
244
+ let remaining = 0;
245
+ let frozen = 0;
246
+ for (const raw of summary.Packages) {
247
+ const item = object(raw, "package");
248
+ if (item.CapacityUnit !== "credits") continue;
249
+ total += amount(item.CycleTotalCapacity, "CycleTotalCapacity");
250
+ remaining += amount(item.CycleRemainCapacity, "CycleRemainCapacity");
251
+ if (item.CycleFrozenCapacity !== undefined) frozen += amount(item.CycleFrozenCapacity, "CycleFrozenCapacity");
252
+ }
253
+ // Credit groups split the same allowance by origin. Rewards are optional, so an unexpected group
254
+ // shape must not discard the balance the dashboard shows.
255
+ let rewardTotal = 0;
256
+ let rewardRemaining = 0;
257
+ for (const raw of Array.isArray(summary.CreditGroups) ? summary.CreditGroups : []) {
258
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) continue;
259
+ const group = raw;
260
+ if (group.Kind !== "benefit" || group.CapacityUnit !== "credits") continue;
261
+ try {
262
+ const groupTotal = amount(group.CycleTotalCapacity, "CycleTotalCapacity");
263
+ const groupRemaining = amount(group.CycleRemainCapacity, "CycleRemainCapacity");
264
+ rewardTotal += groupTotal;
265
+ rewardRemaining += groupRemaining;
266
+ } catch (error) {
267
+ void error;
268
+ }
269
+ }
270
+ const plan = text(summary.SubscriptionPackageName);
271
+ // Frozen credits are listed as reported; the meter uses the remaining amount the dashboard shows.
272
+ const rows = frozen > 0 ? [{ label: "Reserved", value: format(frozen) }] : [];
273
+ if (total <= 0) {
274
+ rows.unshift({ label: "Left", value: format(remaining) }, { label: "Total", value: format(total) });
275
+ }
276
+ const wantsRewards = rewardTotal > 0;
277
+ const cycle = await listings(session, agent, wantsRewards);
278
+ // The window carries the balance; it cannot carry a countdown, because reward credits lapse
279
+ // grant by grant instead of resetting, so the expiry stays a detail row.
280
+ if (wantsRewards && cycle.rewardExpiry) {
281
+ rows.push({ label: "Reward expiry", value: ctx.format.monthDay(cycle.rewardExpiry.getTime()) });
282
+ }
283
+ const extraWindows = wantsRewards
284
+ ? [
285
+ {
286
+ id: "rewards",
287
+ title: "Rewards",
288
+ window: {
289
+ usedPercent: ctx.pct(Math.max(0, rewardTotal - rewardRemaining), rewardTotal),
290
+ resetDescription: `${format(rewardRemaining)} / ${format(rewardTotal)} credits left`,
291
+ },
292
+ },
293
+ ]
294
+ : [];
295
+ return {
296
+ primary:
297
+ total > 0
298
+ ? {
299
+ usedPercent: ctx.pct(Math.max(0, total - remaining), total),
300
+ resetsAt: cycle.reset,
301
+ resetDescription: `${format(remaining)} / ${format(total)} credits left`,
302
+ }
303
+ : undefined,
304
+ extraWindows: extraWindows.length ? extraWindows : undefined,
305
+ details: rows.length ? [{ title: "Credits", rows }] : undefined,
306
+ identity: plan ? { loginMethod: plan } : undefined,
307
+ dataConfidence: "exact",
308
+ };
309
+ }
310
+ if (rejected) throw sessionExpired;
311
+ throw ctx.fail.missingCredential(
312
+ `No WorkBuddy session cookies found. Sign in at www.workbuddy.cn (${ctx.browser.supportedBrowsers}) or paste a Cookie header.`,
313
+ );
314
+ },
315
+ });
316
+
317
+ // END UPSTREAM
318
+ })(globalThis.defineProvider);
@@ -0,0 +1,63 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "workbuddy",
4
+ "name": "WorkBuddy",
5
+ "version": "0.1.0",
6
+ "entry": "plugin.js",
7
+ "enabledByDefault": false,
8
+ "supportedModes": [
9
+ "web"
10
+ ],
11
+ "autoMode": "web",
12
+ "usageDashboardUrl": "https://www.workbuddy.cn",
13
+ "webUrl": "https://workbuddy.cn",
14
+ "envVars": [
15
+ "WORKBUDDY_COOKIE"
16
+ ],
17
+ "setupHelp": "Use a Cookie header from www.workbuddy.cn and the full User-Agent from the same browser. Set Browser User-Agent below. Desktop login files are not imported.",
18
+ "setupFields": [
19
+ {
20
+ "key": "webTimeoutSeconds",
21
+ "title": "Web timeout",
22
+ "type": "string",
23
+ "description": "Provider-specific account or source selection."
24
+ },
25
+ {
26
+ "key": "resetDeadlineMillis",
27
+ "title": "Reset lookup deadline",
28
+ "type": "string",
29
+ "description": "Provider-specific account or source selection."
30
+ },
31
+ {
32
+ "key": "chromeMajorVersion",
33
+ "title": "Chrome major version",
34
+ "type": "string",
35
+ "description": "Provider-specific account or source selection."
36
+ },
37
+ {
38
+ "key": "manualUserAgent",
39
+ "title": "User-Agent",
40
+ "type": "string",
41
+ "description": "Provider-specific account or source selection."
42
+ },
43
+ {
44
+ "key": "manualUserAgentError",
45
+ "title": "Invalid User-Agent message",
46
+ "type": "string",
47
+ "description": "Provider-specific account or source selection."
48
+ },
49
+ {
50
+ "key": "browserUserAgent",
51
+ "title": "Browser User-Agent",
52
+ "type": "string",
53
+ "description": "Paste the full User-Agent from the same browser session that supplied the cookies. Required for WorkBuddy web readback."
54
+ }
55
+ ],
56
+ "upstream": {
57
+ "repository": "https://github.com/steipete/CodexBar",
58
+ "revision": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
59
+ "path": "Sources/CodexBarCore/Resources/Plugins/workbuddy.js",
60
+ "sha256": "4a440637dc7a8ec77592edf5d0fe50181eff9919be08fefa7007bc50476a4301",
61
+ "license": "MIT"
62
+ }
63
+ }
@@ -12,6 +12,7 @@
12
12
  }
13
13
 
14
14
  function env(ctx, name) {
15
+ if (ctx.provider && ctx.provider.instanceId && ctx.provider.instanceId !== 'xai') return null;
15
16
  try {
16
17
  return clean(ctx.host.env.get(name));
17
18
  } catch (_) {
@@ -135,6 +136,14 @@
135
136
  });
136
137
  var balance = balanceUsd(balanceJson.total && balanceJson.total.val);
137
138
  var metrics = [ctx.line.text({ label: "Balance", value: balance < 0 ? "Deficit: $" + (-balance).toFixed(2) : "$" + balance.toFixed(2) })];
139
+ try {
140
+ var preview = ctx.util.requestJson({method:'GET',url:BASE_URL+'/v1/billing/teams/'+encodeURIComponent(id)+'/postpaid/invoice/preview',
141
+ headers:{Authorization:'Bearer '+key,Accept:'application/json'},timeoutMs:5000});
142
+ var cents = preview.json && preview.json.coreInvoice && preview.json.coreInvoice.amountAfterVat;
143
+ if (preview.resp.status>=200 && preview.resp.status<300 && typeof cents==='string' && /^-?\d+$/.test(cents) && Number.isSafeInteger(Number(cents)))
144
+ metrics.push(ctx.line.text({label:'Live remaining (est.)',value:'$'+(balance-Number(cents)/100).toFixed(2),
145
+ subtitle:'Prepaid balance less the current invoice preview; not a settled charge.'}));
146
+ } catch (_) {ctx.host.log.warn('xAI invoice preview unavailable');}
138
147
 
139
148
  var daily = fetchDaily(ctx, key, id);
140
149
  if (daily.length) {
@@ -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 xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M3 3h5.2l5.3 7.1L19.5 3H22l-7.3 8.9L22 21h-5.2l-5.7-7.5L4.7 21H2l7.9-9.3L3 3zm3.4 1.7 11.2 14.6h1.1L7.5 4.7H6.4z"/></svg>