@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
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
var USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/124.0.0.0 Safari/537.36"
|
|
4
4
|
|
|
5
5
|
function getCookieHeader(ctx) {
|
|
6
|
-
var
|
|
6
|
+
var provider = ctx.provider || {}
|
|
7
|
+
var raw = Object.prototype.hasOwnProperty.call(provider, 'cookieHeader') ? provider.cookieHeader :
|
|
8
|
+
provider.instanceId && provider.instanceId !== 'mistral' ? null : ctx.host.env.get("MISTRAL_COOKIE")
|
|
7
9
|
if (!raw || !raw.trim()) {
|
|
8
10
|
throw "Set MISTRAL_COOKIE to your cookie header from admin.mistral.ai. Include csrftoken if present."
|
|
9
11
|
}
|
|
@@ -27,34 +29,51 @@
|
|
|
27
29
|
return { month: now.getUTCMonth() + 1, year: now.getUTCFullYear() }
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
function aggregateModels(models, prices) {
|
|
32
|
+
function aggregateModels(models, prices, countsTokens) {
|
|
31
33
|
var total = 0
|
|
34
|
+
var complete = true
|
|
32
35
|
var inputTokens = 0
|
|
33
36
|
var outputTokens = 0
|
|
34
|
-
if (!models) return { cost: 0, inputTokens: 0, outputTokens: 0 }
|
|
37
|
+
if (!models) return { cost: 0, complete: true, inputTokens: 0, outputTokens: 0 }
|
|
35
38
|
var keys = Object.keys(models)
|
|
36
39
|
for (var i = 0; i < keys.length; i++) {
|
|
37
40
|
var data = models[keys[i]]
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
for (var entries of [data.input, data.output, data.cached]) {
|
|
42
|
+
var sum = sumEntries(entries, prices)
|
|
43
|
+
total += sum.cost
|
|
44
|
+
complete = complete && sum.complete
|
|
45
|
+
}
|
|
46
|
+
if (countsTokens !== false) {
|
|
47
|
+
inputTokens += countEntries(data.input)
|
|
48
|
+
outputTokens += countEntries(data.output)
|
|
49
|
+
}
|
|
43
50
|
}
|
|
44
|
-
|
|
51
|
+
if (!Number.isFinite(total)) throw new Error('Invalid Mistral billing total.')
|
|
52
|
+
return { cost: total, complete: complete, inputTokens: inputTokens, outputTokens: outputTokens }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function priceKey(entry, unqualified) {
|
|
56
|
+
return JSON.stringify([entry.event_type ?? null, entry.billing_metric ?? null, entry.billing_group ?? null,
|
|
57
|
+
unqualified ? null : entry.api_zone ?? null, unqualified ? null : entry.service_tier ?? null])
|
|
45
58
|
}
|
|
46
59
|
|
|
47
60
|
function sumEntries(entries, prices) {
|
|
48
|
-
if (!entries) return 0
|
|
61
|
+
if (!entries) return { cost: 0, complete: true }
|
|
49
62
|
var total = 0
|
|
63
|
+
var complete = true
|
|
50
64
|
for (var i = 0; i < entries.length; i++) {
|
|
51
65
|
var e = entries[i]
|
|
52
66
|
var paid = e.value_paid != null ? e.value_paid : (e.value || 0)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
67
|
+
if (typeof paid !== 'number' || !Number.isFinite(paid) || paid < 0)
|
|
68
|
+
throw new Error('Invalid Mistral billed quantity.')
|
|
69
|
+
if (paid === 0) continue
|
|
70
|
+
// A different event type, region or tier must never supply the price.
|
|
71
|
+
// Legacy unqualified rows are the only supported fallback.
|
|
72
|
+
var price = prices.get(priceKey(e, false)) ?? prices.get(priceKey(e, true))
|
|
73
|
+
if (price === undefined) complete = false
|
|
74
|
+
else total += paid * price
|
|
56
75
|
}
|
|
57
|
-
return total
|
|
76
|
+
return { cost: total, complete: complete }
|
|
58
77
|
}
|
|
59
78
|
|
|
60
79
|
function countEntries(entries) {
|
|
@@ -62,24 +81,124 @@
|
|
|
62
81
|
var total = 0
|
|
63
82
|
for (var i = 0; i < entries.length; i++) {
|
|
64
83
|
var e = entries[i]
|
|
65
|
-
total += e.
|
|
84
|
+
total += Number(e.value != null ? e.value : (e.value_paid || 0))
|
|
66
85
|
}
|
|
86
|
+
if (!Number.isSafeInteger(total) || total < 0) throw new Error('Invalid Mistral token total.')
|
|
67
87
|
return total
|
|
68
88
|
}
|
|
69
89
|
|
|
70
90
|
function buildPriceIndex(prices) {
|
|
71
|
-
var index =
|
|
91
|
+
var index = new Map()
|
|
72
92
|
if (!prices) return index
|
|
73
93
|
for (var i = 0; i < prices.length; i++) {
|
|
74
94
|
var p = prices[i]
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
95
|
+
var validPrice = typeof p.price === 'number' || (typeof p.price === 'string' && p.price.trim() !== '')
|
|
96
|
+
var price = validPrice ? Number(p.price) : NaN
|
|
97
|
+
if (p.billing_metric && p.billing_group && Number.isFinite(price) && price >= 0) {
|
|
98
|
+
index.set(priceKey(p, false), price)
|
|
78
99
|
}
|
|
79
100
|
}
|
|
80
101
|
return index
|
|
81
102
|
}
|
|
82
103
|
|
|
104
|
+
function subscriptionBudgets(html) {
|
|
105
|
+
if (typeof html !== 'string' || html.length > 2 * 1024 * 1024) throw new Error('Invalid subscription page.')
|
|
106
|
+
var chunks = [], marker = 'self.__next_f.push(', cursor = 0
|
|
107
|
+
while ((cursor = html.indexOf(marker, cursor)) >= 0) {
|
|
108
|
+
cursor += marker.length
|
|
109
|
+
var start = cursor, stack = [], quoted = false, escaped = false
|
|
110
|
+
while (/\s/.test(html[start] || '') && start < html.length) start++
|
|
111
|
+
if (html[start] !== '[') continue
|
|
112
|
+
for (var end = start; end < html.length; end++) {
|
|
113
|
+
var ch = html[end]
|
|
114
|
+
if (quoted) { if (escaped) escaped = false; else if (ch === '\\') escaped = true; else if (ch === '"') quoted = false }
|
|
115
|
+
else if (ch === '"') quoted = true
|
|
116
|
+
else if (ch === '[' || ch === '{') stack.push(ch === '[' ? ']' : '}')
|
|
117
|
+
else if (ch === ']' || ch === '}') {
|
|
118
|
+
if (stack.pop() !== ch) throw new Error('Invalid subscription record.')
|
|
119
|
+
if (!stack.length) {
|
|
120
|
+
var value = JSON.parse(html.slice(start,end+1))
|
|
121
|
+
if (value[0] === 1 && typeof value[1] === 'string') chunks.push(value[1])
|
|
122
|
+
cursor = end+1; break
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Flight's text/binary records are byte-counted and may contain fake JSON rows.
|
|
128
|
+
var stream = encodeURIComponent(chunks.join('')).replace(/%([0-9A-F]{2})/g, function(_,hex){return String.fromCharCode(parseInt(hex,16))})
|
|
129
|
+
var found = new Map()
|
|
130
|
+
function budget(raw) {
|
|
131
|
+
if (!raw || typeof raw.usage_percentage !== 'number' || !Number.isFinite(raw.usage_percentage) || raw.usage_percentage < 0 ||
|
|
132
|
+
typeof raw.initial_budget !== 'number' || !Number.isFinite(raw.initial_budget) || raw.initial_budget <= 0 ||
|
|
133
|
+
!/^[A-Za-z]{3}$/.test(raw.currency || '')) return null
|
|
134
|
+
return {percent:raw.usage_percentage,limit:raw.initial_budget,currency:raw.currency.toUpperCase(),reset:raw.reset_at || null}
|
|
135
|
+
}
|
|
136
|
+
function collect(value, depth) {
|
|
137
|
+
if (depth > 64) throw new Error('Subscription record too deep.')
|
|
138
|
+
if (!value || typeof value !== 'object') return
|
|
139
|
+
if (value.budget) {
|
|
140
|
+
var pair = [budget(value.budget.api_budget),budget(value.budget.vibe_budget)]
|
|
141
|
+
if (pair.some(Boolean)) found.set(JSON.stringify(pair),pair)
|
|
142
|
+
}
|
|
143
|
+
for (var child of Object.values(value)) collect(child,depth+1)
|
|
144
|
+
}
|
|
145
|
+
cursor = 0
|
|
146
|
+
while (cursor < stream.length) {
|
|
147
|
+
var newline = stream.indexOf('\n',cursor); if (newline < 0) newline = stream.length
|
|
148
|
+
var row = stream.slice(cursor,newline), match = /^[0-9a-f]+:/i.exec(row)
|
|
149
|
+
if (!match) { cursor = newline+1; continue }
|
|
150
|
+
var body = row.slice(match[0].length)
|
|
151
|
+
if (/^[TAOoUSsLlGgMmV]/.test(body)) {
|
|
152
|
+
var length = /^[TAOoUSsLlGgMmV]([0-9a-f]+),/i.exec(body)
|
|
153
|
+
if (!length) throw new Error('Invalid Flight length.')
|
|
154
|
+
cursor += match[0].length+length[0].length+parseInt(length[1],16)
|
|
155
|
+
if (cursor > stream.length) throw new Error('Incomplete Flight record.')
|
|
156
|
+
continue
|
|
157
|
+
}
|
|
158
|
+
if (/^[\[{]/.test(body)) {
|
|
159
|
+
var text = decodeURIComponent(Array.from(body,function(c){return '%'+c.charCodeAt(0).toString(16).padStart(2,'0')}).join(''))
|
|
160
|
+
collect(JSON.parse(text),0)
|
|
161
|
+
}
|
|
162
|
+
cursor = newline+1
|
|
163
|
+
}
|
|
164
|
+
if (found.size !== 1) throw new Error('Subscription budgets absent or ambiguous.')
|
|
165
|
+
return found.values().next().value
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function optionalAllowances(ctx, headers, cookie, csrf, lines) {
|
|
169
|
+
var hasVibe = false
|
|
170
|
+
try {
|
|
171
|
+
var page = ctx.host.http.request({method:'GET',url:BASE_URL+'/subscription',headers:headers,timeoutMs:3000})
|
|
172
|
+
if (page.status === 200) subscriptionBudgets(page.bodyText).forEach(function(b,index){
|
|
173
|
+
if (!b) return
|
|
174
|
+
var used = b.limit*b.percent/100
|
|
175
|
+
if (!Number.isFinite(used)) return
|
|
176
|
+
var reset = ctx.util.toIso(b.reset)
|
|
177
|
+
lines.push(ctx.line.progress({label:index?'Monthly Plan':'Included API',used:b.percent,limit:100,
|
|
178
|
+
format:{kind:'percent'},resetsAt:reset || undefined,
|
|
179
|
+
detail:b.currency+' '+used.toFixed(2)+' / '+b.limit.toFixed(2)}))
|
|
180
|
+
if (index) hasVibe = true
|
|
181
|
+
})
|
|
182
|
+
} catch (_) {}
|
|
183
|
+
if (!hasVibe && csrf) try {
|
|
184
|
+
var minimal = cookie.split(';').map(function(p){return p.trim()}).filter(function(p){return /^(csrftoken|ory_session_[^=]+)=/.test(p)}).join('; ')
|
|
185
|
+
var url = 'https://console.mistral.ai/api-ui/trpc/billing.vibeUsage?batch=1&input='+encodeURIComponent(JSON.stringify({'0':{json:null,meta:{values:['undefined'],v:1}}}))
|
|
186
|
+
var resp = ctx.host.http.request({method:'GET',url:url,headers:{Cookie:minimal,'X-CSRFTOKEN':csrf,Accept:'application/json'},timeoutMs:2000})
|
|
187
|
+
var vibe = resp.status===200 ? ctx.util.tryParseJson(resp.bodyText)?.[0]?.result?.data?.json : null
|
|
188
|
+
if (typeof vibe?.usage_percentage==='number' && vibe.usage_percentage>=0 && vibe.usage_percentage<=100)
|
|
189
|
+
lines.push(ctx.line.progress({label:'Monthly Plan',used:vibe.usage_percentage,limit:100,format:{kind:'percent'},resetsAt:ctx.util.toIso(vibe.reset_at) || undefined}))
|
|
190
|
+
} catch (_) {}
|
|
191
|
+
try {
|
|
192
|
+
var credits = ctx.util.requestJson({method:'GET',url:BASE_URL+'/api/billing/credits',headers:headers,timeoutMs:2000})
|
|
193
|
+
var data = credits.json
|
|
194
|
+
if (credits.resp.status!==200 || typeof data?.wallet_amount!=='number' || !/^[A-Za-z]{3}$/.test(data.currency || '')) return
|
|
195
|
+
var values = [data.wallet_amount,data.credit_notes_amount ?? 0,data.ongoing_usage_balance ?? 0]
|
|
196
|
+
if (!values.every(function(n){return typeof n==='number'&&Number.isFinite(n)})) return
|
|
197
|
+
var amount = values[0]+values[1]-values[2]
|
|
198
|
+
if (Number.isFinite(amount)) lines.push(ctx.line.text({label:'Credit balance',value:data.currency.toUpperCase()+' '+amount.toFixed(2)}))
|
|
199
|
+
} catch (_) {}
|
|
200
|
+
}
|
|
201
|
+
|
|
83
202
|
function probe(ctx) {
|
|
84
203
|
var cookieHeader = getCookieHeader(ctx)
|
|
85
204
|
var csrf = extractCsrf(cookieHeader)
|
|
@@ -116,36 +235,54 @@
|
|
|
116
235
|
var symbol = billing.currency_symbol || "€"
|
|
117
236
|
|
|
118
237
|
var totalCost = 0
|
|
238
|
+
var completeCost = true
|
|
119
239
|
var totalInput = 0
|
|
120
240
|
var totalOutput = 0
|
|
121
241
|
|
|
122
|
-
|
|
123
|
-
|
|
242
|
+
var completions = [billing.completion, billing.chat, billing.vibe_code && billing.vibe_code.completion]
|
|
243
|
+
for (var c = 0; c < completions.length; c++) {
|
|
244
|
+
if (!completions[c] || !completions[c].models) continue
|
|
245
|
+
var r = aggregateModels(completions[c].models, prices)
|
|
124
246
|
totalCost += r.cost; totalInput += r.inputTokens; totalOutput += r.outputTokens
|
|
247
|
+
completeCost = completeCost && r.complete
|
|
125
248
|
}
|
|
126
249
|
|
|
127
250
|
var extras = [billing.ocr, billing.connectors, billing.audio]
|
|
128
251
|
for (var i = 0; i < extras.length; i++) {
|
|
129
252
|
if (extras[i] && extras[i].models) {
|
|
130
|
-
|
|
253
|
+
var extra = aggregateModels(extras[i].models, prices, false)
|
|
254
|
+
totalCost += extra.cost
|
|
255
|
+
completeCost = completeCost && extra.complete
|
|
131
256
|
}
|
|
132
257
|
}
|
|
133
258
|
|
|
134
259
|
if (billing.libraries_api) {
|
|
135
260
|
var lib = billing.libraries_api
|
|
136
|
-
|
|
137
|
-
|
|
261
|
+
for (var category of [lib.pages, lib.tokens]) {
|
|
262
|
+
var extra = aggregateModels(category && category.models, prices, false)
|
|
263
|
+
totalCost += extra.cost
|
|
264
|
+
completeCost = completeCost && extra.complete
|
|
265
|
+
}
|
|
138
266
|
}
|
|
139
267
|
|
|
140
|
-
|
|
268
|
+
if (billing.fine_tuning) for (var category of [billing.fine_tuning.training, billing.fine_tuning.storage]) {
|
|
269
|
+
var extra = aggregateModels(category, prices, false)
|
|
270
|
+
totalCost += extra.cost
|
|
271
|
+
completeCost = completeCost && extra.complete
|
|
272
|
+
}
|
|
273
|
+
if (!Number.isFinite(totalCost)) throw new Error('Invalid Mistral billing total.')
|
|
274
|
+
var costStr = symbol + totalCost.toFixed(4) + (completeCost ? "" : "+") + " this month (" + currency + ")"
|
|
141
275
|
var tokenDetail = totalInput + " in / " + totalOutput + " out tokens"
|
|
142
276
|
|
|
143
277
|
var lines = [
|
|
144
|
-
ctx.line.text({ label: "Monthly spend", value: costStr
|
|
278
|
+
ctx.line.text({ label: "Monthly spend", value: costStr,
|
|
279
|
+
subtitle: completeCost ? undefined : "Partial total: some billing rows have no matching price." }),
|
|
145
280
|
ctx.line.text({ label: "Tokens", value: tokenDetail }),
|
|
146
281
|
]
|
|
147
282
|
|
|
148
|
-
|
|
283
|
+
optionalAllowances(ctx,headers,cookieHeader,csrf,lines)
|
|
284
|
+
|
|
285
|
+
return { source:'web', lines: lines }
|
|
149
286
|
}
|
|
150
287
|
|
|
151
288
|
globalThis.__openusage_plugin = { id: "mistral", probe: probe }
|
|
@@ -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>MoonshotAI</title><path d="M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z"></path></svg>
|
|
@@ -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,7 @@
|
|
|
1
|
+
<svg fill="currentColor" viewBox="-11.8 -11.8 55.6 55.6" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<title>Munito</title>
|
|
3
|
+
<path d="M8 0h24v1h-24zM7 1h24v1h-24zM6 2h24v1h-24zM5 3h24v1h-24zM4 4h24v1h-24zM3 5h24v1h-24zM2 6h24v1h-24zM1 7h24v1h-24z" opacity=".55"/>
|
|
4
|
+
<path d="M0 8h24v1h-24zM0 9h24v1h-24zM0 10h24v1h-24zM0 11h24v1h-24zM0 12h24v1h-24zM0 13h24v1h-24zM0 14h24v1h-24zM0 15h24v1h-24zM0 16h6v1h-6zM10 16h4v1h-4zM18 16h6v1h-6zM0 17h6v1h-6zM10 17h4v1h-4zM18 17h6v1h-6zM0 18h6v1h-6zM10 18h4v1h-4zM18 18h6v1h-6zM0 19h6v1h-6zM10 19h4v1h-4zM18 19h6v1h-6zM0 20h6v1h-6zM10 20h4v1h-4zM18 20h6v1h-6zM0 21h6v1h-6zM10 21h4v1h-4zM18 21h6v1h-6zM0 22h24v1h-24zM0 23h24v1h-24zM0 24h24v1h-24zM0 25h24v1h-24zM0 26h24v1h-24zM0 27h24v1h-24zM0 28h24v1h-24zM0 29h24v1h-24zM0 30h24v1h-24zM0 31h24v1h-24z"/>
|
|
5
|
+
<path d="M31 1h1v1h-1zM30 2h2v1h-2zM29 3h3v1h-3zM28 4h4v1h-4zM27 5h5v1h-5zM26 6h6v1h-6zM25 7h7v1h-7zM24 8h6v1h-6zM31 8h1v1h-1zM24 9h6v1h-6zM31 9h1v1h-1zM24 10h4v1h-4zM29 10h1v1h-1zM31 10h1v1h-1zM24 11h3v1h-3zM29 11h1v1h-1zM31 11h1v1h-1zM24 12h2v1h-2zM29 12h1v1h-1zM31 12h1v1h-1zM24 13h2v1h-2zM27 13h1v1h-1zM29 13h1v1h-1zM31 13h1v1h-1zM24 14h2v1h-2zM27 14h1v1h-1zM29 14h1v1h-1zM31 14h1v1h-1zM24 15h2v1h-2zM29 15h1v1h-1zM31 15h1v1h-1zM24 16h2v1h-2zM29 16h1v1h-1zM31 16h1v1h-1zM24 17h2v1h-2zM27 17h1v1h-1zM29 17h1v1h-1zM31 17h1v1h-1zM24 18h2v1h-2zM27 18h1v1h-1zM29 18h3v1h-3zM24 19h2v1h-2zM27 19h1v1h-1zM29 19h3v1h-3zM24 20h2v1h-2zM27 20h5v1h-5zM24 21h2v1h-2zM27 21h5v1h-5zM24 22h8v1h-8zM24 23h8v1h-8zM24 24h7v1h-7zM24 25h6v1h-6zM24 26h5v1h-5zM24 27h4v1h-4zM24 28h3v1h-3zM24 29h2v1h-2zM24 30h1v1h-1z" opacity=".35"/>
|
|
6
|
+
<path d="M30 8h1v1h-1zM30 9h1v1h-1zM28 10h1v1h-1zM30 10h1v1h-1zM27 11h2v1h-2zM30 11h1v1h-1zM26 12h3v1h-3zM30 12h1v1h-1zM26 13h1v1h-1zM28 13h1v1h-1zM30 13h1v1h-1zM26 14h1v1h-1zM28 14h1v1h-1zM30 14h1v1h-1zM26 15h3v1h-3zM30 15h1v1h-1zM26 16h3v1h-3zM30 16h1v1h-1zM26 17h1v1h-1zM28 17h1v1h-1zM30 17h1v1h-1zM26 18h1v1h-1zM28 18h1v1h-1zM26 19h1v1h-1zM28 19h1v1h-1zM26 20h1v1h-1zM26 21h1v1h-1z" opacity=".8"/>
|
|
7
|
+
</svg>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
|
|
2
|
+
globalThis.__usagestat_bundled_options = {"labels":["Daily spend limit","Monthly spend limit","Additional"],"defaults":{},"autoMode":"api"};
|
|
3
|
+
(function(defineProvider) {
|
|
4
|
+
// BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/munito.js
|
|
5
|
+
function _nullishCoalesce(lhs, rhsFn) {
|
|
6
|
+
if (lhs != null) {
|
|
7
|
+
return lhs;
|
|
8
|
+
} else {
|
|
9
|
+
return rhsFn();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
defineProvider({
|
|
13
|
+
id: "munito",
|
|
14
|
+
name: "Munito",
|
|
15
|
+
endpoints: ["https://api.munito.ai"],
|
|
16
|
+
auth: { type: "bearer", secret: "MUNITO_API_KEY" },
|
|
17
|
+
settings: [{ key: "MUNITO_API_KEY", title: "Munito admin API key", type: "secure" }],
|
|
18
|
+
capabilities: ["http-status"],
|
|
19
|
+
async fetchUsage(ctx) {
|
|
20
|
+
const base = "https://api.munito.ai/admin/v1";
|
|
21
|
+
const response = await ctx.http.getWithOptional(`${base}/limits`, `${base}/organization`, {
|
|
22
|
+
retryPolicy: "transientIdempotent",
|
|
23
|
+
});
|
|
24
|
+
const message = `Munito returned HTTP ${response.status}.`;
|
|
25
|
+
if (response.status === 401) throw ctx.fail.authenticationExpired(message);
|
|
26
|
+
if (response.status === 403) {
|
|
27
|
+
throw ctx.fail.permissionDenied(
|
|
28
|
+
"Munito rejected the key: the Admin API needs a key with Read account data permission.",
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
// The native transientIdempotent retry already honors Retry-After; an explicit retry hint
|
|
32
|
+
// here would schedule a second, outer retry cycle (docs/plugins.md plugin retry contract).
|
|
33
|
+
if (response.status === 429) throw ctx.fail.rateLimited(message);
|
|
34
|
+
if (response.status >= 500) throw ctx.fail.providerUnavailable(message);
|
|
35
|
+
if (response.status !== 200) throw ctx.fail.apiFailure(message);
|
|
36
|
+
const fail = () => {
|
|
37
|
+
throw ctx.fail.parseFailure("Munito returned an unrecognized spend limits response.");
|
|
38
|
+
};
|
|
39
|
+
let root;
|
|
40
|
+
try {
|
|
41
|
+
root = JSON.parse(response.bodyText);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
void error;
|
|
44
|
+
return fail();
|
|
45
|
+
}
|
|
46
|
+
if (!root || typeof root !== "object" || Array.isArray(root)) return fail();
|
|
47
|
+
const body = root;
|
|
48
|
+
const text = (value) => (typeof value === "string" && value.trim() ? value.trim() : undefined);
|
|
49
|
+
const money = (value, field) => {
|
|
50
|
+
const number =
|
|
51
|
+
typeof value === "number"
|
|
52
|
+
? value
|
|
53
|
+
: typeof value === "string" && /^\s*-?\d+(?:\.\d+)?\s*$/.test(value)
|
|
54
|
+
? Number(value)
|
|
55
|
+
: NaN;
|
|
56
|
+
if (!Number.isFinite(number) || number < 0) {
|
|
57
|
+
throw ctx.fail.parseFailure(`Munito returned an unusable ${field}.`);
|
|
58
|
+
}
|
|
59
|
+
return number;
|
|
60
|
+
};
|
|
61
|
+
const limit = (value, field) => (value == null ? undefined : money(value, field));
|
|
62
|
+
if (!Array.isArray(body.periods)) return fail();
|
|
63
|
+
|
|
64
|
+
const periods = [];
|
|
65
|
+
for (const raw of body.periods) {
|
|
66
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return fail();
|
|
67
|
+
const entry = raw;
|
|
68
|
+
const kind = text(entry.period);
|
|
69
|
+
if (kind !== "day" && kind !== "month") continue;
|
|
70
|
+
const stopped = text(entry.stopped_until);
|
|
71
|
+
let stoppedUntil;
|
|
72
|
+
if (stopped) {
|
|
73
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(stopped)) return fail();
|
|
74
|
+
try {
|
|
75
|
+
stoppedUntil = ctx.date.iso(stopped);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
void error;
|
|
78
|
+
return fail();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
periods.push({
|
|
82
|
+
period: kind,
|
|
83
|
+
spent: money(entry.spent_usd, `${kind} spend`),
|
|
84
|
+
limit: limit(entry.limit_usd, `${kind} limit`),
|
|
85
|
+
organizationLimit: limit(entry.organization_limit_usd, `${kind} organization limit`),
|
|
86
|
+
accountLimit: limit(entry.account_limit_usd, `${kind} account limit`),
|
|
87
|
+
stoppedUntil,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const find = (kind) => periods.find((entry) => entry.period === kind);
|
|
91
|
+
const day = find("day");
|
|
92
|
+
const month = find("month");
|
|
93
|
+
// The organization is a best-effort companion read; spend and limits stay authoritative.
|
|
94
|
+
let organization;
|
|
95
|
+
if (response.optional && response.optional.status === 200) {
|
|
96
|
+
try {
|
|
97
|
+
const parsed = JSON.parse(response.optional.bodyText);
|
|
98
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) organization = parsed;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
void error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const usageTier = _nullishCoalesce(text(body.usage_tier), () =>
|
|
104
|
+
organization ? text(organization.usage_tier) : undefined,
|
|
105
|
+
);
|
|
106
|
+
const rows = [];
|
|
107
|
+
const moneyRow = (label, entry) => {
|
|
108
|
+
const spend = ctx.format.usd(entry.spent);
|
|
109
|
+
rows.push({
|
|
110
|
+
label,
|
|
111
|
+
value: entry.limit && entry.limit > 0 ? `${spend} of ${ctx.format.usd(entry.limit)}` : spend,
|
|
112
|
+
progress: entry.limit && entry.limit > 0 ? Math.min(1, entry.spent / entry.limit) : undefined,
|
|
113
|
+
usageValue: entry.spent,
|
|
114
|
+
});
|
|
115
|
+
const organizational =
|
|
116
|
+
entry.organizationLimit != null && entry.organizationLimit > 0 && entry.organizationLimit !== entry.limit
|
|
117
|
+
? entry.organizationLimit
|
|
118
|
+
: undefined;
|
|
119
|
+
const account =
|
|
120
|
+
entry.accountLimit != null && entry.accountLimit > 0 && entry.accountLimit !== entry.limit
|
|
121
|
+
? entry.accountLimit
|
|
122
|
+
: undefined;
|
|
123
|
+
if (organizational != null) {
|
|
124
|
+
rows.push({ label: `${label} organization limit`, value: ctx.format.usd(organizational) });
|
|
125
|
+
}
|
|
126
|
+
if (account != null) {
|
|
127
|
+
rows.push({ label: `${label} account limit`, value: ctx.format.usd(account) });
|
|
128
|
+
}
|
|
129
|
+
if (entry.stoppedUntil) rows.push({ label: `${label} stopped until`, value: entry.stoppedUntil.toISOString() });
|
|
130
|
+
};
|
|
131
|
+
if (day) moneyRow("Today", day);
|
|
132
|
+
if (month) moneyRow("This month", month);
|
|
133
|
+
if (usageTier) rows.push({ label: "Usage tier", value: usageTier });
|
|
134
|
+
const details = [];
|
|
135
|
+
if (rows.length) details.push({ title: "Spend limits", rows });
|
|
136
|
+
const organizationRows = [];
|
|
137
|
+
if (organization) {
|
|
138
|
+
const status = text(organization.status);
|
|
139
|
+
if (status) organizationRows.push({ label: "Status", value: status.charAt(0).toUpperCase() + status.slice(1) });
|
|
140
|
+
const region = text(organization.data_region);
|
|
141
|
+
if (region) organizationRows.push({ label: "Data region", value: region });
|
|
142
|
+
if (organizationRows.length) details.push({ title: "Organization", rows: organizationRows });
|
|
143
|
+
}
|
|
144
|
+
// The identity keeps the card visible even when every period is temporarily absent;
|
|
145
|
+
// spend windows and cost appear only while Munito reports them.
|
|
146
|
+
return {
|
|
147
|
+
primary:
|
|
148
|
+
day && day.limit && day.limit > 0 ? { usedPercent: ctx.pct(day.spent, day.limit), windowMinutes: 1440 } : null,
|
|
149
|
+
secondary: month && month.limit && month.limit > 0 ? { usedPercent: ctx.pct(month.spent, month.limit) } : null,
|
|
150
|
+
cost:
|
|
151
|
+
month != null || day != null
|
|
152
|
+
? {
|
|
153
|
+
used: _nullishCoalesce(month, () => day).spent,
|
|
154
|
+
limit: _nullishCoalesce(_nullishCoalesce(month, () => day).limit, () => 0),
|
|
155
|
+
currency: "USD",
|
|
156
|
+
period: month ? "This month" : "Today",
|
|
157
|
+
}
|
|
158
|
+
: null,
|
|
159
|
+
details,
|
|
160
|
+
identity: {
|
|
161
|
+
organization: organization ? text(organization.name) : undefined,
|
|
162
|
+
accountID: organization ? text(organization.id) : undefined,
|
|
163
|
+
loginMethod: "Admin API key",
|
|
164
|
+
},
|
|
165
|
+
dataConfidence: "exact",
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// END UPSTREAM
|
|
171
|
+
})(globalThis.defineProvider);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "munito",
|
|
4
|
+
"name": "Munito",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"entry": "plugin.js",
|
|
7
|
+
"enabledByDefault": false,
|
|
8
|
+
"supportedModes": [
|
|
9
|
+
"api"
|
|
10
|
+
],
|
|
11
|
+
"autoMode": "api",
|
|
12
|
+
"usageDashboardUrl": "https://app.munito.ai",
|
|
13
|
+
"envVars": [
|
|
14
|
+
"MUNITO_API_KEY"
|
|
15
|
+
],
|
|
16
|
+
"setupFields": [],
|
|
17
|
+
"upstream": {
|
|
18
|
+
"repository": "https://github.com/steipete/CodexBar",
|
|
19
|
+
"revision": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
|
|
20
|
+
"path": "Sources/CodexBarCore/Resources/Plugins/munito.js",
|
|
21
|
+
"sha256": "6feee407bd3765acb723bca995e660ee9dc8d556e51bfdff158686e3ffaf0ffe",
|
|
22
|
+
"license": "MIT"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Peter Steinberger
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill="currentColor" d="M6.915 4.03c-1.968 0-3.683 1.28-4.871 3.113C.704 9.208 0 11.883 0 14.449c0 .706.07 1.369.21 1.973a6.624 6.624 0 0 0 .265.86 5.297 5.297 0 0 0 .371.761c.696 1.159 1.818 1.927 3.593 1.927 1.497 0 2.633-.671 3.965-2.444.76-1.012 1.144-1.626 2.663-4.32l.756-1.339.186-.325c.061.1.121.196.183.3l2.152 3.595c.724 1.21 1.665 2.556 2.47 3.314 1.046.987 1.992 1.22 3.06 1.22 1.075 0 1.876-.355 2.455-.843a3.743 3.743 0 0 0 .81-.973c.542-.939.861-2.127.861-3.745 0-2.72-.681-5.357-2.084-7.45-1.282-1.912-2.957-2.93-4.716-2.93-1.047 0-2.088.467-3.053 1.308-.652.57-1.257 1.29-1.82 2.05-.69-.875-1.335-1.547-1.958-2.056-1.182-.966-2.315-1.303-3.454-1.303zm10.16 2.053c1.147 0 2.188.758 2.992 1.999 1.132 1.748 1.647 4.195 1.647 6.4 0 1.548-.368 2.9-1.839 2.9-.58 0-1.027-.23-1.664-1.004-.496-.601-1.343-1.878-2.832-4.358l-.617-1.028a44.908 44.908 0 0 0-1.255-1.98c.07-.109.141-.224.211-.327 1.12-1.667 2.118-2.602 3.358-2.602zm-10.201.553c1.265 0 2.058.791 2.675 1.446.307.327.737.871 1.234 1.579l-1.02 1.566c-.757 1.163-1.882 3.017-2.837 4.338-1.191 1.649-1.81 1.817-2.486 1.817-.524 0-1.038-.237-1.383-.794-.263-.426-.464-1.13-.464-2.046 0-2.221.63-4.535 1.66-6.088.454-.687.964-1.226 1.533-1.533a2.264 2.264 0 0 1 1.088-.285z"/>
|
|
3
|
+
</svg>
|