@hashimkarim/usagestat-darwin-arm64 2.0.0-alpha.3 → 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 +1532 -134
- package/package.json +235 -2
- package/plugins/UPSTREAM-LICENSES.md +6 -2
- package/plugins/_provider-icons/LICENSE +21 -0
- package/plugins/_provider-icons/NOTICE +12 -0
- package/plugins/_provider-icons/licenses/CodexBar-MIT.txt +21 -0
- package/plugins/_provider-icons/licenses/LobeHub-MIT.txt +21 -0
- package/plugins/_provider-icons/licenses/UsageStat-Bar-MIT.txt +21 -0
- package/plugins/_provider-icons/manifest.json +1219 -0
- package/plugins/_provider-icons/provenance.json +269 -0
- package/plugins/_provider-icons/source.json +4 -0
- package/plugins/abacus-ai/icon-color.svg +18 -0
- 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/LICENSE +21 -0
- package/plugins/aixy/icon.svg +1 -0
- package/plugins/aixy/plugin.js +266 -0
- package/plugins/aixy/plugin.json +32 -0
- package/plugins/antigravity/plugin.js +189 -65
- package/plugins/antigravity-cli/icon-color.svg +1 -0
- package/plugins/antigravity-cli/icon.svg +1 -3
- package/plugins/antigravity-cli/plugin.js +32 -20
- package/plugins/antigravity-ide/icon-color.svg +1 -0
- package/plugins/antigravity-ide/icon.svg +1 -3
- package/plugins/antigravity-ide/plugin.js +19 -7
- package/plugins/atlascloud/LICENSE +21 -0
- package/plugins/atlascloud/icon-color.svg +1 -0
- package/plugins/atlascloud/icon.svg +1 -0
- package/plugins/atlascloud/plugin.js +54 -0
- package/plugins/atlascloud/plugin.json +24 -0
- package/plugins/augment/icon-color.svg +14 -0
- package/plugins/bifrost/LICENSE +21 -0
- package/plugins/bifrost/icon.svg +3 -0
- package/plugins/bifrost/plugin.js +366 -0
- package/plugins/bifrost/plugin.json +31 -0
- 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 +340 -153
- package/plugins/claude/plugin.json +1 -1
- 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/clinepass/plugin.js +19 -3
- package/plugins/codebuff/icon-color.svg +92 -0
- package/plugins/coderabbit/plugin.js +25 -0
- package/plugins/coderabbit/plugin.json +12 -0
- package/plugins/codex/plugin.js +15 -8
- package/plugins/codex/plugin.json +11 -2
- package/plugins/command-code/icon-color.svg +3 -0
- package/plugins/command-code/plugin.js +7 -3
- package/plugins/copilot/icon.svg +1 -1
- 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/crof/icon-color.svg +3 -0
- package/plugins/crofai/icon-color.svg +3 -0
- package/plugins/crofai/icon.svg +2 -15
- package/plugins/cursor/icon-color.svg +1 -0
- package/plugins/cursor/plugin.js +51 -14
- package/plugins/cursor-nightly/plugin.json +1 -1
- package/plugins/deepinfra/icon-color.svg +1 -0
- package/plugins/deepinfra/icon.svg +1 -4
- package/plugins/deepseek/plugin.js +150 -59
- package/plugins/deepseek/plugin.json +3 -1
- package/plugins/devin/plugin.js +3 -0
- package/plugins/devpass/LICENSE +21 -0
- package/plugins/devpass/icon.svg +3 -0
- package/plugins/devpass/plugin.js +120 -0
- package/plugins/devpass/plugin.json +24 -0
- package/plugins/elevenlabs/icon-color.svg +4 -0
- 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/factory/icon-color.svg +1 -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/fireworks-ai/icon-color.svg +1 -0
- package/plugins/fireworks-ai/icon.svg +1 -6
- 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 +21 -0
- package/plugins/gemini-apps/icon-color.svg +1 -0
- package/plugins/gemini-apps/icon.svg +1 -0
- package/plugins/gemini-apps/plugin.js +141 -0
- package/plugins/gemini-apps/plugin.json +25 -0
- package/plugins/gitkraken/LICENSE +21 -0
- package/plugins/gitkraken/icon.svg +2 -0
- package/plugins/gitkraken/plugin.js +158 -0
- package/plugins/gitkraken/plugin.json +32 -0
- 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/grok/icon-color.svg +1 -0
- package/plugins/groqcloud/icon-color.svg +1 -0
- package/plugins/helmcode/LICENSE +21 -0
- package/plugins/helmcode/icon.svg +5 -0
- package/plugins/helmcode/plugin.js +253 -0
- package/plugins/helmcode/plugin.json +32 -0
- package/plugins/huggingface/LICENSE +21 -0
- package/plugins/huggingface/icon-color.svg +1 -0
- package/plugins/huggingface/icon.svg +1 -0
- package/plugins/huggingface/plugin.js +298 -0
- package/plugins/huggingface/plugin.json +26 -0
- package/plugins/hyper/LICENSE +21 -0
- package/plugins/hyper/plugin.js +137 -0
- package/plugins/hyper/plugin.json +27 -0
- 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/kilo/icon-color.svg +1 -0
- 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/litellm/plugin.js +54 -3
- 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/LICENSE +21 -0
- package/plugins/llmman/icon.svg +4 -0
- package/plugins/llmman/plugin.js +138 -0
- package/plugins/llmman/plugin.json +31 -0
- package/plugins/longcat/icon-color.svg +1 -0
- package/plugins/longcat/icon.svg +1 -4
- package/plugins/manus/icon-color.svg +6 -0
- package/plugins/mimo/icon-color.svg +4 -0
- package/plugins/mimo/icon.svg +4 -1
- package/plugins/mistral/plugin.js +164 -27
- package/plugins/moonshot/icon-color.svg +1 -0
- 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/LICENSE +21 -0
- package/plugins/muse/icon.svg +3 -0
- package/plugins/muse/plugin.js +288 -0
- package/plugins/muse/plugin.json +34 -0
- 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/LICENSE +21 -0
- package/plugins/nous/icon-color.svg +1 -0
- package/plugins/nous/icon.svg +1 -0
- package/plugins/nous/plugin.js +129 -0
- package/plugins/nous/plugin.json +32 -0
- package/plugins/ollama/icon-color.svg +1 -0
- package/plugins/ollama/plugin.js +58 -0
- package/plugins/openai-api/icon-color.svg +1 -0
- package/plugins/opencode/icon-color.svg +1 -0
- package/plugins/opencode-go/icon-color.svg +1 -0
- package/plugins/opencode-go/plugin.js +104 -37
- 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/openrouter/icon-color.svg +1 -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/pi/plugin.js +113 -0
- package/plugins/pi/plugin.json +11 -0
- package/plugins/qwencloud/LICENSE +21 -0
- package/plugins/qwencloud/icon-color.svg +1 -0
- package/plugins/qwencloud/icon.svg +1 -4
- package/plugins/qwencloud/plugin.js +197 -0
- package/plugins/qwencloud/plugin.json +17 -0
- package/plugins/raycast/LICENSE +21 -0
- package/plugins/raycast/icon.svg +4 -0
- package/plugins/raycast/plugin.js +179 -0
- package/plugins/raycast/plugin.json +32 -0
- package/plugins/replicate/LICENSE +21 -0
- package/plugins/replicate/icon-color.svg +1 -0
- package/plugins/replicate/icon.svg +1 -0
- package/plugins/replicate/plugin.js +170 -0
- package/plugins/replicate/plugin.json +25 -0
- 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/icon-color.svg +14 -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/LICENSE +21 -0
- package/plugins/typesafe/icon.svg +4 -0
- package/plugins/typesafe/plugin.js +181 -0
- package/plugins/typesafe/plugin.json +25 -0
- package/plugins/v0/LICENSE +21 -0
- package/plugins/v0/icon-color.svg +1 -0
- package/plugins/v0/icon.svg +1 -0
- package/plugins/v0/plugin.js +219 -0
- package/plugins/v0/plugin.json +32 -0
- package/plugins/venice/plugin.js +50 -1
- package/plugins/venice/plugin.json +2 -1
- package/plugins/vercel/LICENSE +21 -0
- package/plugins/vercel/icon-color.svg +1 -0
- package/plugins/vercel/icon.svg +1 -0
- package/plugins/vercel/plugin.js +202 -0
- package/plugins/vercel/plugin.json +54 -0
- package/plugins/windsurf/icon-color.svg +1 -0
- 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/icon-color.svg +1 -0
- package/plugins/xai/icon.svg +1 -7
- 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/LICENSE +21 -0
- package/plugins/xkiro/icon.svg +1 -0
- package/plugins/xkiro/plugin.js +104 -0
- package/plugins/xkiro/plugin.json +24 -0
- package/plugins/zai/icon-color.svg +1 -0
- package/plugins/zai/plugin.js +5 -1
- package/plugins/zenmux/icon-color.svg +1 -0
- package/plugins/zenmux/icon.svg +1 -3
- package/usagestat +0 -0
- package/usagestatd +0 -0
- package/plugins/cursor-nightly/plugin.js +0 -1416
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
|
|
2
|
+
globalThis.__usagestat_bundled_options = {"labels":["Budget","Secondary budget","Additional"],"defaults":{"AIXY_BASE_URL":"https://api.aixy-gateway.com"},"autoMode":"api"};
|
|
3
|
+
(function(defineProvider) {
|
|
4
|
+
// BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/aixy.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: "aixy",
|
|
28
|
+
name: "Aixy",
|
|
29
|
+
endpoints: [{ setting: "AIXY_BASE_URL", policy: "https-or-private-network-http" }],
|
|
30
|
+
auth: { type: "bearer", secret: "AIXY_API_KEY" },
|
|
31
|
+
settings: [
|
|
32
|
+
{ key: "AIXY_API_KEY", title: "API key", type: "secure" },
|
|
33
|
+
{ key: "AIXY_BASE_URL", title: "Base URL", type: "plain" },
|
|
34
|
+
],
|
|
35
|
+
capabilities: ["http-status"],
|
|
36
|
+
async fetchUsage(ctx) {
|
|
37
|
+
const fail = (message) => {
|
|
38
|
+
throw ctx.fail.parseFailure(`Aixy: ${message}`);
|
|
39
|
+
};
|
|
40
|
+
const object = (value) => {
|
|
41
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return fail("expected an object");
|
|
42
|
+
return value;
|
|
43
|
+
};
|
|
44
|
+
const text = (value) => {
|
|
45
|
+
if (typeof value !== "string" || !value.trim()) return fail("invalid text");
|
|
46
|
+
return value.trim();
|
|
47
|
+
};
|
|
48
|
+
const bounded = (value) => Array.from(value).slice(0, 120).join("");
|
|
49
|
+
const number = (value) => {
|
|
50
|
+
if (value == null) return undefined;
|
|
51
|
+
if (typeof value === "string" && /^\d+(?:\.\d+)?$/u.test(value)) value = Number(value);
|
|
52
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) return fail("invalid amount");
|
|
53
|
+
return value;
|
|
54
|
+
};
|
|
55
|
+
const count = (value) => {
|
|
56
|
+
const parsed = number(value);
|
|
57
|
+
if (parsed === undefined || !Number.isSafeInteger(parsed)) return fail("invalid count");
|
|
58
|
+
return parsed;
|
|
59
|
+
};
|
|
60
|
+
const date = (value) => {
|
|
61
|
+
if (value == null) return undefined;
|
|
62
|
+
let parsed;
|
|
63
|
+
try {
|
|
64
|
+
parsed = ctx.date.iso(text(value));
|
|
65
|
+
} catch (error) {
|
|
66
|
+
void error;
|
|
67
|
+
return fail("invalid date");
|
|
68
|
+
}
|
|
69
|
+
if (!Number.isFinite(parsed.getTime())) return fail("invalid date");
|
|
70
|
+
return parsed;
|
|
71
|
+
};
|
|
72
|
+
const base = (ctx.settings.get("AIXY_BASE_URL") || "https://api.aixy-gateway.com").replace(/\/+$/u, "");
|
|
73
|
+
if (/[?#]/u.test(base)) throw ctx.fail.apiFailure("Aixy Base URL must not contain a query or fragment.");
|
|
74
|
+
const endpoint = `${base.replace(/\/v1$/u, "")}/v1/usage`;
|
|
75
|
+
const response = await ctx.http.get(endpoint);
|
|
76
|
+
const message = `Aixy usage request failed (HTTP ${response.status}).`;
|
|
77
|
+
if (response.status === 401)
|
|
78
|
+
throw ctx.fail.authenticationExpired("Aixy rejected the API key. Check its expiry or revocation.");
|
|
79
|
+
if (response.status === 403) throw ctx.fail.permissionDenied("Aixy denied access to this key's usage.");
|
|
80
|
+
if (response.status === 404)
|
|
81
|
+
throw ctx.fail.apiFailure(
|
|
82
|
+
"This Aixy installation does not provide the usage endpoint. Update the gateway or check its Base URL.",
|
|
83
|
+
);
|
|
84
|
+
if (response.status === 429) throw ctx.fail.rateLimited(message);
|
|
85
|
+
if (response.status >= 500) throw ctx.fail.providerUnavailable(message);
|
|
86
|
+
if (response.status < 200 || response.status >= 300) throw ctx.fail.apiFailure(message);
|
|
87
|
+
let decoded;
|
|
88
|
+
try {
|
|
89
|
+
decoded = JSON.parse(response.bodyText);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
void error;
|
|
92
|
+
return fail("invalid usage JSON");
|
|
93
|
+
}
|
|
94
|
+
const root = object(decoded);
|
|
95
|
+
if (root.object !== "key.usage" || root.currency !== "USD") return fail("unsupported usage contract");
|
|
96
|
+
const asOf = date(root.as_of);
|
|
97
|
+
if (!asOf) return fail("missing observation time");
|
|
98
|
+
const key = object(root.key);
|
|
99
|
+
const keyID = text(key.id);
|
|
100
|
+
if (!Array.isArray(root.budgets)) return fail("invalid budgets");
|
|
101
|
+
const labels = {
|
|
102
|
+
organization: "Organization",
|
|
103
|
+
project: "Project",
|
|
104
|
+
team: "Team",
|
|
105
|
+
user: "User",
|
|
106
|
+
api_key: "Key",
|
|
107
|
+
daily: "Daily",
|
|
108
|
+
weekly: "Weekly",
|
|
109
|
+
monthly: "Monthly",
|
|
110
|
+
lifetime: "Lifetime",
|
|
111
|
+
};
|
|
112
|
+
if (root.budgets.length > 64) return fail("too many budgets");
|
|
113
|
+
const ids = new Set();
|
|
114
|
+
const budgets = root.budgets
|
|
115
|
+
.map((raw) => {
|
|
116
|
+
const budget = object(raw),
|
|
117
|
+
id = text(budget.id);
|
|
118
|
+
if (ids.has(id)) return fail("duplicate budget");
|
|
119
|
+
ids.add(id);
|
|
120
|
+
const scope = text(budget.scope),
|
|
121
|
+
interval = text(budget.interval);
|
|
122
|
+
if (
|
|
123
|
+
!["organization", "project", "team", "user", "api_key"].includes(scope) ||
|
|
124
|
+
!["daily", "weekly", "monthly", "lifetime"].includes(interval)
|
|
125
|
+
)
|
|
126
|
+
return fail("invalid budget scope or interval");
|
|
127
|
+
if (budget.enforcement !== "hard" && budget.enforcement !== "monitor") return fail("invalid enforcement");
|
|
128
|
+
if (typeof budget.shared !== "boolean") return fail("invalid shared scope");
|
|
129
|
+
const limit = number(budget.limit_usd);
|
|
130
|
+
if (limit === undefined || limit <= 0) return fail("invalid budget limit");
|
|
131
|
+
if (
|
|
132
|
+
!Array.isArray(budget.applies_to) ||
|
|
133
|
+
!budget.applies_to.length ||
|
|
134
|
+
budget.applies_to.some(
|
|
135
|
+
(item) => object(item).api_key_id !== keyID || object(item).project_id !== key.project_id,
|
|
136
|
+
)
|
|
137
|
+
)
|
|
138
|
+
return fail("budget belongs to another key");
|
|
139
|
+
const availability = object(budget.availability);
|
|
140
|
+
const hard = budget.enforcement === "hard";
|
|
141
|
+
if (!["available", "unavailable", "not_enforced"].includes(text(availability.status)))
|
|
142
|
+
return fail("invalid availability");
|
|
143
|
+
if (!["available", "unavailable"].includes(text(budget.spend_status))) return fail("invalid spend status");
|
|
144
|
+
const known = hard ? availability.status === "available" : budget.spend_status === "available";
|
|
145
|
+
const spent = number(hard ? availability.spent_usd : budget.spend_usd);
|
|
146
|
+
const reserved = hard ? number(availability.reserved_usd) : 0;
|
|
147
|
+
const remaining = number(hard ? availability.remaining_usd : budget.remaining_usd);
|
|
148
|
+
if (known && (spent === undefined || reserved === undefined || remaining === undefined))
|
|
149
|
+
return fail("incomplete budget balance");
|
|
150
|
+
const used = known ? spent + reserved : undefined;
|
|
151
|
+
if (used !== undefined && !Number.isFinite(used)) return fail("budget amount overflow");
|
|
152
|
+
const startsAt = date(budget.starts_at),
|
|
153
|
+
resetsAt = date(budget.resets_at);
|
|
154
|
+
if (startsAt && resetsAt && resetsAt <= startsAt) return fail("invalid budget period");
|
|
155
|
+
const minutes = startsAt && resetsAt ? (resetsAt.getTime() - startsAt.getTime()) / 60000 : undefined;
|
|
156
|
+
const title = bounded(
|
|
157
|
+
`${labels[scope]} · ${labels[interval]} · ${budget.shared ? "Shared" : "Personal"} · ${hard ? "Hard" : "Monitor"}`,
|
|
158
|
+
);
|
|
159
|
+
return {
|
|
160
|
+
id: `aixy-${id}`,
|
|
161
|
+
title,
|
|
162
|
+
known,
|
|
163
|
+
hard,
|
|
164
|
+
spent,
|
|
165
|
+
reserved,
|
|
166
|
+
remaining,
|
|
167
|
+
limit,
|
|
168
|
+
used,
|
|
169
|
+
window: {
|
|
170
|
+
usedPercent: known ? ctx.pct(used, limit) : 0,
|
|
171
|
+
windowMinutes: minutes !== undefined && Number.isSafeInteger(minutes) && minutes > 0 ? minutes : undefined,
|
|
172
|
+
resetsAt,
|
|
173
|
+
resetDescription: `${title} · ${known ? `${ctx.format.usd(remaining)} remaining` : "Unavailable"}`,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
})
|
|
177
|
+
.sort(
|
|
178
|
+
(a, b) =>
|
|
179
|
+
Number(b.hard) - Number(a.hard) ||
|
|
180
|
+
Number(b.known) - Number(a.known) ||
|
|
181
|
+
b.window.usedPercent - a.window.usedPercent ||
|
|
182
|
+
(a.id < b.id ? -1 : a.id > b.id ? 1 : 0),
|
|
183
|
+
);
|
|
184
|
+
const known = budgets.filter((budget) => budget.known);
|
|
185
|
+
const selected = known.slice(0, 2);
|
|
186
|
+
const details = [
|
|
187
|
+
{
|
|
188
|
+
title: "Aixy key",
|
|
189
|
+
rows: [
|
|
190
|
+
{ label: "Key", value: bounded(key.name == null ? keyID : text(key.name)) },
|
|
191
|
+
{
|
|
192
|
+
label: "Project",
|
|
193
|
+
value: bounded(key.project_name == null ? text(key.project_id) : text(key.project_name)),
|
|
194
|
+
},
|
|
195
|
+
{ label: "Observed", value: asOf.toISOString() },
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
];
|
|
199
|
+
for (let offset = 0; offset < budgets.length; offset += 24)
|
|
200
|
+
details.push({
|
|
201
|
+
title: "Applicable budgets",
|
|
202
|
+
rows: budgets.slice(offset, offset + 24).map((budget) => ({
|
|
203
|
+
label: budget.title,
|
|
204
|
+
value: budget.known
|
|
205
|
+
? `${ctx.format.usd(budget.remaining)} / ${ctx.format.usd(budget.limit)} remaining`
|
|
206
|
+
: "Unavailable",
|
|
207
|
+
secondaryValue: budget.known
|
|
208
|
+
? `${ctx.format.usd(budget.spent)} spent${budget.hard ? ` · ${ctx.format.usd(budget.reserved)} reserved` : ""}`
|
|
209
|
+
: undefined,
|
|
210
|
+
progress: budget.known ? budget.window.usedPercent / 100 : undefined,
|
|
211
|
+
usageValue: budget.used,
|
|
212
|
+
})),
|
|
213
|
+
});
|
|
214
|
+
let cost;
|
|
215
|
+
let confidence = "unknown";
|
|
216
|
+
if (root.usage != null) {
|
|
217
|
+
const usage = object(root.usage);
|
|
218
|
+
if (usage.window !== "7d") return fail("unsupported reporting period");
|
|
219
|
+
const requests = count(usage.requests),
|
|
220
|
+
tokens = count(usage.total_tokens);
|
|
221
|
+
const attributed = count(usage.attributed_requests),
|
|
222
|
+
partial = count(usage.partial_requests);
|
|
223
|
+
const spend = number(usage.spend_usd);
|
|
224
|
+
if (attributed > requests || partial > attributed || (spend !== undefined && spend > 0 && attributed === 0))
|
|
225
|
+
return fail("invalid attribution coverage");
|
|
226
|
+
if (spend !== undefined) {
|
|
227
|
+
cost = { used: spend, currency: "USD", period: "Last 7 days · attributed" };
|
|
228
|
+
confidence = "estimated";
|
|
229
|
+
}
|
|
230
|
+
details.push({
|
|
231
|
+
title: "Last 7 days · this key",
|
|
232
|
+
rows: [
|
|
233
|
+
{ label: "Requests", value: ctx.format.number(requests) },
|
|
234
|
+
{ label: "Tokens", value: ctx.format.number(tokens) },
|
|
235
|
+
{ label: "Attributed spend", value: spend === undefined ? "Unavailable" : ctx.format.usd(spend) },
|
|
236
|
+
{
|
|
237
|
+
label: "Cost coverage",
|
|
238
|
+
value: `${attributed} / ${requests} requests`,
|
|
239
|
+
secondaryValue: `${partial} partial`,
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
});
|
|
243
|
+
} else {
|
|
244
|
+
details.push({ title: "Last 7 days · this key", rows: [{ label: "Usage", value: "Unavailable" }] });
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
primary: _optionalChain([selected, "access", (_) => _[0], "optionalAccess", (_2) => _2.window]),
|
|
248
|
+
secondary: _optionalChain([selected, "access", (_3) => _3[1], "optionalAccess", (_4) => _4.window]),
|
|
249
|
+
extraWindows: budgets
|
|
250
|
+
.filter((budget) => !selected.includes(budget))
|
|
251
|
+
.map((budget) => ({
|
|
252
|
+
id: budget.id,
|
|
253
|
+
title: budget.title,
|
|
254
|
+
usageKnown: budget.known,
|
|
255
|
+
window: budget.window,
|
|
256
|
+
})),
|
|
257
|
+
cost,
|
|
258
|
+
details,
|
|
259
|
+
dataConfidence: confidence,
|
|
260
|
+
identity: { accountID: keyID, loginMethod: "API key" },
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// END UPSTREAM
|
|
266
|
+
})(globalThis.defineProvider);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "aixy",
|
|
4
|
+
"name": "Aixy",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"entry": "plugin.js",
|
|
7
|
+
"enabledByDefault": false,
|
|
8
|
+
"supportedModes": [
|
|
9
|
+
"api"
|
|
10
|
+
],
|
|
11
|
+
"autoMode": "api",
|
|
12
|
+
"usageDashboardUrl": "https://dash.aixy-gateway.com",
|
|
13
|
+
"envVars": [
|
|
14
|
+
"AIXY_API_KEY",
|
|
15
|
+
"AIXY_BASE_URL"
|
|
16
|
+
],
|
|
17
|
+
"setupFields": [
|
|
18
|
+
{
|
|
19
|
+
"key": "AIXY_BASE_URL",
|
|
20
|
+
"title": "Base URL",
|
|
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/aixy.js",
|
|
29
|
+
"sha256": "975d98525503e286f9425c2a1d64fe00da8e2fdc0b00890e15c2cbcb9a37c125",
|
|
30
|
+
"license": "MIT"
|
|
31
|
+
}
|
|
32
|
+
}
|