@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.
- package/native-manifest.json +873 -141
- package/package.json +124 -2
- package/plugins/abliteration/LICENSE +21 -0
- package/plugins/abliteration/icon.svg +5 -0
- package/plugins/abliteration/plugin.js +89 -0
- package/plugins/abliteration/plugin.json +24 -0
- package/plugins/aerostack/LICENSE +21 -0
- package/plugins/aerostack/icon.svg +1 -0
- package/plugins/aerostack/plugin.js +94 -0
- package/plugins/aerostack/plugin.json +24 -0
- package/plugins/aixy/icon.svg +1 -0
- package/plugins/aixy/plugin.js +5 -0
- package/plugins/aixy/plugin.json +9 -1
- package/plugins/antigravity/plugin.js +60 -26
- package/plugins/antigravity-cli/plugin.js +21 -5
- package/plugins/antigravity-ide/plugin.js +19 -7
- package/plugins/atlascloud/plugin.js +5 -0
- package/plugins/atlascloud/plugin.json +2 -1
- package/plugins/bifrost/icon.svg +3 -0
- package/plugins/bifrost/plugin.js +5 -0
- package/plugins/bifrost/plugin.json +9 -1
- package/plugins/chatbox/LICENSE +21 -0
- package/plugins/chatbox/icon.svg +4 -0
- package/plugins/chatbox/plugin.js +208 -0
- package/plugins/chatbox/plugin.json +24 -0
- package/plugins/claude/plugin.js +39 -2
- package/plugins/claudeplatform/LICENSE +21 -0
- package/plugins/claudeplatform/icon.svg +3 -0
- package/plugins/claudeplatform/plugin.js +244 -0
- package/plugins/claudeplatform/plugin.json +25 -0
- package/plugins/codex/plugin.js +14 -8
- package/plugins/codex/plugin.json +11 -2
- package/plugins/copilot/plugin.json +1 -0
- package/plugins/cosmic/LICENSE +21 -0
- package/plugins/cosmic/icon.svg +1 -0
- package/plugins/cosmic/plugin.js +134 -0
- package/plugins/cosmic/plugin.json +32 -0
- package/plugins/cursor/plugin.js +51 -14
- package/plugins/cursor-nightly/plugin.json +1 -1
- package/plugins/devpass/icon.svg +3 -0
- package/plugins/devpass/plugin.js +5 -0
- package/plugins/devpass/plugin.json +2 -1
- package/plugins/exa/LICENSE +21 -0
- package/plugins/exa/icon-color.svg +1 -0
- package/plugins/exa/icon.svg +1 -0
- package/plugins/exa/plugin.js +75 -0
- package/plugins/exa/plugin.json +32 -0
- package/plugins/fal/LICENSE +21 -0
- package/plugins/fal/icon-color.svg +1 -0
- package/plugins/fal/icon.svg +1 -0
- package/plugins/fal/plugin.js +74 -0
- package/plugins/fal/plugin.json +24 -0
- package/plugins/flora/LICENSE +21 -0
- package/plugins/flora/icon.svg +4 -0
- package/plugins/flora/plugin.js +93 -0
- package/plugins/flora/plugin.json +32 -0
- package/plugins/futureagi/LICENSE +21 -0
- package/plugins/futureagi/icon.svg +24 -0
- package/plugins/futureagi/plugin.js +139 -0
- package/plugins/futureagi/plugin.json +32 -0
- package/plugins/gemini-apps/LICENSE +1 -2
- package/plugins/gemini-apps/plugin.js +136 -465
- package/plugins/gemini-apps/plugin.json +13 -7
- package/plugins/gitkraken/icon.svg +2 -0
- package/plugins/gitkraken/plugin.js +5 -0
- package/plugins/gitkraken/plugin.json +9 -1
- package/plugins/googledeveloper/LICENSE +21 -0
- package/plugins/googledeveloper/icon.svg +3 -0
- package/plugins/googledeveloper/plugin.js +204 -0
- package/plugins/googledeveloper/plugin.json +25 -0
- package/plugins/helmcode/icon.svg +5 -0
- package/plugins/helmcode/plugin.js +121 -56
- package/plugins/helmcode/plugin.json +10 -2
- package/plugins/huggingface/plugin.js +6 -1
- package/plugins/huggingface/plugin.json +4 -3
- package/plugins/hyper/plugin.js +53 -47
- package/plugins/hyper/plugin.json +3 -2
- package/plugins/jetbrains-ai-assistant/LICENSE +22 -0
- package/plugins/jetbrains-ai-assistant/plugin.js +502 -16
- package/plugins/jetbrains-ai-assistant/plugin.json +27 -4
- package/plugins/kimi/plugin.js +54 -14
- package/plugins/kimi/plugin.json +46 -6
- package/plugins/langdock/LICENSE +21 -0
- package/plugins/langdock/icon.svg +4 -0
- package/plugins/langdock/plugin.js +106 -0
- package/plugins/langdock/plugin.json +25 -0
- package/plugins/linkup/LICENSE +21 -0
- package/plugins/linkup/icon.svg +10 -0
- package/plugins/linkup/plugin.js +46 -0
- package/plugins/linkup/plugin.json +24 -0
- package/plugins/lithosai/LICENSE +21 -0
- package/plugins/lithosai/icon.svg +1 -0
- package/plugins/lithosai/plugin.js +130 -0
- package/plugins/lithosai/plugin.json +26 -0
- package/plugins/llmman/icon.svg +4 -0
- package/plugins/llmman/plugin.js +5 -0
- package/plugins/llmman/plugin.json +9 -1
- package/plugins/mistral/plugin.js +54 -22
- package/plugins/munito/LICENSE +21 -0
- package/plugins/munito/icon.svg +7 -0
- package/plugins/munito/plugin.js +171 -0
- package/plugins/munito/plugin.json +24 -0
- package/plugins/muse/icon.svg +3 -0
- package/plugins/muse/plugin.js +98 -129
- package/plugins/muse/plugin.json +10 -2
- package/plugins/museai/LICENSE +21 -0
- package/plugins/museai/icon.svg +3 -0
- package/plugins/museai/plugin.js +161 -0
- package/plugins/museai/plugin.json +26 -0
- package/plugins/nous/plugin.js +5 -0
- package/plugins/nous/plugin.json +9 -1
- package/plugins/ollama/plugin.js +58 -0
- package/plugins/opencode-go/plugin.js +74 -25
- package/plugins/opendesign/LICENSE +21 -0
- package/plugins/opendesign/icon.svg +4 -0
- package/plugins/opendesign/plugin.js +108 -0
- package/plugins/opendesign/plugin.json +25 -0
- package/plugins/parallel/LICENSE +21 -0
- package/plugins/parallel/icon.svg +11 -0
- package/plugins/parallel/plugin.js +97 -0
- package/plugins/parallel/plugin.json +25 -0
- package/plugins/perplexity/LICENSE +22 -0
- package/plugins/perplexity/plugin.js +122 -0
- package/plugins/perplexity/plugin.json +36 -7
- package/plugins/qwencloud/LICENSE +21 -0
- package/plugins/qwencloud/plugin.js +197 -0
- package/plugins/qwencloud/plugin.json +17 -0
- package/plugins/raycast/icon.svg +4 -0
- package/plugins/raycast/plugin.js +6 -1
- package/plugins/raycast/plugin.json +10 -2
- package/plugins/replicate/plugin.js +5 -0
- package/plugins/replicate/plugin.json +2 -1
- package/plugins/sailresearch/LICENSE +21 -0
- package/plugins/sailresearch/icon.svg +4 -0
- package/plugins/sailresearch/plugin.js +104 -0
- package/plugins/sailresearch/plugin.json +24 -0
- package/plugins/siliconflow/LICENSE +21 -0
- package/plugins/siliconflow/icon.svg +3 -0
- package/plugins/siliconflow/plugin.js +87 -0
- package/plugins/siliconflow/plugin.json +32 -0
- package/plugins/sofya/LICENSE +21 -0
- package/plugins/sofya/icon.svg +3 -0
- package/plugins/sofya/plugin.js +86 -0
- package/plugins/sofya/plugin.json +24 -0
- package/plugins/soniox/LICENSE +21 -0
- package/plugins/soniox/icon.svg +3 -0
- package/plugins/soniox/plugin.js +103 -0
- package/plugins/soniox/plugin.json +24 -0
- package/plugins/synthetic/plugin.js +12 -0
- package/plugins/synthetic/plugin.json +51 -9
- package/plugins/tavily/LICENSE +21 -0
- package/plugins/tavily/icon.svg +3 -0
- package/plugins/tavily/plugin.js +61 -0
- package/plugins/tavily/plugin.json +24 -0
- package/plugins/tinyapi/LICENSE +21 -0
- package/plugins/tinyapi/icon.svg +4 -0
- package/plugins/tinyapi/plugin.js +73 -0
- package/plugins/tinyapi/plugin.json +25 -0
- package/plugins/traecn/LICENSE +21 -0
- package/plugins/traecn/icon.svg +3 -0
- package/plugins/traecn/plugin.js +103 -0
- package/plugins/traecn/plugin.json +25 -0
- package/plugins/tripo/LICENSE +21 -0
- package/plugins/tripo/icon.svg +4 -0
- package/plugins/tripo/plugin.js +60 -0
- package/plugins/tripo/plugin.json +24 -0
- package/plugins/typesafe/icon.svg +4 -0
- package/plugins/typesafe/plugin.js +85 -129
- package/plugins/typesafe/plugin.json +3 -2
- package/plugins/v0/plugin.js +5 -0
- package/plugins/v0/plugin.json +9 -1
- package/plugins/vercel/plugin.js +147 -0
- package/plugins/vercel/plugin.json +34 -3
- package/plugins/workbuddy/LICENSE +21 -0
- package/plugins/workbuddy/icon.svg +1 -0
- package/plugins/workbuddy/plugin.js +318 -0
- package/plugins/workbuddy/plugin.json +63 -0
- package/plugins/xai/plugin.js +9 -0
- package/plugins/xapi/LICENSE +21 -0
- package/plugins/xapi/icon.svg +1 -0
- package/plugins/xapi/plugin.js +90 -0
- package/plugins/xapi/plugin.json +25 -0
- package/plugins/xkiro/icon.svg +1 -0
- package/plugins/xkiro/plugin.js +5 -0
- package/plugins/xkiro/plugin.json +2 -1
- package/plugins/zai/plugin.js +5 -1
- package/usagestat +0 -0
- package/usagestatd +0 -0
- package/plugins/cursor-nightly/plugin.js +0 -1416
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
|
|
2
|
+
globalThis.__usagestat_bundled_options = {"labels":["Plan","Top-up credits","Additional"],"defaults":{},"autoMode":"api"};
|
|
3
|
+
(function(defineProvider) {
|
|
4
|
+
// BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/chatbox.js
|
|
5
|
+
function _nullishCoalesce(lhs, rhsFn) {
|
|
6
|
+
if (lhs != null) {
|
|
7
|
+
return lhs;
|
|
8
|
+
} else {
|
|
9
|
+
return rhsFn();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function _optionalChain(ops) {
|
|
13
|
+
let lastAccessLHS = undefined;
|
|
14
|
+
let value = ops[0];
|
|
15
|
+
let i = 1;
|
|
16
|
+
while (i < ops.length) {
|
|
17
|
+
const op = ops[i];
|
|
18
|
+
const fn = ops[i + 1];
|
|
19
|
+
i += 2;
|
|
20
|
+
if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
if (op === "access" || op === "optionalAccess") {
|
|
24
|
+
lastAccessLHS = value;
|
|
25
|
+
value = fn(value);
|
|
26
|
+
} else if (op === "call" || op === "optionalCall") {
|
|
27
|
+
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
28
|
+
lastAccessLHS = undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
defineProvider({
|
|
34
|
+
id: "chatbox",
|
|
35
|
+
name: "Chatbox AI",
|
|
36
|
+
endpoints: ["https://api.chatboxai.app"],
|
|
37
|
+
auth: { type: "header", header: "Authorization", secret: "CHATBOX_LICENSE_KEY" },
|
|
38
|
+
settings: [
|
|
39
|
+
{ key: "CHATBOX_LICENSE_KEY", title: "API key", type: "secure" },
|
|
40
|
+
{ key: "MESSAGES", title: "Chatbox AI", type: "plain" },
|
|
41
|
+
],
|
|
42
|
+
capabilities: ["http-status"],
|
|
43
|
+
async fetchUsage(ctx) {
|
|
44
|
+
const messages = JSON.parse(ctx.settings.get("MESSAGES") || "{}");
|
|
45
|
+
const message = (key, status) => (messages[key] || key) + (status === undefined ? "" : ` (HTTP ${status})`);
|
|
46
|
+
const key = ctx.settings.getSecret("CHATBOX_LICENSE_KEY");
|
|
47
|
+
if (
|
|
48
|
+
!key ||
|
|
49
|
+
key.length > 4096 ||
|
|
50
|
+
/\s/u.test(key) ||
|
|
51
|
+
Array.from(key).some((character) => {
|
|
52
|
+
const code = character.charCodeAt(0);
|
|
53
|
+
return code < 32 || (code >= 127 && code <= 159);
|
|
54
|
+
})
|
|
55
|
+
) {
|
|
56
|
+
throw ctx.fail.authenticationExpired(message("Chatbox AI license key is invalid. Update it in Settings."));
|
|
57
|
+
}
|
|
58
|
+
const response = await ctx.http.get("https://api.chatboxai.app/api/license/detail/realtime", {
|
|
59
|
+
headers: { "Cache-Control": "no-store" },
|
|
60
|
+
});
|
|
61
|
+
const record = (value) => (value && typeof value === "object" && !Array.isArray(value) ? value : undefined);
|
|
62
|
+
const decode = (body) => {
|
|
63
|
+
try {
|
|
64
|
+
return record(JSON.parse(body));
|
|
65
|
+
} catch (error) {
|
|
66
|
+
void error;
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (response.status === 401) {
|
|
71
|
+
throw ctx.fail.authenticationExpired(
|
|
72
|
+
message("Chatbox AI license key is invalid. Update it in Settings.", response.status),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (response.status === 403) {
|
|
76
|
+
throw ctx.fail.permissionDenied(message("Chatbox AI denied access. Check your license.", response.status));
|
|
77
|
+
}
|
|
78
|
+
if (response.status === 429) {
|
|
79
|
+
const delay = Number(_nullishCoalesce(response.headers["retry-after"], () => 1));
|
|
80
|
+
throw ctx.fail.rateLimited(message("Chatbox AI is rate limiting requests. Try again later.", response.status), {
|
|
81
|
+
retryAfterSeconds: Number.isFinite(delay) && delay >= 0 ? Math.min(delay, 10) : 1,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (response.status >= 500) {
|
|
85
|
+
throw ctx.fail.providerUnavailable(message("Chatbox AI request failed. Try refreshing later.", response.status));
|
|
86
|
+
}
|
|
87
|
+
if (response.status !== 200) {
|
|
88
|
+
throw ctx.fail.apiFailure(message("Chatbox AI request failed. Try refreshing later.", response.status));
|
|
89
|
+
}
|
|
90
|
+
const fail = () => {
|
|
91
|
+
throw ctx.fail.parseFailure(
|
|
92
|
+
message("Chatbox AI returned an unrecognized response. Update CodexBar and try again."),
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
const root = decode(response.bodyText);
|
|
96
|
+
const data = record(_optionalChain([root, "optionalAccess", (_) => _.data]));
|
|
97
|
+
if (!data || _optionalChain([root, "optionalAccess", (_2) => _2.error])) return fail();
|
|
98
|
+
const now = ctx.date.now().getTime();
|
|
99
|
+
const text = (value) =>
|
|
100
|
+
typeof value === "string"
|
|
101
|
+
? Array.from(value, (character) => {
|
|
102
|
+
const code = character.charCodeAt(0);
|
|
103
|
+
return code < 32 || code === 127 ? " " : character;
|
|
104
|
+
})
|
|
105
|
+
.join("")
|
|
106
|
+
.trim()
|
|
107
|
+
.slice(0, 100) || undefined
|
|
108
|
+
: undefined;
|
|
109
|
+
const counter = (value) => {
|
|
110
|
+
if (value === undefined || value === null) return undefined;
|
|
111
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : fail();
|
|
112
|
+
};
|
|
113
|
+
const date = (value) => {
|
|
114
|
+
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}T/.test(value)) return undefined;
|
|
115
|
+
const parsed = new Date(value);
|
|
116
|
+
return Number.isFinite(parsed.getTime()) && parsed.getUTCFullYear() >= 1970 ? parsed : undefined;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const pool = (object, usedKey, limitKey) => {
|
|
120
|
+
const used = counter(object[usedKey]);
|
|
121
|
+
const limit = counter(object[limitKey]);
|
|
122
|
+
return used !== undefined && limit !== undefined ? { used, limit } : undefined;
|
|
123
|
+
};
|
|
124
|
+
const rows = [];
|
|
125
|
+
const addPool = (label, value) => {
|
|
126
|
+
if (!value || (value.used === 0 && value.limit === 0)) return;
|
|
127
|
+
const remaining = Math.max(value.limit - value.used, 0);
|
|
128
|
+
rows.push({
|
|
129
|
+
label,
|
|
130
|
+
value: `${ctx.format.number(remaining)} / ${ctx.format.number(value.limit)}`,
|
|
131
|
+
usageValue: value.used,
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
const details = data.unified_token_usage_details;
|
|
135
|
+
let plan;
|
|
136
|
+
let detailRewards;
|
|
137
|
+
if (details !== undefined && details !== null) {
|
|
138
|
+
if (!Array.isArray(details) || details.length > 100) return fail();
|
|
139
|
+
for (const entry of details) {
|
|
140
|
+
const item = record(entry);
|
|
141
|
+
if (!item || typeof item.type !== "string") return fail();
|
|
142
|
+
const value = pool(item, "token_usage", "token_limit");
|
|
143
|
+
if (item.type === "plan") {
|
|
144
|
+
if (plan) return fail();
|
|
145
|
+
plan = value;
|
|
146
|
+
} else if (value) {
|
|
147
|
+
const expires = date(item.expires_at);
|
|
148
|
+
if (expires && expires.getTime() <= now) continue;
|
|
149
|
+
detailRewards = {
|
|
150
|
+
used:
|
|
151
|
+
_nullishCoalesce(_optionalChain([detailRewards, "optionalAccess", (_3) => _3.used]), () => 0) +
|
|
152
|
+
value.used,
|
|
153
|
+
limit:
|
|
154
|
+
_nullishCoalesce(_optionalChain([detailRewards, "optionalAccess", (_4) => _4.limit]), () => 0) +
|
|
155
|
+
value.limit,
|
|
156
|
+
};
|
|
157
|
+
if (!Number.isSafeInteger(detailRewards.used) || !Number.isSafeInteger(detailRewards.limit)) return fail();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const total = pool(data, "unified_token_usage", "unified_token_limit");
|
|
162
|
+
const rewardRecord = record(data.aggregated_reward_details);
|
|
163
|
+
if (data.aggregated_reward_details != null && !rewardRecord) return fail();
|
|
164
|
+
const rewards = rewardRecord ? pool(rewardRecord, "token_usage", "token_limit") : detailRewards;
|
|
165
|
+
const expansion = pool(data, "expansion_pack_usage", "expansion_pack_limit");
|
|
166
|
+
const images = pool(data, "image_used_count", "image_total_quota");
|
|
167
|
+
if (!plan && !total && !rewards && !expansion && !images) return fail();
|
|
168
|
+
addPool("Plan", plan);
|
|
169
|
+
if (!plan) addPool("Quota", total);
|
|
170
|
+
addPool("Credits", rewards);
|
|
171
|
+
addPool("Top-up credits", expansion);
|
|
172
|
+
addPool("Image Generation", images);
|
|
173
|
+
const name = text(data.name);
|
|
174
|
+
const status = text(data.status);
|
|
175
|
+
const expires = _nullishCoalesce(date(data.token_expire_time), () => date(data.expires_at));
|
|
176
|
+
const next = date(data.token_next_refresh_time);
|
|
177
|
+
const usablePlan = (status === undefined || status === "active") && (!expires || expires.getTime() > now);
|
|
178
|
+
// Trial has no positive plan pool. Rewards and image totals do not share the plan's reset schedule.
|
|
179
|
+
const reset =
|
|
180
|
+
usablePlan &&
|
|
181
|
+
plan &&
|
|
182
|
+
plan.limit > 0 &&
|
|
183
|
+
next &&
|
|
184
|
+
next.getTime() > now &&
|
|
185
|
+
(!expires || next.getTime() < expires.getTime())
|
|
186
|
+
? next
|
|
187
|
+
: undefined;
|
|
188
|
+
if (rows.length === 0) rows.push({ label: "Quota", value: "0 / 0", usageValue: 0 });
|
|
189
|
+
return {
|
|
190
|
+
primary:
|
|
191
|
+
usablePlan && plan && plan.limit > 0
|
|
192
|
+
? {
|
|
193
|
+
usedPercent: ctx.pct(plan.used, plan.limit),
|
|
194
|
+
resetsAt: reset,
|
|
195
|
+
}
|
|
196
|
+
: undefined,
|
|
197
|
+
secondary:
|
|
198
|
+
expansion && expansion.limit > 0 ? { usedPercent: ctx.pct(expansion.used, expansion.limit) } : undefined,
|
|
199
|
+
identity: name ? { loginMethod: name } : undefined,
|
|
200
|
+
details: [{ title: "Remaining", rows }],
|
|
201
|
+
subscriptionExpiresAt: expires,
|
|
202
|
+
dataConfidence: "exact",
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// END UPSTREAM
|
|
208
|
+
})(globalThis.defineProvider);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "chatbox",
|
|
4
|
+
"name": "Chatbox AI",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"entry": "plugin.js",
|
|
7
|
+
"enabledByDefault": false,
|
|
8
|
+
"supportedModes": [
|
|
9
|
+
"api"
|
|
10
|
+
],
|
|
11
|
+
"autoMode": "api",
|
|
12
|
+
"usageDashboardUrl": "https://chatboxai.app",
|
|
13
|
+
"envVars": [
|
|
14
|
+
"CHATBOX_LICENSE_KEY"
|
|
15
|
+
],
|
|
16
|
+
"setupFields": [],
|
|
17
|
+
"upstream": {
|
|
18
|
+
"repository": "https://github.com/steipete/CodexBar",
|
|
19
|
+
"revision": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
|
|
20
|
+
"path": "Sources/CodexBarCore/Resources/Plugins/chatbox.js",
|
|
21
|
+
"sha256": "cf0ae84410aa3794635c0df1edf4936ae514a070968a189dc6ef613c5445f957",
|
|
22
|
+
"license": "MIT"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/plugins/claude/plugin.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
// Rate-limit state persisted across probe() calls (module scope survives re-invocations).
|
|
20
20
|
const MIN_USAGE_FETCH_INTERVAL_MS = 5 * 60 * 1000 // never poll more than once per 5 min
|
|
21
21
|
const DEFAULT_RATE_LIMIT_BACKOFF_MS = 5 * 60 * 1000 // fallback when no Retry-After header
|
|
22
|
+
const RESET_GRANTS_CHECK_INTERVAL_MS = 60 * 60 * 1000
|
|
22
23
|
const LIVE_USAGE_CACHE_FILE = "live-usage-cache.json"
|
|
23
24
|
const LIVE_USAGE_CACHE_VERSION = 2
|
|
24
25
|
const LIVE_USAGE_CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1000
|
|
@@ -596,15 +597,19 @@
|
|
|
596
597
|
|
|
597
598
|
function fetchUsage(ctx, accessToken) {
|
|
598
599
|
const oauthConfig = getOauthConfig(ctx)
|
|
600
|
+
const cache = readLiveUsageCache(ctx)
|
|
601
|
+
const now = Date.parse(ctx.nowIso)
|
|
602
|
+
const checkedAt = Number(cache && cache.resetGrantsCheckedAtMs)
|
|
603
|
+
const checkGrants = !Number.isFinite(checkedAt) || checkedAt <= 0 || now < checkedAt || now - checkedAt >= RESET_GRANTS_CHECK_INTERVAL_MS
|
|
599
604
|
let version = "2.1.0"
|
|
600
605
|
try {
|
|
601
606
|
const result = ctx.host.command.run({program: "claude", args: ["--version"], timeoutMs: 3000})
|
|
602
607
|
const match = result.status === 0 && /^\s*(\d+\.\d+\.\d+)(?:\s|$)/.exec(result.stdout || "")
|
|
603
608
|
if (match) version = match[1]
|
|
604
609
|
} catch (_) { /* The OAuth source also works without a local CLI. */ }
|
|
605
|
-
|
|
610
|
+
const response = ctx.util.request({
|
|
606
611
|
method: "GET",
|
|
607
|
-
url: oauthConfig.usageUrl + "?cedar_ember=1&skip_spend=1",
|
|
612
|
+
url: oauthConfig.usageUrl + (checkGrants ? "?cedar_ember=1&skip_spend=1" : ""),
|
|
608
613
|
headers: {
|
|
609
614
|
Authorization: "Bearer " + accessToken.trim(),
|
|
610
615
|
Accept: "application/json",
|
|
@@ -614,6 +619,21 @@
|
|
|
614
619
|
},
|
|
615
620
|
timeoutMs: 10000,
|
|
616
621
|
})
|
|
622
|
+
if (response.status >= 200 && response.status < 300) {
|
|
623
|
+
const data = ctx.util.tryParseJson(response.bodyText)
|
|
624
|
+
if (data && typeof data === "object" && !Array.isArray(data) && !data.error) {
|
|
625
|
+
const validLines=[]
|
|
626
|
+
addUsageWindowLines(ctx,data,validLines)
|
|
627
|
+
if (!validLines.length) return response
|
|
628
|
+
if (checkGrants || data.cedar_ember) {
|
|
629
|
+
writeLiveUsageCache(ctx, {resetGrantsCheckedAtMs:now,resetGrantsBlock: data.cedar_ember || null})
|
|
630
|
+
} else if (cache && cache.resetGrantsBlock) {
|
|
631
|
+
data.cedar_ember = cache.resetGrantsBlock
|
|
632
|
+
response.bodyText = JSON.stringify(data)
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return response
|
|
617
637
|
}
|
|
618
638
|
|
|
619
639
|
function parseRetryAfterSeconds(headers) {
|
|
@@ -1520,6 +1540,23 @@
|
|
|
1520
1540
|
subtitle: expiries.length ? "Expires " + expiries.sort().join(", ") : undefined}))
|
|
1521
1541
|
}
|
|
1522
1542
|
|
|
1543
|
+
const cloud = data.iguana_necktie
|
|
1544
|
+
if (cloud && typeof cloud === 'object' && !Array.isArray(cloud)) {
|
|
1545
|
+
const limit = cloud.limit_dollars, used = cloud.used_dollars
|
|
1546
|
+
const remaining = cloud.remaining_dollars != null ? cloud.remaining_dollars
|
|
1547
|
+
: typeof used === 'number' ? limit - used : null
|
|
1548
|
+
const validMoney = value => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= limit
|
|
1549
|
+
const expires = cloud.resets_at == null ? null : ctx.util.toIso(cloud.resets_at)
|
|
1550
|
+
if (typeof limit === 'number' && Number.isFinite(limit) && limit > 0 && validMoney(remaining) &&
|
|
1551
|
+
(used == null || validMoney(used)) && (cloud.resets_at == null || expires) &&
|
|
1552
|
+
(cloud.locked_reason == null || typeof cloud.locked_reason === 'string')) {
|
|
1553
|
+
const expired = expires && Date.parse(expires) <= Date.parse(ctx.nowIso)
|
|
1554
|
+
const locked = typeof cloud.locked_reason === 'string' && cloud.locked_reason.trim()
|
|
1555
|
+
lines.push(ctx.line.text({label:'Cloud credits',value:expired ? 'Expired' : locked ? 'Unavailable' : '$'+remaining.toFixed(2)+' remaining',
|
|
1556
|
+
subtitle:expires ? (expired ? 'Expired ' : 'Expires ')+expires : undefined}))
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1523
1560
|
if (data.extra_usage && data.extra_usage.is_enabled) {
|
|
1524
1561
|
const used = moneyMajorUnits(data.extra_usage.used_credits)
|
|
1525
1562
|
const limit = moneyMajorUnits(data.extra_usage.monthly_limit)
|
|
@@ -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,3 @@
|
|
|
1
|
+
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M25.7146 63.2153L41.4393 54.3917L41.7025 53.6226L41.4393 53.1976H40.6705L38.0394 53.0359L29.054 52.7929L21.2624 52.4691L13.7134 52.0644L11.8111 51.6594L10.0303 49.3118L10.2123 48.138L11.8111 47.0657L14.0981 47.2681L19.1574 47.6119L26.7467 48.138L32.2516 48.4618L40.4073 49.3118H41.7025L41.8846 48.7857L41.4393 48.4618L41.0955 48.138L33.243 42.8155L24.7432 37.1894L20.2909 33.9513L17.8824 32.3119L16.6684 30.774L16.1422 27.4147L18.328 25.0062L21.2624 25.2088L22.0112 25.4112L24.9861 27.6979L31.3407 32.616L39.6381 38.7273L40.8525 39.7391L41.3381 39.395L41.399 39.1523L40.8525 38.2415L36.3394 30.0858L31.5227 21.7883L29.3775 18.3478L28.811 16.2837C28.6087 15.4334 28.4669 14.7252 28.4669 13.8549L30.9563 10.4753L32.3321 10.0303L35.6515 10.4756L37.0479 11.6897L39.112 16.4052L42.4513 23.8327L47.6321 33.9313L49.15 36.9265L49.9594 39.6991L50.2632 40.5491H50.7894V40.0632L51.2141 34.3766L52.0035 27.3944L52.7726 18.4087L53.0358 15.8793L54.2905 12.8435L56.7795 11.2041L58.7224 12.135L60.3212 14.422L60.0986 15.899L59.1474 22.0718L57.2857 31.7458L56.0713 38.2218H56.7795L57.5892 37.4121L60.8677 33.061L66.3723 26.18L68.801 23.448L71.6342 20.4325L73.4556 18.9957H76.8962L79.4255 22.7601L78.2926 26.6456L74.7509 31.1384L71.8163 34.943L67.607 40.6097L64.9758 45.1431L65.2188 45.5072L65.8464 45.4466L75.358 43.4228L80.4984 42.4917L86.6304 41.4393L89.4033 42.7346L89.7065 44.0502L88.6135 46.7419L82.0566 48.3607L74.3662 49.8989L62.9118 52.6109L62.77 52.7121L62.9321 52.9144L68.0925 53.4L70.2987 53.5214H75.7021L85.7601 54.2702L88.3912 56.0108L89.9697 58.1358L89.7065 59.7545L85.6589 61.8189L80.1949 60.5236L67.4452 57.4881L63.0735 56.3952H62.4665V56.7596L66.1093 60.3213L72.7877 66.3523L81.1461 74.1236L81.5707 76.0462L80.4984 77.5638L79.3649 77.4021L72.0186 71.8772L69.1854 69.3879L62.77 63.9844H62.3453V64.5509L63.8223 66.7164L71.6342 78.4544L72.0389 82.0567L71.4725 83.2308L69.4487 83.939L67.2222 83.534L62.6485 77.1189L57.9333 69.8937L54.1284 63.4177L53.6631 63.6809L51.4167 87.8651L50.3644 89.0995L47.9356 90.0303L45.9121 88.4924L44.8392 86.0031L45.9118 81.0852L47.2071 74.6701L48.2594 69.5699L49.2106 63.2356L49.7773 61.131L49.7367 60.9892L49.2715 61.0498L44.4954 67.607L37.23 77.4224L31.4825 83.5746L30.1063 84.1211L27.7181 82.8864L27.9408 80.6805L29.2763 78.7177L37.2297 68.5988L42.026 62.3248L45.1227 58.7025L45.1024 58.176H44.9204L23.7917 71.8975L20.0274 72.3831L18.4083 70.8655L18.6106 68.3761L19.3798 67.5664L25.7343 63.195L25.7146 63.2153Z" fill="currentColor"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
|
|
2
|
+
globalThis.__usagestat_bundled_options = {"labels":["Credits","Additional","Additional"],"defaults":{},"autoMode":"web","balanceOnly":true};
|
|
3
|
+
(function(defineProvider) {
|
|
4
|
+
// BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/claudeplatform.js
|
|
5
|
+
function _nullishCoalesce(lhs, rhsFn) {
|
|
6
|
+
if (lhs != null) {
|
|
7
|
+
return lhs;
|
|
8
|
+
} else {
|
|
9
|
+
return rhsFn();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
defineProvider({
|
|
13
|
+
id: "claudeplatform",
|
|
14
|
+
name: "Claude Platform",
|
|
15
|
+
settings: [],
|
|
16
|
+
endpoints: ["https://platform.claude.com"],
|
|
17
|
+
capabilities: ["browser-cookies", "http-status"],
|
|
18
|
+
cookieDomains: ["platform.claude.com"],
|
|
19
|
+
cookiePolicy: {
|
|
20
|
+
selection: "request-url",
|
|
21
|
+
cache: "nonpersistent",
|
|
22
|
+
imports: "access-gated",
|
|
23
|
+
requiredCookies: ["sessionKey"],
|
|
24
|
+
},
|
|
25
|
+
async fetchUsage(ctx) {
|
|
26
|
+
const domain = "platform.claude.com";
|
|
27
|
+
if (ctx.browser.availability(domain) === "off")
|
|
28
|
+
throw ctx.fail.missingCredential("Claude Platform cookies are disabled.");
|
|
29
|
+
|
|
30
|
+
const invalid = (field) => {
|
|
31
|
+
throw ctx.fail.parseFailure(
|
|
32
|
+
`Could not parse Claude Console ${field}. The Console response format may have changed; update CodexBar or report this.`,
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
const object = (value, field) =>
|
|
36
|
+
value !== null && typeof value === "object" && !Array.isArray(value) ? value : invalid(field);
|
|
37
|
+
const minorUnits = (value, field) =>
|
|
38
|
+
typeof value === "number" && Number.isSafeInteger(value) ? value : invalid(field);
|
|
39
|
+
const text = (value) => (typeof value === "string" && value.trim() ? value.trim() : undefined);
|
|
40
|
+
// A malformed date means an unknown expiry, never a failed refresh.
|
|
41
|
+
const timestamp = (value) => {
|
|
42
|
+
const raw = text(value);
|
|
43
|
+
if (!raw || !/^\d{4}-\d{2}-\d{2}T/.test(raw) || !Number.isFinite(Date.parse(raw))) return undefined;
|
|
44
|
+
try {
|
|
45
|
+
const date = ctx.date.iso(raw);
|
|
46
|
+
return Number.isFinite(date.getTime()) ? date : undefined;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
void error;
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
53
|
+
const now = ctx.date.now();
|
|
54
|
+
// Console grants expire at UTC midnight; show that UTC calendar date instead of shifting it into the local zone.
|
|
55
|
+
const expiry = (date) => {
|
|
56
|
+
const [year, month, day] = date.toISOString().slice(0, 10).split("-").map(Number);
|
|
57
|
+
const label = `${months[month - 1]} ${day}`;
|
|
58
|
+
return `Expires ${year === now.getUTCFullYear() ? label : `${label}, ${year}`} (UTC)`;
|
|
59
|
+
};
|
|
60
|
+
const sessionRejected = ctx.fail.authenticationExpired("Claude Console session expired.");
|
|
61
|
+
const billingDenied = ctx.fail.permissionDenied(
|
|
62
|
+
"Claude Console billing access was denied. Ask the organization owner for billing access.",
|
|
63
|
+
);
|
|
64
|
+
let rejected = false;
|
|
65
|
+
for await (const session of ctx.browser.sessions(domain)) {
|
|
66
|
+
const request = async (path, forbidden) => {
|
|
67
|
+
const response = await ctx.http.get(`https://${domain}${path}`, {
|
|
68
|
+
cookieSession: session.id,
|
|
69
|
+
headers: { Accept: "application/json" },
|
|
70
|
+
});
|
|
71
|
+
if (response.status === 401) throw sessionRejected;
|
|
72
|
+
if (response.status === 403) throw forbidden;
|
|
73
|
+
if (response.status === 429) {
|
|
74
|
+
throw ctx.fail.rateLimited("Claude Console requests are rate limited. Try again in a few minutes.");
|
|
75
|
+
}
|
|
76
|
+
if (response.status >= 500) {
|
|
77
|
+
throw ctx.fail.providerUnavailable("Claude Console is unavailable. Try again later.");
|
|
78
|
+
}
|
|
79
|
+
if (response.status !== 200) {
|
|
80
|
+
throw ctx.fail.apiFailure(`Claude Console returned HTTP ${response.status}. Try again later or report this.`);
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
return JSON.parse(response.bodyText);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
void error;
|
|
86
|
+
return invalid("JSON response");
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
try {
|
|
90
|
+
// The organizations list doubles as the session check; a rejected cookie answers 403.
|
|
91
|
+
const organizations = await request("/api/organizations", sessionRejected);
|
|
92
|
+
if (!Array.isArray(organizations)) return invalid("organizations");
|
|
93
|
+
// Claude.ai chat organizations share this list; only API organizations own Console billing.
|
|
94
|
+
const candidates = organizations
|
|
95
|
+
.map((value) => object(value, "organization"))
|
|
96
|
+
.filter((value) => Array.isArray(value.capabilities) && value.capabilities.some((item) => item === "api"))
|
|
97
|
+
.map((organization) => {
|
|
98
|
+
const id = text(organization.uuid);
|
|
99
|
+
if (!id || !/^[A-Za-z0-9-]{1,64}$/.test(id)) return invalid("organization ID");
|
|
100
|
+
return { id, name: text(organization.name) };
|
|
101
|
+
});
|
|
102
|
+
if (candidates.length === 0)
|
|
103
|
+
throw ctx.fail.permissionDenied(
|
|
104
|
+
"This Claude account has no Claude Console API organization. Create one at platform.claude.com.",
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// Try API organizations in listed order; the first one whose billing this member can read wins.
|
|
108
|
+
let selected;
|
|
109
|
+
for (const candidate of candidates) {
|
|
110
|
+
try {
|
|
111
|
+
const credits = object(
|
|
112
|
+
await request(`/api/organizations/${candidate.id}/prepaid/credits`, billingDenied),
|
|
113
|
+
"credit balance",
|
|
114
|
+
);
|
|
115
|
+
selected = { ...candidate, credits };
|
|
116
|
+
break;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (error !== billingDenied) throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (!selected) throw billingDenied;
|
|
122
|
+
const credits = selected.credits;
|
|
123
|
+
const currency = _nullishCoalesce(text(credits.currency), () => "USD");
|
|
124
|
+
if (!/^[A-Z]{3}$/.test(currency)) return invalid("currency");
|
|
125
|
+
let exponent = 2;
|
|
126
|
+
if (credits.balance !== undefined && credits.balance !== null) {
|
|
127
|
+
const reported = object(
|
|
128
|
+
_nullishCoalesce(object(credits.balance, "balance").credits, () => ({})),
|
|
129
|
+
"balance credits",
|
|
130
|
+
).exponent;
|
|
131
|
+
if (reported !== undefined && reported !== null) {
|
|
132
|
+
if (typeof reported !== "number" || !Number.isInteger(reported) || reported < 0 || reported > 4)
|
|
133
|
+
return invalid("currency exponent");
|
|
134
|
+
exponent = reported;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const scale = 10 ** exponent;
|
|
138
|
+
const money = (minor) => ctx.format.currency(minor / scale, currency);
|
|
139
|
+
const balance = minorUnits(credits.amount, "credit balance") / scale;
|
|
140
|
+
|
|
141
|
+
const grants = [];
|
|
142
|
+
for (const [field, purchased] of [
|
|
143
|
+
["promo_tranches", false],
|
|
144
|
+
["tranches", true],
|
|
145
|
+
]) {
|
|
146
|
+
const list = credits[field];
|
|
147
|
+
if (list === undefined || list === null) continue;
|
|
148
|
+
if (!Array.isArray(list)) return invalid(field);
|
|
149
|
+
for (const raw of list) {
|
|
150
|
+
const tranche = object(raw, "credit grant");
|
|
151
|
+
const granted = minorUnits(tranche.granted_amount_minor_units, "granted credit");
|
|
152
|
+
const remaining = minorUnits(tranche.remaining_amount_minor_units, "remaining credit");
|
|
153
|
+
const expiresAt = timestamp(tranche.expires_at);
|
|
154
|
+
if (granted <= 0 || (expiresAt && expiresAt.getTime() <= now.getTime())) continue;
|
|
155
|
+
grants.push({
|
|
156
|
+
label: _nullishCoalesce(text(tranche.name), () => (purchased ? "Purchased credit" : "API credit")),
|
|
157
|
+
program: text(tranche.program_id),
|
|
158
|
+
purchased,
|
|
159
|
+
remaining: Math.max(0, remaining),
|
|
160
|
+
granted,
|
|
161
|
+
expiresAt,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
grants.sort((lhs, rhs) => {
|
|
166
|
+
if (!lhs.expiresAt && !rhs.expiresAt) return 0;
|
|
167
|
+
if (!lhs.expiresAt) return 1;
|
|
168
|
+
if (!rhs.expiresAt) return -1;
|
|
169
|
+
return lhs.expiresAt.getTime() - rhs.expiresAt.getTime();
|
|
170
|
+
});
|
|
171
|
+
// The soonest-expiring grant that still has credit is the one about to be lost. An exhausted subscription
|
|
172
|
+
// grant is not a lane: the menu bar falls back to purchased credit and the grant moves to the detail list.
|
|
173
|
+
const subscription = grants.find((grant) => grant.program === "subscription_api_credit" && grant.remaining > 0);
|
|
174
|
+
const purchasedGrants = grants.filter((grant) => grant.purchased);
|
|
175
|
+
const purchased = _nullishCoalesce(
|
|
176
|
+
purchasedGrants.find((grant) => grant.remaining > 0),
|
|
177
|
+
() => purchasedGrants[0],
|
|
178
|
+
);
|
|
179
|
+
const amounts = (grant) => `${money(grant.remaining)} of ${money(grant.granted)} left`;
|
|
180
|
+
const [primary, secondary] = [subscription, purchased].map((grant) =>
|
|
181
|
+
grant
|
|
182
|
+
? {
|
|
183
|
+
usedPercent: ctx.pct(grant.granted - grant.remaining, grant.granted),
|
|
184
|
+
resetDescription: grant.expiresAt ? `${amounts(grant)} · ${expiry(grant.expiresAt)}` : amounts(grant),
|
|
185
|
+
}
|
|
186
|
+
: undefined,
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const details = [];
|
|
190
|
+
const otherGrants = grants.filter((grant) => grant !== subscription && grant !== purchased);
|
|
191
|
+
if (otherGrants.length > 0) {
|
|
192
|
+
details.push({
|
|
193
|
+
title: "Other credit grants",
|
|
194
|
+
rows: otherGrants.map((grant) => ({
|
|
195
|
+
label: grant.label,
|
|
196
|
+
value: amounts(grant),
|
|
197
|
+
secondaryValue: grant.expiresAt ? expiry(grant.expiresAt) : null,
|
|
198
|
+
progress: (grant.granted - Math.min(grant.remaining, grant.granted)) / grant.granted,
|
|
199
|
+
})),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Spend is optional: a broken report must not discard an authenticated balance.
|
|
204
|
+
let spendRow;
|
|
205
|
+
try {
|
|
206
|
+
const spend = object(
|
|
207
|
+
await request(`/api/organizations/${selected.id}/current_spend`, billingDenied),
|
|
208
|
+
"spend",
|
|
209
|
+
);
|
|
210
|
+
const amount = minorUnits(spend.amount, "spend");
|
|
211
|
+
if (amount < 0) return invalid("spend");
|
|
212
|
+
spendRow = { label: "This month (UTC)", value: money(amount) };
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (error.transportClass === "cancelled") throw error;
|
|
215
|
+
spendRow = { label: "Spend", value: "Unavailable" };
|
|
216
|
+
}
|
|
217
|
+
details.push({ title: "Billing", rows: [spendRow] });
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
primary,
|
|
221
|
+
secondary,
|
|
222
|
+
cost: { used: balance, currency, period: "Prepaid credits", balance },
|
|
223
|
+
details,
|
|
224
|
+
identity: { organization: selected.name, loginMethod: "Console session" },
|
|
225
|
+
dataConfidence: "exact",
|
|
226
|
+
};
|
|
227
|
+
} catch (error) {
|
|
228
|
+
if (error !== sessionRejected) throw error;
|
|
229
|
+
ctx.browser.rejectCookie(domain, session);
|
|
230
|
+
rejected = true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (rejected)
|
|
234
|
+
throw ctx.fail.authenticationExpired(
|
|
235
|
+
"Claude Console session expired. Sign in at platform.claude.com or paste a fresh Cookie header.",
|
|
236
|
+
);
|
|
237
|
+
throw ctx.fail.missingCredential(
|
|
238
|
+
`Sign in at platform.claude.com. Supported browsers: ${ctx.browser.supportedBrowsers}. Or paste its Cookie header.`,
|
|
239
|
+
);
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// END UPSTREAM
|
|
244
|
+
})(globalThis.defineProvider);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "claudeplatform",
|
|
4
|
+
"name": "Claude Platform",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"entry": "plugin.js",
|
|
7
|
+
"enabledByDefault": false,
|
|
8
|
+
"supportedModes": [
|
|
9
|
+
"web"
|
|
10
|
+
],
|
|
11
|
+
"autoMode": "web",
|
|
12
|
+
"usageDashboardUrl": "https://platform.claude.com/settings/billing",
|
|
13
|
+
"webUrl": "https://platform.claude.com",
|
|
14
|
+
"envVars": [
|
|
15
|
+
"CLAUDEPLATFORM_COOKIE"
|
|
16
|
+
],
|
|
17
|
+
"setupFields": [],
|
|
18
|
+
"upstream": {
|
|
19
|
+
"repository": "https://github.com/steipete/CodexBar",
|
|
20
|
+
"revision": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
|
|
21
|
+
"path": "Sources/CodexBarCore/Resources/Plugins/claudeplatform.js",
|
|
22
|
+
"sha256": "d3c61855621fd4e5b5b753bdd223524e0ee7f4b55cfd63f24f23516ac33027e8",
|
|
23
|
+
"license": "MIT"
|
|
24
|
+
}
|
|
25
|
+
}
|