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

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 (273) hide show
  1. package/LICENSE +0 -0
  2. package/native-manifest.json +365 -77
  3. package/package.json +49 -1
  4. package/plugins/UPSTREAM-LICENSES.md +109 -0
  5. package/plugins/abacus-ai/icon.svg +0 -0
  6. package/plugins/abacus-ai/plugin.js +0 -0
  7. package/plugins/abacus-ai/plugin.json +0 -0
  8. package/plugins/aiand/icon.svg +6 -0
  9. package/plugins/aiand/plugin.js +108 -0
  10. package/plugins/aiand/plugin.json +22 -0
  11. package/plugins/alibaba/icon-color.svg +0 -0
  12. package/plugins/alibaba/icon.svg +0 -0
  13. package/plugins/alibaba/plugin.js +0 -0
  14. package/plugins/alibaba/plugin.json +0 -0
  15. package/plugins/alibaba-token-plan/icon-color.svg +0 -0
  16. package/plugins/alibaba-token-plan/icon.svg +0 -0
  17. package/plugins/alibaba-token-plan/plugin.js +0 -0
  18. package/plugins/alibaba-token-plan/plugin.json +0 -0
  19. package/plugins/amp/icon-color.svg +0 -0
  20. package/plugins/amp/icon-conflict.svg +0 -0
  21. package/plugins/amp/icon.svg +0 -0
  22. package/plugins/amp/plugin.js +0 -0
  23. package/plugins/amp/plugin.json +0 -0
  24. package/plugins/antigravity/icon-color.svg +0 -0
  25. package/plugins/antigravity/icon-conflict.svg +0 -0
  26. package/plugins/antigravity/icon.svg +0 -0
  27. package/plugins/antigravity/plugin.js +0 -0
  28. package/plugins/antigravity/plugin.json +0 -0
  29. package/plugins/antigravity-cli/icon.svg +0 -0
  30. package/plugins/antigravity-cli/plugin.js +0 -0
  31. package/plugins/antigravity-cli/plugin.json +0 -0
  32. package/plugins/antigravity-ide/icon.svg +0 -0
  33. package/plugins/antigravity-ide/plugin.js +0 -0
  34. package/plugins/antigravity-ide/plugin.json +0 -0
  35. package/plugins/augment/icon.svg +0 -0
  36. package/plugins/augment/plugin.js +0 -0
  37. package/plugins/augment/plugin.json +0 -0
  38. package/plugins/aws-bedrock/icon-color.svg +0 -0
  39. package/plugins/aws-bedrock/icon.svg +0 -0
  40. package/plugins/aws-bedrock/plugin.js +0 -0
  41. package/plugins/aws-bedrock/plugin.json +0 -0
  42. package/plugins/azure-openai/icon-color.svg +0 -0
  43. package/plugins/azure-openai/icon.svg +0 -0
  44. package/plugins/azure-openai/plugin.js +0 -0
  45. package/plugins/azure-openai/plugin.json +0 -0
  46. package/plugins/chutes/icon.svg +0 -0
  47. package/plugins/chutes/plugin.js +0 -0
  48. package/plugins/chutes/plugin.json +0 -0
  49. package/plugins/claude/icon-color.svg +0 -0
  50. package/plugins/claude/icon.svg +0 -0
  51. package/plugins/claude/plugin.js +70 -23
  52. package/plugins/claude/plugin.json +0 -0
  53. package/plugins/clawrouter/icon.svg +7 -0
  54. package/plugins/clawrouter/plugin.js +45 -0
  55. package/plugins/clawrouter/plugin.json +22 -0
  56. package/plugins/clinepass/icon.svg +4 -0
  57. package/plugins/clinepass/plugin.js +71 -0
  58. package/plugins/clinepass/plugin.json +23 -0
  59. package/plugins/codebuddy/plugin.js +331 -0
  60. package/plugins/codebuddy/plugin.json +30 -0
  61. package/plugins/codebuff/icon.svg +0 -0
  62. package/plugins/codebuff/plugin.js +0 -0
  63. package/plugins/codebuff/plugin.json +0 -0
  64. package/plugins/codex/icon-color.svg +0 -0
  65. package/plugins/codex/icon.svg +0 -0
  66. package/plugins/codex/plugin.js +7 -2
  67. package/plugins/codex/plugin.json +0 -0
  68. package/plugins/command-code/icon.svg +0 -0
  69. package/plugins/command-code/plugin.js +7 -0
  70. package/plugins/command-code/plugin.json +0 -0
  71. package/plugins/copilot/icon-color.svg +0 -0
  72. package/plugins/copilot/icon.svg +0 -0
  73. package/plugins/copilot/plugin.js +61 -9
  74. package/plugins/copilot/plugin.json +4 -1
  75. package/plugins/crof/icon.svg +0 -0
  76. package/plugins/crof/plugin.js +0 -0
  77. package/plugins/crof/plugin.json +0 -0
  78. package/plugins/crofai/icon.svg +0 -0
  79. package/plugins/crofai/plugin.js +0 -0
  80. package/plugins/crofai/plugin.json +0 -0
  81. package/plugins/cursor/icon-conflict.svg +0 -0
  82. package/plugins/cursor/icon.svg +0 -0
  83. package/plugins/cursor/plugin.js +46 -9
  84. package/plugins/cursor/plugin.json +3 -2
  85. package/plugins/cursor-nightly/icon.png +0 -0
  86. package/plugins/cursor-nightly/plugin.js +45 -8
  87. package/plugins/cursor-nightly/plugin.json +3 -2
  88. package/plugins/deepgram/icon.svg +0 -0
  89. package/plugins/deepgram/plugin.js +0 -0
  90. package/plugins/deepgram/plugin.json +0 -0
  91. package/plugins/deepinfra/icon.svg +4 -0
  92. package/plugins/deepinfra/plugin.js +97 -0
  93. package/plugins/deepinfra/plugin.json +28 -0
  94. package/plugins/deepseek/icon-color.svg +0 -0
  95. package/plugins/deepseek/icon.svg +0 -0
  96. package/plugins/deepseek/plugin.js +0 -0
  97. package/plugins/deepseek/plugin.json +0 -0
  98. package/plugins/devin/icon.svg +0 -0
  99. package/plugins/devin/plugin.js +111 -0
  100. package/plugins/devin/plugin.json +2 -1
  101. package/plugins/doubao/icon-color.svg +0 -0
  102. package/plugins/doubao/icon.svg +0 -0
  103. package/plugins/doubao/plugin.js +0 -0
  104. package/plugins/doubao/plugin.json +0 -0
  105. package/plugins/droid/icon.svg +0 -0
  106. package/plugins/droid/plugin.json +2 -1
  107. package/plugins/elevenlabs/icon.svg +0 -0
  108. package/plugins/elevenlabs/plugin.js +17 -2
  109. package/plugins/elevenlabs/plugin.json +0 -0
  110. package/plugins/factory/icon-conflict.svg +0 -0
  111. package/plugins/factory/icon.svg +0 -0
  112. package/plugins/factory/plugin.js +38 -14
  113. package/plugins/factory/plugin.json +2 -1
  114. package/plugins/fireworks-ai/icon.svg +0 -0
  115. package/plugins/fireworks-ai/plugin.js +0 -0
  116. package/plugins/fireworks-ai/plugin.json +0 -0
  117. package/plugins/gemini/icon-color.svg +0 -0
  118. package/plugins/gemini/icon.svg +0 -0
  119. package/plugins/gemini/plugin.js +0 -0
  120. package/plugins/gemini/plugin.json +0 -0
  121. package/plugins/grok/icon.svg +0 -0
  122. package/plugins/grok/plugin.js +30 -5
  123. package/plugins/grok/plugin.json +3 -1
  124. package/plugins/groqcloud/icon.svg +0 -0
  125. package/plugins/groqcloud/plugin.js +0 -0
  126. package/plugins/groqcloud/plugin.json +0 -0
  127. package/plugins/ibmbob/icon.svg +23 -0
  128. package/plugins/ibmbob/plugin.js +61 -0
  129. package/plugins/ibmbob/plugin.json +22 -0
  130. package/plugins/jetbrains-ai-assistant/icon-color.svg +0 -0
  131. package/plugins/jetbrains-ai-assistant/icon-conflict.svg +0 -0
  132. package/plugins/jetbrains-ai-assistant/icon.svg +0 -0
  133. package/plugins/jetbrains-ai-assistant/plugin.js +0 -0
  134. package/plugins/jetbrains-ai-assistant/plugin.json +0 -0
  135. package/plugins/kilo/icon.svg +0 -0
  136. package/plugins/kilo/plugin.js +0 -0
  137. package/plugins/kilo/plugin.json +0 -0
  138. package/plugins/kimi/icon-color.svg +0 -0
  139. package/plugins/kimi/icon-conflict.svg +0 -0
  140. package/plugins/kimi/icon.svg +0 -0
  141. package/plugins/kimi/plugin.js +122 -141
  142. package/plugins/kimi/plugin.json +5 -2
  143. package/plugins/kimi-k2/icon-color.svg +0 -0
  144. package/plugins/kimi-k2/icon.svg +0 -0
  145. package/plugins/kimi-k2/plugin.js +0 -0
  146. package/plugins/kimi-k2/plugin.json +0 -0
  147. package/plugins/kiro/icon-color.svg +0 -0
  148. package/plugins/kiro/icon-conflict.svg +0 -0
  149. package/plugins/kiro/icon.svg +0 -0
  150. package/plugins/kiro/plugin.js +49 -10
  151. package/plugins/kiro/plugin.json +3 -1
  152. package/plugins/litellm/icon.svg +0 -0
  153. package/plugins/litellm/plugin.js +0 -0
  154. package/plugins/litellm/plugin.json +0 -0
  155. package/plugins/llm-proxy/icon.svg +0 -0
  156. package/plugins/llm-proxy/plugin.js +0 -0
  157. package/plugins/llm-proxy/plugin.json +0 -0
  158. package/plugins/longcat/icon.svg +4 -0
  159. package/plugins/longcat/plugin.js +182 -0
  160. package/plugins/longcat/plugin.json +23 -0
  161. package/plugins/manus/icon.svg +0 -0
  162. package/plugins/manus/plugin.js +0 -0
  163. package/plugins/manus/plugin.json +0 -0
  164. package/plugins/mimo/icon.svg +0 -0
  165. package/plugins/mimo/plugin.js +0 -0
  166. package/plugins/mimo/plugin.json +0 -0
  167. package/plugins/minimax/icon-color.svg +0 -0
  168. package/plugins/minimax/icon-conflict.svg +0 -0
  169. package/plugins/minimax/icon.svg +0 -0
  170. package/plugins/minimax/plugin.js +25 -31
  171. package/plugins/minimax/plugin.json +0 -0
  172. package/plugins/mistral/icon-color.svg +0 -0
  173. package/plugins/mistral/icon.svg +0 -0
  174. package/plugins/mistral/plugin.js +0 -0
  175. package/plugins/mistral/plugin.json +0 -0
  176. package/plugins/moonshot/icon.svg +0 -0
  177. package/plugins/moonshot/plugin.js +8 -6
  178. package/plugins/moonshot/plugin.json +0 -0
  179. package/plugins/nanogpt/icon-color.svg +0 -0
  180. package/plugins/nanogpt/icon.svg +0 -0
  181. package/plugins/nanogpt/plugin.js +0 -0
  182. package/plugins/nanogpt/plugin.json +0 -0
  183. package/plugins/neuralwatt/icon.svg +0 -0
  184. package/plugins/neuralwatt/plugin.js +0 -0
  185. package/plugins/neuralwatt/plugin.json +0 -0
  186. package/plugins/notion/icon.svg +1 -0
  187. package/plugins/notion/plugin.js +282 -0
  188. package/plugins/notion/plugin.json +29 -0
  189. package/plugins/ollama/icon.svg +0 -0
  190. package/plugins/ollama/plugin.js +257 -56
  191. package/plugins/ollama/plugin.json +6 -3
  192. package/plugins/openai-api/icon.svg +0 -0
  193. package/plugins/openai-api/plugin.js +0 -0
  194. package/plugins/openai-api/plugin.json +0 -0
  195. package/plugins/opencode/icon.svg +0 -0
  196. package/plugins/opencode/plugin.js +0 -0
  197. package/plugins/opencode/plugin.json +0 -0
  198. package/plugins/opencode-go/icon-conflict.svg +0 -0
  199. package/plugins/opencode-go/icon.svg +0 -0
  200. package/plugins/opencode-go/plugin.js +78 -10
  201. package/plugins/opencode-go/plugin.json +5 -2
  202. package/plugins/openrouter/icon.svg +0 -0
  203. package/plugins/openrouter/plugin.js +371 -114
  204. package/plugins/openrouter/plugin.json +6 -0
  205. package/plugins/perplexity/icon-color.svg +0 -0
  206. package/plugins/perplexity/icon-conflict.svg +0 -0
  207. package/plugins/perplexity/icon.svg +0 -0
  208. package/plugins/perplexity/plugin.js +0 -0
  209. package/plugins/perplexity/plugin.json +0 -0
  210. package/plugins/poe/icon.svg +0 -0
  211. package/plugins/poe/plugin.js +24 -18
  212. package/plugins/poe/plugin.json +2 -0
  213. package/plugins/qoder/icon.svg +3 -0
  214. package/plugins/qoder/plugin.js +227 -0
  215. package/plugins/qoder/plugin.json +23 -0
  216. package/plugins/qwencloud/icon.svg +4 -0
  217. package/plugins/qwencloud/plugin.js +677 -0
  218. package/plugins/qwencloud/plugin.json +29 -0
  219. package/plugins/sakana/icon.svg +5 -0
  220. package/plugins/sakana/plugin.js +156 -0
  221. package/plugins/sakana/plugin.json +23 -0
  222. package/plugins/stepfun/icon-color.svg +0 -0
  223. package/plugins/stepfun/icon.svg +0 -0
  224. package/plugins/stepfun/plugin.js +0 -0
  225. package/plugins/stepfun/plugin.json +0 -0
  226. package/plugins/sub2api/icon.svg +4 -0
  227. package/plugins/sub2api/plugin.js +191 -0
  228. package/plugins/sub2api/plugin.json +16 -0
  229. package/plugins/synthetic/icon-conflict.svg +0 -0
  230. package/plugins/synthetic/icon.svg +0 -0
  231. package/plugins/synthetic/plugin.js +0 -0
  232. package/plugins/synthetic/plugin.json +0 -0
  233. package/plugins/t3chat/icon-color.svg +0 -0
  234. package/plugins/t3chat/icon.svg +0 -0
  235. package/plugins/t3chat/plugin.js +0 -0
  236. package/plugins/t3chat/plugin.json +0 -0
  237. package/plugins/venice/icon-color.svg +0 -0
  238. package/plugins/venice/icon.svg +0 -0
  239. package/plugins/venice/plugin.js +0 -0
  240. package/plugins/venice/plugin.json +0 -0
  241. package/plugins/vertex-ai/icon-color.svg +0 -0
  242. package/plugins/vertex-ai/icon.svg +0 -0
  243. package/plugins/vertex-ai/plugin.js +0 -0
  244. package/plugins/vertex-ai/plugin.json +0 -0
  245. package/plugins/warp/icon-color.svg +0 -0
  246. package/plugins/warp/icon.svg +0 -0
  247. package/plugins/warp/plugin.js +0 -0
  248. package/plugins/warp/plugin.json +0 -0
  249. package/plugins/wayfinder/icon.svg +5 -0
  250. package/plugins/wayfinder/plugin.js +47 -0
  251. package/plugins/wayfinder/plugin.json +16 -0
  252. package/plugins/windsurf/icon-conflict.svg +0 -0
  253. package/plugins/windsurf/icon.svg +0 -0
  254. package/plugins/windsurf/plugin.js +0 -0
  255. package/plugins/windsurf/plugin.json +0 -0
  256. package/plugins/xai/icon.svg +7 -0
  257. package/plugins/xai/plugin.js +162 -0
  258. package/plugins/xai/plugin.json +28 -0
  259. package/plugins/zai/icon-conflict.svg +0 -0
  260. package/plugins/zai/icon.svg +0 -0
  261. package/plugins/zai/plugin.js +111 -161
  262. package/plugins/zai/plugin.json +4 -1
  263. package/plugins/zed/icon.svg +0 -0
  264. package/plugins/zed/plugin.js +0 -0
  265. package/plugins/zed/plugin.json +0 -0
  266. package/plugins/zenmux/icon.svg +3 -0
  267. package/plugins/zenmux/plugin.js +102 -0
  268. package/plugins/zenmux/plugin.json +23 -0
  269. package/plugins/zoommate/icon.svg +1 -0
  270. package/plugins/zoommate/plugin.js +244 -0
  271. package/plugins/zoommate/plugin.json +29 -0
  272. package/usagestat +0 -0
  273. package/usagestatd +0 -0
@@ -0,0 +1,182 @@
1
+ (function () {
2
+ var HOST = "https://longcat.chat";
3
+ var USER_CURRENT = "/api/v1/user-current";
4
+ var TOKEN_USAGE = "/api/lc-platform/v1/tokenUsage";
5
+ var PENDING_FUEL = "/api/lc-platform/v1/pending-fuel-packages";
6
+ var TOKEN_PACKS_SUMMARY = "/api/pay/quota/metering/token-packs/summary";
7
+
8
+ function trim(value) {
9
+ return typeof value === "string" && value.trim() ? value.trim() : null;
10
+ }
11
+
12
+ function env(ctx, name) {
13
+ try {
14
+ return trim(ctx.host.env.get(name));
15
+ } catch (_) {
16
+ return null;
17
+ }
18
+ }
19
+
20
+ function setting(ctx, names) {
21
+ var settings = ctx.provider && ctx.provider.settings ? ctx.provider.settings : {};
22
+ for (var i = 0; i < names.length; i++) {
23
+ var value = trim(settings[names[i]]);
24
+ if (value) return value;
25
+ }
26
+ return null;
27
+ }
28
+
29
+ function normalizeCookie(raw) {
30
+ var header = trim(raw);
31
+ if (!header) return null;
32
+ if (header.slice(0, 7).toLowerCase() === "cookie:") header = header.slice(7).trim();
33
+ return header.indexOf("=") >= 0 ? header : null;
34
+ }
35
+
36
+ function cookieHeader(ctx) {
37
+ return normalizeCookie(ctx.provider && ctx.provider.cookieHeader) ||
38
+ normalizeCookie(setting(ctx, ["cookieHeader", "cookie"])) ||
39
+ normalizeCookie(env(ctx, "LONGCAT_COOKIE"));
40
+ }
41
+
42
+ function requestJson(ctx, method, path, cookie, optional) {
43
+ var result = ctx.util.requestJson({
44
+ method: method,
45
+ url: HOST + path,
46
+ headers: {
47
+ Cookie: cookie,
48
+ Accept: "application/json",
49
+ "Content-Type": method === "POST" ? "application/json" : undefined,
50
+ },
51
+ bodyText: method === "POST" ? "{}" : undefined,
52
+ timeoutMs: optional ? 2000 : 10000,
53
+ });
54
+ if (ctx.util.isAuthStatus(result.resp.status)) throw "LongCat session expired.";
55
+ if (result.resp.status < 200 || result.resp.status >= 300) {
56
+ if (optional) return null;
57
+ throw "LongCat API " + path + " returned HTTP " + result.resp.status + ".";
58
+ }
59
+ if (!result.json || typeof result.json !== "object") {
60
+ if (optional) return null;
61
+ throw "Failed to parse LongCat " + path + ".";
62
+ }
63
+ var code = result.json.code != null ? Number(result.json.code) : result.json.status != null ? Number(result.json.status) : null;
64
+ if (code === 401 || code === 403) throw "LongCat session expired.";
65
+ return result.json;
66
+ }
67
+
68
+ function data(value) {
69
+ return value && value.data && typeof value.data === "object" ? value.data : value;
70
+ }
71
+
72
+ function number(obj, key) {
73
+ if (!obj || typeof obj !== "object") return null;
74
+ var value = obj[key];
75
+ if (typeof value === "number" && Number.isFinite(value)) return value;
76
+ if (typeof value === "string" && value.trim()) {
77
+ var parsed = Number(value.replace(/,/g, ""));
78
+ if (Number.isFinite(parsed)) return parsed;
79
+ }
80
+ return null;
81
+ }
82
+
83
+ function string(obj, key) {
84
+ var value = obj && obj[key];
85
+ return typeof value === "string" && value.trim() ? value.trim() : null;
86
+ }
87
+
88
+ function activeLot(summary) {
89
+ var lot = data(summary);
90
+ lot = lot && lot.currentLot;
91
+ if (!lot || typeof lot !== "object") return null;
92
+ if (String(string(lot, "status") || "").toUpperCase() !== "ACTIVE") return null;
93
+ var total = number(lot, "totalToken");
94
+ return total && total > 0 ? lot : null;
95
+ }
96
+
97
+ function parseFuel(ctx, fuel) {
98
+ var root = data(fuel);
99
+ var packages = root && Array.isArray(root.packages) ? root.packages : Array.isArray(root) ? root : null;
100
+ if (!packages) return null;
101
+ var total = 0;
102
+ var remaining = 0;
103
+ var sawRemaining = false;
104
+ var nearest = null;
105
+ for (var i = 0; i < packages.length; i++) {
106
+ var pkg = packages[i] || {};
107
+ var capacity = number(pkg, "totalToken");
108
+ if (capacity === null) capacity = number(pkg, "total");
109
+ if (capacity === null) capacity = number(pkg, "amount");
110
+ var rem = number(pkg, "availableToken");
111
+ if (rem === null) rem = number(pkg, "remainingToken");
112
+ if (rem === null) rem = number(pkg, "remaining");
113
+ if (capacity === null || capacity < 0 || rem === null || rem < 0) return null;
114
+ total += capacity;
115
+ remaining += rem;
116
+ sawRemaining = true;
117
+ var raw = string(pkg, "expireTime") || string(pkg, "expireAt") || string(pkg, "expiresAt");
118
+ var iso = raw ? ctx.util.toIso(raw) : null;
119
+ if (iso && (!nearest || iso < nearest)) nearest = iso;
120
+ }
121
+ if (total <= 0 && !sawRemaining) return null;
122
+ if (total <= 0) total = remaining;
123
+ if (!sawRemaining) remaining = total;
124
+ return { total: total, remaining: remaining, resetsAt: nearest };
125
+ }
126
+
127
+ function progress(ctx, label, used, total, detail, reset) {
128
+ var opts = {
129
+ label: label,
130
+ used: total > 0 ? Math.max(0, Math.min(100, used / total * 100)) : 0,
131
+ limit: 100,
132
+ format: { kind: "percent" },
133
+ detail: detail,
134
+ };
135
+ if (reset) opts.resetsAt = reset;
136
+ return ctx.line.progress(opts);
137
+ }
138
+
139
+ function accountName(account) {
140
+ var root = data(account);
141
+ return string(root, "name") || string(root, "nickname") || string(root, "userName");
142
+ }
143
+
144
+ function probe(ctx) {
145
+ var cookie = cookieHeader(ctx);
146
+ if (!cookie) throw "LongCat session not configured. Set LONGCAT_COOKIE or provider cookieHeader.";
147
+ var account = requestJson(ctx, "GET", USER_CURRENT, cookie, false);
148
+ var tokenPacks = requestJson(ctx, "POST", TOKEN_PACKS_SUMMARY, cookie, true);
149
+ var lot = tokenPacks ? activeLot(tokenPacks) : null;
150
+ var total;
151
+ var used;
152
+ var usage;
153
+ if (lot) {
154
+ total = number(lot, "totalToken");
155
+ used = number(lot, "consumedToken");
156
+ if (used === null || used < 0) throw "LongCat token pack was missing consumedToken.";
157
+ } else {
158
+ usage = data(requestJson(ctx, "GET", TOKEN_USAGE, cookie, false));
159
+ var usageObj = usage && usage.usage && typeof usage.usage === "object" ? usage.usage : usage;
160
+ total = number(usageObj, "totalToken");
161
+ var remaining = number(usageObj, "availableToken");
162
+ if (total === null || total <= 0 || remaining === null || remaining < 0) throw "LongCat tokenUsage data was missing usable totalToken or availableToken.";
163
+ used = Math.max(0, total - remaining);
164
+ }
165
+ var lines = [progress(ctx, "Quota", used, total, Math.round(used) + "/" + Math.round(total) + " tokens", null)];
166
+ var fuel = requestJson(ctx, "GET", PENDING_FUEL, cookie, true);
167
+ var fuelTotals = fuel ? parseFuel(ctx, fuel) : null;
168
+ if (fuelTotals && fuelTotals.total > 0) {
169
+ lines.push(progress(
170
+ ctx,
171
+ "Fuel Pack",
172
+ Math.max(0, fuelTotals.total - fuelTotals.remaining),
173
+ fuelTotals.total,
174
+ "Fuel pack: " + Math.round(fuelTotals.remaining) + "/" + Math.round(fuelTotals.total),
175
+ fuelTotals.resetsAt
176
+ ));
177
+ }
178
+ return { displayName: "LongCat", source: "web", plan: accountName(account), lines: lines };
179
+ }
180
+
181
+ globalThis.__openusage_plugin = { id: "longcat", probe: probe };
182
+ })();
@@ -0,0 +1,23 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "longcat",
4
+ "name": "LongCat",
5
+ "version": "0.1.0",
6
+ "entry": "plugin.js",
7
+ "enabledByDefault": false,
8
+ "supportedModes": [
9
+ "web"
10
+ ],
11
+ "autoMode": "web",
12
+ "webUrl": "https://longcat.chat",
13
+ "usageDashboardUrl": "https://longcat.chat/platform/",
14
+ "links": [
15
+ {
16
+ "label": "Dashboard",
17
+ "url": "https://longcat.chat/platform/"
18
+ }
19
+ ],
20
+ "envVars": [
21
+ "LONGCAT_COOKIE"
22
+ ]
23
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,10 +1,11 @@
1
1
  (function () {
2
- const GLOBAL_PRIMARY_USAGE_URL = "https://www.minimax.io/v1/token_plan/remains"
2
+ const GLOBAL_PRIMARY_USAGE_URL = "https://platform.minimax.io/v1/api/openplatform/coding_plan/remains"
3
3
  const GLOBAL_FALLBACK_USAGE_URLS = [
4
+ "https://www.minimax.io/v1/api/openplatform/coding_plan/remains",
4
5
  "https://www.minimax.io/v1/token_plan/remains",
5
6
  ]
6
- const CN_PRIMARY_USAGE_URL = "https://api.minimaxi.com/v1/token_plan/remains"
7
- const CN_FALLBACK_USAGE_URLS = ["https://api.minimaxi.com/v1/token_plan/remains"]
7
+ const CN_PRIMARY_USAGE_URL = "https://platform.minimaxi.com/v1/api/openplatform/coding_plan/remains"
8
+ const CN_FALLBACK_USAGE_URLS = ["https://www.minimaxi.com/v1/api/openplatform/coding_plan/remains", "https://api.minimaxi.com/v1/token_plan/remains"]
8
9
  const GLOBAL_API_KEY_ENV_VARS = ["MINIMAX_API_KEY", "MINIMAX_API_TOKEN"]
9
10
  const CN_API_KEY_ENV_VARS = ["MINIMAX_CN_API_KEY", "MINIMAX_API_KEY", "MINIMAX_API_TOKEN"]
10
11
  const CODING_PLAN_WINDOW_MS = 5 * 60 * 60 * 1000
@@ -112,6 +113,8 @@
112
113
  }
113
114
 
114
115
  function loadApiKey(ctx, endpointSelection) {
116
+ const configured = readString(ctx.provider && ctx.provider.apiKey)
117
+ if (configured) return { value: configured, source: "configuration" }
115
118
  const envVars = endpointSelection === "CN" ? CN_API_KEY_ENV_VARS : GLOBAL_API_KEY_ENV_VARS
116
119
  for (let i = 0; i < envVars.length; i += 1) {
117
120
  const name = envVars[i]
@@ -138,15 +141,21 @@
138
141
  }
139
142
 
140
143
  function endpointAttempts(ctx) {
141
- // AUTO: if CN key exists, try CN first; otherwise try GLOBAL first.
144
+ const region = readString(ctx.provider && ctx.provider.region)
145
+ if (region) {
146
+ if (/^(cn|china)$/i.test(region)) return ["CN"]
147
+ if (/^(global|international)$/i.test(region)) return ["GLOBAL"]
148
+ throw "MiniMax region must be global or cn."
149
+ }
150
+ // Keep credentials within the selected region, including failed requests.
142
151
  let cnApiKeyValue = null
143
152
  try {
144
153
  cnApiKeyValue = ctx.host.env.get("MINIMAX_CN_API_KEY")
145
154
  } catch (e) {
146
155
  ctx.host.log.warn("env read failed for MINIMAX_CN_API_KEY: " + String(e))
147
156
  }
148
- if (readString(cnApiKeyValue)) return ["CN", "GLOBAL"]
149
- return ["GLOBAL", "CN"]
157
+ if (readString(cnApiKeyValue)) return ["CN"]
158
+ return ["GLOBAL"]
150
159
  }
151
160
 
152
161
  function formatAuthError() {
@@ -158,11 +167,7 @@
158
167
  * @returns {object} parsed JSON response
159
168
  * @throws {string} error message
160
169
  */
161
- function tryUrls(ctx, urls, apiKey) {
162
- let lastStatus = null
163
- let hadNetworkError = false
164
- let authStatusCount = 0
165
-
170
+ function tryUrls(ctx, urls, apiKey, endpointSelection) {
166
171
  for (let i = 0; i < urls.length; i += 1) {
167
172
  const url = urls[i]
168
173
  let resp
@@ -178,20 +183,15 @@
178
183
  timeoutMs: 15000,
179
184
  })
180
185
  } catch (e) {
181
- hadNetworkError = true
182
- ctx.host.log.warn("request failed (" + url + "): " + String(e))
183
- continue
186
+ throw "MiniMax request failed. Check your connection."
184
187
  }
185
188
 
186
189
  if (ctx.util.isAuthStatus(resp.status)) {
187
- authStatusCount += 1
188
- ctx.host.log.warn("request returned auth status " + resp.status + " (" + url + ")")
189
- continue
190
+ throw formatAuthError()
190
191
  }
192
+ if (resp.status === 404 || resp.status === 405) continue
191
193
  if (resp.status < 200 || resp.status >= 300) {
192
- lastStatus = resp.status
193
- ctx.host.log.warn("request returned status " + resp.status + " (" + url + ")")
194
- continue
194
+ throw "MiniMax request failed (HTTP " + resp.status + "). Try again later."
195
195
  }
196
196
 
197
197
  const parsed = ctx.util.tryParseJson(resp.bodyText)
@@ -200,14 +200,9 @@
200
200
  continue
201
201
  }
202
202
 
203
- return parsed
204
- }
205
-
206
- if (authStatusCount > 0 && lastStatus === null && !hadNetworkError) {
207
- throw formatAuthError()
203
+ const usage = parsePayloadShape(ctx, parsed, endpointSelection)
204
+ if (usage) return usage
208
205
  }
209
- if (lastStatus !== null) throw "Request failed (HTTP " + lastStatus + "). Try again later."
210
- if (hadNetworkError) throw "Request failed. Check your connection."
211
206
  throw "Could not parse usage data."
212
207
  }
213
208
 
@@ -393,7 +388,7 @@
393
388
  }
394
389
 
395
390
  function fetchUsagePayload(ctx, apiKey, endpointSelection) {
396
- return tryUrls(ctx, getUsageUrls(endpointSelection), apiKey)
391
+ return tryUrls(ctx, getUsageUrls(endpointSelection), apiKey, endpointSelection)
397
392
  }
398
393
 
399
394
  function probe(ctx) {
@@ -407,8 +402,7 @@
407
402
  const apiKeyInfo = loadApiKey(ctx, endpoint)
408
403
  if (!apiKeyInfo) continue
409
404
  try {
410
- const payload = fetchUsagePayload(ctx, apiKeyInfo.value, endpoint)
411
- parsed = parsePayloadShape(ctx, payload, endpoint)
405
+ parsed = fetchUsagePayload(ctx, apiKeyInfo.value, endpoint)
412
406
  if (parsed) {
413
407
  successfulEndpoint = endpoint
414
408
  break
@@ -441,7 +435,7 @@
441
435
  if (parsed.resetsAt) line.resetsAt = parsed.resetsAt
442
436
  if (parsed.periodDurationMs !== null) line.periodDurationMs = parsed.periodDurationMs
443
437
 
444
- const result = { lines: [ctx.line.progress(line)] }
438
+ const result = { source: "api", lines: [ctx.line.progress(line)] }
445
439
  if (parsed.planName) {
446
440
  const regionLabel = successfulEndpoint === "CN" ? " (CN)" : " (GLOBAL)"
447
441
  result.plan = parsed.planName + regionLabel
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,10 +1,10 @@
1
1
  (function () {
2
2
  function apiKey(ctx) {
3
- return ctx.host.env.get("MOONSHOT_API_KEY") || ctx.host.env.get("MOONSHOT_KEY");
3
+ return (ctx.provider && ctx.provider.apiKey) || ctx.host.env.get("MOONSHOT_API_KEY") || ctx.host.env.get("MOONSHOT_KEY");
4
4
  }
5
5
 
6
6
  function baseUrl(ctx) {
7
- var region = String(ctx.host.env.get("MOONSHOT_REGION") || "").toLowerCase();
7
+ var region = String((ctx.provider && ctx.provider.region) || ctx.host.env.get("MOONSHOT_REGION") || "").toLowerCase();
8
8
  var explicit = ctx.host.env.get("MOONSHOT_API_URL");
9
9
  if (explicit) return explicit.replace(/\/$/, "");
10
10
  return region === "cn" || region === "china" ? "https://api.moonshot.cn" : "https://api.moonshot.ai";
@@ -13,8 +13,8 @@
13
13
  function pick(obj, names) {
14
14
  for (var i = 0; i < names.length; i++) {
15
15
  var v = obj && obj[names[i]];
16
- if (typeof v === "number") return v;
17
- if (typeof v === "string" && v.trim() !== "" && !isNaN(Number(v))) return Number(v);
16
+ if (typeof v === "number" && Number.isFinite(v)) return v;
17
+ if (typeof v === "string" && v.trim() !== "" && Number.isFinite(Number(v))) return Number(v);
18
18
  }
19
19
  return null;
20
20
  }
@@ -23,9 +23,10 @@
23
23
  var key = apiKey(ctx);
24
24
  if (!key) throw "Moonshot API key not found. Set MOONSHOT_API_KEY or MOONSHOT_KEY.";
25
25
 
26
+ var base = baseUrl(ctx);
26
27
  var result = ctx.util.requestJson({
27
28
  method: "GET",
28
- url: baseUrl(ctx) + "/v1/users/me/balance",
29
+ url: base + "/v1/users/me/balance",
29
30
  headers: { Authorization: "Bearer " + key, Accept: "application/json" },
30
31
  timeoutMs: 15000,
31
32
  });
@@ -36,7 +37,8 @@
36
37
  var data = json.data || json;
37
38
  var available = pick(data, ["available_balance", "availableBalance", "balance", "cash_balance"]);
38
39
  if (available === null) throw "Moonshot response did not include a recognizable balance.";
39
- return { lines: [ctx.line.text({ label: "Balance", value: String(available) })] };
40
+ var currency = /^https:\/\/api\.moonshot\.cn(?::443)?(?:\/|$)/i.test(base) ? "CNY" : "USD";
41
+ return { source: "api", lines: [ctx.line.text({ label: "Balance", value: currency + " " + available.toFixed(2) })] };
40
42
  }
41
43
 
42
44
  globalThis.__openusage_plugin = { id: "moonshot", probe: probe };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ <svg fill="currentColor" fill-rule="evenodd" height="512" style="flex:none;line-height:1" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><title>Notion</title><path clip-rule="evenodd" d="M15.257.055l-13.31.98C.874 1.128.5 1.83.5 2.667v14.559c0 .654.233 1.213.794 1.96l3.129 4.06c.513.653.98.794 1.962.745l15.457-.932c1.307-.093 1.681-.7 1.681-1.727V4.954c0-.53-.21-.684-.829-1.135l-.106-.078L18.34.755c-1.027-.746-1.45-.84-3.083-.7zm-8.521 4.63c-1.263.086-1.549.105-2.266-.477L2.647 2.76c-.186-.187-.092-.42.375-.466l12.796-.933c1.074-.094 1.634.28 2.054.606l2.195 1.587c.093.047.326.326.047.326l-13.216.794-.162.01zM5.263 21.193V7.287c0-.606.187-.886.748-.933l15.176-.886c.515-.047.748.28.748.886v13.81c0 .609-.093 1.122-.934 1.168l-14.523.84c-.842.047-1.215-.232-1.215-.98zm14.338-13.16c.093.422 0 .842-.422.89l-.699.139v10.264c-.608.327-1.168.513-1.635.513-.747 0-.934-.232-1.495-.932l-4.576-7.185v6.952l1.448.327s0 .84-1.169.84l-3.221.186c-.094-.187 0-.654.327-.747l.84-.232V9.853L7.832 9.76c-.093-.42.14-1.026.794-1.073l3.456-.232 4.763 7.279v-6.44l-1.214-.14c-.094-.513.28-.887.747-.933l3.223-.187z"></path></svg>