@hashimkarim/usagestat-linux-x64-gnu 2.0.0-alpha.1

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 (225) hide show
  1. package/LICENSE +57744 -0
  2. package/native-manifest.json +1414 -0
  3. package/package.json +254 -0
  4. package/plugins/abacus-ai/icon.svg +18 -0
  5. package/plugins/abacus-ai/plugin.js +121 -0
  6. package/plugins/abacus-ai/plugin.json +17 -0
  7. package/plugins/alibaba/icon-color.svg +1 -0
  8. package/plugins/alibaba/icon.svg +1 -0
  9. package/plugins/alibaba/plugin.js +322 -0
  10. package/plugins/alibaba/plugin.json +20 -0
  11. package/plugins/alibaba-token-plan/icon-color.svg +1 -0
  12. package/plugins/alibaba-token-plan/icon.svg +1 -0
  13. package/plugins/alibaba-token-plan/plugin.js +544 -0
  14. package/plugins/alibaba-token-plan/plugin.json +19 -0
  15. package/plugins/amp/icon-color.svg +1 -0
  16. package/plugins/amp/icon-conflict.svg +6 -0
  17. package/plugins/amp/icon.svg +1 -0
  18. package/plugins/amp/plugin.js +175 -0
  19. package/plugins/amp/plugin.json +16 -0
  20. package/plugins/antigravity/icon-color.svg +1 -0
  21. package/plugins/antigravity/icon-conflict.svg +3 -0
  22. package/plugins/antigravity/icon.svg +1 -0
  23. package/plugins/antigravity/plugin.js +739 -0
  24. package/plugins/antigravity/plugin.json +31 -0
  25. package/plugins/antigravity-cli/icon.svg +3 -0
  26. package/plugins/antigravity-cli/plugin.js +570 -0
  27. package/plugins/antigravity-cli/plugin.json +16 -0
  28. package/plugins/antigravity-ide/icon.svg +3 -0
  29. package/plugins/antigravity-ide/plugin.js +257 -0
  30. package/plugins/antigravity-ide/plugin.json +29 -0
  31. package/plugins/augment/icon.svg +14 -0
  32. package/plugins/augment/plugin.js +59 -0
  33. package/plugins/augment/plugin.json +18 -0
  34. package/plugins/aws-bedrock/icon-color.svg +1 -0
  35. package/plugins/aws-bedrock/icon.svg +1 -0
  36. package/plugins/aws-bedrock/plugin.js +206 -0
  37. package/plugins/aws-bedrock/plugin.json +18 -0
  38. package/plugins/azure-openai/icon-color.svg +1 -0
  39. package/plugins/azure-openai/icon.svg +1 -0
  40. package/plugins/azure-openai/plugin.js +145 -0
  41. package/plugins/azure-openai/plugin.json +17 -0
  42. package/plugins/chutes/icon.svg +7 -0
  43. package/plugins/chutes/plugin.js +236 -0
  44. package/plugins/chutes/plugin.json +19 -0
  45. package/plugins/claude/icon-color.svg +1 -0
  46. package/plugins/claude/icon.svg +1 -0
  47. package/plugins/claude/plugin.js +1723 -0
  48. package/plugins/claude/plugin.json +30 -0
  49. package/plugins/codebuff/icon.svg +92 -0
  50. package/plugins/codebuff/plugin.js +113 -0
  51. package/plugins/codebuff/plugin.json +17 -0
  52. package/plugins/codex/icon-color.svg +5 -0
  53. package/plugins/codex/icon.svg +1 -0
  54. package/plugins/codex/plugin.js +1009 -0
  55. package/plugins/codex/plugin.json +82 -0
  56. package/plugins/command-code/icon.svg +3 -0
  57. package/plugins/command-code/plugin.js +184 -0
  58. package/plugins/command-code/plugin.json +20 -0
  59. package/plugins/copilot/icon-color.svg +1 -0
  60. package/plugins/copilot/icon.svg +1 -0
  61. package/plugins/copilot/plugin.js +684 -0
  62. package/plugins/copilot/plugin.json +21 -0
  63. package/plugins/crof/icon.svg +3 -0
  64. package/plugins/crof/plugin.js +53 -0
  65. package/plugins/crof/plugin.json +17 -0
  66. package/plugins/crofai/icon.svg +16 -0
  67. package/plugins/crofai/plugin.js +81 -0
  68. package/plugins/crofai/plugin.json +18 -0
  69. package/plugins/cursor/icon-conflict.svg +3 -0
  70. package/plugins/cursor/icon.svg +1 -0
  71. package/plugins/cursor/plugin.js +1379 -0
  72. package/plugins/cursor/plugin.json +23 -0
  73. package/plugins/cursor-nightly/icon.png +0 -0
  74. package/plugins/cursor-nightly/plugin.js +1379 -0
  75. package/plugins/cursor-nightly/plugin.json +23 -0
  76. package/plugins/deepgram/icon.svg +1 -0
  77. package/plugins/deepgram/plugin.js +20 -0
  78. package/plugins/deepgram/plugin.json +17 -0
  79. package/plugins/deepseek/icon-color.svg +1 -0
  80. package/plugins/deepseek/icon.svg +1 -0
  81. package/plugins/deepseek/plugin.js +71 -0
  82. package/plugins/deepseek/plugin.json +17 -0
  83. package/plugins/devin/icon.svg +5 -0
  84. package/plugins/devin/plugin.js +341 -0
  85. package/plugins/devin/plugin.json +16 -0
  86. package/plugins/doubao/icon-color.svg +1 -0
  87. package/plugins/doubao/icon.svg +1 -0
  88. package/plugins/doubao/plugin.js +92 -0
  89. package/plugins/doubao/plugin.json +17 -0
  90. package/plugins/droid/icon.svg +1 -0
  91. package/plugins/droid/plugin.json +20 -0
  92. package/plugins/elevenlabs/icon.svg +4 -0
  93. package/plugins/elevenlabs/plugin.js +48 -0
  94. package/plugins/elevenlabs/plugin.json +18 -0
  95. package/plugins/factory/icon-conflict.svg +1 -0
  96. package/plugins/factory/icon.svg +1 -0
  97. package/plugins/factory/plugin.js +487 -0
  98. package/plugins/factory/plugin.json +15 -0
  99. package/plugins/fireworks-ai/icon.svg +6 -0
  100. package/plugins/fireworks-ai/plugin.js +370 -0
  101. package/plugins/fireworks-ai/plugin.json +19 -0
  102. package/plugins/gemini/icon-color.svg +1 -0
  103. package/plugins/gemini/icon.svg +1 -0
  104. package/plugins/gemini/plugin.js +460 -0
  105. package/plugins/gemini/plugin.json +16 -0
  106. package/plugins/grok/icon.svg +1 -0
  107. package/plugins/grok/plugin.js +297 -0
  108. package/plugins/grok/plugin.json +19 -0
  109. package/plugins/groqcloud/icon.svg +1 -0
  110. package/plugins/groqcloud/plugin.js +117 -0
  111. package/plugins/groqcloud/plugin.json +19 -0
  112. package/plugins/jetbrains-ai-assistant/icon-color.svg +14 -0
  113. package/plugins/jetbrains-ai-assistant/icon-conflict.svg +3 -0
  114. package/plugins/jetbrains-ai-assistant/icon.svg +14 -0
  115. package/plugins/jetbrains-ai-assistant/plugin.js +313 -0
  116. package/plugins/jetbrains-ai-assistant/plugin.json +16 -0
  117. package/plugins/kilo/icon.svg +1 -0
  118. package/plugins/kilo/plugin.js +111 -0
  119. package/plugins/kilo/plugin.json +19 -0
  120. package/plugins/kimi/icon-color.svg +1 -0
  121. package/plugins/kimi/icon-conflict.svg +3 -0
  122. package/plugins/kimi/icon.svg +1 -0
  123. package/plugins/kimi/plugin.js +358 -0
  124. package/plugins/kimi/plugin.json +15 -0
  125. package/plugins/kimi-k2/icon-color.svg +1 -0
  126. package/plugins/kimi-k2/icon.svg +1 -0
  127. package/plugins/kimi-k2/plugin.js +58 -0
  128. package/plugins/kimi-k2/plugin.json +18 -0
  129. package/plugins/kiro/icon-color.svg +5 -0
  130. package/plugins/kiro/icon-conflict.svg +1 -0
  131. package/plugins/kiro/icon.svg +4 -0
  132. package/plugins/kiro/plugin.js +390 -0
  133. package/plugins/kiro/plugin.json +16 -0
  134. package/plugins/litellm/icon.svg +16 -0
  135. package/plugins/litellm/plugin.js +199 -0
  136. package/plugins/litellm/plugin.json +16 -0
  137. package/plugins/llm-proxy/icon.svg +1 -0
  138. package/plugins/llm-proxy/plugin.js +40 -0
  139. package/plugins/llm-proxy/plugin.json +17 -0
  140. package/plugins/manus/icon.svg +6 -0
  141. package/plugins/manus/plugin.js +50 -0
  142. package/plugins/manus/plugin.json +17 -0
  143. package/plugins/mimo/icon.svg +1 -0
  144. package/plugins/mimo/plugin.js +177 -0
  145. package/plugins/mimo/plugin.json +19 -0
  146. package/plugins/minimax/icon-color.svg +1 -0
  147. package/plugins/minimax/icon-conflict.svg +4 -0
  148. package/plugins/minimax/icon.svg +1 -0
  149. package/plugins/minimax/plugin.js +453 -0
  150. package/plugins/minimax/plugin.json +14 -0
  151. package/plugins/mistral/icon-color.svg +1 -0
  152. package/plugins/mistral/icon.svg +1 -0
  153. package/plugins/mistral/plugin.js +152 -0
  154. package/plugins/mistral/plugin.json +18 -0
  155. package/plugins/moonshot/icon.svg +1 -0
  156. package/plugins/moonshot/plugin.js +43 -0
  157. package/plugins/moonshot/plugin.json +16 -0
  158. package/plugins/nanogpt/icon-color.svg +17 -0
  159. package/plugins/nanogpt/icon.svg +10 -0
  160. package/plugins/nanogpt/plugin.js +80 -0
  161. package/plugins/nanogpt/plugin.json +17 -0
  162. package/plugins/neuralwatt/icon.svg +3 -0
  163. package/plugins/neuralwatt/plugin.js +152 -0
  164. package/plugins/neuralwatt/plugin.json +17 -0
  165. package/plugins/ollama/icon.svg +1 -0
  166. package/plugins/ollama/plugin.js +92 -0
  167. package/plugins/ollama/plugin.json +20 -0
  168. package/plugins/openai-api/icon.svg +1 -0
  169. package/plugins/openai-api/plugin.js +533 -0
  170. package/plugins/openai-api/plugin.json +26 -0
  171. package/plugins/opencode/icon.svg +1 -0
  172. package/plugins/opencode/plugin.js +342 -0
  173. package/plugins/opencode/plugin.json +19 -0
  174. package/plugins/opencode-go/icon-conflict.svg +1 -0
  175. package/plugins/opencode-go/icon.svg +1 -0
  176. package/plugins/opencode-go/plugin.js +617 -0
  177. package/plugins/opencode-go/plugin.json +50 -0
  178. package/plugins/openrouter/icon.svg +1 -0
  179. package/plugins/openrouter/plugin.js +156 -0
  180. package/plugins/openrouter/plugin.json +8 -0
  181. package/plugins/perplexity/icon-color.svg +1 -0
  182. package/plugins/perplexity/icon-conflict.svg +1 -0
  183. package/plugins/perplexity/icon.svg +1 -0
  184. package/plugins/perplexity/plugin.js +425 -0
  185. package/plugins/perplexity/plugin.json +19 -0
  186. package/plugins/poe/icon.svg +1 -0
  187. package/plugins/poe/plugin.js +190 -0
  188. package/plugins/poe/plugin.json +19 -0
  189. package/plugins/stepfun/icon-color.svg +1 -0
  190. package/plugins/stepfun/icon.svg +1 -0
  191. package/plugins/stepfun/plugin.js +155 -0
  192. package/plugins/stepfun/plugin.json +18 -0
  193. package/plugins/synthetic/icon-conflict.svg +12 -0
  194. package/plugins/synthetic/icon.svg +14 -0
  195. package/plugins/synthetic/plugin.js +331 -0
  196. package/plugins/synthetic/plugin.json +23 -0
  197. package/plugins/t3chat/icon-color.svg +28 -0
  198. package/plugins/t3chat/icon.svg +4 -0
  199. package/plugins/t3chat/plugin.js +243 -0
  200. package/plugins/t3chat/plugin.json +20 -0
  201. package/plugins/venice/icon-color.svg +1 -0
  202. package/plugins/venice/icon.svg +1 -0
  203. package/plugins/venice/plugin.js +69 -0
  204. package/plugins/venice/plugin.json +16 -0
  205. package/plugins/vertex-ai/icon-color.svg +1 -0
  206. package/plugins/vertex-ai/icon.svg +1 -0
  207. package/plugins/vertex-ai/plugin.js +172 -0
  208. package/plugins/vertex-ai/plugin.json +18 -0
  209. package/plugins/warp/icon-color.svg +10 -0
  210. package/plugins/warp/icon.svg +6 -0
  211. package/plugins/warp/plugin.js +108 -0
  212. package/plugins/warp/plugin.json +18 -0
  213. package/plugins/windsurf/icon-conflict.svg +3 -0
  214. package/plugins/windsurf/icon.svg +1 -0
  215. package/plugins/windsurf/plugin.js +208 -0
  216. package/plugins/windsurf/plugin.json +16 -0
  217. package/plugins/zai/icon-conflict.svg +5 -0
  218. package/plugins/zai/icon.svg +1 -0
  219. package/plugins/zai/plugin.js +188 -0
  220. package/plugins/zai/plugin.json +16 -0
  221. package/plugins/zed/icon.svg +4 -0
  222. package/plugins/zed/plugin.js +270 -0
  223. package/plugins/zed/plugin.json +19 -0
  224. package/usagestat +0 -0
  225. package/usagestatd +0 -0
@@ -0,0 +1,322 @@
1
+ (function () {
2
+ var USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36";
3
+ var INTL_PROFILE = {
4
+ gateway: "https://modelstudio.console.alibabacloud.com",
5
+ apiAction: "IntlBroadScopeAspnGateway",
6
+ apiProduct: "sfm_bailian",
7
+ apiMethod: "zeldaEasy.broadscope-bailian.codingPlan.queryCodingPlanInstanceInfoV2",
8
+ commodityCode: "sfm_codingplan_public_intl",
9
+ switchAgent: 313762,
10
+ switchUserType: 3,
11
+ consoleSite: "MODELSTUDIO_ALBABACLOUD",
12
+ consoleDomain: "modelstudio.console.alibabacloud.com",
13
+ };
14
+
15
+ function trim(value) {
16
+ return typeof value === "string" && value.trim() ? value.trim() : null;
17
+ }
18
+
19
+ function env(ctx, name) {
20
+ try {
21
+ return trim(ctx.host.env.get(name));
22
+ } catch (_) {
23
+ return null;
24
+ }
25
+ }
26
+
27
+ function settings(ctx) {
28
+ return ctx.provider && ctx.provider.settings ? ctx.provider.settings : {};
29
+ }
30
+
31
+ function regionFromValue(raw) {
32
+ var value = String(raw || "").trim().toLowerCase();
33
+ if (value === "us" || value === "us-east-1" || value === "useast" || value === "us-west-1") return "us";
34
+ if (value === "germany" || value === "eu" || value === "eu-central-1" || value === "frankfurt") return "germany";
35
+ if (value === "hongkong" || value === "hong-kong" || value === "hk" || value === "cn-hongkong") return "hongkong";
36
+ if (value === "cn" || value === "china" || value === "china-mainland" || value === "china_mainland" || value === "mainland") return "cn";
37
+ return "singapore";
38
+ }
39
+
40
+ function region(ctx) {
41
+ var s = settings(ctx);
42
+ return regionFromValue(
43
+ trim(ctx.provider && ctx.provider.region) ||
44
+ trim(s.region) ||
45
+ trim(s.apiRegion) ||
46
+ trim(s.api_region) ||
47
+ env(ctx, "ALIBABA_CODING_PLAN_REGION")
48
+ );
49
+ }
50
+
51
+ function regionCode(region) {
52
+ return {
53
+ singapore: "ap-southeast-1",
54
+ us: "us-east-1",
55
+ germany: "eu-central-1",
56
+ hongkong: "cn-hongkong",
57
+ cn: "cn-hangzhou",
58
+ }[region] || "ap-southeast-1";
59
+ }
60
+
61
+ function profile(region, ctx) {
62
+ var host = trim(settings(ctx).host) || env(ctx, "ALIBABA_CODING_PLAN_HOST");
63
+ var base = region === "cn" ? "https://bailian.console.alibabacloud.com" : INTL_PROFILE.gateway;
64
+ if (host) {
65
+ base = /^https:\/\//i.test(host) ? host : "https://" + host;
66
+ base = base.replace(/\/+$/, "");
67
+ }
68
+ if (region === "cn") {
69
+ var cn = {};
70
+ Object.keys(INTL_PROFILE).forEach(function (key) { cn[key] = INTL_PROFILE[key]; });
71
+ cn.gateway = base;
72
+ cn.consoleDomain = base.replace(/^https:\/\//i, "");
73
+ return cn;
74
+ }
75
+ var intl = {};
76
+ Object.keys(INTL_PROFILE).forEach(function (key) { intl[key] = INTL_PROFILE[key]; });
77
+ intl.gateway = base;
78
+ intl.consoleDomain = base.replace(/^https:\/\//i, "");
79
+ return intl;
80
+ }
81
+
82
+ function dashboardUrl(region, profile) {
83
+ return region === "cn" ? profile.gateway : profile.gateway + "/" + regionCode(region);
84
+ }
85
+
86
+ function cookieHeader(ctx) {
87
+ var s = settings(ctx);
88
+ var cookie = trim(ctx.provider && ctx.provider.cookieHeader) ||
89
+ trim(s.cookieHeader) ||
90
+ trim(s.cookie) ||
91
+ env(ctx, "ALIBABA_CODING_PLAN_COOKIE") ||
92
+ env(ctx, "ALIBABA_COOKIE");
93
+ if (cookie) return cookie;
94
+ if (env(ctx, "ALIBABA_CODING_PLAN_API_KEY")) {
95
+ throw "Alibaba Coding Plan quota requires browser cookies; API keys cannot read console quotas.";
96
+ }
97
+ throw "Alibaba session not configured. Set ALIBABA_COOKIE or ALIBABA_CODING_PLAN_COOKIE.";
98
+ }
99
+
100
+ function cookieValue(name, cookie) {
101
+ var parts = String(cookie || "").split(";");
102
+ for (var i = 0; i < parts.length; i++) {
103
+ var idx = parts[i].indexOf("=");
104
+ if (idx < 0) continue;
105
+ var key = parts[i].slice(0, idx).trim();
106
+ var value = parts[i].slice(idx + 1).trim();
107
+ if (key === name && value) return value;
108
+ }
109
+ return null;
110
+ }
111
+
112
+ function extractSecToken(html) {
113
+ var patterns = [
114
+ /"secToken"\s*:\s*"([^"]+)"/,
115
+ /"sec_token"\s*:\s*"([^"]+)"/,
116
+ /secToken['"]?\s*[:=]\s*['"]([^'"]+)['"]/,
117
+ /sec_token['"]?\s*[:=]\s*['"]([^'"]+)['"]/,
118
+ ];
119
+ for (var i = 0; i < patterns.length; i++) {
120
+ var match = patterns[i].exec(String(html || ""));
121
+ if (match && match[1] && match[1].trim()) return match[1].trim();
122
+ }
123
+ return null;
124
+ }
125
+
126
+ function resolveSecToken(ctx, cookie, regionName, requestProfile) {
127
+ try {
128
+ var resp = ctx.util.request({
129
+ method: "GET",
130
+ url: dashboardUrl(regionName, requestProfile) + "?tab=plan",
131
+ headers: {
132
+ Cookie: cookie,
133
+ "User-Agent": USER_AGENT,
134
+ Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
135
+ },
136
+ timeoutMs: 10000,
137
+ });
138
+ if (resp.status >= 200 && resp.status < 300) {
139
+ return extractSecToken(resp.bodyText) || cookieValue("sec_token", cookie);
140
+ }
141
+ } catch (_) {}
142
+ return cookieValue("sec_token", cookie);
143
+ }
144
+
145
+ function randomId() {
146
+ return Math.random().toString(16).slice(2) + Date.now().toString(16);
147
+ }
148
+
149
+ function quotaUrl(ctx, requestProfile) {
150
+ var override = trim(settings(ctx).quotaUrl) || env(ctx, "ALIBABA_CODING_PLAN_QUOTA_URL");
151
+ if (override) {
152
+ if (!/^https:\/\//i.test(override)) override = "https://" + override;
153
+ return override;
154
+ }
155
+ return requestProfile.gateway + "/data/api.json?action=" + encodeURIComponent(requestProfile.apiAction) +
156
+ "&product=" + encodeURIComponent(requestProfile.apiProduct) + "&_tag=";
157
+ }
158
+
159
+ function formEncode(pairs) {
160
+ return pairs.map(function (pair) {
161
+ return encodeURIComponent(pair[0]) + "=" + encodeURIComponent(pair[1]);
162
+ }).join("&");
163
+ }
164
+
165
+ function fetchQuota(ctx, cookie, regionName, requestProfile, secToken) {
166
+ var referer = dashboardUrl(regionName, requestProfile) + "?tab=plan";
167
+ var feUrl = referer + "#/efm/subscription/coding-plan";
168
+ var params = {
169
+ Api: requestProfile.apiMethod,
170
+ V: "1.0",
171
+ Data: {
172
+ queryCodingPlanInstanceInfoRequest: {
173
+ commodityCode: requestProfile.commodityCode,
174
+ onlyLatestOne: true,
175
+ },
176
+ cornerstoneParam: {
177
+ feTraceId: randomId(),
178
+ feURL: feUrl,
179
+ protocol: "V2",
180
+ console: "ONE_CONSOLE",
181
+ productCode: "p_efm",
182
+ switchAgent: requestProfile.switchAgent,
183
+ switchUserType: requestProfile.switchUserType,
184
+ domain: requestProfile.consoleDomain,
185
+ consoleSite: requestProfile.consoleSite,
186
+ userNickName: "",
187
+ userPrincipalName: "",
188
+ xsp_lang: "en-US",
189
+ "X-Anonymous-Id": cookieValue("cna", cookie) || "",
190
+ },
191
+ },
192
+ };
193
+ var form = [
194
+ ["action", requestProfile.apiAction],
195
+ ["product", requestProfile.apiProduct],
196
+ ["api", requestProfile.apiMethod],
197
+ ["_v", "undefined"],
198
+ ["params", JSON.stringify(params)],
199
+ ["region", regionCode(regionName)],
200
+ ];
201
+ if (secToken) form.push(["sec_token", secToken]);
202
+ var resp = ctx.util.request({
203
+ method: "POST",
204
+ url: quotaUrl(ctx, requestProfile),
205
+ headers: {
206
+ Cookie: cookie,
207
+ "Content-Type": "application/x-www-form-urlencoded",
208
+ Accept: "*/*",
209
+ Origin: requestProfile.gateway,
210
+ Referer: referer,
211
+ "User-Agent": USER_AGENT,
212
+ "sec-fetch-site": "same-origin",
213
+ "sec-fetch-mode": "cors",
214
+ "sec-fetch-dest": "empty",
215
+ },
216
+ bodyText: formEncode(form),
217
+ timeoutMs: 20000,
218
+ });
219
+ if (ctx.util.isAuthStatus(resp.status)) throw "Alibaba Coding Plan login required.";
220
+ if (resp.status < 200 || resp.status >= 300) throw "Alibaba Coding Plan API error: HTTP " + resp.status + ".";
221
+ if (/^\s*</.test(String(resp.bodyText || ""))) throw "Alibaba Coding Plan login required.";
222
+ var json = ctx.util.tryParseJson(resp.bodyText);
223
+ if (!json) throw "Alibaba Coding Plan response was not valid JSON.";
224
+ return json;
225
+ }
226
+
227
+ function pointer(value, path) {
228
+ var current = value;
229
+ for (var i = 0; i < path.length; i++) {
230
+ if (!current || typeof current !== "object") return undefined;
231
+ current = current[path[i]];
232
+ }
233
+ return current;
234
+ }
235
+
236
+ function numberValue(value) {
237
+ if (typeof value === "number" && Number.isFinite(value)) return value;
238
+ if (typeof value === "string" && value.trim()) {
239
+ var parsed = Number(value.replace(/,/g, ""));
240
+ if (Number.isFinite(parsed)) return parsed;
241
+ }
242
+ return null;
243
+ }
244
+
245
+ function formatTokens(value) {
246
+ var rounded = Math.round(value || 0);
247
+ return String(rounded).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
248
+ }
249
+
250
+ function dateFromMs(ctx, value) {
251
+ var ms = numberValue(value);
252
+ return ms && ms > 0 ? ctx.util.toIso(ms) : null;
253
+ }
254
+
255
+ function progress(ctx, label, quota, usedKey, totalKey, resetKey, periodMs) {
256
+ var used = numberValue(quota[usedKey]) || 0;
257
+ var total = numberValue(quota[totalKey]) || 0;
258
+ var line = {
259
+ label: label,
260
+ used: used,
261
+ limit: total > 0 ? total : 1,
262
+ format: { kind: "count", suffix: "tokens" },
263
+ detail: formatTokens(used) + " / " + formatTokens(total) + " tokens",
264
+ periodDurationMs: periodMs,
265
+ };
266
+ var reset = dateFromMs(ctx, quota[resetKey]);
267
+ if (reset) line.resetsAt = reset;
268
+ return ctx.line.progress(line);
269
+ }
270
+
271
+ function parseQuota(ctx, json) {
272
+ var code = trim(json && json.code);
273
+ if (code && code !== "200") {
274
+ if (code === "401" || code === "403") throw "Alibaba Coding Plan login required.";
275
+ throw "Alibaba Coding Plan API error: " + (trim(json.message) || code);
276
+ }
277
+ var ret = pointer(json, ["data", "DataV2", "ret"]);
278
+ if (Array.isArray(ret)) {
279
+ var joined = ret.join(";");
280
+ if (joined.indexOf("No Authority") >= 0 || joined.indexOf("10032390") >= 0 || joined.indexOf("NeedLogin") >= 0) {
281
+ throw "Alibaba Coding Plan login required.";
282
+ }
283
+ }
284
+ var instances = pointer(json, ["data", "DataV2", "data", "data", "codingPlanInstanceInfos"]);
285
+ if (!Array.isArray(instances) || instances.length === 0) {
286
+ throw "Alibaba Coding Plan response missing codingPlanInstanceInfos.";
287
+ }
288
+ var instance = instances[0];
289
+ for (var i = 0; i < instances.length; i++) {
290
+ if (instances[i] && instances[i].status === "VALID") {
291
+ instance = instances[i];
292
+ break;
293
+ }
294
+ }
295
+ var quota = instance && instance.codingPlanQuotaInfo;
296
+ if (!quota || typeof quota !== "object") throw "Alibaba Coding Plan response missing quota info.";
297
+ return {
298
+ plan: trim(instance.instanceName) || "Coding Plan",
299
+ quota: quota,
300
+ };
301
+ }
302
+
303
+ function probe(ctx) {
304
+ var regionName = region(ctx);
305
+ var requestProfile = profile(regionName, ctx);
306
+ var cookie = cookieHeader(ctx);
307
+ var secToken = resolveSecToken(ctx, cookie, regionName, requestProfile);
308
+ var parsed = parseQuota(ctx, fetchQuota(ctx, cookie, regionName, requestProfile, secToken));
309
+ return {
310
+ displayName: "Alibaba",
311
+ source: "web",
312
+ plan: parsed.plan,
313
+ lines: [
314
+ progress(ctx, "5-Hour", parsed.quota, "per5HourUsedQuota", "per5HourTotalQuota", "per5HourQuotaNextRefreshTime", 5 * 60 * 60 * 1000),
315
+ progress(ctx, "Weekly", parsed.quota, "perWeekUsedQuota", "perWeekTotalQuota", "perWeekQuotaNextRefreshTime", 7 * 24 * 60 * 60 * 1000),
316
+ progress(ctx, "Monthly", parsed.quota, "perBillMonthUsedQuota", "perBillMonthTotalQuota", "perBillMonthQuotaNextRefreshTime", 30 * 24 * 60 * 60 * 1000),
317
+ ],
318
+ };
319
+ }
320
+
321
+ globalThis.__openusage_plugin = { id: "alibaba", probe: probe };
322
+ })();
@@ -0,0 +1,20 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "alibaba",
4
+ "name": "Alibaba",
5
+ "version": "0.0.1",
6
+ "entry": "plugin.js",
7
+ "brandColor": "#FF6A00",
8
+ "links": [
9
+ { "label": "Console", "url": "https://bailian.console.aliyun.com" },
10
+ { "label": "Status", "url": "https://status.aliyun.com" }
11
+ ],
12
+ "supportedModes": ["web"],
13
+ "autoMode": "web",
14
+ "webUrl": "https://bailian.console.aliyun.com",
15
+ "lines": [
16
+ { "type": "progress", "label": "5-Hour", "scope": "overview", "primaryOrder": 1 },
17
+ { "type": "progress", "label": "Weekly", "scope": "detail" },
18
+ { "type": "progress", "label": "Monthly", "scope": "detail" }
19
+ ]
20
+ }
@@ -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>BaiLian</title><path d="M6.336 8.919v6.162l5.335-3.083L6.337 8.92z" fill="#1C54E3"></path><path d="M21.394 5.288s-.006-.006-.01-.006L17.01 2.754 6.336 8.92l5.335 3.082 9.701-5.6.016-.01a.635.635 0 00.006-1.1v-.003z" fill="#AA9AFF"></path><path d="M21.71 12.465a.62.62 0 00-.316.085s-.006 0-.009.003l-4.375 2.528 5.05 2.915h.006a2.06 2.06 0 00.28-1.04v-3.855a.637.637 0 00-.636-.636z" fill="#00EAD1"></path><path d="M22.06 17.996l-5.05-2.915L6.34 21.242l4.27 2.465s.016.006.022.012a2.102 2.102 0 002.093 0c.006-.003.016-.006.022-.012l8.538-4.93c.003 0 .006-.003.01-.006.321-.183.589-.45.775-.772h-.006l-.004-.003z" fill="#00CEC9"></path><path d="M11.672 11.998l-5.336 3.083-1.444.832-3.605 2.083H1.28c.173.303.416.555.709.738l.078.044.016.01.02.012 4.232 2.442 10.671-6.161-5.335-3.082z" fill="#00EAD1"></path><path d="M12.74.29c-.1-.06-.208-.107-.315-.148-.02-.006-.038-.016-.057-.022a2.121 2.121 0 00-.7-.12c-.233 0-.457.038-.668.11l-.031.01a2.196 2.196 0 00-.372.17L2.068 5.222s-.003 0-.006.003c-.324.183-.592.451-.781.773h.006l5.049 2.918L17.01 2.758 12.74.29z" fill="#7347FF"></path><path d="M1.287 6.001H1.28A2.06 2.06 0 001 7.041v9.915c0 .378.1.735.28 1.043h.007l5.049-2.918V8.919l-5.05-2.918z" fill="#0423DA"></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>BaiLian</title><path d="M6.336 8.919v6.162l5.335-3.083L6.337 8.92z" fill-opacity=".4"></path><path d="M21.394 5.288s-.006-.006-.01-.006L17.01 2.754 6.336 8.92l5.335 3.082 9.701-5.6.016-.01a.635.635 0 00.006-1.1v-.003z" fill-opacity=".8"></path><path d="M21.71 12.465a.62.62 0 00-.316.085s-.006 0-.009.003l-4.375 2.528 5.05 2.915h.006a2.06 2.06 0 00.28-1.04v-3.855a.637.637 0 00-.636-.636z"></path><path d="M22.06 17.996l-5.05-2.915L6.34 21.242l4.27 2.465s.016.006.022.012a2.102 2.102 0 002.093 0c.006-.003.016-.006.022-.012l8.538-4.93c.003 0 .006-.003.01-.006.321-.183.589-.45.775-.772h-.006l-.004-.003z" fill-opacity=".8"></path><path d="M11.672 11.998l-5.336 3.083-1.444.832-3.605 2.083H1.28c.173.303.416.555.709.738l.078.044.016.01.02.012 4.232 2.442 10.671-6.161-5.335-3.082z"></path><path d="M12.74.29c-.1-.06-.208-.107-.315-.148-.02-.006-.038-.016-.057-.022a2.121 2.121 0 00-.7-.12c-.233 0-.457.038-.668.11l-.031.01a2.196 2.196 0 00-.372.17L2.068 5.222s-.003 0-.006.003c-.324.183-.592.451-.781.773h.006l5.049 2.918L17.01 2.758 12.74.29z" fill-opacity=".6"></path><path d="M1.287 6.001H1.28A2.06 2.06 0 001 7.041v9.915c0 .378.1.735.28 1.043h.007l5.049-2.918V8.919l-5.05-2.918z" fill-opacity=".3"></path></svg>