@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
package/plugins/codex/plugin.js
CHANGED
|
@@ -375,12 +375,18 @@
|
|
|
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
|
}
|
|
383
384
|
|
|
385
|
+
function reportedPeriod(window, fallback) {
|
|
386
|
+
const seconds = window && window.limit_window_seconds
|
|
387
|
+
return typeof seconds === "number" && Number.isFinite(seconds) && seconds > 0 ? seconds * 1000 : fallback
|
|
388
|
+
}
|
|
389
|
+
|
|
384
390
|
function getResetsAtIso(ctx, nowSec, window) {
|
|
385
391
|
if (!window) return null
|
|
386
392
|
if (typeof window.reset_at === "number") {
|
|
@@ -779,12 +785,12 @@
|
|
|
779
785
|
|
|
780
786
|
if (headerPrimary !== null) {
|
|
781
787
|
lines.push(ctx.line.progress({
|
|
782
|
-
label: "Session",
|
|
788
|
+
label: reportedPeriod(primaryWindow, PERIOD_SESSION_MS) === 30*86400000 ? "Monthly" : "Session",
|
|
783
789
|
used: headerPrimary,
|
|
784
790
|
limit: 100,
|
|
785
791
|
format: { kind: "percent" },
|
|
786
792
|
resetsAt: getResetsAtIso(ctx, nowSec, primaryWindow),
|
|
787
|
-
periodDurationMs: PERIOD_SESSION_MS
|
|
793
|
+
periodDurationMs: reportedPeriod(primaryWindow, PERIOD_SESSION_MS)
|
|
788
794
|
}))
|
|
789
795
|
}
|
|
790
796
|
if (headerSecondary !== null) {
|
|
@@ -794,19 +800,19 @@
|
|
|
794
800
|
limit: 100,
|
|
795
801
|
format: { kind: "percent" },
|
|
796
802
|
resetsAt: getResetsAtIso(ctx, nowSec, secondaryWindow),
|
|
797
|
-
periodDurationMs: PERIOD_WEEKLY_MS
|
|
803
|
+
periodDurationMs: reportedPeriod(secondaryWindow, PERIOD_WEEKLY_MS)
|
|
798
804
|
}))
|
|
799
805
|
}
|
|
800
806
|
|
|
801
807
|
if (lines.length === 0 && data.rate_limit) {
|
|
802
808
|
if (data.rate_limit.primary_window && typeof data.rate_limit.primary_window.used_percent === "number") {
|
|
803
809
|
lines.push(ctx.line.progress({
|
|
804
|
-
label: "Session",
|
|
810
|
+
label: reportedPeriod(primaryWindow, PERIOD_SESSION_MS) === 30*86400000 ? "Monthly" : "Session",
|
|
805
811
|
used: data.rate_limit.primary_window.used_percent,
|
|
806
812
|
limit: 100,
|
|
807
813
|
format: { kind: "percent" },
|
|
808
814
|
resetsAt: getResetsAtIso(ctx, nowSec, primaryWindow),
|
|
809
|
-
periodDurationMs: PERIOD_SESSION_MS
|
|
815
|
+
periodDurationMs: reportedPeriod(primaryWindow, PERIOD_SESSION_MS)
|
|
810
816
|
}))
|
|
811
817
|
}
|
|
812
818
|
if (data.rate_limit.secondary_window && typeof data.rate_limit.secondary_window.used_percent === "number") {
|
|
@@ -816,7 +822,7 @@
|
|
|
816
822
|
limit: 100,
|
|
817
823
|
format: { kind: "percent" },
|
|
818
824
|
resetsAt: getResetsAtIso(ctx, nowSec, secondaryWindow),
|
|
819
|
-
periodDurationMs: PERIOD_WEEKLY_MS
|
|
825
|
+
periodDurationMs: reportedPeriod(secondaryWindow, PERIOD_WEEKLY_MS)
|
|
820
826
|
}))
|
|
821
827
|
}
|
|
822
828
|
}
|
|
@@ -13,10 +13,14 @@
|
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"label": "Usage dashboard",
|
|
16
|
-
"url": "https://chatgpt.com/
|
|
16
|
+
"url": "https://chatgpt.com/settings/usage?tab=overview"
|
|
17
17
|
}
|
|
18
18
|
],
|
|
19
|
-
"supportedModes": [
|
|
19
|
+
"supportedModes": [
|
|
20
|
+
"oauth",
|
|
21
|
+
"local",
|
|
22
|
+
"web"
|
|
23
|
+
],
|
|
20
24
|
"autoMode": "oauth",
|
|
21
25
|
"webUrl": "https://chatgpt.com",
|
|
22
26
|
"lines": [
|
|
@@ -77,6 +81,11 @@
|
|
|
77
81
|
"type": "barChart",
|
|
78
82
|
"label": "Usage Trend",
|
|
79
83
|
"scope": "detail"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"type": "progress",
|
|
87
|
+
"label": "Monthly",
|
|
88
|
+
"scope": "overview"
|
|
80
89
|
}
|
|
81
90
|
]
|
|
82
91
|
}
|
|
@@ -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": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
|
|
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"
|
|
@@ -198,15 +197,16 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
198
197
|
const injected = readInjectedCredential(ctx)
|
|
199
198
|
if (injected) return injected
|
|
200
199
|
|
|
201
|
-
const
|
|
202
|
-
const
|
|
200
|
+
const usable = value => typeof value === "string" && value.trim() && !value.trim().startsWith("cursor-safe-storage:") ? value.trim() : null
|
|
201
|
+
const sqliteAccessToken = usable(readStateValue(ctx, "cursorAuth/accessToken"))
|
|
202
|
+
const sqliteRefreshToken = usable(readStateValue(ctx, "cursorAuth/refreshToken"))
|
|
203
203
|
if (sqliteAccessToken || sqliteRefreshToken) {
|
|
204
204
|
return { accessToken: sqliteAccessToken, refreshToken: sqliteRefreshToken, source: "sqlite" }
|
|
205
205
|
}
|
|
206
206
|
// Generic CLI keychain targets are shared, not tied to an IDE variant.
|
|
207
207
|
// They cannot represent Nightly or an explicitly selected database profile.
|
|
208
|
-
const keychainAccessToken = sharedCredentialsAllowed(ctx) ? readKeychainValue(ctx, KEYCHAIN_ACCESS_TOKEN_SERVICE) : null
|
|
209
|
-
const keychainRefreshToken = sharedCredentialsAllowed(ctx) ? readKeychainValue(ctx, KEYCHAIN_REFRESH_TOKEN_SERVICE) : null
|
|
208
|
+
const keychainAccessToken = sharedCredentialsAllowed(ctx) ? usable(readKeychainValue(ctx, KEYCHAIN_ACCESS_TOKEN_SERVICE)) : null
|
|
209
|
+
const keychainRefreshToken = sharedCredentialsAllowed(ctx) ? usable(readKeychainValue(ctx, KEYCHAIN_REFRESH_TOKEN_SERVICE)) : null
|
|
210
210
|
|
|
211
211
|
if (keychainAccessToken || keychainRefreshToken) {
|
|
212
212
|
return {
|
|
@@ -216,6 +216,13 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
if (sharedCredentialsAllowed(ctx) && (!ctx.provider?.instanceId || ctx.provider.instanceId === "cursor") && ctx.host.cursorPaths?.readCliAuth) {
|
|
220
|
+
try {
|
|
221
|
+
const cli = ctx.util.tryParseJson(ctx.host.cursorPaths.readCliAuth())
|
|
222
|
+
if (cli && (usable(cli.accessToken) || usable(cli.refreshToken)))
|
|
223
|
+
return {accessToken:usable(cli.accessToken),refreshToken:usable(cli.refreshToken),source:"cli-file"}
|
|
224
|
+
} catch (_) {}
|
|
225
|
+
}
|
|
219
226
|
return {
|
|
220
227
|
accessToken: null,
|
|
221
228
|
refreshToken: null,
|
|
@@ -232,6 +239,8 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
232
239
|
if (!credential) return null
|
|
233
240
|
const accessToken = String(credential.accessToken || credential.sessionKey || "").trim()
|
|
234
241
|
const refreshToken = String(credential.refreshToken || "").trim()
|
|
242
|
+
if (accessToken.startsWith("cursor-safe-storage:") || refreshToken.startsWith("cursor-safe-storage:"))
|
|
243
|
+
throw {code:"credential-malformed",message:"Cursor safe-storage values are encrypted, not provider access tokens."}
|
|
235
244
|
if (!accessToken && !refreshToken) return null
|
|
236
245
|
return {
|
|
237
246
|
accessToken: accessToken || null,
|
|
@@ -239,6 +248,7 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
239
248
|
source: "provider-account",
|
|
240
249
|
}
|
|
241
250
|
} catch (e) {
|
|
251
|
+
if (e && e.code) throw e
|
|
242
252
|
ctx.host.log.warn("provider account credential read failed: " + String(e))
|
|
243
253
|
return null
|
|
244
254
|
}
|
|
@@ -313,6 +323,7 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
313
323
|
}
|
|
314
324
|
|
|
315
325
|
function persistAccessToken(ctx, source, accessToken) {
|
|
326
|
+
if (source === "cli-file") return false // The Cursor CLI owns its credential file.
|
|
316
327
|
if (source === "provider-account") {
|
|
317
328
|
try {
|
|
318
329
|
if (ctx.host.credentials && typeof ctx.host.credentials.update === "function") {
|
|
@@ -643,11 +654,21 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
643
654
|
const hasPlanUsageLimit = hasPlanUsage && Number.isFinite(limitN)
|
|
644
655
|
const planUsageLimitMissing = hasPlanUsage && !hasPlanUsageLimit
|
|
645
656
|
const hasTotalUsagePercent = hasPlanUsage && Number.isFinite(pctN)
|
|
657
|
+
const auto = hasPlanUsage && typeof pu.autoPercentUsed === "number" ? pu.autoPercentUsed : NaN
|
|
658
|
+
const api = hasPlanUsage && typeof pu.apiPercentUsed === "number" ? pu.apiPercentUsed : NaN
|
|
659
|
+
const reportedSpend = hasPlanUsage ? readFiniteNumber(pu.totalSpend) : NaN
|
|
660
|
+
const remaining = hasPlanUsage ? readFiniteNumber(pu.remaining) : NaN
|
|
661
|
+
const spent = Number.isFinite(reportedSpend) ? reportedSpend
|
|
662
|
+
: (Number.isFinite(limitN) ? limitN - (Number.isFinite(remaining) ? remaining : limitN) : 0)
|
|
663
|
+
// Legacy Teams reports zero pool placeholders beside positive dollar spend.
|
|
664
|
+
const hasModelPools = Number.isFinite(auto) && auto >= 0 && Number.isFinite(api) && api >= 0 &&
|
|
665
|
+
(auto > 0 || api > 0 || spent === 0)
|
|
646
666
|
return {
|
|
647
667
|
hasPlanUsage: hasPlanUsage,
|
|
648
668
|
hasPlanUsageLimit: hasPlanUsageLimit,
|
|
649
|
-
planUsageLimitMissing: planUsageLimitMissing,
|
|
669
|
+
planUsageLimitMissing: planUsageLimitMissing && !hasModelPools,
|
|
650
670
|
hasTotalUsagePercent: hasTotalUsagePercent,
|
|
671
|
+
hasModelPools: hasModelPools,
|
|
651
672
|
pu: pu,
|
|
652
673
|
}
|
|
653
674
|
}
|
|
@@ -676,7 +697,7 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
676
697
|
const hasTotalUsagePercent = flags.hasTotalUsagePercent
|
|
677
698
|
const pu = flags.pu
|
|
678
699
|
|
|
679
|
-
if (!hasPlanUsageLimit && !hasTotalUsagePercent) {
|
|
700
|
+
if (!hasPlanUsageLimit && !hasTotalUsagePercent && !flags.hasModelPools) {
|
|
680
701
|
throw "Total usage limit missing from API response."
|
|
681
702
|
}
|
|
682
703
|
|
|
@@ -734,7 +755,14 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
734
755
|
(su && typeof su.pooledLimit === "number" && su.pooledLimit > 0)
|
|
735
756
|
)
|
|
736
757
|
|
|
737
|
-
if (isTeamAccount) {
|
|
758
|
+
if (isTeamAccount && flags.hasModelPools) {
|
|
759
|
+
// A combined percentage cannot be reconstructed from independent pools.
|
|
760
|
+
if (hasTotalUsagePercent) lines.push(ctx.line.progress({
|
|
761
|
+
label: "Total usage", used: pu.totalPercentUsed, limit: 100,
|
|
762
|
+
format: { kind: "percent" }, resetsAt: ctx.util.toIso(usage.billingCycleEnd),
|
|
763
|
+
periodDurationMs: billingPeriodMs,
|
|
764
|
+
}))
|
|
765
|
+
} else if (isTeamAccount) {
|
|
738
766
|
if (!hasPlanUsageLimit) {
|
|
739
767
|
return null
|
|
740
768
|
}
|
|
@@ -761,7 +789,8 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
761
789
|
}))
|
|
762
790
|
}
|
|
763
791
|
|
|
764
|
-
|
|
792
|
+
const showModelPools = !(isTeamAccount && !flags.hasModelPools && pu.autoPercentUsed === 0 && pu.apiPercentUsed === 0)
|
|
793
|
+
if (showModelPools && typeof pu.autoPercentUsed === "number" && Number.isFinite(pu.autoPercentUsed) && pu.autoPercentUsed >= 0) {
|
|
765
794
|
lines.push(ctx.line.progress({
|
|
766
795
|
label: "Cursor Models",
|
|
767
796
|
used: pu.autoPercentUsed,
|
|
@@ -772,7 +801,7 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
772
801
|
}))
|
|
773
802
|
}
|
|
774
803
|
|
|
775
|
-
if (typeof pu.apiPercentUsed === "number" && Number.isFinite(pu.apiPercentUsed)) {
|
|
804
|
+
if (showModelPools && typeof pu.apiPercentUsed === "number" && Number.isFinite(pu.apiPercentUsed) && pu.apiPercentUsed >= 0) {
|
|
776
805
|
lines.push(ctx.line.progress({
|
|
777
806
|
label: "Other Models",
|
|
778
807
|
used: pu.apiPercentUsed,
|
|
@@ -1119,13 +1148,21 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
1119
1148
|
if (!Number.isFinite(percent) || percent < 0) return result
|
|
1120
1149
|
const resetMs = ctx.util.parseDateMs(usage.nextResetTimestampUtc)
|
|
1121
1150
|
const startMs = ctx.util.parseDateMs(usage.currentPeriodStart)
|
|
1151
|
+
const paid = usage.hasNonZeroIncludedLimit === true || usage.includedLimitZero === false
|
|
1152
|
+
const requestsPrimary = result.lines.some(item => item.type === 'progress' && item.label === 'Requests')
|
|
1153
|
+
if (usage.isUnified === true && paid && Number.isFinite(resetMs) && resetMs > Date.parse(ctx.nowIso) && !requestsPrimary) {
|
|
1154
|
+
result.lines = result.lines.filter(item => !['Total usage','Cursor Models','Other Models','Grok Bot usage'].includes(item.label))
|
|
1155
|
+
result.lines.unshift(ctx.line.progress({label:'Weekly',used:Math.min(100,percent),limit:100,format:{kind:'percent'},
|
|
1156
|
+
resetsAt:ctx.util.toIso(resetMs),periodDurationMs:7*24*60*60*1000}))
|
|
1157
|
+
return result
|
|
1158
|
+
}
|
|
1122
1159
|
const line = ctx.line.progress({
|
|
1123
1160
|
label: "Grok Bot usage",
|
|
1124
1161
|
used: Math.min(100, percent),
|
|
1125
1162
|
limit: 100,
|
|
1126
1163
|
format: { kind: "percent" },
|
|
1127
1164
|
resetsAt: Number.isFinite(resetMs) ? ctx.util.toIso(resetMs) : undefined,
|
|
1128
|
-
periodDurationMs: Number.isFinite(startMs) && Number.isFinite(resetMs) && resetMs > startMs
|
|
1165
|
+
periodDurationMs: paid ? 7*24*60*60*1000 : Number.isFinite(startMs) && Number.isFinite(resetMs) && resetMs > startMs
|
|
1129
1166
|
? resetMs - startMs : 7 * 24 * 60 * 60 * 1000,
|
|
1130
1167
|
})
|
|
1131
1168
|
let insertAt = result.lines.length
|
|
@@ -1155,7 +1192,7 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
1155
1192
|
|
|
1156
1193
|
if (!accessToken && !refreshTokenValue) {
|
|
1157
1194
|
ctx.host.log.error("probe failed: no access or refresh token in sqlite/keychain")
|
|
1158
|
-
throw "Not logged in. " + LOGIN_HINT
|
|
1195
|
+
throw "Not logged in. Cursor encrypted sign-ins require `agent login` for the stable CLI, or explicit provider credentials. " + LOGIN_HINT
|
|
1159
1196
|
}
|
|
1160
1197
|
|
|
1161
1198
|
ctx.host.log.info("tokens loaded from " + authSource + ": accessToken=" + (accessToken ? "yes" : "no") + " refreshToken=" + (refreshTokenValue ? "yes" : "no"))
|
|
@@ -1177,7 +1214,7 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
1177
1214
|
accessToken = refreshed
|
|
1178
1215
|
} else if (!accessToken) {
|
|
1179
1216
|
ctx.host.log.error("refresh failed and no access token available")
|
|
1180
|
-
throw "Not logged in. " + LOGIN_HINT
|
|
1217
|
+
throw "Not logged in. Cursor encrypted sign-ins require `agent login` for the stable CLI, or explicit provider credentials. " + LOGIN_HINT
|
|
1181
1218
|
}
|
|
1182
1219
|
}
|
|
1183
1220
|
|
|
@@ -1335,7 +1372,7 @@ globalThis.__OPENUSAGE_PLUGIN_REGISTRATION_ID__ = "cursor";
|
|
|
1335
1372
|
const hasPlanUsageLimit = hasPlanUsage &&
|
|
1336
1373
|
typeof usage.planUsage.limit === "number" &&
|
|
1337
1374
|
Number.isFinite(usage.planUsage.limit)
|
|
1338
|
-
const planUsageLimitMissing = hasPlanUsage && !hasPlanUsageLimit
|
|
1375
|
+
const planUsageLimitMissing = hasPlanUsage && !hasPlanUsageLimit && !getConnectUsageMetricFlags(usage).hasModelPools
|
|
1339
1376
|
const hasTotalUsagePercent = hasPlanUsage &&
|
|
1340
1377
|
typeof usage.planUsage.totalPercentUsed === "number" &&
|
|
1341
1378
|
Number.isFinite(usage.planUsage.totalPercentUsed)
|
|
@@ -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": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
|
|
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);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "exa",
|
|
4
|
+
"name": "Exa",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"entry": "plugin.js",
|
|
7
|
+
"enabledByDefault": false,
|
|
8
|
+
"supportedModes": [
|
|
9
|
+
"api"
|
|
10
|
+
],
|
|
11
|
+
"autoMode": "api",
|
|
12
|
+
"usageDashboardUrl": "https://dashboard.exa.ai",
|
|
13
|
+
"envVars": [
|
|
14
|
+
"EXA_SERVICE_KEY",
|
|
15
|
+
"EXA_API_KEY_ID"
|
|
16
|
+
],
|
|
17
|
+
"setupFields": [
|
|
18
|
+
{
|
|
19
|
+
"key": "EXA_API_KEY_ID",
|
|
20
|
+
"title": "API key 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": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
|
|
28
|
+
"path": "Sources/CodexBarCore/Resources/Plugins/exa.js",
|
|
29
|
+
"sha256": "36d2cbf9973e160f2e0d2548ff1f9bbf254f94c9a09710004c0718749e5cdfbd",
|
|
30
|
+
"license": "MIT"
|
|
31
|
+
}
|
|
32
|
+
}
|