@hashimkarim/usagestat-linux-x64-gnu 2.0.2 → 2.1.0
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 +685 -133
- package/package.json +94 -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 +19 -10
- package/plugins/antigravity-cli/plugin.js +8 -3
- package/plugins/antigravity-ide/plugin.js +8 -5
- 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 +3 -2
- package/plugins/codex/plugin.json +1 -1
- 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 +9 -2
- 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/helmcode/icon.svg +5 -0
- package/plugins/helmcode/plugin.js +48 -40
- 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/kimi/plugin.js +39 -14
- 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/plugin.js +5 -0
- package/plugins/lithosai/plugin.json +2 -1
- package/plugins/llmman/icon.svg +4 -0
- package/plugins/llmman/plugin.js +5 -0
- package/plugins/llmman/plugin.json +9 -1
- 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 +5 -0
- package/plugins/muse/plugin.json +9 -1
- package/plugins/museai/plugin.js +5 -0
- package/plugins/museai/plugin.json +2 -1
- 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 +17 -6
- 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/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 +5 -0
- package/plugins/raycast/plugin.json +9 -1
- 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/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/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 +104 -0
- package/plugins/traecn/plugin.json +25 -0
- package/plugins/typesafe/icon.svg +4 -0
- package/plugins/typesafe/plugin.js +30 -25
- 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/icon.svg +1 -1
- package/plugins/workbuddy/plugin.js +9 -4
- package/plugins/workbuddy/plugin.json +20 -2
- 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/usagestat +0 -0
- package/usagestatd +0 -0
- package/plugins/cursor-nightly/plugin.js +0 -1416
|
@@ -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": "6070b29a1a5d51193a634dc1b0a14a67c39d0ccc",
|
|
21
|
+
"path": "Sources/CodexBarCore/Resources/Plugins/claudeplatform.js",
|
|
22
|
+
"sha256": "d3c61855621fd4e5b5b753bdd223524e0ee7f4b55cfd63f24f23516ac33027e8",
|
|
23
|
+
"license": "MIT"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/plugins/codex/plugin.js
CHANGED
|
@@ -375,8 +375,9 @@
|
|
|
375
375
|
function formatCodexPlan(ctx, planType) {
|
|
376
376
|
const rawPlan = typeof planType === "string" ? planType.trim() : ""
|
|
377
377
|
if (!rawPlan) return null
|
|
378
|
-
if (rawPlan.toLowerCase() === "prolite") return "Pro
|
|
379
|
-
if (rawPlan.toLowerCase() === "pro") return "Pro
|
|
378
|
+
if (rawPlan.toLowerCase() === "prolite") return "Pro 100"
|
|
379
|
+
if (rawPlan.toLowerCase() === "pro") return "Pro 200"
|
|
380
|
+
if (rawPlan.toLowerCase() === "promax") return "Pro 500"
|
|
380
381
|
if (rawPlan.toLowerCase() === "self_serve_business_prolite") return "Business Premium"
|
|
381
382
|
return ctx.fmt.planLabel(rawPlan) || null
|
|
382
383
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Peter Steinberger
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M16 4a9 9 0 1 0 0 16l-2-3a5.5 5.5 0 1 1 0-10Z"/><path fill="currentColor" d="m19 3 1.2 3.8L24 8l-3.8 1.2L19 13l-1.2-3.8L14 8l3.8-1.2Z"/></svg>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
|
|
2
|
+
globalThis.__usagestat_bundled_options = {"labels":["Input tokens","Output tokens","Additional"],"defaults":{},"autoMode":"api"};
|
|
3
|
+
(function(defineProvider) {
|
|
4
|
+
// BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/cosmic.js
|
|
5
|
+
function _optionalChain(ops) {
|
|
6
|
+
let lastAccessLHS = undefined;
|
|
7
|
+
let value = ops[0];
|
|
8
|
+
let i = 1;
|
|
9
|
+
while (i < ops.length) {
|
|
10
|
+
const op = ops[i];
|
|
11
|
+
const fn = ops[i + 1];
|
|
12
|
+
i += 2;
|
|
13
|
+
if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
if (op === "access" || op === "optionalAccess") {
|
|
17
|
+
lastAccessLHS = value;
|
|
18
|
+
value = fn(value);
|
|
19
|
+
} else if (op === "call" || op === "optionalCall") {
|
|
20
|
+
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
21
|
+
lastAccessLHS = undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
defineProvider({
|
|
27
|
+
id: "cosmic",
|
|
28
|
+
name: "Cosmic AI",
|
|
29
|
+
endpoints: ["https://dapi.cosmicjs.com"],
|
|
30
|
+
auth: { type: "bearer", secret: "COSMIC_TOKEN" },
|
|
31
|
+
settings: [
|
|
32
|
+
{ key: "COSMIC_TOKEN", title: "Personal Access Token", type: "secure" },
|
|
33
|
+
{ key: "COSMIC_PROJECT_ID", title: "Project ID", type: "plain" },
|
|
34
|
+
],
|
|
35
|
+
capabilities: ["http-status"],
|
|
36
|
+
async fetchUsage(ctx) {
|
|
37
|
+
const project = _optionalChain([
|
|
38
|
+
ctx,
|
|
39
|
+
"access",
|
|
40
|
+
(_) => _.settings,
|
|
41
|
+
"access",
|
|
42
|
+
(_2) => _2.get,
|
|
43
|
+
"call",
|
|
44
|
+
(_3) => _3("COSMIC_PROJECT_ID"),
|
|
45
|
+
"optionalAccess",
|
|
46
|
+
(_4) => _4.trim,
|
|
47
|
+
"call",
|
|
48
|
+
(_5) => _5(),
|
|
49
|
+
]);
|
|
50
|
+
if (!project) throw ctx.fail.missingCredential("Set a Cosmic Project ID in Settings or COSMIC_PROJECT_ID.");
|
|
51
|
+
const response = await ctx.http.get(
|
|
52
|
+
`https://dapi.cosmicjs.com/v3/projects/usage?project_id=${encodeURIComponent(project)}`,
|
|
53
|
+
{ headers: { Origin: "https://app.cosmicjs.com" } },
|
|
54
|
+
);
|
|
55
|
+
const message = `Cosmic AI returned HTTP ${response.status}.`;
|
|
56
|
+
if (response.status === 401) throw ctx.fail.authenticationExpired(message);
|
|
57
|
+
if (response.status === 403) throw ctx.fail.permissionDenied(message);
|
|
58
|
+
if (response.status === 429) throw ctx.fail.rateLimited(message);
|
|
59
|
+
if (response.status >= 500) throw ctx.fail.providerUnavailable(message);
|
|
60
|
+
if (response.status !== 200) throw ctx.fail.apiFailure(message);
|
|
61
|
+
const fail = () => {
|
|
62
|
+
throw ctx.fail.parseFailure("Cosmic AI returned an unrecognized project AI-token usage response.");
|
|
63
|
+
};
|
|
64
|
+
const record = (value) => (value && typeof value === "object" && !Array.isArray(value) ? value : undefined);
|
|
65
|
+
let decoded;
|
|
66
|
+
try {
|
|
67
|
+
decoded = JSON.parse(response.bodyText);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
void error;
|
|
70
|
+
return fail();
|
|
71
|
+
}
|
|
72
|
+
const root = record(decoded);
|
|
73
|
+
const usage = record(
|
|
74
|
+
_optionalChain([
|
|
75
|
+
record,
|
|
76
|
+
"call",
|
|
77
|
+
(_6) => _6(_optionalChain([root, "optionalAccess", (_7) => _7.usage])),
|
|
78
|
+
"optionalAccess",
|
|
79
|
+
(_8) => _8.ai,
|
|
80
|
+
]),
|
|
81
|
+
);
|
|
82
|
+
const allowance = record(
|
|
83
|
+
_optionalChain([
|
|
84
|
+
record,
|
|
85
|
+
"call",
|
|
86
|
+
(_9) => _9(_optionalChain([root, "optionalAccess", (_10) => _10.plan_info])),
|
|
87
|
+
"optionalAccess",
|
|
88
|
+
(_11) => _11.ai_tokens,
|
|
89
|
+
]),
|
|
90
|
+
);
|
|
91
|
+
const count = (value) => {
|
|
92
|
+
if (value === undefined || value === null) return undefined;
|
|
93
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : fail();
|
|
94
|
+
};
|
|
95
|
+
const limit = (value) => {
|
|
96
|
+
if (typeof value !== "string") return count(value);
|
|
97
|
+
const match = /^(\d+(?:\.\d+)?)\s*([km]?)$/i.exec(value.trim());
|
|
98
|
+
if (!match) return undefined;
|
|
99
|
+
return count(Number(match[1]) * (match[2].toLowerCase() === "m" ? 1000000 : match[2] ? 1000 : 1));
|
|
100
|
+
};
|
|
101
|
+
const details = [];
|
|
102
|
+
const window = (name, rawUsed, rawLimit) => {
|
|
103
|
+
const used = count(rawUsed);
|
|
104
|
+
const total = limit(rawLimit);
|
|
105
|
+
const rows = [];
|
|
106
|
+
if (used !== undefined) rows.push({ label: "Used", value: ctx.format.number(used) });
|
|
107
|
+
if (total !== undefined) rows.push({ label: "Allowance", value: ctx.format.number(total) });
|
|
108
|
+
else if (typeof rawLimit === "string" && rawLimit.trim()) {
|
|
109
|
+
rows.push({ label: "Allowance", value: /^unlimited$/i.test(rawLimit.trim()) ? "Unlimited" : "Not reported" });
|
|
110
|
+
}
|
|
111
|
+
if (used !== undefined && total !== undefined) {
|
|
112
|
+
rows.push({ label: "Remaining", value: ctx.format.number(Math.max(0, total - used)) });
|
|
113
|
+
if (used > total) rows.push({ label: "Above allowance", value: ctx.format.number(used - total) });
|
|
114
|
+
}
|
|
115
|
+
if (rows.length) details.push({ title: name, rows });
|
|
116
|
+
return used !== undefined && total !== undefined && total > 0 ? { usedPercent: ctx.pct(used, total) } : undefined;
|
|
117
|
+
};
|
|
118
|
+
const primary = window(
|
|
119
|
+
"Input tokens",
|
|
120
|
+
_optionalChain([usage, "optionalAccess", (_12) => _12.input_tokens]),
|
|
121
|
+
_optionalChain([allowance, "optionalAccess", (_13) => _13.max_input]),
|
|
122
|
+
);
|
|
123
|
+
const secondary = window(
|
|
124
|
+
"Output tokens",
|
|
125
|
+
_optionalChain([usage, "optionalAccess", (_14) => _14.output_tokens]),
|
|
126
|
+
_optionalChain([allowance, "optionalAccess", (_15) => _15.max_output]),
|
|
127
|
+
);
|
|
128
|
+
if (!details.length) return fail();
|
|
129
|
+
return { primary, secondary, details, dataConfidence: "exact" };
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// END UPSTREAM
|
|
134
|
+
})(globalThis.defineProvider);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "cosmic",
|
|
4
|
+
"name": "Cosmic AI",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"entry": "plugin.js",
|
|
7
|
+
"enabledByDefault": false,
|
|
8
|
+
"supportedModes": [
|
|
9
|
+
"api"
|
|
10
|
+
],
|
|
11
|
+
"autoMode": "api",
|
|
12
|
+
"usageDashboardUrl": "https://app.cosmicjs.com",
|
|
13
|
+
"envVars": [
|
|
14
|
+
"COSMIC_TOKEN",
|
|
15
|
+
"COSMIC_PROJECT_ID"
|
|
16
|
+
],
|
|
17
|
+
"setupFields": [
|
|
18
|
+
{
|
|
19
|
+
"key": "COSMIC_PROJECT_ID",
|
|
20
|
+
"title": "Project ID",
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Provider-specific account or source selection."
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"upstream": {
|
|
26
|
+
"repository": "https://github.com/steipete/CodexBar",
|
|
27
|
+
"revision": "6070b29a1a5d51193a634dc1b0a14a67c39d0ccc",
|
|
28
|
+
"path": "Sources/CodexBarCore/Resources/Plugins/cosmic.js",
|
|
29
|
+
"sha256": "eb869360f719b3b3b96311617c173e624efa05b91c0f7d31ce985f0a3a77d7a6",
|
|
30
|
+
"license": "MIT"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/plugins/cursor/plugin.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
2
1
|
(function () {
|
|
3
2
|
const KEYCHAIN_ACCESS_TOKEN_SERVICE = "cursor-access-token"
|
|
4
3
|
const KEYCHAIN_REFRESH_TOKEN_SERVICE = "cursor-refresh-token"
|
|
@@ -1137,13 +1136,21 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
1137
1136
|
if (!Number.isFinite(percent) || percent < 0) return result
|
|
1138
1137
|
const resetMs = ctx.util.parseDateMs(usage.nextResetTimestampUtc)
|
|
1139
1138
|
const startMs = ctx.util.parseDateMs(usage.currentPeriodStart)
|
|
1139
|
+
const paid = usage.hasNonZeroIncludedLimit === true || usage.includedLimitZero === false
|
|
1140
|
+
const requestsPrimary = result.lines.some(item => item.type === 'progress' && item.label === 'Requests')
|
|
1141
|
+
if (usage.isUnified === true && paid && Number.isFinite(resetMs) && resetMs > Date.parse(ctx.nowIso) && !requestsPrimary) {
|
|
1142
|
+
result.lines = result.lines.filter(item => !['Total usage','Cursor Models','Other Models','Grok Bot usage'].includes(item.label))
|
|
1143
|
+
result.lines.unshift(ctx.line.progress({label:'Weekly',used:Math.min(100,percent),limit:100,format:{kind:'percent'},
|
|
1144
|
+
resetsAt:ctx.util.toIso(resetMs),periodDurationMs:7*24*60*60*1000}))
|
|
1145
|
+
return result
|
|
1146
|
+
}
|
|
1140
1147
|
const line = ctx.line.progress({
|
|
1141
1148
|
label: "Grok Bot usage",
|
|
1142
1149
|
used: Math.min(100, percent),
|
|
1143
1150
|
limit: 100,
|
|
1144
1151
|
format: { kind: "percent" },
|
|
1145
1152
|
resetsAt: Number.isFinite(resetMs) ? ctx.util.toIso(resetMs) : undefined,
|
|
1146
|
-
periodDurationMs: Number.isFinite(startMs) && Number.isFinite(resetMs) && resetMs > startMs
|
|
1153
|
+
periodDurationMs: paid ? 7*24*60*60*1000 : Number.isFinite(startMs) && Number.isFinite(resetMs) && resetMs > startMs
|
|
1147
1154
|
? resetMs - startMs : 7 * 24 * 60 * 60 * 1000,
|
|
1148
1155
|
})
|
|
1149
1156
|
let insertAt = result.lines.length
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
|
|
2
2
|
globalThis.__usagestat_bundled_options = {"labels":["Plan credits","Premium weekly","Additional"],"defaults":{},"autoMode":"api"};
|
|
3
|
+
(function(defineProvider) {
|
|
4
|
+
// BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/devpass.js
|
|
3
5
|
function _nullishCoalesce(lhs, rhsFn) {
|
|
4
6
|
if (lhs != null) {
|
|
5
7
|
return lhs;
|
|
@@ -113,3 +115,6 @@ defineProvider({
|
|
|
113
115
|
};
|
|
114
116
|
},
|
|
115
117
|
});
|
|
118
|
+
|
|
119
|
+
// END UPSTREAM
|
|
120
|
+
})(globalThis.defineProvider);
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
"envVars": [
|
|
14
14
|
"DEVPASS_API_KEY"
|
|
15
15
|
],
|
|
16
|
+
"setupFields": [],
|
|
16
17
|
"upstream": {
|
|
17
18
|
"repository": "https://github.com/steipete/CodexBar",
|
|
18
|
-
"revision": "
|
|
19
|
+
"revision": "6070b29a1a5d51193a634dc1b0a14a67c39d0ccc",
|
|
19
20
|
"path": "Sources/CodexBarCore/Resources/Plugins/devpass.js",
|
|
20
21
|
"sha256": "6fdfab17f543fc88f28b90f76fbe6edc6db3f4d3c7fa657a899c573d363a0886",
|
|
21
22
|
"license": "MIT"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Peter Steinberger
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Exa</title><path clip-rule="evenodd" d="M3 0h19v1.791L13.892 12 22 22.209V24H3V0zm9.62 10.348l6.589-8.557H6.03l6.59 8.557zM5.138 3.935v7.17h5.52l-5.52-7.17zm5.52 8.96h-5.52v7.17l5.52-7.17zM6.03 22.21l6.59-8.557 6.589 8.557H6.03z" fill="#1F40ED" fill-rule="evenodd"></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>Exa</title><path clip-rule="evenodd" d="M3 0h19v1.791L13.892 12 22 22.209V24H3V0zm9.62 10.348l6.589-8.557H6.03l6.59 8.557zM5.138 3.935v7.17h5.52l-5.52-7.17zm5.52 8.96h-5.52v7.17l5.52-7.17zM6.03 22.21l6.59-8.557 6.589 8.557H6.03z"></path></svg>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
|
|
2
|
+
globalThis.__usagestat_bundled_options = {"labels":["Usage","Additional","Additional"],"defaults":{},"autoMode":"api"};
|
|
3
|
+
(function(defineProvider) {
|
|
4
|
+
// BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/exa.js
|
|
5
|
+
defineProvider({
|
|
6
|
+
id: "exa",
|
|
7
|
+
name: "Exa",
|
|
8
|
+
endpoints: ["https://admin-api.exa.ai"],
|
|
9
|
+
auth: { type: "x-api-key", secret: "EXA_SERVICE_KEY" },
|
|
10
|
+
settings: [
|
|
11
|
+
{ key: "EXA_SERVICE_KEY", title: "Exa service key", type: "secure" },
|
|
12
|
+
{ key: "EXA_API_KEY_ID", title: "API key ID", type: "plain" },
|
|
13
|
+
],
|
|
14
|
+
capabilities: ["http-status"],
|
|
15
|
+
async fetchUsage(ctx) {
|
|
16
|
+
const id = ctx.settings.get("EXA_API_KEY_ID");
|
|
17
|
+
if (!id || id === "." || id === "..") {
|
|
18
|
+
throw ctx.fail.missingCredential(
|
|
19
|
+
"Set the Exa API key ID in Scope or EXA_API_KEY_ID; this is not the service key.",
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
const end = new Date(Math.floor(ctx.date.now().getTime() / 1000) * 1000);
|
|
23
|
+
const start = new Date(Date.UTC(end.getUTCFullYear(), end.getUTCMonth(), 1));
|
|
24
|
+
const url =
|
|
25
|
+
`https://admin-api.exa.ai/team-management/api-keys/${encodeURIComponent(id)}/usage` +
|
|
26
|
+
`?start_date=${encodeURIComponent(start.toISOString())}&end_date=${encodeURIComponent(end.toISOString())}`;
|
|
27
|
+
const response = await ctx.http.get(url);
|
|
28
|
+
const message = `Exa returned HTTP ${response.status}.`;
|
|
29
|
+
if (response.status === 401) {
|
|
30
|
+
throw ctx.fail.authenticationExpired("Exa rejected the service key. Ordinary search API keys are not supported.");
|
|
31
|
+
}
|
|
32
|
+
if (response.status === 403) {
|
|
33
|
+
throw ctx.fail.permissionDenied(
|
|
34
|
+
"Exa Team Management must be enabled and both keys must belong to the same team.",
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (response.status === 429) throw ctx.fail.rateLimited(message);
|
|
38
|
+
if (response.status >= 500) throw ctx.fail.providerUnavailable(message);
|
|
39
|
+
if (response.status !== 200) throw ctx.fail.apiFailure(message);
|
|
40
|
+
const fail = () => {
|
|
41
|
+
throw ctx.fail.parseFailure("Exa returned an unrecognized API key usage response.");
|
|
42
|
+
};
|
|
43
|
+
let data;
|
|
44
|
+
try {
|
|
45
|
+
data = JSON.parse(response.bodyText);
|
|
46
|
+
} catch {
|
|
47
|
+
return fail();
|
|
48
|
+
}
|
|
49
|
+
if (
|
|
50
|
+
!data ||
|
|
51
|
+
typeof data.total_cost_usd !== "number" ||
|
|
52
|
+
!Number.isFinite(data.total_cost_usd) ||
|
|
53
|
+
data.total_cost_usd < 0 ||
|
|
54
|
+
!data.period ||
|
|
55
|
+
typeof data.period.start !== "string" ||
|
|
56
|
+
typeof data.period.end !== "string" ||
|
|
57
|
+
Date.parse(data.period.start) !== start.getTime() ||
|
|
58
|
+
Date.parse(data.period.end) !== end.getTime()
|
|
59
|
+
)
|
|
60
|
+
return fail();
|
|
61
|
+
return {
|
|
62
|
+
details: [
|
|
63
|
+
{
|
|
64
|
+
title: "API key this month (UTC)",
|
|
65
|
+
rows: [{ label: "Spend", value: ctx.format.currency(data.total_cost_usd, "USD") }],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
identity: { loginMethod: "Service key" },
|
|
69
|
+
dataConfidence: "exact",
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// END UPSTREAM
|
|
75
|
+
})(globalThis.defineProvider);
|